git.delta.rocks / unique-network / refs/commits / 8f513946a618

difftreelog

Merge pull request #905 from UniqueNetwork/feature/astar-barrier

Yaroslav Bolyukin2023-03-30parents: #396344d #de88466.patch.diff
in: master
Configure astar barrier

21 files changed

modified.docker/Dockerfile-acala.j2diffbeforeafterboth
--- a/.docker/Dockerfile-acala.j2
+++ b/.docker/Dockerfile-acala.j2
@@ -38,4 +38,4 @@
 
 FROM ubuntu:22.04 as builder-acala
 
-COPY --from=builder-acala-bin /unique_parachain/Acala/target/production/acala /unique_parachain/Acala/target/production/acala
+COPY --from=builder-acala-bin /unique_parachain/Acala/target/production/acala /unique_parachain/acala/target/production/acala
added.docker/Dockerfile-astar.j2diffbeforeafterboth
--- /dev/null
+++ b/.docker/Dockerfile-astar.j2
@@ -0,0 +1,40 @@
+# ===== Rust builder =====
+FROM ubuntu:22.04 as rust-builder
+LABEL maintainer="Unique.Network"
+
+ENV CARGO_HOME="/cargo-home"
+ENV PATH="/cargo-home/bin:$PATH"
+ENV TZ=UTC
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+
+RUN apt-get update && \
+    apt-get install -y curl cmake pkg-config libssl-dev git clang llvm libudev-dev protobuf-compiler && \
+    apt-get clean && \
+    rm -r /var/lib/apt/lists/*
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
+
+RUN rustup toolchain uninstall $(rustup toolchain list) && \
+    rustup toolchain install {{ RUST_TOOLCHAIN }} && \
+    rustup default {{ RUST_TOOLCHAIN }} && \
+    rustup target list --installed && \
+    rustup show
+RUN rustup target add wasm32-unknown-unknown --toolchain {{ RUST_TOOLCHAIN }}
+
+RUN mkdir /unique_parachain
+WORKDIR /unique_parachain
+
+# ===== BUILD ACALA =====
+FROM rust-builder as builder-astar-bin
+
+WORKDIR /unique_parachain
+
+RUN git clone --recurse-submodules -b {{ ASTAR_BUILD_BRANCH }} --depth 1 https://github.com/AstarNetwork/Astar.git && \
+    cd Astar && \
+    cargo build --release
+
+# ===== BIN ======
+
+FROM ubuntu:22.04 as builder-astar
+
+COPY --from=builder-astar-bin /unique_parachain/Astar/target/release/astar-collator /unique_parachain/astar/target/release/astar
modified.docker/Dockerfile-xcm.j2diffbeforeafterboth
--- a/.docker/Dockerfile-xcm.j2
+++ b/.docker/Dockerfile-xcm.j2
@@ -23,6 +23,7 @@
 
 COPY ./xcm-config/launch-config-xcm-{{ NETWORK }}.json ./launch-config-xcm-{{ NETWORK }}.json
 COPY ./xcm-config/5validators.jsonnet ./5validators.jsonnet
+COPY ./xcm-config/6validators.jsonnet ./6validators.jsonnet
 
 RUN git clone -b {{ BRANCH }} https://github.com/UniqueNetwork/unique-chain.git && \
     cd unique-chain && \
@@ -50,6 +51,7 @@
 
 COPY --from=builder-unique /unique_parachain/launch-config-xcm-{{ NETWORK }}.json /polkadot-launch/
 COPY --from=builder-unique /unique_parachain/5validators.jsonnet /polkadot-launch/5validators.jsonnet
+COPY --from=builder-unique /unique_parachain/6validators.jsonnet /polkadot-launch/6validators.jsonnet
 
 COPY --from=builder-unique /unique_parachain/unique-chain/target/release/unique-collator /unique-chain/target/release/
 
@@ -57,6 +59,7 @@
 COPY --from=uniquenetwork/builder-moonbeam:{{ MOONBEAM_BUILD_BRANCH }} /unique_parachain/moonbeam/target/release/moonbeam /moonbeam/target/release/
 COPY --from=uniquenetwork/builder-cumulus:{{ CUMULUS_BUILD_BRANCH }} /unique_parachain/cumulus/target/release/polkadot-parachain /cumulus/target/release/cumulus
 COPY --from=uniquenetwork/builder-acala:{{ ACALA_BUILD_BRANCH }} /unique_parachain/Acala/target/production/acala /acala/target/release/
+COPY --from=uniquenetwork/builder-astar:{{ ASTAR_BUILD_BRANCH }} /unique_parachain/astar/target/release/astar /astar/target/release/
 COPY --from=uniquenetwork/builder-chainql:latest /chainql/target/release/chainql /chainql/target/release/
 
 EXPOSE 9844
@@ -65,6 +68,7 @@
 EXPOSE 9946
 EXPOSE 9947
 EXPOSE 9948
+EXPOSE 9949
 
 CMD export NVM_DIR="$HOME/.nvm" PATH="$PATH:/chainql/target/release" && \
     [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
modified.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.tempdiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.temp
+++ b/.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.temp
@@ -2,6 +2,7 @@
 FROM uniquenetwork/builder-moonbeam:{{ MOONRIVER_BUILD_BRANCH }} as moonbeam
 FROM uniquenetwork/builder-cumulus:{{ STATEMINE_BUILD_BRANCH }} as cumulus
 FROM uniquenetwork/builder-acala:{{ KARURA_BUILD_BRANCH }} as acala
+FROM uniquenetwork/builder-astar:{{ SHIDEN_BUILD_BRANCH }} as astar
 
 # ===== Rust builder =====
 FROM ubuntu:22.04 as rust-builder
@@ -62,13 +63,14 @@
     yarn install
 
 COPY --from=builder-unique /unique_parachain/.docker/additional/xcm-rococo/launch-config-xcm-quartz-rococo.json /polkadot-launch/launch-config.json
-COPY --from=builder-unique /unique_parachain/.docker/xcm-config/5validators.jsonnet /polkadot-launch/5validators.jsonnet
+COPY --from=builder-unique /unique_parachain/.docker/xcm-config/6validators.jsonnet /polkadot-launch/6validators.jsonnet
 
 COPY --from=builder-unique /unique_parachain/target/release/unique-collator /unique-chain/target/release/
 COPY --from=polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/
 COPY --from=moonbeam /unique_parachain/moonbeam/target/release/moonbeam /moonbeam/target/release/
 COPY --from=cumulus /unique_parachain/cumulus/target/release/polkadot-parachain /cumulus/target/release/cumulus
 COPY --from=acala /unique_parachain/Acala/target/production/acala /acala/target/release/
+COPY --from=astar /unique_parachain/astar/target/release/astar /astar/target/release/
 COPY --from=uniquenetwork/builder-chainql:latest /chainql/target/release/chainql /chainql/target/release/
 
 EXPOSE 9844
@@ -76,6 +78,7 @@
 EXPOSE 9946
 EXPOSE 9947
 EXPOSE 9948
+EXPOSE 9949
 
 CMD export NVM_DIR="$HOME/.nvm" PATH="$PATH:/chainql/target/release" && \
     [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
modified.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.tempdiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.temp
+++ b/.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.temp
@@ -2,6 +2,7 @@
 FROM uniquenetwork/builder-moonbeam:{{ MOONBEAM_BUILD_BRANCH }} as moonbeam
 FROM uniquenetwork/builder-cumulus:{{ STATEMINT_BUILD_BRANCH }} as cumulus
 FROM uniquenetwork/builder-acala:{{ ACALA_BUILD_BRANCH }} as acala
+FROM uniquenetwork/builder-astar:{{ ASTAR_BUILD_BRANCH }} as astar
 
 # ===== Rust builder =====
 FROM ubuntu:22.04 as rust-builder
@@ -62,13 +63,14 @@
     yarn install
 
 COPY --from=builder-unique /unique_parachain/.docker/additional/xcm-rococo/launch-config-xcm-unique-rococo.json /polkadot-launch/launch-config.json
-COPY --from=builder-unique /unique_parachain/.docker/xcm-config/5validators.jsonnet /polkadot-launch/5validators.jsonnet
+COPY --from=builder-unique /unique_parachain/.docker/xcm-config/6validators.jsonnet /polkadot-launch/6validators.jsonnet
 
 COPY --from=builder-unique /unique_parachain/target/release/unique-collator /unique-chain/target/release/
 COPY --from=polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/
 COPY --from=moonbeam /unique_parachain/moonbeam/target/release/moonbeam /moonbeam/target/release/
 COPY --from=cumulus /unique_parachain/cumulus/target/release/polkadot-parachain /cumulus/target/release/cumulus
 COPY --from=acala /unique_parachain/Acala/target/production/acala /acala/target/release/
+COPY --from=astar /unique_parachain/astar/target/release/astar /astar/target/release/
 COPY --from=uniquenetwork/builder-chainql:latest /chainql/target/release/chainql /chainql/target/release/
 
 EXPOSE 9844
@@ -76,6 +78,7 @@
 EXPOSE 9946
 EXPOSE 9947
 EXPOSE 9948
+EXPOSE 9949
 
 CMD export NVM_DIR="$HOME/.nvm" PATH="$PATH:/chainql/target/release" && \
     [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
modified.docker/additional/xcm-rococo/docker-compose-xcm-quartz-rococo.ymldiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/docker-compose-xcm-quartz-rococo.yml
+++ b/.docker/additional/xcm-rococo/docker-compose-xcm-quartz-rococo.yml
@@ -13,10 +13,12 @@
       - 9946
       - 9947
       - 9948
+      - 9949
     ports:
       - 127.0.0.1:9844:9844
       - 127.0.0.1:9944:9944
       - 127.0.0.1:9946:9946
       - 127.0.0.1:9947:9947
       - 127.0.0.1:9948:9948
+      - 127.0.0.1:9949:9949
 
modified.docker/additional/xcm-rococo/docker-compose-xcm-unique-rococo.ymldiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/docker-compose-xcm-unique-rococo.yml
+++ b/.docker/additional/xcm-rococo/docker-compose-xcm-unique-rococo.yml
@@ -13,10 +13,12 @@
       - 9946
       - 9947
       - 9948
+      - 9949
     ports:
       - 127.0.0.1:9844:9844
       - 127.0.0.1:9944:9944
       - 127.0.0.1:9946:9946
       - 127.0.0.1:9947:9947
       - 127.0.0.1:9948:9948
+      - 127.0.0.1:9949:9949
 
modified.docker/additional/xcm-rococo/launch-config-xcm-quartz-rococo.jsondiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/launch-config-xcm-quartz-rococo.json
+++ b/.docker/additional/xcm-rococo/launch-config-xcm-quartz-rococo.json
@@ -5,7 +5,7 @@
         "chainInitializer": [
                 "chainql",
                 "--tla-code=spec=import '${spec}'",
-                "5validators.jsonnet"
+                "6validators.jsonnet"
             ],	
         "nodes": [
             {
@@ -62,8 +62,18 @@
                     "--unsafe-ws-external",
                     "-lparachain::candidate_validation=debug"
                 ]
+            },
+            {
+                "name": "ferdie",
+                "wsPort": 9899,
+                "rpcPort": 9898,
+                "port": 30999,
+                "flags": [
+                    "--unsafe-rpc-external",
+                    "--unsafe-ws-external",
+                    "-lparachain::candidate_validation=debug"
+                ]
             }
-
         ],
         "genesis": {
             "runtime": {
@@ -155,6 +165,23 @@
                     ]
                 }
             ]
+        },
+        {
+            "bin": "/astar/target/release/astar",
+            "id": "2007",
+            "chain": "shiden-dev",
+            "balance": "1000000000000000000000000",
+            "nodes": [
+                {
+                    "wsPort": 9949,
+                    "port": 31205,
+                    "name": "alice",
+                    "flags": [
+                       "--unsafe-rpc-external",
+                       "--unsafe-ws-external"
+                    ]
+                }
+            ]
         }
     ],
     "simpleParachains": [],
@@ -194,7 +221,19 @@
             "recipient": 2095,
             "maxCapacity": 8,
             "maxMessageSize": 512
-        }
+        },
+        {
+            "sender": 2007,
+            "recipient": 2095,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        },
+        {
+            "sender": 2095,
+            "recipient": 2007,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        }  
     ],
     "finalization": false
 }
modified.docker/additional/xcm-rococo/launch-config-xcm-unique-rococo.jsondiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/launch-config-xcm-unique-rococo.json
+++ b/.docker/additional/xcm-rococo/launch-config-xcm-unique-rococo.json
@@ -5,7 +5,7 @@
         "chainInitializer": [
                 "chainql",
                 "--tla-code=spec=import '${spec}'",
-                "5validators.jsonnet"
+                "6validators.jsonnet"
             ],	
         "nodes": [
             {
@@ -62,8 +62,18 @@
                     "--unsafe-ws-external",
                     "-lparachain::candidate_validation=debug"
                 ]
+            },
+            {
+                "name": "ferdie",
+                "wsPort": 9899,
+                "rpcPort": 9898,
+                "port": 30999,
+                "flags": [
+                    "--unsafe-rpc-external",
+                    "--unsafe-ws-external",
+                    "-lparachain::candidate_validation=debug"
+                ]
             }
-
         ],
         "genesis": {
             "runtime": {
@@ -155,6 +165,23 @@
 		    ]
                 }
             ]
+        },
+        {
+            "bin": "/astar/target/release/astar",
+            "id": "2006",
+            "chain": "astar-dev",
+            "balance": "1000000000000000000000000",
+            "nodes": [
+                {
+                    "wsPort": 9949,
+                    "port": 31205,
+                    "name": "alice",
+                    "flags": [
+                       "--unsafe-rpc-external",
+                       "--unsafe-ws-external"
+                    ]
+                }
+            ]
         }
     ],
     "simpleParachains": [],
@@ -194,7 +221,19 @@
             "recipient": 2037,
             "maxCapacity": 8,
             "maxMessageSize": 512
-        }
+        },
+        {
+            "sender": 2006,
+            "recipient": 2037,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        },
+        {
+            "sender": 2037,
+            "recipient": 2006,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        }     
     ],
     "finalization": false
 }
modified.docker/docker-compose.tmp-xcm-tests.j2diffbeforeafterboth
--- a/.docker/docker-compose.tmp-xcm-tests.j2
+++ b/.docker/docker-compose.tmp-xcm-tests.j2
@@ -11,6 +11,7 @@
       - 9946
       - 9947
       - 9948
+      - 9949
     ports:
       - 127.0.0.1:9844:9844
       - 127.0.0.1:9933:9933      
@@ -18,6 +19,7 @@
       - 127.0.0.1:9946:9946
       - 127.0.0.1:9947:9947
       - 127.0.0.1:9948:9948
+      - 127.0.0.1:9949:9949
     logging:
       options:
         max-size: "1m"
added.docker/xcm-config/6validators.jsonnetdiffbeforeafterboth
--- /dev/null
+++ b/.docker/xcm-config/6validators.jsonnet
@@ -0,0 +1,57 @@
+
+function(spec)
+  spec {
+    genesis+: {
+      runtime+: {
+        staking+: {
+          validatorCount: 6,
+          invulnerables: [
+            '5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY',
+            '5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc',
+            '5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT',
+            '5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8',
+            '5FCfAonRZgTFrTd9HREEyeJjDpT397KMzizE6T3DvebLFE7n',
+            '5CRmqmsiNFExV6VbdmPJViVxrWmkaXXvBrSX8oqBT8R9vmWk',
+          ],
+          stakers: [
+            [
+              '5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY',
+              '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
+              100000000000000,
+              'Validator',
+            ],
+            [
+              '5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc',
+              '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
+              100000000000000,
+              'Validator',
+            ],
+            [
+              '5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT',
+              '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y',
+              100000000000000,
+              'Validator',
+            ],
+            [
+              '5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8',
+              '5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy',
+              100000000000000,
+              'Validator',
+            ],
+            [
+              '5FCfAonRZgTFrTd9HREEyeJjDpT397KMzizE6T3DvebLFE7n',
+              '5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw',
+              100000000000000,
+              'Validator',
+            ],
+            [
+              '5CRmqmsiNFExV6VbdmPJViVxrWmkaXXvBrSX8oqBT8R9vmWk',
+              '5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL',
+              100000000000000,
+              'Validator',
+            ],
+          ],
+        },
+      },
+    },
+  }
modified.docker/xcm-config/launch-config-xcm-quartz.j2diffbeforeafterboth
--- a/.docker/xcm-config/launch-config-xcm-quartz.j2
+++ b/.docker/xcm-config/launch-config-xcm-quartz.j2
@@ -5,7 +5,7 @@
         "chainInitializer": [
                 "chainql",
                 "--tla-code=spec=import '${spec}'",
-                "5validators.jsonnet"
+                "6validators.jsonnet"
             ],	
         "nodes": [
             {
@@ -62,8 +62,18 @@
                     "--unsafe-ws-external",
                     "-lparachain::candidate_validation=debug"
                 ]
+            },
+            {
+                "name": "ferdie",
+                "wsPort": 9899,
+                "rpcPort": 9898,
+                "port": 30999,
+                "flags": [
+                    "--unsafe-rpc-external",
+                    "--unsafe-ws-external",
+                    "-lparachain::candidate_validation=debug"
+                ]
             }
-
         ],
         "genesis": {
             "runtime": {
@@ -155,6 +165,23 @@
                     ]
                 }
             ]
+        },
+        {
+            "bin": "/astar/target/release/astar",
+            "id": "2007",
+            "chain": "shiden-dev",
+            "balance": "1000000000000000000000000",
+            "nodes": [
+                {
+                    "wsPort": 9949,
+                    "port": 31205,
+                    "name": "alice",
+                    "flags": [
+                       "--unsafe-rpc-external",
+                       "--unsafe-ws-external"
+                    ]
+                }
+            ]
         }
     ],
     "simpleParachains": [],
@@ -194,7 +221,19 @@
             "recipient": 2095,
             "maxCapacity": 8,
             "maxMessageSize": 512
-        }
+        },
+        {
+            "sender": 2007,
+            "recipient": 2095,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        },
+        {
+            "sender": 2095,
+            "recipient": 2007,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        }        
     ],
     "finalization": false
 }
modified.docker/xcm-config/launch-config-xcm-unique.j2diffbeforeafterboth
--- a/.docker/xcm-config/launch-config-xcm-unique.j2
+++ b/.docker/xcm-config/launch-config-xcm-unique.j2
@@ -5,7 +5,7 @@
         "chainInitializer": [
                 "chainql",
                 "--tla-code=spec=import '${spec}'",
-                "5validators.jsonnet"
+                "6validators.jsonnet"
             ],	
         "nodes": [
             {
@@ -62,8 +62,18 @@
                     "--unsafe-ws-external",
                     "-lparachain::candidate_validation=debug"
                 ]
-            }
-
+            },
+            {
+                "name": "ferdie",
+                "wsPort": 9899,
+                "rpcPort": 9898,
+                "port": 30999,
+                "flags": [
+                    "--unsafe-rpc-external",
+                    "--unsafe-ws-external",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            }            
         ],
         "genesis": {
             "runtime": {
@@ -93,7 +103,7 @@
                         "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
                         "--unsafe-rpc-external",
                         "--unsafe-ws-external"
-		    ]
+		            ]
                 }
             ]
         },
@@ -115,7 +125,7 @@
                     "flags": [
                         "--unsafe-rpc-external",
                         "--unsafe-ws-external"
-		    ]
+		            ]
                 }
               ]
         },
@@ -133,7 +143,7 @@
                     "flags": [
                         "--unsafe-rpc-external",
                         "--unsafe-ws-external",
-  			"--",
+  			            "--",
                         "--execution=wasm"
                     ]
                 }
@@ -152,9 +162,26 @@
                     "flags": [
                         "--unsafe-rpc-external",
                         "--unsafe-ws-external"
-		    ]
+		            ]
                 }
             ]
+        },
+        {
+            "bin": "/astar/target/release/astar",
+            "id": "2006",
+            "chain": "astar-dev",
+            "balance": "1000000000000000000000000",
+            "nodes": [
+                {
+                    "wsPort": 9949,
+                    "port": 31205,
+                    "name": "alice",
+                    "flags": [
+                       "--unsafe-rpc-external",
+                       "--unsafe-ws-external"
+                    ]
+                }
+            ]
         }
     ],
     "simpleParachains": [],
@@ -194,7 +221,19 @@
             "recipient": 2037,
             "maxCapacity": 8,
             "maxMessageSize": 512
-        }
+        },
+        {
+            "sender": 2006,
+            "recipient": 2037,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        },
+        {
+            "sender": 2037,
+            "recipient": 2006,
+            "maxCapacity": 8,
+            "maxMessageSize": 512
+        }        
     ],
     "finalization": false
 }
modified.envdiffbeforeafterboth
--- a/.env
+++ b/.env
@@ -7,6 +7,7 @@
 STATEMINT_BUILD_BRANCH=release-parachains-v9370
 ACALA_BUILD_BRANCH=2.12.0
 MOONBEAM_BUILD_BRANCH=runtime-2100
+ASTAR_BUILD_BRANCH=v4.49.0
 UNIQUE_MAINNET_BRANCH=release-v930033-fix-gas-price
 UNIQUE_REPLICA_FROM=wss://ws.unique.network:443
 
@@ -14,6 +15,7 @@
 STATEMINE_BUILD_BRANCH=release-parachains-v9370
 KARURA_BUILD_BRANCH=release-karura-2.15.0
 MOONRIVER_BUILD_BRANCH=runtime-2201
+SHIDEN_BUILD_BRANCH=v4.49.0
 QUARTZ_MAINNET_BRANCH=release-v930034-fix-gas-price
 QUARTZ_REPLICA_FROM=wss://ws-quartz.unique.network:443
 
modified.github/workflows/xcm.ymldiffbeforeafterboth
--- a/.github/workflows/xcm.yml
+++ b/.github/workflows/xcm.yml
@@ -18,7 +18,7 @@
 
     name: Prepare execution matrix
 
-    runs-on: [XL]
+    runs-on: [self-hosted-ci]
     outputs:
       matrix: ${{ steps.create_matrix.outputs.matrix }}
 
@@ -41,8 +41,8 @@
         with:
           matrix: |
             network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.WESTMINT_BUILD_BRANCH }}}, runtest {testXcmOpal}
-            network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, runtest {testXcmQuartz}
-            network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, runtest {testXcmUnique}
+            network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, astar_version {${{ env.SHIDEN_BUILD_BRANCH }}}, runtest {testXcmQuartz}
+            network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, astar_version {${{ env.ASTAR_BUILD_BRANCH }}}, runtest {testXcmUnique}
 
   xcm-build:
     
@@ -184,7 +184,6 @@
             fi
         shell: bash
 
-
       # Check CUMULUS version and build it if it doesn't exist in repository
       - name: Generate ENV related extend Dockerfile file for CUMULUS
         uses: cuchi/jinja2-action@v1.2.0
@@ -218,6 +217,41 @@
             fi
         shell: bash
 
+
+      # Check ASTAR version and build it if it doesn't exist in repository
+      - name: Generate ENV related extend Dockerfile file for ASTAR
+        uses: cuchi/jinja2-action@v1.2.0
+        with:
+          template: .docker/Dockerfile-astar.j2
+          output_file: .docker/Dockerfile-astar.${{ matrix.astar_version }}.yml
+          variables: |
+            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
+            ASTAR_BUILD_BRANCH=${{ matrix.astar_version }}
+
+      - name: Check if the dockerhub repository contains the needed ASTAR version
+        run: |
+          # aquire token
+            TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
+            export TOKEN=$TOKEN
+
+          # Get TAGS from DOCKERHUB repository
+            ASTAR_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-astar/tags/?page_size=100 | jq -r '."results"[]["name"]')
+          # Show TAGS
+            echo "ASTAR TAGS:"
+            echo $ASTAR_TAGS
+          # Check correct version ASTAR and build it if it doesn't exist in ASTAR TAGS
+            if [[ ${ASTAR_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.astar_version }}"($|[[:space:]]) ]]; then
+                echo "Repository has needed ASTAR version";
+                docker pull uniquenetwork/builder-astar:${{ matrix.astar_version }}
+            else
+                echo "Repository has not needed ASTAR version, so build it";
+                cd .docker/ && docker build --no-cache --file ./Dockerfile-astar.${{ matrix.astar_version }}.yml --tag uniquenetwork/builder-astar:${{ matrix.astar_version }} .
+                echo "Push needed ASTAR version to the repository";
+                docker push uniquenetwork/builder-astar:${{ matrix.astar_version }}
+            fi
+        shell: bash
+
+
       - name: Generate ENV related extend launch-config file
         uses: cuchi/jinja2-action@v1.2.0
         with:
@@ -242,6 +276,7 @@
             POLKADOT_LAUNCH_BRANCH=${{ env.POLKADOT_LAUNCH_BRANCH }}           
             BRANCH=${{ github.head_ref }}
             ACALA_BUILD_BRANCH=${{ matrix.acala_version }}
+            ASTAR_BUILD_BRANCH=${{ matrix.astar_version }}
             MOONBEAM_BUILD_BRANCH=${{ matrix.moonbeam_version }}
             CUMULUS_BUILD_BRANCH=${{ matrix.cumulus_version }}
 
modifiedtests/src/config.tsdiffbeforeafterboth
--- a/tests/src/config.ts
+++ b/tests/src/config.ts
@@ -24,6 +24,8 @@
   karuraUrl: process.env.acalaUrl || 'ws://127.0.0.1:9946',
   moonbeamUrl: process.env.moonbeamUrl || 'ws://127.0.0.1:9947',
   moonriverUrl: process.env.moonbeamUrl || 'ws://127.0.0.1:9947',
+  astarUrl: process.env.astarUrl || 'ws://127.0.0.1:9949',
+  shidenUrl: process.env.shidenUrl || 'ws://127.0.0.1:9949',
   westmintUrl: process.env.westmintUrl || 'ws://127.0.0.1:9948',
   statemineUrl: process.env.statemineUrl || 'ws://127.0.0.1:9948',
   statemintUrl: process.env.statemintUrl || 'ws://127.0.0.1:9948',
modifiedtests/src/util/index.tsdiffbeforeafterboth
--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -11,7 +11,7 @@
 import config from '../config';
 import {ChainHelperBase} from './playgrounds/unique';
 import {ILogger} from './playgrounds/types';
-import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper, DevStatemineHelper, DevStatemintHelper} from './playgrounds/unique.dev';
+import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper, DevStatemineHelper, DevStatemintHelper, DevAstarHelper, DevShidenHelper} from './playgrounds/unique.dev';
 import {dirname} from 'path';
 import {fileURLToPath} from 'url';
 
@@ -101,6 +101,14 @@
   return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
 };
 
+export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
+};
+
+export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
+};
+
 export const MINIMUM_DONOR_FUND = 100_000n;
 export const DONOR_FUNDING = 2_000_000n;
 
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -3,7 +3,7 @@
 
 import {stringToU8a} from '@polkadot/util';
 import {encodeAddress, mnemonicGenerate} from '@polkadot/util-crypto';
-import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper} from './unique';
+import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper, AstarHelper} from './unique';
 import {ApiPromise, Keyring, WsProvider} from '@polkadot/api';
 import * as defs from '../../interfaces/definitions';
 import {IKeyringPair} from '@polkadot/types/types';
@@ -173,6 +173,28 @@
   }
 }
 
+export class DevAstarHelper extends AstarHelper {
+  wait: WaitGroup;
+
+  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
+    options.helperBase = options.helperBase ?? DevAstarHelper;
+
+    super(logger, options);
+    this.wait = new WaitGroup(this);
+  }
+}
+
+export class DevShidenHelper extends AstarHelper {
+  wait: WaitGroup;
+
+  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
+    options.helperBase = options.helperBase ?? DevShidenHelper;
+
+    super(logger, options);
+    this.wait = new WaitGroup(this);
+  }
+}
+
 export class DevAcalaHelper extends AcalaHelper {
   wait: WaitGroup;
 
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -3243,6 +3243,26 @@
   }
 }
 
+export class AstarHelper extends XcmChainHelper {
+  balance: SubstrateBalanceGroup<AstarHelper>;
+  assets: AssetsGroup<AstarHelper>;
+  xcm: XcmGroup<AstarHelper>;
+
+  constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
+    super(logger, options.helperBase ?? AstarHelper);
+
+    this.balance = new SubstrateBalanceGroup(this);
+    this.assets = new AssetsGroup(this);
+    this.xcm = new XcmGroup(this, 'polkadotXcm');
+  }
+
+  getSudo<T extends UniqueHelper>() {
+    // eslint-disable-next-line @typescript-eslint/naming-convention
+    const SudoHelperType = SudoHelper(this.helperBase);
+    return this.clone(SudoHelperType) as T;
+  }
+}
+
 export class AcalaHelper extends XcmChainHelper {
   balance: SubstrateBalanceGroup<AcalaHelper>;
   assetRegistry: AcalaAssetRegistryGroup;
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
before · tests/src/xcm/xcmQuartz.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {blake2AsHex} from '@polkadot/util-crypto';19import config from '../config';20import {XcmV2TraitsError} from '../interfaces';21import {itSub, expect, describeXCM, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds, usingStateminePlaygrounds} from '../util';2223const QUARTZ_CHAIN = 2095;24const STATEMINE_CHAIN = 1000;25const KARURA_CHAIN = 2000;26const MOONRIVER_CHAIN = 2023;2728const STATEMINE_PALLET_INSTANCE = 50;2930const relayUrl = config.relayUrl;31const statemineUrl = config.statemineUrl;32const karuraUrl = config.karuraUrl;33const moonriverUrl = config.moonriverUrl;3435const RELAY_DECIMALS = 12;36const STATEMINE_DECIMALS = 12;37const KARURA_DECIMALS = 12;3839const TRANSFER_AMOUNT = 2000000000000000000000000n;4041const FUNDING_AMOUNT = 3_500_000_0000_000_000n;4243const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;4445const USDT_ASSET_ID = 100;46const USDT_ASSET_METADATA_DECIMALS = 18;47const USDT_ASSET_METADATA_NAME = 'USDT';48const USDT_ASSET_METADATA_DESCRIPTION = 'USDT';49const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;50const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;5152const SAFE_XCM_VERSION = 2;5354describeXCM('[XCM] Integration test: Exchanging USDT with Statemine', () => {55  let alice: IKeyringPair;56  let bob: IKeyringPair;5758  let balanceStmnBefore: bigint;59  let balanceStmnAfter: bigint;6061  let balanceQuartzBefore: bigint;62  let balanceQuartzAfter: bigint;63  let balanceQuartzFinal: bigint;6465  let balanceBobBefore: bigint;66  let balanceBobAfter: bigint;67  let balanceBobFinal: bigint;6869  let balanceBobRelayTokenBefore: bigint;70  let balanceBobRelayTokenAfter: bigint;717273  before(async () => {74    await usingPlaygrounds(async (helper, privateKey) => {75      alice = await privateKey('//Alice');76      bob = await privateKey('//Bob'); // sovereign account on Statemine(t) funds donor7778      // Set the default version to wrap the first message to other chains.79      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);80    });8182    await usingRelayPlaygrounds(relayUrl, async (helper) => {83      // Fund accounts on Statemine(t)84      await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, alice.addressRaw, FUNDING_AMOUNT);85      await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, bob.addressRaw, FUNDING_AMOUNT);86    });8788    await usingStateminePlaygrounds(statemineUrl, async (helper) => {89      const sovereignFundingAmount = 3_500_000_000n;9091      await helper.assets.create(92        alice,93        USDT_ASSET_ID,94        alice.address,95        USDT_ASSET_METADATA_MINIMAL_BALANCE,96      );97      await helper.assets.setMetadata(98        alice,99        USDT_ASSET_ID,100        USDT_ASSET_METADATA_NAME,101        USDT_ASSET_METADATA_DESCRIPTION,102        USDT_ASSET_METADATA_DECIMALS,103      );104      await helper.assets.mint(105        alice,106        USDT_ASSET_ID,107        alice.address,108        USDT_ASSET_AMOUNT,109      );110111      // funding parachain sovereing account on Statemine(t).112      // The sovereign account should be created before any action113      // (the assets pallet on Statemine(t) check if the sovereign account exists)114      const parachainSovereingAccount = helper.address.paraSiblingSovereignAccount(QUARTZ_CHAIN);115      await helper.balance.transferToSubstrate(bob, parachainSovereingAccount, sovereignFundingAmount);116    });117118119    await usingPlaygrounds(async (helper) => {120      const location = {121        V2: {122          parents: 1,123          interior: {X3: [124            {125              Parachain: STATEMINE_CHAIN,126            },127            {128              PalletInstance: STATEMINE_PALLET_INSTANCE,129            },130            {131              GeneralIndex: USDT_ASSET_ID,132            },133          ]},134        },135      };136137      const metadata =138      {139        name: USDT_ASSET_ID,140        symbol: USDT_ASSET_METADATA_NAME,141        decimals: USDT_ASSET_METADATA_DECIMALS,142        minimalBalance: USDT_ASSET_METADATA_MINIMAL_BALANCE,143      };144      await helper.getSudo().foreignAssets.register(alice, alice.address, location, metadata);145      balanceQuartzBefore = await helper.balance.getSubstrate(alice.address);146    });147148149    // Providing the relay currency to the quartz sender account150    // (fee for USDT XCM are paid in relay tokens)151    await usingRelayPlaygrounds(relayUrl, async (helper) => {152      const destination = {153        V1: {154          parents: 0,155          interior: {X1: {156            Parachain: QUARTZ_CHAIN,157          },158          },159        }};160161      const beneficiary = {162        V1: {163          parents: 0,164          interior: {X1: {165            AccountId32: {166              network: 'Any',167              id: alice.addressRaw,168            },169          }},170        },171      };172173      const assets = {174        V1: [175          {176            id: {177              Concrete: {178                parents: 0,179                interior: 'Here',180              },181            },182            fun: {183              Fungible: TRANSFER_AMOUNT_RELAY,184            },185          },186        ],187      };188189      const feeAssetItem = 0;190191      await helper.xcm.limitedReserveTransferAssets(alice, destination, beneficiary, assets, feeAssetItem, 'Unlimited');192    });193194  });195196  itSub('Should connect and send USDT from Statemine to Quartz', async ({helper}) => {197    await usingStateminePlaygrounds(statemineUrl, async (helper) => {198      const dest = {199        V1: {200          parents: 1,201          interior: {X1: {202            Parachain: QUARTZ_CHAIN,203          },204          },205        }};206207      const beneficiary = {208        V1: {209          parents: 0,210          interior: {X1: {211            AccountId32: {212              network: 'Any',213              id: alice.addressRaw,214            },215          }},216        },217      };218219      const assets = {220        V1: [221          {222            id: {223              Concrete: {224                parents: 0,225                interior: {226                  X2: [227                    {228                      PalletInstance: STATEMINE_PALLET_INSTANCE,229                    },230                    {231                      GeneralIndex: USDT_ASSET_ID,232                    },233                  ]},234              },235            },236            fun: {237              Fungible: TRANSFER_AMOUNT,238            },239          },240        ],241      };242243      const feeAssetItem = 0;244245      balanceStmnBefore = await helper.balance.getSubstrate(alice.address);246      await helper.xcm.limitedReserveTransferAssets(alice, dest, beneficiary, assets, feeAssetItem, 'Unlimited');247248      balanceStmnAfter = await helper.balance.getSubstrate(alice.address);249250      // common good parachain take commission in it native token251      console.log(252        '[Statemine -> Quartz] transaction fees on Statemine: %s WND',253        helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, STATEMINE_DECIMALS),254      );255      expect(balanceStmnBefore > balanceStmnAfter).to.be.true;256257    });258259260    // ensure that asset has been delivered261    await helper.wait.newBlocks(3);262263    // expext collection id will be with id 1264    const free = await helper.ft.getBalance(1, {Substrate: alice.address});265266    balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);267268    console.log(269      '[Statemine -> Quartz] transaction fees on Quartz: %s USDT',270      helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, USDT_ASSET_METADATA_DECIMALS),271    );272    console.log(273      '[Statemine -> Quartz] transaction fees on Quartz: %s QTZ',274      helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore),275    );276    // commission has not paid in USDT token277    expect(free).to.be.equal(TRANSFER_AMOUNT);278    // ... and parachain native token279    expect(balanceQuartzAfter == balanceQuartzBefore).to.be.true;280  });281282  itSub('Should connect and send USDT from Quartz to Statemine back', async ({helper}) => {283    const destination = {284      V2: {285        parents: 1,286        interior: {X2: [287          {288            Parachain: STATEMINE_CHAIN,289          },290          {291            AccountId32: {292              network: 'Any',293              id: alice.addressRaw,294            },295          },296        ]},297      },298    };299300    const relayFee = 400_000_000_000_000n;301    const currencies: [any, bigint][] = [302      [303        {304          ForeignAssetId: 0,305        },306        TRANSFER_AMOUNT,307      ],308      [309        {310          NativeAssetId: 'Parent',311        },312        relayFee,313      ],314    ];315316    const feeItem = 1;317318    await helper.xTokens.transferMulticurrencies(alice, currencies, feeItem, destination, 'Unlimited');319320    // the commission has been paid in parachain native token321    balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);322    console.log('[Quartz -> Statemine] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzFinal));323    expect(balanceQuartzAfter > balanceQuartzFinal).to.be.true;324325    await usingStateminePlaygrounds(statemineUrl, async (helper) => {326      await helper.wait.newBlocks(3);327328      // The USDT token never paid fees. Its amount not changed from begin value.329      // Also check that xcm transfer has been succeeded330      expect((await helper.assets.account(USDT_ASSET_ID, alice.address))! == USDT_ASSET_AMOUNT).to.be.true;331    });332  });333334  itSub('Should connect and send Relay token to Quartz', async ({helper}) => {335    balanceBobBefore = await helper.balance.getSubstrate(bob.address);336    balanceBobRelayTokenBefore = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});337338    await usingRelayPlaygrounds(relayUrl, async (helper) => {339      const destination = {340        V1: {341          parents: 0,342          interior: {X1: {343            Parachain: QUARTZ_CHAIN,344          },345          },346        }};347348      const beneficiary = {349        V1: {350          parents: 0,351          interior: {X1: {352            AccountId32: {353              network: 'Any',354              id: bob.addressRaw,355            },356          }},357        },358      };359360      const assets = {361        V1: [362          {363            id: {364              Concrete: {365                parents: 0,366                interior: 'Here',367              },368            },369            fun: {370              Fungible: TRANSFER_AMOUNT_RELAY,371            },372          },373        ],374      };375376      const feeAssetItem = 0;377378      await helper.xcm.limitedReserveTransferAssets(bob, destination, beneficiary, assets, feeAssetItem, 'Unlimited');379    });380381    await helper.wait.newBlocks(3);382383    balanceBobAfter = await helper.balance.getSubstrate(bob.address);384    balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});385386    const wndFeeOnQuartz = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;387    const wndDiffOnQuartz = balanceBobRelayTokenAfter - balanceBobRelayTokenBefore;388    console.log(389      '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',390      helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),391    );392    console.log(393      '[Relay (Westend) -> Quartz] transaction fees: %s WND',394      helper.util.bigIntToDecimals(wndFeeOnQuartz, STATEMINE_DECIMALS),395    );396    console.log('[Relay (Westend) -> Quartz] actually delivered: %s WND', wndDiffOnQuartz);397    expect(wndFeeOnQuartz == 0n, 'No incoming WND fees should be taken').to.be.true;398    expect(balanceBobBefore == balanceBobAfter, 'No incoming QTZ fees should be taken').to.be.true;399  });400401  itSub('Should connect and send Relay token back', async ({helper}) => {402    let relayTokenBalanceBefore: bigint;403    let relayTokenBalanceAfter: bigint;404    await usingRelayPlaygrounds(relayUrl, async (helper) => {405      relayTokenBalanceBefore = await helper.balance.getSubstrate(bob.address);406    });407408    const destination = {409      V2: {410        parents: 1,411        interior: {412          X1:{413            AccountId32: {414              network: 'Any',415              id: bob.addressRaw,416            },417          },418        },419      },420    };421422    const currencies: any = [423      [424        {425          NativeAssetId: 'Parent',426        },427        TRANSFER_AMOUNT_RELAY,428      ],429    ];430431    const feeItem = 0;432433    await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, 'Unlimited');434435    balanceBobFinal = await helper.balance.getSubstrate(bob.address);436    console.log('[Quartz -> Relay (Westend)] transaction fees: %s QTZ',  helper.util.bigIntToDecimals(balanceBobAfter - balanceBobFinal));437438    await usingRelayPlaygrounds(relayUrl, async (helper) => {439      await helper.wait.newBlocks(10);440      relayTokenBalanceAfter = await helper.balance.getSubstrate(bob.address);441442      const diff = relayTokenBalanceAfter - relayTokenBalanceBefore;443      console.log('[Quartz -> Relay (Westend)] actually delivered: %s WND', helper.util.bigIntToDecimals(diff, RELAY_DECIMALS));444      expect(diff > 0, 'Relay tokens was not delivered back').to.be.true;445    });446  });447});448449describeXCM('[XCM] Integration test: Exchanging tokens with Karura', () => {450  let alice: IKeyringPair;451  let randomAccount: IKeyringPair;452453  let balanceQuartzTokenInit: bigint;454  let balanceQuartzTokenMiddle: bigint;455  let balanceQuartzTokenFinal: bigint;456  let balanceKaruraTokenInit: bigint;457  let balanceKaruraTokenMiddle: bigint;458  let balanceKaruraTokenFinal: bigint;459  let balanceQuartzForeignTokenInit: bigint;460  let balanceQuartzForeignTokenMiddle: bigint;461  let balanceQuartzForeignTokenFinal: bigint;462463  // computed by a test transfer from prod Quartz to prod Karura.464  // 2 QTZ sent https://quartz.subscan.io/xcm_message/kusama-f60d821b049f8835a3005ce7102285006f5b61e9465  // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)466  const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;467468  const KARURA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedKaruraIncomeFee;469470  before(async () => {471    await usingPlaygrounds(async (helper, privateKey) => {472      alice = await privateKey('//Alice');473      [randomAccount] = await helper.arrange.createAccounts([0n], alice);474475      // Set the default version to wrap the first message to other chains.476      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);477    });478479    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {480      const destination = {481        V1: {482          parents: 1,483          interior: {484            X1: {485              Parachain: QUARTZ_CHAIN,486            },487          },488        },489      };490491      const metadata = {492        name: 'Quartz',493        symbol: 'QTZ',494        decimals: 18,495        minimalBalance: 1000000000000000000n,496      };497498      await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);499      await helper.balance.transferToSubstrate(alice, randomAccount.address, 10000000000000n);500      balanceKaruraTokenInit = await helper.balance.getSubstrate(randomAccount.address);501      balanceQuartzForeignTokenInit = await helper.tokens.accounts(randomAccount.address, {ForeignAsset: 0});502    });503504    await usingPlaygrounds(async (helper) => {505      await helper.balance.transferToSubstrate(alice, randomAccount.address, 10n * TRANSFER_AMOUNT);506      balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccount.address);507    });508  });509510  itSub('Should connect and send QTZ to Karura', async ({helper}) => {511    const destination = {512      V2: {513        parents: 1,514        interior: {515          X1: {516            Parachain: KARURA_CHAIN,517          },518        },519      },520    };521522    const beneficiary = {523      V2: {524        parents: 0,525        interior: {526          X1: {527            AccountId32: {528              network: 'Any',529              id: randomAccount.addressRaw,530            },531          },532        },533      },534    };535536    const assets = {537      V2: [538        {539          id: {540            Concrete: {541              parents: 0,542              interior: 'Here',543            },544          },545          fun: {546            Fungible: TRANSFER_AMOUNT,547          },548        },549      ],550    };551552    const feeAssetItem = 0;553554    await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');555    balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);556557    const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;558    expect(qtzFees > 0n, 'Negative fees QTZ, looks like nothing was transferred').to.be.true;559    console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));560561    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {562      await helper.wait.newBlocks(3);563564      balanceQuartzForeignTokenMiddle = await helper.tokens.accounts(randomAccount.address, {ForeignAsset: 0});565      balanceKaruraTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);566567      const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;568      const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;569      const karUnqFees = TRANSFER_AMOUNT - qtzIncomeTransfer;570571      console.log(572        '[Quartz -> Karura] transaction fees on Karura: %s KAR',573        helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),574      );575      console.log(576        '[Quartz -> Karura] transaction fees on Karura: %s QTZ',577        helper.util.bigIntToDecimals(karUnqFees),578      );579      console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));580      expect(karFees == 0n).to.be.true;581      expect(582        karUnqFees == expectedKaruraIncomeFee,583        'Karura took different income fee, check the Karura foreign asset config',584      ).to.be.true;585    });586  });587588  itSub('Should connect to Karura and send QTZ back', async ({helper}) => {589    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {590      const destination = {591        V1: {592          parents: 1,593          interior: {594            X2: [595              {Parachain: QUARTZ_CHAIN},596              {597                AccountId32: {598                  network: 'Any',599                  id: randomAccount.addressRaw,600                },601              },602            ],603          },604        },605      };606607      const id = {608        ForeignAsset: 0,609      };610611      await helper.xTokens.transfer(randomAccount, id, KARURA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');612      balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);613      balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);614615      const karFees = balanceKaruraTokenMiddle - balanceKaruraTokenFinal;616      const qtzOutcomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenFinal;617618      console.log(619        '[Karura -> Quartz] transaction fees on Karura: %s KAR',620        helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),621      );622      console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));623624      expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;625      expect(qtzOutcomeTransfer == KARURA_BACKWARD_TRANSFER_AMOUNT).to.be.true;626    });627628    await helper.wait.newBlocks(3);629630    balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccount.address);631    const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;632    expect(actuallyDelivered > 0).to.be.true;633634    console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));635636    const qtzFees = KARURA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;637    console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));638    expect(qtzFees == 0n).to.be.true;639  });640});641642// These tests are relevant only when the foreign asset pallet is disabled643describeXCM('[XCM] Integration test: Quartz rejects non-native tokens', () => {644  let alice: IKeyringPair;645646  before(async () => {647    await usingPlaygrounds(async (helper, privateKey) => {648      alice = await privateKey('//Alice');649650      // Set the default version to wrap the first message to other chains.651      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);652    });653  });654655  itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {656    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {657      const destination = {658        V1: {659          parents: 1,660          interior: {661            X2: [662              {Parachain: QUARTZ_CHAIN},663              {664                AccountId32: {665                  network: 'Any',666                  id: alice.addressRaw,667                },668              },669            ],670          },671        },672      };673674      const id = {675        Token: 'KAR',676      };677678      await helper.xTokens.transfer(alice, id, 100_000_000_000n, destination, 'Unlimited');679    });680681    const maxWaitBlocks = 3;682683    const xcmpQueueFailEvent = await helper.wait.event(maxWaitBlocks, 'xcmpQueue', 'Fail');684685    expect(686      xcmpQueueFailEvent != null,687      '[Karura] xcmpQueue.FailEvent event is expected',688    ).to.be.true;689690    const event = xcmpQueueFailEvent!.event;691    const outcome = event.data[1] as XcmV2TraitsError;692693    expect(694      outcome.isFailedToTransactAsset,695      '[Karura] The XCM error should be `FailedToTransactAsset`',696    ).to.be.true;697  });698});699700describeXCM('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {701  // Quartz constants702  let quartzDonor: IKeyringPair;703  let quartzAssetLocation;704705  let randomAccountQuartz: IKeyringPair;706  let randomAccountMoonriver: IKeyringPair;707708  // Moonriver constants709  let assetId: string;710711  const councilVotingThreshold = 2;712  const technicalCommitteeThreshold = 2;713  const votingPeriod = 3;714  const delayPeriod = 0;715716  const quartzAssetMetadata = {717    name: 'xcQuartz',718    symbol: 'xcQTZ',719    decimals: 18,720    isFrozen: false,721    minimalBalance: 1n,722  };723724  let balanceQuartzTokenInit: bigint;725  let balanceQuartzTokenMiddle: bigint;726  let balanceQuartzTokenFinal: bigint;727  let balanceForeignQtzTokenInit: bigint;728  let balanceForeignQtzTokenMiddle: bigint;729  let balanceForeignQtzTokenFinal: bigint;730  let balanceMovrTokenInit: bigint;731  let balanceMovrTokenMiddle: bigint;732  let balanceMovrTokenFinal: bigint;733734  before(async () => {735    await usingPlaygrounds(async (helper, privateKey) => {736      quartzDonor = await privateKey('//Alice');737      [randomAccountQuartz] = await helper.arrange.createAccounts([0n], quartzDonor);738739      balanceForeignQtzTokenInit = 0n;740      741      // Set the default version to wrap the first message to other chains.742      const alice = quartzDonor;743      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);744    });745746    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {747      const alithAccount = helper.account.alithAccount();748      const baltatharAccount = helper.account.baltatharAccount();749      const dorothyAccount = helper.account.dorothyAccount();750751      randomAccountMoonriver = helper.account.create();752753      // >>> Sponsoring Dorothy >>>754      console.log('Sponsoring Dorothy.......');755      await helper.balance.transferToEthereum(alithAccount, dorothyAccount.address, 11_000_000_000_000_000_000n);756      console.log('Sponsoring Dorothy.......DONE');757      // <<< Sponsoring Dorothy <<<758759      quartzAssetLocation = {760        XCM: {761          parents: 1,762          interior: {X1: {Parachain: QUARTZ_CHAIN}},763        },764      };765      const existentialDeposit = 1n;766      const isSufficient = true;767      const unitsPerSecond = 1n;768      const numAssetsWeightHint = 0;769770      const encodedProposal = helper.assetManager.makeRegisterForeignAssetProposal({771        location: quartzAssetLocation,772        metadata: quartzAssetMetadata,773        existentialDeposit,774        isSufficient,775        unitsPerSecond,776        numAssetsWeightHint,777      });778      const proposalHash = blake2AsHex(encodedProposal);779780      console.log('Encoded proposal for registerForeignAsset & setAssetUnitsPerSecond is %s', encodedProposal);781      console.log('Encoded length %d', encodedProposal.length);782      console.log('Encoded proposal hash for batch utility after schedule is %s', proposalHash);783784      // >>> Note motion preimage >>>785      console.log('Note motion preimage.......');786      await helper.democracy.notePreimage(baltatharAccount, encodedProposal);787      console.log('Note motion preimage.......DONE');788      // <<< Note motion preimage <<<789790      // >>> Propose external motion through council >>>791      console.log('Propose external motion through council.......');792      const externalMotion = helper.democracy.externalProposeMajority({Legacy: proposalHash});793      const encodedMotion = externalMotion?.method.toHex() || '';794      const motionHash = blake2AsHex(encodedMotion);795      console.log('Motion hash is %s', motionHash);796797      await helper.collective.council.propose(baltatharAccount, councilVotingThreshold, externalMotion, externalMotion.encodedLength);798799      const councilProposalIdx = await helper.collective.council.proposalCount() - 1;800      await helper.collective.council.vote(dorothyAccount, motionHash, councilProposalIdx, true);801      await helper.collective.council.vote(baltatharAccount, motionHash, councilProposalIdx, true);802803      await helper.collective.council.close(804        dorothyAccount,805        motionHash,806        councilProposalIdx,807        {808          refTime: 1_000_000_000,809          proofSize: 1_000_000,810        },811        externalMotion.encodedLength,812      );813      console.log('Propose external motion through council.......DONE');814      // <<< Propose external motion through council <<<815816      // >>> Fast track proposal through technical committee >>>817      console.log('Fast track proposal through technical committee.......');818      const fastTrack = helper.democracy.fastTrack(proposalHash, votingPeriod, delayPeriod);819      const encodedFastTrack = fastTrack?.method.toHex() || '';820      const fastTrackHash = blake2AsHex(encodedFastTrack);821      console.log('FastTrack hash is %s', fastTrackHash);822823      await helper.collective.techCommittee.propose(alithAccount, technicalCommitteeThreshold, fastTrack, fastTrack.encodedLength);824825      const techProposalIdx = await helper.collective.techCommittee.proposalCount() - 1;826      await helper.collective.techCommittee.vote(baltatharAccount, fastTrackHash, techProposalIdx, true);827      await helper.collective.techCommittee.vote(alithAccount, fastTrackHash, techProposalIdx, true);828829      await helper.collective.techCommittee.close(830        baltatharAccount,831        fastTrackHash,832        techProposalIdx,833        {834          refTime: 1_000_000_000,835          proofSize: 1_000_000,836        },837        fastTrack.encodedLength,838      );839      console.log('Fast track proposal through technical committee.......DONE');840      // <<< Fast track proposal through technical committee <<<841842      // >>> Referendum voting >>>843      console.log('Referendum voting.......');844      await helper.democracy.referendumVote(dorothyAccount, 0, {845        balance: 10_000_000_000_000_000_000n,846        vote: {aye: true, conviction: 1},847      });848      console.log('Referendum voting.......DONE');849      // <<< Referendum voting <<<850851      // >>> Acquire Quartz AssetId Info on Moonriver >>>852      console.log('Acquire Quartz AssetId Info on Moonriver.......');853854      // Wait for the democracy execute855      await helper.wait.newBlocks(5);856857      assetId = (await helper.assetManager.assetTypeId(quartzAssetLocation)).toString();858859      console.log('QTZ asset ID is %s', assetId);860      console.log('Acquire Quartz AssetId Info on Moonriver.......DONE');861      // >>> Acquire Quartz AssetId Info on Moonriver >>>862863      // >>> Sponsoring random Account >>>864      console.log('Sponsoring random Account.......');865      await helper.balance.transferToEthereum(baltatharAccount, randomAccountMoonriver.address, 11_000_000_000_000_000_000n);866      console.log('Sponsoring random Account.......DONE');867      // <<< Sponsoring random Account <<<868869      balanceMovrTokenInit = await helper.balance.getEthereum(randomAccountMoonriver.address);870    });871872    await usingPlaygrounds(async (helper) => {873      await helper.balance.transferToSubstrate(quartzDonor, randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);874      balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccountQuartz.address);875    });876  });877878  itSub('Should connect and send QTZ to Moonriver', async ({helper}) => {879    const currencyId = {880      NativeAssetId: 'Here',881    };882    const dest = {883      V2: {884        parents: 1,885        interior: {886          X2: [887            {Parachain: MOONRIVER_CHAIN},888            {AccountKey20: {network: 'Any', key: randomAccountMoonriver.address}},889          ],890        },891      },892    };893    const amount = TRANSFER_AMOUNT;894895    await helper.xTokens.transfer(randomAccountQuartz, currencyId, amount, dest, 'Unlimited');896897    balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccountQuartz.address);898    expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;899900    const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;901    console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(transactionFees));902    expect(transactionFees > 0, 'Negative fees QTZ, looks like nothing was transferred').to.be.true;903904    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {905      await helper.wait.newBlocks(3);906907      balanceMovrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonriver.address);908909      const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;910      console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',helper.util.bigIntToDecimals(movrFees));911      expect(movrFees == 0n).to.be.true;912913      balanceForeignQtzTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonriver.address))!; // BigInt(qtzRandomAccountAsset['balance']);914      const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;915      console.log('[Quartz -> Moonriver] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));916      expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;917    });918  });919920  itSub('Should connect to Moonriver and send QTZ back', async ({helper}) => {921    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {922      const asset = {923        V1: {924          id: {925            Concrete: {926              parents: 1,927              interior: {928                X1: {Parachain: QUARTZ_CHAIN},929              },930            },931          },932          fun: {933            Fungible: TRANSFER_AMOUNT,934          },935        },936      };937      const destination = {938        V1: {939          parents: 1,940          interior: {941            X2: [942              {Parachain: QUARTZ_CHAIN},943              {AccountId32: {network: 'Any', id: randomAccountQuartz.addressRaw}},944            ],945          },946        },947      };948949      await helper.xTokens.transferMultiasset(randomAccountMoonriver, asset, destination, 'Unlimited');950951      balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);952953      const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;954      console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', helper.util.bigIntToDecimals(movrFees));955      expect(movrFees > 0, 'Negative fees MOVR, looks like nothing was transferred').to.be.true;956957      const qtzRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonriver.address);958959      expect(qtzRandomAccountAsset).to.be.null;960961      balanceForeignQtzTokenFinal = 0n;962963      const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;964      console.log('[Quartz -> Moonriver] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));965      expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;966    });967968    await helper.wait.newBlocks(3);969970    balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccountQuartz.address);971    const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;972    expect(actuallyDelivered > 0).to.be.true;973974    console.log('[Moonriver -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));975976    const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;977    console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));978    expect(qtzFees == 0n).to.be.true;979  });980});
after · tests/src/xcm/xcmQuartz.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {blake2AsHex} from '@polkadot/util-crypto';19import config from '../config';20import {XcmV2TraitsError} from '../interfaces';21import {itSub, expect, describeXCM, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds, usingStateminePlaygrounds, usingShidenPlaygrounds} from '../util';2223const QUARTZ_CHAIN = 2095;24const STATEMINE_CHAIN = 1000;25const KARURA_CHAIN = 2000;26const MOONRIVER_CHAIN = 2023;27const SHIDEN_CHAIN = 2007;2829const STATEMINE_PALLET_INSTANCE = 50;3031const relayUrl = config.relayUrl;32const statemineUrl = config.statemineUrl;33const karuraUrl = config.karuraUrl;34const moonriverUrl = config.moonriverUrl;35const shidenUrl = config.shidenUrl;3637const RELAY_DECIMALS = 12;38const STATEMINE_DECIMALS = 12;39const KARURA_DECIMALS = 12;40const SHIDEN_DECIMALS = 18n;41const QTZ_DECIMALS = 18n;4243const TRANSFER_AMOUNT = 2000000000000000000000000n;4445const FUNDING_AMOUNT = 3_500_000_0000_000_000n;4647const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;4849const USDT_ASSET_ID = 100;50const USDT_ASSET_METADATA_DECIMALS = 18;51const USDT_ASSET_METADATA_NAME = 'USDT';52const USDT_ASSET_METADATA_DESCRIPTION = 'USDT';53const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;54const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;5556const SAFE_XCM_VERSION = 2;5758describeXCM('[XCM] Integration test: Exchanging USDT with Statemine', () => {59  let alice: IKeyringPair;60  let bob: IKeyringPair;6162  let balanceStmnBefore: bigint;63  let balanceStmnAfter: bigint;6465  let balanceQuartzBefore: bigint;66  let balanceQuartzAfter: bigint;67  let balanceQuartzFinal: bigint;6869  let balanceBobBefore: bigint;70  let balanceBobAfter: bigint;71  let balanceBobFinal: bigint;7273  let balanceBobRelayTokenBefore: bigint;74  let balanceBobRelayTokenAfter: bigint;757677  before(async () => {78    await usingPlaygrounds(async (helper, privateKey) => {79      alice = await privateKey('//Alice');80      bob = await privateKey('//Bob'); // sovereign account on Statemine(t) funds donor8182      // Set the default version to wrap the first message to other chains.83      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);84    });8586    await usingRelayPlaygrounds(relayUrl, async (helper) => {87      // Fund accounts on Statemine(t)88      await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, alice.addressRaw, FUNDING_AMOUNT);89      await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, bob.addressRaw, FUNDING_AMOUNT);90    });9192    await usingStateminePlaygrounds(statemineUrl, async (helper) => {93      const sovereignFundingAmount = 3_500_000_000n;9495      await helper.assets.create(96        alice,97        USDT_ASSET_ID,98        alice.address,99        USDT_ASSET_METADATA_MINIMAL_BALANCE,100      );101      await helper.assets.setMetadata(102        alice,103        USDT_ASSET_ID,104        USDT_ASSET_METADATA_NAME,105        USDT_ASSET_METADATA_DESCRIPTION,106        USDT_ASSET_METADATA_DECIMALS,107      );108      await helper.assets.mint(109        alice,110        USDT_ASSET_ID,111        alice.address,112        USDT_ASSET_AMOUNT,113      );114115      // funding parachain sovereing account on Statemine(t).116      // The sovereign account should be created before any action117      // (the assets pallet on Statemine(t) check if the sovereign account exists)118      const parachainSovereingAccount = helper.address.paraSiblingSovereignAccount(QUARTZ_CHAIN);119      await helper.balance.transferToSubstrate(bob, parachainSovereingAccount, sovereignFundingAmount);120    });121122123    await usingPlaygrounds(async (helper) => {124      const location = {125        V2: {126          parents: 1,127          interior: {X3: [128            {129              Parachain: STATEMINE_CHAIN,130            },131            {132              PalletInstance: STATEMINE_PALLET_INSTANCE,133            },134            {135              GeneralIndex: USDT_ASSET_ID,136            },137          ]},138        },139      };140141      const metadata =142      {143        name: USDT_ASSET_ID,144        symbol: USDT_ASSET_METADATA_NAME,145        decimals: USDT_ASSET_METADATA_DECIMALS,146        minimalBalance: USDT_ASSET_METADATA_MINIMAL_BALANCE,147      };148      await helper.getSudo().foreignAssets.register(alice, alice.address, location, metadata);149      balanceQuartzBefore = await helper.balance.getSubstrate(alice.address);150    });151152153    // Providing the relay currency to the quartz sender account154    // (fee for USDT XCM are paid in relay tokens)155    await usingRelayPlaygrounds(relayUrl, async (helper) => {156      const destination = {157        V1: {158          parents: 0,159          interior: {X1: {160            Parachain: QUARTZ_CHAIN,161          },162          },163        }};164165      const beneficiary = {166        V1: {167          parents: 0,168          interior: {X1: {169            AccountId32: {170              network: 'Any',171              id: alice.addressRaw,172            },173          }},174        },175      };176177      const assets = {178        V1: [179          {180            id: {181              Concrete: {182                parents: 0,183                interior: 'Here',184              },185            },186            fun: {187              Fungible: TRANSFER_AMOUNT_RELAY,188            },189          },190        ],191      };192193      const feeAssetItem = 0;194195      await helper.xcm.limitedReserveTransferAssets(alice, destination, beneficiary, assets, feeAssetItem, 'Unlimited');196    });197198  });199200  itSub('Should connect and send USDT from Statemine to Quartz', async ({helper}) => {201    await usingStateminePlaygrounds(statemineUrl, async (helper) => {202      const dest = {203        V1: {204          parents: 1,205          interior: {X1: {206            Parachain: QUARTZ_CHAIN,207          },208          },209        }};210211      const beneficiary = {212        V1: {213          parents: 0,214          interior: {X1: {215            AccountId32: {216              network: 'Any',217              id: alice.addressRaw,218            },219          }},220        },221      };222223      const assets = {224        V1: [225          {226            id: {227              Concrete: {228                parents: 0,229                interior: {230                  X2: [231                    {232                      PalletInstance: STATEMINE_PALLET_INSTANCE,233                    },234                    {235                      GeneralIndex: USDT_ASSET_ID,236                    },237                  ]},238              },239            },240            fun: {241              Fungible: TRANSFER_AMOUNT,242            },243          },244        ],245      };246247      const feeAssetItem = 0;248249      balanceStmnBefore = await helper.balance.getSubstrate(alice.address);250      await helper.xcm.limitedReserveTransferAssets(alice, dest, beneficiary, assets, feeAssetItem, 'Unlimited');251252      balanceStmnAfter = await helper.balance.getSubstrate(alice.address);253254      // common good parachain take commission in it native token255      console.log(256        '[Statemine -> Quartz] transaction fees on Statemine: %s WND',257        helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, STATEMINE_DECIMALS),258      );259      expect(balanceStmnBefore > balanceStmnAfter).to.be.true;260261    });262263264    // ensure that asset has been delivered265    await helper.wait.newBlocks(3);266267    // expext collection id will be with id 1268    const free = await helper.ft.getBalance(1, {Substrate: alice.address});269270    balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);271272    console.log(273      '[Statemine -> Quartz] transaction fees on Quartz: %s USDT',274      helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, USDT_ASSET_METADATA_DECIMALS),275    );276    console.log(277      '[Statemine -> Quartz] transaction fees on Quartz: %s QTZ',278      helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore),279    );280    // commission has not paid in USDT token281    expect(free).to.be.equal(TRANSFER_AMOUNT);282    // ... and parachain native token283    expect(balanceQuartzAfter == balanceQuartzBefore).to.be.true;284  });285286  itSub('Should connect and send USDT from Quartz to Statemine back', async ({helper}) => {287    const destination = {288      V2: {289        parents: 1,290        interior: {X2: [291          {292            Parachain: STATEMINE_CHAIN,293          },294          {295            AccountId32: {296              network: 'Any',297              id: alice.addressRaw,298            },299          },300        ]},301      },302    };303304    const relayFee = 400_000_000_000_000n;305    const currencies: [any, bigint][] = [306      [307        {308          ForeignAssetId: 0,309        },310        TRANSFER_AMOUNT,311      ],312      [313        {314          NativeAssetId: 'Parent',315        },316        relayFee,317      ],318    ];319320    const feeItem = 1;321322    await helper.xTokens.transferMulticurrencies(alice, currencies, feeItem, destination, 'Unlimited');323324    // the commission has been paid in parachain native token325    balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);326    console.log('[Quartz -> Statemine] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzFinal));327    expect(balanceQuartzAfter > balanceQuartzFinal).to.be.true;328329    await usingStateminePlaygrounds(statemineUrl, async (helper) => {330      await helper.wait.newBlocks(3);331332      // The USDT token never paid fees. Its amount not changed from begin value.333      // Also check that xcm transfer has been succeeded334      expect((await helper.assets.account(USDT_ASSET_ID, alice.address))! == USDT_ASSET_AMOUNT).to.be.true;335    });336  });337338  itSub('Should connect and send Relay token to Quartz', async ({helper}) => {339    balanceBobBefore = await helper.balance.getSubstrate(bob.address);340    balanceBobRelayTokenBefore = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});341342    await usingRelayPlaygrounds(relayUrl, async (helper) => {343      const destination = {344        V1: {345          parents: 0,346          interior: {X1: {347            Parachain: QUARTZ_CHAIN,348          },349          },350        }};351352      const beneficiary = {353        V1: {354          parents: 0,355          interior: {X1: {356            AccountId32: {357              network: 'Any',358              id: bob.addressRaw,359            },360          }},361        },362      };363364      const assets = {365        V1: [366          {367            id: {368              Concrete: {369                parents: 0,370                interior: 'Here',371              },372            },373            fun: {374              Fungible: TRANSFER_AMOUNT_RELAY,375            },376          },377        ],378      };379380      const feeAssetItem = 0;381382      await helper.xcm.limitedReserveTransferAssets(bob, destination, beneficiary, assets, feeAssetItem, 'Unlimited');383    });384385    await helper.wait.newBlocks(3);386387    balanceBobAfter = await helper.balance.getSubstrate(bob.address);388    balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});389390    const wndFeeOnQuartz = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;391    const wndDiffOnQuartz = balanceBobRelayTokenAfter - balanceBobRelayTokenBefore;392    console.log(393      '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',394      helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),395    );396    console.log(397      '[Relay (Westend) -> Quartz] transaction fees: %s WND',398      helper.util.bigIntToDecimals(wndFeeOnQuartz, STATEMINE_DECIMALS),399    );400    console.log('[Relay (Westend) -> Quartz] actually delivered: %s WND', wndDiffOnQuartz);401    expect(wndFeeOnQuartz == 0n, 'No incoming WND fees should be taken').to.be.true;402    expect(balanceBobBefore == balanceBobAfter, 'No incoming QTZ fees should be taken').to.be.true;403  });404405  itSub('Should connect and send Relay token back', async ({helper}) => {406    let relayTokenBalanceBefore: bigint;407    let relayTokenBalanceAfter: bigint;408    await usingRelayPlaygrounds(relayUrl, async (helper) => {409      relayTokenBalanceBefore = await helper.balance.getSubstrate(bob.address);410    });411412    const destination = {413      V2: {414        parents: 1,415        interior: {416          X1:{417            AccountId32: {418              network: 'Any',419              id: bob.addressRaw,420            },421          },422        },423      },424    };425426    const currencies: any = [427      [428        {429          NativeAssetId: 'Parent',430        },431        TRANSFER_AMOUNT_RELAY,432      ],433    ];434435    const feeItem = 0;436437    await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, 'Unlimited');438439    balanceBobFinal = await helper.balance.getSubstrate(bob.address);440    console.log('[Quartz -> Relay (Westend)] transaction fees: %s QTZ',  helper.util.bigIntToDecimals(balanceBobAfter - balanceBobFinal));441442    await usingRelayPlaygrounds(relayUrl, async (helper) => {443      await helper.wait.newBlocks(10);444      relayTokenBalanceAfter = await helper.balance.getSubstrate(bob.address);445446      const diff = relayTokenBalanceAfter - relayTokenBalanceBefore;447      console.log('[Quartz -> Relay (Westend)] actually delivered: %s WND', helper.util.bigIntToDecimals(diff, RELAY_DECIMALS));448      expect(diff > 0, 'Relay tokens was not delivered back').to.be.true;449    });450  });451});452453describeXCM('[XCM] Integration test: Exchanging tokens with Karura', () => {454  let alice: IKeyringPair;455  let randomAccount: IKeyringPair;456457  let balanceQuartzTokenInit: bigint;458  let balanceQuartzTokenMiddle: bigint;459  let balanceQuartzTokenFinal: bigint;460  let balanceKaruraTokenInit: bigint;461  let balanceKaruraTokenMiddle: bigint;462  let balanceKaruraTokenFinal: bigint;463  let balanceQuartzForeignTokenInit: bigint;464  let balanceQuartzForeignTokenMiddle: bigint;465  let balanceQuartzForeignTokenFinal: bigint;466467  // computed by a test transfer from prod Quartz to prod Karura.468  // 2 QTZ sent https://quartz.subscan.io/xcm_message/kusama-f60d821b049f8835a3005ce7102285006f5b61e9469  // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)470  const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;471472  const KARURA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedKaruraIncomeFee;473474  before(async () => {475    await usingPlaygrounds(async (helper, privateKey) => {476      alice = await privateKey('//Alice');477      [randomAccount] = await helper.arrange.createAccounts([0n], alice);478479      // Set the default version to wrap the first message to other chains.480      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);481    });482483    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {484      const destination = {485        V1: {486          parents: 1,487          interior: {488            X1: {489              Parachain: QUARTZ_CHAIN,490            },491          },492        },493      };494495      const metadata = {496        name: 'Quartz',497        symbol: 'QTZ',498        decimals: 18,499        minimalBalance: 1000000000000000000n,500      };501502      await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);503      await helper.balance.transferToSubstrate(alice, randomAccount.address, 10000000000000n);504      balanceKaruraTokenInit = await helper.balance.getSubstrate(randomAccount.address);505      balanceQuartzForeignTokenInit = await helper.tokens.accounts(randomAccount.address, {ForeignAsset: 0});506    });507508    await usingPlaygrounds(async (helper) => {509      await helper.balance.transferToSubstrate(alice, randomAccount.address, 10n * TRANSFER_AMOUNT);510      balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccount.address);511    });512  });513514  itSub('Should connect and send QTZ to Karura', async ({helper}) => {515    const destination = {516      V2: {517        parents: 1,518        interior: {519          X1: {520            Parachain: KARURA_CHAIN,521          },522        },523      },524    };525526    const beneficiary = {527      V2: {528        parents: 0,529        interior: {530          X1: {531            AccountId32: {532              network: 'Any',533              id: randomAccount.addressRaw,534            },535          },536        },537      },538    };539540    const assets = {541      V2: [542        {543          id: {544            Concrete: {545              parents: 0,546              interior: 'Here',547            },548          },549          fun: {550            Fungible: TRANSFER_AMOUNT,551          },552        },553      ],554    };555556    const feeAssetItem = 0;557558    await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');559    balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);560561    const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;562    expect(qtzFees > 0n, 'Negative fees QTZ, looks like nothing was transferred').to.be.true;563    console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));564565    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {566      await helper.wait.newBlocks(3);567568      balanceQuartzForeignTokenMiddle = await helper.tokens.accounts(randomAccount.address, {ForeignAsset: 0});569      balanceKaruraTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);570571      const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;572      const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;573      const karUnqFees = TRANSFER_AMOUNT - qtzIncomeTransfer;574575      console.log(576        '[Quartz -> Karura] transaction fees on Karura: %s KAR',577        helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),578      );579      console.log(580        '[Quartz -> Karura] transaction fees on Karura: %s QTZ',581        helper.util.bigIntToDecimals(karUnqFees),582      );583      console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));584      expect(karFees == 0n).to.be.true;585      expect(586        karUnqFees == expectedKaruraIncomeFee,587        'Karura took different income fee, check the Karura foreign asset config',588      ).to.be.true;589    });590  });591592  itSub('Should connect to Karura and send QTZ back', async ({helper}) => {593    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {594      const destination = {595        V1: {596          parents: 1,597          interior: {598            X2: [599              {Parachain: QUARTZ_CHAIN},600              {601                AccountId32: {602                  network: 'Any',603                  id: randomAccount.addressRaw,604                },605              },606            ],607          },608        },609      };610611      const id = {612        ForeignAsset: 0,613      };614615      await helper.xTokens.transfer(randomAccount, id, KARURA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');616      balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);617      balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);618619      const karFees = balanceKaruraTokenMiddle - balanceKaruraTokenFinal;620      const qtzOutcomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenFinal;621622      console.log(623        '[Karura -> Quartz] transaction fees on Karura: %s KAR',624        helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),625      );626      console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));627628      expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;629      expect(qtzOutcomeTransfer == KARURA_BACKWARD_TRANSFER_AMOUNT).to.be.true;630    });631632    await helper.wait.newBlocks(3);633634    balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccount.address);635    const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;636    expect(actuallyDelivered > 0).to.be.true;637638    console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));639640    const qtzFees = KARURA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;641    console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));642    expect(qtzFees == 0n).to.be.true;643  });644});645646// These tests are relevant only when the foreign asset pallet is disabled647describeXCM('[XCM] Integration test: Quartz rejects non-native tokens', () => {648  let alice: IKeyringPair;649650  before(async () => {651    await usingPlaygrounds(async (helper, privateKey) => {652      alice = await privateKey('//Alice');653654      // Set the default version to wrap the first message to other chains.655      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);656    });657  });658659  itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {660    await usingKaruraPlaygrounds(karuraUrl, async (helper) => {661      const destination = {662        V1: {663          parents: 1,664          interior: {665            X2: [666              {Parachain: QUARTZ_CHAIN},667              {668                AccountId32: {669                  network: 'Any',670                  id: alice.addressRaw,671                },672              },673            ],674          },675        },676      };677678      const id = {679        Token: 'KAR',680      };681682      await helper.xTokens.transfer(alice, id, 100_000_000_000n, destination, 'Unlimited');683    });684685    const maxWaitBlocks = 3;686687    const xcmpQueueFailEvent = await helper.wait.event(maxWaitBlocks, 'xcmpQueue', 'Fail');688689    expect(690      xcmpQueueFailEvent != null,691      '[Karura] xcmpQueue.FailEvent event is expected',692    ).to.be.true;693694    const event = xcmpQueueFailEvent!.event;695    const outcome = event.data[1] as XcmV2TraitsError;696697    expect(698      outcome.isFailedToTransactAsset,699      '[Karura] The XCM error should be `FailedToTransactAsset`',700    ).to.be.true;701  });702});703704describeXCM('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {705  // Quartz constants706  let quartzDonor: IKeyringPair;707  let quartzAssetLocation;708709  let randomAccountQuartz: IKeyringPair;710  let randomAccountMoonriver: IKeyringPair;711712  // Moonriver constants713  let assetId: string;714715  const councilVotingThreshold = 2;716  const technicalCommitteeThreshold = 2;717  const votingPeriod = 3;718  const delayPeriod = 0;719720  const quartzAssetMetadata = {721    name: 'xcQuartz',722    symbol: 'xcQTZ',723    decimals: 18,724    isFrozen: false,725    minimalBalance: 1n,726  };727728  let balanceQuartzTokenInit: bigint;729  let balanceQuartzTokenMiddle: bigint;730  let balanceQuartzTokenFinal: bigint;731  let balanceForeignQtzTokenInit: bigint;732  let balanceForeignQtzTokenMiddle: bigint;733  let balanceForeignQtzTokenFinal: bigint;734  let balanceMovrTokenInit: bigint;735  let balanceMovrTokenMiddle: bigint;736  let balanceMovrTokenFinal: bigint;737738  before(async () => {739    await usingPlaygrounds(async (helper, privateKey) => {740      quartzDonor = await privateKey('//Alice');741      [randomAccountQuartz] = await helper.arrange.createAccounts([0n], quartzDonor);742743      balanceForeignQtzTokenInit = 0n;744      745      // Set the default version to wrap the first message to other chains.746      const alice = quartzDonor;747      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);748    });749750    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {751      const alithAccount = helper.account.alithAccount();752      const baltatharAccount = helper.account.baltatharAccount();753      const dorothyAccount = helper.account.dorothyAccount();754755      randomAccountMoonriver = helper.account.create();756757      // >>> Sponsoring Dorothy >>>758      console.log('Sponsoring Dorothy.......');759      await helper.balance.transferToEthereum(alithAccount, dorothyAccount.address, 11_000_000_000_000_000_000n);760      console.log('Sponsoring Dorothy.......DONE');761      // <<< Sponsoring Dorothy <<<762763      quartzAssetLocation = {764        XCM: {765          parents: 1,766          interior: {X1: {Parachain: QUARTZ_CHAIN}},767        },768      };769      const existentialDeposit = 1n;770      const isSufficient = true;771      const unitsPerSecond = 1n;772      const numAssetsWeightHint = 0;773774      const encodedProposal = helper.assetManager.makeRegisterForeignAssetProposal({775        location: quartzAssetLocation,776        metadata: quartzAssetMetadata,777        existentialDeposit,778        isSufficient,779        unitsPerSecond,780        numAssetsWeightHint,781      });782      const proposalHash = blake2AsHex(encodedProposal);783784      console.log('Encoded proposal for registerForeignAsset & setAssetUnitsPerSecond is %s', encodedProposal);785      console.log('Encoded length %d', encodedProposal.length);786      console.log('Encoded proposal hash for batch utility after schedule is %s', proposalHash);787788      // >>> Note motion preimage >>>789      console.log('Note motion preimage.......');790      await helper.democracy.notePreimage(baltatharAccount, encodedProposal);791      console.log('Note motion preimage.......DONE');792      // <<< Note motion preimage <<<793794      // >>> Propose external motion through council >>>795      console.log('Propose external motion through council.......');796      const externalMotion = helper.democracy.externalProposeMajority({Legacy: proposalHash});797      const encodedMotion = externalMotion?.method.toHex() || '';798      const motionHash = blake2AsHex(encodedMotion);799      console.log('Motion hash is %s', motionHash);800801      await helper.collective.council.propose(baltatharAccount, councilVotingThreshold, externalMotion, externalMotion.encodedLength);802803      const councilProposalIdx = await helper.collective.council.proposalCount() - 1;804      await helper.collective.council.vote(dorothyAccount, motionHash, councilProposalIdx, true);805      await helper.collective.council.vote(baltatharAccount, motionHash, councilProposalIdx, true);806807      await helper.collective.council.close(808        dorothyAccount,809        motionHash,810        councilProposalIdx,811        {812          refTime: 1_000_000_000,813          proofSize: 1_000_000,814        },815        externalMotion.encodedLength,816      );817      console.log('Propose external motion through council.......DONE');818      // <<< Propose external motion through council <<<819820      // >>> Fast track proposal through technical committee >>>821      console.log('Fast track proposal through technical committee.......');822      const fastTrack = helper.democracy.fastTrack(proposalHash, votingPeriod, delayPeriod);823      const encodedFastTrack = fastTrack?.method.toHex() || '';824      const fastTrackHash = blake2AsHex(encodedFastTrack);825      console.log('FastTrack hash is %s', fastTrackHash);826827      await helper.collective.techCommittee.propose(alithAccount, technicalCommitteeThreshold, fastTrack, fastTrack.encodedLength);828829      const techProposalIdx = await helper.collective.techCommittee.proposalCount() - 1;830      await helper.collective.techCommittee.vote(baltatharAccount, fastTrackHash, techProposalIdx, true);831      await helper.collective.techCommittee.vote(alithAccount, fastTrackHash, techProposalIdx, true);832833      await helper.collective.techCommittee.close(834        baltatharAccount,835        fastTrackHash,836        techProposalIdx,837        {838          refTime: 1_000_000_000,839          proofSize: 1_000_000,840        },841        fastTrack.encodedLength,842      );843      console.log('Fast track proposal through technical committee.......DONE');844      // <<< Fast track proposal through technical committee <<<845846      // >>> Referendum voting >>>847      console.log('Referendum voting.......');848      await helper.democracy.referendumVote(dorothyAccount, 0, {849        balance: 10_000_000_000_000_000_000n,850        vote: {aye: true, conviction: 1},851      });852      console.log('Referendum voting.......DONE');853      // <<< Referendum voting <<<854855      // >>> Acquire Quartz AssetId Info on Moonriver >>>856      console.log('Acquire Quartz AssetId Info on Moonriver.......');857858      // Wait for the democracy execute859      await helper.wait.newBlocks(5);860861      assetId = (await helper.assetManager.assetTypeId(quartzAssetLocation)).toString();862863      console.log('QTZ asset ID is %s', assetId);864      console.log('Acquire Quartz AssetId Info on Moonriver.......DONE');865      // >>> Acquire Quartz AssetId Info on Moonriver >>>866867      // >>> Sponsoring random Account >>>868      console.log('Sponsoring random Account.......');869      await helper.balance.transferToEthereum(baltatharAccount, randomAccountMoonriver.address, 11_000_000_000_000_000_000n);870      console.log('Sponsoring random Account.......DONE');871      // <<< Sponsoring random Account <<<872873      balanceMovrTokenInit = await helper.balance.getEthereum(randomAccountMoonriver.address);874    });875876    await usingPlaygrounds(async (helper) => {877      await helper.balance.transferToSubstrate(quartzDonor, randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);878      balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccountQuartz.address);879    });880  });881882  itSub('Should connect and send QTZ to Moonriver', async ({helper}) => {883    const currencyId = {884      NativeAssetId: 'Here',885    };886    const dest = {887      V2: {888        parents: 1,889        interior: {890          X2: [891            {Parachain: MOONRIVER_CHAIN},892            {AccountKey20: {network: 'Any', key: randomAccountMoonriver.address}},893          ],894        },895      },896    };897    const amount = TRANSFER_AMOUNT;898899    await helper.xTokens.transfer(randomAccountQuartz, currencyId, amount, dest, 'Unlimited');900901    balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccountQuartz.address);902    expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;903904    const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;905    console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(transactionFees));906    expect(transactionFees > 0, 'Negative fees QTZ, looks like nothing was transferred').to.be.true;907908    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {909      await helper.wait.newBlocks(3);910911      balanceMovrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonriver.address);912913      const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;914      console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',helper.util.bigIntToDecimals(movrFees));915      expect(movrFees == 0n).to.be.true;916917      balanceForeignQtzTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonriver.address))!; // BigInt(qtzRandomAccountAsset['balance']);918      const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;919      console.log('[Quartz -> Moonriver] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));920      expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;921    });922  });923924  itSub('Should connect to Moonriver and send QTZ back', async ({helper}) => {925    await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {926      const asset = {927        V1: {928          id: {929            Concrete: {930              parents: 1,931              interior: {932                X1: {Parachain: QUARTZ_CHAIN},933              },934            },935          },936          fun: {937            Fungible: TRANSFER_AMOUNT,938          },939        },940      };941      const destination = {942        V1: {943          parents: 1,944          interior: {945            X2: [946              {Parachain: QUARTZ_CHAIN},947              {AccountId32: {network: 'Any', id: randomAccountQuartz.addressRaw}},948            ],949          },950        },951      };952953      await helper.xTokens.transferMultiasset(randomAccountMoonriver, asset, destination, 'Unlimited');954955      balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);956957      const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;958      console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', helper.util.bigIntToDecimals(movrFees));959      expect(movrFees > 0, 'Negative fees MOVR, looks like nothing was transferred').to.be.true;960961      const qtzRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonriver.address);962963      expect(qtzRandomAccountAsset).to.be.null;964965      balanceForeignQtzTokenFinal = 0n;966967      const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;968      console.log('[Quartz -> Moonriver] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));969      expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;970    });971972    await helper.wait.newBlocks(3);973974    balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccountQuartz.address);975    const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;976    expect(actuallyDelivered > 0).to.be.true;977978    console.log('[Moonriver -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));979980    const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;981    console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));982    expect(qtzFees == 0n).to.be.true;983  });984});985986describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {987  let alice: IKeyringPair;988  let sender: IKeyringPair;989990  const QTZ_ASSET_ID_ON_SHIDEN = 1;991  const QTZ_MINIMAL_BALANCE_ON_SHIDEN = 1n;992993  // Quartz -> Shiden994  const shidenInitialBalance = 1n * (10n ** SHIDEN_DECIMALS); // 1 SHD, existential deposit required to actually create the account on Shiden995  const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?996  const qtzToShidenTransferred = 10n * (10n ** QTZ_DECIMALS); // 10 QTZ997  const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens998  const senderIinitialBalanceQTZ = 100n * (10n ** QTZ_DECIMALS); // How many QTZ sender has initially999  const senderBalanceAfterXCM = 89_946678090945539197n; // 89.94... QTZ after XCM call10001001  // Shiden -> Quartz1002  const qtzFromShidenTransfered = 5n * (10n ** QTZ_DECIMALS); // 5 QTZ1003  const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ10041005  before(async () => {1006    await usingPlaygrounds(async (helper, privateKey) => {1007      alice = await privateKey('//Alice');1008      [sender] = await helper.arrange.createAccounts([100n], alice);1009      console.log('sender', sender.address);10101011      // Set the default version to wrap the first message to other chains.1012      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);1013    });10141015    await usingShidenPlaygrounds(shidenUrl, async (helper) => {1016      console.log('1. Create foreign asset and metadata');1017      // TODO update metadata with values from production1018      await helper.assets.create(1019        alice,1020        QTZ_ASSET_ID_ON_SHIDEN,1021        alice.address,1022        QTZ_MINIMAL_BALANCE_ON_SHIDEN,1023      );10241025      await helper.assets.setMetadata(1026        alice,1027        QTZ_ASSET_ID_ON_SHIDEN,1028        'Cross chain QTZ',1029        'xcQTZ',1030        Number(QTZ_DECIMALS),1031      );10321033      console.log('2. Register asset location on Shiden');1034      const assetLocation = {1035        V1: {1036          parents: 1,1037          interior: {1038            X1: {1039              Parachain: QUARTZ_CHAIN,1040            },1041          },1042        },1043      };10441045      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.registerAssetLocation', [assetLocation, QTZ_ASSET_ID_ON_SHIDEN]);10461047      console.log('3. Set QTZ payment for XCM execution on Shiden');1048      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);10491050      console.log('4. Transfer 1 SDN to recipient to create the account (needed due to existential balance)');1051      await helper.balance.transferToSubstrate(alice, sender.address, shidenInitialBalance);1052    });1053  });10541055  itSub('Should connect and send QTZ to Shiden', async ({helper}) => {1056    const destination = {1057      V2: {1058        parents: 1,1059        interior: {1060          X1: {1061            Parachain: SHIDEN_CHAIN,1062          },1063        },1064      },1065    };10661067    const beneficiary = {1068      V2: {1069        parents: 0,1070        interior: {1071          X1: {1072            AccountId32: {1073              network: 'Any',1074              id: sender.addressRaw,1075            },1076          },1077        },1078      },1079    };10801081    const assets = {1082      V2: [1083        {1084          id: {1085            Concrete: {1086              parents: 0,1087              interior: 'Here',1088            },1089          },1090          fun: {1091            Fungible: qtzToShidenTransferred,1092          },1093        },1094      ],1095    };10961097    // Initial balance is 100 QTZ1098    const balanceBefore = await helper.balance.getSubstrate(sender.address);1099    console.log(`Initial balance is: ${balanceBefore}`);1100    expect(balanceBefore).to.eq(senderIinitialBalanceQTZ);11011102    const feeAssetItem = 0;1103    await helper.xcm.limitedReserveTransferAssets(sender, destination, beneficiary, assets, feeAssetItem, 'Unlimited');11041105    // Balance after reserve transfer is less than 901106    const balanceAfter = await helper.balance.getSubstrate(sender.address);1107    console.log(`QTZ Balance on Quartz after XCM is: ${balanceAfter}`);1108    console.log(`Quartz's QTZ commission is: ${balanceBefore - balanceAfter}`);1109    expect(balanceAfter).to.eq(senderBalanceAfterXCM);11101111    await usingShidenPlaygrounds(shidenUrl, async (helper) => {1112      await helper.wait.newBlocks(3);1113      const xcQTZbalance = await helper.assets.account(QTZ_ASSET_ID_ON_SHIDEN, sender.address);1114      const shidenBalance = await helper.balance.getSubstrate(sender.address);11151116      console.log(`xcQTZ balance on Shiden after XCM is: ${xcQTZbalance}`);1117      console.log(`Shiden's QTZ commission is: ${qtzToShidenTransferred - xcQTZbalance!}`);11181119      expect(xcQTZbalance).to.eq(qtzToShidenArrived);1120      // SHD balance does not changed:1121      expect(shidenBalance).to.eq(shidenInitialBalance);1122    });1123  });11241125  itSub('Should connect to Shiden and send QTZ back', async ({helper}) => {1126    await usingShidenPlaygrounds(shidenUrl, async (helper) => {1127      const destination = {1128        V1: {1129          parents: 1,1130          interior: {1131            X1: {1132              Parachain: QUARTZ_CHAIN,1133            },1134          },1135        },1136      };11371138      const beneficiary = {1139        V1: {1140          parents: 0,1141          interior: {1142            X1: {1143              AccountId32: {1144                network: 'Any',1145                id: sender.addressRaw,1146              },1147            },1148          },1149        },1150      };11511152      const assets = {1153        V1: [1154          {1155            id: {1156              Concrete: {1157                parents: 1,1158                interior: {1159                  X1: {1160                    Parachain: QUARTZ_CHAIN,1161                  },1162                },1163              },1164            },1165            fun: {1166              Fungible: qtzFromShidenTransfered,1167            },1168          },1169        ],1170      };11711172      // Initial balance is 1 SDN1173      const balanceSDNbefore = await helper.balance.getSubstrate(sender.address);1174      console.log(`SDN balance is: ${balanceSDNbefore}, it does not changed`);1175      expect(balanceSDNbefore).to.eq(shidenInitialBalance);11761177      const feeAssetItem = 0;1178      // this is non-standard polkadotXcm extension for Astar only. It calls InitiateReserveWithdraw1179      await helper.executeExtrinsic(sender, 'api.tx.polkadotXcm.reserveWithdrawAssets', [destination, beneficiary, assets, feeAssetItem]);11801181      // Balance after reserve transfer is less than 1 SDN1182      const xcQTZbalance = await helper.assets.account(QTZ_ASSET_ID_ON_SHIDEN, sender.address);1183      const balanceSDN = await helper.balance.getSubstrate(sender.address);1184      console.log(`xcQTZ balance on Shiden after XCM is: ${xcQTZbalance}`);11851186      // Assert: xcQTZ balance correctly decreased1187      expect(xcQTZbalance).to.eq(qtzOnShidenLeft);1188      // Assert: SDN balance is 0.996...1189      expect(balanceSDN / (10n ** (SHIDEN_DECIMALS - 3n))).to.eq(996n);1190    });11911192    await helper.wait.newBlocks(3);1193    const balanceQTZ = await helper.balance.getSubstrate(sender.address);1194    console.log(`QTZ Balance on Quartz after XCM is: ${balanceQTZ}`);1195    expect(balanceQTZ).to.eq(senderBalanceAfterXCM + qtzFromShidenTransfered);1196  });1197});
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -18,12 +18,13 @@
 import {blake2AsHex} from '@polkadot/util-crypto';
 import config from '../config';
 import {XcmV2TraitsError} from '../interfaces';
-import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds} from '../util';
+import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds, usingAstarPlaygrounds} from '../util';
 
 const UNIQUE_CHAIN = 2037;
 const STATEMINT_CHAIN = 1000;
 const ACALA_CHAIN = 2000;
 const MOONBEAM_CHAIN = 2004;
+const ASTAR_CHAIN = 2006;
 
 const STATEMINT_PALLET_INSTANCE = 50;
 
@@ -31,10 +32,13 @@
 const statemintUrl = config.statemintUrl;
 const acalaUrl = config.acalaUrl;
 const moonbeamUrl = config.moonbeamUrl;
+const astarUrl = config.astarUrl;
 
 const RELAY_DECIMALS = 12;
 const STATEMINT_DECIMALS = 12;
 const ACALA_DECIMALS = 12;
+const ASTAR_DECIMALS = 18n;
+const UNQ_DECIMALS = 18n;
 
 const TRANSFER_AMOUNT = 2000000000000000000000000n;
 
@@ -980,3 +984,271 @@
     expect(unqFees == 0n).to.be.true;
   });
 });
+
+describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
+  let alice: IKeyringPair;
+  let randomAccount: IKeyringPair;
+
+  const UNQ_ASSET_ID_ON_SHIDEN = 1;
+  const UNQ_MINIMAL_BALANCE_ON_SHIDEN = 1n;
+
+  // Unique -> Astar
+  const astarInitialBalance = 1n * (10n ** ASTAR_DECIMALS); // 1 ASTR, existential deposit required to actually create the account on Shiden.
+  const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?
+  const unqToAstarTransferred = 10n * (10n ** UNQ_DECIMALS); // 10 UNQ
+  const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Shiden takes a commision in foreign tokens
+  const senderIinitialBalanceUNQ = 100n * (10n ** UNQ_DECIMALS); // How many UNQ sender has initially
+  const senderBalanceAfterXCM = 89_946678090945539197n; // 89.94... UNQ after XCM call
+
+  // Astar -> Unique
+  const unqFromAstarTransfered = 5n * (10n ** UNQ_DECIMALS); // 5 UNQ
+  const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ
+
+  before(async () => {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      alice = await privateKey('//Alice');
+      [randomAccount] = await helper.arrange.createAccounts([100n], alice);
+      console.log('randomAccount', randomAccount.address);
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
+    });
+
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      console.log('1. Create foreign asset and metadata');
+      // TODO update metadata with values from production
+      await helper.assets.create(
+        alice,
+        UNQ_ASSET_ID_ON_SHIDEN,
+        alice.address,
+        UNQ_MINIMAL_BALANCE_ON_SHIDEN,
+      );
+
+      await helper.assets.setMetadata(
+        alice,
+        UNQ_ASSET_ID_ON_SHIDEN,
+        'Cross chain UNQ',
+        'xcUNQ',
+        Number(UNQ_DECIMALS),
+      );
+
+      console.log('2. Register asset location on Astar');
+      const assetLocation = {
+        V1: {
+          parents: 1,
+          interior: {
+            X1: {
+              Parachain: UNIQUE_CHAIN,
+            },
+          },
+        },
+      };
+
+      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.registerAssetLocation', [assetLocation, UNQ_ASSET_ID_ON_SHIDEN]);
+
+      console.log('3. Set UNQ payment for XCM execution on Astar');
+      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
+
+      console.log('4. Transfer 1 ASTR to recipient to create the account (needed due to existential balance)');
+      await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
+    });
+  });
+
+  itSub('Should connect and send UNQ to Astar', async ({helper}) => {
+    const destination = {
+      V2: {
+        parents: 1,
+        interior: {
+          X1: {
+            Parachain: ASTAR_CHAIN,
+          },
+        },
+      },
+    };
+
+    const beneficiary = {
+      V2: {
+        parents: 0,
+        interior: {
+          X1: {
+            AccountId32: {
+              network: 'Any',
+              id: randomAccount.addressRaw,
+            },
+          },
+        },
+      },
+    };
+
+    const assets = {
+      V2: [
+        {
+          id: {
+            Concrete: {
+              parents: 0,
+              interior: 'Here',
+            },
+          },
+          fun: {
+            Fungible: unqToAstarTransferred,
+          },
+        },
+      ],
+    };
+
+    // Initial balance is 100 UNQ
+    const balanceBefore = await helper.balance.getSubstrate(randomAccount.address);
+    console.log(`Initial balance is: ${balanceBefore}`);
+    expect(balanceBefore).to.eq(senderIinitialBalanceUNQ);
+
+    const feeAssetItem = 0;
+    await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');
+
+    // Balance after reserve transfer is less than 90
+    const balanceAfter = await helper.balance.getSubstrate(randomAccount.address);
+    console.log(`UNQ Balance on Unique after XCM is: ${balanceAfter}`);
+    console.log(`Unique's UNQ commission is: ${balanceBefore - balanceAfter}`);
+    expect(balanceAfter).to.eq(senderBalanceAfterXCM);
+
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      await helper.wait.newBlocks(3);
+      const xcUNQbalance = await helper.assets.account(UNQ_ASSET_ID_ON_SHIDEN, randomAccount.address);
+      const astarBalance = await helper.balance.getSubstrate(randomAccount.address);
+
+      console.log(`xcUNQ balance on Astar after XCM is: ${xcUNQbalance}`);
+      console.log(`Astar's UNQ commission is: ${unqToAstarTransferred - xcUNQbalance!}`);
+
+      expect(xcUNQbalance).to.eq(unqToAstarArrived);
+      // Astar balance does not changed
+      expect(astarBalance).to.eq(astarInitialBalance);
+    });
+  });
+
+  itSub('Should connect to Astar and send UNQ back', async ({helper}) => {
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      const destination = {
+        V1: {
+          parents: 1,
+          interior: {
+            X1: {
+              Parachain: UNIQUE_CHAIN,
+            },
+          },
+        },
+      };
+
+      const beneficiary = {
+        V1: {
+          parents: 0,
+          interior: {
+            X1: {
+              AccountId32: {
+                network: 'Any',
+                id: randomAccount.addressRaw,
+              },
+            },
+          },
+        },
+      };
+
+      const assets = {
+        V1: [
+          {
+            id: {
+              Concrete: {
+                parents: 1,
+                interior: {
+                  X1: {
+                    Parachain: UNIQUE_CHAIN,
+                  },
+                },
+              },
+            },
+            fun: {
+              Fungible: unqFromAstarTransfered,
+            },
+          },
+        ],
+      };
+
+      // Initial balance is 1 ASTR
+      const balanceASTRbefore = await helper.balance.getSubstrate(randomAccount.address);
+      console.log(`ASTR balance is: ${balanceASTRbefore}, it does not changed`);
+      expect(balanceASTRbefore).to.eq(astarInitialBalance);
+
+      const feeAssetItem = 0;
+      // this is non-standard polkadotXcm extension for Astar only. It calls InitiateReserveWithdraw
+      await helper.executeExtrinsic(randomAccount, 'api.tx.polkadotXcm.reserveWithdrawAssets', [destination, beneficiary, assets, feeAssetItem]);
+
+      const xcUNQbalance = await helper.assets.account(UNQ_ASSET_ID_ON_SHIDEN, randomAccount.address);
+      const balanceAstar = await helper.balance.getSubstrate(randomAccount.address);
+      console.log(`xcUNQ balance on Astar after XCM is: ${xcUNQbalance}`);
+
+      // Assert: xcUNQ balance correctly decreased
+      expect(xcUNQbalance).to.eq(unqOnAstarLeft);
+      // Assert: ASTR balance is 0.996...
+      expect(balanceAstar / (10n ** (ASTAR_DECIMALS - 3n))).to.eq(996n);
+    });
+
+    await helper.wait.newBlocks(3);
+    const balanceUNQ = await helper.balance.getSubstrate(randomAccount.address);
+    console.log(`UNQ Balance on Unique after XCM is: ${balanceUNQ}`);
+    expect(balanceUNQ).to.eq(senderBalanceAfterXCM + unqFromAstarTransfered);
+  });
+
+  itSub.skip('Should not accept limitedReserveTransfer of UNQ from ASTAR', async ({helper}) => {
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      const destination = {
+        V1: {
+          parents: 1,
+          interior: {
+            X1: {
+              Parachain: UNIQUE_CHAIN,
+            },
+          },
+        },
+      };
+
+      const beneficiary = {
+        V1: {
+          parents: 0,
+          interior: {
+            X1: {
+              AccountId32: {
+                network: 'Any',
+                id: randomAccount.addressRaw,
+              },
+            },
+          },
+        },
+      };
+
+      const assets = {
+        V1: [
+          {
+            id: {
+              Concrete: {
+                parents: 1,
+                interior: {
+                  X1: {
+                    Parachain: UNIQUE_CHAIN,
+                  },
+                },
+              },
+            },
+            fun: {
+              Fungible: unqFromAstarTransfered,
+            },
+          },
+        ],
+      };
+
+      // Initial balance is 1 ASTAR
+      expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(astarInitialBalance);
+
+      const feeAssetItem = 0;
+      // TODO: expect rejected:
+      await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');
+    });
+  });
+});