difftreelog
feat add foreignAssets to playgrnds
in: master
2 files changed
tests/src/util/playgrounds/types.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IEvent {7 section: string;8 method: string;9 index: [number, number] | string;10 data: any[];11 phase: {applyExtrinsic: number} | 'Initialization',12}1314export interface ITransactionResult {15 status: 'Fail' | 'Success';16 result: {17 dispatchError: any,18 events: {19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',20 event: IEvent;21 }[];22 },23 moduleError?: string;24}2526export interface ISubscribeBlockEventsData {27 number: number;28 hash: string;29 timestamp: number; 30 events: IEvent[];31}3233export interface ILogger {34 log: (msg: any, level?: string) => void;35 level: {36 ERROR: 'ERROR';37 WARNING: 'WARNING';38 INFO: 'INFO';39 [key: string]: string;40 }41}4243export interface IUniqueHelperLog {44 executedAt: number;45 executionTime: number;46 type: 'extrinsic' | 'rpc';47 status: 'Fail' | 'Success';48 call: string;49 params: any[];50 moduleError?: string;51 dispatchError?: any;52 events?: any;53}5455export interface IApiListeners {56 connected?: (...args: any[]) => any;57 disconnected?: (...args: any[]) => any;58 error?: (...args: any[]) => any;59 ready?: (...args: any[]) => any; 60 decorated?: (...args: any[]) => any;61}6263export interface ICrossAccountId {64 Substrate?: TSubstrateAccount;65 Ethereum?: TEthereumAccount;66}6768export interface ICrossAccountIdLower {69 substrate?: TSubstrateAccount;70 ethereum?: TEthereumAccount;71}7273export interface ICollectionLimits {74 accountTokenOwnershipLimit?: number | null;75 sponsoredDataSize?: number | null;76 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;77 tokenLimit?: number | null;78 sponsorTransferTimeout?: number | null;79 sponsorApproveTimeout?: number | null;80 ownerCanTransfer?: boolean | null;81 ownerCanDestroy?: boolean | null;82 transfersEnabled?: boolean | null;83}8485export interface INestingPermissions {86 tokenOwner?: boolean;87 collectionAdmin?: boolean;88 restricted?: number[] | null;89}9091export interface ICollectionPermissions {92 access?: 'Normal' | 'AllowList';93 mintMode?: boolean;94 nesting?: INestingPermissions;95}9697export interface IProperty {98 key: string;99 value?: string;100}101102export interface ITokenPropertyPermission {103 key: string;104 permission: {105 mutable?: boolean;106 tokenOwner?: boolean;107 collectionAdmin?: boolean;108 }109}110111export interface IToken {112 collectionId: number;113 tokenId: number;114}115116export interface IBlock {117 extrinsics: IExtrinsic[]118 header: {119 parentHash: string,120 number: number,121 };122}123124export interface IExtrinsic {125 isSigned: boolean,126 method: {127 method: string,128 section: string,129 args: any[]130 }131}132133export interface ICollectionCreationOptions {134 name?: string | number[];135 description?: string | number[];136 tokenPrefix?: string | number[];137 mode?: {138 nft?: null;139 refungible?: null;140 fungible?: number;141 }142 permissions?: ICollectionPermissions;143 properties?: IProperty[];144 tokenPropertyPermissions?: ITokenPropertyPermission[];145 limits?: ICollectionLimits;146 pendingSponsor?: TSubstrateAccount;147}148149export interface IChainProperties {150 ss58Format: number;151 tokenDecimals: number[];152 tokenSymbol: string[]153}154155export interface ISubstrateBalance {156 free: bigint,157 reserved: bigint,158 miscFrozen: bigint,159 feeFrozen: bigint160}161162export interface IStakingInfo {163 block: bigint,164 amount: bigint,165}166167export interface ISchedulerOptions {168 priority?: number,169 periodic?: {170 period: number,171 repetitions: number,172 },173}174175export type TSubstrateAccount = string;176export type TEthereumAccount = string;177export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';178export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';179export type TSigner = IKeyringPair; // | 'string'1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IEvent {7 section: string;8 method: string;9 index: [number, number] | string;10 data: any[];11 phase: {applyExtrinsic: number} | 'Initialization',12}1314export interface ITransactionResult {15 status: 'Fail' | 'Success';16 result: {17 dispatchError: any,18 events: {19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',20 event: IEvent;21 }[];22 },23 moduleError?: string;24}2526export interface ISubscribeBlockEventsData {27 number: number;28 hash: string;29 timestamp: number; 30 events: IEvent[];31}3233export interface ILogger {34 log: (msg: any, level?: string) => void;35 level: {36 ERROR: 'ERROR';37 WARNING: 'WARNING';38 INFO: 'INFO';39 [key: string]: string;40 }41}4243export interface IUniqueHelperLog {44 executedAt: number;45 executionTime: number;46 type: 'extrinsic' | 'rpc';47 status: 'Fail' | 'Success';48 call: string;49 params: any[];50 moduleError?: string;51 dispatchError?: any;52 events?: any;53}5455export interface IApiListeners {56 connected?: (...args: any[]) => any;57 disconnected?: (...args: any[]) => any;58 error?: (...args: any[]) => any;59 ready?: (...args: any[]) => any; 60 decorated?: (...args: any[]) => any;61}6263export interface ICrossAccountId {64 Substrate?: TSubstrateAccount;65 Ethereum?: TEthereumAccount;66}6768export interface ICrossAccountIdLower {69 substrate?: TSubstrateAccount;70 ethereum?: TEthereumAccount;71}7273export interface ICollectionLimits {74 accountTokenOwnershipLimit?: number | null;75 sponsoredDataSize?: number | null;76 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;77 tokenLimit?: number | null;78 sponsorTransferTimeout?: number | null;79 sponsorApproveTimeout?: number | null;80 ownerCanTransfer?: boolean | null;81 ownerCanDestroy?: boolean | null;82 transfersEnabled?: boolean | null;83}8485export interface INestingPermissions {86 tokenOwner?: boolean;87 collectionAdmin?: boolean;88 restricted?: number[] | null;89}9091export interface ICollectionPermissions {92 access?: 'Normal' | 'AllowList';93 mintMode?: boolean;94 nesting?: INestingPermissions;95}9697export interface IProperty {98 key: string;99 value?: string;100}101102export interface ITokenPropertyPermission {103 key: string;104 permission: {105 mutable?: boolean;106 tokenOwner?: boolean;107 collectionAdmin?: boolean;108 }109}110111export interface IToken {112 collectionId: number;113 tokenId: number;114}115116export interface IBlock {117 extrinsics: IExtrinsic[]118 header: {119 parentHash: string,120 number: number,121 };122}123124export interface IExtrinsic {125 isSigned: boolean,126 method: {127 method: string,128 section: string,129 args: any[]130 }131}132133export interface ICollectionCreationOptions {134 name?: string | number[];135 description?: string | number[];136 tokenPrefix?: string | number[];137 mode?: {138 nft?: null;139 refungible?: null;140 fungible?: number;141 }142 permissions?: ICollectionPermissions;143 properties?: IProperty[];144 tokenPropertyPermissions?: ITokenPropertyPermission[];145 limits?: ICollectionLimits;146 pendingSponsor?: TSubstrateAccount;147}148149export interface IChainProperties {150 ss58Format: number;151 tokenDecimals: number[];152 tokenSymbol: string[]153}154155export interface ISubstrateBalance {156 free: bigint,157 reserved: bigint,158 miscFrozen: bigint,159 feeFrozen: bigint160}161162export interface IStakingInfo {163 block: bigint,164 amount: bigint,165}166167export interface ISchedulerOptions {168 priority?: number,169 periodic?: {170 period: number,171 repetitions: number,172 },173}174175export interface IForeignAssetMetadata {176 name?: number | Uint8Array,177 symbol?: string,178 decimals?: number,179 minimalBalance?: bigint,180}181182export type TSubstrateAccount = string;183export type TEthereumAccount = string;184export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';185export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';186export type TSigner = IKeyringPair; // | 'string'tests/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} = {}) {