--- a/js-packages/playgrounds/unique.xcm.ts +++ b/js-packages/playgrounds/unique.xcm.ts @@ -104,17 +104,17 @@ } export class ForeignAssetsGroup extends HelperGroup { - async register(signer: TSigner, location: any, name: string, tokenPrefix: string, mode: 'NFT' | { Fungible: number }) { + async register(signer: TSigner, assetId: any, name: string, tokenPrefix: string, mode: 'NFT' | { Fungible: number }) { await this.helper.executeExtrinsic( signer, 'api.tx.foreignAssets.forceRegisterForeignAsset', - [location, this.helper.util.str2vec(name), tokenPrefix, mode], + [assetId, this.helper.util.str2vec(name), tokenPrefix, mode], true, ); } - async foreignCollectionId(location: any) { - return (await this.helper.callRpc('api.query.foreignAssets.foreignReserveLocationToCollection', [location])).toJSON(); + async foreignCollectionId(assetId: any) { + return (await this.helper.callRpc('api.query.foreignAssets.foreignAssetToCollection', [assetId])).toJSON(); } } --- a/js-packages/tests/xcm/xcm.types.ts +++ b/js-packages/tests/xcm/xcm.types.ts @@ -512,15 +512,16 @@ parents: 1, interior: 'Here', }; + const relayAssetId = {Concrete: relayLocation}; - const relayCollectionId = await helper.foreignAssets.foreignCollectionId(relayLocation); + const relayCollectionId = await helper.foreignAssets.foreignCollectionId(relayAssetId); if(relayCollectionId == null) { const name = 'Relay Tokens'; const tokenPrefix = 'xDOT'; const decimals = 10; - await helper.getSudo().foreignAssets.register(alice, relayLocation, name, tokenPrefix, {Fungible: decimals}); + await helper.getSudo().foreignAssets.register(alice, relayAssetId, name, tokenPrefix, {Fungible: decimals}); - return await helper.foreignAssets.foreignCollectionId(relayLocation); + return await helper.foreignAssets.foreignCollectionId(relayAssetId); } else { console.log('Relay foreign collection is already registered'); return relayCollectionId; --- a/js-packages/tests/xcm/xcmOpal.test.ts +++ b/js-packages/tests/xcm/xcmOpal.test.ts @@ -17,7 +17,7 @@ import type {IKeyringPair} from '@polkadot/types/types'; import config from '../config.js'; import {itSub, expect, describeXCM, usingPlaygrounds, usingWestmintPlaygrounds, usingRelayPlaygrounds} from '../util/index.js'; -import {XcmTestHelper} from './xcm.types'; +import {XcmTestHelper} from './xcm.types.js'; const STATEMINE_CHAIN = +(process.env.RELAY_WESTMINT_ID || 1000); const UNIQUE_CHAIN = +(process.env.RELAY_OPAL_ID || 2095); @@ -120,16 +120,23 @@ }, ]}, }; + const assetId = {Concrete: location}; - if(await helper.foreignAssets.foreignCollectionId(location) == null) { + if(await helper.foreignAssets.foreignCollectionId(assetId) == null) { const tokenPrefix = USDT_ASSET_METADATA_NAME; - await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS}); + await helper.getSudo().foreignAssets.register( + alice, + assetId, + USDT_ASSET_METADATA_NAME, + tokenPrefix, + {Fungible: USDT_ASSET_METADATA_DECIMALS}, + ); } else { console.log('Foreign collection is already registered on Opal'); } balanceOpalBefore = await helper.balance.getSubstrate(alice.address); - usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location); + usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId); }); // Providing the relay currency to the unique sender account --- a/js-packages/tests/xcm/xcmQuartz.test.ts +++ b/js-packages/tests/xcm/xcmQuartz.test.ts @@ -19,7 +19,7 @@ import {DevUniqueHelper, Event} from '@unique/playgrounds/unique.dev.js'; import {STATEMINE_CHAIN, QUARTZ_CHAIN, KARURA_CHAIN, MOONRIVER_CHAIN, SHIDEN_CHAIN, STATEMINE_DECIMALS, KARURA_DECIMALS, QTZ_DECIMALS, RELAY_DECIMALS, SHIDEN_DECIMALS, karuraUrl, moonriverUrl, relayUrl, shidenUrl, statemineUrl} from './xcm.types.js'; import {hexToString} from '@polkadot/util'; -import {XcmTestHelper} from './xcm.types'; +import {XcmTestHelper} from './xcm.types.js'; const STATEMINE_PALLET_INSTANCE = 50; @@ -130,16 +130,17 @@ }, ]}, }; + const assetId = {Concrete: location}; - if(await helper.foreignAssets.foreignCollectionId(location) == null) { + if(await helper.foreignAssets.foreignCollectionId(assetId) == null) { const tokenPrefix = USDT_ASSET_METADATA_NAME; - await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS}); + await helper.getSudo().foreignAssets.register(alice, assetId, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS}); } else { console.log('Foreign collection is already registered on Quartz'); } balanceQuartzBefore = await helper.balance.getSubstrate(alice.address); - usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location); + usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId); }); --- a/js-packages/tests/xcm/xcmUnique.test.ts +++ b/js-packages/tests/xcm/xcmUnique.test.ts @@ -20,7 +20,7 @@ import {Event} from '@unique/playgrounds/unique.dev.js'; import {hexToString, nToBigInt} from '@polkadot/util'; import {ACALA_CHAIN, ASTAR_CHAIN, MOONBEAM_CHAIN, POLKADEX_CHAIN, SAFE_XCM_VERSION, STATEMINT_CHAIN, UNIQUE_CHAIN, expectFailedToTransact, expectUntrustedReserveLocationFail, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types.js'; -import {XcmTestHelper} from './xcm.types'; +import {XcmTestHelper} from './xcm.types.js'; const STATEMINT_PALLET_INSTANCE = 50; @@ -142,16 +142,17 @@ }, ]}, }; + const assetId = {Concrete: location}; - if(await helper.foreignAssets.foreignCollectionId(location) == null) { + if(await helper.foreignAssets.foreignCollectionId(assetId) == null) { const tokenPrefix = USDT_ASSET_METADATA_NAME; - await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS}); + await helper.getSudo().foreignAssets.register(alice, assetId, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS}); } else { console.log('Foreign collection is already registered on Unique'); } balanceUniqueBefore = await helper.balance.getSubstrate(alice.address); - usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location); + usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId); });