-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
171 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api"; | ||
import { RELAY_ASSET_ID, setupRelayAsset, sleep, submitExtrinsic } from "../common"; | ||
|
||
import assert from "node:assert"; | ||
|
||
async function run(nodeName: string, networkInfo: any, _jsArgs: any) { | ||
const { wsUri: regionXUri } = networkInfo.nodesByName[nodeName]; | ||
const { wsUri: rococoUri } = networkInfo.nodesByName["rococo-validator01"]; | ||
|
||
const rococoApi = await ApiPromise.create({ provider: new WsProvider(rococoUri) }); | ||
const regionXApi = await ApiPromise.create({ provider: new WsProvider(regionXUri) }); | ||
|
||
// account to submit tx | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
|
||
const setXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]); | ||
await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(setXcmVersion), {}); | ||
|
||
const BALANCE = 10n ** 12n; | ||
|
||
await setupRelayAsset(regionXApi, alice, BALANCE); | ||
|
||
const receiverKeypair = new Keyring(); | ||
receiverKeypair.addFromAddress(alice.address); | ||
|
||
const { free: balanceBefore } = ( | ||
await regionXApi.query.tokens.accounts(alice.address, RELAY_ASSET_ID) | ||
).toJSON() as any; | ||
|
||
console.log(`balanceBefore = ${balanceBefore}`); | ||
|
||
assert.equal(BigInt(balanceBefore), BALANCE); | ||
|
||
const feeAssetItem = 0; | ||
const weightLimit = "Unlimited"; | ||
const reserveTransfer = rococoApi.tx.xcmPallet.limitedReserveTransferAssets( | ||
{ V3: { parents: 0, interior: { X1: { Parachain: 2000 } } } }, //dest | ||
{ | ||
V3: { | ||
parents: 0, | ||
interior: { | ||
X1: { | ||
AccountId32: { | ||
chain: "Any", | ||
id: receiverKeypair.pairs[0].publicKey, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, //beneficiary | ||
{ | ||
V3: [ | ||
{ | ||
id: { | ||
Concrete: { parents: 0, interior: "Here" }, | ||
}, | ||
fun: { | ||
Fungible: BALANCE, | ||
}, | ||
}, | ||
], | ||
}, //asset | ||
feeAssetItem, | ||
weightLimit | ||
); | ||
await submitExtrinsic(alice, reserveTransfer, {}); | ||
|
||
await sleep(15 * 1000); | ||
|
||
const { free: balanceAfter } = ( | ||
await regionXApi.query.tokens.accounts(alice.address, RELAY_ASSET_ID) | ||
).toJSON() as any; | ||
|
||
console.log(`balanceAfter = ${balanceAfter}`); | ||
|
||
assert.equal(BigInt(balanceAfter), BALANCE * 2n); | ||
} | ||
|
||
export { run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[settings] | ||
timeout = 1000 | ||
|
||
[relaychain] | ||
chain = "rococo-local" | ||
command = "polkadot" | ||
|
||
[[relaychain.nodes]] | ||
name = "rococo-validator01" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "rococo-validator02" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 2000 | ||
addToGenesis = false | ||
|
||
[parachains.collator] | ||
name = "regionx-collator01" | ||
command = "regionx-node" | ||
args = [ "-lruntime=debug,parachain=trace" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Description: Cross chain transfer between RegionX and the relay chain | ||
Network: ./0006-xc-transfer.toml | ||
Creds: config | ||
|
||
rococo-validator01: is up | ||
rococo-validator02: is up | ||
|
||
rococo-validator01: parachain 2000 is registered within 225 seconds | ||
|
||
regionx-collator01: js-script ../e2e_tests/build/xc-transfer/rococo-regionx.js return is 0 within 400 seconds | ||
|