From dd42ee766bf79bb7954f5d66368d86027a105f6f Mon Sep 17 00:00:00 2001 From: bee344 Date: Thu, 9 Nov 2023 12:57:35 -0300 Subject: [PATCH] fixed StagedXcmDoubleEncoded on foreign assets script --- scripts/testNetworkForeignAssets.ts | 30 ++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/testNetworkForeignAssets.ts b/scripts/testNetworkForeignAssets.ts index d8789c64..e72e9e8e 100644 --- a/scripts/testNetworkForeignAssets.ts +++ b/scripts/testNetworkForeignAssets.ts @@ -5,8 +5,8 @@ import { Keyring } from '@polkadot/keyring'; import { cryptoWaitReady } from '@polkadot/util-crypto'; import chalk from 'chalk'; -import { KUSAMA_ASSET_HUB_WS_URL, TRAPPIST_WS_URL } from './consts'; -import { awaitBlockProduction, delay, logWithDate } from './util'; +import { KUSAMA_ASSET_HUB_WS_URL, TRAPPIST_WS_URL, ROCOCO_ALICE_WS_URL } from './consts'; +import { awaitBlockProduction, delay, logWithDate, awaitEpochChange } from './util'; const fAssetSetMetadataCall = (assetHubApi: ApiPromise): `0x${string}` => { const trappistMultiLocation = { @@ -58,7 +58,7 @@ const fAssetCreateCall = (assetHubApi: ApiPromise): `0x${string}` => { const sudoCallWrapper = (trappistApi: ApiPromise, call: `0x${string}`) => { // Double encode the call - const xcmDoubleEncoded = trappistApi.createType('XcmDoubleEncoded', { + const xcmDoubleEncoded = trappistApi.createType('StagingXcmDoubleEncoded', { encoded: call, }); @@ -159,6 +159,10 @@ const setMetadataForeignAssetViaSudo = (assetHubApi: ApiPromise, trappistApi: Ap return sudoCallWrapper(trappistApi, setMetadataCall); }; +const openHrmpChannels = (api: ApiPromise, sender: number, receiver: number) => { + return api.tx.hrmp.forceOpenHrmpChannel(sender, receiver, Number(8), Number(512)); +}; + const main = async () => { logWithDate(chalk.yellow('Initializing script to create foreignAssets on chain')); await cryptoWaitReady(); @@ -183,6 +187,26 @@ const main = async () => { await trappistApi.isReady; logWithDate(chalk.green('Created a connection to Trappist')); + const relayApi = await ApiPromise.create({ + provider: new WsProvider(ROCOCO_ALICE_WS_URL), + noInitWarn: true, + }); + + await relayApi.isReady; + + logWithDate(chalk.green('Created a connection to Rococo')); + + logWithDate(chalk.blue('Opening HRMP Channels')); + + let hrmpChannelCalls = []; + + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1000), Number(1836))); + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1836), Number(1000))); + + await relayApi.tx.sudo.sudo(relayApi.tx.utility.batchAll(hrmpChannelCalls)).signAndSend(alice); + + await awaitEpochChange(relayApi); + logWithDate(chalk.magenta('Sending funds to Trappist Sibling on Kusama AssetHub')); await kusamaAssetHubApi.tx.balances