git.delta.rocks / unique-network / refs/commits / 7f26d6928c9d

difftreelog

fix tests

Trubnikov Sergey2022-12-09parent: #5811ea8.patch.diff
in: master

2 files changed

modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
before · tests/src/eth/events.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';20import {TCollectionMode} from '../util/playgrounds/types';2122let donor: IKeyringPair;23  24before(async function () {25  await usingEthPlaygrounds(async (_helper, privateKey) => {26    donor = await privateKey({filename: __filename});27  });28});2930async function testCollectionCreatedAndDestroy(helper: EthUniqueHelper, mode: TCollectionMode) {31  const owner = await helper.eth.createAccountWithBalance(donor);32  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);33  const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');34  {35    expect(ethEvents).to.be.like([36      {37        event: 'CollectionCreated',38        args: {39          owner: owner,40          collectionId: collectionAddress,41        },42      },43    ]);44    expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);45    ethEvents.pop();46    subEvents.pop();47  }48  {49    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);50    const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});51    expect(result.events).to.be.like({52      CollectionDestroyed: {53        returnValues: {54          collectionId: collectionAddress,55        },56      },57    });58    expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);59  }60  unsubscribe();61}6263async function testCollectionPropertySetAndCollectionPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {64  const owner = await helper.eth.createAccountWithBalance(donor);65  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');66  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);67  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);68    69  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);70  {71    const ethEvents: any = [];72    collectionHelper.events.allEvents((_: any, event: any) => {73      ethEvents.push(event);74    });75    await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});76    expect(ethEvents).to.be.like([77      {78        event: 'CollectionChanged',79        returnValues: {80          collectionId: collectionAddress,81        },82      },83    ]);84    expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);85    subEvents.pop();86  }87  {88    const ethEvents: any = [];89    collectionHelper.events.allEvents((_: any, event: any) => {90      ethEvents.push(event);91    });92    await collection.methods.deleteCollectionProperties(['A']).send({from:owner});93    expect(ethEvents).to.be.like([94      {95        event: 'CollectionChanged',96        returnValues: {97          collectionId: collectionAddress,98        },99      },100    ]);101    expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);102  }103  unsubscribe();104}105106async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {107  const owner = await helper.eth.createAccountWithBalance(donor);108  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');109  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);110  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);111  const eethEvents: any = [];112  collectionHelper.events.allEvents((_: any, event: any) => {113    eethEvents.push(event);114  });115  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);116  await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});117  expect(eethEvents).to.be.like([118    {119      event: 'CollectionChanged',120      returnValues: {121        collectionId: collectionAddress,122      },123    },124  ]);125  expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);126  unsubscribe();127}128129async function testAllowListAddressAddedAndAllowListAddressRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {130  const owner = await helper.eth.createAccountWithBalance(donor);131  const user = helper.ethCrossAccount.createAccount();132  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');133  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);134  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);135  const ethEvents: any[] = [];136  collectionHelper.events.allEvents((_: any, event: any) => {137    ethEvents.push(event);138  });139140  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);141  {142    await collection.methods.addToCollectionAllowListCross(user).send({from: owner});143    expect(ethEvents).to.be.like([144      {145        event: 'CollectionChanged',146        returnValues: {147          collectionId: collectionAddress,148        },149      },150    ]);151    expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);152    ethEvents.pop();153    subEvents.pop();154  }155  {156    await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});157    expect(ethEvents.length).to.be.eq(1);158    expect(ethEvents).to.be.like([159      {160        event: 'CollectionChanged',161        returnValues: {162          collectionId: collectionAddress,163        },164      },165    ]);166    expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);167  }168  unsubscribe();169}170171async function testCollectionAdminAddedAndCollectionAdminRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {172  const owner = await helper.eth.createAccountWithBalance(donor);173  const user = helper.ethCrossAccount.createAccount();174  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');175  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);176  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);177  const ethEvents: any = [];178  collectionHelper.events.allEvents((_: any, event: any) => {179    ethEvents.push(event);180  });181  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);182  {183    await collection.methods.addCollectionAdminCross(user).send({from: owner});184    expect(ethEvents).to.be.like([185      {186        event: 'CollectionChanged',187        returnValues: {188          collectionId: collectionAddress,189        },190      },191    ]);192    expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);193    ethEvents.pop();194    subEvents.pop();195  }196  {197    await collection.methods.removeCollectionAdminCross(user).send({from: owner});198    expect(ethEvents).to.be.like([199      {200        event: 'CollectionChanged',201        returnValues: {202          collectionId: collectionAddress,203        },204      },205    ]);206    expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);207  }208  unsubscribe();209}210211async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {212  const owner = await helper.eth.createAccountWithBalance(donor);213  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');214  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);215  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);216  const ethEvents: any = [];217  collectionHelper.events.allEvents((_: any, event: any) => {218    ethEvents.push(event);219  });220  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);221  {222    await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});223    expect(ethEvents).to.be.like([224      {225        event: 'CollectionChanged',226        returnValues: {227          collectionId: collectionAddress,228        },229      },230    ]);231    expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);232  }233  unsubscribe();234}235236async function testCollectionOwnedChanged(helper: EthUniqueHelper, mode: TCollectionMode) {237  const owner = await helper.eth.createAccountWithBalance(donor);238  const new_owner = helper.ethCrossAccount.createAccount();239  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');240  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);241  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);242  const ethEvents: any = [];243  collectionHelper.events.allEvents((_: any, event: any) => {244    ethEvents.push(event);245  });246  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);247  {248    await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});249    expect(ethEvents).to.be.like([250      {251        event: 'CollectionChanged',252        returnValues: {253          collectionId: collectionAddress,254        },255      },256    ]);257    expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);258  }259  unsubscribe();260}261262async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {263  const owner = await helper.eth.createAccountWithBalance(donor);264  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');265  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);266  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);267  const ethEvents: any = [];268  collectionHelper.events.allEvents((_: any, event: any) => {269    ethEvents.push(event);270  });271  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);272  {273    await collection.methods.setCollectionMintMode(true).send({from: owner});274    expect(ethEvents).to.be.like([275      {276        event: 'CollectionChanged',277        returnValues: {278          collectionId: collectionAddress,279        },280      },281    ]);282    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);283    ethEvents.pop();284    subEvents.pop();285  }286  {287    await collection.methods.setCollectionAccess(1).send({from: owner});288    expect(ethEvents).to.be.like([289      {290        event: 'CollectionChanged',291        returnValues: {292          collectionId: collectionAddress,293        },294      },295    ]);296    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);297  }298  unsubscribe();299}300301async function testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {302  const owner = await helper.eth.createAccountWithBalance(donor);303  const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);304  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');305  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);306  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);307  const ethEvents: any = [];308  collectionHelper.events.allEvents((_: any, event: any) => {309    ethEvents.push(event);310  });311  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{312    section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved',313    ]}]);314  {315    await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});316    expect(ethEvents).to.be.like([317      {318        event: 'CollectionChanged',319        returnValues: {320          collectionId: collectionAddress,321        },322      },323    ]);324    expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);325    ethEvents.pop();326    subEvents.pop();327  }328  {329    await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});330    expect(ethEvents).to.be.like([331      {332        event: 'CollectionChanged',333        returnValues: {334          collectionId: collectionAddress,335        },336      },337    ]);338    expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);339    ethEvents.pop();340    subEvents.pop();341  }342  {343    await collection.methods.removeCollectionSponsor().send({from: owner});344    expect(ethEvents).to.be.like([345      {346        event: 'CollectionChanged',347        returnValues: {348          collectionId: collectionAddress,349        },350      },351    ]);352    expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);353  }354  unsubscribe();355}356357async function testTokenPropertySetAndTokenPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {358  const owner = await helper.eth.createAccountWithBalance(donor);359  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');360  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);361  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);362  const result = await collection.methods.mint(owner).send({from: owner});363  const tokenId = result.events.Transfer.returnValues.tokenId;364  await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});365366367  const ethEvents: any = [];368  collectionHelper.events.allEvents((_: any, event: any) => {369    ethEvents.push(event);370  });371  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);372  {373    await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});374    expect(ethEvents).to.be.like([375      {376        event: 'TokenChanged',377        returnValues: {378          collectionId: collectionAddress,379        },380      },381    ]);382    expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);383    ethEvents.pop();384    subEvents.pop();385  }386  {387    await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});388    expect(ethEvents).to.be.like([389      {390        event: 'TokenChanged',391        returnValues: {392          collectionId: collectionAddress,393        },394      },395    ]);396    expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);397  }398  unsubscribe();399}400401describe('[FT] Sync sub & eth events', () => {402  const mode: TCollectionMode = 'ft';403404  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {405    await testCollectionCreatedAndDestroy(helper, mode);406  });407408  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {409    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);410  });411    412  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {413    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);414  });415    416  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {417    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);418  });419    420  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {421    await testCollectionLimitSet(helper, mode);422  });423    424  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {425    await testCollectionOwnedChanged(helper, mode);426  });427    428  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {429    await testCollectionPermissionSet(helper, mode);430  });431432  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {433    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);434  });435});436437describe('[NFT] Sync sub & eth events', () => {438  const mode: TCollectionMode = 'nft';439440  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {441    await testCollectionCreatedAndDestroy(helper, mode);442  });443444  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {445    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);446  });447    448  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {449    await testPropertyPermissionSet(helper, mode);450  });451    452  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {453    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);454  });455    456  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {457    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);458  });459    460  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {461    await testCollectionLimitSet(helper, mode);462  });463    464  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {465    await testCollectionOwnedChanged(helper, mode);466  });467    468  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {469    await testCollectionPermissionSet(helper, mode);470  });471472  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {473    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);474  });475     476  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {477    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);478  });479});480481describe('[RFT] Sync sub & eth events', () => {482  const mode: TCollectionMode = 'rft';483484  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {485    await testCollectionCreatedAndDestroy(helper, mode);486  });487488  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {489    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);490  });491    492  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {493    await testPropertyPermissionSet(helper, mode);494  });495    496  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {497    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);498  });499    500  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {501    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);502  });503    504  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {505    await testCollectionLimitSet(helper, mode);506  });507    508  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {509    await testCollectionOwnedChanged(helper, mode);510  });511    512  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {513    await testCollectionPermissionSet(helper, mode);514  });515516  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {517    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);518  });519     520  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {521    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);522  });523});
after · tests/src/eth/events.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';20import {TCollectionMode} from '../util/playgrounds/types';2122let donor: IKeyringPair;23  24before(async function () {25  await usingEthPlaygrounds(async (_helper, privateKey) => {26    donor = await privateKey({filename: __filename});27  });28});2930async function testCollectionCreatedAndDestroy(helper: EthUniqueHelper, mode: TCollectionMode) {31  const owner = await helper.eth.createAccountWithBalance(donor);32  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);33  const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');34  await helper.wait.newBlocks(1);35  {36    expect(ethEvents).to.be.like([37      {38        event: 'CollectionCreated',39        args: {40          owner: owner,41          collectionId: collectionAddress,42        },43      },44    ]);45    expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);46    ethEvents.pop();47    subEvents.pop();48  }49  {50    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);51    const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});52    await helper.wait.newBlocks(1);53    expect(result.events).to.be.like({54      CollectionDestroyed: {55        returnValues: {56          collectionId: collectionAddress,57        },58      },59    });60    expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);61  }62  unsubscribe();63}6465async function testCollectionPropertySetAndCollectionPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {66  const owner = await helper.eth.createAccountWithBalance(donor);67  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');68  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);69  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);70    71  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);72  {73    const ethEvents: any = [];74    collectionHelper.events.allEvents((_: any, event: any) => {75      ethEvents.push(event);76    });77    await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});78    await helper.wait.newBlocks(1);79    expect(ethEvents).to.be.like([80      {81        event: 'CollectionChanged',82        returnValues: {83          collectionId: collectionAddress,84        },85      },86    ]);87    expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);88    subEvents.pop();89  }90  {91    const ethEvents: any = [];92    collectionHelper.events.allEvents((_: any, event: any) => {93      ethEvents.push(event);94    });95    await collection.methods.deleteCollectionProperties(['A']).send({from:owner});96    await helper.wait.newBlocks(1);97    expect(ethEvents).to.be.like([98      {99        event: 'CollectionChanged',100        returnValues: {101          collectionId: collectionAddress,102        },103      },104    ]);105    expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);106  }107  unsubscribe();108}109110async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {111  const owner = await helper.eth.createAccountWithBalance(donor);112  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');113  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);114  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);115  const eethEvents: any = [];116  collectionHelper.events.allEvents((_: any, event: any) => {117    eethEvents.push(event);118  });119  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);120  await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});121  await helper.wait.newBlocks(1);122  expect(eethEvents).to.be.like([123    {124      event: 'CollectionChanged',125      returnValues: {126        collectionId: collectionAddress,127      },128    },129  ]);130  expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);131  unsubscribe();132}133134async function testAllowListAddressAddedAndAllowListAddressRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {135  const owner = await helper.eth.createAccountWithBalance(donor);136  const user = helper.ethCrossAccount.createAccount();137  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');138  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);139  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);140  const ethEvents: any[] = [];141  collectionHelper.events.allEvents((_: any, event: any) => {142    ethEvents.push(event);143  });144145  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);146  {147    await collection.methods.addToCollectionAllowListCross(user).send({from: owner});148    await helper.wait.newBlocks(1);149    expect(ethEvents).to.be.like([150      {151        event: 'CollectionChanged',152        returnValues: {153          collectionId: collectionAddress,154        },155      },156    ]);157    expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);158    ethEvents.pop();159    subEvents.pop();160  }161  {162    await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});163    await helper.wait.newBlocks(1);164    expect(ethEvents.length).to.be.eq(1);165    expect(ethEvents).to.be.like([166      {167        event: 'CollectionChanged',168        returnValues: {169          collectionId: collectionAddress,170        },171      },172    ]);173    expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);174  }175  unsubscribe();176}177178async function testCollectionAdminAddedAndCollectionAdminRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {179  const owner = await helper.eth.createAccountWithBalance(donor);180  const user = helper.ethCrossAccount.createAccount();181  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');182  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);183  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);184  const ethEvents: any = [];185  collectionHelper.events.allEvents((_: any, event: any) => {186    ethEvents.push(event);187  });188  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);189  {190    await collection.methods.addCollectionAdminCross(user).send({from: owner});191    await helper.wait.newBlocks(1);192    expect(ethEvents).to.be.like([193      {194        event: 'CollectionChanged',195        returnValues: {196          collectionId: collectionAddress,197        },198      },199    ]);200    expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);201    ethEvents.pop();202    subEvents.pop();203  }204  {205    await collection.methods.removeCollectionAdminCross(user).send({from: owner});206    await helper.wait.newBlocks(1);207    expect(ethEvents).to.be.like([208      {209        event: 'CollectionChanged',210        returnValues: {211          collectionId: collectionAddress,212        },213      },214    ]);215    expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);216  }217  unsubscribe();218}219220async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {221  const owner = await helper.eth.createAccountWithBalance(donor);222  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');223  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);224  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);225  const ethEvents: any = [];226  collectionHelper.events.allEvents((_: any, event: any) => {227    ethEvents.push(event);228  });229  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);230  {231    await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});232    await helper.wait.newBlocks(1);233    expect(ethEvents).to.be.like([234      {235        event: 'CollectionChanged',236        returnValues: {237          collectionId: collectionAddress,238        },239      },240    ]);241    expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);242  }243  unsubscribe();244}245246async function testCollectionOwnedChanged(helper: EthUniqueHelper, mode: TCollectionMode) {247  const owner = await helper.eth.createAccountWithBalance(donor);248  const new_owner = helper.ethCrossAccount.createAccount();249  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');250  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);251  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);252  const ethEvents: any = [];253  collectionHelper.events.allEvents((_: any, event: any) => {254    ethEvents.push(event);255  });256  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);257  {258    await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});259    await helper.wait.newBlocks(1);260    expect(ethEvents).to.be.like([261      {262        event: 'CollectionChanged',263        returnValues: {264          collectionId: collectionAddress,265        },266      },267    ]);268    expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);269  }270  unsubscribe();271}272273async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {274  const owner = await helper.eth.createAccountWithBalance(donor);275  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');276  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);277  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);278  const ethEvents: any = [];279  collectionHelper.events.allEvents((_: any, event: any) => {280    ethEvents.push(event);281  });282  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);283  {284    await collection.methods.setCollectionMintMode(true).send({from: owner});285    await helper.wait.newBlocks(1);286    expect(ethEvents).to.be.like([287      {288        event: 'CollectionChanged',289        returnValues: {290          collectionId: collectionAddress,291        },292      },293    ]);294    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);295    ethEvents.pop();296    subEvents.pop();297  }298  {299    await collection.methods.setCollectionAccess(1).send({from: owner});300    await helper.wait.newBlocks(1);301    expect(ethEvents).to.be.like([302      {303        event: 'CollectionChanged',304        returnValues: {305          collectionId: collectionAddress,306        },307      },308    ]);309    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);310  }311  unsubscribe();312}313314async function testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {315  const owner = await helper.eth.createAccountWithBalance(donor);316  const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);317  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');318  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);319  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);320  const ethEvents: any = [];321  collectionHelper.events.allEvents((_: any, event: any) => {322    ethEvents.push(event);323  });324  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{325    section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved',326    ]}]);327  {328    await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});329    await helper.wait.newBlocks(1);330    expect(ethEvents).to.be.like([331      {332        event: 'CollectionChanged',333        returnValues: {334          collectionId: collectionAddress,335        },336      },337    ]);338    expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);339    ethEvents.pop();340    subEvents.pop();341  }342  {343    await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});344    await helper.wait.newBlocks(1);345    expect(ethEvents).to.be.like([346      {347        event: 'CollectionChanged',348        returnValues: {349          collectionId: collectionAddress,350        },351      },352    ]);353    expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);354    ethEvents.pop();355    subEvents.pop();356  }357  {358    await collection.methods.removeCollectionSponsor().send({from: owner});359    expect(ethEvents).to.be.like([360      {361        event: 'CollectionChanged',362        returnValues: {363          collectionId: collectionAddress,364        },365      },366    ]);367    expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);368  }369  unsubscribe();370}371372async function testTokenPropertySetAndTokenPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {373  const owner = await helper.eth.createAccountWithBalance(donor);374  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');375  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);376  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);377  const result = await collection.methods.mint(owner).send({from: owner});378  const tokenId = result.events.Transfer.returnValues.tokenId;379  await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});380381382  const ethEvents: any = [];383  collectionHelper.events.allEvents((_: any, event: any) => {384    ethEvents.push(event);385  });386  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);387  {388    await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});389    await helper.wait.newBlocks(1);390    expect(ethEvents).to.be.like([391      {392        event: 'TokenChanged',393        returnValues: {394          collectionId: collectionAddress,395        },396      },397    ]);398    expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);399    ethEvents.pop();400    subEvents.pop();401  }402  {403    await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});404    expect(ethEvents).to.be.like([405      {406        event: 'TokenChanged',407        returnValues: {408          collectionId: collectionAddress,409        },410      },411    ]);412    expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);413  }414  unsubscribe();415}416417describe.only('[FT] Sync sub & eth events', () => {418  const mode: TCollectionMode = 'ft';419420  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {421    await testCollectionCreatedAndDestroy(helper, mode);422  });423424  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {425    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);426  });427    428  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {429    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);430  });431    432  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {433    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);434  });435    436  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {437    await testCollectionLimitSet(helper, mode);438  });439    440  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {441    await testCollectionOwnedChanged(helper, mode);442  });443    444  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {445    await testCollectionPermissionSet(helper, mode);446  });447448  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {449    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);450  });451});452453describe.only('[NFT] Sync sub & eth events', () => {454  const mode: TCollectionMode = 'nft';455456  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {457    await testCollectionCreatedAndDestroy(helper, mode);458  });459460  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {461    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);462  });463    464  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {465    await testPropertyPermissionSet(helper, mode);466  });467    468  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {469    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);470  });471    472  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {473    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);474  });475    476  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {477    await testCollectionLimitSet(helper, mode);478  });479    480  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {481    await testCollectionOwnedChanged(helper, mode);482  });483    484  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {485    await testCollectionPermissionSet(helper, mode);486  });487488  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {489    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);490  });491     492  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {493    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);494  });495});496497describe.only('[RFT] Sync sub & eth events', () => {498  const mode: TCollectionMode = 'rft';499500  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {501    await testCollectionCreatedAndDestroy(helper, mode);502  });503504  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {505    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);506  });507    508  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {509    await testPropertyPermissionSet(helper, mode);510  });511    512  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {513    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);514  });515    516  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {517    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);518  });519    520  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {521    await testCollectionLimitSet(helper, mode);522  });523    524  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {525    await testCollectionOwnedChanged(helper, mode);526  });527    528  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {529    await testCollectionPermissionSet(helper, mode);530  });531532  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {533    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);534  });535     536  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {537    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);538  });539});
modifiedtests/src/util/index.tsdiffbeforeafterboth
--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -3,7 +3,7 @@
 
 import * as path from 'path';
 import * as crypto from 'crypto';
-import {IKeyringPair} from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types/interfaces';
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
 import {Context} from 'mocha';