git.delta.rocks / unique-network / refs/commits / 515ea8c66cf5

difftreelog

feature: Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.

PraetorP2022-11-11parent: #f715967.patch.diff
in: master

15 files changed

modifiedCargo.lockdiffbeforeafterboth
63766376
6377[[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",
64986498
6499[[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",
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->
6
7## [v0.1.8] - 2022-11-11
8
9### Changed
10
11- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.
12
6## [v0.1.7] - 2022-11-0213## [v0.1.7] - 2022-11-02
14
7### Changed15### Changed
16
8 - Use named structure `EthCrossAccount` in eth functions.17- Use named structure `EthCrossAccount` in eth functions.
918
10## [v0.1.6] - 2022-20-1019## [v0.1.6] - 2022-20-10
1120
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
1[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"
66
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
162 /// @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 }
180
181 /// @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 = keys
194 .into_iter()
195 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
196 .collect::<Result<Vec<_>>>()?;
197
198 let nesting_budget = self
199 .recorder
200 .weight_calls_budget(<StructureWeight<T>>::find_parent());
201
202 <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 }
179211
180 /// @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 found
modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
18}18}
1919
20/// @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 0x91a97a68
22contract 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 }
76
77 // /// @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 // }
7689
77 /// @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 }
89102
modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5<!-- bureaucrate goes here -->
6
7## [v0.2.7] - 2022-11-11
8
9### Changed
10
11- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.
12
5## [v0.2.6] - 2022-11-0213## [v0.2.6] - 2022-11-02
14
6### Changed15### Changed
7 - Use named structure `EthCrossAccount` in eth functions.
816
17- Use named structure `EthCrossAccount` in eth functions.
18
9## [v0.2.5] - 2022-20-1019## [v0.2.5] - 2022-20-10
1020
11### Change21### Change
17### Change27### Change
1828
19- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.29- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.
20
21<!-- bureaucrate goes here -->
2230
23## [v0.2.3] 2022-08-1631## [v0.2.3] 2022-08-16
2432
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
1[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"
66
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
164 /// @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 }
182
183 /// @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 = keys
196 .into_iter()
197 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
198 .collect::<Result<Vec<_>>>()?;
199
200 let nesting_budget = self
201 .recorder
202 .weight_calls_budget(<StructureWeight<T>>::find_parent());
203
204 <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 }
181213
182 /// @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 found
modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
18}18}
1919
20/// @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 0x91a97a68
22contract 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 }
76
77 // /// @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 // }
7689
77 /// @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 }
89102
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
13}13}
1414
15/// @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 0x91a97a68
17interface 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;
53
54 // /// @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;
5361
54 /// @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;
6169
62 /// @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 found
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
13}13}
1414
15/// @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 0x91a97a68
17interface 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;
53
54 // /// @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;
5361
54 /// @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;
6169
62 /// @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 found
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
139 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);
141141
142 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);
144144
145 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;
147147
148 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);148 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
149149
150 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);
152152
153 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();153 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
334 {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"
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
316 {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"
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
138 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'}]);
146153
147 await collection.addAdmin(alice, {Ethereum: caller});154 await collection.addAdmin(alice, {Ethereum: caller});
148155
149 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);
151158
152 await contract.methods.deleteProperty(token.tokenId, 'testKey').send({from: caller});159 await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});
153160
154 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);