-
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
16 changed files
with
210 additions
and
188 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 |
---|---|---|
|
@@ -23,3 +23,4 @@ bin/ | |
|
||
node_modules | ||
**/package-lock.json | ||
**/build |
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
This file was deleted.
Oops, something went wrong.
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,73 @@ | ||
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api"; | ||
import { submitExtrinsic, setupRelayAsset, RELAY_ASSET_ID } from "../common"; | ||
|
||
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), | ||
signedExtensions: { | ||
ChargeAssetTxPayment: { | ||
extrinsic: { | ||
tip: "Compact<Balance>", | ||
assetId: "Option<AssetId>", | ||
}, | ||
payload: {}, | ||
}, | ||
}, | ||
}); | ||
|
||
// 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), {}); | ||
|
||
await setupRelayAsset(regionXApi, alice); | ||
|
||
const receiverKeypair = new Keyring(); | ||
receiverKeypair.addFromAddress(alice.address); | ||
|
||
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: 10n ** 9n, | ||
}, | ||
}, | ||
], | ||
}, //asset | ||
feeAssetItem, | ||
weightLimit | ||
); | ||
await submitExtrinsic(alice, reserveTransfer, {}); | ||
|
||
// Try to pay for fees with relay chain asset. | ||
const remarkCall = regionXApi.tx.system.remark("0x44"); | ||
await submitExtrinsic(alice, remarkCall, { assetId: RELAY_ASSET_ID }); | ||
} | ||
|
||
export { run }; |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
import { ApiPromise, Keyring, WsProvider } from "@polkadot/api"; | ||
import { submitExtrinsic } from "../common"; | ||
|
||
async function run(nodeName: string, networkInfo: any, _jsArgs: any) { | ||
const { wsUri } = networkInfo.nodesByName[nodeName]; | ||
const api = await ApiPromise.create({ provider: new WsProvider(wsUri) }); | ||
|
||
// account to submit tx | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
const bob = keyring.addFromUri("//Bob"); | ||
|
||
const call = api.tx.balances.transferKeepAlive(bob.address, 10n ** 6n); | ||
const sudo = api.tx.sudo.sudo(call); | ||
await submitExtrinsic(alice, sudo, {}); | ||
} | ||
|
||
export { run }; |
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api"; | ||
import { submitExtrinsic, setupRelayAsset, RELAY_ASSET_ID } from "../common"; | ||
|
||
const PREIMAGE_HASH = "0xb8375f7ca0c64a384f2dd643a0d520977f3aae06e64afb8c960891eee5147bd1"; | ||
|
||
async function run(nodeName: string, networkInfo: any, _jsArgs: any) { | ||
const { wsUri } = networkInfo.nodesByName[nodeName]; | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider(wsUri), | ||
signedExtensions: { | ||
ChargeAssetTxPayment: { | ||
extrinsic: { | ||
tip: "Compact<Balance>", | ||
assetId: "Option<AssetId>", | ||
}, | ||
payload: {}, | ||
}, | ||
}, | ||
}); | ||
|
||
// account to submit tx | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
const anna = keyring.addFromUri("//Anna"); | ||
|
||
await setupRelayAsset(api, alice); | ||
|
||
const giveBalanceCall = api.tx.tokens.setBalance(anna.address, RELAY_ASSET_ID, 10n ** 18n, 0); | ||
await submitExtrinsic(alice, api.tx.sudo.sudo(giveBalanceCall), {}); | ||
|
||
const remarkCallBytes = api.tx.system.remark("hey").toU8a(); | ||
await submitExtrinsic(alice, api.tx.preimage.notePreimage(remarkCallBytes), {}); | ||
|
||
const submitProposal = api.tx.delegatedReferenda.submit( | ||
{ system: "Root" }, | ||
{ Lookup: { hash: PREIMAGE_HASH, len: remarkCallBytes.length } }, | ||
{ After: 5 } | ||
); | ||
await submitExtrinsic(anna, submitProposal, { assetId: RELAY_ASSET_ID }); | ||
|
||
const placeDeposit = api.tx.delegatedReferenda.placeDecisionDeposit(0); | ||
await submitExtrinsic(anna, placeDeposit, { assetId: RELAY_ASSET_ID }); | ||
|
||
const voteCall = api.tx.delegatedConvictionVoting.vote(0, { | ||
// Voting with relay chain tokens. We know this is true; otherwise, this call | ||
// would fail, given that Anna doesn't have 10^16 RegionX tokens. | ||
Standard: { vote: { aye: true, conviction: "None" }, balance: 10n ** 16n }, | ||
}); | ||
await submitExtrinsic(anna, voteCall, { assetId: RELAY_ASSET_ID }); | ||
} | ||
|
||
export { run }; |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api"; | ||
import { submitExtrinsic, setupRelayAsset } from "../common"; | ||
|
||
const PREIMAGE_HASH = "0x0ccf4369e9a9f88f035828ba0dd5da645d5c0fa7baa86bdc8d7a80c183ab84c9"; | ||
|
||
async function run(nodeName: string, networkInfo: any, _jsArgs: any) { | ||
const { wsUri } = networkInfo.nodesByName[nodeName]; | ||
const api = await ApiPromise.create({ provider: new WsProvider(wsUri) }); | ||
|
||
// account to submit tx | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
|
||
await setupRelayAsset(api, alice); | ||
|
||
const spendCallBytes = api.tx.treasury.spendLocal(10n ** 6n, alice.address).toU8a(); | ||
await submitExtrinsic(alice, api.tx.preimage.notePreimage(spendCallBytes), {}); | ||
|
||
const submitProposal = api.tx.nativeReferenda.submit( | ||
{ Origins: "SmallTipper" }, | ||
{ Lookup: { hash: PREIMAGE_HASH, len: spendCallBytes.length } }, | ||
{ After: 5 } | ||
); | ||
await submitExtrinsic(alice, submitProposal, {}); | ||
|
||
const placeDeposit = api.tx.nativeReferenda.placeDecisionDeposit(0); | ||
await submitExtrinsic(alice, placeDeposit, {}); | ||
|
||
const voteCall = api.tx.nativeConvictionVoting.vote(0, { | ||
Standard: { vote: { aye: true, conviction: "None" }, balance: 10n ** 16n }, | ||
}); | ||
await submitExtrinsic(alice, voteCall, {}); | ||
} | ||
|
||
export { run }; |
Oops, something went wrong.