From f2ade55622b2989f8b4d49e2e74bba5a30b26679 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Thu, 06 Oct 2022 17:31:07 +0000 Subject: [PATCH] feat: add foreignAssets to playgrnds --- --- a/tests/src/util/playgrounds/types.ts +++ b/tests/src/util/playgrounds/types.ts @@ -172,6 +172,13 @@ }, } +export interface IForeignAssetMetadata { + name?: number | Uint8Array, + symbol?: string, + decimals?: number, + minimalBalance?: bigint, +} + export type TSubstrateAccount = string; export type TEthereumAccount = string; export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated'; --- a/tests/src/util/playgrounds/unique.ts +++ b/tests/src/util/playgrounds/unique.ts @@ -9,7 +9,7 @@ import {ApiInterfaceEvents, SignerOptions} from '@polkadot/api/types'; import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto'; import {IKeyringPair} from '@polkadot/types/types'; -import {IApiListeners, IBlock, IEvent, IChainProperties, ICollectionCreationOptions, ICollectionLimits, ICollectionPermissions, ICrossAccountId, ICrossAccountIdLower, ILogger, INestingPermissions, IProperty, IStakingInfo, ISchedulerOptions, ISubstrateBalance, IToken, ITokenPropertyPermission, ITransactionResult, IUniqueHelperLog, TApiAllowedListeners, TEthereumAccount, TSigner, TSubstrateAccount, TUniqueNetworks} from './types'; +import {IApiListeners, IBlock, IEvent, IChainProperties, ICollectionCreationOptions, ICollectionLimits, ICollectionPermissions, ICrossAccountId, ICrossAccountIdLower, ILogger, INestingPermissions, IProperty, IStakingInfo, ISchedulerOptions, ISubstrateBalance, IToken, ITokenPropertyPermission, ITransactionResult, IUniqueHelperLog, TApiAllowedListeners, TEthereumAccount, TSigner, TSubstrateAccount, TUniqueNetworks, IForeignAssetMetadata} from './types'; export class CrossAccountId implements ICrossAccountId { Substrate?: TSubstrateAccount; @@ -2314,6 +2314,30 @@ } } +class ForeignAssetsGroup extends HelperGroup { + constructor(helper: UniqueHelper) { + super(helper); + } + + async register(signer: TSigner, ownerAddress: TSubstrateAccount, location: any, metadata: IForeignAssetMetadata) { + await this.helper.executeExtrinsic( + signer, + 'api.tx.foreignAssets.registerForeignAsset', + [ownerAddress, location, metadata], + true, + ); + } + + async update(signer: TSigner, foreignAssetId: number, location: any, metadata: IForeignAssetMetadata) { + await this.helper.executeExtrinsic( + signer, + 'api.tx.foreignAssets.updateForeignAsset', + [foreignAssetId, location, metadata], + true, + ); + } +} + export type UniqueHelperConstructor = new(...args: any[]) => UniqueHelper; export class UniqueHelper extends ChainHelperBase { @@ -2328,6 +2352,7 @@ ft: FTGroup; staking: StakingGroup; scheduler: SchedulerGroup; + foreignAssets: ForeignAssetsGroup; constructor(logger?: ILogger, options: {[key: string]: any} = {}) { super(logger); @@ -2343,6 +2368,7 @@ this.ft = new FTGroup(this); this.staking = new StakingGroup(this); this.scheduler = new SchedulerGroup(this); + this.foreignAssets = new ForeignAssetsGroup(this); } clone(helperCls: UniqueHelperConstructor, options: {[key: string]: any} = {}) { -- gitstuff