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
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -17,6 +17,7 @@
 import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';
 import {IKeyringPair} from '@polkadot/types/types';
 import {Contract} from 'web3-eth-contract';
+import {UNIQUE} from '../util/helpers';
 
 describe('NFT: Information getting', () => {
   let donor: IKeyringPair;
@@ -83,7 +84,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, 'nft', owner);
     
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
before · tests/src/eth/reFungibleToken.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 {Pallets, requirePalletsOrSkip} from '../util/playgrounds';18import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';19import {IKeyringPair} from '@polkadot/types/types';20import {Contract} from 'web3-eth-contract';2122describe('Refungible token: Information getting', () => {23  let donor: IKeyringPair;24  let alice: IKeyringPair;2526  before(async function() {27    await usingEthPlaygrounds(async (helper, privateKey) => {28      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);2930      donor = privateKey('//Alice');31      [alice] = await helper.arrange.createAccounts([20n], donor);32    });33  });3435  itEth('totalSupply', async ({helper}) => {36    const caller = await helper.eth.createAccountWithBalance(donor);37    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});38    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});3940    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);41    const totalSupply = await contract.methods.totalSupply().call();42    expect(totalSupply).to.equal('200');43  });4445  itEth('balanceOf', async ({helper}) => {46    const caller = await helper.eth.createAccountWithBalance(donor);47    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});48    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});4950    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);51    const balance = await contract.methods.balanceOf(caller).call();52    expect(balance).to.equal('200');53  });5455  itEth('decimals', async ({helper}) => {56    const caller = await helper.eth.createAccountWithBalance(donor);57    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});58    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});5960    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);61    const decimals = await contract.methods.decimals().call();62    expect(decimals).to.equal('0');63  });64});6566// FIXME: Need erc721 for ReFubgible.67describe('Check ERC721 token URI for ReFungible', () => {68  let donor: IKeyringPair;6970  before(async function() {71    await usingEthPlaygrounds(async (helper, privateKey) => {72      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);7374      donor = privateKey('//Alice');75    });76  });7778  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {79    const owner = await helper.eth.createAccountWithBalance(donor);80    const receiver = helper.eth.createAccount();8182    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);83    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send();84    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);85    const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);86    87    const nextTokenId = await contract.methods.nextTokenId().call();88    expect(nextTokenId).to.be.equal('1');89    result = await contract.methods.mint(90      receiver,91      nextTokenId,92    ).send();9394    if (propertyKey && propertyValue) {95      // Set URL or suffix96      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();97    }9899    const event = result.events.Transfer;100    expect(event.address).to.be.equal(collectionAddress);101    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');102    expect(event.returnValues.to).to.be.equal(receiver);103    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);104105    return {contract, nextTokenId};106  }107108  itEth('Empty tokenURI', async ({helper}) => {109    const {contract, nextTokenId} = await setup(helper, '');110    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');111  });112113  itEth('TokenURI from url', async ({helper}) => {114    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');115    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');116  });117118  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {119    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');120    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);121  });122123  itEth('TokenURI from baseURI + suffix', async ({helper}) => {124    const suffix = '/some/suffix';125    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);126    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);127  });128});129130describe('Refungible: Plain calls', () => {131  let donor: IKeyringPair;132  let alice: IKeyringPair;133134  before(async function() {135    await usingEthPlaygrounds(async (helper, privateKey) => {136      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);137138      donor = privateKey('//Alice');139      [alice] = await helper.arrange.createAccounts([50n], donor);140    });141  });142143  itEth('Can perform approve()', async ({helper}) => {144    const owner = await helper.eth.createAccountWithBalance(donor);145    const spender = helper.eth.createAccount();146    const collection = await helper.rft.mintCollection(alice);147    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});148149    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);150    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);151152    {153      const result = await contract.methods.approve(spender, 100).send({from: owner});154      const event = result.events.Approval;155      expect(event.address).to.be.equal(tokenAddress);156      expect(event.returnValues.owner).to.be.equal(owner);157      expect(event.returnValues.spender).to.be.equal(spender);158      expect(event.returnValues.value).to.be.equal('100');159    }160161    {162      const allowance = await contract.methods.allowance(owner, spender).call();163      expect(+allowance).to.equal(100);164    }165  });166167  itEth('Can perform transferFrom()', async ({helper}) => {168    const owner = await helper.eth.createAccountWithBalance(donor);169    const spender = await helper.eth.createAccountWithBalance(donor);170    const receiver = helper.eth.createAccount();171    const collection = await helper.rft.mintCollection(alice);172    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});173174    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);175    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);176177    await contract.methods.approve(spender, 100).send();178179    {180      const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: spender});181      let event = result.events.Transfer;182      expect(event.address).to.be.equal(tokenAddress);183      expect(event.returnValues.from).to.be.equal(owner);184      expect(event.returnValues.to).to.be.equal(receiver);185      expect(event.returnValues.value).to.be.equal('49');186187      event = result.events.Approval;188      expect(event.address).to.be.equal(tokenAddress);189      expect(event.returnValues.owner).to.be.equal(owner);190      expect(event.returnValues.spender).to.be.equal(spender);191      expect(event.returnValues.value).to.be.equal('51');192    }193194    {195      const balance = await contract.methods.balanceOf(receiver).call();196      expect(+balance).to.equal(49);197    }198199    {200      const balance = await contract.methods.balanceOf(owner).call();201      expect(+balance).to.equal(151);202    }203  });204205  itEth('Can perform transfer()', async ({helper}) => {206    const owner = await helper.eth.createAccountWithBalance(donor);207    const receiver = helper.eth.createAccount();208    const collection = await helper.rft.mintCollection(alice);209    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});210211    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);212    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);213214    {215      const result = await contract.methods.transfer(receiver, 50).send({from: owner});216      const event = result.events.Transfer;217      expect(event.address).to.be.equal(tokenAddress);218      expect(event.returnValues.from).to.be.equal(owner);219      expect(event.returnValues.to).to.be.equal(receiver);220      expect(event.returnValues.value).to.be.equal('50');221    }222223    {224      const balance = await contract.methods.balanceOf(owner).call();225      expect(+balance).to.equal(150);226    }227228    {229      const balance = await contract.methods.balanceOf(receiver).call();230      expect(+balance).to.equal(50);231    }232  });233234  itEth('Can perform repartition()', async ({helper}) => {235    const owner = await helper.eth.createAccountWithBalance(donor);236    const receiver = await helper.eth.createAccountWithBalance(donor);237    const collection = await helper.rft.mintCollection(alice);238    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});239240    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);241    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);242243    await contract.methods.repartition(200).send({from: owner});244    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);245    await contract.methods.transfer(receiver, 110).send({from: owner});246    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(90);247    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(110);248249    await expect(contract.methods.repartition(80).send({from: owner})).to.eventually.be.rejected; // Transaction is reverted250251    await contract.methods.transfer(receiver, 90).send({from: owner});252    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(0);253    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(200);254255    await contract.methods.repartition(150).send({from: receiver});256    await expect(contract.methods.transfer(owner, 160).send({from: receiver})).to.eventually.be.rejected; // Transaction is reverted257    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(150);258  });259260  itEth('Can repartition with increased amount', async ({helper}) => {261    const owner = await helper.eth.createAccountWithBalance(donor);262    const collection = await helper.rft.mintCollection(alice);263    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});264265    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);266    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);267268    const result = await contract.methods.repartition(200).send();269270    const event = result.events.Transfer;271    expect(event.address).to.be.equal(tokenAddress);272    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');273    expect(event.returnValues.to).to.be.equal(owner);274    expect(event.returnValues.value).to.be.equal('100');275  });276277  itEth('Can repartition with decreased amount', async ({helper}) => {278    const owner = await helper.eth.createAccountWithBalance(donor);279    const collection = await helper.rft.mintCollection(alice);280    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});281282    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);283    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);284285    const result = await contract.methods.repartition(50).send();286    const event = result.events.Transfer;287    expect(event.address).to.be.equal(tokenAddress);288    expect(event.returnValues.from).to.be.equal(owner);289    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');290    expect(event.returnValues.value).to.be.equal('50');291  });292293  itEth('Receiving Transfer event on burning into full ownership', async ({helper}) => {294    const caller = await helper.eth.createAccountWithBalance(donor);295    const receiver = await helper.eth.createAccountWithBalance(donor);296    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Devastation', '6', '6');297    const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);298299    const tokenId = await contract.methods.nextTokenId().call();300    await contract.methods.mint(caller, tokenId).send();301    const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);302    const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);303304    await tokenContract.methods.repartition(2).send();305    await tokenContract.methods.transfer(receiver, 1).send();306307    const events: any = [];308    contract.events.allEvents((_: any, event: any) => {309      events.push(event);310    });311    await tokenContract.methods.burnFrom(caller, 1).send();312313    const event = events[0];314    expect(event.address).to.be.equal(collectionAddress);315    expect(event.returnValues.from).to.be.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');316    expect(event.returnValues.to).to.be.equal(receiver);317    expect(event.returnValues.tokenId).to.be.equal(tokenId);318  });319});320321describe('Refungible: Fees', () => {322  let donor: IKeyringPair;323  let alice: IKeyringPair;324325  before(async function() {326    await usingEthPlaygrounds(async (helper, privateKey) => {327      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);328329      donor = privateKey('//Alice');330      [alice] = await helper.arrange.createAccounts([50n], donor);331    });332  });333334  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();337    const collection = await helper.rft.mintCollection(alice);338    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});339340    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);341    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);342343    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).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);350    const collection = await helper.rft.mintCollection(alice);351    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});352353    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);354    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);355356    await contract.methods.approve(spender, 100).send({from: owner});357358    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, 100).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();365    const collection = await helper.rft.mintCollection(alice);366    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});367368    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);369    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);370371    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));372    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));373  });374});375376describe('Refungible: Substrate calls', () => {377  let donor: IKeyringPair;378  let alice: IKeyringPair;379380  before(async function() {381    await usingEthPlaygrounds(async (helper, privateKey) => {382      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);383384      donor = privateKey('//Alice');385      [alice] = await helper.arrange.createAccounts([50n], donor);386    });387  });388389  itEth('Events emitted for approve()', async ({helper}) => {390    const receiver = helper.eth.createAccount();391    const collection = await helper.rft.mintCollection(alice);392    const token = await collection.mintToken(alice, 200n);393394    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);395    const contract = helper.ethNativeContract.rftToken(tokenAddress);396397    const events: any = [];398    contract.events.allEvents((_: any, event: any) => {399      events.push(event);400    });401    expect(await token.approve(alice, {Ethereum: receiver}, 100n)).to.be.true;402403    const event = events[0];404    expect(event.event).to.be.equal('Approval');405    expect(event.address).to.be.equal(tokenAddress);406    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));407    expect(event.returnValues.spender).to.be.equal(receiver);408    expect(event.returnValues.value).to.be.equal('100');409  });410411  itEth('Events emitted for transferFrom()', async ({helper}) => {412    const [bob] = await helper.arrange.createAccounts([10n], donor);413    const receiver = helper.eth.createAccount();414    const collection = await helper.rft.mintCollection(alice);415    const token = await collection.mintToken(alice, 200n);416    await token.approve(alice, {Substrate: bob.address}, 100n);417418    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);419    const contract = helper.ethNativeContract.rftToken(tokenAddress);420421    const events: any = [];422    contract.events.allEvents((_: any, event: any) => {423      events.push(event);424    });425426    expect(await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver},  51n)).to.be.true;427428    let event = events[0];429    expect(event.event).to.be.equal('Transfer');430    expect(event.address).to.be.equal(tokenAddress);431    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));432    expect(event.returnValues.to).to.be.equal(receiver);433    expect(event.returnValues.value).to.be.equal('51');434435    event = events[1];436    expect(event.event).to.be.equal('Approval');437    expect(event.address).to.be.equal(tokenAddress);438    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));439    expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(bob.address));440    expect(event.returnValues.value).to.be.equal('49');441  });442443  itEth('Events emitted for transfer()', async ({helper}) => {444    const receiver = helper.eth.createAccount();445    const collection = await helper.rft.mintCollection(alice);446    const token = await collection.mintToken(alice, 200n);447448    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);449    const contract = helper.ethNativeContract.rftToken(tokenAddress);450451    const events: any = [];452    contract.events.allEvents((_: any, event: any) => {453      events.push(event);454    });455456    expect(await token.transfer(alice, {Ethereum: receiver},  51n)).to.be.true;457458    const event = events[0];459    expect(event.event).to.be.equal('Transfer');460    expect(event.address).to.be.equal(tokenAddress);461    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));462    expect(event.returnValues.to).to.be.equal(receiver);463    expect(event.returnValues.value).to.be.equal('51');464  });465});466467describe('ERC 1633 implementation', () => {468  let donor: IKeyringPair;469470  before(async function() {471    await usingEthPlaygrounds(async (helper, privateKey) => {472      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);473474      donor = privateKey('//Alice');475    });476  });477478  itEth('Default parent token address and id', async ({helper}) => {479    const owner = await helper.eth.createAccountWithBalance(donor);480481    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sands', '', 'GRAIN');482    const collectionContract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);483    484    const tokenId = await collectionContract.methods.nextTokenId().call();485    await collectionContract.methods.mint(owner, tokenId).send();486    const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);487    const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);488489    expect(await tokenContract.methods.parentToken().call()).to.be.equal(collectionAddress);490    expect(await tokenContract.methods.parentTokenId().call()).to.be.equal(tokenId);491  });492});
after · tests/src/eth/reFungibleToken.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 {Pallets, requirePalletsOrSkip} from '../util/playgrounds';18import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';19import {IKeyringPair} from '@polkadot/types/types';20import {Contract} from 'web3-eth-contract';21import {UNIQUE} from '../util/helpers';2223describe('Refungible token: Information getting', () => {24  let donor: IKeyringPair;25  let alice: IKeyringPair;2627  before(async function() {28    await usingEthPlaygrounds(async (helper, privateKey) => {29      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);3031      donor = privateKey('//Alice');32      [alice] = await helper.arrange.createAccounts([20n], donor);33    });34  });3536  itEth('totalSupply', async ({helper}) => {37    const caller = await helper.eth.createAccountWithBalance(donor);38    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});39    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});4041    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);42    const totalSupply = await contract.methods.totalSupply().call();43    expect(totalSupply).to.equal('200');44  });4546  itEth('balanceOf', async ({helper}) => {47    const caller = await helper.eth.createAccountWithBalance(donor);48    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});49    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});5051    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);52    const balance = await contract.methods.balanceOf(caller).call();53    expect(balance).to.equal('200');54  });5556  itEth('decimals', async ({helper}) => {57    const caller = await helper.eth.createAccountWithBalance(donor);58    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});59    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});6061    const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);62    const decimals = await contract.methods.decimals().call();63    expect(decimals).to.equal('0');64  });65});6667// FIXME: Need erc721 for ReFubgible.68describe('Check ERC721 token URI for ReFungible', () => {69  let donor: IKeyringPair;7071  before(async function() {72    await usingEthPlaygrounds(async (helper, privateKey) => {73      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);7475      donor = privateKey('//Alice');76    });77  });7879  async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {80    const owner = await helper.eth.createAccountWithBalance(donor);81    const receiver = helper.eth.createAccount();8283    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);84    let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});85    const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);86    const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);87    88    const nextTokenId = await contract.methods.nextTokenId().call();89    expect(nextTokenId).to.be.equal('1');90    result = await contract.methods.mint(91      receiver,92      nextTokenId,93    ).send();9495    if (propertyKey && propertyValue) {96      // Set URL or suffix97      await contract.methods.setProperty(nextTokenId, propertyKey, Buffer.from(propertyValue)).send();98    }99100    const event = result.events.Transfer;101    expect(event.address).to.be.equal(collectionAddress);102    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');103    expect(event.returnValues.to).to.be.equal(receiver);104    expect(event.returnValues.tokenId).to.be.equal(nextTokenId);105106    return {contract, nextTokenId};107  }108109  itEth('Empty tokenURI', async ({helper}) => {110    const {contract, nextTokenId} = await setup(helper, '');111    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');112  });113114  itEth('TokenURI from url', async ({helper}) => {115    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');116    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');117  });118119  itEth('TokenURI from baseURI + tokenId', async ({helper}) => {120    const {contract, nextTokenId} = await setup(helper, 'BaseURI_');121    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);122  });123124  itEth('TokenURI from baseURI + suffix', async ({helper}) => {125    const suffix = '/some/suffix';126    const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);127    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);128  });129});130131describe('Refungible: Plain calls', () => {132  let donor: IKeyringPair;133  let alice: IKeyringPair;134135  before(async function() {136    await usingEthPlaygrounds(async (helper, privateKey) => {137      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);138139      donor = privateKey('//Alice');140      [alice] = await helper.arrange.createAccounts([50n], donor);141    });142  });143144  itEth('Can perform approve()', async ({helper}) => {145    const owner = await helper.eth.createAccountWithBalance(donor);146    const spender = helper.eth.createAccount();147    const collection = await helper.rft.mintCollection(alice);148    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});149150    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);151    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);152153    {154      const result = await contract.methods.approve(spender, 100).send({from: owner});155      const event = result.events.Approval;156      expect(event.address).to.be.equal(tokenAddress);157      expect(event.returnValues.owner).to.be.equal(owner);158      expect(event.returnValues.spender).to.be.equal(spender);159      expect(event.returnValues.value).to.be.equal('100');160    }161162    {163      const allowance = await contract.methods.allowance(owner, spender).call();164      expect(+allowance).to.equal(100);165    }166  });167168  itEth('Can perform transferFrom()', async ({helper}) => {169    const owner = await helper.eth.createAccountWithBalance(donor);170    const spender = await helper.eth.createAccountWithBalance(donor);171    const receiver = helper.eth.createAccount();172    const collection = await helper.rft.mintCollection(alice);173    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});174175    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);176    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);177178    await contract.methods.approve(spender, 100).send();179180    {181      const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: spender});182      let event = result.events.Transfer;183      expect(event.address).to.be.equal(tokenAddress);184      expect(event.returnValues.from).to.be.equal(owner);185      expect(event.returnValues.to).to.be.equal(receiver);186      expect(event.returnValues.value).to.be.equal('49');187188      event = result.events.Approval;189      expect(event.address).to.be.equal(tokenAddress);190      expect(event.returnValues.owner).to.be.equal(owner);191      expect(event.returnValues.spender).to.be.equal(spender);192      expect(event.returnValues.value).to.be.equal('51');193    }194195    {196      const balance = await contract.methods.balanceOf(receiver).call();197      expect(+balance).to.equal(49);198    }199200    {201      const balance = await contract.methods.balanceOf(owner).call();202      expect(+balance).to.equal(151);203    }204  });205206  itEth('Can perform transfer()', async ({helper}) => {207    const owner = await helper.eth.createAccountWithBalance(donor);208    const receiver = helper.eth.createAccount();209    const collection = await helper.rft.mintCollection(alice);210    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});211212    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);213    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);214215    {216      const result = await contract.methods.transfer(receiver, 50).send({from: owner});217      const event = result.events.Transfer;218      expect(event.address).to.be.equal(tokenAddress);219      expect(event.returnValues.from).to.be.equal(owner);220      expect(event.returnValues.to).to.be.equal(receiver);221      expect(event.returnValues.value).to.be.equal('50');222    }223224    {225      const balance = await contract.methods.balanceOf(owner).call();226      expect(+balance).to.equal(150);227    }228229    {230      const balance = await contract.methods.balanceOf(receiver).call();231      expect(+balance).to.equal(50);232    }233  });234235  itEth('Can perform repartition()', async ({helper}) => {236    const owner = await helper.eth.createAccountWithBalance(donor);237    const receiver = await helper.eth.createAccountWithBalance(donor);238    const collection = await helper.rft.mintCollection(alice);239    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});240241    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);242    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);243244    await contract.methods.repartition(200).send({from: owner});245    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);246    await contract.methods.transfer(receiver, 110).send({from: owner});247    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(90);248    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(110);249250    await expect(contract.methods.repartition(80).send({from: owner})).to.eventually.be.rejected; // Transaction is reverted251252    await contract.methods.transfer(receiver, 90).send({from: owner});253    expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(0);254    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(200);255256    await contract.methods.repartition(150).send({from: receiver});257    await expect(contract.methods.transfer(owner, 160).send({from: receiver})).to.eventually.be.rejected; // Transaction is reverted258    expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(150);259  });260261  itEth('Can repartition with increased amount', async ({helper}) => {262    const owner = await helper.eth.createAccountWithBalance(donor);263    const collection = await helper.rft.mintCollection(alice);264    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});265266    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);267    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);268269    const result = await contract.methods.repartition(200).send();270271    const event = result.events.Transfer;272    expect(event.address).to.be.equal(tokenAddress);273    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');274    expect(event.returnValues.to).to.be.equal(owner);275    expect(event.returnValues.value).to.be.equal('100');276  });277278  itEth('Can repartition with decreased amount', async ({helper}) => {279    const owner = await helper.eth.createAccountWithBalance(donor);280    const collection = await helper.rft.mintCollection(alice);281    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});282283    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);284    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);285286    const result = await contract.methods.repartition(50).send();287    const event = result.events.Transfer;288    expect(event.address).to.be.equal(tokenAddress);289    expect(event.returnValues.from).to.be.equal(owner);290    expect(event.returnValues.to).to.be.equal('0x0000000000000000000000000000000000000000');291    expect(event.returnValues.value).to.be.equal('50');292  });293294  itEth('Receiving Transfer event on burning into full ownership', async ({helper}) => {295    const caller = await helper.eth.createAccountWithBalance(donor);296    const receiver = await helper.eth.createAccountWithBalance(donor);297    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(caller, 'Devastation', '6', '6');298    const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);299300    const tokenId = await contract.methods.nextTokenId().call();301    await contract.methods.mint(caller, tokenId).send();302    const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);303    const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);304305    await tokenContract.methods.repartition(2).send();306    await tokenContract.methods.transfer(receiver, 1).send();307308    const events: any = [];309    contract.events.allEvents((_: any, event: any) => {310      events.push(event);311    });312    await tokenContract.methods.burnFrom(caller, 1).send();313314    const event = events[0];315    expect(event.address).to.be.equal(collectionAddress);316    expect(event.returnValues.from).to.be.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');317    expect(event.returnValues.to).to.be.equal(receiver);318    expect(event.returnValues.tokenId).to.be.equal(tokenId);319  });320});321322describe('Refungible: Fees', () => {323  let donor: IKeyringPair;324  let alice: IKeyringPair;325326  before(async function() {327    await usingEthPlaygrounds(async (helper, privateKey) => {328      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);329330      donor = privateKey('//Alice');331      [alice] = await helper.arrange.createAccounts([50n], donor);332    });333  });334335  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {336    const owner = await helper.eth.createAccountWithBalance(donor);337    const spender = helper.eth.createAccount();338    const collection = await helper.rft.mintCollection(alice);339    const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});340341    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);342    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);343344    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));345    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));346  });347348  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {349    const owner = await helper.eth.createAccountWithBalance(donor);350    const spender = await helper.eth.createAccountWithBalance(donor);351    const collection = await helper.rft.mintCollection(alice);352    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});353354    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);355    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);356357    await contract.methods.approve(spender, 100).send({from: owner});358359    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, 100).send({from: spender}));360    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));361  });362363  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {364    const owner = await helper.eth.createAccountWithBalance(donor);365    const receiver = helper.eth.createAccount();366    const collection = await helper.rft.mintCollection(alice);367    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});368369    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);370    const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);371372    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));373    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));374  });375});376377describe('Refungible: Substrate calls', () => {378  let donor: IKeyringPair;379  let alice: IKeyringPair;380381  before(async function() {382    await usingEthPlaygrounds(async (helper, privateKey) => {383      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);384385      donor = privateKey('//Alice');386      [alice] = await helper.arrange.createAccounts([50n], donor);387    });388  });389390  itEth('Events emitted for approve()', async ({helper}) => {391    const receiver = helper.eth.createAccount();392    const collection = await helper.rft.mintCollection(alice);393    const token = await collection.mintToken(alice, 200n);394395    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);396    const contract = helper.ethNativeContract.rftToken(tokenAddress);397398    const events: any = [];399    contract.events.allEvents((_: any, event: any) => {400      events.push(event);401    });402    expect(await token.approve(alice, {Ethereum: receiver}, 100n)).to.be.true;403404    const event = events[0];405    expect(event.event).to.be.equal('Approval');406    expect(event.address).to.be.equal(tokenAddress);407    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));408    expect(event.returnValues.spender).to.be.equal(receiver);409    expect(event.returnValues.value).to.be.equal('100');410  });411412  itEth('Events emitted for transferFrom()', async ({helper}) => {413    const [bob] = await helper.arrange.createAccounts([10n], donor);414    const receiver = helper.eth.createAccount();415    const collection = await helper.rft.mintCollection(alice);416    const token = await collection.mintToken(alice, 200n);417    await token.approve(alice, {Substrate: bob.address}, 100n);418419    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);420    const contract = helper.ethNativeContract.rftToken(tokenAddress);421422    const events: any = [];423    contract.events.allEvents((_: any, event: any) => {424      events.push(event);425    });426427    expect(await token.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver},  51n)).to.be.true;428429    let event = events[0];430    expect(event.event).to.be.equal('Transfer');431    expect(event.address).to.be.equal(tokenAddress);432    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));433    expect(event.returnValues.to).to.be.equal(receiver);434    expect(event.returnValues.value).to.be.equal('51');435436    event = events[1];437    expect(event.event).to.be.equal('Approval');438    expect(event.address).to.be.equal(tokenAddress);439    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));440    expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(bob.address));441    expect(event.returnValues.value).to.be.equal('49');442  });443444  itEth('Events emitted for transfer()', async ({helper}) => {445    const receiver = helper.eth.createAccount();446    const collection = await helper.rft.mintCollection(alice);447    const token = await collection.mintToken(alice, 200n);448449    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);450    const contract = helper.ethNativeContract.rftToken(tokenAddress);451452    const events: any = [];453    contract.events.allEvents((_: any, event: any) => {454      events.push(event);455    });456457    expect(await token.transfer(alice, {Ethereum: receiver},  51n)).to.be.true;458459    const event = events[0];460    expect(event.event).to.be.equal('Transfer');461    expect(event.address).to.be.equal(tokenAddress);462    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));463    expect(event.returnValues.to).to.be.equal(receiver);464    expect(event.returnValues.value).to.be.equal('51');465  });466});467468describe('ERC 1633 implementation', () => {469  let donor: IKeyringPair;470471  before(async function() {472    await usingEthPlaygrounds(async (helper, privateKey) => {473      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);474475      donor = privateKey('//Alice');476    });477  });478479  itEth('Default parent token address and id', async ({helper}) => {480    const owner = await helper.eth.createAccountWithBalance(donor);481482    const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sands', '', 'GRAIN');483    const collectionContract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);484    485    const tokenId = await collectionContract.methods.nextTokenId().call();486    await collectionContract.methods.mint(owner, tokenId).send();487    const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);488    const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);489490    expect(await tokenContract.methods.parentToken().call()).to.be.equal(collectionAddress);491    expect(await tokenContract.methods.parentTokenId().call()).to.be.equal(tokenId);492  });493});
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()