git.delta.rocks / unique-network / refs/commits / d996a74e54de

difftreelog

Merge pull request #835 from UniqueNetwork/tests/generalization

Yaroslav Bolyukin2023-01-18parents: #d161923 #5954afe.patch.diff
in: master

20 files changed

modifiedtests/src/apiConsts.test.tsdiffbeforeafterboth
--- a/tests/src/apiConsts.test.ts
+++ b/tests/src/apiConsts.test.ts
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {ApiPromise} from '@polkadot/api';
-import {usingPlaygrounds, itSub, expect} from './util';
+import {usingPlaygrounds, itSub, expect, COLLECTION_HELPER, CONTRACT_HELPER} from './util';
 
 
 const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;
@@ -40,9 +40,6 @@
   ownerCanDestroy: true,
   transfersEnabled: true,
 };
-
-const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
-const HELPERS_CONTRACT_ADDRESS = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';
 
 describe('integration test: API UNIQUE consts', () => {
   let api: ApiPromise;
@@ -106,11 +103,11 @@
   });
 
   itSub('HELPERS_CONTRACT_ADDRESS', () => {
-    expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(HELPERS_CONTRACT_ADDRESS.toLowerCase());
+    expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(CONTRACT_HELPER.toLowerCase());
   });
 
   itSub('EVM_COLLECTION_HELPERS_ADDRESS', () => {
-    expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS.toLowerCase());
+    expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(COLLECTION_HELPER.toLowerCase());
   });
 });
 
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -45,32 +45,6 @@
     await collection.burnTokens(alice, 1n);
     expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);
   });
-
-  itSub.ifWithPallets('Burn item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
-    const collection = await helper.rft.mintCollection(alice);
-    const token = await collection.mintToken(alice, 100n);
-
-    await token.burn(alice, 90n);
-    expect(await token.getBalance({Substrate: alice.address})).to.eq(10n);
-
-    await token.burn(alice, 10n);
-    expect(await token.getBalance({Substrate: alice.address})).to.eq(0n);
-  });
-
-  itSub.ifWithPallets('Burn owned portion of item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
-    const collection = await helper.rft.mintCollection(alice);
-    const token = await collection.mintToken(alice, 100n);
-
-    await token.transfer(alice, {Substrate: bob.address}, 1n);
-
-    expect(await token.getBalance({Substrate: alice.address})).to.eq(99n);
-    expect(await token.getBalance({Substrate: bob.address})).to.eq(1n);
-
-    await token.burn(bob, 1n);
-
-    expect(await token.getBalance({Substrate: alice.address})).to.eq(99n);
-    expect(await token.getBalance({Substrate: bob.address})).to.eq(0n);
-  });
 });
 
 describe('integration test: ext. burnItem() with admin permissions:', () => {
@@ -104,16 +78,6 @@
     await collection.burnTokensFrom(bob, {Substrate: alice.address}, 1n);
     expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);
   });
-
-  itSub.ifWithPallets('Burn item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
-    const collection = await helper.rft.mintCollection(alice);
-    await collection.setLimits(alice, {ownerCanTransfer: true});
-    await collection.addAdmin(alice, {Substrate: bob.address});
-    const token = await collection.mintToken(alice, 100n);
-
-    await token.burnFrom(bob, {Substrate: alice.address}, 100n);
-    expect(await token.doesExist()).to.be.false;
-  });
 });
 
 describe('Negative integration test: ext. burnItem():', () => {
@@ -138,31 +102,6 @@
     const token = await collection.mintToken(alice);
 
     await expect(token.burn(bob)).to.be.rejectedWith('common.NoPermission');
-  });
-
-  itSub.ifWithPallets('RFT: cannot burn non-owned token pieces', [Pallets.ReFungible], async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice);
-    const aliceToken = await collection.mintToken(alice, 10n, {Substrate: alice.address});
-    const bobToken = await collection.mintToken(alice, 10n, {Substrate: bob.address});
-
-    // 1. Cannot burn non-owned token:
-    await expect(bobToken.burn(alice, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
-    await expect(bobToken.burn(alice, 5n)).to.be.rejectedWith('common.TokenValueTooLow');
-    // 2. Cannot burn non-existing token:
-    await expect(helper.rft.burnToken(alice, 99999, 10)).to.be.rejectedWith('common.CollectionNotFound');
-    await expect(helper.rft.burnToken(alice, collection.collectionId, 99999)).to.be.rejectedWith('common.TokenValueTooLow');
-    // 3. Can burn zero amount of owned tokens (EIP-20)
-    await aliceToken.burn(alice, 0n);
-
-    // 4. Storage is not corrupted:
-    expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
-    expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
-
-    // 4.1 Tokens can be transfered:
-    await aliceToken.transfer(alice, {Substrate: bob.address}, 10n);
-    await bobToken.transfer(bob, {Substrate: alice.address}, 10n);
-    expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
-    expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
   });
 
   itSub('Transfer a burned token', async ({helper}) => {
modifiedtests/src/eth/collectionHelperAddress.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionHelperAddress.test.ts
+++ b/tests/src/eth/collectionHelperAddress.test.ts
@@ -16,9 +16,7 @@
 
 import {itEth, usingEthPlaygrounds, expect} from './util';
 import {IKeyringPair} from '@polkadot/types/types';
-import {Pallets} from '../util';
-
-const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
+import {COLLECTION_HELPER, Pallets} from '../util';
 
 describe('[eth]CollectionHelperAddress test: ERC20/ERC721 ', () => {
   let donor: IKeyringPair;
@@ -36,7 +34,7 @@
     const nftCollection = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);
 
     expect((await nftCollection.methods.collectionHelperAddress().call())
-      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
   });
 
   itEth.ifWithPallets('RFT ', [Pallets.ReFungible], async ({helper}) => {
@@ -46,7 +44,7 @@
 
     const rftCollection = await helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);
     expect((await rftCollection.methods.collectionHelperAddress().call())
-      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
   });
 
   itEth('FT', async ({helper}) => {
@@ -56,7 +54,7 @@
     const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
 
     expect((await collection.methods.collectionHelperAddress().call())
-      .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);
+      .toString().toLowerCase()).to.be.equal(COLLECTION_HELPER);
   });
 
   itEth('[collectionHelpers] convert collectionId into address', async ({helper}) => {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -18,6 +18,7 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {expect, itEth, usingEthPlaygrounds} from './util';
 import {CollectionLimitField} from './util/playgrounds/types';
+import {COLLECTION_HELPER} from '../util';
 
 
 describe('Create NFT collection from EVM', () => {
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
before · tests/src/eth/fungible.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 {expect, itEth, usingEthPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';1920describe('Fungible: Information getting', () => {21  let donor: IKeyringPair;22  let alice: IKeyringPair;2324  before(async function() {25    await usingEthPlaygrounds(async (helper, privateKey) => {26      donor = await privateKey({filename: __filename});27      [alice] = await helper.arrange.createAccounts([20n], donor);28    });29  });3031  itEth('totalSupply', async ({helper}) => {32    const caller = await helper.eth.createAccountWithBalance(donor);33    const collection = await helper.ft.mintCollection(alice);34    await collection.mint(alice, 200n);3536    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);37    const totalSupply = await contract.methods.totalSupply().call();38    expect(totalSupply).to.equal('200');39  });4041  itEth('balanceOf', async ({helper}) => {42    const caller = await helper.eth.createAccountWithBalance(donor);43    const collection = await helper.ft.mintCollection(alice);44    await collection.mint(alice, 200n, {Ethereum: caller});4546    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);47    const balance = await contract.methods.balanceOf(caller).call();48    expect(balance).to.equal('200');49  });50});5152describe('Fungible: Plain calls', () => {53  let donor: IKeyringPair;54  let alice: IKeyringPair;55  let owner: IKeyringPair;5657  before(async function() {58    await usingEthPlaygrounds(async (helper, privateKey) => {59      donor = await privateKey({filename: __filename});60      [alice, owner] = await helper.arrange.createAccounts([30n, 20n], donor);61    });62  });6364  itEth('Can perform mint()', async ({helper}) => {65    const owner = await helper.eth.createAccountWithBalance(donor);66    const receiver = helper.eth.createAccount();67    const collection = await helper.ft.mintCollection(alice);68    await collection.addAdmin(alice, {Ethereum: owner});6970    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);71    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);7273    const result = await contract.methods.mint(receiver, 100).send();7475    const event = result.events.Transfer;76    expect(event.address).to.equal(collectionAddress);77    expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');78    expect(event.returnValues.to).to.equal(receiver);79    expect(event.returnValues.value).to.equal('100');80  });8182  [83    'substrate' as const,84    'ethereum' as const,85  ].map(testCase => {86    itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {87      // 1. Create receiver depending on the test case:88      const receiverEth = helper.eth.createAccount();89      const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);90      const receiverSub = owner;91      const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(owner);9293      const ethOwner = await helper.eth.createAccountWithBalance(donor);94      const collection = await helper.ft.mintCollection(alice);95      await collection.addAdmin(alice, {Ethereum: ethOwner});9697      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);98      const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', ethOwner);99100      // 2. Mint tokens:101      const result = await collectionEvm.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, 100).send();102103      const event = result.events.Transfer;104      expect(event.address).to.equal(collectionAddress);105      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');106      expect(event.returnValues.to).to.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(receiverSub.address));107      expect(event.returnValues.value).to.equal('100');108109      // 3. Get balance depending on the test case:110      let balance;111      if (testCase === 'ethereum') balance = await collection.getBalance({Ethereum: receiverEth});112      else if (testCase === 'substrate') balance = await collection.getBalance({Substrate: receiverSub.address});113      // 3.1 Check balance:114      expect(balance).to.eq(100n);115    });116  });117118  itEth('Can perform mintBulk()', async ({helper}) => {119    const owner = await helper.eth.createAccountWithBalance(donor);120    const bulkSize = 3;121    const receivers = [...new Array(bulkSize)].map(() => helper.eth.createAccount());122    const collection = await helper.ft.mintCollection(alice);123    await collection.addAdmin(alice, {Ethereum: owner});124125    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);126    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);127128    const result = await contract.methods.mintBulk(Array.from({length: bulkSize}, (_, i) => (129      [receivers[i], (i + 1) * 10]130    ))).send();131    const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.value - b.returnValues.value);132    for (let i = 0; i < bulkSize; i++) {133      const event = events[i];134      expect(event.address).to.equal(collectionAddress);135      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');136      expect(event.returnValues.to).to.equal(receivers[i]);137      expect(event.returnValues.value).to.equal(String(10 * (i + 1)));138    }139  });140141  // Soft-deprecated142  itEth('Can perform burn()', async ({helper}) => {143    const owner = await helper.eth.createAccountWithBalance(donor);144    const receiver = await helper.eth.createAccountWithBalance(donor);145    const collection = await helper.ft.mintCollection(alice);146    await collection.addAdmin(alice, {Ethereum: owner});147148    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);149    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);150    await contract.methods.mint(receiver, 100).send();151152    const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});153154    const event = result.events.Transfer;155    expect(event.address).to.equal(collectionAddress);156    expect(event.returnValues.from).to.equal(receiver);157    expect(event.returnValues.to).to.equal('0x0000000000000000000000000000000000000000');158    expect(event.returnValues.value).to.equal('49');159160    const balance = await contract.methods.balanceOf(receiver).call();161    expect(balance).to.equal('51');162  });163164  itEth('Can perform approve()', async ({helper}) => {165    const owner = await helper.eth.createAccountWithBalance(donor);166    const spender = helper.eth.createAccount();167    const collection = await helper.ft.mintCollection(alice);168    await collection.mint(alice, 200n, {Ethereum: owner});169170    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);171    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);172173    {174      const result = await contract.methods.approve(spender, 100).send({from: owner});175176      const event = result.events.Approval;177      expect(event.address).to.be.equal(collectionAddress);178      expect(event.returnValues.owner).to.be.equal(owner);179      expect(event.returnValues.spender).to.be.equal(spender);180      expect(event.returnValues.value).to.be.equal('100');181    }182183    {184      const allowance = await contract.methods.allowance(owner, spender).call();185      expect(+allowance).to.equal(100);186    }187  });188189  itEth('Can perform approveCross()', async ({helper}) => {190    const owner = await helper.eth.createAccountWithBalance(donor);191    const spender = helper.eth.createAccount();192    const spenderSub = (await helper.arrange.createAccounts([1n], donor))[0];193    const spenderCrossEth = helper.ethCrossAccount.fromAddress(spender);194    const spenderCrossSub = helper.ethCrossAccount.fromKeyringPair(spenderSub);195196197    const collection = await helper.ft.mintCollection(alice);198    await collection.mint(alice, 200n, {Ethereum: owner});199200    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);201    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);202203    {204      const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});205      const event = result.events.Approval;206      expect(event.address).to.be.equal(collectionAddress);207      expect(event.returnValues.owner).to.be.equal(owner);208      expect(event.returnValues.spender).to.be.equal(spender);209      expect(event.returnValues.value).to.be.equal('100');210    }211212    {213      const allowance = await contract.methods.allowance(owner, spender).call();214      expect(+allowance).to.equal(100);215    }216217218    {219      const result = await contract.methods.approveCross(spenderCrossSub, 100).send({from: owner});220      const event = result.events.Approval;221      expect(event.address).to.be.equal(collectionAddress);222      expect(event.returnValues.owner).to.be.equal(owner);223      expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(spenderSub.address));224      expect(event.returnValues.value).to.be.equal('100');225    }226227    {228      const allowance = await collection.getApprovedTokens({Ethereum: owner}, {Substrate: spenderSub.address});229      expect(allowance).to.equal(100n);230    }231232    {233      //TO-DO expect with future allowanceCross(owner, spenderCrossEth).call()234    }235  });236237  itEth('Non-owner and non admin cannot approveCross', async ({helper}) => {238    const nonOwner = await helper.eth.createAccountWithBalance(donor);239    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);240    const owner = await helper.eth.createAccountWithBalance(donor);241    const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});242    await collection.mint(alice, 100n, {Ethereum: owner});243244    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);245    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);246247    await expect(collectionEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');248  });249250251  itEth('Can perform burnFromCross()', async ({helper}) => {252    const sender = await helper.eth.createAccountWithBalance(donor, 100n);253254    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);255256    await collection.mint(owner, 200n, {Substrate: owner.address});257    await collection.approveTokens(owner, {Ethereum: sender}, 100n);258259    const address = helper.ethAddress.fromCollectionId(collection.collectionId);260    const contract = await helper.ethNativeContract.collection(address, 'ft');261262    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});263264    const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);265    const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});266    const events = result.events;267268    expect(events).to.be.like({269      Transfer: {270        address: helper.ethAddress.fromCollectionId(collection.collectionId),271        event: 'Transfer',272        returnValues: {273          from: helper.address.substrateToEth(owner.address),274          to: '0x0000000000000000000000000000000000000000',275          value: '49',276        },277      },278      Approval: {279        address: helper.ethAddress.fromCollectionId(collection.collectionId),280        returnValues: {281          owner: helper.address.substrateToEth(owner.address),282          spender: sender,283          value: '51',284        },285        event: 'Approval',286      },287    });288289    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});290    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);291  });292293  itEth('Can perform transferFrom()', async ({helper}) => {294    const owner = await helper.eth.createAccountWithBalance(donor);295    const spender = await helper.eth.createAccountWithBalance(donor);296    const receiver = helper.eth.createAccount();297    const collection = await helper.ft.mintCollection(alice);298    await collection.mint(alice, 200n, {Ethereum: owner});299300    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);301    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);302303    await contract.methods.approve(spender, 100).send();304305    {306      const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: spender});307308      let event = result.events.Transfer;309      expect(event.address).to.be.equal(collectionAddress);310      expect(event.returnValues.from).to.be.equal(owner);311      expect(event.returnValues.to).to.be.equal(receiver);312      expect(event.returnValues.value).to.be.equal('49');313314      event = result.events.Approval;315      expect(event.address).to.be.equal(collectionAddress);316      expect(event.returnValues.owner).to.be.equal(owner);317      expect(event.returnValues.spender).to.be.equal(spender);318      expect(event.returnValues.value).to.be.equal('51');319    }320321    {322      const balance = await contract.methods.balanceOf(receiver).call();323      expect(+balance).to.equal(49);324    }325326    {327      const balance = await contract.methods.balanceOf(owner).call();328      expect(+balance).to.equal(151);329    }330  });331332  itEth('Can perform transferCross()', async ({helper}) => {333    const sender = await helper.eth.createAccountWithBalance(donor);334    const receiverEth = await helper.eth.createAccountWithBalance(donor);335    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);336    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(donor);337    const collection = await helper.ft.mintCollection(alice);338    await collection.mint(alice, 200n, {Ethereum: sender});339340    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);341    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);342343    {344      // Can transferCross to ethereum address:345      const result = await collectionEvm.methods.transferCross(receiverCrossEth, 50).send({from: sender});346      // Check events:347      const event = result.events.Transfer;348      expect(event.address).to.be.equal(collectionAddress);349      expect(event.returnValues.from).to.be.equal(sender);350      expect(event.returnValues.to).to.be.equal(receiverEth);351      expect(event.returnValues.value).to.be.equal('50');352      // Sender's balance decreased:353      const ownerBalance = await collectionEvm.methods.balanceOf(sender).call();354      expect(+ownerBalance).to.equal(150);355      // Receiver's balance increased:356      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();357      expect(+receiverBalance).to.equal(50);358    }359360    {361      // Can transferCross to substrate address:362      const result = await collectionEvm.methods.transferCross(receiverCrossSub, 50).send({from: sender});363      // Check events:364      const event = result.events.Transfer;365      expect(event.address).to.be.equal(collectionAddress);366      expect(event.returnValues.from).to.be.equal(sender);367      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(donor.address));368      expect(event.returnValues.value).to.be.equal('50');369      // Sender's balance decreased:370      const senderBalance = await collection.getBalance({Ethereum: sender});371      expect(senderBalance).to.equal(100n);372      // Receiver's balance increased:373      const balance = await collection.getBalance({Substrate: donor.address});374      expect(balance).to.equal(50n);375    }376  });377378  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} incorrect amount`, async ({helper}) => {379    const sender = await helper.eth.createAccountWithBalance(donor);380    const receiverEth = await helper.eth.createAccountWithBalance(donor);381    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);382    const BALANCE = 200n;383    const BALANCE_TO_TRANSFER = BALANCE + 100n;384385    const collection = await helper.ft.mintCollection(alice);386    await collection.mint(alice, BALANCE, {Ethereum: sender});387    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);388    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);389390    // 1. Cannot transfer more than have391    const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth;392    await expect(collectionEvm.methods[testCase](receiver, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;393    // 2. Zero transfer allowed (EIP-20):394    await collectionEvm.methods[testCase](receiver, 0n).send({from: sender});395  }));396397398  itEth('Can perform transfer()', async ({helper}) => {399    const owner = await helper.eth.createAccountWithBalance(donor);400    const receiver = await helper.eth.createAccountWithBalance(donor);401    const collection = await helper.ft.mintCollection(alice);402    await collection.mint(alice, 200n, {Ethereum: owner});403404    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);405    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);406407    {408      const result = await contract.methods.transfer(receiver, 50).send({from: owner});409410      const event = result.events.Transfer;411      expect(event.address).to.be.equal(collectionAddress);412      expect(event.returnValues.from).to.be.equal(owner);413      expect(event.returnValues.to).to.be.equal(receiver);414      expect(event.returnValues.value).to.be.equal('50');415    }416417    {418      const balance = await contract.methods.balanceOf(owner).call();419      expect(+balance).to.equal(150);420    }421422    {423      const balance = await contract.methods.balanceOf(receiver).call();424      expect(+balance).to.equal(50);425    }426  });427428  itEth('Can perform transferFromCross()', async ({helper}) => {429    const sender = await helper.eth.createAccountWithBalance(donor, 100n);430431    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);432433    const receiver = helper.eth.createAccount();434435    await collection.mint(owner, 200n, {Substrate: owner.address});436    await collection.approveTokens(owner, {Ethereum: sender}, 100n);437438    const address = helper.ethAddress.fromCollectionId(collection.collectionId);439    const contract = await helper.ethNativeContract.collection(address, 'ft');440441    const from = helper.ethCrossAccount.fromKeyringPair(owner);442    const to = helper.ethCrossAccount.fromAddress(receiver);443444    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});445    const toBalanceBefore = await collection.getBalance({Ethereum: receiver});446447    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});448449    expect(result.events).to.be.like({450      Transfer: {451        address,452        event: 'Transfer',453        returnValues: {454          from: helper.address.substrateToEth(owner.address),455          to: receiver,456          value: '51',457        },458      },459      Approval: {460        address,461        event: 'Approval',462        returnValues: {463          owner: helper.address.substrateToEth(owner.address),464          spender: sender,465          value: '49',466        },467      }});468469    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});470    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);471    const toBalanceAfter = await collection.getBalance({Ethereum: receiver});472    expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);473  });474});475476describe('Fungible: Fees', () => {477  let donor: IKeyringPair;478  let alice: IKeyringPair;479480  before(async function() {481    await usingEthPlaygrounds(async (helper, privateKey) => {482      donor = await privateKey({filename: __filename});483      [alice] = await helper.arrange.createAccounts([20n], donor);484    });485  });486487  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {488    const owner = await helper.eth.createAccountWithBalance(donor);489    const spender = helper.eth.createAccount();490    const collection = await helper.ft.mintCollection(alice);491    await collection.mint(alice, 200n, {Ethereum: owner});492493    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);494    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);495496    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));497    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));498  });499500  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {501    const owner = await helper.eth.createAccountWithBalance(donor);502    const spender = await helper.eth.createAccountWithBalance(donor);503    const collection = await helper.ft.mintCollection(alice);504    await collection.mint(alice, 200n, {Ethereum: owner});505506    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);507    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);508509    await contract.methods.approve(spender, 100).send({from: owner});510511    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, 100).send({from: spender}));512    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));513  });514515  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {516    const owner = await helper.eth.createAccountWithBalance(donor);517    const receiver = helper.eth.createAccount();518    const collection = await helper.ft.mintCollection(alice);519    await collection.mint(alice, 200n, {Ethereum: owner});520521    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);522    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);523524    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));525    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));526  });527});528529describe('Fungible: Substrate calls', () => {530  let donor: IKeyringPair;531  let alice: IKeyringPair;532  let owner: IKeyringPair;533534  before(async function() {535    await usingEthPlaygrounds(async (helper, privateKey) => {536      donor = await privateKey({filename: __filename});537      [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);538    });539  });540541  itEth('Events emitted for approve()', async ({helper}) => {542    const receiver = helper.eth.createAccount();543    const collection = await helper.ft.mintCollection(alice);544    await collection.mint(alice, 200n);545546    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);547    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');548549    const events: any = [];550    contract.events.allEvents((_: any, event: any) => {551      events.push(event);552    });553554    await collection.approveTokens(alice, {Ethereum: receiver}, 100n);555    if (events.length == 0) await helper.wait.newBlocks(1);556    const event = events[0];557558    expect(event.event).to.be.equal('Approval');559    expect(event.address).to.be.equal(collectionAddress);560    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));561    expect(event.returnValues.spender).to.be.equal(receiver);562    expect(event.returnValues.value).to.be.equal('100');563  });564565  itEth('Events emitted for transferFrom()', async ({helper}) => {566    const [bob] = await helper.arrange.createAccounts([10n], donor);567    const receiver = helper.eth.createAccount();568    const collection = await helper.ft.mintCollection(alice);569    await collection.mint(alice, 200n);570    await collection.approveTokens(alice, {Substrate: bob.address}, 100n);571572    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);573    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');574575    const events: any = [];576    contract.events.allEvents((_: any, event: any) => {577      events.push(event);578    });579580    await collection.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver}, 51n);581    if (events.length == 0) await helper.wait.newBlocks(1);582    let event = events[0];583584    expect(event.event).to.be.equal('Transfer');585    expect(event.address).to.be.equal(collectionAddress);586    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));587    expect(event.returnValues.to).to.be.equal(receiver);588    expect(event.returnValues.value).to.be.equal('51');589590    event = events[1];591    expect(event.event).to.be.equal('Approval');592    expect(event.address).to.be.equal(collectionAddress);593    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));594    expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(bob.address));595    expect(event.returnValues.value).to.be.equal('49');596  });597598  itEth('Events emitted for transfer()', async ({helper}) => {599    const receiver = helper.eth.createAccount();600    const collection = await helper.ft.mintCollection(alice);601    await collection.mint(alice, 200n);602603    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);604    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');605606    const events: any = [];607    contract.events.allEvents((_: any, event: any) => {608      events.push(event);609    });610611    await collection.transfer(alice, {Ethereum:receiver}, 51n);612    if (events.length == 0) await helper.wait.newBlocks(1);613    const event = events[0];614615    expect(event.event).to.be.equal('Transfer');616    expect(event.address).to.be.equal(collectionAddress);617    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));618    expect(event.returnValues.to).to.be.equal(receiver);619    expect(event.returnValues.value).to.be.equal('51');620  });621622  itEth('Events emitted for transferFromCross()', async ({helper}) => {623    const sender = await helper.eth.createAccountWithBalance(donor, 100n);624625    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);626627    const receiver = helper.eth.createAccount();628629    await collection.mint(owner, 200n, {Substrate: owner.address});630    await collection.approveTokens(owner, {Ethereum: sender}, 100n);631632    const address = helper.ethAddress.fromCollectionId(collection.collectionId);633    const contract = await helper.ethNativeContract.collection(address, 'ft');634635    const from = helper.ethCrossAccount.fromKeyringPair(owner);636    const to = helper.ethCrossAccount.fromAddress(receiver);637638    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});639640    expect(result.events).to.be.like({641      Transfer: {642        address,643        event: 'Transfer',644        returnValues: {645          from: helper.address.substrateToEth(owner.address),646          to: receiver,647          value: '51',648        },649      },650      Approval: {651        address,652        event: 'Approval',653        returnValues: {654          owner: helper.address.substrateToEth(owner.address),655          spender: sender,656          value: '49',657        },658      }});659  });660});
after · tests/src/eth/fungible.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 {expect, itEth, usingEthPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';1920describe('Fungible: Plain calls', () => {21  let donor: IKeyringPair;22  let alice: IKeyringPair;23  let owner: IKeyringPair;2425  before(async function() {26    await usingEthPlaygrounds(async (helper, privateKey) => {27      donor = await privateKey({filename: __filename});28      [alice, owner] = await helper.arrange.createAccounts([30n, 20n], donor);29    });30  });3132  [33    'substrate' as const,34    'ethereum' as const,35  ].map(testCase => {36    itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {37      // 1. Create receiver depending on the test case:38      const receiverEth = helper.eth.createAccount();39      const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);40      const receiverSub = owner;41      const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(owner);4243      const ethOwner = await helper.eth.createAccountWithBalance(donor);44      const collection = await helper.ft.mintCollection(alice);45      await collection.addAdmin(alice, {Ethereum: ethOwner});4647      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);48      const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', ethOwner);4950      // 2. Mint tokens:51      const result = await collectionEvm.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, 100).send();5253      const event = result.events.Transfer;54      expect(event.address).to.equal(collectionAddress);55      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');56      expect(event.returnValues.to).to.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(receiverSub.address));57      expect(event.returnValues.value).to.equal('100');5859      // 3. Get balance depending on the test case:60      let balance;61      if (testCase === 'ethereum') balance = await collection.getBalance({Ethereum: receiverEth});62      else if (testCase === 'substrate') balance = await collection.getBalance({Substrate: receiverSub.address});63      // 3.1 Check balance:64      expect(balance).to.eq(100n);65    });66  });6768  itEth('Can perform mintBulk()', async ({helper}) => {69    const owner = await helper.eth.createAccountWithBalance(donor);70    const bulkSize = 3;71    const receivers = [...new Array(bulkSize)].map(() => helper.eth.createAccount());72    const collection = await helper.ft.mintCollection(alice);73    await collection.addAdmin(alice, {Ethereum: owner});7475    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);76    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);7778    const result = await contract.methods.mintBulk(Array.from({length: bulkSize}, (_, i) => (79      [receivers[i], (i + 1) * 10]80    ))).send();81    const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.value - b.returnValues.value);82    for (let i = 0; i < bulkSize; i++) {83      const event = events[i];84      expect(event.address).to.equal(collectionAddress);85      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');86      expect(event.returnValues.to).to.equal(receivers[i]);87      expect(event.returnValues.value).to.equal(String(10 * (i + 1)));88    }89  });9091  // Soft-deprecated92  itEth('Can perform burn()', async ({helper}) => {93    const owner = await helper.eth.createAccountWithBalance(donor);94    const receiver = await helper.eth.createAccountWithBalance(donor);95    const collection = await helper.ft.mintCollection(alice);96    await collection.addAdmin(alice, {Ethereum: owner});9798    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);99    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);100    await contract.methods.mint(receiver, 100).send();101102    const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});103104    const event = result.events.Transfer;105    expect(event.address).to.equal(collectionAddress);106    expect(event.returnValues.from).to.equal(receiver);107    expect(event.returnValues.to).to.equal('0x0000000000000000000000000000000000000000');108    expect(event.returnValues.value).to.equal('49');109110    const balance = await contract.methods.balanceOf(receiver).call();111    expect(balance).to.equal('51');112  });113114  itEth('Can perform approve()', async ({helper}) => {115    const owner = await helper.eth.createAccountWithBalance(donor);116    const spender = helper.eth.createAccount();117    const collection = await helper.ft.mintCollection(alice);118    await collection.mint(alice, 200n, {Ethereum: owner});119120    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);121    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);122123    {124      const result = await contract.methods.approve(spender, 100).send({from: owner});125126      const event = result.events.Approval;127      expect(event.address).to.be.equal(collectionAddress);128      expect(event.returnValues.owner).to.be.equal(owner);129      expect(event.returnValues.spender).to.be.equal(spender);130      expect(event.returnValues.value).to.be.equal('100');131    }132133    {134      const allowance = await contract.methods.allowance(owner, spender).call();135      expect(+allowance).to.equal(100);136    }137  });138139  itEth('Can perform approveCross()', async ({helper}) => {140    const owner = await helper.eth.createAccountWithBalance(donor);141    const spender = helper.eth.createAccount();142    const spenderSub = (await helper.arrange.createAccounts([1n], donor))[0];143    const spenderCrossEth = helper.ethCrossAccount.fromAddress(spender);144    const spenderCrossSub = helper.ethCrossAccount.fromKeyringPair(spenderSub);145146147    const collection = await helper.ft.mintCollection(alice);148    await collection.mint(alice, 200n, {Ethereum: owner});149150    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);151    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);152153    {154      const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});155      const event = result.events.Approval;156      expect(event.address).to.be.equal(collectionAddress);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    }166167168    {169      const result = await contract.methods.approveCross(spenderCrossSub, 100).send({from: owner});170      const event = result.events.Approval;171      expect(event.address).to.be.equal(collectionAddress);172      expect(event.returnValues.owner).to.be.equal(owner);173      expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(spenderSub.address));174      expect(event.returnValues.value).to.be.equal('100');175    }176177    {178      const allowance = await collection.getApprovedTokens({Ethereum: owner}, {Substrate: spenderSub.address});179      expect(allowance).to.equal(100n);180    }181182    {183      //TO-DO expect with future allowanceCross(owner, spenderCrossEth).call()184    }185  });186187  itEth('Non-owner and non admin cannot approveCross', async ({helper}) => {188    const nonOwner = await helper.eth.createAccountWithBalance(donor);189    const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);190    const owner = await helper.eth.createAccountWithBalance(donor);191    const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});192    await collection.mint(alice, 100n, {Ethereum: owner});193194    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);195    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);196197    await expect(collectionEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');198  });199200201  itEth('Can perform burnFromCross()', async ({helper}) => {202    const sender = await helper.eth.createAccountWithBalance(donor, 100n);203204    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);205206    await collection.mint(owner, 200n, {Substrate: owner.address});207    await collection.approveTokens(owner, {Ethereum: sender}, 100n);208209    const address = helper.ethAddress.fromCollectionId(collection.collectionId);210    const contract = await helper.ethNativeContract.collection(address, 'ft');211212    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});213214    const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);215    const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});216    const events = result.events;217218    expect(events).to.be.like({219      Transfer: {220        address: helper.ethAddress.fromCollectionId(collection.collectionId),221        event: 'Transfer',222        returnValues: {223          from: helper.address.substrateToEth(owner.address),224          to: '0x0000000000000000000000000000000000000000',225          value: '49',226        },227      },228      Approval: {229        address: helper.ethAddress.fromCollectionId(collection.collectionId),230        returnValues: {231          owner: helper.address.substrateToEth(owner.address),232          spender: sender,233          value: '51',234        },235        event: 'Approval',236      },237    });238239    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});240    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);241  });242243  itEth('Can perform transferFrom()', async ({helper}) => {244    const owner = await helper.eth.createAccountWithBalance(donor);245    const spender = await helper.eth.createAccountWithBalance(donor);246    const receiver = helper.eth.createAccount();247    const collection = await helper.ft.mintCollection(alice);248    await collection.mint(alice, 200n, {Ethereum: owner});249250    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);251    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);252253    await contract.methods.approve(spender, 100).send();254255    {256      const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: spender});257258      let event = result.events.Transfer;259      expect(event.address).to.be.equal(collectionAddress);260      expect(event.returnValues.from).to.be.equal(owner);261      expect(event.returnValues.to).to.be.equal(receiver);262      expect(event.returnValues.value).to.be.equal('49');263264      event = result.events.Approval;265      expect(event.address).to.be.equal(collectionAddress);266      expect(event.returnValues.owner).to.be.equal(owner);267      expect(event.returnValues.spender).to.be.equal(spender);268      expect(event.returnValues.value).to.be.equal('51');269    }270271    {272      const balance = await contract.methods.balanceOf(receiver).call();273      expect(+balance).to.equal(49);274    }275276    {277      const balance = await contract.methods.balanceOf(owner).call();278      expect(+balance).to.equal(151);279    }280  });281282  itEth('Can perform transferCross()', async ({helper}) => {283    const sender = await helper.eth.createAccountWithBalance(donor);284    const receiverEth = await helper.eth.createAccountWithBalance(donor);285    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);286    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(donor);287    const collection = await helper.ft.mintCollection(alice);288    await collection.mint(alice, 200n, {Ethereum: sender});289290    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);291    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);292293    {294      // Can transferCross to ethereum address:295      const result = await collectionEvm.methods.transferCross(receiverCrossEth, 50).send({from: sender});296      // Check events:297      const event = result.events.Transfer;298      expect(event.address).to.be.equal(collectionAddress);299      expect(event.returnValues.from).to.be.equal(sender);300      expect(event.returnValues.to).to.be.equal(receiverEth);301      expect(event.returnValues.value).to.be.equal('50');302      // Sender's balance decreased:303      const ownerBalance = await collectionEvm.methods.balanceOf(sender).call();304      expect(+ownerBalance).to.equal(150);305      // Receiver's balance increased:306      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();307      expect(+receiverBalance).to.equal(50);308    }309310    {311      // Can transferCross to substrate address:312      const result = await collectionEvm.methods.transferCross(receiverCrossSub, 50).send({from: sender});313      // Check events:314      const event = result.events.Transfer;315      expect(event.address).to.be.equal(collectionAddress);316      expect(event.returnValues.from).to.be.equal(sender);317      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(donor.address));318      expect(event.returnValues.value).to.be.equal('50');319      // Sender's balance decreased:320      const senderBalance = await collection.getBalance({Ethereum: sender});321      expect(senderBalance).to.equal(100n);322      // Receiver's balance increased:323      const balance = await collection.getBalance({Substrate: donor.address});324      expect(balance).to.equal(50n);325    }326  });327328  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} incorrect amount`, async ({helper}) => {329    const sender = await helper.eth.createAccountWithBalance(donor);330    const receiverEth = await helper.eth.createAccountWithBalance(donor);331    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);332    const BALANCE = 200n;333    const BALANCE_TO_TRANSFER = BALANCE + 100n;334335    const collection = await helper.ft.mintCollection(alice);336    await collection.mint(alice, BALANCE, {Ethereum: sender});337    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);338    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);339340    // 1. Cannot transfer more than have341    const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth;342    await expect(collectionEvm.methods[testCase](receiver, BALANCE_TO_TRANSFER).send({from: sender})).to.be.rejected;343    // 2. Zero transfer allowed (EIP-20):344    await collectionEvm.methods[testCase](receiver, 0n).send({from: sender});345  }));346347348  itEth('Can perform transfer()', async ({helper}) => {349    const owner = await helper.eth.createAccountWithBalance(donor);350    const receiver = await helper.eth.createAccountWithBalance(donor);351    const collection = await helper.ft.mintCollection(alice);352    await collection.mint(alice, 200n, {Ethereum: owner});353354    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);355    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);356357    {358      const result = await contract.methods.transfer(receiver, 50).send({from: owner});359360      const event = result.events.Transfer;361      expect(event.address).to.be.equal(collectionAddress);362      expect(event.returnValues.from).to.be.equal(owner);363      expect(event.returnValues.to).to.be.equal(receiver);364      expect(event.returnValues.value).to.be.equal('50');365    }366367    {368      const balance = await contract.methods.balanceOf(owner).call();369      expect(+balance).to.equal(150);370    }371372    {373      const balance = await contract.methods.balanceOf(receiver).call();374      expect(+balance).to.equal(50);375    }376  });377378  itEth('Can perform transferFromCross()', async ({helper}) => {379    const sender = await helper.eth.createAccountWithBalance(donor, 100n);380381    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);382383    const receiver = helper.eth.createAccount();384385    await collection.mint(owner, 200n, {Substrate: owner.address});386    await collection.approveTokens(owner, {Ethereum: sender}, 100n);387388    const address = helper.ethAddress.fromCollectionId(collection.collectionId);389    const contract = await helper.ethNativeContract.collection(address, 'ft');390391    const from = helper.ethCrossAccount.fromKeyringPair(owner);392    const to = helper.ethCrossAccount.fromAddress(receiver);393394    const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});395    const toBalanceBefore = await collection.getBalance({Ethereum: receiver});396397    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});398399    expect(result.events).to.be.like({400      Transfer: {401        address,402        event: 'Transfer',403        returnValues: {404          from: helper.address.substrateToEth(owner.address),405          to: receiver,406          value: '51',407        },408      },409      Approval: {410        address,411        event: 'Approval',412        returnValues: {413          owner: helper.address.substrateToEth(owner.address),414          spender: sender,415          value: '49',416        },417      }});418419    const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});420    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);421    const toBalanceAfter = await collection.getBalance({Ethereum: receiver});422    expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);423  });424});425426describe('Fungible: Fees', () => {427  let donor: IKeyringPair;428  let alice: IKeyringPair;429430  before(async function() {431    await usingEthPlaygrounds(async (helper, privateKey) => {432      donor = await privateKey({filename: __filename});433      [alice] = await helper.arrange.createAccounts([20n], donor);434    });435  });436437  itEth('approve() call fee is less than 0.2UNQ', async ({helper}) => {438    const owner = await helper.eth.createAccountWithBalance(donor);439    const spender = helper.eth.createAccount();440    const collection = await helper.ft.mintCollection(alice);441    await collection.mint(alice, 200n, {Ethereum: owner});442443    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);444    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);445446    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));447    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));448  });449450  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {451    const owner = await helper.eth.createAccountWithBalance(donor);452    const spender = await helper.eth.createAccountWithBalance(donor);453    const collection = await helper.ft.mintCollection(alice);454    await collection.mint(alice, 200n, {Ethereum: owner});455456    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);457    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);458459    await contract.methods.approve(spender, 100).send({from: owner});460461    const cost = await helper.eth.recordCallFee(spender, () => contract.methods.transferFrom(owner, spender, 100).send({from: spender}));462    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));463  });464465  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {466    const owner = await helper.eth.createAccountWithBalance(donor);467    const receiver = helper.eth.createAccount();468    const collection = await helper.ft.mintCollection(alice);469    await collection.mint(alice, 200n, {Ethereum: owner});470471    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);472    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);473474    const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));475    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));476  });477});478479describe('Fungible: Substrate calls', () => {480  let donor: IKeyringPair;481  let alice: IKeyringPair;482  let owner: IKeyringPair;483484  before(async function() {485    await usingEthPlaygrounds(async (helper, privateKey) => {486      donor = await privateKey({filename: __filename});487      [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);488    });489  });490491  itEth('Events emitted for approve()', async ({helper}) => {492    const receiver = helper.eth.createAccount();493    const collection = await helper.ft.mintCollection(alice);494    await collection.mint(alice, 200n);495496    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);497    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');498499    const events: any = [];500    contract.events.allEvents((_: any, event: any) => {501      events.push(event);502    });503504    await collection.approveTokens(alice, {Ethereum: receiver}, 100n);505    if (events.length == 0) await helper.wait.newBlocks(1);506    const event = events[0];507508    expect(event.event).to.be.equal('Approval');509    expect(event.address).to.be.equal(collectionAddress);510    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));511    expect(event.returnValues.spender).to.be.equal(receiver);512    expect(event.returnValues.value).to.be.equal('100');513  });514515  itEth('Events emitted for transferFrom()', async ({helper}) => {516    const [bob] = await helper.arrange.createAccounts([10n], donor);517    const receiver = helper.eth.createAccount();518    const collection = await helper.ft.mintCollection(alice);519    await collection.mint(alice, 200n);520    await collection.approveTokens(alice, {Substrate: bob.address}, 100n);521522    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);523    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');524525    const events: any = [];526    contract.events.allEvents((_: any, event: any) => {527      events.push(event);528    });529530    await collection.transferFrom(bob, {Substrate: alice.address}, {Ethereum: receiver}, 51n);531    if (events.length == 0) await helper.wait.newBlocks(1);532    let event = events[0];533534    expect(event.event).to.be.equal('Transfer');535    expect(event.address).to.be.equal(collectionAddress);536    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));537    expect(event.returnValues.to).to.be.equal(receiver);538    expect(event.returnValues.value).to.be.equal('51');539540    event = events[1];541    expect(event.event).to.be.equal('Approval');542    expect(event.address).to.be.equal(collectionAddress);543    expect(event.returnValues.owner).to.be.equal(helper.address.substrateToEth(alice.address));544    expect(event.returnValues.spender).to.be.equal(helper.address.substrateToEth(bob.address));545    expect(event.returnValues.value).to.be.equal('49');546  });547548  itEth('Events emitted for transfer()', async ({helper}) => {549    const receiver = helper.eth.createAccount();550    const collection = await helper.ft.mintCollection(alice);551    await collection.mint(alice, 200n);552553    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);554    const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');555556    const events: any = [];557    contract.events.allEvents((_: any, event: any) => {558      events.push(event);559    });560561    await collection.transfer(alice, {Ethereum:receiver}, 51n);562    if (events.length == 0) await helper.wait.newBlocks(1);563    const event = events[0];564565    expect(event.event).to.be.equal('Transfer');566    expect(event.address).to.be.equal(collectionAddress);567    expect(event.returnValues.from).to.be.equal(helper.address.substrateToEth(alice.address));568    expect(event.returnValues.to).to.be.equal(receiver);569    expect(event.returnValues.value).to.be.equal('51');570  });571572  itEth('Events emitted for transferFromCross()', async ({helper}) => {573    const sender = await helper.eth.createAccountWithBalance(donor, 100n);574575    const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);576577    const receiver = helper.eth.createAccount();578579    await collection.mint(owner, 200n, {Substrate: owner.address});580    await collection.approveTokens(owner, {Ethereum: sender}, 100n);581582    const address = helper.ethAddress.fromCollectionId(collection.collectionId);583    const contract = await helper.ethNativeContract.collection(address, 'ft');584585    const from = helper.ethCrossAccount.fromKeyringPair(owner);586    const to = helper.ethCrossAccount.fromAddress(receiver);587588    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});589590    expect(result.events).to.be.like({591      Transfer: {592        address,593        event: 'Transfer',594        returnValues: {595          from: helper.address.substrateToEth(owner.address),596          to: receiver,597          value: '51',598        },599      },600      Approval: {601        address,602        event: 'Approval',603        returnValues: {604          owner: helper.address.substrateToEth(owner.address),605          spender: sender,606          value: '49',607        },608      }});609  });610});
addedtests/src/eth/getCode.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/getCode.test.ts
@@ -0,0 +1,53 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {expect, itEth, usingEthPlaygrounds} from './util';
+import {IKeyringPair} from '@polkadot/types/types';
+import {COLLECTION_HELPER, CONTRACT_HELPER} from '../util';
+
+describe('RPC eth_getCode', () => {
+  let donor: IKeyringPair;
+
+  before(async function() {
+    await usingEthPlaygrounds(async (helper, privateKey) => {
+      donor = await privateKey({filename: __filename});
+    });
+  });
+
+  [
+    {address: COLLECTION_HELPER},
+    {address: CONTRACT_HELPER},
+  ].map(testCase => {
+    itEth(`returns value for native contract: ${testCase.address}`, async ({helper}) => {
+      const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [testCase.address])).toJSON();
+      const contractCodeEth = (await helper.getWeb3().eth.getCode(testCase.address));
+
+      expect(contractCodeSub).to.has.length.greaterThan(4);
+      expect(contractCodeEth).to.has.length.greaterThan(4);
+    });
+  });
+
+  itEth('returns value for custom contract', async ({helper}) => {
+    const signer = await helper.eth.createAccountWithBalance(donor);
+    const flipper = await helper.eth.deployFlipper(signer);
+
+    const contractCodeSub = (await helper.callRpc('api.rpc.eth.getCode', [flipper.options.address])).toJSON();
+    const contractCodeEth = (await helper.getWeb3().eth.getCode(flipper.options.address));
+
+    expect(contractCodeSub).to.has.length.greaterThan(4);
+    expect(contractCodeEth).to.has.length.greaterThan(4);
+  });
+});
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -19,68 +19,6 @@
 import {Contract} from 'web3-eth-contract';
 import {ITokenPropertyPermission} from '../util/playgrounds/types';
 
-
-describe('NFT: Information getting', () => {
-  let donor: IKeyringPair;
-  let alice: IKeyringPair;
-
-  before(async function() {
-    await usingEthPlaygrounds(async (helper, privateKey) => {
-      donor = await privateKey({filename: __filename});
-      [alice] = await helper.arrange.createAccounts([10n], donor);
-    });
-  });
-
-  itEth('totalSupply', async ({helper}) => {
-    const collection = await helper.nft.mintCollection(alice, {});
-    await collection.mintToken(alice);
-
-    const caller = await helper.eth.createAccountWithBalance(donor);
-
-    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
-    const totalSupply = await contract.methods.totalSupply().call();
-
-    expect(totalSupply).to.equal('1');
-  });
-
-  itEth('balanceOf', async ({helper}) => {
-    const collection = await helper.nft.mintCollection(alice, {});
-    const caller = await helper.eth.createAccountWithBalance(donor);
-
-    await collection.mintToken(alice, {Ethereum: caller});
-    await collection.mintToken(alice, {Ethereum: caller});
-    await collection.mintToken(alice, {Ethereum: caller});
-
-    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
-    const balance = await contract.methods.balanceOf(caller).call();
-
-    expect(balance).to.equal('3');
-  });
-
-  itEth('ownerOf', async ({helper}) => {
-    const collection = await helper.nft.mintCollection(alice, {});
-    const caller = await helper.eth.createAccountWithBalance(donor);
-
-    const token = await collection.mintToken(alice, {Ethereum: caller});
-
-    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
-
-    const owner = await contract.methods.ownerOf(token.tokenId).call();
-
-    expect(owner).to.equal(caller);
-  });
-
-  itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {
-    const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});
-    const caller = helper.eth.createAccount();
-
-    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
-
-    expect(await contract.methods.name().call()).to.equal('test');
-    expect(await contract.methods.symbol().call()).to.equal('TEST');
-  });
-});
-
 describe('Check ERC721 token URI for NFT', () => {
   let donor: IKeyringPair;
 
@@ -148,30 +86,6 @@
       donor = await privateKey({filename: __filename});
       [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
     });
-  });
-
-  itEth('Can perform mint() & get crossOwner()', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const receiver = helper.eth.createAccount();
-
-    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-
-    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
-    const tokenId = result.events.Transfer.returnValues.tokenId;
-    expect(tokenId).to.be.equal('1');
-
-    const event = result.events.Transfer;
-    expect(event.address).to.be.equal(collectionAddress);
-    expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
-    expect(event.returnValues.to).to.be.equal(receiver);
-
-    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
-    expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
-    // TODO: this wont work right now, need release 919000 first
-    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
-    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
-    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
   });
 
   // TODO combine all minting tests in one place
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -19,90 +19,6 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {ITokenPropertyPermission} from '../util/playgrounds/types';
 
-describe('Refungible: Information getting', () => {
-  let donor: IKeyringPair;
-
-  before(async function() {
-    await usingEthPlaygrounds(async (helper, privateKey) => {
-      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
-
-      donor = await privateKey({filename: __filename});
-    });
-  });
-
-  itEth('totalSupply', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-
-    await contract.methods.mint(caller).send();
-
-    const totalSupply = await contract.methods.totalSupply().call();
-    expect(totalSupply).to.equal('1');
-  });
-
-  itEth('balanceOf', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-
-    await contract.methods.mint(caller).send();
-    await contract.methods.mint(caller).send();
-    await contract.methods.mint(caller).send();
-
-    const balance = await contract.methods.balanceOf(caller).call();
-    expect(balance).to.equal('3');
-  });
-
-  itEth('ownerOf', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-
-    const result = await contract.methods.mint(caller).send();
-    const tokenId = result.events.Transfer.returnValues.tokenId;
-
-    const owner = await contract.methods.ownerOf(tokenId).call();
-    expect(owner).to.equal(caller);
-  });
-
-  itEth('ownerOf after burn', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-
-    const result = await contract.methods.mint(caller).send();
-    const tokenId = result.events.Transfer.returnValues.tokenId;
-    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller, true);
-
-    await tokenContract.methods.repartition(2).send();
-    await tokenContract.methods.transfer(receiver, 1).send();
-
-    await tokenContract.methods.burnFrom(caller, 1).send();
-
-    const owner = await contract.methods.ownerOf(tokenId).call();
-    expect(owner).to.equal(receiver);
-  });
-
-  itEth('ownerOf for partial ownership', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const receiver = helper.eth.createAccount();
-    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
-
-    const result = await contract.methods.mint(caller).send();
-    const tokenId = result.events.Transfer.returnValues.tokenId;
-    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
-
-    await tokenContract.methods.repartition(2).send();
-    await tokenContract.methods.transfer(receiver, 1).send();
-
-    const owner = await contract.methods.ownerOf(tokenId).call();
-    expect(owner).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
-  });
-});
-
 describe('Refungible: Plain calls', () => {
   let donor: IKeyringPair;
   let minter: IKeyringPair;
@@ -116,25 +32,6 @@
       donor = await privateKey({filename: __filename});
       [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
     });
-  });
-
-  itEth('Can perform mint() & crossOwnerOf()', async ({helper}) => {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const receiver = helper.eth.createAccount();
-    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');
-    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-
-    const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
-
-    const event = result.events.Transfer;
-    expect(event.address).to.equal(collectionAddress);
-    expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
-    expect(event.returnValues.to).to.equal(receiver);
-    const tokenId = event.returnValues.tokenId;
-    expect(tokenId).to.be.equal('1');
-
-    expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
-    expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
   });
 
   [
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -19,51 +19,6 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {Contract} from 'web3-eth-contract';
 
-
-describe('Refungible token: Information getting', () => {
-  let donor: IKeyringPair;
-  let alice: IKeyringPair;
-
-  before(async function() {
-    await usingEthPlaygrounds(async (helper, privateKey) => {
-      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
-
-      donor = await privateKey({filename: __filename});
-      [alice] = await helper.arrange.createAccounts([20n], donor);
-    });
-  });
-
-  itEth('totalSupply', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});
-    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});
-
-    const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);
-    const totalSupply = await contract.methods.totalSupply().call();
-    expect(totalSupply).to.equal('200');
-  });
-
-  itEth('balanceOf', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});
-    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});
-
-    const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);
-    const balance = await contract.methods.balanceOf(caller).call();
-    expect(balance).to.equal('200');
-  });
-
-  itEth('decimals', async ({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});
-    const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});
-
-    const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);
-    const decimals = await contract.methods.decimals().call();
-    expect(decimals).to.equal('0');
-  });
-});
-
 // FIXME: Need erc721 for ReFubgible.
 describe('Check ERC721 token URI for ReFungible', () => {
   let donor: IKeyringPair;
addedtests/src/eth/tokens/callMethodsERC20.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/tokens/callMethodsERC20.test.ts
@@ -0,0 +1,91 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {Pallets, requirePalletsOrSkip} from '../../util';
+import {expect, itEth, usingEthPlaygrounds} from '../util';
+import {IKeyringPair} from '@polkadot/types/types';
+
+[
+  {mode: 'ft' as const, requiredPallets: []},
+  {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+].map(testCase => {
+  describe(`${testCase.mode.toUpperCase()}: ERC-20 call methods`, () => {
+    let donor: IKeyringPair;
+
+    before(async function() {
+      await usingEthPlaygrounds(async (helper, privateKey) => {
+        requirePalletsOrSkip(this, helper, testCase.requiredPallets);
+        donor = await privateKey({filename: __filename});
+      });
+    });
+
+    itEth('totalSupply', async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+      const mintingParams = testCase.mode === 'ft' ? [caller, 200n] : [caller];
+
+      const {collection, collectionId} = await helper.eth.createCollection(testCase.mode, caller, 'TotalSupply', '6', '6');
+      if (testCase.mode === 'rft') await collection.methods.mint(caller).send({from: caller});
+
+      // Use collection contract for FT or token contract for RFT:
+      const contract = testCase.mode === 'ft'
+        ? collection
+        : await helper.ethNativeContract.rftTokenById(collectionId, 1, caller);
+
+      // Mint tokens:
+      testCase.mode === 'ft'
+        ? await contract.methods.mint(...mintingParams).send({from: caller})
+        : await contract.methods.repartition(200).send({from: caller});
+
+      const totalSupply = await contract.methods.totalSupply().call();
+      expect(totalSupply).to.equal('200');
+    });
+
+    itEth('balanceOf', async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+      const mintingParams = testCase.mode === 'ft' ? [caller, 200n] : [caller];
+
+      const {collection, collectionId} = await helper.eth.createCollection(testCase.mode, caller, 'BalanceOf', 'Descroption', 'Prefix');
+      if (testCase.mode === 'rft') await collection.methods.mint(caller).send({from: caller});
+
+      // Use collection contract for FT or token contract for RFT:
+      const contract = testCase.mode === 'ft'
+        ? collection
+        : await helper.ethNativeContract.rftTokenById(collectionId, 1, caller);
+
+      // Mint tokens:
+      testCase.mode === 'ft'
+        ? await contract.methods.mint(...mintingParams).send({from: caller})
+        : await contract.methods.repartition(200).send({from: caller});
+
+      const balance = await contract.methods.balanceOf(caller).call();
+      expect(balance).to.equal('200');
+    });
+
+    itEth('decimals', async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+      const {collection, collectionId} = await helper.eth.createCollection(testCase.mode, caller, 'BalanceOf', 'Descroption', 'Prefix');
+      if (testCase.mode === 'rft') await collection.methods.mint(caller).send({from: caller});
+
+      // Use collection contract for FT or token contract for RFT:
+      const contract = testCase.mode === 'ft'
+        ? collection
+        : await helper.ethNativeContract.rftTokenById(collectionId, 1, caller);
+
+      const decimals = await contract.methods.decimals().call();
+      expect(decimals).to.equal(testCase.mode === 'rft' ? '0' : '18');
+    });
+  });
+});
\ No newline at end of file
addedtests/src/eth/tokens/callMethodsERC721.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/tokens/callMethodsERC721.test.ts
@@ -0,0 +1,143 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {Pallets} from '../../util';
+import {expect, itEth, usingEthPlaygrounds} from '../util';
+import {IKeyringPair} from '@polkadot/types/types';
+
+
+describe('ERC-721 call methods', () => {
+  let donor: IKeyringPair;
+
+  before(async function() {
+    await usingEthPlaygrounds(async (helper, privateKey) => {
+      donor = await privateKey({filename: __filename});
+    });
+  });
+
+  [
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'nft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: name/symbol/description`, testCase.requiredPallets, async ({helper}) => {
+      const callerEth = await helper.eth.createAccountWithBalance(donor);
+      const [callerSub] = await helper.arrange.createAccounts([100n], donor);
+      const [name, description, tokenPrefix] = ['Name', 'Description', 'Symbol'];
+
+      const {collection: collectionEth} = await helper.eth.createCollection(testCase.mode, callerEth, name, description, tokenPrefix);
+      await collectionEth.methods.mint(callerEth).send({from: callerEth});
+      const {collectionId} = await helper[testCase.mode].mintCollection(callerSub, {name, description, tokenPrefix});
+      const collectionSub = await helper.ethNativeContract.collectionById(collectionId, testCase.mode, callerEth);
+
+      // Can get name/symbol/description for Eth collection
+      expect(await collectionEth.methods.name().call()).to.eq(name);
+      expect(await collectionEth.methods.symbol().call()).to.eq(tokenPrefix);
+      expect(await collectionEth.methods.description().call()).to.eq(description);
+      // Can get name/symbol/description for Sub collection
+      expect(await collectionSub.methods.name().call()).to.eq(name);
+      expect(await collectionSub.methods.symbol().call()).to.eq(tokenPrefix);
+      expect(await collectionSub.methods.description().call()).to.eq(description);
+    });
+  });
+
+  [
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'nft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: totalSupply`, testCase.requiredPallets, async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+
+      const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'TotalSupply', '6', '6');
+      await collection.methods.mint(caller).send({from: caller});
+
+      const totalSupply = await collection.methods.totalSupply().call();
+      expect(totalSupply).to.equal('1');
+    });
+  });
+
+  [
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'nft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: balanceOf`, testCase.requiredPallets, async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+
+      const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'BalanceOf', 'Descroption', 'Prefix');
+      await collection.methods.mint(caller).send({from: caller});
+      await collection.methods.mint(caller).send({from: caller});
+      await collection.methods.mint(caller).send({from: caller});
+
+      const balance = await collection.methods.balanceOf(caller).call();
+      expect(balance).to.equal('3');
+    });
+  });
+
+  [
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'nft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: ownerOf`, testCase.requiredPallets, async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+      const {collection} = await helper.eth.createCollection(testCase.mode, caller, 'OwnerOf', '6', '6');
+
+      const result = await collection.methods.mint(caller).send();
+      const tokenId = result.events.Transfer.returnValues.tokenId;
+
+      const owner = await collection.methods.ownerOf(tokenId).call();
+      expect(owner).to.equal(caller);
+    });
+  });
+
+  [
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    // TODO {mode: 'nft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: ownerOf after burn`, testCase.requiredPallets, async ({helper}) => {
+      const caller = await helper.eth.createAccountWithBalance(donor);
+      const receiver = helper.eth.createAccount();
+      const {collection, collectionId} = await helper.eth.createCollection(testCase.mode, caller, 'OwnerOf-AfterBurn', '6', '6');
+
+      const result = await collection.methods.mint(caller).send();
+      const tokenId = result.events.Transfer.returnValues.tokenId;
+      const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller, true);
+
+      await tokenContract.methods.repartition(2).send();
+      await tokenContract.methods.transfer(receiver, 1).send();
+
+      await tokenContract.methods.burnFrom(caller, 1).send();
+
+      const owner = await collection.methods.ownerOf(tokenId).call();
+      expect(owner).to.equal(receiver);
+    });
+  });
+
+  itEth.ifWithPallets('RFT: ownerOf for partial ownership', [Pallets.ReFungible], async ({helper}) => {
+    const caller = await helper.eth.createAccountWithBalance(donor);
+    const receiver = helper.eth.createAccount();
+    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');
+    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
+
+    const result = await contract.methods.mint(caller).send();
+    const tokenId = result.events.Transfer.returnValues.tokenId;
+    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
+
+    await tokenContract.methods.repartition(2).send();
+    await tokenContract.methods.transfer(receiver, 1).send();
+
+    const owner = await contract.methods.ownerOf(tokenId).call();
+    expect(owner).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
+  });
+});
addedtests/src/eth/tokens/minting.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/tokens/minting.test.ts
@@ -0,0 +1,167 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {IKeyringPair} from '@polkadot/types/types';
+import {Pallets} from '../../util';
+import {expect, itEth, usingEthPlaygrounds} from '../util';
+
+
+describe('Minting tokens', () => {
+  let donor: IKeyringPair;
+  let alice: IKeyringPair;
+
+  before(async function() {
+    await usingEthPlaygrounds(async (helper, privateKey) => {
+      donor = await privateKey({filename: __filename});
+      [alice] = await helper.arrange.createAccounts([30n, 20n], donor);
+    });
+  });
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'ft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Substrate collection`, testCase.requiredPallets, async ({helper}) => {
+      const owner = await helper.eth.createAccountWithBalance(donor);
+      const receiver = helper.eth.createAccount();
+      const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];
+
+      const collection = await helper[testCase.mode].mintCollection(alice);
+      await collection.addAdmin(alice, {Ethereum: owner});
+
+      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+      const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);
+
+      const result = await contract.methods.mint(...mintingParams).send({from: owner});
+
+      // Check events:
+      const event = result.events.Transfer;
+      expect(event.address).to.equal(collectionAddress);
+      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+      expect(event.returnValues.to).to.equal(receiver);
+      if (testCase.mode === 'ft')
+        expect(event.returnValues.value).to.equal('100');
+
+      // Check token exist:
+      if(testCase.mode === 'ft') {
+        expect(await helper.ft.getBalance(collection.collectionId, {Ethereum: receiver})).to.eq(100n);
+      } else {
+        const tokenId = event.returnValues.tokenId;
+        expect(tokenId).to.be.equal('1');
+        expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);
+        expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+      }
+    });
+  });
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'ft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {
+      const owner = await helper.eth.createAccountWithBalance(donor);
+      const receiver = helper.eth.createAccount();
+      const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];
+
+      const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');
+
+      const result = await collection.methods.mint(...mintingParams).send({from: owner});
+
+      // Check events:
+      const event = result.events.Transfer;
+      expect(event.address).to.equal(collectionAddress);
+      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+      expect(event.returnValues.to).to.equal(receiver);
+      if (testCase.mode === 'ft')
+        expect(event.returnValues.value).to.equal('100');
+
+      // Check token exist:
+      if(testCase.mode === 'ft') {
+        expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);
+      } else {
+        const tokenId = event.returnValues.tokenId;
+        expect(tokenId).to.be.equal('1');
+        expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);
+        expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+      }
+    });
+  });
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+    {mode: 'ft' as const, requiredPallets: []},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {
+      const owner = await helper.eth.createAccountWithBalance(donor);
+      const receiver = helper.eth.createAccount();
+      const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];
+
+      const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');
+
+      const result = await collection.methods.mint(...mintingParams).send({from: owner});
+
+      // Check events:
+      const event = result.events.Transfer;
+      expect(event.address).to.equal(collectionAddress);
+      expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+      expect(event.returnValues.to).to.equal(receiver);
+      if (testCase.mode === 'ft')
+        expect(event.returnValues.value).to.equal('100');
+
+      // Check token exist:
+      if(testCase.mode === 'ft') {
+        expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);
+      } else {
+        const tokenId = event.returnValues.tokenId;
+        expect(tokenId).to.be.equal('1');
+        expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);
+        expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+      }
+    });
+  });
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+  ].map(testCase => {
+    itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mintWithTokenURI() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {
+      const owner = await helper.eth.createAccountWithBalance(donor);
+      const receiver = helper.eth.createAccount();
+
+      const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');
+      const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);
+
+      const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();
+      const tokenId = result.events.Transfer.returnValues.tokenId;
+      expect(tokenId).to.be.equal('1');
+
+      const event = result.events.Transfer;
+      expect(event.address).to.be.equal(collectionAddress);
+      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
+      expect(event.returnValues.to).to.be.equal(receiver);
+
+      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
+      expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+      // TODO: this wont work right now, need release 919000 first
+      // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
+      // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
+      // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
+    });
+  });
+});
\ No newline at end of file
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
@@ -257,7 +257,7 @@
     }
   }
 
-  async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
+  async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18, mergeDeprecated = false): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[], collection: Contract }> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);
     const functionName: string = this.createCollectionMethodName(mode);
@@ -268,8 +268,9 @@
     const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
     const events = this.helper.eth.normalizeEvents(result.events);
+    const collection = await this.helper.ethNativeContract.collectionById(collectionId, mode, signer, mergeDeprecated);
 
-    return {collectionId, collectionAddress, events};
+    return {collectionId, collectionAddress, events, collection};
   }
 
   createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import {expect, itSub, Pallets, usingPlaygrounds} from '../util';
+import {expect, itSub, usingPlaygrounds} from '../util';
 
 describe('Integration Test: Composite nesting tests', () => {
   let alice: IKeyringPair;
@@ -287,54 +287,7 @@
     await collectionFT.mint(charlie, 5n);
     await collectionFT.transfer(charlie, targetToken.nestingAccount(), 2n);
     expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);
-  });
-
-  // ---------- Re-Fungible ----------
-
-  itSub.ifWithPallets('ReFungible: allows an Owner to nest/unnest their token', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}}});
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
-
-    await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
-    await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
-    await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
-    await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    // Create an immediately nested token
-    const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
-    expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
-
-    // Create a token to be nested and nest
-    const newToken = await collectionRFT.mintToken(charlie, 5n);
-    await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
-    expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
   });
-
-  itSub.ifWithPallets('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice);
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
-
-    await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted:[collectionRFT.collectionId]}});
-    await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
-    await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
-    await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
-    await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    // Create an immediately nested token
-    const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
-    expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
-
-    // Create a token to be nested and nest
-    const newToken = await collectionRFT.mintToken(charlie, 5n);
-    await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
-    expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
-  });
 });
 
 describe('Negative Test: Nesting', () => {
@@ -579,89 +532,5 @@
 
     expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
     expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(5n);
-  });
-
-  // ---------- Re-Fungible ----------
-
-  itSub.ifWithPallets('ReFungible: disallows to nest token if nesting is disabled', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice);
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice);
-
-    // Try to create an immediately nested token
-    await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
-      .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
-
-    // Try to create a token to be nested and nest
-    const token = await collectionRFT.mintToken(alice, 5n);
-    await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
-      .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
-  });
-
-  itSub.ifWithPallets('ReFungible: disallows a non-Owner to nest someone else\'s token', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice);
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice);
-
-    await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}});
-    await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
-    await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    // Try to create a token to be nested and nest
-    const newToken = await collectionRFT.mintToken(alice);
-    await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
-
-    expect(await targetToken.getChildren()).to.be.length(0);
-    expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
-
-    // Nest some tokens as Alice into Bob's token
-    await newToken.transfer(alice, targetToken.nestingAccount());
-
-    // Try to pull it out
-    await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
-      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);
-    expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
-  });
-
-  itSub.ifWithPallets('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice);
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice);
-
-    await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted: [collectionRFT.collectionId]}});
-    await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
-    await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
-
-    // Try to create a token to be nested and nest
-    const newToken = await collectionRFT.mintToken(alice);
-    await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
-
-    expect(await targetToken.getChildren()).to.be.length(0);
-    expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
-
-    // Nest some tokens as Alice into Bob's token
-    await newToken.transfer(alice, targetToken.nestingAccount());
-
-    // Try to pull it out
-    await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
-      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);
-    expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
-  });
-
-  itSub.ifWithPallets('ReFungible: disallows to nest token to an unlisted collection', [Pallets.ReFungible], async ({helper}) => {
-    const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true, restricted: []}}});
-    const collectionRFT = await helper.rft.mintCollection(alice);
-    const targetToken = await collectionNFT.mintToken(alice);
-
-    // Try to create an immediately nested token
-    await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
-      .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
-
-    // Try to create a token to be nested and nest
-    const token = await collectionRFT.mintToken(alice, 5n);
-    await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
-      .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
   });
 });
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -88,20 +88,6 @@
     expect((await token.getTop10Owners()).length).to.be.equal(10);
   });
 
-  itSub('Transfer token pieces', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
-    expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
-
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
-    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
-
-    await expect(token.transfer(alice, {Substrate: bob.address}, 41n))
-      .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
-  });
-
   itSub('Create multiple tokens', async ({helper}) => {
     const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
     // TODO: fix mintMultipleTokens
@@ -118,56 +104,8 @@
     const lastTokenId = await collection.getLastTokenId();
     expect(lastTokenId).to.be.equal(3);
     expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);
-  });
-
-  itSub('Burn some pieces', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
-    expect(await token.burn(alice, 99n)).to.be.true;
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);
   });
 
-  itSub('Burn all pieces', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
-
-    expect(await token.burn(alice, 100n)).to.be.true;
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
-  });
-
-  itSub('Burn some pieces for multiple users', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
-    expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
-
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
-    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
-
-    expect(await token.burn(alice, 40n)).to.be.true;
-
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
-
-    expect(await token.burn(bob, 59n)).to.be.true;
-
-    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
-
-    expect(await token.burn(bob, 1n)).to.be.true;
-
-    expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
-  });
-
   itSub('Set allowance for token', async ({helper}) => {
     const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
     const token = await collection.mintToken(alice, 100n);
@@ -183,68 +121,6 @@
     expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);
   });
 
-  itSub('Repartition', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-
-    expect(await token.repartition(alice, 200n)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);
-    expect(await token.getTotalPieces()).to.be.equal(200n);
-
-    expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);
-    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);
-
-    await expect(token.repartition(alice, 80n))
-      .to.eventually.be.rejectedWith(/refungible\.RepartitionWhileNotOwningAllPieces/);
-
-    expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;
-    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
-    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);
-
-    expect(await token.repartition(bob, 150n)).to.be.true;
-    await expect(token.transfer(bob, {Substrate: alice.address}, 160n))
-      .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
-  });
-
-  itSub('Repartition with increased amount', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-    await token.repartition(alice, 200n);
-    const chainEvents = helper.chainLog.slice(-1)[0].events;
-    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemCreated');
-    expect(event).to.deep.include({
-      section: 'common',
-      method: 'ItemCreated',
-      index: [66, 2],
-      data: [
-        collection.collectionId,
-        token.tokenId,
-        {substrate: alice.address},
-        100n,
-      ],
-    });
-  });
-
-  itSub('Repartition with decreased amount', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const token = await collection.mintToken(alice, 100n);
-    await token.repartition(alice, 50n);
-    const chainEvents = helper.chainLog.slice(-1)[0].events;
-    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemDestroyed');
-    expect(event).to.deep.include({
-      section: 'common',
-      method: 'ItemDestroyed',
-      index: [66, 3],
-      data: [
-        collection.collectionId,
-        token.tokenId,
-        {substrate: alice.address},
-        50n,
-      ],
-    });
-  });
-
   itSub('Create new collection with properties', async ({helper}) => {
     const properties = [{key: 'key1', value: 'val1'}];
     const tokenPropertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];
@@ -252,46 +128,5 @@
     const info = await collection.getData();
     expect(info?.raw.properties).to.be.deep.equal(properties);
     expect(info?.raw.tokenPropertyPermissions).to.be.deep.equal(tokenPropertyPermissions);
-  });
-});
-
-describe('Refungible negative tests', () => {
-  let donor: IKeyringPair;
-  let alice: IKeyringPair;
-  let bob: IKeyringPair;
-  let charlie: IKeyringPair;
-
-  before(async function() {
-    await usingPlaygrounds(async (helper, privateKey) => {
-      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
-
-      donor = await privateKey({filename: __filename});
-      [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
-    });
-  });
-
-  itSub('Cannot transfer incorrect amount of token pieces', async ({helper}) => {
-    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
-    const tokenAlice = await collection.mintToken(alice, 10n, {Substrate: alice.address});
-    const tokenBob = await collection.mintToken(alice, 10n, {Substrate: bob.address});
-
-    // 1. Alice cannot transfer Bob's token:
-    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
-    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
-    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow');
-    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow');
-
-    // 2. Alice cannot transfer non-existing token:
-    await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
-    await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
-
-    // 3. Zero transfer allowed (EIP-20):
-    await tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n);
-
-    expect(await tokenAlice.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
-    expect(await tokenBob.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
-    expect(await tokenAlice.getBalance({Substrate: alice.address})).to.eq(10n);
-    expect(await tokenBob.getBalance({Substrate: bob.address})).to.eq(10n);
-    expect(await tokenBob.getBalance({Substrate: charlie.address})).to.eq(0n);
   });
 });
addedtests/src/sub/refungible/burn.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/sub/refungible/burn.test.ts
@@ -0,0 +1,127 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {IKeyringPair} from '@polkadot/types/types';
+import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds, expect} from '../../util';
+
+describe('Refungible: burn', () => {
+  let donor: IKeyringPair;
+  let alice: IKeyringPair;
+  let bob: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+
+      donor = await privateKey({filename: __filename});
+      [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
+    });
+  });
+
+  itSub('can burn some pieces', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
+    await token.burn(alice, 99n);
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);
+  });
+
+  itSub('can burn all pieces', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
+
+    await token.burn(alice, 100n);
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
+  });
+
+  itSub('burn pieces for multiple users', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+
+    await token.transfer(alice, {Substrate: bob.address}, 60n);
+
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
+    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
+
+    await token.burn(alice, 40n);
+
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
+
+    await token.burn(bob, 59n);
+
+    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
+
+    await token.burn(bob, 1n);
+
+    expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
+  });
+
+  itSub('burn pieces by admin', async function({helper}) {
+    const collection = await helper.rft.mintCollection(alice);
+    await collection.setLimits(alice, {ownerCanTransfer: true});
+    await collection.addAdmin(alice, {Substrate: bob.address});
+    const token = await collection.mintToken(alice, 100n);
+
+    await token.burnFrom(bob, {Substrate: alice.address}, 100n);
+    expect(await token.doesExist()).to.be.false;
+  });
+});
+
+describe('Refungible: burn negative tests', () => {
+  let donor: IKeyringPair;
+  let alice: IKeyringPair;
+  let bob: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+      donor = await privateKey({filename: __filename});
+      [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
+    });
+  });
+
+  itSub('cannot burn non-owned token pieces', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice);
+    const aliceToken = await collection.mintToken(alice, 10n, {Substrate: alice.address});
+    const bobToken = await collection.mintToken(alice, 10n, {Substrate: bob.address});
+
+    // 1. Cannot burn non-owned token:
+    await expect(bobToken.burn(alice, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
+    await expect(bobToken.burn(alice, 5n)).to.be.rejectedWith('common.TokenValueTooLow');
+    // 2. Cannot burn non-existing token:
+    await expect(helper.rft.burnToken(alice, 99999, 10)).to.be.rejectedWith('common.CollectionNotFound');
+    await expect(helper.rft.burnToken(alice, collection.collectionId, 99999)).to.be.rejectedWith('common.TokenValueTooLow');
+    // 3. Can burn zero amount of owned tokens (EIP-20)
+    await aliceToken.burn(alice, 0n);
+
+    // 4. Storage is not corrupted:
+    expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
+    expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
+
+    // 4.1 Tokens can be transfered:
+    await aliceToken.transfer(alice, {Substrate: bob.address}, 10n);
+    await bobToken.transfer(bob, {Substrate: alice.address}, 10n);
+    expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
+    expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
+  });
+});
addedtests/src/sub/refungible/nesting.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/sub/refungible/nesting.test.ts
@@ -0,0 +1,180 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {IKeyringPair} from '@polkadot/types/types';
+import {expect, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from '../../util';
+
+describe('Refungible nesting', () => {
+  let alice: IKeyringPair;
+  let charlie: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+      const donor = await privateKey({filename: __filename});
+      [alice, charlie] = await helper.arrange.createAccounts([50n, 10n], donor);
+    });
+  });
+
+  [
+    {restrictedMode: true},
+    {restrictedMode: false},
+  ].map(testCase => {
+    itSub(`Owner can nest their token${testCase.restrictedMode ? ': Restricted mode' : ''}`, async ({helper}) => {
+      const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}}});
+      const collectionRFT = await helper.rft.mintCollection(alice);
+      const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
+
+      await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted: testCase.restrictedMode ? [collectionRFT.collectionId] : null}});
+      await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
+      await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
+
+      await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
+      await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
+      await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
+
+      // Create an immediately nested token
+      const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
+      expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
+
+      // Create a token to be nested and nest
+      const newToken = await collectionRFT.mintToken(charlie, 5n);
+      await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
+      expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
+      expect(await newToken.getBalance({Substrate: charlie.address})).to.be.equal(3n);
+    });
+  });
+
+  itSub('Owner can unnest nested token', async ({helper}) => {
+    const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
+    const targetToken = await collection.mintToken(alice);
+
+    // Owner mints nested RFT token:
+    const collectionRFT = await helper.rft.mintCollection(alice);
+    const token = await collectionRFT.mintToken(alice, 10n, targetToken.nestingAccount());
+
+    // 1.1 Owner can partially unnest token pieces with transferFrom:
+    await token.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 9n);
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(9n);
+    expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
+
+    // 1.2 Owner can unnest all pieces:
+    await token.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 1n);
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(10n);
+    expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
+  });
+
+  itSub('Owner can burn nested token pieces', async ({helper}) => {
+    const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
+    const targetToken = await collection.mintToken(alice);
+
+    // Owner mints nested RFT token:
+    const collectionRFT = await helper.rft.mintCollection(alice);
+    const token = await collectionRFT.mintToken(alice, 100n, {Substrate: alice.address});
+    await token.transfer(alice, targetToken.nestingAccount(), 30n);
+
+    // 1.1 Owner can partially burnFrom nested pieces:
+    await token.burnFrom(alice, targetToken.nestingAccount(), 10n);
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(70n);
+    expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(20n);
+    expect(await targetToken.getChildren()).to.has.length(1);
+
+    // 1.1 Owner can burnFrom all nested pieces:
+    await token.burnFrom(alice, targetToken.nestingAccount(), 20n);
+    expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
+    expect(await targetToken.getChildren()).to.has.length(0);
+    expect(await token.doesExist()).to.be.true;
+
+    // 2. Target token does not contain any pieces and can be burnt:
+    await targetToken.burn(alice);
+    expect(await targetToken.doesExist()).to.be.false;
+  });
+});
+
+describe('Refungible nesting negative tests', () => {
+  let alice: IKeyringPair;
+  let bob: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+      const donor = await privateKey({filename: __filename});
+      [alice, bob] = await helper.arrange.createAccounts([100n, 50n], donor);
+    });
+  });
+
+  itSub('cannot nest token if nesting is disabled', async ({helper}) => {
+    const collectionNFT = await helper.nft.mintCollection(alice);
+    const collectionRFT = await helper.rft.mintCollection(alice);
+    const targetToken = await collectionNFT.mintToken(alice);
+
+    // Try to create an immediately nested token
+    await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
+      .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+
+    // Try to create a token to be nested and nest
+    const token = await collectionRFT.mintToken(alice, 5n);
+    await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
+      .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
+  });
+
+  [
+    {restrictedMode: true},
+    {restrictedMode: false},
+  ].map(testCase => {
+    itSub(`non-Owner cannot nest someone else's token${testCase.restrictedMode ? ': Restricted mode' : ''}`, async ({helper}) => {
+      const collectionNFT = await helper.nft.mintCollection(alice);
+      const collectionRFT = await helper.rft.mintCollection(alice);
+      const targetToken = await collectionNFT.mintToken(alice);
+
+      await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted: testCase.restrictedMode ? [collectionRFT.collectionId] : null}});
+      await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
+      await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
+
+      // Try to create a token to be nested and nest
+      const newToken = await collectionRFT.mintToken(alice);
+      await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
+
+      expect(await targetToken.getChildren()).to.be.length(0);
+      expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
+
+      // Nest some tokens as Alice into Bob's token
+      await newToken.transfer(alice, targetToken.nestingAccount());
+
+      // Try to pull it out
+      await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
+        .to.be.rejectedWith(/common\.ApprovedValueTooLow/);
+      expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
+    });
+  });
+
+  itSub('ReFungible: disallows to nest token to an unlisted collection', async ({helper}) => {
+    const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true, restricted: []}}});
+    const collectionRFT = await helper.rft.mintCollection(alice);
+    const targetToken = await collectionNFT.mintToken(alice);
+
+    // Try to create an immediately nested token
+    await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
+      .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
+
+    // Try to create a token to be nested and nest
+    const token = await collectionRFT.mintToken(alice, 5n);
+    await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
+      .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
+  });
+});
addedtests/src/sub/refungible/repartition.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/sub/refungible/repartition.test.ts
@@ -0,0 +1,96 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {IKeyringPair} from '@polkadot/types/types';
+import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds, expect} from '../../util';
+
+describe('integration test: Refungible functionality:', () => {
+  let donor: IKeyringPair;
+  let alice: IKeyringPair;
+  let bob: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+
+      donor = await privateKey({filename: __filename});
+      [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
+    });
+  });
+
+  itSub('Repartition', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+
+    expect(await token.repartition(alice, 200n)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);
+    expect(await token.getTotalPieces()).to.be.equal(200n);
+
+    expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);
+    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);
+
+    await expect(token.repartition(alice, 80n))
+      .to.eventually.be.rejectedWith(/refungible\.RepartitionWhileNotOwningAllPieces/);
+
+    expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
+    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);
+
+    expect(await token.repartition(bob, 150n)).to.be.true;
+    await expect(token.transfer(bob, {Substrate: alice.address}, 160n))
+      .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
+  });
+
+  itSub('Repartition with increased amount', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+    await token.repartition(alice, 200n);
+    const chainEvents = helper.chainLog.slice(-1)[0].events;
+    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemCreated');
+    expect(event).to.deep.include({
+      section: 'common',
+      method: 'ItemCreated',
+      index: [66, 2],
+      data: [
+        collection.collectionId,
+        token.tokenId,
+        {substrate: alice.address},
+        100n,
+      ],
+    });
+  });
+
+  itSub('Repartition with decreased amount', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+    await token.repartition(alice, 50n);
+    const chainEvents = helper.chainLog.slice(-1)[0].events;
+    const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemDestroyed');
+    expect(event).to.deep.include({
+      section: 'common',
+      method: 'ItemDestroyed',
+      index: [66, 3],
+      data: [
+        collection.collectionId,
+        token.tokenId,
+        {substrate: alice.address},
+        50n,
+      ],
+    });
+  });
+});
+
addedtests/src/sub/refungible/transfer.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/sub/refungible/transfer.test.ts
@@ -0,0 +1,73 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// 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 {IKeyringPair} from '@polkadot/types/types';
+import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds, expect} from '../../util';
+
+describe('Refungible transfer tests', () => {
+  let donor: IKeyringPair;
+  let alice: IKeyringPair;
+  let bob: IKeyringPair;
+  let charlie: IKeyringPair;
+
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+
+      donor = await privateKey({filename: __filename});
+      [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+    });
+  });
+
+  itSub('Can transfer token pieces', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const token = await collection.mintToken(alice, 100n);
+
+    expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
+    // 1. Can transfer less or equal than have:
+    expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
+    expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
+  });
+
+  itSub('Cannot transfer incorrect amount of token pieces', async ({helper}) => {
+    const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+    const tokenAlice = await collection.mintToken(alice, 10n, {Substrate: alice.address});
+    const tokenBob = await collection.mintToken(alice, 10n, {Substrate: bob.address});
+
+    // 1. Alice cannot transfer Bob's token:
+    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
+    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
+    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow');
+    await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow');
+
+    // 2. Alice cannot transfer non-existing token:
+    await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
+    await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
+
+    // 3. Cannot transfer more than have:
+    await expect(tokenAlice.transfer(alice, {Substrate: bob.address}, 11n))
+      .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
+
+    // 4. Zero transfer allowed (EIP-20):
+    await tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n);
+
+    expect(await tokenAlice.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
+    expect(await tokenBob.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
+    expect(await tokenAlice.getBalance({Substrate: alice.address})).to.eq(10n);
+    expect(await tokenBob.getBalance({Substrate: bob.address})).to.eq(10n);
+    expect(await tokenBob.getBalance({Substrate: charlie.address})).to.eq(0n);
+  });
+});
\ No newline at end of file
modifiedtests/src/util/index.tsdiffbeforeafterboth
--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -100,6 +100,9 @@
 export const LOCKING_PERIOD = 12n; // 12 blocks of relay
 export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain
 
+// Native contracts
+export const COLLECTION_HELPER = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';
+export const CONTRACT_HELPER = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';
 
 export enum Pallets {
   Inflation = 'inflation',