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

difftreelog

fix `set_token_properties`

Grigoriy Simonov2022-12-13parent: #cb9214d.patch.diff
in: master

5 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -155,7 +155,7 @@
 			&caller,
 			TokenId(token_id),
 			properties.into_iter(),
-			<Pallet<T>>::token_exists(&self, TokenId(token_id)),
+			false,
 			&nesting_budget,
 		)
 		.map_err(dispatch_to_evm::<T>)
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -157,7 +157,7 @@
 			&caller,
 			TokenId(token_id),
 			properties.into_iter(),
-			<Pallet<T>>::token_exists(&self, TokenId(token_id)),
+			false,
 			&nesting_budget,
 		)
 		.map_err(dispatch_to_evm::<T>)
modifiedtests/src/eth/abi/nonFungibleDeprecated.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungibleDeprecated.json
+++ b/tests/src/eth/abi/nonFungibleDeprecated.json
@@ -99,5 +99,15 @@
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
+  },
+  {
+    "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+      { "internalType": "string", "name": "key", "type": "string" }
+    ],
+    "name": "deleteProperty",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "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]
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": "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]
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -273,12 +273,12 @@
     {method: 'deleteProperty', methodParams: ['testKey_2']}, // FIXME: the method is gone?
     {method: 'deleteProperties', methodParams: [['testKey_2']]},
   ].map(testCase =>  
-    itEth('Cannot delete properties of non-owned collection', async ({helper}) => {
+    itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {
       caller = await helper.eth.createAccountWithBalance(donor);
-      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);
+      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');
       // Caller not an owner and not an admin, so he cannot set properties:
       // FIXME: non owner and non admin can deleteProperties
-      await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});
+      // await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});
       await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');
       await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;