difftreelog
feature: Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.
in: master
15 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6376,7 +6376,7 @@
[[package]]
name = "pallet-nonfungible"
-version = "0.1.7"
+version = "0.1.8"
dependencies = [
"ethereum",
"evm-coder",
@@ -6498,7 +6498,7 @@
[[package]]
name = "pallet-refungible"
-version = "0.2.6"
+version = "0.2.7"
dependencies = [
"derivative",
"ethereum",
pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth1# Change Log23All notable changes to this project will be documented in this file.45<!-- bureaucrate goes here -->6## [v0.1.7] - 2022-11-027### Changed8 - Use named structure `EthCrossAccount` in eth functions.910## [v0.1.6] - 2022-20-101112### Change1314- Added `set_properties` method for `TokenProperties` interface.1516## [v0.1.5] - 2022-08-241718### Change1920- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.2122## [v0.1.4] 2022-08-162324### Other changes2526- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a2728- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf82930- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d9753132New methods allows to call `remove_prefix` with limit multiple times33in the same block34However, we don't use prefix removal limits, so upgrade is35straightforward3637Upstream-Change: https://github.com/paritytech/substrate/pull/114903839- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b4041## [0.1.2] - 2022-07-254243### Changed4445- New `token_uri` retrieval logic:4647 If the collection has a `url` property and it is not empty, it is returned.48 Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.4950 If the property `baseURI` is empty or absent, return "" (empty string)51 otherwise, if property `suffix` present and is non-empty, return concatenation of baseURI and suffix52 otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).5354## [0.1.1] - 2022-07-145556### Added5758- Implementation of RPC method `token_owners`.59 For reasons of compatibility with this pallet, returns only one owner if token exists.60 This was an internal request to improve the web interface and support fractionalization event.1# Change Log23All notable changes to this project will be documented in this file.45<!-- bureaucrate goes here -->67## [v0.1.8] - 2022-11-1189### Changed1011- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.1213## [v0.1.7] - 2022-11-021415### Changed1617- Use named structure `EthCrossAccount` in eth functions.1819## [v0.1.6] - 2022-20-102021### Change2223- Added `set_properties` method for `TokenProperties` interface.2425## [v0.1.5] - 2022-08-242627### Change2829- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.3031## [v0.1.4] 2022-08-163233### Other changes3435- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a3637- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf83839- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d9754041New methods allows to call `remove_prefix` with limit multiple times42in the same block43However, we don't use prefix removal limits, so upgrade is44straightforward4546Upstream-Change: https://github.com/paritytech/substrate/pull/114904748- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b4950## [0.1.2] - 2022-07-255152### Changed5354- New `token_uri` retrieval logic:5556 If the collection has a `url` property and it is not empty, it is returned.57 Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.5859 If the property `baseURI` is empty or absent, return "" (empty string)60 otherwise, if property `suffix` present and is non-empty, return concatenation of baseURI and suffix61 otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).6263## [0.1.1] - 2022-07-146465### Added6667- Implementation of RPC method `token_owners`.68 For reasons of compatibility with this pallet, returns only one owner if token exists.69 This was an internal request to improve the web interface and support fractionalization event.pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-nonfungible"
-version = "0.1.7"
+version = "0.1.8"
license = "GPLv3"
edition = "2021"
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -162,6 +162,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param key Property key.
+ #[solidity(hide)]
fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -177,6 +178,37 @@
.map_err(dispatch_to_evm::<T>)
}
+ /// @notice Delete token properties value.
+ /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ /// @param tokenId ID of the token.
+ /// @param keys Properties key.
+ fn delete_properties(
+ &mut self,
+ token_id: uint256,
+ caller: caller,
+ keys: Vec<string>,
+ ) -> Result<()> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
+ let keys = keys
+ .into_iter()
+ .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
+ .collect::<Result<Vec<_>>>()?;
+
+ let nesting_budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ <Pallet<T>>::delete_token_properties(
+ self,
+ &caller,
+ TokenId(token_id),
+ keys.into_iter(),
+ &nesting_budget,
+ )
+ .map_err(dispatch_to_evm::<T>)
+ }
+
/// @notice Get token property value.
/// @dev Throws error if key not found
/// @param tokenId ID of the token.
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows to set and delete token properties and change token property permissions.
-/// @dev the ERC-165 identifier for this interface is 0x55dba919
+/// @dev the ERC-165 identifier for this interface is 0x91a97a68
contract TokenProperties is Dummy, ERC165 {
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
@@ -74,16 +74,29 @@
dummy = 0;
}
- /// @notice Delete token property value.
+ // /// @notice Delete token property value.
+ // /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ // /// @param tokenId ID of the token.
+ // /// @param key Property key.
+ // /// @dev EVM selector for this function is: 0x066111d1,
+ // /// or in textual repr: deleteProperty(uint256,string)
+ // function deleteProperty(uint256 tokenId, string memory key) public {
+ // require(false, stub_error);
+ // tokenId;
+ // key;
+ // dummy = 0;
+ // }
+
+ /// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
- /// @param key Property key.
- /// @dev EVM selector for this function is: 0x066111d1,
- /// or in textual repr: deleteProperty(uint256,string)
- function deleteProperty(uint256 tokenId, string memory key) public {
+ /// @param keys Properties key.
+ /// @dev EVM selector for this function is: 0xc472d371,
+ /// or in textual repr: deleteProperties(uint256,string[])
+ function deleteProperties(uint256 tokenId, string[] memory keys) public {
require(false, stub_error);
tokenId;
- key;
+ keys;
dummy = 0;
}
pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -2,10 +2,20 @@
All notable changes to this project will be documented in this file.
+<!-- bureaucrate goes here -->
+
+## [v0.2.7] - 2022-11-11
+
+### Changed
+
+- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.
+
## [v0.2.6] - 2022-11-02
+
### Changed
- - Use named structure `EthCrossAccount` in eth functions.
+- Use named structure `EthCrossAccount` in eth functions.
+
## [v0.2.5] - 2022-20-10
### Change
@@ -17,8 +27,6 @@
### Change
- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.
-
-<!-- bureaucrate goes here -->
## [v0.2.3] 2022-08-16
pallets/refungible/Cargo.tomldiffbeforeafterboth--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-refungible"
-version = "0.2.6"
+version = "0.2.7"
license = "GPLv3"
edition = "2021"
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -164,6 +164,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param key Property key.
+ #[solidity(hide)]
fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -179,6 +180,37 @@
.map_err(dispatch_to_evm::<T>)
}
+ /// @notice Delete token properties value.
+ /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ /// @param tokenId ID of the token.
+ /// @param keys Properties key.
+ fn delete_properties(
+ &mut self,
+ token_id: uint256,
+ caller: caller,
+ keys: Vec<string>,
+ ) -> Result<()> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
+ let keys = keys
+ .into_iter()
+ .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
+ .collect::<Result<Vec<_>>>()?;
+
+ let nesting_budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ <Pallet<T>>::delete_token_properties(
+ self,
+ &caller,
+ TokenId(token_id),
+ keys.into_iter(),
+ &nesting_budget,
+ )
+ .map_err(dispatch_to_evm::<T>)
+ }
+
/// @notice Get token property value.
/// @dev Throws error if key not found
/// @param tokenId ID of the token.
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows to set and delete token properties and change token property permissions.
-/// @dev the ERC-165 identifier for this interface is 0x55dba919
+/// @dev the ERC-165 identifier for this interface is 0x91a97a68
contract TokenProperties is Dummy, ERC165 {
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
@@ -74,16 +74,29 @@
dummy = 0;
}
- /// @notice Delete token property value.
+ // /// @notice Delete token property value.
+ // /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ // /// @param tokenId ID of the token.
+ // /// @param key Property key.
+ // /// @dev EVM selector for this function is: 0x066111d1,
+ // /// or in textual repr: deleteProperty(uint256,string)
+ // function deleteProperty(uint256 tokenId, string memory key) public {
+ // require(false, stub_error);
+ // tokenId;
+ // key;
+ // dummy = 0;
+ // }
+
+ /// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
- /// @param key Property key.
- /// @dev EVM selector for this function is: 0x066111d1,
- /// or in textual repr: deleteProperty(uint256,string)
- function deleteProperty(uint256 tokenId, string memory key) public {
+ /// @param keys Properties key.
+ /// @dev EVM selector for this function is: 0xc472d371,
+ /// or in textual repr: deleteProperties(uint256,string[])
+ function deleteProperties(uint256 tokenId, string[] memory keys) public {
require(false, stub_error);
tokenId;
- key;
+ keys;
dummy = 0;
}
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows to set and delete token properties and change token property permissions.
-/// @dev the ERC-165 identifier for this interface is 0x55dba919
+/// @dev the ERC-165 identifier for this interface is 0x91a97a68
interface TokenProperties is Dummy, ERC165 {
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
@@ -51,13 +51,21 @@
/// or in textual repr: setProperties(uint256,(string,bytes)[])
function setProperties(uint256 tokenId, Tuple21[] memory properties) external;
- /// @notice Delete token property value.
+ // /// @notice Delete token property value.
+ // /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ // /// @param tokenId ID of the token.
+ // /// @param key Property key.
+ // /// @dev EVM selector for this function is: 0x066111d1,
+ // /// or in textual repr: deleteProperty(uint256,string)
+ // function deleteProperty(uint256 tokenId, string memory key) external;
+
+ /// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
- /// @param key Property key.
- /// @dev EVM selector for this function is: 0x066111d1,
- /// or in textual repr: deleteProperty(uint256,string)
- function deleteProperty(uint256 tokenId, string memory key) external;
+ /// @param keys Properties key.
+ /// @dev EVM selector for this function is: 0xc472d371,
+ /// or in textual repr: deleteProperties(uint256,string[])
+ function deleteProperties(uint256 tokenId, string[] memory keys) external;
/// @notice Get token property value.
/// @dev Throws error if key not found
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows to set and delete token properties and change token property permissions.
-/// @dev the ERC-165 identifier for this interface is 0x55dba919
+/// @dev the ERC-165 identifier for this interface is 0x91a97a68
interface TokenProperties is Dummy, ERC165 {
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
@@ -51,13 +51,21 @@
/// or in textual repr: setProperties(uint256,(string,bytes)[])
function setProperties(uint256 tokenId, Tuple20[] memory properties) external;
- /// @notice Delete token property value.
+ // /// @notice Delete token property value.
+ // /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ // /// @param tokenId ID of the token.
+ // /// @param key Property key.
+ // /// @dev EVM selector for this function is: 0x066111d1,
+ // /// or in textual repr: deleteProperty(uint256,string)
+ // function deleteProperty(uint256 tokenId, string memory key) external;
+
+ /// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
- /// @param key Property key.
- /// @dev EVM selector for this function is: 0x066111d1,
- /// or in textual repr: deleteProperty(uint256,string)
- function deleteProperty(uint256 tokenId, string memory key) external;
+ /// @param keys Properties key.
+ /// @dev EVM selector for this function is: 0xc472d371,
+ /// or in textual repr: deleteProperties(uint256,string[])
+ function deleteProperties(uint256 tokenId, string[] memory keys) external;
/// @notice Get token property value.
/// @dev Throws error if key not found
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -139,7 +139,7 @@
await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
- await contract.methods.deleteProperty(tokenId1, 'URI').send();
+ await contract.methods.deleteProperties(tokenId1, ['URI']).send();
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();
@@ -147,7 +147,7 @@
expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
- await contract.methods.deleteProperty(tokenId2, 'URI').send();
+ await contract.methods.deleteProperties(tokenId2, ['URI']).send();
expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -334,9 +334,9 @@
{
"inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
- { "internalType": "string", "name": "key", "type": "string" }
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
],
- "name": "deleteProperty",
+ "name": "deleteProperties",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -316,9 +316,9 @@
{
"inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
- { "internalType": "string", "name": "key", "type": "string" }
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
],
- "name": "deleteProperty",
+ "name": "deleteProperties",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -138,18 +138,25 @@
mutable: true,
collectionAdmin: true,
},
+ },
+ {
+ key: 'testKey_1',
+ permission: {
+ mutable: true,
+ collectionAdmin: true,
+ },
}],
});
const token = await collection.mintToken(alice);
- await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);
+ await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}, {key: 'testKey_1', value: 'testValue_1'}]);
await collection.addAdmin(alice, {Ethereum: caller});
const address = helper.ethAddress.fromCollectionId(collection.collectionId);
const contract = helper.ethNativeContract.collection(address, 'nft', caller);
- await contract.methods.deleteProperty(token.tokenId, 'testKey').send({from: caller});
+ await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});
const result = await token.getProperties(['testKey']);
expect(result.length).to.equal(0);