git.delta.rocks / unique-network / refs/commits / f2ade55622b2

difftreelog

feat add foreignAssets to playgrnds

Daniel Shiposha2022-10-06parent: #3bccb6b.patch.diff
in: master

2 files changed

modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
172 },172 },
173}173}
174
175export interface IForeignAssetMetadata {
176 name?: number | Uint8Array,
177 symbol?: string,
178 decimals?: number,
179 minimalBalance?: bigint,
180}
174181
175export type TSubstrateAccount = string;182export type TSubstrateAccount = string;
176export type TEthereumAccount = string;183export type TEthereumAccount = string;
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- 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} = {}) {