-
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
3 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[settings] | ||
timeout = 1000 | ||
|
||
[relaychain] | ||
chain = "rococo-local" | ||
command = "polkadot" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
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,10 @@ | ||
Description: Native currency fee payment | ||
Network: ./0003-non-native-fee-payment-test.toml | ||
Creds: config | ||
|
||
alice: is up | ||
bob: is up | ||
|
||
alice: parachain 2000 is registered within 225 seconds | ||
|
||
regionx-collator01: js-script ./0003-non-native-transfer.js return is 0 within 400 seconds |
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,61 @@ | ||
const BOB = "5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc"; | ||
const ASSET_ID = 42; | ||
|
||
async function run(nodeName, networkInfo, _jsArgs) { | ||
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName]; | ||
const api = await zombie.connect(wsUri, { | ||
...userDefinedTypes, | ||
signedExtensions: { | ||
ChargeAssetTxPayment: { | ||
extrinsic: { | ||
tip: 'Compact<Balance>', | ||
assetId: 'Option<u32>' | ||
}, | ||
payload: {} | ||
} | ||
}}); | ||
|
||
await zombie.util.cryptoWaitReady(); | ||
|
||
// account to submit tx | ||
const keyring = new zombie.Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
|
||
const createCall = api.tx.assets.forceCreate(ASSET_ID, alice.address, true, 50); | ||
const mintCall = api.tx.assets.mint(ASSET_ID, alice.address, 10n**6n); | ||
|
||
const sudo = api.tx.sudo.sudo(createCall); | ||
await submitExtrinsic(alice, sudo, {}); | ||
await submitExtrinsic(alice, mintCall, {}); | ||
|
||
const transferCall = api.tx.balances.transferKeepAlive(BOB, 10n**6n); | ||
const feePaymentAsset = api.registry.createType('Option<u32>', ASSET_ID); | ||
await submitExtrinsic(alice, transferCall, {assetId: feePaymentAsset}); | ||
|
||
return 0; | ||
} | ||
|
||
async function submitExtrinsic(signer, call, options) { | ||
return new Promise(async (resolve, reject) => { | ||
const unsub = await call.signAndSend(signer, options, (result) => { | ||
console.log(`Current status is ${result.status}`); | ||
if (result.status.isInBlock) { | ||
console.log( | ||
`Transaction included at blockHash ${result.status.asInBlock}` | ||
); | ||
} else if (result.status.isFinalized) { | ||
console.log( | ||
`Transaction finalized at blockHash ${result.status.asFinalized}` | ||
); | ||
unsub(); | ||
return resolve(); | ||
} else if (result.isError) { | ||
console.log(`Transaction error`); | ||
unsub(); | ||
return resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { run }; |