difftreelog
fix rft test
in: master
6 files changed
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
@@ -18,30 +18,45 @@
}
/// @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 0x91a97a68
+/// @dev the ERC-165 identifier for this interface is 0xde0695c2
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.
+ // /// @param key Property key.
+ // /// @param isMutable Permission to mutate property.
+ // /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.
+ // /// @param tokenOwner Permission to mutate property by token owner if property is mutable.
+ // /// @dev EVM selector for this function is: 0x222d97fa,
+ // /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)
+ // function setTokenPropertyPermission(string memory key, bool isMutable, bool collectionAdmin, bool tokenOwner) public {
+ // require(false, stub_error);
+ // key;
+ // isMutable;
+ // collectionAdmin;
+ // tokenOwner;
+ // dummy = 0;
+ // }
+
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
- /// @param key Property key.
- /// @param isMutable Permission to mutate property.
- /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.
- /// @param tokenOwner Permission to mutate property by token owner if property is mutable.
- /// @dev EVM selector for this function is: 0x222d97fa,
- /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)
- function setTokenPropertyPermission(
- string memory key,
- bool isMutable,
- bool collectionAdmin,
- bool tokenOwner
- ) public {
+ /// @param permissions Permissions for keys.
+ /// @dev EVM selector for this function is: 0xbd92983a,
+ /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
+ function setTokenPropertyPermissions(Tuple53[] memory permissions) public {
require(false, stub_error);
- key;
- isMutable;
- collectionAdmin;
- tokenOwner;
+ permissions;
dummy = 0;
}
+ /// @notice Get permissions for token properties.
+ /// @dev EVM selector for this function is: 0xf23d7790,
+ /// or in textual repr: tokenPropertyPermissions()
+ function tokenPropertyPermissions() public view returns (Tuple53[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple53[](0);
+ }
+
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
// /// @param tokenId ID of the token.
@@ -118,6 +133,24 @@
bytes value;
}
+enum EthTokenPermissions {
+ Mutable,
+ TokenOwner,
+ CollectionAdmin
+}
+
+/// @dev anonymous struct
+struct Tuple53 {
+ string field_0;
+ Tuple51[] field_1;
+}
+
+/// @dev anonymous struct
+struct Tuple51 {
+ EthTokenPermissions field_0;
+ bool field_1;
+}
+
/// @title A contract that allows you to work with collections.
/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
contract Collection is Dummy, ERC165 {
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -679,12 +679,29 @@
},
{
"inputs": [
- { "internalType": "string", "name": "key", "type": "string" },
- { "internalType": "bool", "name": "isMutable", "type": "bool" },
- { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },
- { "internalType": "bool", "name": "tokenOwner", "type": "bool" }
+ {
+ "components": [
+ { "internalType": "string", "name": "field_0", "type": "string" },
+ {
+ "components": [
+ {
+ "internalType": "enum EthTokenPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple51[]",
+ "name": "field_1",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct Tuple53[]",
+ "name": "permissions",
+ "type": "tuple[]"
+ }
],
- "name": "setTokenPropertyPermission",
+ "name": "setTokenPropertyPermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
@@ -734,6 +751,35 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "tokenPropertyPermissions",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "string", "name": "field_0", "type": "string" },
+ {
+ "components": [
+ {
+ "internalType": "enum EthTokenPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple51[]",
+ "name": "field_1",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct Tuple53[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7interface Dummy {89}1011interface ERC165 is Dummy {12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}1415/// @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 0x91a97a6817interface TokenProperties is Dummy, ERC165 {18 /// @notice Set permissions for token property.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.20 /// @param key Property key.21 /// @param isMutable Permission to mutate property.22 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.23 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.24 /// @dev EVM selector for this function is: 0x222d97fa,25 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)26 function setTokenPropertyPermission(27 string memory key,28 bool isMutable,29 bool collectionAdmin,30 bool tokenOwner31 ) external;3233 // /// @notice Set token property value.34 // /// @dev Throws error if `msg.sender` has no permission to edit the property.35 // /// @param tokenId ID of the token.36 // /// @param key Property key.37 // /// @param value Property value.38 // /// @dev EVM selector for this function is: 0x1752d67b,39 // /// or in textual repr: setProperty(uint256,string,bytes)40 // function setProperty(uint256 tokenId, string memory key, bytes memory value) external;4142 /// @notice Set token properties value.43 /// @dev Throws error if `msg.sender` has no permission to edit the property.44 /// @param tokenId ID of the token.45 /// @param properties settable properties46 /// @dev EVM selector for this function is: 0x14ed3a6e,47 /// or in textual repr: setProperties(uint256,(string,bytes)[])48 function setProperties(uint256 tokenId, Property[] memory properties) external;4950 // /// @notice Delete token property value.51 // /// @dev Throws error if `msg.sender` has no permission to edit the property.52 // /// @param tokenId ID of the token.53 // /// @param key Property key.54 // /// @dev EVM selector for this function is: 0x066111d1,55 // /// or in textual repr: deleteProperty(uint256,string)56 // function deleteProperty(uint256 tokenId, string memory key) external;5758 /// @notice Delete token properties value.59 /// @dev Throws error if `msg.sender` has no permission to edit the property.60 /// @param tokenId ID of the token.61 /// @param keys Properties key.62 /// @dev EVM selector for this function is: 0xc472d371,63 /// or in textual repr: deleteProperties(uint256,string[])64 function deleteProperties(uint256 tokenId, string[] memory keys) external;6566 /// @notice Get token property value.67 /// @dev Throws error if key not found68 /// @param tokenId ID of the token.69 /// @param key Property key.70 /// @return Property value bytes71 /// @dev EVM selector for this function is: 0x7228c327,72 /// or in textual repr: property(uint256,string)73 function property(uint256 tokenId, string memory key) external view returns (bytes memory);74}7576/// @dev Property struct77struct Property {78 string key;79 bytes value;80}8182/// @title A contract that allows you to work with collections.83/// @dev the ERC-165 identifier for this interface is 0xb5e1747f84interface Collection is Dummy, ERC165 {85 // /// Set collection property.86 // ///87 // /// @param key Property key.88 // /// @param value Propery value.89 // /// @dev EVM selector for this function is: 0x2f073f66,90 // /// or in textual repr: setCollectionProperty(string,bytes)91 // function setCollectionProperty(string memory key, bytes memory value) external;9293 /// Set collection properties.94 ///95 /// @param properties Vector of properties key/value pair.96 /// @dev EVM selector for this function is: 0x50b26b2a,97 /// or in textual repr: setCollectionProperties((string,bytes)[])98 function setCollectionProperties(Property[] memory properties) external;99100 // /// Delete collection property.101 // ///102 // /// @param key Property key.103 // /// @dev EVM selector for this function is: 0x7b7debce,104 // /// or in textual repr: deleteCollectionProperty(string)105 // function deleteCollectionProperty(string memory key) external;106107 /// Delete collection properties.108 ///109 /// @param keys Properties keys.110 /// @dev EVM selector for this function is: 0xee206ee3,111 /// or in textual repr: deleteCollectionProperties(string[])112 function deleteCollectionProperties(string[] memory keys) external;113114 /// Get collection property.115 ///116 /// @dev Throws error if key not found.117 ///118 /// @param key Property key.119 /// @return bytes The property corresponding to the key.120 /// @dev EVM selector for this function is: 0xcf24fd6d,121 /// or in textual repr: collectionProperty(string)122 function collectionProperty(string memory key) external view returns (bytes memory);123124 /// Get collection properties.125 ///126 /// @param keys Properties keys. Empty keys for all propertyes.127 /// @return Vector of properties key/value pairs.128 /// @dev EVM selector for this function is: 0x285fb8e6,129 /// or in textual repr: collectionProperties(string[])130 function collectionProperties(string[] memory keys) external view returns (Property[] memory);131132 // /// Set the sponsor of the collection.133 // ///134 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.135 // ///136 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.137 // /// @dev EVM selector for this function is: 0x7623402e,138 // /// or in textual repr: setCollectionSponsor(address)139 // function setCollectionSponsor(address sponsor) external;140141 /// Set the sponsor of the collection.142 ///143 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.144 ///145 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.146 /// @dev EVM selector for this function is: 0x84a1d5a8,147 /// or in textual repr: setCollectionSponsorCross((address,uint256))148 function setCollectionSponsorCross(EthCrossAccount memory sponsor) external;149150 /// Whether there is a pending sponsor.151 /// @dev EVM selector for this function is: 0x058ac185,152 /// or in textual repr: hasCollectionPendingSponsor()153 function hasCollectionPendingSponsor() external view returns (bool);154155 /// Collection sponsorship confirmation.156 ///157 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.158 /// @dev EVM selector for this function is: 0x3c50e97a,159 /// or in textual repr: confirmCollectionSponsorship()160 function confirmCollectionSponsorship() external;161162 /// Remove collection sponsor.163 /// @dev EVM selector for this function is: 0x6e0326a3,164 /// or in textual repr: removeCollectionSponsor()165 function removeCollectionSponsor() external;166167 /// Get current sponsor.168 ///169 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.170 /// @dev EVM selector for this function is: 0x6ec0a9f1,171 /// or in textual repr: collectionSponsor()172 function collectionSponsor() external view returns (Tuple26 memory);173174 /// Set limits for the collection.175 /// @dev Throws error if limit not found.176 /// @param limit Name of the limit. Valid names:177 /// "accountTokenOwnershipLimit",178 /// "sponsoredDataSize",179 /// "sponsoredDataRateLimit",180 /// "tokenLimit",181 /// "sponsorTransferTimeout",182 /// "sponsorApproveTimeout"183 /// "ownerCanTransfer",184 /// "ownerCanDestroy",185 /// "transfersEnabled"186 /// @param value Value of the limit.187 /// @dev EVM selector for this function is: 0x4ad890a8,188 /// or in textual repr: setCollectionLimit(string,uint256)189 function setCollectionLimit(string memory limit, uint256 value) external;190191 /// Get contract address.192 /// @dev EVM selector for this function is: 0xf6b4dfb4,193 /// or in textual repr: contractAddress()194 function contractAddress() external view returns (address);195196 /// Add collection admin.197 /// @param newAdmin Cross account administrator address.198 /// @dev EVM selector for this function is: 0x859aa7d6,199 /// or in textual repr: addCollectionAdminCross((address,uint256))200 function addCollectionAdminCross(EthCrossAccount memory newAdmin) external;201202 /// Remove collection admin.203 /// @param admin Cross account administrator address.204 /// @dev EVM selector for this function is: 0x6c0cd173,205 /// or in textual repr: removeCollectionAdminCross((address,uint256))206 function removeCollectionAdminCross(EthCrossAccount memory admin) external;207208 // /// Add collection admin.209 // /// @param newAdmin Address of the added administrator.210 // /// @dev EVM selector for this function is: 0x92e462c7,211 // /// or in textual repr: addCollectionAdmin(address)212 // function addCollectionAdmin(address newAdmin) external;213214 // /// Remove collection admin.215 // ///216 // /// @param admin Address of the removed administrator.217 // /// @dev EVM selector for this function is: 0xfafd7b42,218 // /// or in textual repr: removeCollectionAdmin(address)219 // function removeCollectionAdmin(address admin) external;220221 /// Toggle accessibility of collection nesting.222 ///223 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'224 /// @dev EVM selector for this function is: 0x112d4586,225 /// or in textual repr: setCollectionNesting(bool)226 function setCollectionNesting(bool enable) external;227228 /// Toggle accessibility of collection nesting.229 ///230 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'231 /// @param collections Addresses of collections that will be available for nesting.232 /// @dev EVM selector for this function is: 0x64872396,233 /// or in textual repr: setCollectionNesting(bool,address[])234 function setCollectionNesting(bool enable, address[] memory collections) external;235236 /// Returns nesting for a collection237 /// @dev EVM selector for this function is: 0x22d25bfe,238 /// or in textual repr: collectionNestingRestrictedCollectionIds()239 function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 memory);240241 /// Returns permissions for a collection242 /// @dev EVM selector for this function is: 0x5b2eaf4b,243 /// or in textual repr: collectionNestingPermissions()244 function collectionNestingPermissions() external view returns (Tuple33[] memory);245246 /// Set the collection access method.247 /// @param mode Access mode248 /// 0 for Normal249 /// 1 for AllowList250 /// @dev EVM selector for this function is: 0x41835d4c,251 /// or in textual repr: setCollectionAccess(uint8)252 function setCollectionAccess(uint8 mode) external;253254 /// Checks that user allowed to operate with collection.255 ///256 /// @param user User address to check.257 /// @dev EVM selector for this function is: 0x91b6df49,258 /// or in textual repr: allowlistedCross((address,uint256))259 function allowlistedCross(EthCrossAccount memory user) external view returns (bool);260261 // /// Add the user to the allowed list.262 // ///263 // /// @param user Address of a trusted user.264 // /// @dev EVM selector for this function is: 0x67844fe6,265 // /// or in textual repr: addToCollectionAllowList(address)266 // function addToCollectionAllowList(address user) external;267268 /// Add user to allowed list.269 ///270 /// @param user User cross account address.271 /// @dev EVM selector for this function is: 0xa0184a3a,272 /// or in textual repr: addToCollectionAllowListCross((address,uint256))273 function addToCollectionAllowListCross(EthCrossAccount memory user) external;274275 // /// Remove the user from the allowed list.276 // ///277 // /// @param user Address of a removed user.278 // /// @dev EVM selector for this function is: 0x85c51acb,279 // /// or in textual repr: removeFromCollectionAllowList(address)280 // function removeFromCollectionAllowList(address user) external;281282 /// Remove user from allowed list.283 ///284 /// @param user User cross account address.285 /// @dev EVM selector for this function is: 0x09ba452a,286 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))287 function removeFromCollectionAllowListCross(EthCrossAccount memory user) external;288289 /// Switch permission for minting.290 ///291 /// @param mode Enable if "true".292 /// @dev EVM selector for this function is: 0x00018e84,293 /// or in textual repr: setCollectionMintMode(bool)294 function setCollectionMintMode(bool mode) external;295296 // /// Check that account is the owner or admin of the collection297 // ///298 // /// @param user account to verify299 // /// @return "true" if account is the owner or admin300 // /// @dev EVM selector for this function is: 0x9811b0c7,301 // /// or in textual repr: isOwnerOrAdmin(address)302 // function isOwnerOrAdmin(address user) external view returns (bool);303304 /// Check that account is the owner or admin of the collection305 ///306 /// @param user User cross account to verify307 /// @return "true" if account is the owner or admin308 /// @dev EVM selector for this function is: 0x3e75a905,309 /// or in textual repr: isOwnerOrAdminCross((address,uint256))310 function isOwnerOrAdminCross(EthCrossAccount memory user) external view returns (bool);311312 /// Returns collection type313 ///314 /// @return `Fungible` or `NFT` or `ReFungible`315 /// @dev EVM selector for this function is: 0xd34b55b8,316 /// or in textual repr: uniqueCollectionType()317 function uniqueCollectionType() external view returns (string memory);318319 /// Get collection owner.320 ///321 /// @return Tuble with sponsor address and his substrate mirror.322 /// If address is canonical then substrate mirror is zero and vice versa.323 /// @dev EVM selector for this function is: 0xdf727d3b,324 /// or in textual repr: collectionOwner()325 function collectionOwner() external view returns (EthCrossAccount memory);326327 // /// Changes collection owner to another account328 // ///329 // /// @dev Owner can be changed only by current owner330 // /// @param newOwner new owner account331 // /// @dev EVM selector for this function is: 0x4f53e226,332 // /// or in textual repr: changeCollectionOwner(address)333 // function changeCollectionOwner(address newOwner) external;334335 /// Get collection administrators336 ///337 /// @return Vector of tuples with admins address and his substrate mirror.338 /// If address is canonical then substrate mirror is zero and vice versa.339 /// @dev EVM selector for this function is: 0x5813216b,340 /// or in textual repr: collectionAdmins()341 function collectionAdmins() external view returns (EthCrossAccount[] memory);342343 /// Changes collection owner to another account344 ///345 /// @dev Owner can be changed only by current owner346 /// @param newOwner new owner cross account347 /// @dev EVM selector for this function is: 0x6496c497,348 /// or in textual repr: changeCollectionOwnerCross((address,uint256))349 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) external;350}351352/// @dev Cross account struct353struct EthCrossAccount {354 address eth;355 uint256 sub;356}357358/// @dev anonymous struct359struct Tuple33 {360 CollectionPermissions field_0;361 bool field_1;362}363364enum CollectionPermissions {365 CollectionAdmin,366 TokenOwner367}368369/// @dev anonymous struct370struct Tuple30 {371 bool field_0;372 uint256[] field_1;373}374375/// @dev anonymous struct376struct Tuple26 {377 address field_0;378 uint256 field_1;379}380381/// @dev the ERC-165 identifier for this interface is 0x5b5e139f382interface ERC721Metadata is Dummy, ERC165 {383 // /// @notice A descriptive name for a collection of NFTs in this contract384 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`385 // /// @dev EVM selector for this function is: 0x06fdde03,386 // /// or in textual repr: name()387 // function name() external view returns (string memory);388389 // /// @notice An abbreviated name for NFTs in this contract390 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`391 // /// @dev EVM selector for this function is: 0x95d89b41,392 // /// or in textual repr: symbol()393 // function symbol() external view returns (string memory);394395 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.396 ///397 /// @dev If the token has a `url` property and it is not empty, it is returned.398 /// 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`.399 /// If the collection property `baseURI` is empty or absent, return "" (empty string)400 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix401 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).402 ///403 /// @return token's const_metadata404 /// @dev EVM selector for this function is: 0xc87b56dd,405 /// or in textual repr: tokenURI(uint256)406 function tokenURI(uint256 tokenId) external view returns (string memory);407}408409/// @title ERC721 Token that can be irreversibly burned (destroyed).410/// @dev the ERC-165 identifier for this interface is 0x42966c68411interface ERC721Burnable is Dummy, ERC165 {412 /// @notice Burns a specific ERC721 token.413 /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized414 /// operator of the current owner.415 /// @param tokenId The RFT to approve416 /// @dev EVM selector for this function is: 0x42966c68,417 /// or in textual repr: burn(uint256)418 function burn(uint256 tokenId) external;419}420421/// @dev inlined interface422interface ERC721UniqueMintableEvents {423 event MintingFinished();424}425426/// @title ERC721 minting logic.427/// @dev the ERC-165 identifier for this interface is 0x476ff149428interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {429 /// @dev EVM selector for this function is: 0x05d2035b,430 /// or in textual repr: mintingFinished()431 function mintingFinished() external view returns (bool);432433 /// @notice Function to mint token.434 /// @param to The new owner435 /// @return uint256 The id of the newly minted token436 /// @dev EVM selector for this function is: 0x6a627842,437 /// or in textual repr: mint(address)438 function mint(address to) external returns (uint256);439440 // /// @notice Function to mint token.441 // /// @dev `tokenId` should be obtained with `nextTokenId` method,442 // /// unlike standard, you can't specify it manually443 // /// @param to The new owner444 // /// @param tokenId ID of the minted RFT445 // /// @dev EVM selector for this function is: 0x40c10f19,446 // /// or in textual repr: mint(address,uint256)447 // function mint(address to, uint256 tokenId) external returns (bool);448449 /// @notice Function to mint token with the given tokenUri.450 /// @param to The new owner451 /// @param tokenUri Token URI that would be stored in the NFT properties452 /// @return uint256 The id of the newly minted token453 /// @dev EVM selector for this function is: 0x45c17782,454 /// or in textual repr: mintWithTokenURI(address,string)455 function mintWithTokenURI(address to, string memory tokenUri) external returns (uint256);456457 // /// @notice Function to mint token with the given tokenUri.458 // /// @dev `tokenId` should be obtained with `nextTokenId` method,459 // /// unlike standard, you can't specify it manually460 // /// @param to The new owner461 // /// @param tokenId ID of the minted RFT462 // /// @param tokenUri Token URI that would be stored in the RFT properties463 // /// @dev EVM selector for this function is: 0x50bb4e7f,464 // /// or in textual repr: mintWithTokenURI(address,uint256,string)465 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);466467 /// @dev Not implemented468 /// @dev EVM selector for this function is: 0x7d64bcb4,469 /// or in textual repr: finishMinting()470 function finishMinting() external returns (bool);471}472473/// @title Unique extensions for ERC721.474/// @dev the ERC-165 identifier for this interface is 0x12f7d6c1475interface ERC721UniqueExtensions is Dummy, ERC165 {476 /// @notice A descriptive name for a collection of NFTs in this contract477 /// @dev EVM selector for this function is: 0x06fdde03,478 /// or in textual repr: name()479 function name() external view returns (string memory);480481 /// @notice An abbreviated name for NFTs in this contract482 /// @dev EVM selector for this function is: 0x95d89b41,483 /// or in textual repr: symbol()484 function symbol() external view returns (string memory);485486 /// @notice A description for the collection.487 /// @dev EVM selector for this function is: 0x7284e416,488 /// or in textual repr: description()489 function description() external view returns (string memory);490491 /// Returns the owner (in cross format) of the token.492 ///493 /// @param tokenId Id for the token.494 /// @dev EVM selector for this function is: 0x2b29dace,495 /// or in textual repr: crossOwnerOf(uint256)496 function crossOwnerOf(uint256 tokenId) external view returns (EthCrossAccount memory);497498 /// Returns the token properties.499 ///500 /// @param tokenId Id for the token.501 /// @param keys Properties keys. Empty keys for all propertyes.502 /// @return Vector of properties key/value pairs.503 /// @dev EVM selector for this function is: 0xe07ede7e,504 /// or in textual repr: properties(uint256,string[])505 function properties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory);506507 /// @notice Transfer ownership of an RFT508 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`509 /// is the zero address. Throws if `tokenId` is not a valid RFT.510 /// Throws if RFT pieces have multiple owners.511 /// @param to The new owner512 /// @param tokenId The RFT to transfer513 /// @dev EVM selector for this function is: 0xa9059cbb,514 /// or in textual repr: transfer(address,uint256)515 function transfer(address to, uint256 tokenId) external;516517 /// @notice Transfer ownership of an RFT518 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`519 /// is the zero address. Throws if `tokenId` is not a valid RFT.520 /// Throws if RFT pieces have multiple owners.521 /// @param to The new owner522 /// @param tokenId The RFT to transfer523 /// @dev EVM selector for this function is: 0x2ada85ff,524 /// or in textual repr: transferCross((address,uint256),uint256)525 function transferCross(EthCrossAccount memory to, uint256 tokenId) external;526527 /// @notice Transfer ownership of an RFT528 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`529 /// is the zero address. Throws if `tokenId` is not a valid RFT.530 /// Throws if RFT pieces have multiple owners.531 /// @param to The new owner532 /// @param tokenId The RFT to transfer533 /// @dev EVM selector for this function is: 0xd5cf430b,534 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)535 function transferFromCross(536 EthCrossAccount memory from,537 EthCrossAccount memory to,538 uint256 tokenId539 ) external;540541 // /// @notice Burns a specific ERC721 token.542 // /// @dev Throws unless `msg.sender` is the current owner or an authorized543 // /// operator for this RFT. Throws if `from` is not the current owner. Throws544 // /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.545 // /// Throws if RFT pieces have multiple owners.546 // /// @param from The current owner of the RFT547 // /// @param tokenId The RFT to transfer548 // /// @dev EVM selector for this function is: 0x79cc6790,549 // /// or in textual repr: burnFrom(address,uint256)550 // function burnFrom(address from, uint256 tokenId) external;551552 /// @notice Burns a specific ERC721 token.553 /// @dev Throws unless `msg.sender` is the current owner or an authorized554 /// operator for this RFT. Throws if `from` is not the current owner. Throws555 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.556 /// Throws if RFT pieces have multiple owners.557 /// @param from The current owner of the RFT558 /// @param tokenId The RFT to transfer559 /// @dev EVM selector for this function is: 0xbb2f5a58,560 /// or in textual repr: burnFromCross((address,uint256),uint256)561 function burnFromCross(EthCrossAccount memory from, uint256 tokenId) external;562563 /// @notice Returns next free RFT ID.564 /// @dev EVM selector for this function is: 0x75794a3c,565 /// or in textual repr: nextTokenId()566 function nextTokenId() external view returns (uint256);567568 // /// @notice Function to mint multiple tokens.569 // /// @dev `tokenIds` should be an array of consecutive numbers and first number570 // /// should be obtained with `nextTokenId` method571 // /// @param to The new owner572 // /// @param tokenIds IDs of the minted RFTs573 // /// @dev EVM selector for this function is: 0x44a9945e,574 // /// or in textual repr: mintBulk(address,uint256[])575 // function mintBulk(address to, uint256[] memory tokenIds) external returns (bool);576577 // /// @notice Function to mint multiple tokens with the given tokenUris.578 // /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive579 // /// numbers and first number should be obtained with `nextTokenId` method580 // /// @param to The new owner581 // /// @param tokens array of pairs of token ID and token URI for minted tokens582 // /// @dev EVM selector for this function is: 0x36543006,583 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])584 // function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);585586 /// Returns EVM address for refungible token587 ///588 /// @param token ID of the token589 /// @dev EVM selector for this function is: 0xab76fac6,590 /// or in textual repr: tokenContractAddress(uint256)591 function tokenContractAddress(uint256 token) external view returns (address);592}593594/// @dev anonymous struct595struct Tuple12 {596 uint256 field_0;597 string field_1;598}599600/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension601/// @dev See https://eips.ethereum.org/EIPS/eip-721602/// @dev the ERC-165 identifier for this interface is 0x780e9d63603interface ERC721Enumerable is Dummy, ERC165 {604 /// @notice Enumerate valid RFTs605 /// @param index A counter less than `totalSupply()`606 /// @return The token identifier for the `index`th NFT,607 /// (sort order not specified)608 /// @dev EVM selector for this function is: 0x4f6ccce7,609 /// or in textual repr: tokenByIndex(uint256)610 function tokenByIndex(uint256 index) external view returns (uint256);611612 /// Not implemented613 /// @dev EVM selector for this function is: 0x2f745c59,614 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)615 function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);616617 /// @notice Count RFTs tracked by this contract618 /// @return A count of valid RFTs tracked by this contract, where each one of619 /// them has an assigned and queryable owner not equal to the zero address620 /// @dev EVM selector for this function is: 0x18160ddd,621 /// or in textual repr: totalSupply()622 function totalSupply() external view returns (uint256);623}624625/// @dev inlined interface626interface ERC721Events {627 event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);628 event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);629 event ApprovalForAll(address indexed owner, address indexed operator, bool approved);630}631632/// @title ERC-721 Non-Fungible Token Standard633/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md634/// @dev the ERC-165 identifier for this interface is 0x4016cd87635interface ERC721 is Dummy, ERC165, ERC721Events {636 /// @notice Count all RFTs assigned to an owner637 /// @dev RFTs assigned to the zero address are considered invalid, and this638 /// function throws for queries about the zero address.639 /// @param owner An address for whom to query the balance640 /// @return The number of RFTs owned by `owner`, possibly zero641 /// @dev EVM selector for this function is: 0x70a08231,642 /// or in textual repr: balanceOf(address)643 function balanceOf(address owner) external view returns (uint256);644645 /// @notice Find the owner of an RFT646 /// @dev RFTs assigned to zero address are considered invalid, and queries647 /// about them do throw.648 /// Returns special 0xffffffffffffffffffffffffffffffffffffffff address for649 /// the tokens that are partially owned.650 /// @param tokenId The identifier for an RFT651 /// @return The address of the owner of the RFT652 /// @dev EVM selector for this function is: 0x6352211e,653 /// or in textual repr: ownerOf(uint256)654 function ownerOf(uint256 tokenId) external view returns (address);655656 /// @dev Not implemented657 /// @dev EVM selector for this function is: 0x60a11672,658 /// or in textual repr: safeTransferFromWithData(address,address,uint256,bytes)659 function safeTransferFromWithData(660 address from,661 address to,662 uint256 tokenId,663 bytes memory data664 ) external;665666 /// @dev Not implemented667 /// @dev EVM selector for this function is: 0x42842e0e,668 /// or in textual repr: safeTransferFrom(address,address,uint256)669 function safeTransferFrom(670 address from,671 address to,672 uint256 tokenId673 ) external;674675 /// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE676 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE677 /// THEY MAY BE PERMANENTLY LOST678 /// @dev Throws unless `msg.sender` is the current owner or an authorized679 /// operator for this RFT. Throws if `from` is not the current owner. Throws680 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.681 /// Throws if RFT pieces have multiple owners.682 /// @param from The current owner of the NFT683 /// @param to The new owner684 /// @param tokenId The NFT to transfer685 /// @dev EVM selector for this function is: 0x23b872dd,686 /// or in textual repr: transferFrom(address,address,uint256)687 function transferFrom(688 address from,689 address to,690 uint256 tokenId691 ) external;692693 /// @dev Not implemented694 /// @dev EVM selector for this function is: 0x095ea7b3,695 /// or in textual repr: approve(address,uint256)696 function approve(address approved, uint256 tokenId) external;697698 /// @notice Sets or unsets the approval of a given operator.699 /// The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.700 /// @param operator Operator701 /// @param approved Should operator status be granted or revoked?702 /// @dev EVM selector for this function is: 0xa22cb465,703 /// or in textual repr: setApprovalForAll(address,bool)704 function setApprovalForAll(address operator, bool approved) external;705706 /// @dev Not implemented707 /// @dev EVM selector for this function is: 0x081812fc,708 /// or in textual repr: getApproved(uint256)709 function getApproved(uint256 tokenId) external view returns (address);710711 /// @notice Tells whether the given `owner` approves the `operator`.712 /// @dev EVM selector for this function is: 0xe985e9c5,713 /// or in textual repr: isApprovedForAll(address,address)714 function isApprovedForAll(address owner, address operator) external view returns (bool);715716 /// @notice Returns collection helper contract address717 /// @dev EVM selector for this function is: 0x1896cce6,718 /// or in textual repr: collectionHelperAddress()719 function collectionHelperAddress() external view returns (address);720}721722interface UniqueRefungible is723 Dummy,724 ERC165,725 ERC721,726 ERC721Enumerable,727 ERC721UniqueExtensions,728 ERC721UniqueMintable,729 ERC721Burnable,730 ERC721Metadata,731 Collection,732 TokenProperties733{}tests/src/eth/events.test.tsdiffbeforeafterboth--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -119,7 +119,7 @@
ethEvents.push(event);
});
const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
- await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
+ await collection.methods.setTokenPropertyPermissions([['testKey', [[0, true], [1, true], [2, true]]]]).send({from: owner});
await helper.wait.newBlocks(1);
expect(ethEvents).to.be.like([
{
@@ -374,7 +374,7 @@
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
const result = await collection.methods.mint(owner).send({from: owner});
const tokenId = result.events.Transfer.returnValues.tokenId;
- await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
+ await collection.methods.setTokenPropertyPermissions([['A', [[0, true], [1, true], [2, true]]]]).send({from: owner});
const ethEvents: any = [];
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -17,7 +17,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
import {itEth, usingEthPlaygrounds, expect} from './util';
-import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import {ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
import {Pallets} from '../util';
import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';
@@ -32,28 +32,32 @@
});
});
- itEth('Can be reconfigured', async({helper}) => {
+ [
+ {mode: 'nft'},
+ {mode: 'rft'}
+ ].map(testCase =>
+ itEth(`[${testCase.mode}] Set and get token property permissions`, async({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
- const caller = await helper.eth.createAccountWithBalance(donor);
+ const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);
+ const mode: any = testCase.mode;
for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
- const collection = await helper.nft.mintCollection(alice);
- await collection.addAdmin(alice, {Ethereum: caller});
+ const {collectionId, collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ await collection.methods.addCollectionAdminCross(caller).send({from: owner});
+
+ await collection.methods.setTokenPropertyPermissions([['testKey', [[0, mutable], [1, tokenOwner], [2, collectionAdmin]]]]).send({from: caller.eth});
- const address = helper.ethAddress.fromCollectionId(collection.collectionId);
- const contract = helper.ethNativeContract.collection(address, 'nft', caller);
-
- await contract.methods.setTokenPropertyPermissions([['testKey', [[0, mutable], [1, tokenOwner], [2, collectionAdmin]]]]).send({from: caller});
-
- expect(await collection.getPropertyPermissions()).to.be.deep.equal([{
+ expect(await helper.nft.getPropertyPermissions(collectionId)).to.be.deep.equal([{
key: 'testKey',
permission: {mutable, collectionAdmin, tokenOwner},
}]);
- expect(await contract.methods.tokenPropertyPermissions().call({from: caller})).to.be.like([
+ expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([
['testKey', [['0', mutable], ['1', tokenOwner], ['2', collectionAdmin]]]
]);
}
- });
+ })
+ );
[
{