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

difftreelog

fix tests around foreign flag

Daniel Shiposha2023-10-18parent: #dbb52bb.patch.diff
in: master

3 files changed

modifiedjs-packages/playgrounds/types.tsdiffbeforeafterboth
before · js-packages/playgrounds/types.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import type {IKeyringPair} from '@polkadot/types/types';56export const NON_EXISTENT_COLLECTION_ID = 4_294_967_295;78export const MILLISECS_PER_BLOCK = 12000;9export const MINUTES = 60_000 / MILLISECS_PER_BLOCK;10export const HOURS = MINUTES * 60;11export const DAYS = HOURS * 24;1213export interface IEvent {14  section: string;15  method: string;16  index: [number, number] | string;17  data: any[];18  phase: {applyExtrinsic: number} | 'Initialization',19}2021export interface IPhasicEvent {22  phase: any, // {ApplyExtrinsic: number} | 'Initialization',23  event: IEvent;24}2526export interface ITransactionResult {27  status: 'Fail' | 'Success';28  result: {29      dispatchError: any,30      events: IPhasicEvent[];31  },32  blockHash: string,33  moduleError?: string | object;34}3536export interface ISubscribeBlockEventsData {37  number: number;38  hash: string;39  timestamp: number;40  events: IEvent[];41}4243export interface ILogger {44  log: (msg: any, level?: string) => void;45  level: {46    ERROR: 'ERROR';47    WARNING: 'WARNING';48    INFO: 'INFO';49    [key: string]: string;50  }51}5253export interface IUniqueHelperLog {54  executedAt: number;55  executionTime: number;56  type: 'extrinsic' | 'rpc';57  status: 'Fail' | 'Success';58  call: string;59  params: any[];60  moduleError?: string;61  dispatchError?: any;62  events?: any;63}6465export interface IApiListeners {66  connected?: (...args: any[]) => any;67  disconnected?: (...args: any[]) => any;68  error?: (...args: any[]) => any;69  ready?: (...args: any[]) => any;70  decorated?: (...args: any[]) => any;71}7273export type ICrossAccountId = {74  Substrate: TSubstrateAccount;75} | {76  Ethereum: TEthereumAccount;77}7879export type ICrossAccountIdLower = {80  substrate: TSubstrateAccount;81} | {82  ethereum: TEthereumAccount;83};8485export interface IEthCrossAccountId {86  0: TEthereumAccount;87  1: TSubstrateAccount;88  eth: TEthereumAccount;89  sub: TSubstrateAccount;90}9192export interface ICollectionLimits {93  accountTokenOwnershipLimit?: number | null;94  sponsoredDataSize?: number | null;95  sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;96  tokenLimit?: number | null;97  sponsorTransferTimeout?: number | null;98  sponsorApproveTimeout?: number | null;99  ownerCanTransfer?: boolean | null;100  ownerCanDestroy?: boolean | null;101  transfersEnabled?: boolean | null;102}103104export interface INestingPermissions {105  tokenOwner?: boolean;106  collectionAdmin?: boolean;107  restricted?: number[] | null;108}109110export interface ICollectionPermissions {111  access?: 'Normal' | 'AllowList';112  mintMode?: boolean;113  nesting?: INestingPermissions;114}115116export interface IProperty {117  key: string;118  value?: string;119}120121export interface ITokenPropertyPermission {122  key: string;123  permission: {124    mutable?: boolean;125    tokenOwner?: boolean;126    collectionAdmin?: boolean;127  }128}129130export interface IToken {131  collectionId: number;132  tokenId: number;133}134135export interface IBlock {136  extrinsics: IExtrinsic[]137  header: {138    parentHash: string,139    number: number,140  };141}142143export interface IExtrinsic {144  isSigned: boolean,145  method: {146    method: string,147    section: string,148    args: any[]149  }150}151152export interface ICollectionFlags {153  foreign: boolean,154  erc721metadata: boolean,155}156157export enum CollectionFlag {158  None = 0,159  /// External collections can't be managed using `unique` api160  External = 1,161  /// Supports ERC721Metadata162  Erc721metadata = 64,163  /// Tokens in foreign collections can be transferred, but not burnt164  Foreign = 128,165}166167export interface ICollectionCreationOptions {168  name?: string | number[];169  description?: string | number[];170  tokenPrefix?: string | number[];171  mode?: {172    nft?: null;173    refungible?: null;174    fungible?: number;175  }176  permissions?: ICollectionPermissions;177  properties?: IProperty[];178  tokenPropertyPermissions?: ITokenPropertyPermission[];179  limits?: ICollectionLimits;180  pendingSponsor?: ICrossAccountId;181  adminList?: ICrossAccountId[];182  flags?: number[] | CollectionFlag[] ,183}184185export interface IChainProperties {186  ss58Format: number;187  tokenDecimals: number[];188  tokenSymbol: string[]189}190191export interface ISubstrateBalance {192  free: bigint,193  reserved: bigint,194  frozen: bigint,195}196197export interface IStakingInfo {198  block: bigint,199  amount: bigint,200}201202export interface IPovInfo {203  proofSize: number,204  compactProofSize: number,205  compressedProofSize: number,206  results: any[],207  kv: any,208}209210export interface ISchedulerOptions {211  scheduledId?: string,212  priority?: number,213  periodic?: {214    period: number,215    repetitions: number,216  },217}218219export interface DemocracySplitAccount {220  aye: bigint,221  nay: bigint,222}223224export type TSubstrateAccount = string;225export type TEthereumAccount = string;226export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';227export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';228export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';229export type TRelayNetworks = 'rococo' | 'westend';230export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;231export type TSigner = IKeyringPair; // | 'string'232export type TCollectionMode = 'nft' | 'rft' | 'ft';
after · js-packages/playgrounds/types.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import type {IKeyringPair} from '@polkadot/types/types';56export const NON_EXISTENT_COLLECTION_ID = 4_294_967_295;78export const MILLISECS_PER_BLOCK = 12000;9export const MINUTES = 60_000 / MILLISECS_PER_BLOCK;10export const HOURS = MINUTES * 60;11export const DAYS = HOURS * 24;1213export interface IEvent {14  section: string;15  method: string;16  index: [number, number] | string;17  data: any[];18  phase: {applyExtrinsic: number} | 'Initialization',19}2021export interface IPhasicEvent {22  phase: any, // {ApplyExtrinsic: number} | 'Initialization',23  event: IEvent;24}2526export interface ITransactionResult {27  status: 'Fail' | 'Success';28  result: {29      dispatchError: any,30      events: IPhasicEvent[];31  },32  blockHash: string,33  moduleError?: string | object;34}3536export interface ISubscribeBlockEventsData {37  number: number;38  hash: string;39  timestamp: number;40  events: IEvent[];41}4243export interface ILogger {44  log: (msg: any, level?: string) => void;45  level: {46    ERROR: 'ERROR';47    WARNING: 'WARNING';48    INFO: 'INFO';49    [key: string]: string;50  }51}5253export interface IUniqueHelperLog {54  executedAt: number;55  executionTime: number;56  type: 'extrinsic' | 'rpc';57  status: 'Fail' | 'Success';58  call: string;59  params: any[];60  moduleError?: string;61  dispatchError?: any;62  events?: any;63}6465export interface IApiListeners {66  connected?: (...args: any[]) => any;67  disconnected?: (...args: any[]) => any;68  error?: (...args: any[]) => any;69  ready?: (...args: any[]) => any;70  decorated?: (...args: any[]) => any;71}7273export type ICrossAccountId = {74  Substrate: TSubstrateAccount;75} | {76  Ethereum: TEthereumAccount;77}7879export type ICrossAccountIdLower = {80  substrate: TSubstrateAccount;81} | {82  ethereum: TEthereumAccount;83};8485export interface IEthCrossAccountId {86  0: TEthereumAccount;87  1: TSubstrateAccount;88  eth: TEthereumAccount;89  sub: TSubstrateAccount;90}9192export interface ICollectionLimits {93  accountTokenOwnershipLimit?: number | null;94  sponsoredDataSize?: number | null;95  sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;96  tokenLimit?: number | null;97  sponsorTransferTimeout?: number | null;98  sponsorApproveTimeout?: number | null;99  ownerCanTransfer?: boolean | null;100  ownerCanDestroy?: boolean | null;101  transfersEnabled?: boolean | null;102}103104export interface INestingPermissions {105  tokenOwner?: boolean;106  collectionAdmin?: boolean;107  restricted?: number[] | null;108}109110export interface ICollectionPermissions {111  access?: 'Normal' | 'AllowList';112  mintMode?: boolean;113  nesting?: INestingPermissions;114}115116export interface IProperty {117  key: string;118  value?: string;119}120121export interface ITokenPropertyPermission {122  key: string;123  permission: {124    mutable?: boolean;125    tokenOwner?: boolean;126    collectionAdmin?: boolean;127  }128}129130export interface IToken {131  collectionId: number;132  tokenId: number;133}134135export interface IBlock {136  extrinsics: IExtrinsic[]137  header: {138    parentHash: string,139    number: number,140  };141}142143export interface IExtrinsic {144  isSigned: boolean,145  method: {146    method: string,147    section: string,148    args: any[]149  }150}151152export interface ICollectionFlags {153  foreign: boolean,154  erc721metadata: boolean,155}156157export enum CollectionFlag {158  None = 0,159  /// External collections can't be managed using `unique` api160  External = 1,161  /// Supports ERC721Metadata162  Erc721metadata = 64,163}164165export interface ICollectionCreationOptions {166  name?: string | number[];167  description?: string | number[];168  tokenPrefix?: string | number[];169  mode?: {170    nft?: null;171    refungible?: null;172    fungible?: number;173  }174  permissions?: ICollectionPermissions;175  properties?: IProperty[];176  tokenPropertyPermissions?: ITokenPropertyPermission[];177  limits?: ICollectionLimits;178  pendingSponsor?: ICrossAccountId;179  adminList?: ICrossAccountId[];180  flags?: number[] | CollectionFlag[] ,181}182183export interface IChainProperties {184  ss58Format: number;185  tokenDecimals: number[];186  tokenSymbol: string[]187}188189export interface ISubstrateBalance {190  free: bigint,191  reserved: bigint,192  frozen: bigint,193}194195export interface IStakingInfo {196  block: bigint,197  amount: bigint,198}199200export interface IPovInfo {201  proofSize: number,202  compactProofSize: number,203  compressedProofSize: number,204  results: any[],205  kv: any,206}207208export interface ISchedulerOptions {209  scheduledId?: string,210  priority?: number,211  periodic?: {212    period: number,213    repetitions: number,214  },215}216217export interface DemocracySplitAccount {218  aye: bigint,219  nay: bigint,220}221222export type TSubstrateAccount = string;223export type TEthereumAccount = string;224export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';225export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';226export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';227export type TRelayNetworks = 'rococo' | 'westend';228export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;229export type TSigner = IKeyringPair; // | 'string'230export type TCollectionMode = 'nft' | 'rft' | 'ft';
modifiedjs-packages/tests/createCollection.test.tsdiffbeforeafterboth
--- a/js-packages/tests/createCollection.test.ts
+++ b/js-packages/tests/createCollection.test.ts
@@ -106,18 +106,6 @@
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       flags: [CollectionFlag.Erc721metadata],
     }, 'nft');
-
-    // User can not set Foreign flag itself
-
-    await expect(mintCollectionHelper(helper, alice, {
-      name: 'name', description: 'descr', tokenPrefix: 'COL',
-      flags: [CollectionFlag.Foreign],
-    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
-
-    await expect(mintCollectionHelper(helper, alice, {
-      name: 'name', description: 'descr', tokenPrefix: 'COL',
-      flags: [CollectionFlag.Erc721metadata, CollectionFlag.Foreign],
-    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
   });
 
   itSub('Create new collection with extra fields', async ({helper}) => {
modifiedjs-packages/tests/eth/createCollection.test.tsdiffbeforeafterboth
--- a/js-packages/tests/eth/createCollection.test.ts
+++ b/js-packages/tests/eth/createCollection.test.ts
@@ -1404,16 +1404,16 @@
 
       {
         const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: 0}).send();
-        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: false});
+        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({erc721metadata: false});
       }
 
       {
         const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: 64}).send();
-        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: true});
+        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({erc721metadata: true});
       }
     });
 
-    itEth('NFT: can\'t set foreign flag number', async ({helper}) => {
+    itEth('NFT: cannot set a reserved flag number', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
 
       {
@@ -1430,19 +1430,7 @@
 
       {
         const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Erc721metadata]}).send();
-        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: true});
-      }
-    });
-
-    itEth('NFT: foreign flag enum is ignored', async ({helper}) => {
-      const owner = await helper.eth.createAccountWithBalance(donor);
-
-      {
-        await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Foreign]}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);
-      }
-
-      {
-        await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Erc721metadata | CollectionFlag.Foreign]}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);
+        expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({erc721metadata: true});
       }
     });
   });