git.delta.rocks / unique-network / refs/commits / 46515fa1c836

difftreelog

Merge pull request #826 from UniqueNetwork/fix/deprecate-eth-methods

ut-akuznetsov2023-01-12parents: #6994f61 #766b8da.patch.diff
in: master
Deprecate ethereum methods

9 files changed

modifiedtests/src/eth/abi/fungibleDeprecated.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungibleDeprecated.json
+++ b/tests/src/eth/abi/fungibleDeprecated.json
@@ -88,14 +88,5 @@
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "address", "name": "newOwner", "type": "address" }
-    ],
-    "name": "changeCollectionOwner",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
   }
 ]
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -51,12 +51,6 @@
   },
   {
     "anonymous": false,
-    "inputs": [],
-    "name": "MintingFinished",
-    "type": "event"
-  },
-  {
-    "anonymous": false,
     "inputs": [
       {
         "indexed": true,
@@ -420,13 +414,6 @@
     "name": "description",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
     "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "finishMinting",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
     "type": "function"
   },
   {
@@ -513,13 +500,6 @@
     "name": "mintWithTokenURI",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "mintingFinished",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
     "type": "function"
   },
   {
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -51,12 +51,6 @@
   },
   {
     "anonymous": false,
-    "inputs": [],
-    "name": "MintingFinished",
-    "type": "event"
-  },
-  {
-    "anonymous": false,
     "inputs": [
       {
         "indexed": true,
@@ -402,13 +396,6 @@
     "name": "description",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
     "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "finishMinting",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
     "type": "function"
   },
   {
@@ -495,13 +482,6 @@
     "name": "mintWithTokenURI",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "mintingFinished",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
     "type": "function"
   },
   {
modifiedtests/src/eth/abi/reFungibleDeprecated.jsondiffbeforeafterboth
before · tests/src/eth/abi/reFungibleDeprecated.json
1[2  {3    "inputs": [4      { "internalType": "address", "name": "newAdmin", "type": "address" }5    ],6    "name": "addCollectionAdmin",7    "outputs": [],8    "stateMutability": "nonpayable",9    "type": "function"10  },11  {12    "inputs": [13      { "internalType": "address", "name": "user", "type": "address" }14    ],15    "name": "addToCollectionAllowList",16    "outputs": [],17    "stateMutability": "nonpayable",18    "type": "function"19  },20  {21    "inputs": [22      { "internalType": "address", "name": "from", "type": "address" },23      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }24    ],25    "name": "burnFrom",26    "outputs": [],27    "stateMutability": "nonpayable",28    "type": "function"29  },30  {31    "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],32    "name": "deleteCollectionProperty",33    "outputs": [],34    "stateMutability": "nonpayable",35    "type": "function"36  },37  {38    "inputs": [39      { "internalType": "address", "name": "user", "type": "address" }40    ],41    "name": "isOwnerOrAdmin",42    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],43    "stateMutability": "view",44    "type": "function"45  },46  {47    "inputs": [48      { "internalType": "address", "name": "admin", "type": "address" }49    ],50    "name": "removeCollectionAdmin",51    "outputs": [],52    "stateMutability": "nonpayable",53    "type": "function"54  },55  {56    "inputs": [57      { "internalType": "address", "name": "user", "type": "address" }58    ],59    "name": "removeFromCollectionAllowList",60    "outputs": [],61    "stateMutability": "nonpayable",62    "type": "function"63  },64  {65    "inputs": [66      { "internalType": "string", "name": "key", "type": "string" },67      { "internalType": "bytes", "name": "value", "type": "bytes" }68    ],69    "name": "setCollectionProperty",70    "outputs": [],71    "stateMutability": "nonpayable",72    "type": "function"73  },74  {75    "inputs": [76      { "internalType": "address", "name": "sponsor", "type": "address" }77    ],78    "name": "setCollectionSponsor",79    "outputs": [],80    "stateMutability": "nonpayable",81    "type": "function"82  },83  {84    "inputs": [85      { "internalType": "address", "name": "newOwner", "type": "address" }86    ],87    "name": "changeCollectionOwner",88    "outputs": [],89    "stateMutability": "nonpayable",90    "type": "function"91  },92  {93    "inputs": [94      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },95      { "internalType": "string", "name": "key", "type": "string" }96    ],97    "name": "deleteProperty",98    "outputs": [],99    "stateMutability": "nonpayable",100    "type": "function"101  },102  {103    "inputs": [104      { "internalType": "address", "name": "to", "type": "address" },105      { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }106    ],107    "name": "mintBulk",108    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],109    "stateMutability": "nonpayable",110    "type": "function"111  },112  {113    "inputs": [114      { "internalType": "address", "name": "to", "type": "address" },115      {116        "components": [117          { "internalType": "uint256", "name": "field_0", "type": "uint256" },118          { "internalType": "string", "name": "field_1", "type": "string" }119        ],120        "internalType": "struct Tuple0[]",121        "name": "tokens",122        "type": "tuple[]"123      }124    ],125    "name": "mintBulkWithTokenURI",126    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],127    "stateMutability": "nonpayable",128    "type": "function"129  }130]
after · tests/src/eth/abi/reFungibleDeprecated.json
1[2  {3    "inputs": [4      { "internalType": "address", "name": "newAdmin", "type": "address" }5    ],6    "name": "addCollectionAdmin",7    "outputs": [],8    "stateMutability": "nonpayable",9    "type": "function"10  },11  {12    "inputs": [13      { "internalType": "address", "name": "user", "type": "address" }14    ],15    "name": "addToCollectionAllowList",16    "outputs": [],17    "stateMutability": "nonpayable",18    "type": "function"19  },20  {21    "inputs": [22      { "internalType": "address", "name": "from", "type": "address" },23      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }24    ],25    "name": "burnFrom",26    "outputs": [],27    "stateMutability": "nonpayable",28    "type": "function"29  },30  {31    "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],32    "name": "deleteCollectionProperty",33    "outputs": [],34    "stateMutability": "nonpayable",35    "type": "function"36  },37  {38    "inputs": [39      { "internalType": "address", "name": "user", "type": "address" }40    ],41    "name": "isOwnerOrAdmin",42    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],43    "stateMutability": "view",44    "type": "function"45  },46  {47    "inputs": [48      { "internalType": "address", "name": "admin", "type": "address" }49    ],50    "name": "removeCollectionAdmin",51    "outputs": [],52    "stateMutability": "nonpayable",53    "type": "function"54  },55  {56    "inputs": [57      { "internalType": "address", "name": "user", "type": "address" }58    ],59    "name": "removeFromCollectionAllowList",60    "outputs": [],61    "stateMutability": "nonpayable",62    "type": "function"63  },64  {65    "inputs": [66      { "internalType": "string", "name": "key", "type": "string" },67      { "internalType": "bytes", "name": "value", "type": "bytes" }68    ],69    "name": "setCollectionProperty",70    "outputs": [],71    "stateMutability": "nonpayable",72    "type": "function"73  },74  {75    "inputs": [76      { "internalType": "address", "name": "sponsor", "type": "address" }77    ],78    "name": "setCollectionSponsor",79    "outputs": [],80    "stateMutability": "nonpayable",81    "type": "function"82  },83  {84    "inputs": [85      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },86      { "internalType": "string", "name": "key", "type": "string" },87      { "internalType": "bytes", "name": "value", "type": "bytes" }88    ],89    "name": "setProperty",90    "outputs": [],91    "stateMutability": "nonpayable",92    "type": "function"93  },94  {95    "inputs": [96      { "internalType": "address", "name": "newOwner", "type": "address" }97    ],98    "name": "changeCollectionOwner",99    "outputs": [],100    "stateMutability": "nonpayable",101    "type": "function"102  },103  {104    "inputs": [105      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },106      { "internalType": "string", "name": "key", "type": "string" }107    ],108    "name": "deleteProperty",109    "outputs": [],110    "stateMutability": "nonpayable",111    "type": "function"112  },113  {114    "inputs": [115      { "internalType": "address", "name": "to", "type": "address" },116      { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }117    ],118    "name": "mintBulk",119    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],120    "stateMutability": "nonpayable",121    "type": "function"122  },123  {124    "inputs": [125      { "internalType": "address", "name": "to", "type": "address" },126      {127        "components": [128          { "internalType": "uint256", "name": "field_0", "type": "uint256" },129          { "internalType": "string", "name": "field_1", "type": "string" }130        ],131        "internalType": "struct Tuple0[]",132        "name": "tokens",133        "type": "tuple[]"134      }135    ],136    "name": "mintBulkWithTokenURI",137    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],138    "stateMutability": "nonpayable",139    "type": "function"140  }141]
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungibleToken.json
+++ b/tests/src/eth/abi/reFungibleToken.json
@@ -98,16 +98,6 @@
   },
   {
     "inputs": [
-      { "internalType": "address", "name": "from", "type": "address" },
-      { "internalType": "uint256", "name": "amount", "type": "uint256" }
-    ],
-    "name": "burnFrom",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
       {
         "components": [
           { "internalType": "address", "name": "eth", "type": "address" },
addedtests/src/eth/abi/reFungibleTokenDeprecated.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/abi/reFungibleTokenDeprecated.json
@@ -0,0 +1,12 @@
+[
+  {
+    "inputs": [
+      { "internalType": "address", "name": "from", "type": "address" },
+      { "internalType": "uint256", "name": "amount", "type": "uint256" }
+    ],
+    "name": "burnFrom",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  }
+]
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -74,7 +74,7 @@
 
     const result = await contract.methods.mint(caller).send();
     const tokenId = result.events.Transfer.returnValues.tokenId;
-    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);
+    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller, true);
 
     await tokenContract.methods.repartition(2).send();
     await tokenContract.methods.transfer(receiver, 1).send();
@@ -316,7 +316,7 @@
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = await helper.ethNativeContract.collection(address, 'rft');
 
-    const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner);
+    const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);
 
     {
       await rftToken.methods.approve(operator, 15n).send({from: owner});
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -458,7 +458,7 @@
     const result = await contract.methods.mint(caller).send();
     const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
-    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);
+    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller, true);
 
     await tokenContract.methods.repartition(2).send();
     await tokenContract.methods.transfer(receiver, 1).send();
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
@@ -29,6 +29,7 @@
 import refungibleAbi from '../../abi/reFungible.json';
 import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';
 import refungibleTokenAbi from '../../abi/reFungibleToken.json';
+import refungibleTokenDeprecatedAbi from '../../abi/reFungibleTokenDeprecated.json';
 import contractHelpersAbi from '../../abi/contractHelpers.json';
 import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
 import {TCollectionMode} from '../../../util/playgrounds/types';
@@ -187,17 +188,18 @@
     return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);
   }
 
-  async rftToken(address: string, caller?: string) {
+  async rftToken(address: string, caller?: string, mergeDeprecated = false) {
     const web3 = this.helper.getWeb3();
-    return unlimitedMoneyHack(new web3.eth.Contract(refungibleTokenAbi as any, address, {
+    const abi = mergeDeprecated ? [...refungibleTokenAbi, ...refungibleTokenDeprecatedAbi] : refungibleTokenAbi;
+    return unlimitedMoneyHack(new web3.eth.Contract(abi as any, address, {
       gas: this.helper.eth.DEFAULT_GAS,
       gasPrice: await this.getGasPrice(),
       ...(caller ? {from: caller} : {}),
     }));
   }
 
-  rftTokenById(collectionId: number, tokenId: number, caller?: string) {
-    return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);
+  rftTokenById(collectionId: number, tokenId: number, caller?: string, mergeDeprecated = false) {
+    return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller, mergeDeprecated);
   }
 }