git.delta.rocks / unique-network / refs/commits / 25ce44862797

difftreelog

test fixed and improved tests for ERC721Metadata compatible collections. WIP, 1 test still fails

Alex Saft2022-10-15parent: #49ed2a2.patch.diff
in: master

13 files changed

modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -23,7 +23,7 @@
 describe('Contract calls', () => {
   let donor: IKeyringPair;
 
-  before(async function() {
+  before(async function () {
     await usingEthPlaygrounds(async (_helper, privateKey) => {
       donor = privateKey('//Alice');
     });
@@ -40,7 +40,12 @@
   itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {
     const userA = await helper.eth.createAccountWithBalance(donor);
     const userB = helper.eth.createAccount();
-    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({from: userA, to: userB, value: '1000000', gas: helper.eth.DEFAULT_GAS}));
+    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({
+      from: userA,
+      to: userB,
+      value: '1000000',
+      gas: helper.eth.DEFAULT_GAS
+    }));
     const balanceB = await helper.balance.getEthereum(userB);
     expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;
   });
@@ -69,67 +74,59 @@
 describe('ERC165 tests', async () => {
   // https://eips.ethereum.org/EIPS/eip-165
 
-  let collection: number;
+  let erc721MetadataCompatibleNftCollectionId: number;
+  let simpleNftCollectionId: number;
   let minter: string;
 
-  function contract(helper: EthUniqueHelper): Contract {
-    return helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection), 'nft', minter);
+  const BASE_URI = 'base/';
+
+  async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {
+    const simple = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);
+    const compatible = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);
+
+    expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);
+    expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);
   }
 
   before(async () => {
     await usingEthPlaygrounds(async (helper, privateKey) => {
       const donor = privateKey('//Alice');
-      const [alice] = await helper.arrange.createAccounts([10n], donor);
-      ({collectionId: collection} = await helper.nft.mintCollection(
-        alice,
-        {
-          name: 'test',
-          description: 'test',
-          tokenPrefix: 'test',
-          properties: [{key: 'ERC721Metadata', value: '1'}],
-          tokenPropertyPermissions: [{
-            key: 'URI',
-            permission: {
-              mutable: true,
-              collectionAdmin: true,
-              tokenOwner: false,
-            },
-          }],
-        },
-      ));
-      minter = helper.eth.createAccount();
+      minter = await helper.eth.createAccountWithBalance(donor);
+
+      simpleNftCollectionId = (await helper.eth.createNFTCollection(minter, 'n', 'd', 'p')).collectionId;
+      erc721MetadataCompatibleNftCollectionId = (await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI)).collectionId;
     });
   });
 
-  itEth('interfaceID == 0xffffffff always false', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0xffffffff').call()).to.be.false;
+  itEth('nonexistent interfaceID - 0xffffffff - always false', async ({helper}) => {
+    await checkInterface(helper, '0xffffffff', false, false);
   });
 
-  itEth('ERC721 support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;
+  itEth('ERC721 - 0x780e9d63 - support', async ({helper}) => {
+    await checkInterface(helper, '0x780e9d63', true, true);
   });
 
-  itEth('ERC721Metadata support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x5b5e139f').call()).to.be.true;
+  itEth('ERC721Metadata - 0x5b5e139f - support', async ({helper}) => {
+    await checkInterface(helper, '0x5b5e139f', false, true);
   });
 
-  itEth('ERC721Mintable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x68ccfe89').call()).to.be.true;
+  itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {
+    await checkInterface(helper, '0x476ff149', true, true);
   });
 
-  itEth('ERC721Enumerable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;
+  itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {
+    await checkInterface(helper, '0x780e9d63', true, true);
   });
 
-  itEth('ERC721UniqueExtensions support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0xd74d154f').call()).to.be.true;
+  itEth('ERC721UniqueExtensions - 0x4468500d - support', async ({helper}) => {
+    await checkInterface(helper, '0x4468500d', true, true);
   });
 
-  itEth('ERC721Burnable support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x42966c68').call()).to.be.true;
+  itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {
+    await checkInterface(helper, '0x42966c68', true, true);
   });
 
-  itEth('ERC165 support', async ({helper}) => {
-    expect(await contract(helper).methods.supportsInterface('0x01ffc9a7').call()).to.be.true;
+  itEth('ERC165 - 0x01ffc9a7 - support', async ({helper}) => {
+    await checkInterface(helper, '0x01ffc9a7', true, true);
   });
 });
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -1,6 +1,7 @@
-import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';
+import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';
 import {IKeyringPair} from '@polkadot/types/types';
 import {Pallets} from '../util/playgrounds';
+import {IProperty, ITokenPropertyPermission} from "../util/playgrounds/types";
 
 describe('EVM collection properties', () => {
   let donor: IKeyringPair;
@@ -65,52 +66,82 @@
     });
   });
 
-  itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
+  const checkERC721Metadata = async (helper: EthUniqueHelper, mode: 'nft' | 'rft') => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const tokenPropertyPermissions = [{
-      key: 'URI',
-      permission: {
-        mutable: true,
-        collectionAdmin: true,
-        tokenOwner: false,
-      },
-    }];
-    const collection = await helper.nft.mintCollection(donor, {name: 'col', description: 'descr', tokenPrefix: 'COL', tokenPropertyPermissions});
+    const bruh = await helper.eth.createAccountWithBalance(donor);
 
-    await collection.addAdmin(donor, {Ethereum: caller});
-    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
+    const BASE_URI = 'base/'
+    const SUFFIX = 'suffix1'
+    const URI = 'uri1'
 
-    await contract.methods.setCollectionProperty('ERC721Metadata', Buffer.from('1')).send({from: caller});
+    const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);
+    const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection'
 
-    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
+    const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p')
 
-    await contract.methods.setCollectionProperty('ERC721Metadata', Buffer.from('0')).send({from: caller});
+    const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);
+    await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too
 
+    const collection1 = await helper.nft.getCollectionObject(collectionId);
+    const data1 = await collection1.getData()
+    expect(data1?.raw.flags.erc721metadata).to.be.false;
     expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;
-  });
 
-  itEth.ifWithPallets('ERC721Metadata property can be set for RFT collection', [Pallets.ReFungible], async({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const tokenPropertyPermissions = [{
-      key: 'URI',
-      permission: {
-        mutable: true,
-        collectionAdmin: true,
-        tokenOwner: false,
-      },
-    }];
-    const collection = await helper.rft.mintCollection(donor, {name: 'col', description: 'descr', tokenPrefix: 'COL', tokenPropertyPermissions});
+    await collectionHelpers.methods.makeCollectionERC721MetadataCompatible(collectionAddress, BASE_URI)
+      .send({from: bruh});
 
-    await collection.addAdmin(donor, {Ethereum: caller});
+    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
 
-    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
+    const collection2 = await helper.nft.getCollectionObject(collectionId);
+    const data2 = await collection2.getData()
+    expect(data2?.raw.flags.erc721metadata).to.be.true;
 
-    await contract.methods.setCollectionProperty('ERC721Metadata', Buffer.from('1')).send({from: caller});
+    const TPPs = data2?.raw.tokenPropertyPermissions
+    expect(TPPs?.length).to.equal(2);
 
-    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
+    expect(TPPs.find((tpp: ITokenPropertyPermission) => {
+      return tpp.key === "URI" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
+    })).to.be.not.null
 
-    await contract.methods.setCollectionProperty('ERC721Metadata', Buffer.from('0')).send({from: caller});
+    expect(TPPs.find((tpp: ITokenPropertyPermission) => {
+      return tpp.key === "URISuffix" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
+    })).to.be.not.null
+
+    expect(data2?.raw.properties?.find((property: IProperty) => {
+      return property.key === "baseURI" && property.value === BASE_URI
+    })).to.be.not.null
+
+    const token1Result = await contract.methods.mint(bruh).send();
+    const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
+
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);
+
+    await contract.methods.setProperty(tokenId1, "URISuffix", Buffer.from(SUFFIX)).send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
 
-    expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;
+    await contract.methods.setProperty(tokenId1, "URI", Buffer.from(URI)).send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
+
+    await contract.methods.deleteProperty(tokenId1, "URI").send();
+    expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
+
+    const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();
+    const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;
+
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
+
+    await contract.methods.deleteProperty(tokenId2, "URI").send();
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
+
+    await contract.methods.setProperty(tokenId2, "URISuffix", Buffer.from(SUFFIX)).send();
+    expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
+  }
+
+  itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
+    await checkERC721Metadata(helper, 'nft');
+  });
+
+  itEth.ifWithPallets('ERC721Metadata property can be set for RFT collection', [Pallets.ReFungible], async({helper}) => {
+    await checkERC721Metadata(helper, 'rft');
   });
 });
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -33,9 +33,8 @@
 
     await collection.addToAllowList(alice, {Ethereum: minter});
 
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.equal('1');
-    const result = await contract.methods.mint(minter, nextTokenId).send();
+    const result = await contract.methods.mint(minter).send();
+
     const events = helper.eth.normalizeEvents(result.events);
     expect(events).to.be.deep.equal([
       {
@@ -44,7 +43,7 @@
         args: {
           from: '0x0000000000000000000000000000000000000000',
           to: minter,
-          tokenId: nextTokenId,
+          tokenId: '1',
         },
       },
     ]);
@@ -62,11 +61,11 @@
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
   //   result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
-    
+
   //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
   //   await submitTransactionAsync(sponsor, confirmTx);
   //   expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
-    
+
   //   const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
   //   expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);
   // });
@@ -83,28 +82,26 @@
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
-    
+
     await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
-    
+
     await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
-    
+
     const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
     expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
   });
 
   itEth('Sponsoring collection from evm address via access list', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
-    let result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});
-    const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
+    const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
+
     const collection = helper.nft.getCollectionObject(collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
-    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
+    await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
     let collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
@@ -133,23 +130,17 @@
     const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
 
     {
-      const nextTokenId = await collectionEvm.methods.nextTokenId().call();
-      expect(nextTokenId).to.be.equal('1');
-      const result = await collectionEvm.methods.mintWithTokenURI(
-        user,
-        nextTokenId,
-        'Test URI',
-      ).send({from: user});
+      const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
       const events = helper.eth.normalizeEvents(result.events);
 
       expect(events).to.be.deep.equal([
         {
-          address: collectionIdAddress,
+          address: collectionAddress,
           event: 'Transfer',
           args: {
             from: '0x0000000000000000000000000000000000000000',
             to: user,
-            tokenId: nextTokenId,
+            tokenId: '1',
           },
         },
       ]);
@@ -173,10 +164,10 @@
   //   const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
 
   //   await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
-    
+
   //   const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
   //   await submitTransactionAsync(sponsor, confirmTx);
-    
+
   //   const user = createEthAccount(web3);
   //   const nextTokenId = await collectionEvm.methods.nextTokenId().call();
   //   expect(nextTokenId).to.be.equal('1');
@@ -221,39 +212,32 @@
 
   itEth('Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
-    const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
 
-    let result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});
-    const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
+    const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
     const collection = helper.nft.getCollectionObject(collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
-    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
 
-    result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
+    await collectionEvm.methods.setCollectionSponsor(sponsor).send();
     let collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
-    const sponsorCollection = helper.ethNativeContract.collection(collectionIdAddress, 'nft', sponsor);
+    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
 
     const user = helper.eth.createAccount();
     await collectionEvm.methods.addCollectionAdmin(user).send();
-    
+
     const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
     const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
 
-    const userCollectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', user);
-    const nextTokenId = await userCollectionEvm.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    result = await userCollectionEvm.methods.mintWithTokenURI(
-      user,
-      nextTokenId,
-      'Test URI',
-    ).send();
+    const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
+
+    let result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI',).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const events = helper.eth.normalizeEvents(result.events);
     const address = helper.ethAddress.fromCollectionId(collectionId);
@@ -265,12 +249,12 @@
         args: {
           from: '0x0000000000000000000000000000000000000000',
           to: user,
-          tokenId: nextTokenId,
+          tokenId: '1',
         },
       },
     ]);
-    expect(await userCollectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
-  
+    expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
+
     const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
     expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
     const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -124,8 +124,7 @@
 		address rftTokenAddress;
 		UniqueRefungibleToken rftTokenContract;
 		if (nft2rftMapping[_collection][_token] == 0) {
-			rftTokenId = rftCollectionContract.nextTokenId();
-			rftCollectionContract.mint(address(this), rftTokenId);
+            rftTokenId = rftCollectionContract.mint(address(this));
 			rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
 			nft2rftMapping[_collection][_token] = rftTokenId;
 			rft2nftMapping[rftTokenAddress] = Token(_collection, _token);
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -64,8 +64,8 @@
 }> => {
   const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
   const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-  const nftTokenId = await nftContract.methods.nextTokenId().call();
-  await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+  const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+  const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
   await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});
   await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});
@@ -148,8 +148,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -280,8 +280,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const fractionalizer = await deployContract(helper, owner);
 
@@ -295,8 +295,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
     await nftContract.methods.transfer(nftOwner, 1).send({from: owner});
 
 
@@ -312,8 +312,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -327,8 +327,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     const {contract: fractionalizer} = await initContract(helper, owner);
 
@@ -343,9 +343,9 @@
     const fractionalizer = await deployContract(helper, owner);
     const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call({from: owner}))
       .to.be.rejectedWith(/RFT collection is not set$/g);
   });
@@ -356,9 +356,9 @@
     const {contract: fractionalizer} = await initContract(helper, owner);
     const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
     const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())
       .to.be.rejectedWith(/Wrong RFT collection$/g);
   });
@@ -373,9 +373,9 @@
     await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});
     await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});
 
-    const rftTokenId = await refungibleContract.methods.nextTokenId().call();
-    await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});
-    
+    const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
+    const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;
+
     await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())
       .to.be.rejectedWith(/No corresponding NFT token found$/g);
   });
@@ -386,7 +386,7 @@
 
     const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);
     const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);
-    
+
     const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);
     const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);
     await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});
@@ -420,7 +420,7 @@
     await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())
       .to.be.rejectedWith(/TransferNotAllowed$/g);
   });
-  
+
   itEth('fractionalize NFT with RFT transfers disallowed', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor, 20n);
 
@@ -434,8 +434,8 @@
 
     const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');
     const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
-    const nftTokenId = await nftContract.methods.nextTokenId().call();
-    await nftContract.methods.mint(owner, nftTokenId).send({from: owner});
+    const mintResult = await nftContract.methods.mint(owner).send({from: owner});
+    const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;
 
     await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});
     await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -29,74 +29,53 @@
     itEth('NFT: allows an Owner to nest/unnest their token', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const {collectionId, contract} = await createNestingCollection(helper, owner);
-  
-      // Create a token to be nested
-      const targetNFTTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetNFTTokenId,
-      ).send({from: owner});
-  
+
+      // Create a token to be nested to
+      const mintingTargetNFTTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetNFTTokenId = mintingTargetNFTTokenIdResult.events.Transfer.returnValues.tokenId;
       const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetNFTTokenId);
-  
+
       // Create a nested token
-      const firstTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        targetNftTokenAddress,
-        firstTokenId,
-      ).send({from: owner});
-  
+      const mintingFirstTokenIdResult = await contract.methods.mint(targetNftTokenAddress).send({from: owner});
+      const firstTokenId = mintingFirstTokenIdResult.events.Transfer.returnValues.tokenId;
       expect(await contract.methods.ownerOf(firstTokenId).call()).to.be.equal(targetNftTokenAddress);
-  
+
       // Create a token to be nested and nest
-      const secondTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        secondTokenId,
-      ).send({from: owner});
-  
+      const mintingSecondTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const secondTokenId = mintingSecondTokenIdResult.events.Transfer.returnValues.tokenId;
+
       await contract.methods.transfer(targetNftTokenAddress, secondTokenId).send({from: owner});
-  
       expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(targetNftTokenAddress);
-  
+
       // Unnest token back
       await contract.methods.transferFrom(targetNftTokenAddress, owner, secondTokenId).send({from: owner});
       expect(await contract.methods.ownerOf(secondTokenId).call()).to.be.equal(owner);
     });
-  
+
     itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(helper, owner);
       await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
-  
+
       // Create a token to nest into
-      const targetNftTokenId = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        targetNftTokenId,
-      ).send({from: owner});
+      const mintingtargetNftTokenIdResult = await contractA.methods.mint(owner).send({from: owner});
+      const targetNftTokenId = mintingtargetNftTokenIdResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA1 = helper.ethAddress.fromTokenId(collectionIdA, targetNftTokenId);
-  
+
       // Create a token for nesting in the same collection as the target
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
-  
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
+
       // Create a token for nesting in a different collection
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        owner,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+      const mintingTokenIdBResult = await contractB.methods.mint(owner).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
       // Nest
       await contractA.methods.transfer(nftTokenAddressA1, nftTokenIdA).send({from: owner});
       expect(await contractA.methods.ownerOf(nftTokenIdA).call()).to.be.equal(nftTokenAddressA1);
-  
+
       await contractB.methods.transfer(nftTokenAddressA1, nftTokenIdB).send({from: owner});
       expect(await contractB.methods.ownerOf(nftTokenIdB).call()).to.be.equal(nftTokenAddressA1);
     });
@@ -105,112 +84,88 @@
   describe('Negative Test: EVM Nesting', async() => {
     itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId, contract} = await createNestingCollection(helper, owner);
       await contract.methods.setCollectionNesting(false).send({from: owner});
-  
+
       // Create a token to nest into
-      const targetNftTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetNftTokenId,
-      ).send({from: owner});
-  
-      const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetNftTokenId);
-  
+      const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetTokenId = mintingTargetTokenIdResult.events.Transfer.returnValues.tokenId;
+      const targetNftTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetTokenId);
+
       // Create a token to nest
-      const nftTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        nftTokenId,
-      ).send({from: owner});
-  
+      const mintingNftTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const nftTokenId = mintingNftTokenIdResult.events.Transfer.returnValues.tokenId;
+
       // Try to nest
       await expect(contract.methods
         .transfer(targetNftTokenAddress, nftTokenId)
         .call({from: owner})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows a non-Owner to nest someone else\'s token', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const malignant = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId, contract} = await createNestingCollection(helper, owner);
-  
+
       // Mint a token
-      const targetTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        owner,
-        targetTokenId,
-      ).send({from: owner});
+      const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});
+      const targetTokenId = mintingTargetTokenIdResult.events.Transfer.returnValues.tokenId;
       const targetTokenAddress = helper.ethAddress.fromTokenId(collectionId, targetTokenId);
-  
+
       // Mint a token belonging to a different account
-      const tokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(
-        malignant,
-        tokenId,
-      ).send({from: owner});
-  
+      const mintingTokenIdResult = await contract.methods.mint(malignant).send({from: owner});
+      const tokenId = mintingTokenIdResult.events.Transfer.returnValues.tokenId;
+
       // Try to nest one token in another as a non-owner account
       await expect(contract.methods
         .transfer(targetTokenAddress, tokenId)
         .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const malignant = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(helper, owner);
-  
+
       await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
-  
+
       // Create a token in one collection
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA = helper.ethAddress.fromTokenId(collectionIdA, nftTokenIdA);
-  
-      // Create a token in another collection belonging to someone else
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        malignant,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+
+      // Create a token in another collection
+      const mintingTokenIdBResult = await contractB.methods.mint(malignant).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
       // Try to drag someone else's token into the other collection and nest
       await expect(contractB.methods
         .transfer(nftTokenAddressA, nftTokenIdB)
         .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
     });
-  
+
     itEth('NFT: disallows to nest token in an unlisted collection', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
-  
+
       const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(helper, owner);
       const {contract: contractB} = await createNestingCollection(helper, owner);
-  
+
       await contractA.methods.setCollectionNesting(true, [collectionAddressA]).send({from: owner});
-  
+
       // Create a token in one collection
-      const nftTokenIdA = await contractA.methods.nextTokenId().call();
-      await contractA.methods.mint(
-        owner,
-        nftTokenIdA,
-      ).send({from: owner});
+      const mintingTokenIdAResult = await contractA.methods.mint(owner).send({from: owner});
+      const nftTokenIdA = mintingTokenIdAResult.events.Transfer.returnValues.tokenId;
       const nftTokenAddressA = helper.ethAddress.fromTokenId(collectionIdA, nftTokenIdA);
-  
+
       // Create a token in another collection
-      const nftTokenIdB = await contractB.methods.nextTokenId().call();
-      await contractB.methods.mint(
-        owner,
-        nftTokenIdB,
-      ).send({from: owner});
-  
+      const mintingTokenIdBResult = await contractB.methods.mint(owner).send({from: owner});
+      const nftTokenIdB = mintingTokenIdBResult.events.Transfer.returnValues.tokenId;
+
+
       // Try to nest into a token in the other collection, disallowed in the first
       await expect(contractB.methods
         .transfer(nftTokenAddressA, nftTokenIdB)
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
before · tests/src/eth/nonFungible.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 {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';18import {IKeyringPair} from '@polkadot/types/types';19import {Contract} from 'web3-eth-contract';202122describe('NFT: Information getting', () => {23  let donor: IKeyringPair;24  let alice: IKeyringPair;2526  before(async function() {27    await usingEthPlaygrounds(async (helper, privateKey) => {28      donor = privateKey('//Alice');29      [alice] = await helper.arrange.createAccounts([10n], donor);30    });31  });32  33  itEth('totalSupply', async ({helper}) => {34    const collection = await helper.nft.mintCollection(alice, {});35    await collection.mintToken(alice);3637    const caller = await helper.eth.createAccountWithBalance(donor);3839    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);40    const totalSupply = await contract.methods.totalSupply().call();4142    expect(totalSupply).to.equal('1');43  });4445  itEth('balanceOf', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {});47    const caller = await helper.eth.createAccountWithBalance(donor);4849    await collection.mintToken(alice, {Ethereum: caller});50    await collection.mintToken(alice, {Ethereum: caller});51    await collection.mintToken(alice, {Ethereum: caller});5253    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);54    const balance = await contract.methods.balanceOf(caller).call();5556    expect(balance).to.equal('3');57  });5859  itEth('ownerOf', async ({helper}) => {60    const collection = await helper.nft.mintCollection(alice, {});61    const caller = await helper.eth.createAccountWithBalance(donor);6263    const token = await collection.mintToken(alice, {Ethereum: caller});6465    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);6667    const owner = await contract.methods.ownerOf(token.tokenId).call();6869    expect(owner).to.equal(caller);70  });7172  itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {73    const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});74    const caller = helper.eth.createAccount();7576    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);7778    expect(await contract.methods.name().call()).to.equal('test');79    expect(await contract.methods.symbol().call()).to.equal('TEST');80  });81});8283describe('Check ERC721 token URI for NFT', () => {84  let donor: IKeyringPair;8586  before(async function() {87    await usingEthPlaygrounds(async (_helper, privateKey) => {88      donor = privateKey('//Alice');89    });90  });9192  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {93    const owner = await helper.eth.createAccountWithBalance(donor);94    const receiver = helper.eth.createAccount();9596    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);97    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);98    99    const nextTokenId = await contract.methods.nextTokenId().call();100    expect(nextTokenId).to.be.equal('1');101    const result = await contract.methods.mint(102      receiver,103      nextTokenId,104    ).send();105106    if (propertyKey && propertyValue) {107      // Set URL or suffix108      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();109    }110111    const event = result.events.Transfer;112    expect(event.address).to.be.equal(collectionAddress);113    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');114    expect(event.returnValues.to).to.be.equal(receiver);115    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);116117    return {contract, nextTokenId};118  }119120  itEth('Empty tokenURI', async ({helper}) => {121    const {contract, nextTokenId} = await setup(helper, '');122    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');123  });124125  itEth('TokenURI from url', async ({helper}) => {126    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');127    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');128  });129130  itEth('TokenURI from baseURI', async ({helper}) => {131    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');132    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');133  });134135  itEth('TokenURI from baseURI + suffix', async ({helper}) => {136    const suffix = '/some/suffix';137    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);138    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);139  });140});141142describe('NFT: Plain calls', () => {143  let donor: IKeyringPair;144  let alice: IKeyringPair;145146  before(async function() {147    await usingEthPlaygrounds(async (helper, privateKey) => {148      donor = privateKey('//Alice');149      [alice] = await helper.arrange.createAccounts([10n], donor);150    });151  });152153  itEth('Can perform mint()', async ({helper}) => {154    const owner = await helper.eth.createAccountWithBalance(donor);155    const receiver = helper.eth.createAccount();156157    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');158    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);159    const nextTokenId = await contract.methods.nextTokenId().call();160161    expect(nextTokenId).to.be.equal('1');162    const result = await contract.methods.mintWithTokenURI(163      receiver,164      nextTokenId,165      'Test URI',166    ).send();167168    const event = result.events.Transfer;169    expect(event.address).to.be.equal(collectionAddress);170    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');171    expect(event.returnValues.to).to.be.equal(receiver);172    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);173174    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');175176    // TODO: this wont work right now, need release 919000 first177    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();178    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();179    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);180  });181182  //TODO: CORE-302 add eth methods183  itEth.skip('Can perform mintBulk()', async ({helper}) => {184    const caller = await helper.eth.createAccountWithBalance(donor);185    const receiver = helper.eth.createAccount();186187    const collection = await helper.nft.mintCollection(alice);188    await collection.addAdmin(alice, {Ethereum: caller});189190    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);191    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);192    {193      const bulkSize = 3;194      const nextTokenId = await contract.methods.nextTokenId().call();195      expect(nextTokenId).to.be.equal('1');196      const result = await contract.methods.mintBulkWithTokenURI(197        receiver,198        Array.from({length: bulkSize}, (_, i) => (199          [+nextTokenId + i, `Test URI ${i}`]200        )),201      ).send({from: caller});202203      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);204      for (let i = 0; i < bulkSize; i++) {205        const event = events[i];206        expect(event.address).to.equal(collectionAddress);207        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');208        expect(event.returnValues.to).to.equal(receiver);209        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);210211        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);212      }213    }214  });215216  itEth('Can perform burn()', async ({helper}) => {217    const caller = await helper.eth.createAccountWithBalance(donor);218219    const collection = await helper.nft.mintCollection(alice, {});220    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});221222    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);223    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);224225    {226      const result = await contract.methods.burn(tokenId).send({from: caller});227      228      const event = result.events.Transfer;229      expect(event.address).to.be.equal(collectionAddress);230      expect(event.returnValues.from).to.be.equal(caller);231      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');232      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);233    }234  });235236  itEth('Can perform approve()', async ({helper}) => {237    const owner = await helper.eth.createAccountWithBalance(donor);238    const spender = helper.eth.createAccount();239240    const collection = await helper.nft.mintCollection(alice, {});241    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});242243    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);244    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);245246    {247      const result = await contract.methods.approve(spender, tokenId).send({from: owner});248249      const event = result.events.Approval;250      expect(event.address).to.be.equal(collectionAddress);251      expect(event.returnValues.owner).to.be.equal(owner);252      expect(event.returnValues.approved).to.be.equal(spender);253      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);254    }255  });256257  itEth('Can perform transferFrom()', async ({helper}) => {258    const owner = await helper.eth.createAccountWithBalance(donor);259    const spender = await helper.eth.createAccountWithBalance(donor);260    const receiver = helper.eth.createAccount();261262    const collection = await helper.nft.mintCollection(alice, {});263    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});264265    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);266    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);267268    await contract.methods.approve(spender, tokenId).send({from: owner});269270    {271      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});272273      const event = result.events.Transfer;274      expect(event.address).to.be.equal(collectionAddress);275      expect(event.returnValues.from).to.be.equal(owner);276      expect(event.returnValues.to).to.be.equal(receiver);277      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);278    }279280    {281      const balance = await contract.methods.balanceOf(receiver).call();282      expect(+balance).to.equal(1);283    }284285    {286      const balance = await contract.methods.balanceOf(owner).call();287      expect(+balance).to.equal(0);288    }289  });290291  itEth('Can perform transfer()', async ({helper}) => {292    const collection = await helper.nft.mintCollection(alice, {});293    const owner = await helper.eth.createAccountWithBalance(donor);294    const receiver = helper.eth.createAccount();295296    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});297298    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);299    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);300301    {302      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});303304      const event = result.events.Transfer;305      expect(event.address).to.be.equal(collectionAddress);306      expect(event.returnValues.from).to.be.equal(owner);307      expect(event.returnValues.to).to.be.equal(receiver);308      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);309    }310311    {312      const balance = await contract.methods.balanceOf(owner).call();313      expect(+balance).to.equal(0);314    }315316    {317      const balance = await contract.methods.balanceOf(receiver).call();318      expect(+balance).to.equal(1);319    }320  });321});322323describe('NFT: Fees', () => {324  let donor: IKeyringPair;325  let alice: IKeyringPair;326327  before(async function() {328    await usingEthPlaygrounds(async (helper, privateKey) => {329      donor = privateKey('//Alice');330      [alice] = await helper.arrange.createAccounts([10n], donor);331    });332  });333  334  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {335    const owner = await helper.eth.createAccountWithBalance(donor);336    const spender = helper.eth.createAccount();337338    const collection = await helper.nft.mintCollection(alice, {});339    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});340341    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);342343    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));344    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));345  });346347  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {348    const owner = await helper.eth.createAccountWithBalance(donor);349    const spender = await helper.eth.createAccountWithBalance(donor);350351    const collection = await helper.nft.mintCollection(alice, {});352    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});353354    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);355356    await contract.methods.approve(spender, tokenId).send({from: owner});357358    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));359    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));360  });361362  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {363    const owner = await helper.eth.createAccountWithBalance(donor);364    const receiver = helper.eth.createAccount();365366    const collection = await helper.nft.mintCollection(alice, {});367    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});368369    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);370371    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));372    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));373  });374});375376describe('NFT: Substrate calls', () => {377  let donor: IKeyringPair;378  let alice: IKeyringPair;379380  before(async function() {381    await usingEthPlaygrounds(async (helper, privateKey) => {382      donor = privateKey('//Alice');383      [alice] = await helper.arrange.createAccounts([20n], donor);384    });385  });386387  itEth('Events emitted for mint()', async ({helper}) => {388    const collection = await helper.nft.mintCollection(alice, {});389    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);390    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');391392    const events: any = [];393    contract.events.allEvents((_: any, event: any) => {394      events.push(event);395    });396    const {tokenId} = await collection.mintToken(alice);397398    const event = events[0];399    expect(event.event).to.be.equal('Transfer');400    expect(event.address).to.be.equal(collectionAddress);401    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');402    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));403    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());404  });405406  itEth('Events emitted for burn()', async ({helper}) => {407    const collection = await helper.nft.mintCollection(alice, {});408    const token = await collection.mintToken(alice);409410    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);411    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');412    413    const events: any = [];414    contract.events.allEvents((_: any, event: any) => {415      events.push(event);416    });417418    await token.burn(alice);419420    const event = events[0];421    expect(event.event).to.be.equal('Transfer');422    expect(event.address).to.be.equal(collectionAddress);423    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));424    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');425    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());426  });427428  itEth('Events emitted for approve()', async ({helper}) => {429    const receiver = helper.eth.createAccount();430431    const collection = await helper.nft.mintCollection(alice, {});432    const token = await collection.mintToken(alice);433434    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);435    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');436    437    const events: any = [];438    contract.events.allEvents((_: any, event: any) => {439      events.push(event);440    });441442    await token.approve(alice, {Ethereum: receiver});443444    const event = events[0];445    expect(event.event).to.be.equal('Approval');446    expect(event.address).to.be.equal(collectionAddress);447    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));448    expect(event.returnValues.approved).to.be.equal(receiver);449    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());450  });451452  itEth('Events emitted for transferFrom()', async ({helper}) => {453    const [bob] = await helper.arrange.createAccounts([10n], donor);454    const receiver = helper.eth.createAccount();455456    const collection = await helper.nft.mintCollection(alice, {});457    const token = await collection.mintToken(alice);458    await token.approve(alice, {Substrate: bob.address});459460    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);461    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');462    463    const events: any = [];464    contract.events.allEvents((_: any, event: any) => {465      events.push(event);466    });467468    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});469    470    const event = events[0];471    expect(event.address).to.be.equal(collectionAddress);472    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));473    expect(event.returnValues.to).to.be.equal(receiver);474    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);475  });476477  itEth('Events emitted for transfer()', async ({helper}) => {478    const receiver = helper.eth.createAccount();479480    const collection = await helper.nft.mintCollection(alice, {});481    const token = await collection.mintToken(alice);482483    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);484    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');485    486    const events: any = [];487    contract.events.allEvents((_: any, event: any) => {488      events.push(event);489    });490491    await token.transfer(alice, {Ethereum: receiver});492    493    const event = events[0];494    expect(event.address).to.be.equal(collectionAddress);495    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));496    expect(event.returnValues.to).to.be.equal(receiver);497    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);498  });499});500501describe('Common metadata', () => {502  let donor: IKeyringPair;503  let alice: IKeyringPair;504505  before(async function() {506    await usingEthPlaygrounds(async (helper, privateKey) => {507      donor = privateKey('//Alice');508      [alice] = await helper.arrange.createAccounts([20n], donor);509    });510  });511512  itEth('Returns collection name', async ({helper}) => {513    const caller = await helper.eth.createAccountWithBalance(donor);514    const tokenPropertyPermissions = [{515      key: 'URI',516      permission: {517        mutable: true,518        collectionAdmin: true,519        tokenOwner: false,520      },521    }];522    const collection = await helper.nft.mintCollection(523      alice,524      {525        name: 'oh River',526        tokenPrefix: 'CHANGE',527        properties: [{key: 'ERC721Metadata', value: '1'}],528        tokenPropertyPermissions,529      },530    );531532    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);533    const name = await contract.methods.name().call();534    expect(name).to.equal('oh River');535  });536537  itEth('Returns symbol name', async ({helper}) => {538    const caller = await helper.eth.createAccountWithBalance(donor);539    const tokenPropertyPermissions = [{540      key: 'URI',541      permission: {542        mutable: true,543        collectionAdmin: true,544        tokenOwner: false,545      },546    }];547    const collection = await helper.nft.mintCollection(548      alice,549      {550        name: 'oh River',551        tokenPrefix: 'CHANGE',552        properties: [{key: 'ERC721Metadata', value: '1'}],553        tokenPropertyPermissions,554      },555    );556557    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);558    const symbol = await contract.methods.symbol().call();559    expect(symbol).to.equal('CHANGE');560  });561});
after · tests/src/eth/nonFungible.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 {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';18import {IKeyringPair} from '@polkadot/types/types';19import {Contract} from 'web3-eth-contract';202122describe('NFT: Information getting', () => {23  let donor: IKeyringPair;24  let alice: IKeyringPair;2526  before(async function() {27    await usingEthPlaygrounds(async (helper, privateKey) => {28      donor = privateKey('//Alice');29      [alice] = await helper.arrange.createAccounts([10n], donor);30    });31  });3233  itEth('totalSupply', async ({helper}) => {34    const collection = await helper.nft.mintCollection(alice, {});35    await collection.mintToken(alice);3637    const caller = await helper.eth.createAccountWithBalance(donor);3839    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);40    const totalSupply = await contract.methods.totalSupply().call();4142    expect(totalSupply).to.equal('1');43  });4445  itEth('balanceOf', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {});47    const caller = await helper.eth.createAccountWithBalance(donor);4849    await collection.mintToken(alice, {Ethereum: caller});50    await collection.mintToken(alice, {Ethereum: caller});51    await collection.mintToken(alice, {Ethereum: caller});5253    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);54    const balance = await contract.methods.balanceOf(caller).call();5556    expect(balance).to.equal('3');57  });5859  itEth('ownerOf', async ({helper}) => {60    const collection = await helper.nft.mintCollection(alice, {});61    const caller = await helper.eth.createAccountWithBalance(donor);6263    const token = await collection.mintToken(alice, {Ethereum: caller});6465    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);6667    const owner = await contract.methods.ownerOf(token.tokenId).call();6869    expect(owner).to.equal(caller);70  });7172  itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {73    const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});74    const caller = helper.eth.createAccount();7576    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);7778    expect(await contract.methods.name().call()).to.equal('test');79    expect(await contract.methods.symbol().call()).to.equal('TEST');80  });81});8283describe('Check ERC721 token URI for NFT', () => {84  let donor: IKeyringPair;8586  before(async function() {87    await usingEthPlaygrounds(async (_helper, privateKey) => {88      donor = privateKey('//Alice');89    });90  });9192  async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {93    const owner = await helper.eth.createAccountWithBalance(donor);94    const receiver = helper.eth.createAccount();9596    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);97    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);9899    const result = await contract.methods.mint(receiver).send();100    const tokenId = result.events.Transfer.returnValues.tokenId;101    expect(tokenId).to.be.equal('1');102103    if (propertyKey && propertyValue) {104      // Set URL or suffix105      await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();106    }107108    const event = result.events.Transfer;109    expect(event.address).to.be.equal(collectionAddress);110    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');111    expect(event.returnValues.to).to.be.equal(receiver);112    expect(event.returnValues.tokenId).to.be.equal(tokenId);113114    return {contract, nextTokenId: tokenId};115  }116117  itEth('Empty tokenURI', async ({helper}) => {118    const {contract, nextTokenId} = await setup(helper, '');119    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');120  });121122  itEth('TokenURI from url', async ({helper}) => {123    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');124    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');125  });126127  itEth('TokenURI from baseURI', async ({helper}) => {128    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');129    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_');130  });131132  itEth('TokenURI from baseURI + suffix', async ({helper}) => {133    const suffix = '/some/suffix';134    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);135    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);136  });137});138139describe('NFT: Plain calls', () => {140  let donor: IKeyringPair;141  let alice: IKeyringPair;142143  before(async function() {144    await usingEthPlaygrounds(async (helper, privateKey) => {145      donor = privateKey('//Alice');146      [alice] = await helper.arrange.createAccounts([10n], donor);147    });148  });149150  itEth('Can perform mint()', async ({helper}) => {151    const owner = await helper.eth.createAccountWithBalance(donor);152    const receiver = helper.eth.createAccount();153154    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');155    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);156157    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();158    const tokenId = result.events.Transfer.returnValues.tokenId;159    expect(tokenId).to.be.equal('1');160161    const event = result.events.Transfer;162    expect(event.address).to.be.equal(collectionAddress);163    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');164    expect(event.returnValues.to).to.be.equal(receiver);165166    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');167168    // TODO: this wont work right now, need release 919000 first169    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();170    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();171    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);172  });173174  //TODO: CORE-302 add eth methods175  itEth.skip('Can perform mintBulk()', async ({helper}) => {176    const caller = await helper.eth.createAccountWithBalance(donor);177    const receiver = helper.eth.createAccount();178179    const collection = await helper.nft.mintCollection(alice);180    await collection.addAdmin(alice, {Ethereum: caller});181182    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);183    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);184    {185      const bulkSize = 3;186      const nextTokenId = await contract.methods.nextTokenId().call();187      expect(nextTokenId).to.be.equal('1');188      const result = await contract.methods.mintBulkWithTokenURI(189        receiver,190        Array.from({length: bulkSize}, (_, i) => (191          [+nextTokenId + i, `Test URI ${i}`]192        )),193      ).send({from: caller});194195      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);196      for (let i = 0; i < bulkSize; i++) {197        const event = events[i];198        expect(event.address).to.equal(collectionAddress);199        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');200        expect(event.returnValues.to).to.equal(receiver);201        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);202203        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);204      }205    }206  });207208  itEth('Can perform burn()', async ({helper}) => {209    const caller = await helper.eth.createAccountWithBalance(donor);210211    const collection = await helper.nft.mintCollection(alice, {});212    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});213214    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);215    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);216217    {218      const result = await contract.methods.burn(tokenId).send({from: caller});219220      const event = result.events.Transfer;221      expect(event.address).to.be.equal(collectionAddress);222      expect(event.returnValues.from).to.be.equal(caller);223      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');224      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);225    }226  });227228  itEth('Can perform approve()', async ({helper}) => {229    const owner = await helper.eth.createAccountWithBalance(donor);230    const spender = helper.eth.createAccount();231232    const collection = await helper.nft.mintCollection(alice, {});233    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});234235    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);236    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);237238    {239      const result = await contract.methods.approve(spender, tokenId).send({from: owner});240241      const event = result.events.Approval;242      expect(event.address).to.be.equal(collectionAddress);243      expect(event.returnValues.owner).to.be.equal(owner);244      expect(event.returnValues.approved).to.be.equal(spender);245      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);246    }247  });248249  itEth('Can perform transferFrom()', async ({helper}) => {250    const owner = await helper.eth.createAccountWithBalance(donor);251    const spender = await helper.eth.createAccountWithBalance(donor);252    const receiver = helper.eth.createAccount();253254    const collection = await helper.nft.mintCollection(alice, {});255    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});256257    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);258    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);259260    await contract.methods.approve(spender, tokenId).send({from: owner});261262    {263      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});264265      const event = result.events.Transfer;266      expect(event.address).to.be.equal(collectionAddress);267      expect(event.returnValues.from).to.be.equal(owner);268      expect(event.returnValues.to).to.be.equal(receiver);269      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);270    }271272    {273      const balance = await contract.methods.balanceOf(receiver).call();274      expect(+balance).to.equal(1);275    }276277    {278      const balance = await contract.methods.balanceOf(owner).call();279      expect(+balance).to.equal(0);280    }281  });282283  itEth('Can perform transfer()', async ({helper}) => {284    const collection = await helper.nft.mintCollection(alice, {});285    const owner = await helper.eth.createAccountWithBalance(donor);286    const receiver = helper.eth.createAccount();287288    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});289290    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);291    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);292293    {294      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});295296      const event = result.events.Transfer;297      expect(event.address).to.be.equal(collectionAddress);298      expect(event.returnValues.from).to.be.equal(owner);299      expect(event.returnValues.to).to.be.equal(receiver);300      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);301    }302303    {304      const balance = await contract.methods.balanceOf(owner).call();305      expect(+balance).to.equal(0);306    }307308    {309      const balance = await contract.methods.balanceOf(receiver).call();310      expect(+balance).to.equal(1);311    }312  });313});314315describe('NFT: Fees', () => {316  let donor: IKeyringPair;317  let alice: IKeyringPair;318319  before(async function() {320    await usingEthPlaygrounds(async (helper, privateKey) => {321      donor = privateKey('//Alice');322      [alice] = await helper.arrange.createAccounts([10n], donor);323    });324  });325326  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {327    const owner = await helper.eth.createAccountWithBalance(donor);328    const spender = helper.eth.createAccount();329330    const collection = await helper.nft.mintCollection(alice, {});331    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});332333    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);334335    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));336    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));337  });338339  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {340    const owner = await helper.eth.createAccountWithBalance(donor);341    const spender = await helper.eth.createAccountWithBalance(donor);342343    const collection = await helper.nft.mintCollection(alice, {});344    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});345346    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);347348    await contract.methods.approve(spender, tokenId).send({from: owner});349350    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));351    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));352  });353354  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {355    const owner = await helper.eth.createAccountWithBalance(donor);356    const receiver = helper.eth.createAccount();357358    const collection = await helper.nft.mintCollection(alice, {});359    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});360361    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);362363    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));364    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));365  });366});367368describe('NFT: Substrate calls', () => {369  let donor: IKeyringPair;370  let alice: IKeyringPair;371372  before(async function() {373    await usingEthPlaygrounds(async (helper, privateKey) => {374      donor = privateKey('//Alice');375      [alice] = await helper.arrange.createAccounts([20n], donor);376    });377  });378379  itEth('Events emitted for mint()', async ({helper}) => {380    const collection = await helper.nft.mintCollection(alice, {});381    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);382    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');383384    const events: any = [];385    contract.events.allEvents((_: any, event: any) => {386      events.push(event);387    });388    const {tokenId} = await collection.mintToken(alice);389390    const event = events[0];391    expect(event.event).to.be.equal('Transfer');392    expect(event.address).to.be.equal(collectionAddress);393    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');394    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));395    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());396  });397398  itEth('Events emitted for burn()', async ({helper}) => {399    const collection = await helper.nft.mintCollection(alice, {});400    const token = await collection.mintToken(alice);401402    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);403    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');404405    const events: any = [];406    contract.events.allEvents((_: any, event: any) => {407      events.push(event);408    });409410    await token.burn(alice);411412    const event = events[0];413    expect(event.event).to.be.equal('Transfer');414    expect(event.address).to.be.equal(collectionAddress);415    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));416    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');417    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());418  });419420  itEth('Events emitted for approve()', async ({helper}) => {421    const receiver = helper.eth.createAccount();422423    const collection = await helper.nft.mintCollection(alice, {});424    const token = await collection.mintToken(alice);425426    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);427    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');428429    const events: any = [];430    contract.events.allEvents((_: any, event: any) => {431      events.push(event);432    });433434    await token.approve(alice, {Ethereum: receiver});435436    const event = events[0];437    expect(event.event).to.be.equal('Approval');438    expect(event.address).to.be.equal(collectionAddress);439    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));440    expect(event.returnValues.approved).to.be.equal(receiver);441    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());442  });443444  itEth('Events emitted for transferFrom()', async ({helper}) => {445    const [bob] = await helper.arrange.createAccounts([10n], donor);446    const receiver = helper.eth.createAccount();447448    const collection = await helper.nft.mintCollection(alice, {});449    const token = await collection.mintToken(alice);450    await token.approve(alice, {Substrate: bob.address});451452    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);453    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');454455    const events: any = [];456    contract.events.allEvents((_: any, event: any) => {457      events.push(event);458    });459460    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});461462    const event = events[0];463    expect(event.address).to.be.equal(collectionAddress);464    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));465    expect(event.returnValues.to).to.be.equal(receiver);466    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);467  });468469  itEth('Events emitted for transfer()', async ({helper}) => {470    const receiver = helper.eth.createAccount();471472    const collection = await helper.nft.mintCollection(alice, {});473    const token = await collection.mintToken(alice);474475    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);476    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');477478    const events: any = [];479    contract.events.allEvents((_: any, event: any) => {480      events.push(event);481    });482483    await token.transfer(alice, {Ethereum: receiver});484485    const event = events[0];486    expect(event.address).to.be.equal(collectionAddress);487    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));488    expect(event.returnValues.to).to.be.equal(receiver);489    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);490  });491});492493describe('Common metadata', () => {494  let donor: IKeyringPair;495  let alice: IKeyringPair;496497  before(async function() {498    await usingEthPlaygrounds(async (helper, privateKey) => {499      donor = privateKey('//Alice');500      [alice] = await helper.arrange.createAccounts([20n], donor);501    });502  });503504  itEth('Returns collection name', async ({helper}) => {505    const caller = await helper.eth.createAccountWithBalance(donor);506    const tokenPropertyPermissions = [{507      key: 'URI',508      permission: {509        mutable: true,510        collectionAdmin: true,511        tokenOwner: false,512      },513    }];514    const collection = await helper.nft.mintCollection(515      alice,516      {517        name: 'oh River',518        tokenPrefix: 'CHANGE',519        properties: [{key: 'ERC721Metadata', value: '1'}],520        tokenPropertyPermissions,521      },522    );523524    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);525    const name = await contract.methods.name().call();526    expect(name).to.equal('oh River');527  });528529  itEth('Returns symbol name', async ({helper}) => {530    const caller = await helper.eth.createAccountWithBalance(donor);531    const tokenPropertyPermissions = [{532      key: 'URI',533      permission: {534        mutable: true,535        collectionAdmin: true,536        tokenOwner: false,537      },538    }];539    const collection = await helper.nft.mintCollection(540      alice,541      {542        name: 'oh River',543        tokenPrefix: 'CHANGE',544        properties: [{key: 'ERC721Metadata', value: '1'}],545        tokenPropertyPermissions,546      },547    );548549    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);550    const symbol = await contract.methods.symbol().call();551    expect(symbol).to.equal('CHANGE');552  });553});
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -118,7 +118,7 @@
     const deployer = await helper.eth.createAccountWithBalance(donor);
     const caller = await helper.eth.createAccountWithBalance(donor);
     const contract = await helper.eth.deployFlipper(deployer);
-    
+
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     await contract.methods.flip().send({from: caller});
     const finalCallerBalance = await helper.balance.getEthereum(caller);
@@ -129,7 +129,7 @@
     const deployer = await helper.eth.createAccountWithBalance(donor);
     const caller = await helper.eth.createAccountWithBalance(donor);
     const contract = await deployProxyContract(helper, deployer);
-    
+
     const initialCallerBalance = await helper.balance.getEthereum(caller);
     const initialContractBalance = await helper.balance.getEthereum(contract.options.address);
     await contract.methods.flip().send({from: caller});
@@ -138,7 +138,7 @@
     expect(finalCallerBalance < initialCallerBalance).to.be.true;
     expect(finalContractBalance == initialContractBalance).to.be.true;
   });
-  
+
   itEth('Fee for nested calls to native methods is withdrawn from the user', async({helper}) => {
     const CONTRACT_BALANCE = 2n * helper.balance.getOneTokenNominal();
 
@@ -155,7 +155,7 @@
     expect(finalCallerBalance < initialCallerBalance).to.be.true;
     expect(finalContractBalance == initialContractBalance).to.be.true;
   });
-  
+
   itEth('Fee for nested calls to create*Collection methods is withdrawn from the user and from the contract', async({helper}) => {
     const CONTRACT_BALANCE = 2n * helper.balance.getOneTokenNominal();
     const deployer = await helper.eth.createAccountWithBalance(donor);
@@ -176,7 +176,7 @@
     const BIG_FEE = 3n * helper.balance.getOneTokenNominal();
     const caller = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);
-        
+
     await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
     await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
@@ -186,7 +186,7 @@
     const BIG_FEE = 3n * helper.balance.getOneTokenNominal();
     const caller = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);
-        
+
     await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
     await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
@@ -235,8 +235,7 @@
 
         function mintNftToken(address collectionAddress) external  {
           UniqueNFT collection = UniqueNFT(collectionAddress);
-          uint256 tokenId = collection.nextTokenId();
-          collection.mint(msg.sender, tokenId);
+          uint256 tokenId = collection.mint(msg.sender);
           emit TokenMinted(tokenId);
         }
 
modifiedtests/src/eth/proxy/UniqueNFTProxy.soldiffbeforeafterboth
--- a/tests/src/eth/proxy/UniqueNFTProxy.sol
+++ b/tests/src/eth/proxy/UniqueNFTProxy.sol
@@ -120,20 +120,19 @@
         return proxied.mintingFinished();
     }
 
-    function mint(address to, uint256 tokenId)
+    function mint(address to)
         external
         override
-        returns (bool)
+        returns (uint256)
     {
-        return proxied.mint(to, tokenId);
+        return proxied.mint(to);
     }
 
     function mintWithTokenURI(
         address to,
-        uint256 tokenId,
         string memory tokenUri
-    ) external override returns (bool) {
-        return proxied.mintWithTokenURI(to, tokenId, tokenUri);
+    ) external override returns (uint256) {
+        return proxied.mintWithTokenURI(to, tokenUri);
     }
 
     function finishMinting() external override returns (bool) {
@@ -169,7 +168,7 @@
         return proxied.mintBulk(to, tokenIds);
     }
 
-    function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
+    function mintBulkWithTokenURI(address to, Tuple6[] memory tokens)
         external
         override
         returns (bool)
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -111,13 +111,10 @@
     await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();
 
     {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      expect(nextTokenId).to.be.equal('1');
-      const result = await contract.methods.mintWithTokenURI(
-        receiver,
-        nextTokenId,
-        'Test URI',
-      ).send({from: caller});
+      const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send({from: caller});
+      const tokenId = result.events.Transfer.returnValues.tokenId;
+      expect(tokenId).to.be.equal('1');
+
       const events = helper.eth.normalizeEvents(result.events);
       events[0].address = events[0].address.toLocaleLowerCase();
 
@@ -128,12 +125,12 @@
           args: {
             from: '0x0000000000000000000000000000000000000000',
             to: receiver,
-            tokenId: nextTokenId,
+            tokenId,
           },
         },
       ]);
 
-      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
     }
   });
 
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -33,8 +33,9 @@
     const caller = await helper.eth.createAccountWithBalance(donor);
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, nextTokenId).send();
+
+    await contract.methods.mint(caller).send();
+
     const totalSupply = await contract.methods.totalSupply().call();
     expect(totalSupply).to.equal('1');
   });
@@ -44,18 +45,9 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      await contract.methods.mint(caller, nextTokenId).send();
-    }
+    await contract.methods.mint(caller).send();
+    await contract.methods.mint(caller).send();
+    await contract.methods.mint(caller).send();
 
     const balance = await contract.methods.balanceOf(caller).call();
     expect(balance).to.equal('3');
@@ -66,8 +58,8 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const owner = await contract.methods.ownerOf(tokenId).call();
     expect(owner).to.equal(caller);
@@ -79,8 +71,8 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
     await tokenContract.methods.repartition(2).send();
@@ -98,8 +90,8 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
     await tokenContract.methods.repartition(2).send();
@@ -126,22 +118,17 @@
     const receiver = helper.eth.createAccount();
     const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    const result = await contract.methods.mintWithTokenURI(
-      receiver,
-      nextTokenId,
-      'Test URI',
-    ).send();
 
+    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
+
     const event = result.events.Transfer;
     expect(event.address).to.equal(collectionAddress);
     expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.equal(receiver);
-    expect(event.returnValues.tokenId).to.equal(nextTokenId);
+    const tokenId = event.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
 
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
   });
 
   itEth('Can perform mintBulk()', async ({helper}) => {
@@ -182,8 +169,8 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Burny', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     {
       const result = await contract.methods.burn(tokenId).send();
       const event = result.events.Transfer;
@@ -200,9 +187,10 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'TransferFromy', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
-    await contract.methods.mint(caller, tokenId).send();
 
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);
     await tokenContract.methods.repartition(15).send();
@@ -244,12 +232,12 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     {
       const result = await contract.methods.transfer(receiver, tokenId).send();
-      
+
       const event = result.events.Transfer;
       expect(event.address).to.equal(collectionAddress);
       expect(event.returnValues.from).to.equal(caller);
@@ -274,8 +262,8 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Partial-to-Full', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
@@ -301,8 +289,8 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Full-to-Partial', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
 
@@ -339,8 +327,8 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer-From', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
@@ -353,8 +341,8 @@
     const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
 
     const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transfer(receiver, tokenId).send());
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
@@ -394,7 +382,7 @@
         tokenPropertyPermissions,
       },
     );
-    
+
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
     const name = await contract.methods.name().call();
     expect(name).to.equal('Leviathan');
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -82,26 +82,22 @@
 
     const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const nextTokenId = await contract.methods.nextTokenId().call();
-    expect(nextTokenId).to.be.equal('1');
-    const result = await contract.methods.mint(
-      receiver,
-      nextTokenId,
-    ).send();
 
-    if (propertyKey && propertyValue) {
-      // Set URL or suffix
-      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();
-    }
+    const result = await contract.methods.mint(receiver).send();
 
     const event = result.events.Transfer;
+    const tokenId = event.returnValues.tokenId;
+    expect(tokenId).to.be.equal('1');
     expect(event.address).to.be.equal(collectionAddress);
     expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
     expect(event.returnValues.to).to.be.equal(receiver);
-    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);
 
-    return {contract, nextTokenId};
+    if (propertyKey && propertyValue) {
+      // Set URL or suffix
+      await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();
+    }
+
+    return {contract, nextTokenId: tokenId};
   }
 
   itEth('Empty tokenURI', async ({helper}) => {
@@ -295,8 +291,8 @@
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Devastation', '6', '6');
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
 
-    const tokenId = await contract.methods.nextTokenId().call();
-    await contract.methods.mint(caller, tokenId).send();
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);
 
@@ -479,9 +475,10 @@
 
     const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sands', '', 'GRAIN');
     const collectionContract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    
-    const tokenId = await collectionContract.methods.nextTokenId().call();
-    await collectionContract.methods.mint(owner, tokenId).send();
+
+    const result = await collectionContract.methods.mint(owner).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
     const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);
 
modifiedtests/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
@@ -43,12 +43,12 @@
     if(!imports) return function(path: string) {
       return {error: `File not found: ${path}`};
     };
-  
+
     const knownImports = {} as {[key: string]: string};
     for(const imp of imports) {
       knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();
     }
-  
+
     return function(path: string) {
       if(path in knownImports) return {contents: knownImports[path]};
       return {error: `File not found: ${path}`};
@@ -71,7 +71,7 @@
         },
       },
     }), {import: await this.findImports(imports)})).contracts[`${name}.sol`][name];
-  
+
     return {
       abi: out.abi,
       object: '0x' + out.evm.bytecode.object,
@@ -94,7 +94,7 @@
   }
 
 }
-  
+
 class NativeContractGroup extends EthGroupBase {
 
   contractHelpers(caller: string): Contract {
@@ -145,14 +145,14 @@
   async createAccountWithBalance(donor: IKeyringPair, amount=1000n) {
     const account = this.createAccount();
     await this.transferBalanceFromSubstrate(donor, account, amount);
-  
+
     return account;
   }
 
   async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=1000n, inTokens=true) {
     return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));
   }
-  
+
   async getCollectionCreationFee(signer: string) {
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
     return await collectionHelper.methods.collectionCreationFee().call();
@@ -177,7 +177,7 @@
   async createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-        
+
     const result = await collectionHelper.methods.createNFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
@@ -187,13 +187,11 @@
   }
 
   async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
-    const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-        
-    const result = await collectionHelper.methods.createERC721MetadataCompatibleNFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});
 
-    const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
+    const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix)
+
+    await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
 
     return {collectionId, collectionAddress};
   }
@@ -201,7 +199,7 @@
   async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-        
+
     const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
@@ -211,13 +209,11 @@
   }
 
   async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
-    const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
-    
-    const result = await collectionHelper.methods.createERC721MetadataCompatibleRFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});
 
-    const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
-    const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
+    const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix)
+
+    await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
 
     return {collectionId, collectionAddress};
   }
@@ -312,7 +308,7 @@
     };
     return await this.helper.arrange.calculcateFee(address, wrappedCode);
   }
-}  
+}
 
 class EthAddressGroup extends EthGroupBase {
   extractCollectionId(address: string): number {
@@ -343,8 +339,8 @@
   normalizeAddress(address: string): string {
     return '0x' + address.substring(address.length - 40);
   }
-}  
- 
+}
+
 export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
 
 export class EthUniqueHelper extends DevUniqueHelper {
@@ -396,4 +392,3 @@
     return newHelper;
   }
 }
-  
\ No newline at end of file