difftreelog
fmt
in: master
5 files changed
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth1// 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 {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds} from '../util/index';19import {itEth, expect} from './util';2021describe('evm collection sponsoring', () => {22 let donor: IKeyringPair;23 let alice: IKeyringPair;24 let nominal: bigint;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 [alice] = await helper.arrange.createAccounts([100n], donor);30 nominal = helper.balance.getOneTokenNominal();31 });32 });33 34 // TODO: move to substrate tests35 itEth('sponsors mint transactions', async ({helper}) => {36 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}});37 await collection.setSponsor(alice, alice.address);38 await collection.confirmSponsorship(alice);3940 const minter = helper.eth.createAccount();41 expect(await helper.balance.getEthereum(minter)).to.equal(0n);4243 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);44 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', minter);4546 await collection.addToAllowList(alice, {Ethereum: minter});4748 const result = await contract.methods.mint(minter).send();4950 const events = helper.eth.normalizeEvents(result.events);51 expect(events).to.be.deep.equal([52 {53 address: collectionAddress,54 event: 'Transfer',55 args: {56 from: '0x0000000000000000000000000000000000000000',57 to: minter,58 tokenId: '1',59 },60 },61 ]);62 });6364 // TODO: Temprorary off. Need refactor65 // itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {66 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);67 // const collectionHelpers = evmCollectionHelpers(web3, owner);68 // let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send();69 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);70 // const sponsor = privateKeyWrapper('//Alice');71 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);7273 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;74 // result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});75 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;7677 // const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);78 // await submitTransactionAsync(sponsor, confirmTx);79 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;8081 // const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});82 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);83 // });8485 [86 'setCollectionSponsorCross',87 'setCollectionSponsor', // Soft-deprecated88 ].map(testCase => 89 itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {90 const owner = await helper.eth.createAccountWithBalance(donor);91 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);92 93 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});94 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);95 const sponsor = await helper.eth.createAccountWithBalance(donor);96 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);97 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');98 99 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;100 result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});101 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;102 103 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});104 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;105 106 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});107 108 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});109 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');110 }));111112 [113 'setCollectionSponsorCross',114 'setCollectionSponsor', // Soft-deprecated115 ].map(testCase => 116 itEth(`[${testCase}] Can sponsor from evm address via access list`, async ({helper}) => {117 const owner = await helper.eth.createAccountWithBalance(donor);118 const sponsorEth = await helper.eth.createAccountWithBalance(donor);119 const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);120 121 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');122 123 const collectionSub = helper.nft.getCollectionObject(collectionId);124 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');125 126 // Set collection sponsor:127 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});128 let sponsorship = (await collectionSub.getData())!.raw.sponsorship;129 expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));130 // Account cannot confirm sponsorship if it is not set as a sponsor131 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmUnsetSponsorFail');132 133 // Sponsor can confirm sponsorship:134 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});135 sponsorship = (await collectionSub.getData())!.raw.sponsorship;136 expect(sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));137 138 // Create user with no balance:139 const user = helper.eth.createAccount();140 const userCross = helper.ethCrossAccount.fromAddress(user);141 const nextTokenId = await collectionEvm.methods.nextTokenId().call();142 expect(nextTokenId).to.be.equal('1');143 144 // Set collection permissions:145 const oldPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();146 expect(oldPermissions.mintMode).to.be.false;147 expect(oldPermissions.access).to.be.equal('Normal');148149 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});150 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});151 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});152 153 const newPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();154 expect(newPermissions.mintMode).to.be.true;155 expect(newPermissions.access).to.be.equal('AllowList');156 157 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));158 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));159160 // User can mint token without balance:161 {162 const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});163 const event = helper.eth.normalizeEvents(result.events)164 .find(event => event.event === 'Transfer');;165 166 expect(event).to.be.deep.equal(167 {168 address: collectionAddress,169 event: 'Transfer',170 args: {171 from: '0x0000000000000000000000000000000000000000',172 to: user,173 tokenId: '1',174 },175 },176 );177 178 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));179 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));180 const userBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(user));181 182 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');183 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);184 expect(userBalanceAfter).to.be.eq(0n);185 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;186 }187 }));188189 // TODO: Temprorary off. Need refactor190 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {191 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);192 // const collectionHelpers = evmCollectionHelpers(web3, owner);193 // const result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send();194 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);195 // const sponsor = privateKeyWrapper('//Alice');196 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);197198 // await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});199200 // const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);201 // await submitTransactionAsync(sponsor, confirmTx);202203 // const user = createEthAccount(web3);204 // const nextTokenId = await collectionEvm.methods.nextTokenId().call();205 // expect(nextTokenId).to.be.equal('1');206207 // await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});208 // await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});209 // await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});210211 // const ownerBalanceBefore = await ethBalanceViaSub(api, owner);212 // const sponsorBalanceBefore = (await getBalance(api, [sponsor.address]))[0];213214 // {215 // const nextTokenId = await collectionEvm.methods.nextTokenId().call();216 // expect(nextTokenId).to.be.equal('1');217 // const result = await collectionEvm.methods.mintWithTokenURI(218 // user,219 // nextTokenId,220 // 'Test URI',221 // ).send({from: user});222 // const events = normalizeEvents(result.events);223224 // expect(events).to.be.deep.equal([225 // {226 // address: collectionIdAddress,227 // event: 'Transfer',228 // args: {229 // from: '0x0000000000000000000000000000000000000000',230 // to: user,231 // tokenId: nextTokenId,232 // },233 // },234 // ]);235236 // const ownerBalanceAfter = await ethBalanceViaSub(api, owner);237 // const sponsorBalanceAfter = (await getBalance(api, [sponsor.address]))[0];238239 // expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');240 // expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);241 // expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;242 // }243 // });244245 [246 'setCollectionSponsorCross',247 'setCollectionSponsor', // Soft-deprecated248 ].map(testCase => 249 itEth(`[${testCase}] Check that transaction via EVM spend money from sponsor address`, async ({helper}) => {250 const owner = await helper.eth.createAccountWithBalance(donor);251 const sponsor = await helper.eth.createAccountWithBalance(donor);252 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);253 254 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');255256 const collectionSub = helper.nft.getCollectionObject(collectionId);257 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');258 // Set collection sponsor:259 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();260 let collectionData = (await collectionSub.getData())!;261 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));262 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmUnsetSponsorFail');263 264 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});265 collectionData = (await collectionSub.getData())!;266 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));267 268 const user = helper.eth.createAccount();269 const userCross = helper.ethCrossAccount.fromAddress(user);270 await collectionEvm.methods.addCollectionAdminCross(userCross).send();271 272 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));273 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));274 275 const mintingResult = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});276 const tokenId = mintingResult.events.Transfer.returnValues.tokenId;277 278 const event = helper.eth.normalizeEvents(mintingResult.events)279 .find(event => event.event === 'Transfer');280 const address = helper.ethAddress.fromCollectionId(collectionId);281 282 expect(event).to.be.deep.equal(283 {284 address,285 event: 'Transfer',286 args: {287 from: '0x0000000000000000000000000000000000000000',288 to: user,289 tokenId: '1',290 },291 },292 );293 expect(await collectionEvm.methods.tokenURI(tokenId).call({from: user})).to.be.equal('Test URI');294 295 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));296 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);297 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));298 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;299 }));300301 itEth('Can reassign collection sponsor', async ({helper}) => {302 const owner = await helper.eth.createAccountWithBalance(donor);303 const sponsorEth = await helper.eth.createAccountWithBalance(donor);304 const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);305 const [sponsorSub] = await helper.arrange.createAccounts([100n], donor);306 const sponsorCrossSub = helper.ethCrossAccount.fromKeyringPair(sponsorSub);307308 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');309 const collectionSub = helper.nft.getCollectionObject(collectionId);310 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);311312 // Set and confirm sponsor:313 await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossEth).send({from: owner});314 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});315316 // Can reassign sponsor:317 await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossSub).send({from: owner});318 const collectionSponsor = (await collectionSub.getData())?.raw.sponsorship;319 expect(collectionSponsor).to.deep.eq({Unconfirmed: sponsorSub.address});320 });321});tests/src/eth/events.test.tsdiffbeforeafterboth--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -14,510 +14,510 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import { expect } from 'chai';
+import {expect} from 'chai';
import {IKeyringPair} from '@polkadot/types/types';
-import { EthUniqueHelper, itEth, usingEthPlaygrounds } from './util';
-import { TCollectionMode } from '../util/playgrounds/types';
+import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';
+import {TCollectionMode} from '../util/playgrounds/types';
let donor: IKeyringPair;
before(async function () {
- await usingEthPlaygrounds(async (_helper, privateKey) => {
+ await usingEthPlaygrounds(async (_helper, privateKey) => {
donor = await privateKey({filename: __filename});
- });
+ });
});
async function testCollectionCreatedAndDestroy(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);
- const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- {
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionCreated',
- args: {
- owner: owner,
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- let result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
- expect(result.events).to.be.like({
- CollectionDestroyed: {
- returnValues: {
- collectionId: collectionAddress
- }
- }
- });
- expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);
+ const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ {
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionCreated',
+ args: {
+ owner: owner,
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
+ expect(result.events).to.be.like({
+ CollectionDestroyed: {
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ });
+ expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);
+ }
+ unsubscribe();
}
async function testCollectionPropertySetAndCollectionPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- let {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);
- {
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);
- subEvents.pop();
- }
- {
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);
- }
- unsubscribe();
-}
-
-async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const eethEvents: any = [];
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);
+ {
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);
+ subEvents.pop();
+ }
+ {
+ const ethEvents: any = [];
collectionHelper.events.allEvents((_: any, event: any) => {
- eethEvents.push(event);
+ ethEvents.push(event);
});
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
- await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
- expect(eethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
+ await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
]);
- expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);
- unsubscribe();
+ expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);
+ }
+ unsubscribe();
}
+async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const eethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ eethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
+ await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
+ expect(eethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);
+ unsubscribe();
+}
+
async function testAllowListAddressAddedAndAllowListAddressRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const user = helper.ethCrossAccount.createAccount();
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any[] = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const user = helper.ethCrossAccount.createAccount();
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any[] = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);
- {
- await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
- expect(ethEvents.length).to.be.eq(1);
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);
- }
- unsubscribe();
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);
+ {
+ await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
+ expect(ethEvents.length).to.be.eq(1);
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);
+ }
+ unsubscribe();
}
async function testCollectionAdminAddedAndCollectionAdminRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const user = helper.ethCrossAccount.createAccount();
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);
- {
- await collection.methods.addCollectionAdminCross(user).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.removeCollectionAdminCross(user).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const user = helper.ethCrossAccount.createAccount();
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);
+ {
+ await collection.methods.addCollectionAdminCross(user).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.removeCollectionAdminCross(user).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);
+ }
+ unsubscribe();
}
async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
- {
- await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
+ {
+ await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);
+ }
+ unsubscribe();
}
async function testCollectionOwnedChanged(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const new_owner = helper.ethCrossAccount.createAccount();
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);
- {
- await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const new_owner = helper.ethCrossAccount.createAccount();
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);
+ {
+ await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);
+ }
+ unsubscribe();
}
async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);
- {
- await collection.methods.setCollectionMintMode(true).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.setCollectionAccess(1).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);
+ {
+ await collection.methods.setCollectionMintMode(true).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.setCollectionAccess(1).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+ }
+ unsubscribe();
}
async function testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{
- section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved'
- ]}]);
- {
- await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.removeCollectionSponsor().send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'CollectionChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);
- }
- unsubscribe();
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{
+ section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved',
+ ]}]);
+ {
+ await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.removeCollectionSponsor().send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'CollectionChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);
+ }
+ unsubscribe();
}
async function testTokenPropertySetAndTokenPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
- const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
- const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- const result = await collection.methods.mint(owner).send({from: owner});
- const tokenId = result.events.Transfer.returnValues.tokenId;
- await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+ const result = await collection.methods.mint(owner).send({from: owner});
+ const tokenId = result.events.Transfer.returnValues.tokenId;
+ await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
- const ethEvents: any = [];
- collectionHelper.events.allEvents((_: any, event: any) => {
- ethEvents.push(event);
- });
- const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
- {
- await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'TokenChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);
- ethEvents.pop();
- subEvents.pop();
- }
- {
- await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
- expect(ethEvents).to.be.like([
- {
- event: 'TokenChanged',
- returnValues: {
- collectionId: collectionAddress
- }
- }
- ]);
- expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);
- }
- unsubscribe();
+ const ethEvents: any = [];
+ collectionHelper.events.allEvents((_: any, event: any) => {
+ ethEvents.push(event);
+ });
+ const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
+ {
+ await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'TokenChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);
+ ethEvents.pop();
+ subEvents.pop();
+ }
+ {
+ await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
+ expect(ethEvents).to.be.like([
+ {
+ event: 'TokenChanged',
+ returnValues: {
+ collectionId: collectionAddress,
+ },
+ },
+ ]);
+ expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);
+ }
+ unsubscribe();
}
describe('[FT] Sync sub & eth events', () => {
- const mode: TCollectionMode = 'ft';
+ const mode: TCollectionMode = 'ft';
- itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
- await testCollectionCreatedAndDestroy(helper, mode);
- });
+ itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+ await testCollectionCreatedAndDestroy(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
- await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+ await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+ });
- itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
- await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+ await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
- await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+ await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
- await testCollectionLimitSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+ await testCollectionLimitSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
- await testCollectionOwnedChanged(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+ await testCollectionOwnedChanged(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
- await testCollectionPermissionSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+ await testCollectionPermissionSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
- await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+ await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+ });
});
describe('[NFT] Sync sub & eth events', () => {
- const mode: TCollectionMode = 'nft';
+ const mode: TCollectionMode = 'nft';
- itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
- await testCollectionCreatedAndDestroy(helper, mode);
- });
+ itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+ await testCollectionCreatedAndDestroy(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
- await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+ await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+ });
- itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
- await testPropertyPermissionSet(helper, mode);
- });
+ itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
+ await testPropertyPermissionSet(helper, mode);
+ });
- itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
- await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+ await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
- await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+ await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
- await testCollectionLimitSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+ await testCollectionLimitSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
- await testCollectionOwnedChanged(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+ await testCollectionOwnedChanged(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
- await testCollectionPermissionSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+ await testCollectionPermissionSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
- await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+ await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
- await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
- });
+ itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
+ await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
+ });
});
describe('[RFT] Sync sub & eth events', () => {
- const mode: TCollectionMode = 'rft';
+ const mode: TCollectionMode = 'rft';
- itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
- await testCollectionCreatedAndDestroy(helper, mode);
- });
+ itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+ await testCollectionCreatedAndDestroy(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
- await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+ await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+ });
- itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
- await testPropertyPermissionSet(helper, mode);
- });
+ itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
+ await testPropertyPermissionSet(helper, mode);
+ });
- itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
- await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+ await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
- await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+ await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
- await testCollectionLimitSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+ await testCollectionLimitSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
- await testCollectionOwnedChanged(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+ await testCollectionOwnedChanged(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
- await testCollectionPermissionSet(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+ await testCollectionPermissionSet(helper, mode);
+ });
- itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
- await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
- });
+ itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+ await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+ });
- itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
- await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
- });
+ itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
+ await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
+ });
});
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -121,17 +121,15 @@
.find(event => event.event === 'Transfer')!;
event.address = event.address.toLocaleLowerCase();
- expect(event).to.be.deep.equal(
- {
- address: collectionAddress.toLocaleLowerCase(),
- event: 'Transfer',
- args: {
- from: '0x0000000000000000000000000000000000000000',
- to: receiver,
- tokenId,
- },
+ expect(event).to.be.deep.equal({
+ address: collectionAddress.toLocaleLowerCase(),
+ event: 'Transfer',
+ args: {
+ from: '0x0000000000000000000000000000000000000000',
+ to: receiver,
+ tokenId,
},
- );
+ });
expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
}
@@ -159,17 +157,15 @@
.find(event => event.event === 'Transfer')!;
event.address = event.address.toLocaleLowerCase();
- expect(event).to.be.deep.equal(
- {
- address: collectionAddress.toLocaleLowerCase(),
- event: 'Transfer',
- args: {
- from: '0x0000000000000000000000000000000000000000',
- to: receiver,
- tokenId,
- },
+ expect(event).to.be.deep.equal({
+ address: collectionAddress.toLocaleLowerCase(),
+ event: 'Transfer',
+ args: {
+ from: '0x0000000000000000000000000000000000000000',
+ to: receiver,
+ tokenId,
},
- );
+ });
expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
}
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -188,16 +188,16 @@
createCollectionMethodName(mode: TCollectionMode) {
switch (mode) {
- case 'ft':
- return 'createFTCollection';
- case 'nft':
- return 'createNFTCollection';
- case 'rft':
- return 'createRFTCollection';
+ case 'ft':
+ return 'createFTCollection';
+ case 'nft':
+ return 'createNFTCollection';
+ case 'rft':
+ return 'createRFTCollection';
}
}
- async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals: number = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
+ async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
const functionName: string = this.createCollectionMethodName(mode);
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -44,7 +44,7 @@
} from './types';
import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';
import type {Vec} from '@polkadot/types-codec';
-import { FrameSystemEventRecord } from '@polkadot/types/lookup';
+import {FrameSystemEventRecord} from '@polkadot/types/lookup';
export class CrossAccountId implements ICrossAccountId {
Substrate?: TSubstrateAccount;
@@ -409,17 +409,17 @@
async subscribeEvents(expectedEvents: {section: string, names: string[]}[]) {
const collectedEvents: IEvent[] = [];
const unsubscribe = await this.getApi().query.system.events((events: Vec<FrameSystemEventRecord>) => {
- const ievents = this.eventHelper.extractEvents(events);
- ievents.forEach((event) => {
- expectedEvents.forEach((e => {
- if (event.section === e.section && e.names.includes(event.method)) {
- collectedEvents.push(event);
- }
- }))
- });
+ const ievents = this.eventHelper.extractEvents(events);
+ ievents.forEach((event) => {
+ expectedEvents.forEach((e => {
+ if (event.section === e.section && e.names.includes(event.method)) {
+ collectedEvents.push(event);
+ }
+ }));
+ });
});
return {unsubscribe: unsubscribe as any, collectedEvents};
-}
+ }
clearChainLog(): void {
this.chainLog = [];