git.delta.rocks / unique-network / refs/commits / 8c337cff2bc8

difftreelog

refactor rename function

Trubnikov Sergey2022-09-13parent: #8a59560.patch.diff
in: master

11 files changed

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -245,6 +245,7 @@
 	}
 
 	#[weight(<SelfWeightOf<T>>::create_collection())]
+	#[solidity(rename_selector = "createRFTCollection")]
 	fn create_refungible_collection(
 		&mut self,
 		caller: caller,
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -30,7 +30,7 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x675f3074
+/// @dev the ERC-165 identifier for this interface is 0x88ee8ef1
 contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
@@ -69,9 +69,9 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
-	/// @dev EVM selector for this function is: 0x44a68ad5,
-	///  or in textual repr: createRefungibleCollection(string,string,string)
-	function createRefungibleCollection(
+	/// @dev EVM selector for this function is: 0xab173450,
+	///  or in textual repr: createRFTCollection(string,string,string)
+	function createRFTCollection(
 		string memory name,
 		string memory description,
 		string memory tokenPrefix
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -21,7 +21,7 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x675f3074
+/// @dev the ERC-165 identifier for this interface is 0x88ee8ef1
 interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
@@ -45,9 +45,9 @@
 		string memory baseUri
 	) external returns (address);
 
-	/// @dev EVM selector for this function is: 0x44a68ad5,
-	///  or in textual repr: createRefungibleCollection(string,string,string)
-	function createRefungibleCollection(
+	/// @dev EVM selector for this function is: 0xab173450,
+	///  or in textual repr: createRFTCollection(string,string,string)
+	function createRFTCollection(
 		string memory name,
 		string memory description,
 		string memory tokenPrefix
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -59,7 +59,7 @@
       { "internalType": "string", "name": "description", "type": "string" },
       { "internalType": "string", "name": "tokenPrefix", "type": "string" }
     ],
-    "name": "createRefungibleCollection",
+    "name": "createRFTCollection",
     "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
     "stateMutability": "nonpayable",
     "type": "function"
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -41,7 +41,7 @@
   
     const collectionCountBefore = await getCreatedCollectionCount(api);
     const result = await collectionHelper.methods
-      .createRefungibleCollection(collectionName, description, tokenPrefix)
+      .createRFTCollection(collectionName, description, tokenPrefix)
       .send();
     const collectionCountAfter = await getCreatedCollectionCount(api);
   
@@ -65,7 +65,7 @@
       .call()).to.be.false;
 
     await collectionHelpers.methods
-      .createRefungibleCollection('A', 'A', 'A')
+      .createRFTCollection('A', 'A', 'A')
       .send();
     
     expect(await collectionHelpers.methods
@@ -76,7 +76,7 @@
   itWeb3('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    let result = await collectionHelpers.methods.createRefungibleCollection('Sponsor collection', '1', '1').send();
+    let result = await collectionHelpers.methods.createRFTCollection('Sponsor collection', '1', '1').send();
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
@@ -96,7 +96,7 @@
   itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    const result = await collectionHelpers.methods.createRefungibleCollection('Const collection', '5', '5').send();
+    const result = await collectionHelpers.methods.createRFTCollection('Const collection', '5', '5').send();
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const limits = {
       accountTokenOwnershipLimit: 1000,
@@ -141,7 +141,7 @@
       .isCollectionExist(collectionAddressForNonexistentCollection).call())
       .to.be.false;
     
-    const result = await collectionHelpers.methods.createRefungibleCollection('Collection address exist', '7', '7').send();
+    const result = await collectionHelpers.methods.createRFTCollection('Collection address exist', '7', '7').send();
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     expect(await collectionHelpers.methods
       .isCollectionExist(collectionIdAddress).call())
@@ -164,7 +164,7 @@
       const tokenPrefix = 'A';
     
       await expect(helper.methods
-        .createRefungibleCollection(collectionName, description, tokenPrefix)
+        .createRFTCollection(collectionName, description, tokenPrefix)
         .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGHT);
       
     }
@@ -174,7 +174,7 @@
       const description = 'A'.repeat(MAX_DESCRIPTION_LENGHT + 1);
       const tokenPrefix = 'A';
       await expect(helper.methods
-        .createRefungibleCollection(collectionName, description, tokenPrefix)
+        .createRFTCollection(collectionName, description, tokenPrefix)
         .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGHT);
     }
     {  
@@ -183,7 +183,7 @@
       const description = 'A';
       const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGHT + 1);
       await expect(helper.methods
-        .createRefungibleCollection(collectionName, description, tokenPrefix)
+        .createRFTCollection(collectionName, description, tokenPrefix)
         .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGHT);
     }
   });
@@ -196,7 +196,7 @@
     const tokenPrefix = 'A';
     
     await expect(helper.methods
-      .createRefungibleCollection(collectionName, description, tokenPrefix)
+      .createRFTCollection(collectionName, description, tokenPrefix)
       .call()).to.be.rejectedWith('NotSufficientFounds');
   });
 
@@ -204,7 +204,7 @@
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const notOwner = createEthAccount(web3);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();
+    const result = await collectionHelpers.methods.createRFTCollection('A', 'A', 'A').send();
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress, {type: 'ReFungible'});
     const EXPECTED_ERROR = 'NoPermission';
@@ -229,7 +229,7 @@
   itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const collectionHelpers = evmCollectionHelpers(web3, owner);
-    const result = await collectionHelpers.methods.createRefungibleCollection('Schema collection', 'A', 'A').send();
+    const result = await collectionHelpers.methods.createRFTCollection('Schema collection', 'A', 'A').send();
     const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
     await expect(collectionEvm.methods
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -25,7 +25,9 @@
     /// @dev Method modifier to only allow contract owner to call it.
     modifier onlyOwner() {
         address contracthelpersAddress = 0x842899ECF380553E8a4de75bF534cdf6fBF64049;
-        ContractHelpers contractHelpers = ContractHelpers(contracthelpersAddress);
+        ContractHelpers contractHelpers = ContractHelpers(
+            contracthelpersAddress
+        );
         address contractOwner = contractHelpers.contractOwner(address(this));
         require(msg.sender == contractOwner, "Only owner can");
         _;
@@ -38,10 +40,19 @@
     event AllowListSet(address _collection, bool _status);
 
     /// @dev This emits when NFT token is fractionalized by contract.
-    event Fractionalized(address _collection, uint256 _tokenId, address _rftToken, uint128 _amount);
+    event Fractionalized(
+        address _collection,
+        uint256 _tokenId,
+        address _rftToken,
+        uint128 _amount
+    );
 
     /// @dev This emits when NFT token is defractionalized by contract.
-    event Defractionalized(address _rftToken, address _nftCollection, uint256 _nftTokenId);
+    event Defractionalized(
+        address _rftToken,
+        address _nftCollection,
+        uint256 _nftTokenId
+    );
 
     /// Set RFT collection that contract will work with. RFT tokens for fractionalized NFT tokens
     /// would be created in this collection.
@@ -52,13 +63,11 @@
     ///  Can only be called by contract owner.
     /// @param _collection address of RFT collection.
     function setRFTCollection(address _collection) public onlyOwner {
-        require(
-            rftCollection == address(0),
-            "RFT collection is already set"
-        );
+        require(rftCollection == address(0), "RFT collection is already set");
         UniqueRefungible refungibleContract = UniqueRefungible(_collection);
-        string memory collectionType = refungibleContract.uniqueCollectionType();
-        
+        string memory collectionType = refungibleContract
+            .uniqueCollectionType();
+
         require(
             keccak256(bytes(collectionType)) == refungibleCollectionType,
             "Wrong collection type. Collection is not refungible."
@@ -78,13 +87,15 @@
     /// @param _name name for created RFT collection.
     /// @param _description description for created RFT collection.
     /// @param _tokenPrefix token prefix for created RFT collection.
-    function createAndSetRFTCollection(string calldata _name, string calldata _description, string calldata _tokenPrefix) public onlyOwner {
-        require(
-            rftCollection == address(0),
-            "RFT collection is already set"
-        );
+    function createAndSetRFTCollection(
+        string calldata _name,
+        string calldata _description,
+        string calldata _tokenPrefix
+    ) public onlyOwner {
+        require(rftCollection == address(0), "RFT collection is already set");
         address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
-        rftCollection = CollectionHelpers(collectionHelpers).createRefungibleCollection(_name, _description, _tokenPrefix);
+        rftCollection = CollectionHelpers(collectionHelpers)
+            .createRFTCollection(_name, _description, _tokenPrefix);
         emit RFTCollectionSet(rftCollection);
     }
 
@@ -92,7 +103,10 @@
     /// @dev Can only be called by contract owner.
     /// @param collection NFT token address.
     /// @param status `true` to allow and `false` to disallow NFT token.
-    function setNftCollectionIsAllowed(address collection, bool status) public onlyOwner {
+    function setNftCollectionIsAllowed(address collection, bool status)
+        public
+        onlyOwner
+    {
         nftCollectionAllowList[collection] = status;
         emit AllowListSet(collection, status);
     }
@@ -107,12 +121,15 @@
     /// @param  _collection NFT collection address
     /// @param  _token id of NFT token to be fractionalized
     /// @param  _pieces number of pieces new RFT token would have
-    function nft2rft(address _collection, uint256 _token, uint128 _pieces) public {
-        require(
-            rftCollection != address(0),
-            "RFT collection is not set"
+    function nft2rft(
+        address _collection,
+        uint256 _token,
+        uint128 _pieces
+    ) public {
+        require(rftCollection != address(0), "RFT collection is not set");
+        UniqueRefungible rftCollectionContract = UniqueRefungible(
+            rftCollection
         );
-        UniqueRefungible rftCollectionContract = UniqueRefungible(rftCollection);
         require(
             nftCollectionAllowList[_collection] == true,
             "Fractionalization of this collection is not allowed by admin"
@@ -121,25 +138,25 @@
             UniqueNFT(_collection).ownerOf(_token) == msg.sender,
             "Only token owner could fractionalize it"
         );
-        UniqueNFT(_collection).transferFrom(
-            msg.sender,
-            address(this),
-            _token
-        );
+        UniqueNFT(_collection).transferFrom(msg.sender, address(this), _token);
         uint256 rftTokenId;
         address rftTokenAddress;
         UniqueRefungibleToken rftTokenContract;
         if (nft2rftMapping[_collection][_token] == 0) {
             rftTokenId = rftCollectionContract.nextTokenId();
             rftCollectionContract.mint(address(this), rftTokenId);
-            rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
+            rftTokenAddress = rftCollectionContract.tokenContractAddress(
+                rftTokenId
+            );
             nft2rftMapping[_collection][_token] = rftTokenId;
             rft2nftMapping[rftTokenAddress] = Token(_collection, _token);
 
             rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
         } else {
             rftTokenId = nft2rftMapping[_collection][_token];
-            rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
+            rftTokenAddress = rftCollectionContract.tokenContractAddress(
+                rftTokenId
+            );
             rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
         }
         rftTokenContract.repartition(_pieces);
@@ -157,24 +174,25 @@
     /// @param _collection RFT collection address
     /// @param _token id of RFT token
     function rft2nft(address _collection, uint256 _token) public {
-        require(
-            rftCollection != address(0),
-            "RFT collection is not set"
+        require(rftCollection != address(0), "RFT collection is not set");
+        require(rftCollection == _collection, "Wrong RFT collection");
+        UniqueRefungible rftCollectionContract = UniqueRefungible(
+            rftCollection
         );
-        require(
-            rftCollection == _collection,
-            "Wrong RFT collection"
+        address rftTokenAddress = rftCollectionContract.tokenContractAddress(
+            _token
         );
-        UniqueRefungible rftCollectionContract = UniqueRefungible(rftCollection);
-        address rftTokenAddress = rftCollectionContract.tokenContractAddress(_token);
         Token memory nftToken = rft2nftMapping[rftTokenAddress];
         require(
             nftToken._collection != address(0),
             "No corresponding NFT token found"
         );
-        UniqueRefungibleToken rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
+        UniqueRefungibleToken rftTokenContract = UniqueRefungibleToken(
+            rftTokenAddress
+        );
         require(
-            rftTokenContract.balanceOf(msg.sender) == rftTokenContract.totalSupply(),
+            rftTokenContract.balanceOf(msg.sender) ==
+                rftTokenContract.totalSupply(),
             "Not all pieces are owned by the caller"
         );
         rftCollectionContract.transferFrom(msg.sender, address(this), _token);
@@ -183,6 +201,10 @@
             msg.sender,
             nftToken._tokenId
         );
-        emit Defractionalized(rftTokenAddress, nftToken._collection, nftToken._tokenId);
+        emit Defractionalized(
+            rftTokenAddress,
+            nftToken._collection,
+            nftToken._tokenId
+        );
     }
-}
\ No newline at end of file
+}
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -21,7 +21,7 @@
 import {readFile} from 'fs/promises';
 import {executeTransaction, submitTransactionAsync} from '../../substrate/substrate-api';
 import {getCreateCollectionResult, getCreateItemResult, UNIQUE, requirePallets, Pallets} from '../../util/helpers';
-import {collectionIdToAddress, CompiledContract, createEthAccountWithBalance, createNonfungibleCollection, createRefungibleCollection, GAS_ARGS, itWeb3, tokenIdFromAddress, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from '../util/helpers';
+import {collectionIdToAddress, CompiledContract, createEthAccountWithBalance, createNonfungibleCollection, createRFTCollection, GAS_ARGS, itWeb3, tokenIdFromAddress, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from '../util/helpers';
 import {Contract} from 'web3-eth-contract';
 import * as solc from 'solc';
 
@@ -123,7 +123,7 @@
   itWeb3('Set RFT collection', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const fractionalizer = await deployFractionalizer(web3, owner);
-    const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
     const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
     await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send();
     const result = await fractionalizer.methods.setRFTCollection(collectionIdAddress).send();
@@ -256,7 +256,7 @@
 
   itWeb3('call setRFTCollection twice', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
-    const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
     const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
 
     const fractionalizer = await deployFractionalizer(web3, owner);
@@ -282,7 +282,7 @@
   itWeb3('call setRFTCollection while not collection admin', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const fractionalizer = await deployFractionalizer(web3, owner);
-    const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
 
     await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())
       .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);
@@ -368,7 +368,7 @@
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
 
     const fractionalizer = await deployFractionalizer(web3, owner);
-    const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
     const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
     const rftTokenId = await refungibleContract.methods.nextTokenId().call();
     await refungibleContract.methods.mint(owner, rftTokenId).send();
@@ -381,7 +381,7 @@
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
 
     const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);
-    const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
     const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
     const rftTokenId = await refungibleContract.methods.nextTokenId().call();
     await refungibleContract.methods.mint(owner, rftTokenId).send();
@@ -392,7 +392,7 @@
 
   itWeb3('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
-    const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
 
     const fractionalizer = await deployFractionalizer(web3, owner);
     const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
before · tests/src/eth/reFungible.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 {createCollectionExpectSuccess, UNIQUE, requirePallets, Pallets} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress, uniqueRefungibleToken} from './util/helpers';19import {expect} from 'chai';2021describe('Refungible: Information getting', () => {22  before(async function() {23    await requirePallets(this, [Pallets.ReFungible]);24  });2526  itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {27    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);28    const helper = evmCollectionHelpers(web3, caller);29    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();30    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);31    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});32    const nextTokenId = await contract.methods.nextTokenId().call();33    await contract.methods.mint(caller, nextTokenId).send();34    const totalSupply = await contract.methods.totalSupply().call();35    expect(totalSupply).to.equal('1');36  });3738  itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {39    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);40    const helper = evmCollectionHelpers(web3, caller);41    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();42    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);43    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});4445    {46      const nextTokenId = await contract.methods.nextTokenId().call();47      await contract.methods.mint(caller, nextTokenId).send();48    }49    {50      const nextTokenId = await contract.methods.nextTokenId().call();51      await contract.methods.mint(caller, nextTokenId).send();52    }53    {54      const nextTokenId = await contract.methods.nextTokenId().call();55      await contract.methods.mint(caller, nextTokenId).send();56    }5758    const balance = await contract.methods.balanceOf(caller).call();5960    expect(balance).to.equal('3');61  });6263  itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {64    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);65    const helper = evmCollectionHelpers(web3, caller);66    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();67    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);68    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});6970    const tokenId = await contract.methods.nextTokenId().call();71    await contract.methods.mint(caller, tokenId).send();7273    const owner = await contract.methods.ownerOf(tokenId).call();7475    expect(owner).to.equal(caller);76  });7778  itWeb3('ownerOf after burn', async ({api, web3, privateKeyWrapper}) => {79    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);80    const receiver = createEthAccount(web3);81    const helper = evmCollectionHelpers(web3, caller);82    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();83    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);84    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});8586    const tokenId = await contract.methods.nextTokenId().call();87    await contract.methods.mint(caller, tokenId).send();8889    const tokenAddress = tokenIdToAddress(collectionId, tokenId);90    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);9192    await tokenContract.methods.repartition(2).send();93    await tokenContract.methods.transfer(receiver, 1).send();9495    await tokenContract.methods.burnFrom(caller, 1).send();9697    const owner = await contract.methods.ownerOf(tokenId).call();9899    expect(owner).to.equal(receiver);100  });101102  itWeb3('ownerOf for partial ownership', async ({api, web3, privateKeyWrapper}) => {103    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);104    const receiver = createEthAccount(web3);105    const helper = evmCollectionHelpers(web3, caller);106    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();107    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);108    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});109110    const tokenId = await contract.methods.nextTokenId().call();111    await contract.methods.mint(caller, tokenId).send();112113    const tokenAddress = tokenIdToAddress(collectionId, tokenId);114    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);115116    await tokenContract.methods.repartition(2).send();117    await tokenContract.methods.transfer(receiver, 1).send();118119    const owner = await contract.methods.ownerOf(tokenId).call();120121    expect(owner).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');122  });123});124125describe('Refungible: Plain calls', () => {126  before(async function() {127    await requirePallets(this, [Pallets.ReFungible]);128  });129130  itWeb3('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {131    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);132    const helper = evmCollectionHelpers(web3, owner);133    let result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();134    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);135    const receiver = createEthAccount(web3);136    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});137    const nextTokenId = await contract.methods.nextTokenId().call();138139    expect(nextTokenId).to.be.equal('1');140    result = await contract.methods.mintWithTokenURI(141      receiver,142      nextTokenId,143      'Test URI',144    ).send();145146    const events = normalizeEvents(result.events);147148    expect(events).to.include.deep.members([149      {150        address: collectionIdAddress,151        event: 'Transfer',152        args: {153          from: '0x0000000000000000000000000000000000000000',154          to: receiver,155          tokenId: nextTokenId,156        },157      },158    ]);159160    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');161  });162163  itWeb3('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {164    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);165    const helper = evmCollectionHelpers(web3, caller);166    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();167    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);168    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});169170    const receiver = createEthAccount(web3);171172    {173      const nextTokenId = await contract.methods.nextTokenId().call();174      expect(nextTokenId).to.be.equal('1');175      const result = await contract.methods.mintBulkWithTokenURI(176        receiver,177        [178          [nextTokenId, 'Test URI 0'],179          [+nextTokenId + 1, 'Test URI 1'],180          [+nextTokenId + 2, 'Test URI 2'],181        ],182      ).send();183      const events = normalizeEvents(result.events);184185      expect(events).to.include.deep.members([186        {187          address: collectionIdAddress,188          event: 'Transfer',189          args: {190            from: '0x0000000000000000000000000000000000000000',191            to: receiver,192            tokenId: nextTokenId,193          },194        },195        {196          address: collectionIdAddress,197          event: 'Transfer',198          args: {199            from: '0x0000000000000000000000000000000000000000',200            to: receiver,201            tokenId: String(+nextTokenId + 1),202          },203        },204        {205          address: collectionIdAddress,206          event: 'Transfer',207          args: {208            from: '0x0000000000000000000000000000000000000000',209            to: receiver,210            tokenId: String(+nextTokenId + 2),211          },212        },213      ]);214215      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');216      expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');217      expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');218    }219  });220221  itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {222    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);223    const helper = evmCollectionHelpers(web3, caller);224    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();225    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);226    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});227228    const tokenId = await contract.methods.nextTokenId().call();229    await contract.methods.mint(caller, tokenId).send();230    {231      const result = await contract.methods.burn(tokenId).send();232      const events = normalizeEvents(result.events);233      expect(events).to.include.deep.members([234        {235          address: collectionIdAddress,236          event: 'Transfer',237          args: {238            from: caller,239            to: '0x0000000000000000000000000000000000000000',240            tokenId: tokenId.toString(),241          },242        },243      ]);244    }245  });246247  itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {248    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);249    const helper = evmCollectionHelpers(web3, caller);250    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();251    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);252    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});253254    const receiver = createEthAccount(web3);255256    const tokenId = await contract.methods.nextTokenId().call();257    await contract.methods.mint(caller, tokenId).send();258259    const address = tokenIdToAddress(collectionId, tokenId);260    const tokenContract = uniqueRefungibleToken(web3, address, caller);261    await tokenContract.methods.repartition(15).send();262263    {264      const erc20Events = await recordEvents(tokenContract, async () => {265        const result = await contract.methods.transferFrom(caller, receiver, tokenId).send();266        const events = normalizeEvents(result.events);267        expect(events).to.include.deep.members([268          {269            address: collectionIdAddress,270            event: 'Transfer',271            args: {272              from: caller,273              to: receiver,274              tokenId: tokenId.toString(),275            },276          },277        ]);278      });279280      expect(erc20Events).to.include.deep.members([281        {282          address,283          event: 'Transfer',284          args: {285            from: caller,286            to: receiver,287            value: '15',288          },289        },290      ]);291    }292293    {294      const balance = await contract.methods.balanceOf(receiver).call();295      expect(+balance).to.equal(1);296    }297298    {299      const balance = await contract.methods.balanceOf(caller).call();300      expect(+balance).to.equal(0);301    }302  });303304  itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {305    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);306    const helper = evmCollectionHelpers(web3, caller);307    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();308    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);309    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});310311    const receiver = createEthAccount(web3);312313    const tokenId = await contract.methods.nextTokenId().call();314    await contract.methods.mint(caller, tokenId).send();315316    {317      const result = await contract.methods.transfer(receiver, tokenId).send();318      const events = normalizeEvents(result.events);319      expect(events).to.include.deep.members([320        {321          address: collectionIdAddress,322          event: 'Transfer',323          args: {324            from: caller,325            to: receiver,326            tokenId: tokenId.toString(),327          },328        },329      ]);330    }331332    {333      const balance = await contract.methods.balanceOf(caller).call();334      expect(+balance).to.equal(0);335    }336337    {338      const balance = await contract.methods.balanceOf(receiver).call();339      expect(+balance).to.equal(1);340    }341  });342343  itWeb3('transfer event on transfer from partial ownership to full ownership', async ({api, web3, privateKeyWrapper}) => {344    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);345    const receiver = createEthAccount(web3);346    const helper = evmCollectionHelpers(web3, caller);347    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();348    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);349    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});350351    const tokenId = await contract.methods.nextTokenId().call();352    await contract.methods.mint(caller, tokenId).send();353354    const tokenAddress = tokenIdToAddress(collectionId, tokenId);355    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);356357    await tokenContract.methods.repartition(2).send();358    await tokenContract.methods.transfer(receiver, 1).send();359360    const events =  await recordEvents(contract, async () =>361      await tokenContract.methods.transfer(receiver, 1).send());362    expect(events).to.deep.equal([363      {364        address: collectionIdAddress,365        event: 'Transfer',366        args: {367          from: '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF',368          to: receiver,369          tokenId: tokenId.toString(),370        },371      },372    ]);373  });374375  itWeb3('transfer event on transfer from full ownership to partial ownership', async ({api, web3, privateKeyWrapper}) => {376    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);377    const receiver = createEthAccount(web3);378    const helper = evmCollectionHelpers(web3, caller);379    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();380    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);381    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});382383    const tokenId = await contract.methods.nextTokenId().call();384    await contract.methods.mint(caller, tokenId).send();385386    const tokenAddress = tokenIdToAddress(collectionId, tokenId);387    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);388389    await tokenContract.methods.repartition(2).send();390391    const events =  await recordEvents(contract, async () =>392      await tokenContract.methods.transfer(receiver, 1).send());393394    expect(events).to.deep.equal([395      {396        address: collectionIdAddress,397        event: 'Transfer',398        args: {399          from: caller,400          to: '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF',401          tokenId: tokenId.toString(),402        },403      },404    ]);405  });406});407408describe('RFT: Fees', () => {409  before(async function() {410    await requirePallets(this, [Pallets.ReFungible]);411  });412413  itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {414    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);415    const helper = evmCollectionHelpers(web3, caller);416    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();417    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);418    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});419420    const receiver = createEthAccount(web3);421422    const tokenId = await contract.methods.nextTokenId().call();423    await contract.methods.mint(caller, tokenId).send();424425    const cost = await recordEthFee(api, caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());426    expect(cost < BigInt(0.2 * Number(UNIQUE)));427    expect(cost > 0n);428  });429430  itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {431    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);432    const helper = evmCollectionHelpers(web3, caller);433    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();434    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);435    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});436437    const receiver = createEthAccount(web3);438439    const tokenId = await contract.methods.nextTokenId().call();440    await contract.methods.mint(caller, tokenId).send();441442    const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send());443    expect(cost < BigInt(0.2 * Number(UNIQUE)));444    expect(cost > 0n);445  });446});447448describe('Common metadata', () => {449  before(async function() {450    await requirePallets(this, [Pallets.ReFungible]);451  });452453  itWeb3('Returns collection name', async ({api, web3, privateKeyWrapper}) => {454    const collection = await createCollectionExpectSuccess({455      name: 'token name',456      mode: {type: 'ReFungible'},457    });458    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);459460    const address = collectionIdToAddress(collection);461    const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});462    const name = await contract.methods.name().call();463464    expect(name).to.equal('token name');465  });466467  itWeb3('Returns symbol name', async ({api, web3, privateKeyWrapper}) => {468    const collection = await createCollectionExpectSuccess({469      tokenPrefix: 'TOK',470      mode: {type: 'ReFungible'},471    });472    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);473474    const address = collectionIdToAddress(collection);475    const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});476    const symbol = await contract.methods.symbol().call();477478    expect(symbol).to.equal('TOK');479  });480});
after · tests/src/eth/reFungible.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 {createCollectionExpectSuccess, UNIQUE, requirePallets, Pallets} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress, uniqueRefungibleToken} from './util/helpers';19import {expect} from 'chai';2021describe('Refungible: Information getting', () => {22  before(async function() {23    await requirePallets(this, [Pallets.ReFungible]);24  });2526  itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {27    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);28    const helper = evmCollectionHelpers(web3, caller);29    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();30    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);31    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});32    const nextTokenId = await contract.methods.nextTokenId().call();33    await contract.methods.mint(caller, nextTokenId).send();34    const totalSupply = await contract.methods.totalSupply().call();35    expect(totalSupply).to.equal('1');36  });3738  itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {39    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);40    const helper = evmCollectionHelpers(web3, caller);41    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();42    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);43    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});4445    {46      const nextTokenId = await contract.methods.nextTokenId().call();47      await contract.methods.mint(caller, nextTokenId).send();48    }49    {50      const nextTokenId = await contract.methods.nextTokenId().call();51      await contract.methods.mint(caller, nextTokenId).send();52    }53    {54      const nextTokenId = await contract.methods.nextTokenId().call();55      await contract.methods.mint(caller, nextTokenId).send();56    }5758    const balance = await contract.methods.balanceOf(caller).call();5960    expect(balance).to.equal('3');61  });6263  itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {64    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);65    const helper = evmCollectionHelpers(web3, caller);66    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();67    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);68    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});6970    const tokenId = await contract.methods.nextTokenId().call();71    await contract.methods.mint(caller, tokenId).send();7273    const owner = await contract.methods.ownerOf(tokenId).call();7475    expect(owner).to.equal(caller);76  });7778  itWeb3('ownerOf after burn', async ({api, web3, privateKeyWrapper}) => {79    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);80    const receiver = createEthAccount(web3);81    const helper = evmCollectionHelpers(web3, caller);82    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();83    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);84    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});8586    const tokenId = await contract.methods.nextTokenId().call();87    await contract.methods.mint(caller, tokenId).send();8889    const tokenAddress = tokenIdToAddress(collectionId, tokenId);90    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);9192    await tokenContract.methods.repartition(2).send();93    await tokenContract.methods.transfer(receiver, 1).send();9495    await tokenContract.methods.burnFrom(caller, 1).send();9697    const owner = await contract.methods.ownerOf(tokenId).call();9899    expect(owner).to.equal(receiver);100  });101102  itWeb3('ownerOf for partial ownership', async ({api, web3, privateKeyWrapper}) => {103    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);104    const receiver = createEthAccount(web3);105    const helper = evmCollectionHelpers(web3, caller);106    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();107    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);108    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});109110    const tokenId = await contract.methods.nextTokenId().call();111    await contract.methods.mint(caller, tokenId).send();112113    const tokenAddress = tokenIdToAddress(collectionId, tokenId);114    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);115116    await tokenContract.methods.repartition(2).send();117    await tokenContract.methods.transfer(receiver, 1).send();118119    const owner = await contract.methods.ownerOf(tokenId).call();120121    expect(owner).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');122  });123});124125describe('Refungible: Plain calls', () => {126  before(async function() {127    await requirePallets(this, [Pallets.ReFungible]);128  });129130  itWeb3('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {131    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);132    const helper = evmCollectionHelpers(web3, owner);133    let result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();134    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);135    const receiver = createEthAccount(web3);136    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});137    const nextTokenId = await contract.methods.nextTokenId().call();138139    expect(nextTokenId).to.be.equal('1');140    result = await contract.methods.mintWithTokenURI(141      receiver,142      nextTokenId,143      'Test URI',144    ).send();145146    const events = normalizeEvents(result.events);147148    expect(events).to.include.deep.members([149      {150        address: collectionIdAddress,151        event: 'Transfer',152        args: {153          from: '0x0000000000000000000000000000000000000000',154          to: receiver,155          tokenId: nextTokenId,156        },157      },158    ]);159160    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');161  });162163  itWeb3('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {164    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);165    const helper = evmCollectionHelpers(web3, caller);166    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();167    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);168    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});169170    const receiver = createEthAccount(web3);171172    {173      const nextTokenId = await contract.methods.nextTokenId().call();174      expect(nextTokenId).to.be.equal('1');175      const result = await contract.methods.mintBulkWithTokenURI(176        receiver,177        [178          [nextTokenId, 'Test URI 0'],179          [+nextTokenId + 1, 'Test URI 1'],180          [+nextTokenId + 2, 'Test URI 2'],181        ],182      ).send();183      const events = normalizeEvents(result.events);184185      expect(events).to.include.deep.members([186        {187          address: collectionIdAddress,188          event: 'Transfer',189          args: {190            from: '0x0000000000000000000000000000000000000000',191            to: receiver,192            tokenId: nextTokenId,193          },194        },195        {196          address: collectionIdAddress,197          event: 'Transfer',198          args: {199            from: '0x0000000000000000000000000000000000000000',200            to: receiver,201            tokenId: String(+nextTokenId + 1),202          },203        },204        {205          address: collectionIdAddress,206          event: 'Transfer',207          args: {208            from: '0x0000000000000000000000000000000000000000',209            to: receiver,210            tokenId: String(+nextTokenId + 2),211          },212        },213      ]);214215      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');216      expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');217      expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');218    }219  });220221  itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {222    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);223    const helper = evmCollectionHelpers(web3, caller);224    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();225    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);226    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});227228    const tokenId = await contract.methods.nextTokenId().call();229    await contract.methods.mint(caller, tokenId).send();230    {231      const result = await contract.methods.burn(tokenId).send();232      const events = normalizeEvents(result.events);233      expect(events).to.include.deep.members([234        {235          address: collectionIdAddress,236          event: 'Transfer',237          args: {238            from: caller,239            to: '0x0000000000000000000000000000000000000000',240            tokenId: tokenId.toString(),241          },242        },243      ]);244    }245  });246247  itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {248    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);249    const helper = evmCollectionHelpers(web3, caller);250    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();251    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);252    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});253254    const receiver = createEthAccount(web3);255256    const tokenId = await contract.methods.nextTokenId().call();257    await contract.methods.mint(caller, tokenId).send();258259    const address = tokenIdToAddress(collectionId, tokenId);260    const tokenContract = uniqueRefungibleToken(web3, address, caller);261    await tokenContract.methods.repartition(15).send();262263    {264      const erc20Events = await recordEvents(tokenContract, async () => {265        const result = await contract.methods.transferFrom(caller, receiver, tokenId).send();266        const events = normalizeEvents(result.events);267        expect(events).to.include.deep.members([268          {269            address: collectionIdAddress,270            event: 'Transfer',271            args: {272              from: caller,273              to: receiver,274              tokenId: tokenId.toString(),275            },276          },277        ]);278      });279280      expect(erc20Events).to.include.deep.members([281        {282          address,283          event: 'Transfer',284          args: {285            from: caller,286            to: receiver,287            value: '15',288          },289        },290      ]);291    }292293    {294      const balance = await contract.methods.balanceOf(receiver).call();295      expect(+balance).to.equal(1);296    }297298    {299      const balance = await contract.methods.balanceOf(caller).call();300      expect(+balance).to.equal(0);301    }302  });303304  itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {305    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);306    const helper = evmCollectionHelpers(web3, caller);307    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();308    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);309    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});310311    const receiver = createEthAccount(web3);312313    const tokenId = await contract.methods.nextTokenId().call();314    await contract.methods.mint(caller, tokenId).send();315316    {317      const result = await contract.methods.transfer(receiver, tokenId).send();318      const events = normalizeEvents(result.events);319      expect(events).to.include.deep.members([320        {321          address: collectionIdAddress,322          event: 'Transfer',323          args: {324            from: caller,325            to: receiver,326            tokenId: tokenId.toString(),327          },328        },329      ]);330    }331332    {333      const balance = await contract.methods.balanceOf(caller).call();334      expect(+balance).to.equal(0);335    }336337    {338      const balance = await contract.methods.balanceOf(receiver).call();339      expect(+balance).to.equal(1);340    }341  });342343  itWeb3('transfer event on transfer from partial ownership to full ownership', async ({api, web3, privateKeyWrapper}) => {344    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);345    const receiver = createEthAccount(web3);346    const helper = evmCollectionHelpers(web3, caller);347    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();348    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);349    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});350351    const tokenId = await contract.methods.nextTokenId().call();352    await contract.methods.mint(caller, tokenId).send();353354    const tokenAddress = tokenIdToAddress(collectionId, tokenId);355    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);356357    await tokenContract.methods.repartition(2).send();358    await tokenContract.methods.transfer(receiver, 1).send();359360    const events =  await recordEvents(contract, async () =>361      await tokenContract.methods.transfer(receiver, 1).send());362    expect(events).to.deep.equal([363      {364        address: collectionIdAddress,365        event: 'Transfer',366        args: {367          from: '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF',368          to: receiver,369          tokenId: tokenId.toString(),370        },371      },372    ]);373  });374375  itWeb3('transfer event on transfer from full ownership to partial ownership', async ({api, web3, privateKeyWrapper}) => {376    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);377    const receiver = createEthAccount(web3);378    const helper = evmCollectionHelpers(web3, caller);379    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();380    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);381    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});382383    const tokenId = await contract.methods.nextTokenId().call();384    await contract.methods.mint(caller, tokenId).send();385386    const tokenAddress = tokenIdToAddress(collectionId, tokenId);387    const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);388389    await tokenContract.methods.repartition(2).send();390391    const events =  await recordEvents(contract, async () =>392      await tokenContract.methods.transfer(receiver, 1).send());393394    expect(events).to.deep.equal([395      {396        address: collectionIdAddress,397        event: 'Transfer',398        args: {399          from: caller,400          to: '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF',401          tokenId: tokenId.toString(),402        },403      },404    ]);405  });406});407408describe('RFT: Fees', () => {409  before(async function() {410    await requirePallets(this, [Pallets.ReFungible]);411  });412413  itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {414    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);415    const helper = evmCollectionHelpers(web3, caller);416    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();417    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);418    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});419420    const receiver = createEthAccount(web3);421422    const tokenId = await contract.methods.nextTokenId().call();423    await contract.methods.mint(caller, tokenId).send();424425    const cost = await recordEthFee(api, caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());426    expect(cost < BigInt(0.2 * Number(UNIQUE)));427    expect(cost > 0n);428  });429430  itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {431    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);432    const helper = evmCollectionHelpers(web3, caller);433    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();434    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);435    const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});436437    const receiver = createEthAccount(web3);438439    const tokenId = await contract.methods.nextTokenId().call();440    await contract.methods.mint(caller, tokenId).send();441442    const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send());443    expect(cost < BigInt(0.2 * Number(UNIQUE)));444    expect(cost > 0n);445  });446});447448describe('Common metadata', () => {449  before(async function() {450    await requirePallets(this, [Pallets.ReFungible]);451  });452453  itWeb3('Returns collection name', async ({api, web3, privateKeyWrapper}) => {454    const collection = await createCollectionExpectSuccess({455      name: 'token name',456      mode: {type: 'ReFungible'},457    });458    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);459460    const address = collectionIdToAddress(collection);461    const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});462    const name = await contract.methods.name().call();463464    expect(name).to.equal('token name');465  });466467  itWeb3('Returns symbol name', async ({api, web3, privateKeyWrapper}) => {468    const collection = await createCollectionExpectSuccess({469      tokenPrefix: 'TOK',470      mode: {type: 'ReFungible'},471    });472    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);473474    const address = collectionIdToAddress(collection);475    const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});476    const symbol = await contract.methods.symbol().call();477478    expect(symbol).to.equal('TOK');479  });480});
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';
-import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRFTCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';
 
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
@@ -458,7 +458,7 @@
     const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const receiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const helper = evmCollectionHelpers(web3, caller);
-    const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+    const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
     const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
 
@@ -658,7 +658,7 @@
   itWeb3('Default parent token address and id', async ({api, web3, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
 
-    const {collectionIdAddress, collectionId} = await createRefungibleCollection(api, web3, owner);
+    const {collectionIdAddress, collectionId} = await createRFTCollection(api, web3, owner);
     const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
     const refungibleTokenId = await refungibleContract.methods.nextTokenId().call();
     await refungibleContract.methods.mint(owner, refungibleTokenId).send();
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -141,10 +141,10 @@
   expect(result.success).to.be.true;
 }
 
-export async function createRefungibleCollection(api: ApiPromise, web3: Web3, owner: string) {
+export async function createRFTCollection(api: ApiPromise, web3: Web3, owner: string) {
   const collectionHelper = evmCollectionHelpers(web3, owner);
   const result = await collectionHelper.methods
-    .createRefungibleCollection('A', 'B', 'C')
+    .createRFTCollection('A', 'B', 'C')
     .send();
   return await getCollectionAddressFromResult(api, result);
 }