difftreelog
feat add delete properties
in: master
17 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -117,8 +117,6 @@
/// @param key Property key.
#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {
- self.consume_store_reads_and_writes(1, 1)?;
-
let caller = T::CrossAccountId::from_eth(caller);
let key = <Vec<u8>>::from(key)
.try_into()
@@ -127,6 +125,24 @@
<Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ #[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]
+ fn delete_collection_properties(&mut self, caller: caller, keys: Vec<string>) -> Result<()> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let keys = keys
+ .into_iter()
+ .map(|key| {
+ <Vec<u8>>::from(key)
+ .try_into()
+ .map_err(|_| Error::Revert("key too large".into()))
+ })
+ .collect::<Result<Vec<_>>>()?;
+
+ <Pallet<T>>::delete_collection_properties(self, &caller, keys).map_err(dispatch_to_evm::<T>)
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -146,28 +162,34 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
fn collection_properties(&self, keys: Vec<string>) -> Result<Vec<(string, bytes)>> {
- let mut keys_ = Vec::<PropertyKey>::with_capacity(keys.len());
- for key in keys {
- keys_.push(
+ let keys = keys
+ .into_iter()
+ .map(|key| {
<Vec<u8>>::from(key)
.try_into()
- .map_err(|_| Error::Revert("key too large".into()))?,
- )
- }
- let properties = Pallet::<T>::filter_collection_properties(self.id, Some(keys_))
- .map_err(dispatch_to_evm::<T>)?;
+ .map_err(|_| Error::Revert("key too large".into()))
+ })
+ .collect::<Result<Vec<_>>>()?;
- let mut properties_ = Vec::<(string, bytes)>::with_capacity(properties.len());
- for p in properties {
- let key =
- string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;
- let value = bytes(p.value.to_vec());
- properties_.push((key, value));
- }
- Ok(properties_)
+ let properties = Pallet::<T>::filter_collection_properties(
+ self.id,
+ if keys.is_empty() { None } else { Some(keys) },
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+
+ let properties = properties
+ .into_iter()
+ .map(|p| {
+ let key =
+ string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;
+ let value = bytes(p.value.to_vec());
+ Ok((key, value))
+ })
+ .collect::<Result<Vec<_>>>()?;
+ Ok(properties)
}
/// Set the sponsor of the collection.
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -55,6 +55,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -72,7 +83,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -91,7 +91,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -128,6 +128,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -145,7 +156,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -91,7 +91,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -128,6 +128,17 @@
dummy = 0;
}
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) public {
+ require(false, stub_error);
+ keys;
+ dummy = 0;
+ }
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -145,7 +156,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -37,6 +37,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -49,7 +56,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -62,7 +62,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -86,6 +86,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -98,7 +105,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -62,7 +62,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x5d354410
+/// @dev the ERC-165 identifier for this interface is 0xb3152af3
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -86,6 +86,13 @@
/// or in textual repr: deleteCollectionProperty(string)
function deleteCollectionProperty(string memory key) external;
+ /// Delete collection properties.
+ ///
+ /// @param keys Properties keys.
+ /// @dev EVM selector for this function is: 0xee206ee3,
+ /// or in textual repr: deleteCollectionProperties(string[])
+ function deleteCollectionProperties(string[] memory keys) external;
+
/// Get collection property.
///
/// @dev Throws error if key not found.
@@ -98,7 +105,7 @@
/// Get collection properties.
///
- /// @param keys Properties keys.
+ /// @param keys Properties keys. Empty keys for all propertyes.
/// @return Vector of properties key/value pairs.
/// @dev EVM selector for this function is: 0x285fb8e6,
/// or in textual repr: collectionProperties(string[])
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -16,7 +16,7 @@
import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
import {Pallets} from '../util';
-import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
+import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
import {IKeyringPair} from '@polkadot/types/types';
describe('EVM collection properties', () => {
@@ -163,29 +163,89 @@
});
describe('EVM collection property', () => {
- itEth('Set/read properties', async ({helper, privateKey}) => {
- const alice = await privateKey('//Alice');
- const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+ let alice: IKeyringPair;
+
+ before(() => {
+ usingEthPlaygrounds(async (_helper, privateKey) => {
+ alice = await privateKey('//Alice');
+ });
+ });
+
+ async function testSetReadProperties(helper: EthUniqueHelper, mode: TCollectionMode) {
+ const collection = await helper[mode].mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
const sender = await helper.eth.createAccountWithBalance(alice, 100n);
await collection.addAdmin(alice, {Ethereum: sender});
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
- const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', sender);
+ const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);
- const key1 = 'key1';
- const value1 = Buffer.from('value1');
-
- const key2 = 'key2';
- const value2 = Buffer.from('value2');
+ const keys = ['key0', 'key1'];
const writeProperties = [
- [key1, '0x'+value1.toString('hex')],
- [key2, '0x'+value2.toString('hex')],
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
];
await contract.methods.setCollectionProperties(writeProperties).send();
- const readProperties = await contract.methods.collectionProperties([key1, key2]).call();
+ const readProperties = await contract.methods.collectionProperties([keys[0], keys[1]]).call();
expect(readProperties).to.be.like(writeProperties);
+ }
+
+ itEth('Set/read properties ft', async ({helper}) => {
+ await testSetReadProperties(helper, 'ft');
+ });
+ itEth('Set/read properties rft', async ({helper}) => {
+ await testSetReadProperties(helper, 'rft');
+ });
+ itEth('Set/read properties nft', async ({helper}) => {
+ await testSetReadProperties(helper, 'nft');
+ });
+
+ async function testDeleteProperties(helper: EthUniqueHelper, mode: TCollectionMode) {
+ const collection = await helper[mode].mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+ const sender = await helper.eth.createAccountWithBalance(alice, 100n);
+ await collection.addAdmin(alice, {Ethereum: sender});
+
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);
+
+ const keys = ['key0', 'key1', 'key2', 'key3'];
+
+ {
+ const writeProperties = [
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
+ helper.ethProperty.property(keys[2], 'value2'),
+ helper.ethProperty.property(keys[3], 'value3'),
+ ];
+
+ await contract.methods.setCollectionProperties(writeProperties).send();
+ const readProperties = await contract.methods.collectionProperties([keys[0], keys[1], keys[2], keys[3]]).call();
+ expect(readProperties).to.be.like(writeProperties);
+ }
+
+ {
+ const expectProperties = [
+ helper.ethProperty.property(keys[0], 'value0'),
+ helper.ethProperty.property(keys[1], 'value1'),
+ ];
+
+ await contract.methods.deleteCollectionProperties([keys[2], keys[3]]).send();
+ const readProperties = await contract.methods.collectionProperties([]).call();
+ expect(readProperties).to.be.like(expectProperties);
+ }
+ }
+
+ itEth('Delete properties ft', async ({helper}) => {
+ await testDeleteProperties(helper, 'ft');
+ });
+ itEth('Delete properties rft', async ({helper}) => {
+ await testDeleteProperties(helper, 'rft');
});
+ itEth('Delete properties nft', async ({helper}) => {
+ await testDeleteProperties(helper, 'nft');
+ });
+
});
tests/src/eth/fungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -293,6 +293,15 @@
"type": "function"
},
{
+ "inputs": [
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
+ ],
+ "name": "deleteCollectionProperties",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "approved",15 "type": "address"16 },17 {18 "indexed": true,19 "internalType": "uint256",20 "name": "tokenId",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "owner",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "operator",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "bool",45 "name": "approved",46 "type": "bool"47 }48 ],49 "name": "ApprovalForAll",50 "type": "event"51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {59 "anonymous": false,60 "inputs": [61 {62 "indexed": true,63 "internalType": "address",64 "name": "from",65 "type": "address"66 },67 {68 "indexed": true,69 "internalType": "address",70 "name": "to",71 "type": "address"72 },73 {74 "indexed": true,75 "internalType": "uint256",76 "name": "tokenId",77 "type": "uint256"78 }79 ],80 "name": "Transfer",81 "type": "event"82 },83 {84 "inputs": [85 { "internalType": "address", "name": "newAdmin", "type": "address" }86 ],87 "name": "addCollectionAdmin",88 "outputs": [],89 "stateMutability": "nonpayable",90 "type": "function"91 },92 {93 "inputs": [94 {95 "components": [96 { "internalType": "address", "name": "field_0", "type": "address" },97 { "internalType": "uint256", "name": "field_1", "type": "uint256" }98 ],99 "internalType": "struct Tuple6",100 "name": "newAdmin",101 "type": "tuple"102 }103 ],104 "name": "addCollectionAdminCross",105 "outputs": [],106 "stateMutability": "nonpayable",107 "type": "function"108 },109 {110 "inputs": [111 { "internalType": "address", "name": "user", "type": "address" }112 ],113 "name": "addToCollectionAllowList",114 "outputs": [],115 "stateMutability": "nonpayable",116 "type": "function"117 },118 {119 "inputs": [120 {121 "components": [122 { "internalType": "address", "name": "field_0", "type": "address" },123 { "internalType": "uint256", "name": "field_1", "type": "uint256" }124 ],125 "internalType": "struct Tuple6",126 "name": "user",127 "type": "tuple"128 }129 ],130 "name": "addToCollectionAllowListCross",131 "outputs": [],132 "stateMutability": "nonpayable",133 "type": "function"134 },135 {136 "inputs": [137 { "internalType": "address", "name": "user", "type": "address" }138 ],139 "name": "allowed",140 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],141 "stateMutability": "view",142 "type": "function"143 },144 {145 "inputs": [146 { "internalType": "address", "name": "approved", "type": "address" },147 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }148 ],149 "name": "approve",150 "outputs": [],151 "stateMutability": "nonpayable",152 "type": "function"153 },154 {155 "inputs": [156 {157 "components": [158 { "internalType": "address", "name": "field_0", "type": "address" },159 { "internalType": "uint256", "name": "field_1", "type": "uint256" }160 ],161 "internalType": "struct Tuple6",162 "name": "approved",163 "type": "tuple"164 },165 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }166 ],167 "name": "approveCross",168 "outputs": [],169 "stateMutability": "nonpayable",170 "type": "function"171 },172 {173 "inputs": [174 { "internalType": "address", "name": "owner", "type": "address" }175 ],176 "name": "balanceOf",177 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],178 "stateMutability": "view",179 "type": "function"180 },181 {182 "inputs": [183 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }184 ],185 "name": "burn",186 "outputs": [],187 "stateMutability": "nonpayable",188 "type": "function"189 },190 {191 "inputs": [192 { "internalType": "address", "name": "from", "type": "address" },193 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }194 ],195 "name": "burnFrom",196 "outputs": [],197 "stateMutability": "nonpayable",198 "type": "function"199 },200 {201 "inputs": [202 {203 "components": [204 { "internalType": "address", "name": "field_0", "type": "address" },205 { "internalType": "uint256", "name": "field_1", "type": "uint256" }206 ],207 "internalType": "struct Tuple6",208 "name": "from",209 "type": "tuple"210 },211 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }212 ],213 "name": "burnFromCross",214 "outputs": [],215 "stateMutability": "nonpayable",216 "type": "function"217 },218 {219 "inputs": [220 { "internalType": "address", "name": "newOwner", "type": "address" }221 ],222 "name": "changeCollectionOwner",223 "outputs": [],224 "stateMutability": "nonpayable",225 "type": "function"226 },227 {228 "inputs": [],229 "name": "collectionAdmins",230 "outputs": [231 {232 "components": [233 { "internalType": "address", "name": "field_0", "type": "address" },234 { "internalType": "uint256", "name": "field_1", "type": "uint256" }235 ],236 "internalType": "struct Tuple6[]",237 "name": "",238 "type": "tuple[]"239 }240 ],241 "stateMutability": "view",242 "type": "function"243 },244 {245 "inputs": [],246 "name": "collectionOwner",247 "outputs": [248 {249 "components": [250 { "internalType": "address", "name": "field_0", "type": "address" },251 { "internalType": "uint256", "name": "field_1", "type": "uint256" }252 ],253 "internalType": "struct Tuple6",254 "name": "",255 "type": "tuple"256 }257 ],258 "stateMutability": "view",259 "type": "function"260 },261 {262 "inputs": [263 { "internalType": "string[]", "name": "keys", "type": "string[]" }264 ],265 "name": "collectionProperties",266 "outputs": [267 {268 "components": [269 { "internalType": "string", "name": "field_0", "type": "string" },270 { "internalType": "bytes", "name": "field_1", "type": "bytes" }271 ],272 "internalType": "struct Tuple19[]",273 "name": "",274 "type": "tuple[]"275 }276 ],277 "stateMutability": "view",278 "type": "function"279 },280 {281 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],282 "name": "collectionProperty",283 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],284 "stateMutability": "view",285 "type": "function"286 },287 {288 "inputs": [],289 "name": "collectionSponsor",290 "outputs": [291 {292 "components": [293 { "internalType": "address", "name": "field_0", "type": "address" },294 { "internalType": "uint256", "name": "field_1", "type": "uint256" }295 ],296 "internalType": "struct Tuple6",297 "name": "",298 "type": "tuple"299 }300 ],301 "stateMutability": "view",302 "type": "function"303 },304 {305 "inputs": [],306 "name": "confirmCollectionSponsorship",307 "outputs": [],308 "stateMutability": "nonpayable",309 "type": "function"310 },311 {312 "inputs": [],313 "name": "contractAddress",314 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],315 "stateMutability": "view",316 "type": "function"317 },318 {319 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],320 "name": "deleteCollectionProperty",321 "outputs": [],322 "stateMutability": "nonpayable",323 "type": "function"324 },325 {326 "inputs": [327 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },328 { "internalType": "string", "name": "key", "type": "string" }329 ],330 "name": "deleteProperty",331 "outputs": [],332 "stateMutability": "nonpayable",333 "type": "function"334 },335 {336 "inputs": [],337 "name": "finishMinting",338 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],339 "stateMutability": "nonpayable",340 "type": "function"341 },342 {343 "inputs": [344 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }345 ],346 "name": "getApproved",347 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],348 "stateMutability": "view",349 "type": "function"350 },351 {352 "inputs": [],353 "name": "hasCollectionPendingSponsor",354 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],355 "stateMutability": "view",356 "type": "function"357 },358 {359 "inputs": [360 { "internalType": "address", "name": "owner", "type": "address" },361 { "internalType": "address", "name": "operator", "type": "address" }362 ],363 "name": "isApprovedForAll",364 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],365 "stateMutability": "view",366 "type": "function"367 },368 {369 "inputs": [370 { "internalType": "address", "name": "user", "type": "address" }371 ],372 "name": "isOwnerOrAdmin",373 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],374 "stateMutability": "view",375 "type": "function"376 },377 {378 "inputs": [379 {380 "components": [381 { "internalType": "address", "name": "field_0", "type": "address" },382 { "internalType": "uint256", "name": "field_1", "type": "uint256" }383 ],384 "internalType": "struct Tuple6",385 "name": "user",386 "type": "tuple"387 }388 ],389 "name": "isOwnerOrAdminCross",390 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],391 "stateMutability": "view",392 "type": "function"393 },394 {395 "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],396 "name": "mint",397 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],398 "stateMutability": "nonpayable",399 "type": "function"400 },401 {402 "inputs": [403 { "internalType": "address", "name": "to", "type": "address" },404 { "internalType": "string", "name": "tokenUri", "type": "string" }405 ],406 "name": "mintWithTokenURI",407 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],408 "stateMutability": "nonpayable",409 "type": "function"410 },411 {412 "inputs": [],413 "name": "mintingFinished",414 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],415 "stateMutability": "view",416 "type": "function"417 },418 {419 "inputs": [],420 "name": "name",421 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],422 "stateMutability": "view",423 "type": "function"424 },425 {426 "inputs": [],427 "name": "nextTokenId",428 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],429 "stateMutability": "view",430 "type": "function"431 },432 {433 "inputs": [434 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }435 ],436 "name": "ownerOf",437 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],438 "stateMutability": "view",439 "type": "function"440 },441 {442 "inputs": [443 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },444 { "internalType": "string", "name": "key", "type": "string" }445 ],446 "name": "property",447 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],448 "stateMutability": "view",449 "type": "function"450 },451 {452 "inputs": [453 { "internalType": "address", "name": "admin", "type": "address" }454 ],455 "name": "removeCollectionAdmin",456 "outputs": [],457 "stateMutability": "nonpayable",458 "type": "function"459 },460 {461 "inputs": [462 {463 "components": [464 { "internalType": "address", "name": "field_0", "type": "address" },465 { "internalType": "uint256", "name": "field_1", "type": "uint256" }466 ],467 "internalType": "struct Tuple6",468 "name": "admin",469 "type": "tuple"470 }471 ],472 "name": "removeCollectionAdminCross",473 "outputs": [],474 "stateMutability": "nonpayable",475 "type": "function"476 },477 {478 "inputs": [],479 "name": "removeCollectionSponsor",480 "outputs": [],481 "stateMutability": "nonpayable",482 "type": "function"483 },484 {485 "inputs": [486 { "internalType": "address", "name": "user", "type": "address" }487 ],488 "name": "removeFromCollectionAllowList",489 "outputs": [],490 "stateMutability": "nonpayable",491 "type": "function"492 },493 {494 "inputs": [495 {496 "components": [497 { "internalType": "address", "name": "field_0", "type": "address" },498 { "internalType": "uint256", "name": "field_1", "type": "uint256" }499 ],500 "internalType": "struct Tuple6",501 "name": "user",502 "type": "tuple"503 }504 ],505 "name": "removeFromCollectionAllowListCross",506 "outputs": [],507 "stateMutability": "nonpayable",508 "type": "function"509 },510 {511 "inputs": [512 { "internalType": "address", "name": "from", "type": "address" },513 { "internalType": "address", "name": "to", "type": "address" },514 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }515 ],516 "name": "safeTransferFrom",517 "outputs": [],518 "stateMutability": "nonpayable",519 "type": "function"520 },521 {522 "inputs": [523 { "internalType": "address", "name": "from", "type": "address" },524 { "internalType": "address", "name": "to", "type": "address" },525 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },526 { "internalType": "bytes", "name": "data", "type": "bytes" }527 ],528 "name": "safeTransferFrom",529 "outputs": [],530 "stateMutability": "nonpayable",531 "type": "function"532 },533 {534 "inputs": [535 { "internalType": "address", "name": "operator", "type": "address" },536 { "internalType": "bool", "name": "approved", "type": "bool" }537 ],538 "name": "setApprovalForAll",539 "outputs": [],540 "stateMutability": "nonpayable",541 "type": "function"542 },543 {544 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],545 "name": "setCollectionAccess",546 "outputs": [],547 "stateMutability": "nonpayable",548 "type": "function"549 },550 {551 "inputs": [552 { "internalType": "string", "name": "limit", "type": "string" },553 { "internalType": "uint32", "name": "value", "type": "uint32" }554 ],555 "name": "setCollectionLimit",556 "outputs": [],557 "stateMutability": "nonpayable",558 "type": "function"559 },560 {561 "inputs": [562 { "internalType": "string", "name": "limit", "type": "string" },563 { "internalType": "bool", "name": "value", "type": "bool" }564 ],565 "name": "setCollectionLimit",566 "outputs": [],567 "stateMutability": "nonpayable",568 "type": "function"569 },570 {571 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],572 "name": "setCollectionMintMode",573 "outputs": [],574 "stateMutability": "nonpayable",575 "type": "function"576 },577 {578 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],579 "name": "setCollectionNesting",580 "outputs": [],581 "stateMutability": "nonpayable",582 "type": "function"583 },584 {585 "inputs": [586 { "internalType": "bool", "name": "enable", "type": "bool" },587 {588 "internalType": "address[]",589 "name": "collections",590 "type": "address[]"591 }592 ],593 "name": "setCollectionNesting",594 "outputs": [],595 "stateMutability": "nonpayable",596 "type": "function"597 },598 {599 "inputs": [600 {601 "components": [602 { "internalType": "string", "name": "field_0", "type": "string" },603 { "internalType": "bytes", "name": "field_1", "type": "bytes" }604 ],605 "internalType": "struct Tuple19[]",606 "name": "properties",607 "type": "tuple[]"608 }609 ],610 "name": "setCollectionProperties",611 "outputs": [],612 "stateMutability": "nonpayable",613 "type": "function"614 },615 {616 "inputs": [617 { "internalType": "string", "name": "key", "type": "string" },618 { "internalType": "bytes", "name": "value", "type": "bytes" }619 ],620 "name": "setCollectionProperty",621 "outputs": [],622 "stateMutability": "nonpayable",623 "type": "function"624 },625 {626 "inputs": [627 { "internalType": "address", "name": "sponsor", "type": "address" }628 ],629 "name": "setCollectionSponsor",630 "outputs": [],631 "stateMutability": "nonpayable",632 "type": "function"633 },634 {635 "inputs": [636 {637 "components": [638 { "internalType": "address", "name": "field_0", "type": "address" },639 { "internalType": "uint256", "name": "field_1", "type": "uint256" }640 ],641 "internalType": "struct Tuple6",642 "name": "sponsor",643 "type": "tuple"644 }645 ],646 "name": "setCollectionSponsorCross",647 "outputs": [],648 "stateMutability": "nonpayable",649 "type": "function"650 },651 {652 "inputs": [653 {654 "components": [655 { "internalType": "address", "name": "field_0", "type": "address" },656 { "internalType": "uint256", "name": "field_1", "type": "uint256" }657 ],658 "internalType": "struct Tuple6",659 "name": "newOwner",660 "type": "tuple"661 }662 ],663 "name": "setOwnerCross",664 "outputs": [],665 "stateMutability": "nonpayable",666 "type": "function"667 },668 {669 "inputs": [670 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },671 { "internalType": "string", "name": "key", "type": "string" },672 { "internalType": "bytes", "name": "value", "type": "bytes" }673 ],674 "name": "setProperty",675 "outputs": [],676 "stateMutability": "nonpayable",677 "type": "function"678 },679 {680 "inputs": [681 { "internalType": "string", "name": "key", "type": "string" },682 { "internalType": "bool", "name": "isMutable", "type": "bool" },683 { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },684 { "internalType": "bool", "name": "tokenOwner", "type": "bool" }685 ],686 "name": "setTokenPropertyPermission",687 "outputs": [],688 "stateMutability": "nonpayable",689 "type": "function"690 },691 {692 "inputs": [693 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }694 ],695 "name": "supportsInterface",696 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],697 "stateMutability": "view",698 "type": "function"699 },700 {701 "inputs": [],702 "name": "symbol",703 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],704 "stateMutability": "view",705 "type": "function"706 },707 {708 "inputs": [709 { "internalType": "uint256", "name": "index", "type": "uint256" }710 ],711 "name": "tokenByIndex",712 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],713 "stateMutability": "view",714 "type": "function"715 },716 {717 "inputs": [718 { "internalType": "address", "name": "owner", "type": "address" },719 { "internalType": "uint256", "name": "index", "type": "uint256" }720 ],721 "name": "tokenOfOwnerByIndex",722 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],723 "stateMutability": "view",724 "type": "function"725 },726 {727 "inputs": [728 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }729 ],730 "name": "tokenURI",731 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],732 "stateMutability": "view",733 "type": "function"734 },735 {736 "inputs": [],737 "name": "totalSupply",738 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],739 "stateMutability": "view",740 "type": "function"741 },742 {743 "inputs": [744 { "internalType": "address", "name": "to", "type": "address" },745 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }746 ],747 "name": "transfer",748 "outputs": [],749 "stateMutability": "nonpayable",750 "type": "function"751 },752 {753 "inputs": [754 { "internalType": "address", "name": "from", "type": "address" },755 { "internalType": "address", "name": "to", "type": "address" },756 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }757 ],758 "name": "transferFrom",759 "outputs": [],760 "stateMutability": "nonpayable",761 "type": "function"762 },763 {764 "inputs": [765 {766 "components": [767 { "internalType": "address", "name": "field_0", "type": "address" },768 { "internalType": "uint256", "name": "field_1", "type": "uint256" }769 ],770 "internalType": "struct Tuple6",771 "name": "from",772 "type": "tuple"773 },774 {775 "components": [776 { "internalType": "address", "name": "field_0", "type": "address" },777 { "internalType": "uint256", "name": "field_1", "type": "uint256" }778 ],779 "internalType": "struct Tuple6",780 "name": "to",781 "type": "tuple"782 },783 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }784 ],785 "name": "transferFromCross",786 "outputs": [],787 "stateMutability": "nonpayable",788 "type": "function"789 },790 {791 "inputs": [],792 "name": "uniqueCollectionType",793 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],794 "stateMutability": "view",795 "type": "function"796 }797]tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -298,6 +298,15 @@
"type": "function"
},
{
+ "inputs": [
+ { "internalType": "string[]", "name": "keys", "type": "string[]" }
+ ],
+ "name": "deleteCollectionProperties",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -19,3 +19,6 @@
readonly field_0: string,
readonly field_1: string | Uint8Array,
}
+
+export type EthProperty = string[];
+
tests/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
@@ -18,7 +18,7 @@
import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';
-import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent} from './types';
+import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';
// Native contracts ABI
import collectionHelpersAbi from '../../collectionHelpersAbi.json';
@@ -28,6 +28,7 @@
import refungibleTokenAbi from '../../reFungibleTokenAbi.json';
import contractHelpersAbi from './../contractHelpersAbi.json';
import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
+import {TCollectionMode} from '../../../util/playgrounds/types';
class EthGroupBase {
helper: EthUniqueHelper;
@@ -107,7 +108,7 @@
return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});
}
- collection(address: string, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {
+ collection(address: string, mode: TCollectionMode, caller?: string): Contract {
const abi = {
'nft': nonFungibleAbi,
'rft': refungibleAbi,
@@ -336,8 +337,16 @@
normalizeAddress(address: string): string {
return '0x' + address.substring(address.length - 40);
}
-}
+}
+export class EthPropertyGroup extends EthGroupBase {
+ property(key: string, value: string): EthProperty {
+ return [
+ key,
+ '0x'+Buffer.from(value).toString('hex'),
+ ];
+ }
+}
export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
export class EthCrossAccountGroup extends EthGroupBase {
@@ -369,6 +378,7 @@
ethNativeContract: NativeContractGroup;
ethContract: ContractGroup;
ethCrossAccount: EthCrossAccountGroup;
+ ethProperty: EthPropertyGroup;
constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
options.helperBase = options.helperBase ?? EthUniqueHelper;
@@ -379,6 +389,7 @@
this.ethCrossAccount = new EthCrossAccountGroup(this);
this.ethNativeContract = new NativeContractGroup(this);
this.ethContract = new ContractGroup(this);
+ this.ethProperty = new EthPropertyGroup(this);
}
getWeb3(): Web3 {
tests/src/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -224,3 +224,4 @@
export type TRelayNetworks = 'rococo' | 'westend';
export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;
export type TSigner = IKeyringPair; // | 'string'
+export type TCollectionMode = 'nft' | 'rft' | 'ft';