-
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.
Merge branch 'main' into dependabot/cargo/color-print-0.3.6
- Loading branch information
Showing
31 changed files
with
1,177 additions
and
151 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 |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
- uses: ./.github/actions/setup | ||
|
||
- name: Install Rust | ||
run: cargo install [email protected] | ||
run: cargo install --git https://github.com/paritytech/psvm --rev a3ecef700e4c1429c2d01e265a145654ceb3cc49 psvm | ||
- name: Check Dependency Versions | ||
run: | | ||
chmod +x ./scripts/check-dependency-versions.sh | ||
|
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,57 @@ | ||
import { ApiPromise } from "@polkadot/api"; | ||
import { SubmittableExtrinsic, SignerOptions } from "@polkadot/api/types"; | ||
import { KeyringPair } from "@polkadot/keyring/types"; | ||
|
||
const RELAY_ASSET_ID = 1; | ||
|
||
async function submitExtrinsic(signer: KeyringPair, call: SubmittableExtrinsic<"promise">, options: Partial<SignerOptions>): Promise<void> { | ||
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 reject(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function setupRelayAsset(api: ApiPromise, signer: KeyringPair) { | ||
const assetMetadata = { | ||
decimals: 12, | ||
name: "ROC", | ||
symbol: "ROC", | ||
existentialDeposit: 10n ** 3n, | ||
location: null, | ||
additional: null, | ||
}; | ||
|
||
const assetSetupCalls = [ | ||
api.tx.assetRegistry.registerAsset(assetMetadata, RELAY_ASSET_ID), | ||
api.tx.assetRate.create(RELAY_ASSET_ID, 1_000_000_000_000_000_000n), // 1 on 1 | ||
api.tx.tokens.setBalance( | ||
signer.address, | ||
RELAY_ASSET_ID, | ||
10n ** 12n, | ||
0, | ||
), | ||
]; | ||
|
||
const batchCall = api.tx.utility.batch(assetSetupCalls); | ||
const sudoCall = api.tx.sudo.sudo(batchCall); | ||
|
||
await submitExtrinsic(signer, sudoCall, {}); | ||
} | ||
|
||
export { submitExtrinsic, setupRelayAsset, RELAY_ASSET_ID } |
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 }; |
Oops, something went wrong.