git.delta.rocks / unique-network / refs/commits / 624d2812f7d4

difftreelog

chore fix tests

Grigoriy Simonov2022-09-27parent: #57eacee.patch.diff
in: master

12 files changed

modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -30,10 +30,10 @@
   itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelper = evmCollectionHelpers(web3, owner);
-        
+
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const newAdmin = createEthAccount(web3);
@@ -69,7 +69,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
 
     const newAdmin = createEthAccount(web3);
@@ -85,7 +85,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -108,7 +108,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -174,7 +174,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const newAdmin = createEthAccount(web3);
@@ -222,7 +222,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -249,7 +249,7 @@
         
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
 
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -326,7 +326,7 @@
     const collectionHelper = evmCollectionHelpers(web3, owner);
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
   
@@ -342,7 +342,7 @@
     const collectionHelper = evmCollectionHelpers(web3, owner);
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
 
@@ -357,7 +357,7 @@
     const collectionHelper = evmCollectionHelpers(web3, owner);
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'B', 'C')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
   
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -1,10 +1,8 @@
-import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';
+import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess, UNIQUE} from '../util/helpers';
 import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub} from './util/helpers';
 import nonFungibleAbi from './nonFungibleAbi.json';
 import {expect} from 'chai';
 import {evmToAddress} from '@polkadot/util-crypto';
-import {submitTransactionAsync} from '../substrate/substrate-api';
-import getBalance from '../substrate/get-balance';
 
 describe('evm collection sponsoring', () => {
   itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {
@@ -64,7 +62,7 @@
   itWeb3('Remove sponsor', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -85,7 +83,7 @@
   itWeb3('Sponsoring collection from evm address via access list', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -210,7 +208,7 @@
   itWeb3('Check that transaction via EVM spend money from sponsor address', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+    let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -17,6 +17,7 @@
 import {evmToAddress} from '@polkadot/util-crypto';
 import {IKeyringPair} from '@polkadot/types/types';
 import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
+import {UNIQUE} from '../util/helpers';
 
 describe('Create NFT collection from EVM', () => {
   let donor: IKeyringPair;
@@ -64,7 +65,7 @@
 
     await collectionHelpers.methods
       .createNonfungibleCollection('A', 'A', 'A')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     
     expect(await collectionHelpers.methods
       .isCollectionExist(expectedCollectionAddress)
@@ -164,7 +165,7 @@
 
       await expect(collectionHelper.methods
         .createNonfungibleCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
       
     }
     {
@@ -174,7 +175,7 @@
       const tokenPrefix = 'A';
       await expect(collectionHelper.methods
         .createNonfungibleCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
     }
     {
       const MAX_TOKEN_PREFIX_LENGTH = 16;
@@ -183,16 +184,16 @@
       const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
       await expect(collectionHelper.methods
         .createNonfungibleCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
     }
   });
   
   itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {
-    const owner = helper.eth.createAccount();
+    const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
     await expect(collectionHelper.methods
       .createNonfungibleCollection('Peasantry', 'absolutely anything', 'CVE')
-      .call()).to.be.rejectedWith('NotSufficientFounds');
+      .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
 
   itEth('(!negative test!) Check owner', async ({helper}) => {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -18,6 +18,7 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {Pallets, requirePalletsOrSkip} from '../util/playgrounds';
 import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
+import {UNIQUE} from '../util/helpers';
 
 describe('Create RFT collection from EVM', () => {
   let donor: IKeyringPair;
@@ -65,7 +66,7 @@
 
     await collectionHelpers.methods
       .createRFTCollection('A', 'A', 'A')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     
     expect(await collectionHelpers.methods
       .isCollectionExist(expectedCollectionAddress)
@@ -166,7 +167,7 @@
 
       await expect(collectionHelper.methods
         .createRFTCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
     }
     {
       const MAX_DESCRIPTION_LENGTH = 256;
@@ -175,7 +176,7 @@
       const tokenPrefix = 'A';
       await expect(collectionHelper.methods
         .createRFTCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
     }
     {
       const MAX_TOKEN_PREFIX_LENGTH = 16;
@@ -184,16 +185,16 @@
       const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
       await expect(collectionHelper.methods
         .createRFTCollection(collectionName, description, tokenPrefix)
-        .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
+        .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
     }
   });
   
   itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {
-    const owner = helper.eth.createAccount();
+    const owner = await helper.eth.createAccountWithBalance(donor);
     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
     await expect(collectionHelper.methods
       .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')
-      .call()).to.be.rejectedWith('NotSufficientFounds');
+      .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
   });
 
   itEth('(!negative test!) Check owner', async ({helper}) => {
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -81,10 +81,10 @@
 		string calldata _name,
 		string calldata _description,
 		string calldata _tokenPrefix
-	) external onlyOwner {
+	) external payable onlyOwner {
 		require(rftCollection == address(0), "RFT collection is already set");
 		address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
-		rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection(_name, _description, _tokenPrefix);
+		rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection{value: msg.value}(_name, _description, _tokenPrefix);
 		emit RFTCollectionSet(rftCollection);
 	}
 
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -93,7 +93,7 @@
   const fractionalizer = await deployFractionalizer(web3, owner);
   const amount = 10n * UNIQUE;
   await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, ...GAS_ARGS});
-  const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send();
+  const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * UNIQUE)});
   const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;
   return {fractionalizer, rftCollectionAddress};
 }
@@ -141,9 +141,9 @@
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const fractionalizer = await deployFractionalizer(web3, owner);
     const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);
-    await submitTransactionAsync(alice, tx);
+    await executeTransaction(api, alice, tx);
 
-    const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner});
+    const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});
     expect(result.events).to.be.like({
       RFTCollectionSet: {},
     });
@@ -295,7 +295,7 @@
     const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);
     await submitTransactionAsync(alice, tx);
 
-    const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner});
+    const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});
     const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;
 
     await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())
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';2021describe('NFT: Information getting', () => {22  let donor: IKeyringPair;23  let alice: IKeyringPair;2425  before(async function() {26    await usingEthPlaygrounds(async (helper, privateKey) => {27      donor = privateKey('//Alice');28      [alice] = await helper.arrange.createAccounts([10n], donor);29    });30  });31  32  itEth('totalSupply', async ({helper}) => {33    const collection = await helper.nft.mintCollection(alice, {});34    await collection.mintToken(alice);3536    const caller = await helper.eth.createAccountWithBalance(donor);3738    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);39    const totalSupply = await contract.methods.totalSupply().call();4041    expect(totalSupply).to.equal('1');42  });4344  itEth('balanceOf', async ({helper}) => {45    const collection = await helper.nft.mintCollection(alice, {});46    const caller = await helper.eth.createAccountWithBalance(donor);4748    await collection.mintToken(alice, {Ethereum: caller});49    await collection.mintToken(alice, {Ethereum: caller});50    await collection.mintToken(alice, {Ethereum: caller});5152    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);53    const balance = await contract.methods.balanceOf(caller).call();5455    expect(balance).to.equal('3');56  });5758  itEth('ownerOf', async ({helper}) => {59    const collection = await helper.nft.mintCollection(alice, {});60    const caller = await helper.eth.createAccountWithBalance(donor);6162    const token = await collection.mintToken(alice, {Ethereum: caller});6364    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);6566    const owner = await contract.methods.ownerOf(token.tokenId).call();6768    expect(owner).to.equal(caller);69  });70});7172describe('Check ERC721 token URI for NFT', () => {73  let donor: IKeyringPair;7475  before(async function() {76    await usingEthPlaygrounds(async (_helper, privateKey) => {77      donor = privateKey('//Alice');78    });79  });8081  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {82    const owner = await helper.eth.createAccountWithBalance(donor);83    const receiver = helper.eth.createAccount();8485    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);86    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send();87    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);88    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);89    90    const nextTokenId = await contract.methods.nextTokenId().call();91    expect(nextTokenId).to.be.equal('1');92    result = await contract.methods.mint(93      receiver,94      nextTokenId,95    ).send();9697    if (propertyKey && propertyValue) {98      // Set URL or suffix99      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();100    }101102    const event = result.events.Transfer;103    expect(event.address).to.be.equal(collectionAddress);104    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');105    expect(event.returnValues.to).to.be.equal(receiver);106    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);107108    return {contract, nextTokenId};109  }110111  itEth('Empty tokenURI', async ({helper}) => {112    const {contract, nextTokenId} = await setup(helper, '');113    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');114  });115116  itEth('TokenURI from url', async ({helper}) => {117    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');118    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');119  });120121  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {122    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');123    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);124  });125126  itEth('TokenURI from baseURI + suffix', async ({helper}) => {127    const suffix = '/some/suffix';128    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);129    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);130  });131});132133describe('NFT: Plain calls', () => {134  let donor: IKeyringPair;135  let alice: IKeyringPair;136137  before(async function() {138    await usingEthPlaygrounds(async (helper, privateKey) => {139      donor = privateKey('//Alice');140      [alice] = await helper.arrange.createAccounts([10n], donor);141    });142  });143144  itEth('Can perform mint()', async ({helper}) => {145    const owner = await helper.eth.createAccountWithBalance(donor);146    const receiver = helper.eth.createAccount();147148    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Minty', '6', '6');149    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);150    const nextTokenId = await contract.methods.nextTokenId().call();151152    expect(nextTokenId).to.be.equal('1');153    const result = await contract.methods.mintWithTokenURI(154      receiver,155      nextTokenId,156      'Test URI',157    ).send();158159    const event = result.events.Transfer;160    expect(event.address).to.be.equal(collectionAddress);161    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');162    expect(event.returnValues.to).to.be.equal(receiver);163    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);164165    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');166167    // TODO: this wont work right now, need release 919000 first168    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();169    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();170    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);171  });172173  //TODO: CORE-302 add eth methods174  itEth.skip('Can perform mintBulk()', async ({helper}) => {175    const caller = await helper.eth.createAccountWithBalance(donor);176    const receiver = helper.eth.createAccount();177178    const collection = await helper.nft.mintCollection(alice);179    await collection.addAdmin(alice, {Ethereum: caller});180181    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);182    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);183    {184      const bulkSize = 3;185      const nextTokenId = await contract.methods.nextTokenId().call();186      expect(nextTokenId).to.be.equal('1');187      const result = await contract.methods.mintBulkWithTokenURI(188        receiver,189        Array.from({length: bulkSize}, (_, i) => (190          [+nextTokenId + i, `Test URI ${i}`]191        )),192      ).send({from: caller});193194      const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);195      for (let i = 0; i < bulkSize; i++) {196        const event = events[i];197        expect(event.address).to.equal(collectionAddress);198        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');199        expect(event.returnValues.to).to.equal(receiver);200        expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);201202        expect(await contract.methods.tokenURI(+nextTokenId + i).call()).to.be.equal(`Test URI ${i}`);203      }204    }205  });206207  itEth('Can perform burn()', async ({helper}) => {208    const caller = await helper.eth.createAccountWithBalance(donor);209210    const collection = await helper.nft.mintCollection(alice, {});211    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});212213    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);214    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);215216    {217      const result = await contract.methods.burn(tokenId).send({from: caller});218      219      const event = result.events.Transfer;220      expect(event.address).to.be.equal(collectionAddress);221      expect(event.returnValues.from).to.be.equal(caller);222      expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');223      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);224    }225  });226227  itEth('Can perform approve()', async ({helper}) => {228    const owner = await helper.eth.createAccountWithBalance(donor);229    const spender = helper.eth.createAccount();230231    const collection = await helper.nft.mintCollection(alice, {});232    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});233234    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);235    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);236237    {238      const result = await contract.methods.approve(spender, tokenId).send({from: owner});239240      const event = result.events.Approval;241      expect(event.address).to.be.equal(collectionAddress);242      expect(event.returnValues.owner).to.be.equal(owner);243      expect(event.returnValues.approved).to.be.equal(spender);244      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);245    }246  });247248  itEth('Can perform transferFrom()', async ({helper}) => {249    const owner = await helper.eth.createAccountWithBalance(donor);250    const spender = await helper.eth.createAccountWithBalance(donor);251    const receiver = helper.eth.createAccount();252253    const collection = await helper.nft.mintCollection(alice, {});254    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});255256    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);257    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);258259    await contract.methods.approve(spender, tokenId).send({from: owner});260261    {262      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});263264      const event = result.events.Transfer;265      expect(event.address).to.be.equal(collectionAddress);266      expect(event.returnValues.from).to.be.equal(owner);267      expect(event.returnValues.to).to.be.equal(receiver);268      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);269    }270271    {272      const balance = await contract.methods.balanceOf(receiver).call();273      expect(+balance).to.equal(1);274    }275276    {277      const balance = await contract.methods.balanceOf(owner).call();278      expect(+balance).to.equal(0);279    }280  });281282  itEth('Can perform transfer()', async ({helper}) => {283    const collection = await helper.nft.mintCollection(alice, {});284    const owner = await helper.eth.createAccountWithBalance(donor);285    const receiver = helper.eth.createAccount();286287    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});288289    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);290    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);291292    {293      const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});294295      const event = result.events.Transfer;296      expect(event.address).to.be.equal(collectionAddress);297      expect(event.returnValues.from).to.be.equal(owner);298      expect(event.returnValues.to).to.be.equal(receiver);299      expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);300    }301302    {303      const balance = await contract.methods.balanceOf(owner).call();304      expect(+balance).to.equal(0);305    }306307    {308      const balance = await contract.methods.balanceOf(receiver).call();309      expect(+balance).to.equal(1);310    }311  });312});313314describe('NFT: Fees', () => {315  let donor: IKeyringPair;316  let alice: IKeyringPair;317318  before(async function() {319    await usingEthPlaygrounds(async (helper, privateKey) => {320      donor = privateKey('//Alice');321      [alice] = await helper.arrange.createAccounts([10n], donor);322    });323  });324  325  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {326    const owner = await helper.eth.createAccountWithBalance(donor);327    const spender = helper.eth.createAccount();328329    const collection = await helper.nft.mintCollection(alice, {});330    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});331332    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);333334    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));335    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));336  });337338  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {339    const owner = await helper.eth.createAccountWithBalance(donor);340    const spender = await helper.eth.createAccountWithBalance(donor);341342    const collection = await helper.nft.mintCollection(alice, {});343    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});344345    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);346347    await contract.methods.approve(spender, tokenId).send({from: owner});348349    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));350    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));351  });352353  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {354    const owner = await helper.eth.createAccountWithBalance(donor);355    const receiver = helper.eth.createAccount();356357    const collection = await helper.nft.mintCollection(alice, {});358    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});359360    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);361362    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));363    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));364  });365});366367describe('NFT: Substrate calls', () => {368  let donor: IKeyringPair;369  let alice: IKeyringPair;370371  before(async function() {372    await usingEthPlaygrounds(async (helper, privateKey) => {373      donor = privateKey('//Alice');374      [alice] = await helper.arrange.createAccounts([20n], donor);375    });376  });377378  itEth('Events emitted for mint()', async ({helper}) => {379    const collection = await helper.nft.mintCollection(alice, {});380    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);381    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');382383    const events: any = [];384    contract.events.allEvents((_: any, event: any) => {385      events.push(event);386    });387    const {tokenId} = await collection.mintToken(alice);388389    const event = events[0];390    expect(event.event).to.be.equal('Transfer');391    expect(event.address).to.be.equal(collectionAddress);392    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');393    expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(alice.address));394    expect(event.returnValues.tokenId).to.be.equal(tokenId.toString());395  });396397  itEth('Events emitted for burn()', async ({helper}) => {398    const collection = await helper.nft.mintCollection(alice, {});399    const token = await collection.mintToken(alice);400401    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);402    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');403    404    const events: any = [];405    contract.events.allEvents((_: any, event: any) => {406      events.push(event);407    });408409    await token.burn(alice);410411    const event = events[0];412    expect(event.event).to.be.equal('Transfer');413    expect(event.address).to.be.equal(collectionAddress);414    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));415    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');416    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());417  });418419  itEth('Events emitted for approve()', async ({helper}) => {420    const receiver = helper.eth.createAccount();421422    const collection = await helper.nft.mintCollection(alice, {});423    const token = await collection.mintToken(alice);424425    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);426    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');427    428    const events: any = [];429    contract.events.allEvents((_: any, event: any) => {430      events.push(event);431    });432433    await token.approve(alice, {Ethereum: receiver});434435    const event = events[0];436    expect(event.event).to.be.equal('Approval');437    expect(event.address).to.be.equal(collectionAddress);438    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));439    expect(event.returnValues.approved).to.be.equal(receiver);440    expect(event.returnValues.tokenId).to.be.equal(token.tokenId.toString());441  });442443  itEth('Events emitted for transferFrom()', async ({helper}) => {444    const [bob] = await helper.arrange.createAccounts([10n], donor);445    const receiver = helper.eth.createAccount();446447    const collection = await helper.nft.mintCollection(alice, {});448    const token = await collection.mintToken(alice);449    await token.approve(alice, {Substrate: bob.address});450451    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);452    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');453    454    const events: any = [];455    contract.events.allEvents((_: any, event: any) => {456      events.push(event);457    });458459    await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver});460    461    const event = events[0];462    expect(event.address).to.be.equal(collectionAddress);463    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));464    expect(event.returnValues.to).to.be.equal(receiver);465    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);466  });467468  itEth('Events emitted for transfer()', async ({helper}) => {469    const receiver = helper.eth.createAccount();470471    const collection = await helper.nft.mintCollection(alice, {});472    const token = await collection.mintToken(alice);473474    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);475    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');476    477    const events: any = [];478    contract.events.allEvents((_: any, event: any) => {479      events.push(event);480    });481482    await token.transfer(alice, {Ethereum: receiver});483    484    const event = events[0];485    expect(event.address).to.be.equal(collectionAddress);486    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));487    expect(event.returnValues.to).to.be.equal(receiver);488    expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);489  });490});491492describe('Common metadata', () => {493  let donor: IKeyringPair;494  let alice: IKeyringPair;495496  before(async function() {497    await usingEthPlaygrounds(async (helper, privateKey) => {498      donor = privateKey('//Alice');499      [alice] = await helper.arrange.createAccounts([20n], donor);500    });501  });502503  itEth('Returns collection name', async ({helper}) => {504    const caller = await helper.eth.createAccountWithBalance(donor);505    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});506507    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);508    const name = await contract.methods.name().call();509    expect(name).to.equal('oh River');510  });511512  itEth('Returns symbol name', async ({helper}) => {513    const caller = await helper.eth.createAccountWithBalance(donor);514    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});515516    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);517    const symbol = await contract.methods.symbol().call();518    expect(symbol).to.equal('CHANGE');519  });520});
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';20import {UNIQUE} from '../util/helpers';2122describe('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  });71});7273describe('Check ERC721 token URI for NFT', () => {74  let donor: IKeyringPair;7576  before(async function() {77    await usingEthPlaygrounds(async (_helper, privateKey) => {78      donor = privateKey('//Alice');79    });80  });8182  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {83    const owner = await helper.eth.createAccountWithBalance(donor);84    const receiver = helper.eth.createAccount();8586    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);87    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});88    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);89    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);90    91    const nextTokenId = await contract.methods.nextTokenId().call();92    expect(nextTokenId).to.be.equal('1');93    result = await contract.methods.mint(94      receiver,95      nextTokenId,96    ).send();9798    if (propertyKey && propertyValue) {99      // Set URL or suffix100      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();101    }102103    const event = result.events.Transfer;104    expect(event.address).to.be.equal(collectionAddress);105    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');106    expect(event.returnValues.to).to.be.equal(receiver);107    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);108109    return {contract, nextTokenId};110  }111112  itEth('Empty tokenURI', async ({helper}) => {113    const {contract, nextTokenId} = await setup(helper, '');114    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');115  });116117  itEth('TokenURI from url', async ({helper}) => {118    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');119    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');120  });121122  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {123    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');124    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);125  });126127  itEth('TokenURI from baseURI + suffix', async ({helper}) => {128    const suffix = '/some/suffix';129    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);130    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);131  });132});133134describe('NFT: Plain calls', () => {135  let donor: IKeyringPair;136  let alice: IKeyringPair;137138  before(async function() {139    await usingEthPlaygrounds(async (helper, privateKey) => {140      donor = privateKey('//Alice');141      [alice] = await helper.arrange.createAccounts([10n], donor);142    });143  });144145  itEth('Can perform mint()', async ({helper}) => {146    const owner = await helper.eth.createAccountWithBalance(donor);147    const receiver = helper.eth.createAccount();148149    const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'Minty', '6', '6');150    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);151    const nextTokenId = await contract.methods.nextTokenId().call();152153    expect(nextTokenId).to.be.equal('1');154    const result = await contract.methods.mintWithTokenURI(155      receiver,156      nextTokenId,157      'Test URI',158    ).send();159160    const event = result.events.Transfer;161    expect(event.address).to.be.equal(collectionAddress);162    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');163    expect(event.returnValues.to).to.be.equal(receiver);164    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);165166    expect(await contract.methods.tokenURI(nextTokenId).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});219      220      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  });325  326  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');404    405    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');428    429    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');454    455    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});461    462    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');477    478    const events: any = [];479    contract.events.allEvents((_: any, event: any) => {480      events.push(event);481    });482483    await token.transfer(alice, {Ethereum: receiver});484    485    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 collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});507508    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);509    const name = await contract.methods.name().call();510    expect(name).to.equal('oh River');511  });512513  itEth('Returns symbol name', async ({helper}) => {514    const caller = await helper.eth.createAccountWithBalance(donor);515    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});516517    const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);518    const symbol = await contract.methods.symbol().call();519    expect(symbol).to.equal('CHANGE');520  });521});
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../../util/helpers';
 import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents} from '../util/helpers';
 import nonFungibleAbi from '../nonFungibleAbi.json';
 import {expect} from 'chai';
@@ -93,7 +93,7 @@
     const collectionHelper = evmCollectionHelpers(web3, owner);
     const result = await collectionHelper.methods
       .createNonfungibleCollection('A', 'A', 'A')
-      .send();
+      .send({value: Number(2n * UNIQUE)});
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const receiver = createEthAccount(web3);
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -18,6 +18,7 @@
 import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
 import {IKeyringPair} from '@polkadot/types/types';
 import {Contract} from 'web3-eth-contract';
+import {UNIQUE} from '../util/helpers';
 
 describe('Refungible token: Information getting', () => {
   let donor: IKeyringPair;
@@ -80,7 +81,7 @@
     const receiver = helper.eth.createAccount();
 
     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send();
+    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});
     const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
     
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -145,7 +145,7 @@
   const collectionHelper = evmCollectionHelpers(web3, owner);
   const result = await collectionHelper.methods
     .createRFTCollection('A', 'B', 'C')
-    .send();
+    .send({value: Number(2n * UNIQUE)});
   return await getCollectionAddressFromResult(api, result);
 }
 
@@ -154,7 +154,7 @@
   const collectionHelper = evmCollectionHelpers(web3, owner);
   const result = await collectionHelper.methods
     .createNonfungibleCollection('A', 'B', 'C')
-    .send();
+    .send({value: Number(2n * UNIQUE)});
   return await getCollectionAddressFromResult(api, result);
 }
 
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
@@ -170,9 +170,10 @@
   }
 
   async createNonfungibleCollection(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.createNonfungibleCollection(name, description, tokenPrefix).send();
+        
+    const result = await collectionHelper.methods.createNonfungibleCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
@@ -181,9 +182,10 @@
   }
 
   async createRefungibleCollection(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();
+        
+    const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2034,6 +2034,9 @@
 
 
 class BalanceGroup extends HelperGroup {
+  getCollectionCreationPrice(): bigint {
+    return 2n * this.helper.balance.getOneTokenNominal();
+  }
   /**
    * Representation of the native token in the smallest unit - one OPAL (OPL), QUARTZ (QTZ), or UNIQUE (UNQ).
    * @example getOneTokenNominal()