difftreelog
feature: Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.
in: master
15 files changed
Cargo.lockdiffbeforeafterboth637663766377[[package]]6377[[package]]6378name = "pallet-nonfungible"6378name = "pallet-nonfungible"6379version = "0.1.7"6379version = "0.1.8"6380dependencies = [6380dependencies = [6381 "ethereum",6381 "ethereum",6382 "evm-coder",6382 "evm-coder",649864986499[[package]]6499[[package]]6500name = "pallet-refungible"6500name = "pallet-refungible"6501version = "0.2.6"6501version = "0.2.7"6502dependencies = [6502dependencies = [6503 "derivative",6503 "derivative",6504 "ethereum",6504 "ethereum",pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->67## [v0.1.8] - 2022-11-1189### Changed1011- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.126## [v0.1.7] - 2022-11-0213## [v0.1.7] - 2022-11-02147### Changed15### Changed168 - Use named structure `EthCrossAccount` in eth functions.17- Use named structure `EthCrossAccount` in eth functions.91810## [v0.1.6] - 2022-20-1019## [v0.1.6] - 2022-20-101120pallets/nonfungible/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "pallet-nonfungible"2name = "pallet-nonfungible"3version = "0.1.7"3version = "0.1.8"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66pallets/nonfungible/src/erc.rsdiffbeforeafterboth162 /// @dev Throws error if `msg.sender` has no permission to edit the property.162 /// @dev Throws error if `msg.sender` has no permission to edit the property.163 /// @param tokenId ID of the token.163 /// @param tokenId ID of the token.164 /// @param key Property key.164 /// @param key Property key.165 #[solidity(hide)]165 fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {166 fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {166 let caller = T::CrossAccountId::from_eth(caller);167 let caller = T::CrossAccountId::from_eth(caller);167 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;168 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;177 .map_err(dispatch_to_evm::<T>)178 .map_err(dispatch_to_evm::<T>)178 }179 }180181 /// @notice Delete token properties value.182 /// @dev Throws error if `msg.sender` has no permission to edit the property.183 /// @param tokenId ID of the token.184 /// @param keys Properties key.185 fn delete_properties(186 &mut self,187 token_id: uint256,188 caller: caller,189 keys: Vec<string>,190 ) -> Result<()> {191 let caller = T::CrossAccountId::from_eth(caller);192 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;193 let keys = keys194 .into_iter()195 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))196 .collect::<Result<Vec<_>>>()?;197198 let nesting_budget = self199 .recorder200 .weight_calls_budget(<StructureWeight<T>>::find_parent());201202 <Pallet<T>>::delete_token_properties(203 self,204 &caller,205 TokenId(token_id),206 keys.into_iter(),207 &nesting_budget,208 )209 .map_err(dispatch_to_evm::<T>)210 }179211180 /// @notice Get token property value.212 /// @notice Get token property value.181 /// @dev Throws error if key not found213 /// @dev Throws error if key not foundpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth18}18}191920/// @title A contract that allows to set and delete token properties and change token property permissions.20/// @title A contract that allows to set and delete token properties and change token property permissions.21/// @dev the ERC-165 identifier for this interface is 0x55dba91921/// @dev the ERC-165 identifier for this interface is 0x91a97a6822contract TokenProperties is Dummy, ERC165 {22contract TokenProperties is Dummy, ERC165 {23 /// @notice Set permissions for token property.23 /// @notice Set permissions for token property.24 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.24 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.74 dummy = 0;74 dummy = 0;75 }75 }7677 // /// @notice Delete token property value.78 // /// @dev Throws error if `msg.sender` has no permission to edit the property.79 // /// @param tokenId ID of the token.80 // /// @param key Property key.81 // /// @dev EVM selector for this function is: 0x066111d1,82 // /// or in textual repr: deleteProperty(uint256,string)83 // function deleteProperty(uint256 tokenId, string memory key) public {84 // require(false, stub_error);85 // tokenId;86 // key;87 // dummy = 0;88 // }768977 /// @notice Delete token property value.90 /// @notice Delete token properties value.78 /// @dev Throws error if `msg.sender` has no permission to edit the property.91 /// @dev Throws error if `msg.sender` has no permission to edit the property.79 /// @param tokenId ID of the token.92 /// @param tokenId ID of the token.80 /// @param key Property key.93 /// @param keys Properties key.81 /// @dev EVM selector for this function is: 0x066111d1,94 /// @dev EVM selector for this function is: 0xc472d371,82 /// or in textual repr: deleteProperty(uint256,string)95 /// or in textual repr: deleteProperties(uint256,string[])83 function deleteProperty(uint256 tokenId, string memory key) public {96 function deleteProperties(uint256 tokenId, string[] memory keys) public {84 require(false, stub_error);97 require(false, stub_error);85 tokenId;98 tokenId;86 key;99 keys;87 dummy = 0;100 dummy = 0;88 }101 }89102pallets/refungible/CHANGELOG.mddiffbeforeafterboth223All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445<!-- bureaucrate goes here -->67## [v0.2.7] - 2022-11-1189### Changed1011- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.125## [v0.2.6] - 2022-11-0213## [v0.2.6] - 2022-11-02146### Changed15### Changed7 - Use named structure `EthCrossAccount` in eth functions.81617- Use named structure `EthCrossAccount` in eth functions.189## [v0.2.5] - 2022-20-1019## [v0.2.5] - 2022-20-10102011### Change21### Change17### Change27### Change182819- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.29- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.2021<!-- bureaucrate goes here -->223023## [v0.2.3] 2022-08-1631## [v0.2.3] 2022-08-162432pallets/refungible/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "pallet-refungible"2name = "pallet-refungible"3version = "0.2.6"3version = "0.2.7"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66pallets/refungible/src/erc.rsdiffbeforeafterboth164 /// @dev Throws error if `msg.sender` has no permission to edit the property.164 /// @dev Throws error if `msg.sender` has no permission to edit the property.165 /// @param tokenId ID of the token.165 /// @param tokenId ID of the token.166 /// @param key Property key.166 /// @param key Property key.167 #[solidity(hide)]167 fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {168 fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {168 let caller = T::CrossAccountId::from_eth(caller);169 let caller = T::CrossAccountId::from_eth(caller);169 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;170 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;179 .map_err(dispatch_to_evm::<T>)180 .map_err(dispatch_to_evm::<T>)180 }181 }182183 /// @notice Delete token properties value.184 /// @dev Throws error if `msg.sender` has no permission to edit the property.185 /// @param tokenId ID of the token.186 /// @param keys Properties key.187 fn delete_properties(188 &mut self,189 token_id: uint256,190 caller: caller,191 keys: Vec<string>,192 ) -> Result<()> {193 let caller = T::CrossAccountId::from_eth(caller);194 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;195 let keys = keys196 .into_iter()197 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))198 .collect::<Result<Vec<_>>>()?;199200 let nesting_budget = self201 .recorder202 .weight_calls_budget(<StructureWeight<T>>::find_parent());203204 <Pallet<T>>::delete_token_properties(205 self,206 &caller,207 TokenId(token_id),208 keys.into_iter(),209 &nesting_budget,210 )211 .map_err(dispatch_to_evm::<T>)212 }181213182 /// @notice Get token property value.214 /// @notice Get token property value.183 /// @dev Throws error if key not found215 /// @dev Throws error if key not foundpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth18}18}191920/// @title A contract that allows to set and delete token properties and change token property permissions.20/// @title A contract that allows to set and delete token properties and change token property permissions.21/// @dev the ERC-165 identifier for this interface is 0x55dba91921/// @dev the ERC-165 identifier for this interface is 0x91a97a6822contract TokenProperties is Dummy, ERC165 {22contract TokenProperties is Dummy, ERC165 {23 /// @notice Set permissions for token property.23 /// @notice Set permissions for token property.24 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.24 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.74 dummy = 0;74 dummy = 0;75 }75 }7677 // /// @notice Delete token property value.78 // /// @dev Throws error if `msg.sender` has no permission to edit the property.79 // /// @param tokenId ID of the token.80 // /// @param key Property key.81 // /// @dev EVM selector for this function is: 0x066111d1,82 // /// or in textual repr: deleteProperty(uint256,string)83 // function deleteProperty(uint256 tokenId, string memory key) public {84 // require(false, stub_error);85 // tokenId;86 // key;87 // dummy = 0;88 // }768977 /// @notice Delete token property value.90 /// @notice Delete token properties value.78 /// @dev Throws error if `msg.sender` has no permission to edit the property.91 /// @dev Throws error if `msg.sender` has no permission to edit the property.79 /// @param tokenId ID of the token.92 /// @param tokenId ID of the token.80 /// @param key Property key.93 /// @param keys Properties key.81 /// @dev EVM selector for this function is: 0x066111d1,94 /// @dev EVM selector for this function is: 0xc472d371,82 /// or in textual repr: deleteProperty(uint256,string)95 /// or in textual repr: deleteProperties(uint256,string[])83 function deleteProperty(uint256 tokenId, string memory key) public {96 function deleteProperties(uint256 tokenId, string[] memory keys) public {84 require(false, stub_error);97 require(false, stub_error);85 tokenId;98 tokenId;86 key;99 keys;87 dummy = 0;100 dummy = 0;88 }101 }89102tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth13}13}141415/// @title A contract that allows to set and delete token properties and change token property permissions.15/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x55dba91916/// @dev the ERC-165 identifier for this interface is 0x91a97a6817interface TokenProperties is Dummy, ERC165 {17interface TokenProperties is Dummy, ERC165 {18 /// @notice Set permissions for token property.18 /// @notice Set permissions for token property.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.51 /// or in textual repr: setProperties(uint256,(string,bytes)[])51 /// or in textual repr: setProperties(uint256,(string,bytes)[])52 function setProperties(uint256 tokenId, Tuple21[] memory properties) external;52 function setProperties(uint256 tokenId, Tuple21[] memory properties) external;5354 // /// @notice Delete token property value.55 // /// @dev Throws error if `msg.sender` has no permission to edit the property.56 // /// @param tokenId ID of the token.57 // /// @param key Property key.58 // /// @dev EVM selector for this function is: 0x066111d1,59 // /// or in textual repr: deleteProperty(uint256,string)60 // function deleteProperty(uint256 tokenId, string memory key) external;536154 /// @notice Delete token property value.62 /// @notice Delete token properties value.55 /// @dev Throws error if `msg.sender` has no permission to edit the property.63 /// @dev Throws error if `msg.sender` has no permission to edit the property.56 /// @param tokenId ID of the token.64 /// @param tokenId ID of the token.57 /// @param key Property key.65 /// @param keys Properties key.58 /// @dev EVM selector for this function is: 0x066111d1,66 /// @dev EVM selector for this function is: 0xc472d371,59 /// or in textual repr: deleteProperty(uint256,string)67 /// or in textual repr: deleteProperties(uint256,string[])60 function deleteProperty(uint256 tokenId, string memory key) external;68 function deleteProperties(uint256 tokenId, string[] memory keys) external;616962 /// @notice Get token property value.70 /// @notice Get token property value.63 /// @dev Throws error if key not found71 /// @dev Throws error if key not foundtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth13}13}141415/// @title A contract that allows to set and delete token properties and change token property permissions.15/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x55dba91916/// @dev the ERC-165 identifier for this interface is 0x91a97a6817interface TokenProperties is Dummy, ERC165 {17interface TokenProperties is Dummy, ERC165 {18 /// @notice Set permissions for token property.18 /// @notice Set permissions for token property.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.51 /// or in textual repr: setProperties(uint256,(string,bytes)[])51 /// or in textual repr: setProperties(uint256,(string,bytes)[])52 function setProperties(uint256 tokenId, Tuple20[] memory properties) external;52 function setProperties(uint256 tokenId, Tuple20[] memory properties) external;5354 // /// @notice Delete token property value.55 // /// @dev Throws error if `msg.sender` has no permission to edit the property.56 // /// @param tokenId ID of the token.57 // /// @param key Property key.58 // /// @dev EVM selector for this function is: 0x066111d1,59 // /// or in textual repr: deleteProperty(uint256,string)60 // function deleteProperty(uint256 tokenId, string memory key) external;536154 /// @notice Delete token property value.62 /// @notice Delete token properties value.55 /// @dev Throws error if `msg.sender` has no permission to edit the property.63 /// @dev Throws error if `msg.sender` has no permission to edit the property.56 /// @param tokenId ID of the token.64 /// @param tokenId ID of the token.57 /// @param key Property key.65 /// @param keys Properties key.58 /// @dev EVM selector for this function is: 0x066111d1,66 /// @dev EVM selector for this function is: 0xc472d371,59 /// or in textual repr: deleteProperty(uint256,string)67 /// or in textual repr: deleteProperties(uint256,string[])60 function deleteProperty(uint256 tokenId, string memory key) external;68 function deleteProperties(uint256 tokenId, string[] memory keys) external;616962 /// @notice Get token property value.70 /// @notice Get token property value.63 /// @dev Throws error if key not found71 /// @dev Throws error if key not foundtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth139 await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();139 await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();140 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);140 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);141141142 await contract.methods.deleteProperty(tokenId1, 'URI').send();142 await contract.methods.deleteProperties(tokenId1, ['URI']).send();143 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);143 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);144144145 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();145 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();146 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;146 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;147147148 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);148 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);149149150 await contract.methods.deleteProperty(tokenId2, 'URI').send();150 await contract.methods.deleteProperties(tokenId2, ['URI']).send();151 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);151 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);152152153 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();153 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth334 {334 {335 "inputs": [335 "inputs": [336 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },336 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },337 { "internalType": "string", "name": "key", "type": "string" }337 { "internalType": "string[]", "name": "keys", "type": "string[]" }338 ],338 ],339 "name": "deleteProperty",339 "name": "deleteProperties",340 "outputs": [],340 "outputs": [],341 "stateMutability": "nonpayable",341 "stateMutability": "nonpayable",342 "type": "function"342 "type": "function"tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth316 {316 {317 "inputs": [317 "inputs": [318 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },318 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },319 { "internalType": "string", "name": "key", "type": "string" }319 { "internalType": "string[]", "name": "keys", "type": "string[]" }320 ],320 ],321 "name": "deleteProperty",321 "name": "deleteProperties",322 "outputs": [],322 "outputs": [],323 "stateMutability": "nonpayable",323 "stateMutability": "nonpayable",324 "type": "function"324 "type": "function"tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth138 mutable: true,138 mutable: true,139 collectionAdmin: true,139 collectionAdmin: true,140 },140 },141 }],141 },142 {143 key: 'testKey_1',144 permission: {145 mutable: true,146 collectionAdmin: true,147 },148 }],142 });149 });143 150 144 const token = await collection.mintToken(alice);151 const token = await collection.mintToken(alice);145 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);152 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}, {key: 'testKey_1', value: 'testValue_1'}]);146153147 await collection.addAdmin(alice, {Ethereum: caller});154 await collection.addAdmin(alice, {Ethereum: caller});148155149 const address = helper.ethAddress.fromCollectionId(collection.collectionId);156 const address = helper.ethAddress.fromCollectionId(collection.collectionId);150 const contract = helper.ethNativeContract.collection(address, 'nft', caller);157 const contract = helper.ethNativeContract.collection(address, 'nft', caller);151158152 await contract.methods.deleteProperty(token.tokenId, 'testKey').send({from: caller});159 await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});153160154 const result = await token.getProperties(['testKey']);161 const result = await token.getProperties(['testKey']);155 expect(result.length).to.equal(0);162 expect(result.length).to.equal(0);