1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import { expect } from 'chai';19import { itEth, usingEthPlaygrounds } from './util';2021describe.only('NFT events', () => {22 let donor: IKeyringPair;23 24 before(async function () {25 await usingEthPlaygrounds(async (_helper, privateKey) => {26 donor = await privateKey({filename: __filename});27 });28 });2930 itEth('Create event', async ({helper}) => {31 const owner = await helper.eth.createAccountWithBalance(donor);32 const {collectionAddress, events} = await helper.eth.createCollecion('createNFTCollection', owner, 'A', 'B', 'C');33 expect(events).to.be.like([34 {35 event: 'CollectionCreated',36 args: {37 owner: owner,38 collectionId: collectionAddress39 }40 }41 ]);42 });4344 itEth('Destroy event', async ({helper}) => {45 const owner = await helper.eth.createAccountWithBalance(donor);46 const {collectionAddress} = await helper.eth.createCollecion('createNFTCollection', owner, 'A', 'B', 'C');47 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);48 let resutl = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});49 expect(resutl.events).to.be.like({50 CollectionDestroyed: {51 returnValues: {52 collectionId: collectionAddress53 }54 }55 });56 });57 58 itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {59 const owner = await helper.eth.createAccountWithBalance(donor);60 const {collectionAddress} = await helper.eth.createCollecion('createNFTCollection', owner, 'A', 'B', 'C');61 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);62 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);63 64 {65 const events: any = [];66 collectionHelper.events.allEvents((_: any, event: any) => {67 events.push(event);68 });69 await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});70 expect(events).to.be.like([71 {72 event: 'CollectionChanged',73 returnValues: {74 collectionId: collectionAddress75 }76 }77 ]);78 }79 {80 const events: any = [];81 collectionHelper.events.allEvents((_: any, event: any) => {82 events.push(event);83 });84 await collection.methods.deleteCollectionProperties(['A']).send({from:owner});85 expect(events).to.be.like([86 {87 event: 'CollectionChanged',88 returnValues: {89 collectionId: collectionAddress90 }91 }92 ]);93 }9495 });96 97 itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {98 const owner = await helper.eth.createAccountWithBalance(donor);99 const {collectionAddress} = await helper.eth.createCollecion('createNFTCollection', owner, 'A', 'B', 'C');100 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);101 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);102 const events: any = [];103 collectionHelper.events.allEvents((_: any, event: any) => {104 events.push(event);105 });106 await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});107 expect(events).to.be.like([108 {109 event: 'CollectionChanged',110 returnValues: {111 collectionId: collectionAddress112 }113 }114 ]);115 });116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139});