From ac661577468ca9b1d1cc704258210180ba7e14d6 Mon Sep 17 00:00:00 2001 From: bee344 Date: Wed, 10 Jan 2024 14:28:33 -0300 Subject: [PATCH] upload for testing --- e2e-tests/consts.ts | 2 +- e2e-tests/executor.ts | 12 ++-- e2e-tests/tests/assets.ts | 16 ++++- e2e-tests/tests/foreignAssets.ts | 16 ++++- e2e-tests/tests/index.ts | 94 ++++++++++++++--------------- e2e-tests/tests/liquidPools.ts | 44 ++++++++++++-- e2e-tests/tests/local.ts | 55 +---------------- scripts/consts.ts | 2 +- scripts/testNetworkForeignAssets.ts | 58 +++++++++--------- scripts/testNetworkLiquidAssets.ts | 8 +-- src/AssetTransferApi.ts | 7 +++ 11 files changed, 169 insertions(+), 145 deletions(-) diff --git a/e2e-tests/consts.ts b/e2e-tests/consts.ts index 4424070e..805188ff 100644 --- a/e2e-tests/consts.ts +++ b/e2e-tests/consts.ts @@ -2,7 +2,7 @@ export const KUSAMA_ASSET_HUB_WS_URL = 'ws://127.0.0.1:9911'; export const ROCOCO_ALICE_WS_URL = 'ws://127.0.0.1:9900'; -export const TRAPPIST_WS_URL = 'ws://127.0.0.1:9921'; +export const ROCOCO_ASSET_HUB_WS_URL = 'ws://127.0.0.1:9921'; export const MOONRIVER_WS_URL = 'ws://127.0.0.1:9931'; export const BOB_ROC_ADDR = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'; diff --git a/e2e-tests/executor.ts b/e2e-tests/executor.ts index 3c3c1cf7..95b1f54e 100644 --- a/e2e-tests/executor.ts +++ b/e2e-tests/executor.ts @@ -7,7 +7,7 @@ import { cryptoWaitReady } from '@polkadot/util-crypto'; import { delay } from '../scripts/util'; import { constructApiPromise } from '../src'; import { balanceTracker, IBalance } from './balance'; -import { KUSAMA_ASSET_HUB_WS_URL, MOONRIVER_WS_URL, ROCOCO_ALICE_WS_URL, TRAPPIST_WS_URL } from './consts'; +import { KUSAMA_ASSET_HUB_WS_URL, MOONRIVER_WS_URL, ROCOCO_ALICE_WS_URL, ROCOCO_ASSET_HUB_WS_URL } from './consts'; import { assetTests, foreignAssetsTests, IndividualTest, liquidPoolsTests, localTests, tests } from './tests'; import { verification } from './verification'; @@ -70,7 +70,10 @@ const executor = async (testCase: string) => { destAddr = t.args[3]; assetIds = t.args[4].slice(1, -1).split(','); amounts = t.args[5].slice(1, -1).split(','); - opts = JSON.parse(t.args[6]) as object; + opts = JSON.parse(t.args[6], (key, value) => { + return key === "paysWithFeeOrigin" ? JSON.stringify(value) : value; + }) as object; + switch (originChainId) { case '0': @@ -80,7 +83,7 @@ const executor = async (testCase: string) => { originWsUrl = KUSAMA_ASSET_HUB_WS_URL; break; case '1836': - originWsUrl = TRAPPIST_WS_URL; + originWsUrl = ROCOCO_ASSET_HUB_WS_URL; break; case '4000': originWsUrl = MOONRIVER_WS_URL; @@ -98,7 +101,7 @@ const executor = async (testCase: string) => { destWsUrl = KUSAMA_ASSET_HUB_WS_URL; break; case '1836': - destWsUrl = TRAPPIST_WS_URL; + destWsUrl = ROCOCO_ASSET_HUB_WS_URL; break; case '4000': destWsUrl = MOONRIVER_WS_URL; @@ -108,7 +111,6 @@ const executor = async (testCase: string) => { const { api, specName, safeXcmVersion } = await constructApiPromise(originWsUrl); let sanitizedSpecName = originChainId === '1836' ? 'asset-hub-rococo' : specName; - console.log(sanitizedSpecName) await api.isReady; const originApi = api; diff --git a/e2e-tests/tests/assets.ts b/e2e-tests/tests/assets.ts index 36614b0a..baa0b557 100644 --- a/e2e-tests/tests/assets.ts +++ b/e2e-tests/tests/assets.ts @@ -6,7 +6,21 @@ import { AssetTransferApi } from '../../src'; import { TxResult } from '../../src/types'; const createAssetApi = (api: ApiPromise, specName: string, safeXcmVersion: number): AssetTransferApi => { - const assetApi = new AssetTransferApi(api, specName, safeXcmVersion); + const injectedRegistry = { + rococo: { + '1836': { + tokens: ['ROC'], + assetsInfo: {}, + foreignAssetsInfo: {}, + specName: 'asset-hub-rococo', + poolPairsInfo: {}, + }, + }, + }; + + const assetApi = new AssetTransferApi(api, specName, safeXcmVersion, + { injectedRegistry }); + return assetApi; }; diff --git a/e2e-tests/tests/foreignAssets.ts b/e2e-tests/tests/foreignAssets.ts index 7663c841..988255d7 100644 --- a/e2e-tests/tests/foreignAssets.ts +++ b/e2e-tests/tests/foreignAssets.ts @@ -6,7 +6,21 @@ import { AssetTransferApi } from '../../src'; import { TxResult } from '../../src/types'; const createAssetApi = (api: ApiPromise, specName: string, safeXcmVersion: number): AssetTransferApi => { - const assetApi = new AssetTransferApi(api, specName, safeXcmVersion); + const injectedRegistry = { + rococo: { + '1836': { + tokens: ['ROC'], + assetsInfo: {}, + foreignAssetsInfo: {}, + specName: 'asset-hub-rococo', + poolPairsInfo: {}, + }, + }, + }; + + const assetApi = new AssetTransferApi(api, specName, safeXcmVersion, + { injectedRegistry }); + return assetApi; }; diff --git a/e2e-tests/tests/index.ts b/e2e-tests/tests/index.ts index accbbb6b..1203bfe4 100644 --- a/e2e-tests/tests/index.ts +++ b/e2e-tests/tests/index.ts @@ -30,7 +30,7 @@ export const tests: TestGroups = { '1000', '//Alice', BOB_KAH_ADDR, - '[{ "parents": "1", "interior": { "X2": [{ "Parachain": "2500" }, { "GeneralIndex": "0" }]}}]', + '[{ "parents": "1", "interior": { "X2": [{ "Parachain": "1836" }, { "GeneralIndex": "0" }]}}]', '[200000000000]', '{ "format": "submittable", "xcmVersion": 3 }', ], @@ -40,9 +40,26 @@ export const tests: TestGroups = { }, ], liquidPools: [ + // { + // // This will declare the call to use + // test: 'createLocalTransferTransaction', + // // This will be all the args for the above call + // args: [ + // '1000', + // '1000', + // '//Alice', + // BOB_KAH_ADDR, + // '[0]', + // '[2000]', + // '{ "format": "submittable", "transferLiquidToken": true }', + // ], + // // This will be a tuple that will allow us to verify if the xcm message + // // succesfully went through on the other end + // verification: ['[0]', '[2000]'], + // }, { // This will declare the call to use - test: 'createLocalTransferTransaction', + test: 'createPayFeesTransaction', // This will be all the args for the above call args: [ '1000', @@ -50,69 +67,52 @@ export const tests: TestGroups = { '//Alice', BOB_KAH_ADDR, '[0]', - '[2000]', - '{ "format": "submittable", "transferLiquidToken": true }', + '[30000]', + '{ "format": "payload", "xcmVersion": 3, "transferLiquidToken": true, "paysWithFeeOrigin": { "parents": "0", "interior": { "X2": [{"PalletInstance": "50"}, { "GeneralIndex": "1" }]}}, "sendersAddr": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" }', ], // This will be a tuple that will allow us to verify if the xcm message // succesfully went through on the other end - verification: ['[0]', '[2000]'], + verification: ['[0]', '[30000]'], }, + ], + local: [ { // This will declare the call to use - test: 'createPayFeesTransaction', + test: 'createLocalTransferTransaction', // This will be all the args for the above call args: [ '1000', '1000', '//Alice', BOB_KAH_ADDR, - '[0]', - '[30000]', - '{ "format": "submittable", "transferLiquidToken": true }', + '[]', + '[10000000000000]', + '{ "format": "submittable", "keepAlive": true }', ], // This will be a tuple that will allow us to verify if the xcm message // succesfully went through on the other end - verification: ['[0]', '[30000]'], + verification: ['[0]', '[10000000000000]'], + }, + { + // This will declare the call to use + test: 'createLocalTransferTransaction', + // This will be all the args for the above call + args: [ + '1836', + '1836', + '//Alice', + BOB_KAH_ADDR, + '[]', + '[100000000000000000]', + '{ "format": "submittable", "keepAlive": true }', + ], + // This will be a tuple that will allow us to verify if the xcm message + // succesfully went through on the other end + verification: ['[0]', '[10000000000000]'], }, - ], - local: [ - // { - // // This will declare the call to use - // test: 'createSystemLocalTransferTransaction', - // // This will be all the args for the above call - // args: [ - // '1000', - // '1000', - // '//Alice', - // BOB_KAH_ADDR, - // '[]', - // '[10000000000000]', - // '{ "format": "submittable", "keepAlive": true }', - // ], - // // This will be a tuple that will allow us to verify if the xcm message - // // succesfully went through on the other end - // verification: ['[0]', '[10000000000000]'], - // }, - // { - // // This will declare the call to use - // test: 'createSystemLocalTransferTransaction', - // // This will be all the args for the above call - // args: [ - // '1836', - // '1836', - // '//Alice', - // BOB_KAH_ADDR, - // '[]', - // '[100000000000000000]', - // '{ "format": "submittable", "keepAlive": true }', - // ], - // // This will be a tuple that will allow us to verify if the xcm message - // // succesfully went through on the other end - // verification: ['[0]', '[10000000000000]'], - // }, { // This will declare the call to use - test: 'createSystemLocalTransferTransaction', + test: 'createLocalTransferTransaction', // This will be all the args for the above call args: [ '0', diff --git a/e2e-tests/tests/liquidPools.ts b/e2e-tests/tests/liquidPools.ts index 39ade811..54eb06ab 100644 --- a/e2e-tests/tests/liquidPools.ts +++ b/e2e-tests/tests/liquidPools.ts @@ -6,7 +6,21 @@ import { AssetTransferApi } from '../../src'; import { TxResult } from '../../src/types'; const createAssetApi = (api: ApiPromise, specName: string, safeXcmVersion: number): AssetTransferApi => { - const assetApi = new AssetTransferApi(api, specName, safeXcmVersion); + const injectedRegistry = { + rococo: { + '1836': { + tokens: ['ROC'], + assetsInfo: {}, + foreignAssetsInfo: {}, + specName: 'asset-hub-rococo', + poolPairsInfo: {}, + }, + }, + }; + + const assetApi = new AssetTransferApi(api, specName, safeXcmVersion, + { injectedRegistry }); + return assetApi; }; @@ -40,17 +54,39 @@ const createPayFeesTransaction = async ( destAddr: string, assetIds: string[], amounts: string[], - opts: object, + opts: {}, api: ApiPromise, specName: string, safeXcmVersion: number, ) => { const assetApi = createAssetApi(api, specName, safeXcmVersion); - let localTransferInfo: TxResult<'submittable'>; + let localTransferInfo: TxResult<'payload'>; try { localTransferInfo = await assetApi.createTransferTransaction(destChainId, destAddr, assetIds, amounts, opts); - await localTransferInfo.tx.signAndSend(origin); + const signature = api.registry + .createType('ExtrinsicPayload', localTransferInfo, { + version: 4, + }) + .sign(origin).signature as unknown as `0x${string}`; + + const extrinsic = api.registry.createType( + 'Extrinsic', + { method: localTransferInfo.method }, + { version: 4 } + ); + + let sender: string; + if (opts["sendersAddr"] === undefined) { + sender = '' + } else { + sender = opts["sendersAddr"]; + } + + const signed = extrinsic.addSignature(sender, signature, localTransferInfo as unknown as `0x${string}`).toHex() + + await api.rpc.author.submitExtrinsic(signed) + } catch (e) { console.error(e); throw Error(e as string); diff --git a/e2e-tests/tests/local.ts b/e2e-tests/tests/local.ts index d504206b..4d1f9222 100644 --- a/e2e-tests/tests/local.ts +++ b/e2e-tests/tests/local.ts @@ -9,7 +9,7 @@ import { TxResult } from '../../src/types'; const createAssetApi = (api: ApiPromise, specName: string, safeXcmVersion: number): AssetTransferApi => { const injectedRegistry = { - kusama: { + rococo: { '1836': { tokens: ['ROC'], assetsInfo: {}, @@ -27,54 +27,7 @@ const createAssetApi = (api: ApiPromise, specName: string, safeXcmVersion: numbe return assetApi; }; -const createSystemLocalTransferTransaction = async ( - origin: KeyringPair, - destChainId: string, - destAddr: string, - assetIds: string[], - amounts: string[], - opts: object, - api: ApiPromise, - specName: string, - safeXcmVersion: number, -) => { - const assetApi = createAssetApi(api, specName, safeXcmVersion); - - let localTransferInfo: TxResult<'submittable'>; - try { - localTransferInfo = await assetApi.createTransferTransaction(destChainId, destAddr, assetIds, amounts, opts); - console.log(localTransferInfo.direction) - await localTransferInfo.tx.signAndSend(origin); - } catch (e) { - console.error(e); - throw Error(e as string); - } -}; - -const createRelayLocalTransferTransaction = async ( - origin: KeyringPair, - destChainId: string, - destAddr: string, - assetIds: string[], - amounts: string[], - opts: object, - api: ApiPromise, - specName: string, - safeXcmVersion: number, -) => { - const assetApi = createAssetApi(api, specName, safeXcmVersion); - - let localTransferInfo: TxResult<'submittable'>; - try { - localTransferInfo = await assetApi.createTransferTransaction(destChainId, destAddr, assetIds, amounts, opts); - await localTransferInfo.tx.signAndSend(origin); - } catch (e) { - console.error(e); - throw Error(e as string); - } -}; - -const createRelayToSystemTransferTransaction = async ( +const createLocalTransferTransaction = async ( origin: KeyringPair, destChainId: string, destAddr: string, @@ -98,7 +51,5 @@ const createRelayToSystemTransferTransaction = async ( }; export const localTests: { [K: string]: Function } = { - createSystemLocalTransferTransaction, - createRelayLocalTransferTransaction, - createRelayToSystemTransferTransaction, + createLocalTransferTransaction, }; diff --git a/scripts/consts.ts b/scripts/consts.ts index 1a3e85ab..721f697b 100644 --- a/scripts/consts.ts +++ b/scripts/consts.ts @@ -2,5 +2,5 @@ export const KUSAMA_ASSET_HUB_WS_URL = 'ws://127.0.0.1:9911'; export const ROCOCO_ALICE_WS_URL = 'ws://127.0.0.1:9900'; -export const TRAPPIST_WS_URL = 'ws://127.0.0.1:9921'; +export const ROCOCO_ASSET_HUB_WS_URL = 'ws://127.0.0.1:9921'; export const MOONRIVER_WS_URL = 'ws://127.0.0.1:9931'; diff --git a/scripts/testNetworkForeignAssets.ts b/scripts/testNetworkForeignAssets.ts index 86cefa98..7e06af6f 100644 --- a/scripts/testNetworkForeignAssets.ts +++ b/scripts/testNetworkForeignAssets.ts @@ -5,20 +5,20 @@ import { Keyring } from '@polkadot/keyring'; import { cryptoWaitReady } from '@polkadot/util-crypto'; import chalk from 'chalk'; -import { KUSAMA_ASSET_HUB_WS_URL, ROCOCO_ALICE_WS_URL, TRAPPIST_WS_URL } from './consts'; +import { KUSAMA_ASSET_HUB_WS_URL, ROCOCO_ALICE_WS_URL, ROCOCO_ASSET_HUB_WS_URL } from './consts'; import { awaitBlockProduction, awaitEpochChange, delay, logWithDate } from './util'; const fAssetSetMetadataCall = (assetHubApi: ApiPromise): `0x${string}` => { - const trappistMultiLocation = { + const rockmineMultilocatino = { parents: 1, interior: { X1: { - parachain: 3000, + parachain: 1836, }, }, }; - const setMetadataTx = assetHubApi.tx.foreignAssets.setMetadata(trappistMultiLocation, 'Trappist Hop', 'Hop', 12); + const setMetadataTx = assetHubApi.tx.foreignAssets.setMetadata(rockmineMultilocatino, 'Asset Hub Rococo Hop', 'Hop', 12); const hexCall = assetHubApi.registry .createType('Call', { @@ -31,7 +31,7 @@ const fAssetSetMetadataCall = (assetHubApi: ApiPromise): `0x${string}` => { }; const fAssetCreateCall = (assetHubApi: ApiPromise): `0x${string}` => { - const trappistMultiLocation = { + const rockmineMultilocatino = { parents: 1, interior: { X1: { @@ -41,7 +41,7 @@ const fAssetCreateCall = (assetHubApi: ApiPromise): `0x${string}` => { }; const createTx = assetHubApi.tx.foreignAssets.create( - trappistMultiLocation, + rockmineMultilocatino, '5Eg2fnsjAAr8RGZfa8Sy5mYFPabA9ZLNGYECCKXPD6xnK6D2', // Sibling 1836 -> ParaId '100000000000', ); @@ -56,13 +56,13 @@ const fAssetCreateCall = (assetHubApi: ApiPromise): `0x${string}` => { return hexCall; }; -const sudoCallWrapper = (trappistApi: ApiPromise, call: `0x${string}`) => { +const sudoCallWrapper = (rockmineApi: ApiPromise, call: `0x${string}`) => { // Double encode the call - const xcmDoubleEncoded = trappistApi.createType('XcmDoubleEncoded', { + const xcmDoubleEncoded = rockmineApi.createType('XcmDoubleEncoded', { encoded: call, }); - const xcmOriginType = trappistApi.createType('XcmOriginKind', 'Xcm'); + const xcmOriginType = rockmineApi.createType('XcmOriginKind', 'Xcm'); const xcmDestMultiLocation = { V3: { parents: 1, @@ -140,8 +140,8 @@ const sudoCallWrapper = (trappistApi: ApiPromise, call: `0x${string}`) => { }, ], }; - const xcmMsg = trappistApi.tx.polkadotXcm.send(xcmDestMultiLocation, xcmMessage); - const xcmCall = trappistApi.createType('Call', { + const xcmMsg = rockmineApi.tx.polkadotXcm.send(xcmDestMultiLocation, xcmMessage); + const xcmCall = rockmineApi.createType('Call', { callIndex: xcmMsg.callIndex, args: xcmMsg.args, }); @@ -149,14 +149,14 @@ const sudoCallWrapper = (trappistApi: ApiPromise, call: `0x${string}`) => { return xcmCall; }; -const createForeignAssetViaSudo = (assetHubApi: ApiPromise, trappistApi: ApiPromise) => { +const createForeignAssetViaSudo = (assetHubApi: ApiPromise, rockmineApi: ApiPromise) => { const foreignAssetCreateCall = fAssetCreateCall(assetHubApi); - return sudoCallWrapper(trappistApi, foreignAssetCreateCall); + return sudoCallWrapper(rockmineApi, foreignAssetCreateCall); }; -const setMetadataForeignAssetViaSudo = (assetHubApi: ApiPromise, trappistApi: ApiPromise) => { +const setMetadataForeignAssetViaSudo = (assetHubApi: ApiPromise, rockmineApi: ApiPromise) => { const setMetadataCall = fAssetSetMetadataCall(assetHubApi); - return sudoCallWrapper(trappistApi, setMetadataCall); + return sudoCallWrapper(rockmineApi, setMetadataCall); }; const openHrmpChannels = (api: ApiPromise, sender: number, receiver: number) => { @@ -179,13 +179,13 @@ const main = async () => { await kusamaAssetHubApi.isReady; logWithDate(chalk.green('Created a connection to Kusama AssetHub')); - const trappistApi = await ApiPromise.create({ - provider: new WsProvider(TRAPPIST_WS_URL), + const rockmineApi = await ApiPromise.create({ + provider: new WsProvider(ROCOCO_ASSET_HUB_WS_URL), noInitWarn: true, }); - await trappistApi.isReady; - logWithDate(chalk.green('Created a connection to Trappist')); + await rockmineApi.isReady; + logWithDate(chalk.green('Created a connection to Rococo Asset Hub')); const relayApi = await ApiPromise.create({ provider: new WsProvider(ROCOCO_ALICE_WS_URL), @@ -208,23 +208,23 @@ const main = async () => { await awaitEpochChange(relayApi); logWithDate(chalk.magenta('HRMP channels open')); - logWithDate(chalk.magenta('Sending funds to Trappist Sibling on Kusama AssetHub')); + logWithDate(chalk.magenta('Sending funds to Rococo Asset Hub Sibling on Kusama AssetHub')); - await kusamaAssetHubApi.tx.balances // ParaID 3000 - .transferKeepAlive('5Eg2fntDDP4P8TjqRg3Jq89y5boE26JUMM3D7VU3bCAp76nc', 10000000000000) + await kusamaAssetHubApi.tx.balances + .transferKeepAlive('5Eg2fnsjAAr8RGZfa8Sy5mYFPabA9ZLNGYECCKXPD6xnK6D2', 10000000000000) .signAndSend(bob); - const foreignAssetsCreateSudoXcmCall = createForeignAssetViaSudo(kusamaAssetHubApi, trappistApi); + const foreignAssetsCreateSudoXcmCall = createForeignAssetViaSudo(kusamaAssetHubApi, rockmineApi); logWithDate('Sending Sudo XCM message from relay chain to execute create foreign asset call on Kusama AssetHub'); - await trappistApi.tx.sudo.sudo(foreignAssetsCreateSudoXcmCall).signAndSend(alice); + await rockmineApi.tx.sudo.sudo(foreignAssetsCreateSudoXcmCall).signAndSend(alice); await delay(24000); - const foreignAssetsSetMetadataSudoXcmCall = setMetadataForeignAssetViaSudo(kusamaAssetHubApi, trappistApi); + const foreignAssetsSetMetadataSudoXcmCall = setMetadataForeignAssetViaSudo(kusamaAssetHubApi, rockmineApi); logWithDate('Sending Sudo XCM message from relay chain to execute setMetadata call on Kusama AssetHub'); - await trappistApi.tx.sudo.sudo(foreignAssetsSetMetadataSudoXcmCall).signAndSend(alice); + await rockmineApi.tx.sudo.sudo(foreignAssetsSetMetadataSudoXcmCall).signAndSend(alice); await delay(24000); @@ -232,13 +232,13 @@ const main = async () => { logWithDate(chalk.blue('Polkadot-js successfully disconnected from asset-hub')); }); - await trappistApi.disconnect().then(() => { - logWithDate(chalk.blue('Polkadot-js successfully disconnected from trappist')); + await rockmineApi.disconnect().then(() => { + logWithDate(chalk.blue('Polkadot-js successfully disconnected from Rococo Asset Hub')); }); }; // eslint-disable-next-line @typescript-eslint/no-floating-promises -awaitBlockProduction(TRAPPIST_WS_URL).then(async () => { +awaitBlockProduction(ROCOCO_ASSET_HUB_WS_URL).then(async () => { await main() .catch(console.error) .finally(() => process.exit()); diff --git a/scripts/testNetworkLiquidAssets.ts b/scripts/testNetworkLiquidAssets.ts index fbb69a16..970fc48a 100644 --- a/scripts/testNetworkLiquidAssets.ts +++ b/scripts/testNetworkLiquidAssets.ts @@ -80,12 +80,12 @@ const main = async () => { const hrmpChannelCalls = []; - hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1000), Number(3000))); + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1000), Number(1836))); hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1000), Number(4000))); - hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(3000), Number(1000))); - hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(3000), Number(4000))); + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1836), Number(1000))); + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(1836), Number(4000))); hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(4000), Number(1000))); - hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(4000), Number(3000))); + hrmpChannelCalls.push(openHrmpChannels(relayApi, Number(4000), Number(1836))); await relayApi.tx.sudo.sudo(relayApi.tx.utility.batchAll(hrmpChannelCalls)).signAndSend(alice); diff --git a/src/AssetTransferApi.ts b/src/AssetTransferApi.ts index 93277339..4c17ed47 100644 --- a/src/AssetTransferApi.ts +++ b/src/AssetTransferApi.ts @@ -889,6 +889,7 @@ export class AssetTransferApi { try { feeAsset = sanitizeKeys(JSON.parse(paysWithFeeOrigin)) as UnionXcmMultiLocation; + console.log(feeAsset) } catch (err: unknown) { throw new BaseError( `paysWithFeeOrigin value must be a valid MultiLocation. Received: ${paysWithFeeOrigin}`, @@ -900,15 +901,21 @@ export class AssetTransferApi { try { for (const poolPairsData of await this._api.query.assetConversion.pools.entries()) { const poolStorageKeyData = poolPairsData[0]; + console.log('poolAssetDataStr ' + poolStorageKeyData); + // remove any commas from multilocation key values e.g. Parachain: 2,125 -> Parachain: 2125 const poolAssetDataStr = JSON.stringify(poolStorageKeyData).replace(/(\d),/g, '$1'); + console.log('poolAssetDataStr ' + poolAssetDataStr); const palletAssetConversionNativeOrAssetIdData = sanitizeKeys( JSON.parse(poolAssetDataStr), ) as UnionXcmMultiLocation[]; + const firstLpToken = palletAssetConversionNativeOrAssetIdData[0]; + console.log('first ' + firstLpToken) const secondLpToken = palletAssetConversionNativeOrAssetIdData[1]; + console.log('second ' + secondLpToken) if ( JSON.stringify(firstLpToken) == JSON.stringify(feeAsset) ||