From 4e01cb3cfaf7942442f508d95d78a0e355cdc2ee Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Tue, 12 Jul 2022 09:01:20 +0000 Subject: [PATCH] build: upgrade to new evm-coder syntax --- --- a/Cargo.lock +++ b/Cargo.lock @@ -1772,41 +1772,6 @@ ] [[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] name = "data-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2217,14 +2182,13 @@ [[package]] name = "evm-coder-macros" -version = "0.1.0" +version = "0.2.0" dependencies = [ "Inflector", - "darling", "hex", "proc-macro2", "quote", - "sha3 0.9.1", + "sha3 0.10.2", "syn", ] @@ -3427,12 +3391,6 @@ "wasm-bindgen", "winapi", ] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" --- a/pallets/common/src/erc.rs +++ b/pallets/common/src/erc.rs @@ -60,7 +60,7 @@ } /// @title A contract that allows you to work with collections. -#[solidity_interface(name = "Collection")] +#[solidity_interface(name = Collection)] impl CollectionHandle where T::AccountId: From<[u8; 32]>, @@ -228,7 +228,7 @@ } /// Add collection admin by substrate address. - /// @param new_admin Substrate administrator address. + /// @param newAdmin Substrate administrator address. fn add_collection_admin_substrate( &mut self, caller: caller, @@ -254,7 +254,7 @@ } /// Add collection admin. - /// @param new_admin Address of the added administrator. + /// @param newAdmin Address of the added administrator. fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result { let caller = T::CrossAccountId::from_eth(caller); let new_admin = T::CrossAccountId::from_eth(new_admin); @@ -264,7 +264,7 @@ /// Remove collection admin. /// - /// @param new_admin Address of the removed administrator. + /// @param admin Address of the removed administrator. fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result { let caller = T::CrossAccountId::from_eth(caller); let admin = T::CrossAccountId::from_eth(admin); --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -42,14 +42,14 @@ } } -#[solidity_interface(name = "ContractHelpers")] +#[solidity_interface(name = ContractHelpers)] impl ContractHelpers where T::AccountId: AsRef<[u8; 32]>, { /// Get contract ovner /// - /// @param Contract_address contract for which the owner is being determined. + /// @param contractAddress contract for which the owner is being determined. /// @return Contract owner. fn contract_owner(&self, contract_address: address) -> Result
{ Ok(>::get(contract_address)) @@ -57,7 +57,7 @@ /// Set sponsor. /// - /// @param contract_address Contract for which a sponsor is being established. + /// @param contractAddress Contract for which a sponsor is being established. /// @param sponsor User address who set as pending sponsor. fn set_sponsor( &mut self, @@ -80,7 +80,7 @@ /// Set contract as self sponsored. /// - /// @param contract_address Contract for which a self sponsoring is being enabled. + /// @param contractAddress Contract for which a self sponsoring is being enabled. fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result { self.recorder().consume_sload()?; self.recorder().consume_sstore()?; @@ -93,7 +93,7 @@ /// Remove sponsor. /// - /// @param contract_address Contract for which a sponsorship is being removed. + /// @param contractAddress Contract for which a sponsorship is being removed. fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result { self.recorder().consume_sload()?; self.recorder().consume_sstore()?; @@ -106,9 +106,9 @@ /// Confirm sponsorship. /// - /// @dev Caller must be same that set via [`set_sponsor`]. + /// @dev Caller must be same that set via [`setSponsor`]. /// - /// @param contract_address Сontract for which need to confirm sponsorship. + /// @param contractAddress Сontract for which need to confirm sponsorship. fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result { self.recorder().consume_sload()?; self.recorder().consume_sstore()?; @@ -121,7 +121,7 @@ /// Get current sponsor. /// - /// @param contract_address The contract for which a sponsor is requested. + /// @param contractAddress The contract for which a sponsor is requested. /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> { let sponsor = @@ -138,7 +138,7 @@ /// Check tat contract has confirmed sponsor. /// - /// @param contract_address The contract for which the presence of a confirmed sponsor is checked. + /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked. /// @return **true** if contract has confirmed sponsor. fn has_sponsor(&self, contract_address: address) -> Result { Ok(Pallet::::get_sponsor(contract_address).is_some()) @@ -146,7 +146,7 @@ /// Check tat contract has pending sponsor. /// - /// @param contract_address The contract for which the presence of a pending sponsor is checked. + /// @param contractAddress The contract for which the presence of a pending sponsor is checked. /// @return **true** if contract has pending sponsor. fn has_pending_sponsor(&self, contract_address: address) -> Result { Ok(match Sponsoring::::get(contract_address) { @@ -229,13 +229,13 @@ caller: caller, contract_address: address, user: address, - allowed: bool, + is_allowed: bool, ) -> Result { self.recorder().consume_sload()?; self.recorder().consume_sstore()?; >::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::)?; - >::toggle_allowed(contract_address, user, allowed); + >::toggle_allowed(contract_address, user, is_allowed); Ok(()) } --- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol +++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol @@ -3,13 +3,13 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct +/// @dev anonymous struct struct Tuple0 { address field_0; uint256 field_1; } -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -27,14 +27,14 @@ } } -// Selector: 6073d917 +/// @dev the ERC-165 identifier for this interface is 0x6073d917 contract ContractHelpers is Dummy, ERC165 { - // Get contract ovner - // - // @param Contract_address contract for which the owner is being determined. - // @return Contract owner. - // - // Selector: contractOwner(address) 5152b14c + /// Get contract ovner + /// + /// @param contractAddress contract for which the owner is being determined. + /// @return Contract owner. + /// + /// Selector: contractOwner(address) 5152b14c function contractOwner(address contractAddress) public view @@ -46,12 +46,12 @@ return 0x0000000000000000000000000000000000000000; } - // Set sponsor. - // - // @param contract_address Contract for which a sponsor is being established. - // @param sponsor User address who set as pending sponsor. - // - // Selector: setSponsor(address,address) f01fba93 + /// Set sponsor. + /// + /// @param contractAddress Contract for which a sponsor is being established. + /// @param sponsor User address who set as pending sponsor. + /// + /// Selector: setSponsor(address,address) f01fba93 function setSponsor(address contractAddress, address sponsor) public { require(false, stub_error); contractAddress; @@ -59,47 +59,47 @@ dummy = 0; } - // Set contract as self sponsored. - // - // @param contract_address Contract for which a self sponsoring is being enabled. - // - // Selector: selfSponsoredEnable(address) 89f7d9ae + /// Set contract as self sponsored. + /// + /// @param contractAddress Contract for which a self sponsoring is being enabled. + /// + /// Selector: selfSponsoredEnable(address) 89f7d9ae function selfSponsoredEnable(address contractAddress) public { require(false, stub_error); contractAddress; dummy = 0; } - // Remove sponsor. - // - // @param contract_address Contract for which a sponsorship is being removed. - // - // Selector: removeSponsor(address) ef784250 + /// Remove sponsor. + /// + /// @param contractAddress Contract for which a sponsorship is being removed. + /// + /// Selector: removeSponsor(address) ef784250 function removeSponsor(address contractAddress) public { require(false, stub_error); contractAddress; dummy = 0; } - // Confirm sponsorship. - // - // @dev Caller must be same that set via [`set_sponsor`]. - // - // @param contract_address Сontract for which need to confirm sponsorship. - // - // Selector: confirmSponsorship(address) abc00001 + /// Confirm sponsorship. + /// + /// @dev Caller must be same that set via [`setSponsor`]. + /// + /// @param contractAddress Сontract for which need to confirm sponsorship. + /// + /// Selector: confirmSponsorship(address) abc00001 function confirmSponsorship(address contractAddress) public { require(false, stub_error); contractAddress; dummy = 0; } - // Get current sponsor. - // - // @param contract_address The contract for which a sponsor is requested. - // @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. - // - // Selector: getSponsor(address) 743fc745 + /// Get current sponsor. + /// + /// @param contractAddress The contract for which a sponsor is requested. + /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. + /// + /// Selector: getSponsor(address) 743fc745 function getSponsor(address contractAddress) public view @@ -111,12 +111,12 @@ return Tuple0(0x0000000000000000000000000000000000000000, 0); } - // Check tat contract has confirmed sponsor. - // - // @param contract_address The contract for which the presence of a confirmed sponsor is checked. - // @return **true** if contract has confirmed sponsor. - // - // Selector: hasSponsor(address) 97418603 + /// Check tat contract has confirmed sponsor. + /// + /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked. + /// @return **true** if contract has confirmed sponsor. + /// + /// Selector: hasSponsor(address) 97418603 function hasSponsor(address contractAddress) public view returns (bool) { require(false, stub_error); contractAddress; @@ -124,12 +124,12 @@ return false; } - // Check tat contract has pending sponsor. - // - // @param contract_address The contract for which the presence of a pending sponsor is checked. - // @return **true** if contract has pending sponsor. - // - // Selector: hasPendingSponsor(address) 39b9b242 + /// Check tat contract has pending sponsor. + /// + /// @param contractAddress The contract for which the presence of a pending sponsor is checked. + /// @return **true** if contract has pending sponsor. + /// + /// Selector: hasPendingSponsor(address) 39b9b242 function hasPendingSponsor(address contractAddress) public view @@ -141,7 +141,7 @@ return false; } - // Selector: sponsoringEnabled(address) 6027dc61 + /// Selector: sponsoringEnabled(address) 6027dc61 function sponsoringEnabled(address contractAddress) public view @@ -153,7 +153,7 @@ return false; } - // Selector: setSponsoringMode(address,uint8) fde8a560 + /// Selector: setSponsoringMode(address,uint8) fde8a560 function setSponsoringMode(address contractAddress, uint8 mode) public { require(false, stub_error); contractAddress; @@ -161,7 +161,7 @@ dummy = 0; } - // Selector: sponsoringMode(address) b70c7267 + /// Selector: sponsoringMode(address) b70c7267 function sponsoringMode(address contractAddress) public view @@ -173,7 +173,7 @@ return 0; } - // Selector: setSponsoringRateLimit(address,uint32) 77b6c908 + /// Selector: setSponsoringRateLimit(address,uint32) 77b6c908 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit) public { @@ -183,7 +183,7 @@ dummy = 0; } - // Selector: getSponsoringRateLimit(address) 610cfabd + /// Selector: getSponsoringRateLimit(address) 610cfabd function getSponsoringRateLimit(address contractAddress) public view @@ -195,7 +195,7 @@ return 0; } - // Selector: allowed(address,address) 5c658165 + /// Selector: allowed(address,address) 5c658165 function allowed(address contractAddress, address user) public view @@ -208,7 +208,7 @@ return false; } - // Selector: allowlistEnabled(address) c772ef6c + /// Selector: allowlistEnabled(address) c772ef6c function allowlistEnabled(address contractAddress) public view @@ -220,7 +220,7 @@ return false; } - // Selector: toggleAllowlist(address,bool) 36de20f5 + /// Selector: toggleAllowlist(address,bool) 36de20f5 function toggleAllowlist(address contractAddress, bool enabled) public { require(false, stub_error); contractAddress; @@ -228,16 +228,16 @@ dummy = 0; } - // Selector: toggleAllowed(address,address,bool) 4706cc1c + /// Selector: toggleAllowed(address,address,bool) 4706cc1c function toggleAllowed( address contractAddress, address user, - bool allowed + bool isAllowed ) public { require(false, stub_error); contractAddress; user; - allowed; + isAllowed; dummy = 0; } } --- a/pallets/fungible/src/erc.rs +++ b/pallets/fungible/src/erc.rs @@ -50,7 +50,7 @@ }, } -#[solidity_interface(name = "ERC20", events(ERC20Events))] +#[solidity_interface(name = ERC20, events(ERC20Events))] impl FungibleHandle { fn name(&self) -> Result { Ok(decode_utf16(self.name.iter().copied()) @@ -129,7 +129,7 @@ } } -#[solidity_interface(name = "ERC20UniqueExtensions")] +#[solidity_interface(name = ERC20UniqueExtensions)] impl FungibleHandle { #[weight(>::burn_from())] fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result { @@ -147,11 +147,11 @@ } #[solidity_interface( - name = "UniqueFungible", + name = UniqueFungible, is( ERC20, ERC20UniqueExtensions, - via("CollectionHandle", common_mut, Collection) + Collection(common_mut, CollectionHandle), ) )] impl FungibleHandle where T::AccountId: From<[u8; 32]> {} --- a/pallets/fungible/src/stubs/UniqueFungible.sol +++ b/pallets/fungible/src/stubs/UniqueFungible.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -19,122 +19,17 @@ interfaceID; return true; } -} - -// Inline -contract ERC20Events { - event Transfer(address indexed from, address indexed to, uint256 value); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); } -// Selector: 79cc6790 -contract ERC20UniqueExtensions is Dummy, ERC165 { - // Selector: burnFrom(address,uint256) 79cc6790 - function burnFrom(address from, uint256 amount) public returns (bool) { - require(false, stub_error); - from; - amount; - dummy = 0; - return false; - } -} - -// Selector: 942e8b22 -contract ERC20 is Dummy, ERC165, ERC20Events { - // Selector: name() 06fdde03 - function name() public view returns (string memory) { - require(false, stub_error); - dummy; - return ""; - } - - // Selector: symbol() 95d89b41 - function symbol() public view returns (string memory) { - require(false, stub_error); - dummy; - return ""; - } - - // Selector: totalSupply() 18160ddd - function totalSupply() public view returns (uint256) { - require(false, stub_error); - dummy; - return 0; - } - - // Selector: decimals() 313ce567 - function decimals() public view returns (uint8) { - require(false, stub_error); - dummy; - return 0; - } - - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) public view returns (uint256) { - require(false, stub_error); - owner; - dummy; - return 0; - } - - // Selector: transfer(address,uint256) a9059cbb - function transfer(address to, uint256 amount) public returns (bool) { - require(false, stub_error); - to; - amount; - dummy = 0; - return false; - } - - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 amount - ) public returns (bool) { - require(false, stub_error); - from; - to; - amount; - dummy = 0; - return false; - } - - // Selector: approve(address,uint256) 095ea7b3 - function approve(address spender, uint256 amount) public returns (bool) { - require(false, stub_error); - spender; - amount; - dummy = 0; - return false; - } - - // Selector: allowance(address,address) dd62ed3e - function allowance(address owner, address spender) - public - view - returns (uint256) - { - require(false, stub_error); - owner; - spender; - dummy; - return 0; - } -} - -// Selector: ffe4da23 +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 contract Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) function setCollectionProperty(string memory key, bytes memory value) public { @@ -144,25 +39,25 @@ dummy = 0; } - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) function deleteCollectionProperty(string memory key) public { require(false, stub_error); key; dummy = 0; } - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) function collectionProperty(string memory key) public view @@ -174,41 +69,41 @@ return hex""; } - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) function setCollectionSponsor(address sponsor) public { require(false, stub_error); sponsor; dummy = 0; } - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() function confirmCollectionSponsorship() public { require(false, stub_error); dummy = 0; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) function setCollectionLimit(string memory limit, uint32 value) public { require(false, stub_error); limit; @@ -216,15 +111,15 @@ dummy = 0; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) function setCollectionLimit(string memory limit, bool value) public { require(false, stub_error); limit; @@ -232,73 +127,73 @@ dummy = 0; } - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() function contractAddress() public view returns (address) { require(false, stub_error); dummy; return 0x0000000000000000000000000000000000000000; } - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) function addCollectionAdminSubstrate(uint256 newAdmin) public { require(false, stub_error); newAdmin; dummy = 0; } - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) function removeCollectionAdminSubstrate(uint256 admin) public { require(false, stub_error); admin; dummy = 0; } - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) function addCollectionAdmin(address newAdmin) public { require(false, stub_error); newAdmin; dummy = 0; } - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) function removeCollectionAdmin(address admin) public { require(false, stub_error); admin; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) function setCollectionNesting(bool enable) public { require(false, stub_error); enable; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) function setCollectionNesting(bool enable, address[] memory collections) public { @@ -308,57 +203,57 @@ dummy = 0; } - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) function setCollectionAccess(uint8 mode) public { require(false, stub_error); mode; dummy = 0; } - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) function addToCollectionAllowList(address user) public { require(false, stub_error); user; dummy = 0; } - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) function removeFromCollectionAllowList(address user) public { require(false, stub_error); user; dummy = 0; } - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) function setCollectionMintMode(bool mode) public { require(false, stub_error); mode; dummy = 0; } - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) function isOwnerOrAdmin(address user) public view returns (bool) { require(false, stub_error); user; @@ -366,12 +261,12 @@ return false; } - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) { require(false, stub_error); user; @@ -379,35 +274,35 @@ return false; } - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() function uniqueCollectionType() public returns (string memory) { require(false, stub_error); dummy = 0; return ""; } - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) function setOwner(address newOwner) public { require(false, stub_error); newOwner; dummy = 0; } - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) function setOwnerSubstrate(uint256 newOwner) public { require(false, stub_error); newOwner; @@ -415,6 +310,122 @@ } } +/// @dev the ERC-165 identifier for this interface is 0x79cc6790 +contract ERC20UniqueExtensions is Dummy, ERC165 { + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) + function burnFrom(address from, uint256 amount) public returns (bool) { + require(false, stub_error); + from; + amount; + dummy = 0; + return false; + } +} + +/// @dev inlined interface +contract ERC20Events { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + +/// @dev the ERC-165 identifier for this interface is 0x942e8b22 +contract ERC20 is Dummy, ERC165, ERC20Events { + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() public view returns (string memory) { + require(false, stub_error); + dummy; + return ""; + } + + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() public view returns (string memory) { + require(false, stub_error); + dummy; + return ""; + } + + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() public view returns (uint256) { + require(false, stub_error); + dummy; + return 0; + } + + /// @dev EVM selector for this function is: 0x313ce567, + /// or in textual repr: decimals() + function decimals() public view returns (uint8) { + require(false, stub_error); + dummy; + return 0; + } + + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) public view returns (uint256) { + require(false, stub_error); + owner; + dummy; + return 0; + } + + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) + function transfer(address to, uint256 amount) public returns (bool) { + require(false, stub_error); + to; + amount; + dummy = 0; + return false; + } + + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 amount + ) public returns (bool) { + require(false, stub_error); + from; + to; + amount; + dummy = 0; + return false; + } + + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address spender, uint256 amount) public returns (bool) { + require(false, stub_error); + spender; + amount; + dummy = 0; + return false; + } + + /// @dev EVM selector for this function is: 0xdd62ed3e, + /// or in textual repr: allowance(address,address) + function allowance(address owner, address spender) + public + view + returns (uint256) + { + require(false, stub_error); + owner; + spender; + dummy; + return 0; + } +} + contract UniqueFungible is Dummy, ERC165, --- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -50,14 +50,14 @@ }; /// @title A contract that allows to set and delete token properties and change token property permissions. -#[solidity_interface(name = "TokenProperties")] +#[solidity_interface(name = TokenProperties)] impl NonfungibleHandle { /// @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 is_mutable Permission to mutate property. - /// @param collection_admin Permission to mutate property by collection admin if property is mutable. - /// @param token_owner Permission to mutate property by token owner if property is mutable. + /// @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. fn set_token_property_permission( &mut self, caller: caller, @@ -201,7 +201,7 @@ /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 -#[solidity_interface(name = "ERC721Metadata")] +#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)] impl NonfungibleHandle { /// @notice A descriptive name for a collection of NFTs in this contract fn name(&self) -> Result { @@ -262,7 +262,7 @@ /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 -#[solidity_interface(name = "ERC721Enumerable")] +#[solidity_interface(name = ERC721Enumerable, expect_selector = 0x780e9d63)] impl NonfungibleHandle { /// @notice Enumerate valid NFTs /// @param index A counter less than `totalSupply()` @@ -289,7 +289,7 @@ /// @title ERC-721 Non-Fungible Token Standard /// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md -#[solidity_interface(name = "ERC721", events(ERC721Events))] +#[solidity_interface(name = ERC721, events(ERC721Events), expect_selector = 0x80ac58cd)] impl NonfungibleHandle { /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this @@ -316,13 +316,13 @@ .as_eth()) } /// @dev Not implemented + #[solidity(rename_selector = "safeTransferFrom")] fn safe_transfer_from_with_data( &mut self, _from: address, _to: address, _token_id: uint256, _data: bytes, - _value: value, ) -> Result { // TODO: Not implemetable Err("not implemented".into()) @@ -333,7 +333,6 @@ _from: address, _to: address, _token_id: uint256, - _value: value, ) -> Result { // TODO: Not implemetable Err("not implemented".into()) @@ -348,7 +347,6 @@ /// @param from The current owner of the NFT /// @param to The new owner /// @param tokenId The NFT to transfer - /// @param _value Not used for an NFT #[weight(>::transfer_from())] fn transfer_from( &mut self, @@ -356,7 +354,6 @@ from: address, to: address, token_id: uint256, - _value: value, ) -> Result { let caller = T::CrossAccountId::from_eth(caller); let from = T::CrossAccountId::from_eth(from); @@ -378,13 +375,7 @@ /// @param approved The new approved NFT controller /// @param tokenId The NFT to approve #[weight(>::approve())] - fn approve( - &mut self, - caller: caller, - approved: address, - token_id: uint256, - _value: value, - ) -> Result { + fn approve(&mut self, caller: caller, approved: address, token_id: uint256) -> Result { let caller = T::CrossAccountId::from_eth(caller); let approved = T::CrossAccountId::from_eth(approved); let token = token_id.try_into()?; @@ -419,7 +410,7 @@ } /// @title ERC721 Token that can be irreversibly burned (destroyed). -#[solidity_interface(name = "ERC721Burnable")] +#[solidity_interface(name = ERC721Burnable)] impl NonfungibleHandle { /// @notice Burns a specific ERC721 token. /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized @@ -436,7 +427,7 @@ } /// @title ERC721 minting logic. -#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))] +#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))] impl NonfungibleHandle { fn minting_finished(&self) -> Result { Ok(false) @@ -597,22 +588,15 @@ } /// @title Unique extensions for ERC721. -#[solidity_interface(name = "ERC721UniqueExtensions")] +#[solidity_interface(name = ERC721UniqueExtensions)] impl NonfungibleHandle { /// @notice Transfer ownership of an NFT /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` /// is the zero address. Throws if `tokenId` is not a valid NFT. /// @param to The new owner /// @param tokenId The NFT to transfer - /// @param _value Not used for an NFT #[weight(>::transfer())] - fn transfer( - &mut self, - caller: caller, - to: address, - token_id: uint256, - _value: value, - ) -> Result { + fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result { let caller = T::CrossAccountId::from_eth(caller); let to = T::CrossAccountId::from_eth(to); let token = token_id.try_into()?; @@ -630,15 +614,8 @@ /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT. /// @param from The current owner of the NFT /// @param tokenId The NFT to transfer - /// @param _value Not used for an NFT #[weight(>::burn_from())] - fn burn_from( - &mut self, - caller: caller, - from: address, - token_id: uint256, - _value: value, - ) -> Result { + fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result { let caller = T::CrossAccountId::from_eth(caller); let from = T::CrossAccountId::from_eth(from); let token = token_id.try_into()?; @@ -751,7 +728,7 @@ } #[solidity_interface( - name = "UniqueNFT", + name = UniqueNFT, is( ERC721, ERC721Metadata, @@ -759,7 +736,7 @@ ERC721UniqueExtensions, ERC721Mintable, ERC721Burnable, - via("CollectionHandle", common_mut, Collection), + Collection(common_mut, CollectionHandle), TokenProperties, ) )] --- a/pallets/nonfungible/src/stubs/UniqueNFT.sol +++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol @@ -3,13 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct -struct Tuple0 { - uint256 field_0; - string field_1; -} - -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -27,40 +21,17 @@ } } -// Inline -contract ERC721Events { - event Transfer( - address indexed from, - address indexed to, - uint256 indexed tokenId - ); - event Approval( - address indexed owner, - address indexed approved, - uint256 indexed tokenId - ); - event ApprovalForAll( - address indexed owner, - address indexed operator, - bool approved - ); -} - -// Inline -contract ERC721MintableEvents { - event MintingFinished(); -} - -// Selector: 41369377 +/// @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 0x41369377 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 is_mutable Permission to mutate property. - // @param collection_admin Permission to mutate property by collection admin if property is mutable. - // @param token_owner Permission to mutate property by token owner if property is mutable. - // - // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa + /// @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, @@ -75,13 +46,13 @@ dummy = 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. - // @param key Property key. - // @param value Property value. - // - // Selector: setProperty(uint256,string,bytes) 1752d67b + /// @notice Set 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. + /// @param value Property value. + /// @dev EVM selector for this function is: 0x1752d67b, + /// or in textual repr: setProperty(uint256,string,bytes) function setProperty( uint256 tokenId, string memory key, @@ -94,12 +65,12 @@ dummy = 0; } - // @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. - // - // Selector: deleteProperty(uint256,string) 066111d1 + /// @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; @@ -107,13 +78,13 @@ dummy = 0; } - // @notice Get token property value. - // @dev Throws error if key not found - // @param tokenId ID of the token. - // @param key Property key. - // @return Property value bytes - // - // Selector: property(uint256,string) 7228c327 + /// @notice Get token property value. + /// @dev Throws error if key not found + /// @param tokenId ID of the token. + /// @param key Property key. + /// @return Property value bytes + /// @dev EVM selector for this function is: 0x7228c327, + /// or in textual repr: property(uint256,string) function property(uint256 tokenId, string memory key) public view @@ -127,213 +98,334 @@ } } -// Selector: 42966c68 -contract ERC721Burnable is Dummy, ERC165 { - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized - // operator of the current owner. - // @param tokenId The NFT to approve - // - // Selector: burn(uint256) 42966c68 - function burn(uint256 tokenId) public { +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 +contract Collection is Dummy, ERC165 { + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) + function setCollectionProperty(string memory key, bytes memory value) + public + { require(false, stub_error); - tokenId; + key; + value; dummy = 0; } -} -// Selector: 58800161 -contract ERC721 is Dummy, ERC165, ERC721Events { - // @notice Count all NFTs assigned to an owner - // @dev NFTs assigned to the zero address are considered invalid, and this - // function throws for queries about the zero address. - // @param owner An address for whom to query the balance - // @return The number of NFTs owned by `owner`, possibly zero - // - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) public view returns (uint256) { + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) + function deleteCollectionProperty(string memory key) public { require(false, stub_error); - owner; - dummy; - return 0; + key; + dummy = 0; } - // @notice Find the owner of an NFT - // @dev NFTs assigned to zero address are considered invalid, and queries - // about them do throw. - // @param tokenId The identifier for an NFT - // @return The address of the owner of the NFT - // - // Selector: ownerOf(uint256) 6352211e - function ownerOf(uint256 tokenId) public view returns (address) { + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) + function collectionProperty(string memory key) + public + view + returns (bytes memory) + { require(false, stub_error); - tokenId; + key; dummy; - return 0x0000000000000000000000000000000000000000; + return hex""; } - // @dev Not implemented - // - // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672 - function safeTransferFromWithData( - address from, - address to, - uint256 tokenId, - bytes memory data - ) public { + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) + function setCollectionSponsor(address sponsor) public { require(false, stub_error); - from; - to; - tokenId; - data; + sponsor; dummy = 0; } - // @dev Not implemented - // - // Selector: safeTransferFrom(address,address,uint256) 42842e0e - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) public { + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() + function confirmCollectionSponsorship() public { require(false, stub_error); - from; - to; - tokenId; dummy = 0; } - // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE - // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE - // THEY MAY BE PERMANENTLY LOST - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this NFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid NFT. - // @param from The current owner of the NFT - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 tokenId - ) public { + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) + function setCollectionLimit(string memory limit, uint32 value) public { require(false, stub_error); - from; - to; - tokenId; + limit; + value; dummy = 0; } - // @notice Set or reaffirm the approved address for an NFT - // @dev The zero address indicates there is no approved address. - // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized - // operator of the current owner. - // @param approved The new approved NFT controller - // @param tokenId The NFT to approve - // - // Selector: approve(address,uint256) 095ea7b3 - function approve(address approved, uint256 tokenId) public { + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) + function setCollectionLimit(string memory limit, bool value) public { require(false, stub_error); - approved; - tokenId; + limit; + value; dummy = 0; } - // @dev Not implemented - // - // Selector: setApprovalForAll(address,bool) a22cb465 - function setApprovalForAll(address operator, bool approved) public { + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() + function contractAddress() public view returns (address) { + require(false, stub_error); + dummy; + return 0x0000000000000000000000000000000000000000; + } + + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) + function addCollectionAdminSubstrate(uint256 newAdmin) public { + require(false, stub_error); + newAdmin; + dummy = 0; + } + + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) + function removeCollectionAdminSubstrate(uint256 admin) public { + require(false, stub_error); + admin; + dummy = 0; + } + + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) + function addCollectionAdmin(address newAdmin) public { + require(false, stub_error); + newAdmin; + dummy = 0; + } + + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) + function removeCollectionAdmin(address admin) public { require(false, stub_error); - operator; - approved; + admin; dummy = 0; } - // @dev Not implemented - // - // Selector: getApproved(uint256) 081812fc - function getApproved(uint256 tokenId) public view returns (address) { + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) + function setCollectionNesting(bool enable) public { require(false, stub_error); - tokenId; - dummy; - return 0x0000000000000000000000000000000000000000; + enable; + dummy = 0; } - // @dev Not implemented - // - // Selector: isApprovedForAll(address,address) e985e9c5 - function isApprovedForAll(address owner, address operator) + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) + function setCollectionNesting(bool enable, address[] memory collections) public - view - returns (address) { require(false, stub_error); - owner; - operator; + enable; + collections; + dummy = 0; + } + + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) + function setCollectionAccess(uint8 mode) public { + require(false, stub_error); + mode; + dummy = 0; + } + + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) + function addToCollectionAllowList(address user) public { + require(false, stub_error); + user; + dummy = 0; + } + + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) + function removeFromCollectionAllowList(address user) public { + require(false, stub_error); + user; + dummy = 0; + } + + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) + function setCollectionMintMode(bool mode) public { + require(false, stub_error); + mode; + dummy = 0; + } + + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) + function isOwnerOrAdmin(address user) public view returns (bool) { + require(false, stub_error); + user; dummy; - return 0x0000000000000000000000000000000000000000; + return false; } -} -// Selector: 5b5e139f -contract ERC721Metadata is Dummy, ERC165 { - // @notice A descriptive name for a collection of NFTs in this contract - // - // Selector: name() 06fdde03 - function name() public view returns (string memory) { + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) + function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) { require(false, stub_error); + user; dummy; + return false; + } + + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() + function uniqueCollectionType() public returns (string memory) { + require(false, stub_error); + dummy = 0; return ""; } - // @notice An abbreviated name for NFTs in this contract - // - // Selector: symbol() 95d89b41 - function symbol() public view returns (string memory) { + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) + function setOwner(address newOwner) public { + require(false, stub_error); + newOwner; + dummy = 0; + } + + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) + function setOwnerSubstrate(uint256 newOwner) public { require(false, stub_error); - dummy; - return ""; + newOwner; + dummy = 0; } +} - // @notice A distinct Uniform Resource Identifier (URI) for a given asset. - // - // @dev If the token has a `url` property and it is not empty, it is returned. - // 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`. - // If the collection property `baseURI` is empty or absent, return "" (empty string) - // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix - // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). - // - // @return token's const_metadata - // - // Selector: tokenURI(uint256) c87b56dd - function tokenURI(uint256 tokenId) public view returns (string memory) { +/// @title ERC721 Token that can be irreversibly burned (destroyed). +/// @dev the ERC-165 identifier for this interface is 0x42966c68 +contract ERC721Burnable is Dummy, ERC165 { + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized + /// operator of the current owner. + /// @param tokenId The NFT to approve + /// @dev EVM selector for this function is: 0x42966c68, + /// or in textual repr: burn(uint256) + function burn(uint256 tokenId) public { require(false, stub_error); tokenId; - dummy; - return ""; + dummy = 0; } } -// Selector: 68ccfe89 +/// @dev inlined interface +contract ERC721MintableEvents { + event MintingFinished(); +} + +/// @title ERC721 minting logic. +/// @dev the ERC-165 identifier for this interface is 0x68ccfe89 contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents { - // Selector: mintingFinished() 05d2035b + /// @dev EVM selector for this function is: 0x05d2035b, + /// or in textual repr: mintingFinished() function mintingFinished() public view returns (bool) { require(false, stub_error); dummy; return false; } - // @notice Function to mint token. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted NFT - // - // Selector: mint(address,uint256) 40c10f19 + /// @notice Function to mint token. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted NFT + /// @dev EVM selector for this function is: 0x40c10f19, + /// or in textual repr: mint(address,uint256) function mint(address to, uint256 tokenId) public returns (bool) { require(false, stub_error); to; @@ -342,14 +434,14 @@ return false; } - // @notice Function to mint token with the given tokenUri. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted NFT - // @param tokenUri Token URI that would be stored in the NFT properties - // - // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f + /// @notice Function to mint token with the given tokenUri. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted NFT + /// @param tokenUri Token URI that would be stored in the NFT properties + /// @dev EVM selector for this function is: 0x50bb4e7f, + /// or in textual repr: mintWithTokenURI(address,uint256,string) function mintWithTokenURI( address to, uint256 tokenId, @@ -363,9 +455,9 @@ return false; } - // @dev Not implemented - // - // Selector: finishMinting() 7d64bcb4 + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x7d64bcb4, + /// or in textual repr: finishMinting() function finishMinting() public returns (bool) { require(false, stub_error); dummy = 0; @@ -373,58 +465,16 @@ } } -// Selector: 780e9d63 -contract ERC721Enumerable is Dummy, ERC165 { - // @notice Enumerate valid NFTs - // @param index A counter less than `totalSupply()` - // @return The token identifier for the `index`th NFT, - // (sort order not specified) - // - // Selector: tokenByIndex(uint256) 4f6ccce7 - function tokenByIndex(uint256 index) public view returns (uint256) { - require(false, stub_error); - index; - dummy; - return 0; - } - - // @dev Not implemented - // - // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59 - function tokenOfOwnerByIndex(address owner, uint256 index) - public - view - returns (uint256) - { - require(false, stub_error); - owner; - index; - dummy; - return 0; - } - - // @notice Count NFTs tracked by this contract - // @return A count of valid NFTs tracked by this contract, where each one of - // them has an assigned and queryable owner not equal to the zero address - // - // Selector: totalSupply() 18160ddd - function totalSupply() public view returns (uint256) { - require(false, stub_error); - dummy; - return 0; - } -} - -// Selector: d74d154f +/// @title Unique extensions for ERC721. +/// @dev the ERC-165 identifier for this interface is 0xd74d154f contract ERC721UniqueExtensions is Dummy, ERC165 { - // @notice Transfer ownership of an NFT - // @dev Throws unless `msg.sender` is the current owner. Throws if `to` - // is the zero address. Throws if `tokenId` is not a valid NFT. - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transfer(address,uint256) a9059cbb + /// @notice Transfer ownership of an NFT + /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` + /// is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 tokenId) public { require(false, stub_error); to; @@ -432,15 +482,14 @@ dummy = 0; } - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this NFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid NFT. - // @param from The current owner of the NFT - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: burnFrom(address,uint256) 79cc6790 + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this NFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param from The current owner of the NFT + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) function burnFrom(address from, uint256 tokenId) public { require(false, stub_error); from; @@ -448,22 +497,22 @@ dummy = 0; } - // @notice Returns next free NFT ID. - // - // Selector: nextTokenId() 75794a3c + /// @notice Returns next free NFT ID. + /// @dev EVM selector for this function is: 0x75794a3c, + /// or in textual repr: nextTokenId() function nextTokenId() public view returns (uint256) { require(false, stub_error); dummy; return 0; } - // @notice Function to mint multiple tokens. - // @dev `tokenIds` should be an array of consecutive numbers and first number - // should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokenIds IDs of the minted NFTs - // - // Selector: mintBulk(address,uint256[]) 44a9945e + /// @notice Function to mint multiple tokens. + /// @dev `tokenIds` should be an array of consecutive numbers and first number + /// should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokenIds IDs of the minted NFTs + /// @dev EVM selector for this function is: 0x44a9945e, + /// or in textual repr: mintBulk(address,uint256[]) function mintBulk(address to, uint256[] memory tokenIds) public returns (bool) @@ -475,14 +524,14 @@ return false; } - // @notice Function to mint multiple tokens with the given tokenUris. - // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive - // numbers and first number should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokens array of pairs of token ID and token URI for minted tokens - // - // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006 - function mintBulkWithTokenURI(address to, Tuple0[] memory tokens) + /// @notice Function to mint multiple tokens with the given tokenUris. + /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive + /// numbers and first number should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokens array of pairs of token ID and token URI for minted tokens + /// @dev EVM selector for this function is: 0x36543006, + /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) + function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) { @@ -494,291 +543,251 @@ } } -// Selector: ffe4da23 -contract Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 - function setCollectionProperty(string memory key, bytes memory value) - public - { - require(false, stub_error); - key; - value; - dummy = 0; - } +/// @dev anonymous struct +struct Tuple8 { + uint256 field_0; + string field_1; +} - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce - function deleteCollectionProperty(string memory key) public { +/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x780e9d63 +contract ERC721Enumerable is Dummy, ERC165 { + /// @notice Enumerate valid NFTs + /// @param index A counter less than `totalSupply()` + /// @return The token identifier for the `index`th NFT, + /// (sort order not specified) + /// @dev EVM selector for this function is: 0x4f6ccce7, + /// or in textual repr: tokenByIndex(uint256) + function tokenByIndex(uint256 index) public view returns (uint256) { require(false, stub_error); - key; - dummy = 0; + index; + dummy; + return 0; } - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d - function collectionProperty(string memory key) + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x2f745c59, + /// or in textual repr: tokenOfOwnerByIndex(address,uint256) + function tokenOfOwnerByIndex(address owner, uint256 index) public view - returns (bytes memory) + returns (uint256) { require(false, stub_error); - key; + owner; + index; dummy; - return hex""; + return 0; } - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e - function setCollectionSponsor(address sponsor) public { + /// @notice Count NFTs tracked by this contract + /// @return A count of valid NFTs tracked by this contract, where each one of + /// them has an assigned and queryable owner not equal to the zero address + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() public view returns (uint256) { require(false, stub_error); - sponsor; - dummy = 0; + dummy; + return 0; } +} - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a - function confirmCollectionSponsorship() public { +/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x5b5e139f +contract ERC721Metadata is Dummy, ERC165 { + /// @notice A descriptive name for a collection of NFTs in this contract + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() public view returns (string memory) { require(false, stub_error); - dummy = 0; + dummy; + return ""; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db - function setCollectionLimit(string memory limit, uint32 value) public { + /// @notice An abbreviated name for NFTs in this contract + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() public view returns (string memory) { require(false, stub_error); - limit; - value; - dummy = 0; + dummy; + return ""; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba - function setCollectionLimit(string memory limit, bool value) public { + /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. + /// + /// @dev If the token has a `url` property and it is not empty, it is returned. + /// 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`. + /// If the collection property `baseURI` is empty or absent, return "" (empty string) + /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix + /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). + /// + /// @return token's const_metadata + /// @dev EVM selector for this function is: 0xc87b56dd, + /// or in textual repr: tokenURI(uint256) + function tokenURI(uint256 tokenId) public view returns (string memory) { require(false, stub_error); - limit; - value; - dummy = 0; - } - - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 - function contractAddress() public view returns (address) { - require(false, stub_error); + tokenId; dummy; - return 0x0000000000000000000000000000000000000000; + return ""; } +} - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b - function addCollectionAdminSubstrate(uint256 newAdmin) public { - require(false, stub_error); - newAdmin; - dummy = 0; - } +/// @dev inlined interface +contract ERC721Events { + event Transfer( + address indexed from, + address indexed to, + uint256 indexed tokenId + ); + event Approval( + address indexed owner, + address indexed approved, + uint256 indexed tokenId + ); + event ApprovalForAll( + address indexed owner, + address indexed operator, + bool approved + ); +} - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 - function removeCollectionAdminSubstrate(uint256 admin) public { +/// @title ERC-721 Non-Fungible Token Standard +/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md +/// @dev the ERC-165 identifier for this interface is 0x80ac58cd +contract ERC721 is Dummy, ERC165, ERC721Events { + /// @notice Count all NFTs assigned to an owner + /// @dev NFTs assigned to the zero address are considered invalid, and this + /// function throws for queries about the zero address. + /// @param owner An address for whom to query the balance + /// @return The number of NFTs owned by `owner`, possibly zero + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) public view returns (uint256) { require(false, stub_error); - admin; - dummy = 0; + owner; + dummy; + return 0; } - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 - function addCollectionAdmin(address newAdmin) public { + /// @notice Find the owner of an NFT + /// @dev NFTs assigned to zero address are considered invalid, and queries + /// about them do throw. + /// @param tokenId The identifier for an NFT + /// @return The address of the owner of the NFT + /// @dev EVM selector for this function is: 0x6352211e, + /// or in textual repr: ownerOf(uint256) + function ownerOf(uint256 tokenId) public view returns (address) { require(false, stub_error); - newAdmin; - dummy = 0; + tokenId; + dummy; + return 0x0000000000000000000000000000000000000000; } - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 - function removeCollectionAdmin(address admin) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xb88d4fde, + /// or in textual repr: safeTransferFrom(address,address,uint256,bytes) + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes memory data + ) public { require(false, stub_error); - admin; + from; + to; + tokenId; + data; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 - function setCollectionNesting(bool enable) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x42842e0e, + /// or in textual repr: safeTransferFrom(address,address,uint256) + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) public { require(false, stub_error); - enable; + from; + to; + tokenId; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 - function setCollectionNesting(bool enable, address[] memory collections) - public - { + /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE + /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE + /// THEY MAY BE PERMANENTLY LOST + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this NFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param from The current owner of the NFT + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 tokenId + ) public { require(false, stub_error); - enable; - collections; + from; + to; + tokenId; dummy = 0; } - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c - function setCollectionAccess(uint8 mode) public { + /// @notice Set or reaffirm the approved address for an NFT + /// @dev The zero address indicates there is no approved address. + /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized + /// operator of the current owner. + /// @param approved The new approved NFT controller + /// @param tokenId The NFT to approve + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address approved, uint256 tokenId) public { require(false, stub_error); - mode; + approved; + tokenId; dummy = 0; } - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 - function addToCollectionAllowList(address user) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xa22cb465, + /// or in textual repr: setApprovalForAll(address,bool) + function setApprovalForAll(address operator, bool approved) public { require(false, stub_error); - user; - dummy = 0; - } - - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb - function removeFromCollectionAllowList(address user) public { - require(false, stub_error); - user; + operator; + approved; dummy = 0; } - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 - function setCollectionMintMode(bool mode) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x081812fc, + /// or in textual repr: getApproved(uint256) + function getApproved(uint256 tokenId) public view returns (address) { require(false, stub_error); - mode; - dummy = 0; - } - - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 - function isOwnerOrAdmin(address user) public view returns (bool) { - require(false, stub_error); - user; + tokenId; dummy; - return false; + return 0x0000000000000000000000000000000000000000; } - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 - function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xe985e9c5, + /// or in textual repr: isApprovedForAll(address,address) + function isApprovedForAll(address owner, address operator) + public + view + returns (address) + { require(false, stub_error); - user; + owner; + operator; dummy; - return false; - } - - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 - function uniqueCollectionType() public returns (string memory) { - require(false, stub_error); - dummy = 0; - return ""; - } - - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 - function setOwner(address newOwner) public { - require(false, stub_error); - newOwner; - dummy = 0; - } - - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f - function setOwnerSubstrate(uint256 newOwner) public { - require(false, stub_error); - newOwner; - dummy = 0; + return 0x0000000000000000000000000000000000000000; } } --- a/pallets/refungible/src/erc.rs +++ b/pallets/refungible/src/erc.rs @@ -53,14 +53,14 @@ pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff); /// @title A contract that allows to set and delete token properties and change token property permissions. -#[solidity_interface(name = "TokenProperties")] +#[solidity_interface(name = TokenProperties)] impl RefungibleHandle { /// @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 is_mutable Permission to mutate property. - /// @param collection_admin Permission to mutate property by collection admin if property is mutable. - /// @param token_owner Permission to mutate property by token owner if property is mutable. + /// @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. fn set_token_property_permission( &mut self, caller: caller, @@ -197,7 +197,7 @@ MintingFinished {}, } -#[solidity_interface(name = "ERC721Metadata")] +#[solidity_interface(name = ERC721Metadata)] impl RefungibleHandle { /// @notice A descriptive name for a collection of RFTs in this contract fn name(&self) -> Result { @@ -258,7 +258,7 @@ /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 -#[solidity_interface(name = "ERC721Enumerable")] +#[solidity_interface(name = ERC721Enumerable)] impl RefungibleHandle { /// @notice Enumerate valid RFTs /// @param index A counter less than `totalSupply()` @@ -285,7 +285,7 @@ /// @title ERC-721 Non-Fungible Token Standard /// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md -#[solidity_interface(name = "ERC721", events(ERC721Events))] +#[solidity_interface(name = ERC721, events(ERC721Events))] impl RefungibleHandle { /// @notice Count all RFTs assigned to an owner /// @dev RFTs assigned to the zero address are considered invalid, and this @@ -322,7 +322,6 @@ _to: address, _token_id: uint256, _data: bytes, - _value: value, ) -> Result { // TODO: Not implemetable Err("not implemented".into()) @@ -334,7 +333,6 @@ _from: address, _to: address, _token_id: uint256, - _value: value, ) -> Result { // TODO: Not implemetable Err("not implemented".into()) @@ -350,7 +348,6 @@ /// @param from The current owner of the NFT /// @param to The new owner /// @param tokenId The NFT to transfer - /// @param _value Not used for an NFT #[weight(>::transfer_from_creating_removing())] fn transfer_from( &mut self, @@ -358,7 +355,6 @@ from: address, to: address, token_id: uint256, - _value: value, ) -> Result { let caller = T::CrossAccountId::from_eth(caller); let from = T::CrossAccountId::from_eth(from); @@ -378,13 +374,7 @@ } /// @dev Not implemented - fn approve( - &mut self, - _caller: caller, - _approved: address, - _token_id: uint256, - _value: value, - ) -> Result { + fn approve(&mut self, _caller: caller, _approved: address, _token_id: uint256) -> Result { Err("not implemented".into()) } @@ -438,7 +428,7 @@ } /// @title ERC721 Token that can be irreversibly burned (destroyed). -#[solidity_interface(name = "ERC721Burnable")] +#[solidity_interface(name = ERC721Burnable)] impl RefungibleHandle { /// @notice Burns a specific ERC721 token. /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized @@ -458,7 +448,7 @@ } /// @title ERC721 minting logic. -#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))] +#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))] impl RefungibleHandle { fn minting_finished(&self) -> Result { Ok(false) @@ -616,7 +606,7 @@ } /// @title Unique extensions for ERC721. -#[solidity_interface(name = "ERC721UniqueExtensions")] +#[solidity_interface(name = ERC721UniqueExtensions)] impl RefungibleHandle { /// @notice Transfer ownership of an RFT /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` @@ -624,15 +614,8 @@ /// Throws if RFT pieces have multiple owners. /// @param to The new owner /// @param tokenId The RFT to transfer - /// @param _value Not used for an RFT #[weight(>::transfer_creating_removing())] - fn transfer( - &mut self, - caller: caller, - to: address, - token_id: uint256, - _value: value, - ) -> Result { + fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result { let caller = T::CrossAccountId::from_eth(caller); let to = T::CrossAccountId::from_eth(to); let token = token_id.try_into()?; @@ -655,15 +638,8 @@ /// Throws if RFT pieces have multiple owners. /// @param from The current owner of the RFT /// @param tokenId The RFT to transfer - /// @param _value Not used for an RFT #[weight(>::burn_from())] - fn burn_from( - &mut self, - caller: caller, - from: address, - token_id: uint256, - _value: value, - ) -> Result { + fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result { let caller = T::CrossAccountId::from_eth(caller); let from = T::CrossAccountId::from_eth(from); let token = token_id.try_into()?; @@ -801,7 +777,7 @@ } #[solidity_interface( - name = "UniqueRefungible", + name = UniqueRefungible, is( ERC721, ERC721Metadata, @@ -809,7 +785,7 @@ ERC721UniqueExtensions, ERC721Mintable, ERC721Burnable, - via("CollectionHandle", common_mut, Collection), + Collection(common_mut, CollectionHandle), TokenProperties, ) )] --- a/pallets/refungible/src/erc_token.rs +++ b/pallets/refungible/src/erc_token.rs @@ -49,7 +49,7 @@ pub struct RefungibleTokenHandle(pub RefungibleHandle, pub TokenId); -#[solidity_interface(name = "ERC1633")] +#[solidity_interface(name = ERC1633)] impl RefungibleTokenHandle { fn parent_token(&self) -> Result
{ self.consume_store_reads(2)?; @@ -87,7 +87,7 @@ } } -#[solidity_interface(name = "ERC1633UniqueExtensions")] +#[solidity_interface(name = ERC1633UniqueExtensions)] impl RefungibleTokenHandle { #[solidity(rename_selector = "setParentNFT")] #[weight(>::token_owner() + >::set_parent_nft_unchecked())] @@ -137,7 +137,7 @@ /// /// @dev Implementation of the basic standard token. /// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md -#[solidity_interface(name = "ERC20", events(ERC20Events))] +#[solidity_interface(name = ERC20, events(ERC20Events))] impl RefungibleTokenHandle { /// @return the name of the token. fn name(&self) -> Result { @@ -246,7 +246,7 @@ } } -#[solidity_interface(name = "ERC20UniqueExtensions")] +#[solidity_interface(name = ERC20UniqueExtensions)] impl RefungibleTokenHandle { /// @dev Function that burns an amount of the token of a given account, /// deducting from the sender's allowance for said account. @@ -306,7 +306,7 @@ } #[solidity_interface( - name = "UniqueRefungibleToken", + name = UniqueRefungibleToken, is(ERC20, ERC20UniqueExtensions, ERC1633, ERC1633UniqueExtensions) )] impl RefungibleTokenHandle where T::AccountId: From<[u8; 32]> {} --- a/pallets/refungible/src/stubs/UniqueRefungible.sol +++ b/pallets/refungible/src/stubs/UniqueRefungible.sol @@ -3,13 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct -struct Tuple0 { - uint256 field_0; - string field_1; -} - -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -27,40 +21,17 @@ } } -// Inline -contract ERC721Events { - event Transfer( - address indexed from, - address indexed to, - uint256 indexed tokenId - ); - event Approval( - address indexed owner, - address indexed approved, - uint256 indexed tokenId - ); - event ApprovalForAll( - address indexed owner, - address indexed operator, - bool approved - ); -} - -// Inline -contract ERC721MintableEvents { - event MintingFinished(); -} - -// Selector: 41369377 +/// @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 0x41369377 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 is_mutable Permission to mutate property. - // @param collection_admin Permission to mutate property by collection admin if property is mutable. - // @param token_owner Permission to mutate property by token owner if property is mutable. - // - // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa + /// @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, @@ -75,13 +46,13 @@ dummy = 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. - // @param key Property key. - // @param value Property value. - // - // Selector: setProperty(uint256,string,bytes) 1752d67b + /// @notice Set 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. + /// @param value Property value. + /// @dev EVM selector for this function is: 0x1752d67b, + /// or in textual repr: setProperty(uint256,string,bytes) function setProperty( uint256 tokenId, string memory key, @@ -94,12 +65,12 @@ dummy = 0; } - // @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. - // - // Selector: deleteProperty(uint256,string) 066111d1 + /// @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; @@ -107,13 +78,13 @@ dummy = 0; } - // @notice Get token property value. - // @dev Throws error if key not found - // @param tokenId ID of the token. - // @param key Property key. - // @return Property value bytes - // - // Selector: property(uint256,string) 7228c327 + /// @notice Get token property value. + /// @dev Throws error if key not found + /// @param tokenId ID of the token. + /// @param key Property key. + /// @return Property value bytes + /// @dev EVM selector for this function is: 0x7228c327, + /// or in textual repr: property(uint256,string) function property(uint256 tokenId, string memory key) public view @@ -127,211 +98,334 @@ } } -// Selector: 42966c68 -contract ERC721Burnable is Dummy, ERC165 { - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized - // operator of the current owner. - // @param tokenId The RFT to approve - // - // Selector: burn(uint256) 42966c68 - function burn(uint256 tokenId) public { +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 +contract Collection is Dummy, ERC165 { + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) + function setCollectionProperty(string memory key, bytes memory value) + public + { require(false, stub_error); - tokenId; + key; + value; dummy = 0; } -} -// Selector: 58800161 -contract ERC721 is Dummy, ERC165, ERC721Events { - // @notice Count all RFTs assigned to an owner - // @dev RFTs assigned to the zero address are considered invalid, and this - // function throws for queries about the zero address. - // @param owner An address for whom to query the balance - // @return The number of RFTs owned by `owner`, possibly zero - // - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) public view returns (uint256) { + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) + function deleteCollectionProperty(string memory key) public { require(false, stub_error); - owner; - dummy; - return 0; + key; + dummy = 0; } - // @notice Find the owner of an RFT - // @dev RFTs assigned to zero address are considered invalid, and queries - // about them do throw. - // Returns special 0xffffffffffffffffffffffffffffffffffffffff address for - // the tokens that are partially owned. - // @param tokenId The identifier for an RFT - // @return The address of the owner of the RFT - // - // Selector: ownerOf(uint256) 6352211e - function ownerOf(uint256 tokenId) public view returns (address) { + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) + function collectionProperty(string memory key) + public + view + returns (bytes memory) + { require(false, stub_error); - tokenId; + key; dummy; - return 0x0000000000000000000000000000000000000000; + return hex""; } - // @dev Not implemented - // - // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672 - function safeTransferFromWithData( - address from, - address to, - uint256 tokenId, - bytes memory data - ) public { + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) + function setCollectionSponsor(address sponsor) public { require(false, stub_error); - from; - to; - tokenId; - data; + sponsor; dummy = 0; } - // @dev Not implemented - // - // Selector: safeTransferFrom(address,address,uint256) 42842e0e - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) public { + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() + function confirmCollectionSponsorship() public { require(false, stub_error); - from; - to; - tokenId; dummy = 0; } - // @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE - // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE - // THEY MAY BE PERMANENTLY LOST - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this RFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param from The current owner of the NFT - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 tokenId - ) public { + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) + function setCollectionLimit(string memory limit, uint32 value) public { require(false, stub_error); - from; - to; - tokenId; + limit; + value; dummy = 0; } - // @dev Not implemented - // - // Selector: approve(address,uint256) 095ea7b3 - function approve(address approved, uint256 tokenId) public { + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) + function setCollectionLimit(string memory limit, bool value) public { require(false, stub_error); - approved; - tokenId; + limit; + value; dummy = 0; } - // @dev Not implemented - // - // Selector: setApprovalForAll(address,bool) a22cb465 - function setApprovalForAll(address operator, bool approved) public { + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() + function contractAddress() public view returns (address) { require(false, stub_error); - operator; - approved; + dummy; + return 0x0000000000000000000000000000000000000000; + } + + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) + function addCollectionAdminSubstrate(uint256 newAdmin) public { + require(false, stub_error); + newAdmin; dummy = 0; } - // @dev Not implemented - // - // Selector: getApproved(uint256) 081812fc - function getApproved(uint256 tokenId) public view returns (address) { + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) + function removeCollectionAdminSubstrate(uint256 admin) public { require(false, stub_error); - tokenId; - dummy; - return 0x0000000000000000000000000000000000000000; + admin; + dummy = 0; } - // @dev Not implemented - // - // Selector: isApprovedForAll(address,address) e985e9c5 - function isApprovedForAll(address owner, address operator) + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) + function addCollectionAdmin(address newAdmin) public { + require(false, stub_error); + newAdmin; + dummy = 0; + } + + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) + function removeCollectionAdmin(address admin) public { + require(false, stub_error); + admin; + dummy = 0; + } + + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) + function setCollectionNesting(bool enable) public { + require(false, stub_error); + enable; + dummy = 0; + } + + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) + function setCollectionNesting(bool enable, address[] memory collections) public - view - returns (address) { require(false, stub_error); - owner; - operator; + enable; + collections; + dummy = 0; + } + + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) + function setCollectionAccess(uint8 mode) public { + require(false, stub_error); + mode; + dummy = 0; + } + + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) + function addToCollectionAllowList(address user) public { + require(false, stub_error); + user; + dummy = 0; + } + + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) + function removeFromCollectionAllowList(address user) public { + require(false, stub_error); + user; + dummy = 0; + } + + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) + function setCollectionMintMode(bool mode) public { + require(false, stub_error); + mode; + dummy = 0; + } + + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) + function isOwnerOrAdmin(address user) public view returns (bool) { + require(false, stub_error); + user; dummy; - return 0x0000000000000000000000000000000000000000; + return false; } -} -// Selector: 5b5e139f -contract ERC721Metadata is Dummy, ERC165 { - // @notice A descriptive name for a collection of RFTs in this contract - // - // Selector: name() 06fdde03 - function name() public view returns (string memory) { + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) + function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) { require(false, stub_error); + user; dummy; - return ""; + return false; } - // @notice An abbreviated name for RFTs in this contract - // - // Selector: symbol() 95d89b41 - function symbol() public view returns (string memory) { + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() + function uniqueCollectionType() public returns (string memory) { require(false, stub_error); - dummy; + dummy = 0; return ""; } - // @notice A distinct Uniform Resource Identifier (URI) for a given asset. - // - // @dev If the token has a `url` property and it is not empty, it is returned. - // 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`. - // If the collection property `baseURI` is empty or absent, return "" (empty string) - // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix - // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). - // - // @return token's const_metadata - // - // Selector: tokenURI(uint256) c87b56dd - function tokenURI(uint256 tokenId) public view returns (string memory) { + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) + function setOwner(address newOwner) public { require(false, stub_error); + newOwner; + dummy = 0; + } + + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) + function setOwnerSubstrate(uint256 newOwner) public { + require(false, stub_error); + newOwner; + dummy = 0; + } +} + +/// @title ERC721 Token that can be irreversibly burned (destroyed). +/// @dev the ERC-165 identifier for this interface is 0x42966c68 +contract ERC721Burnable is Dummy, ERC165 { + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized + /// operator of the current owner. + /// @param tokenId The RFT to approve + /// @dev EVM selector for this function is: 0x42966c68, + /// or in textual repr: burn(uint256) + function burn(uint256 tokenId) public { + require(false, stub_error); tokenId; - dummy; - return ""; + dummy = 0; } } -// Selector: 68ccfe89 +/// @dev inlined interface +contract ERC721MintableEvents { + event MintingFinished(); +} + +/// @title ERC721 minting logic. +/// @dev the ERC-165 identifier for this interface is 0x68ccfe89 contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents { - // Selector: mintingFinished() 05d2035b + /// @dev EVM selector for this function is: 0x05d2035b, + /// or in textual repr: mintingFinished() function mintingFinished() public view returns (bool) { require(false, stub_error); dummy; return false; } - // @notice Function to mint token. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted RFT - // - // Selector: mint(address,uint256) 40c10f19 + /// @notice Function to mint token. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted RFT + /// @dev EVM selector for this function is: 0x40c10f19, + /// or in textual repr: mint(address,uint256) function mint(address to, uint256 tokenId) public returns (bool) { require(false, stub_error); to; @@ -340,14 +434,14 @@ return false; } - // @notice Function to mint token with the given tokenUri. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted RFT - // @param tokenUri Token URI that would be stored in the RFT properties - // - // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f + /// @notice Function to mint token with the given tokenUri. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted RFT + /// @param tokenUri Token URI that would be stored in the RFT properties + /// @dev EVM selector for this function is: 0x50bb4e7f, + /// or in textual repr: mintWithTokenURI(address,uint256,string) function mintWithTokenURI( address to, uint256 tokenId, @@ -361,9 +455,9 @@ return false; } - // @dev Not implemented - // - // Selector: finishMinting() 7d64bcb4 + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x7d64bcb4, + /// or in textual repr: finishMinting() function finishMinting() public returns (bool) { require(false, stub_error); dummy = 0; @@ -371,59 +465,17 @@ } } -// Selector: 780e9d63 -contract ERC721Enumerable is Dummy, ERC165 { - // @notice Enumerate valid RFTs - // @param index A counter less than `totalSupply()` - // @return The token identifier for the `index`th NFT, - // (sort order not specified) - // - // Selector: tokenByIndex(uint256) 4f6ccce7 - function tokenByIndex(uint256 index) public view returns (uint256) { - require(false, stub_error); - index; - dummy; - return 0; - } - - // Not implemented - // - // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59 - function tokenOfOwnerByIndex(address owner, uint256 index) - public - view - returns (uint256) - { - require(false, stub_error); - owner; - index; - dummy; - return 0; - } - - // @notice Count RFTs tracked by this contract - // @return A count of valid RFTs tracked by this contract, where each one of - // them has an assigned and queryable owner not equal to the zero address - // - // Selector: totalSupply() 18160ddd - function totalSupply() public view returns (uint256) { - require(false, stub_error); - dummy; - return 0; - } -} - -// Selector: 7c3bef89 +/// @title Unique extensions for ERC721. +/// @dev the ERC-165 identifier for this interface is 0x7c3bef89 contract ERC721UniqueExtensions is Dummy, ERC165 { - // @notice Transfer ownership of an RFT - // @dev Throws unless `msg.sender` is the current owner. Throws if `to` - // is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param to The new owner - // @param tokenId The RFT to transfer - // @param _value Not used for an RFT - // - // Selector: transfer(address,uint256) a9059cbb + /// @notice Transfer ownership of an RFT + /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` + /// is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param to The new owner + /// @param tokenId The RFT to transfer + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 tokenId) public { require(false, stub_error); to; @@ -431,16 +483,15 @@ dummy = 0; } - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this RFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param from The current owner of the RFT - // @param tokenId The RFT to transfer - // @param _value Not used for an RFT - // - // Selector: burnFrom(address,uint256) 79cc6790 + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this RFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param from The current owner of the RFT + /// @param tokenId The RFT to transfer + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) function burnFrom(address from, uint256 tokenId) public { require(false, stub_error); from; @@ -448,22 +499,22 @@ dummy = 0; } - // @notice Returns next free RFT ID. - // - // Selector: nextTokenId() 75794a3c + /// @notice Returns next free RFT ID. + /// @dev EVM selector for this function is: 0x75794a3c, + /// or in textual repr: nextTokenId() function nextTokenId() public view returns (uint256) { require(false, stub_error); dummy; return 0; } - // @notice Function to mint multiple tokens. - // @dev `tokenIds` should be an array of consecutive numbers and first number - // should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokenIds IDs of the minted RFTs - // - // Selector: mintBulk(address,uint256[]) 44a9945e + /// @notice Function to mint multiple tokens. + /// @dev `tokenIds` should be an array of consecutive numbers and first number + /// should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokenIds IDs of the minted RFTs + /// @dev EVM selector for this function is: 0x44a9945e, + /// or in textual repr: mintBulk(address,uint256[]) function mintBulk(address to, uint256[] memory tokenIds) public returns (bool) @@ -475,14 +526,14 @@ return false; } - // @notice Function to mint multiple tokens with the given tokenUris. - // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive - // numbers and first number should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokens array of pairs of token ID and token URI for minted tokens - // - // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006 - function mintBulkWithTokenURI(address to, Tuple0[] memory tokens) + /// @notice Function to mint multiple tokens with the given tokenUris. + /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive + /// numbers and first number should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokens array of pairs of token ID and token URI for minted tokens + /// @dev EVM selector for this function is: 0x36543006, + /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) + function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) { @@ -493,11 +544,11 @@ return false; } - // Returns EVM address for refungible token - // - // @param token ID of the token - // - // Selector: tokenContractAddress(uint256) ab76fac6 + /// Returns EVM address for refungible token + /// + /// @param token ID of the token + /// @dev EVM selector for this function is: 0xab76fac6, + /// or in textual repr: tokenContractAddress(uint256) function tokenContractAddress(uint256 token) public view returns (address) { require(false, stub_error); token; @@ -506,291 +557,247 @@ } } -// Selector: ffe4da23 -contract Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 - function setCollectionProperty(string memory key, bytes memory value) - public - { - require(false, stub_error); - key; - value; - dummy = 0; - } +/// @dev anonymous struct +struct Tuple8 { + uint256 field_0; + string field_1; +} - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce - function deleteCollectionProperty(string memory key) public { +/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x780e9d63 +contract ERC721Enumerable is Dummy, ERC165 { + /// @notice Enumerate valid RFTs + /// @param index A counter less than `totalSupply()` + /// @return The token identifier for the `index`th NFT, + /// (sort order not specified) + /// @dev EVM selector for this function is: 0x4f6ccce7, + /// or in textual repr: tokenByIndex(uint256) + function tokenByIndex(uint256 index) public view returns (uint256) { require(false, stub_error); - key; - dummy = 0; + index; + dummy; + return 0; } - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d - function collectionProperty(string memory key) + /// Not implemented + /// @dev EVM selector for this function is: 0x2f745c59, + /// or in textual repr: tokenOfOwnerByIndex(address,uint256) + function tokenOfOwnerByIndex(address owner, uint256 index) public view - returns (bytes memory) + returns (uint256) { require(false, stub_error); - key; + owner; + index; dummy; - return hex""; + return 0; } - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e - function setCollectionSponsor(address sponsor) public { + /// @notice Count RFTs tracked by this contract + /// @return A count of valid RFTs tracked by this contract, where each one of + /// them has an assigned and queryable owner not equal to the zero address + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() public view returns (uint256) { require(false, stub_error); - sponsor; - dummy = 0; + dummy; + return 0; } +} - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a - function confirmCollectionSponsorship() public { +/// @dev the ERC-165 identifier for this interface is 0x5b5e139f +contract ERC721Metadata is Dummy, ERC165 { + /// @notice A descriptive name for a collection of RFTs in this contract + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() public view returns (string memory) { require(false, stub_error); - dummy = 0; + dummy; + return ""; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db - function setCollectionLimit(string memory limit, uint32 value) public { + /// @notice An abbreviated name for RFTs in this contract + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() public view returns (string memory) { require(false, stub_error); - limit; - value; - dummy = 0; + dummy; + return ""; } - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba - function setCollectionLimit(string memory limit, bool value) public { + /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. + /// + /// @dev If the token has a `url` property and it is not empty, it is returned. + /// 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`. + /// If the collection property `baseURI` is empty or absent, return "" (empty string) + /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix + /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). + /// + /// @return token's const_metadata + /// @dev EVM selector for this function is: 0xc87b56dd, + /// or in textual repr: tokenURI(uint256) + function tokenURI(uint256 tokenId) public view returns (string memory) { require(false, stub_error); - limit; - value; - dummy = 0; - } - - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 - function contractAddress() public view returns (address) { - require(false, stub_error); + tokenId; dummy; - return 0x0000000000000000000000000000000000000000; + return ""; } +} - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b - function addCollectionAdminSubstrate(uint256 newAdmin) public { - require(false, stub_error); - newAdmin; - dummy = 0; - } +/// @dev inlined interface +contract ERC721Events { + event Transfer( + address indexed from, + address indexed to, + uint256 indexed tokenId + ); + event Approval( + address indexed owner, + address indexed approved, + uint256 indexed tokenId + ); + event ApprovalForAll( + address indexed owner, + address indexed operator, + bool approved + ); +} - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 - function removeCollectionAdminSubstrate(uint256 admin) public { +/// @title ERC-721 Non-Fungible Token Standard +/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md +/// @dev the ERC-165 identifier for this interface is 0x58800161 +contract ERC721 is Dummy, ERC165, ERC721Events { + /// @notice Count all RFTs assigned to an owner + /// @dev RFTs assigned to the zero address are considered invalid, and this + /// function throws for queries about the zero address. + /// @param owner An address for whom to query the balance + /// @return The number of RFTs owned by `owner`, possibly zero + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) public view returns (uint256) { require(false, stub_error); - admin; - dummy = 0; + owner; + dummy; + return 0; } - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 - function addCollectionAdmin(address newAdmin) public { + /// @notice Find the owner of an RFT + /// @dev RFTs assigned to zero address are considered invalid, and queries + /// about them do throw. + /// Returns special 0xffffffffffffffffffffffffffffffffffffffff address for + /// the tokens that are partially owned. + /// @param tokenId The identifier for an RFT + /// @return The address of the owner of the RFT + /// @dev EVM selector for this function is: 0x6352211e, + /// or in textual repr: ownerOf(uint256) + function ownerOf(uint256 tokenId) public view returns (address) { require(false, stub_error); - newAdmin; - dummy = 0; + tokenId; + dummy; + return 0x0000000000000000000000000000000000000000; } - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 - function removeCollectionAdmin(address admin) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x60a11672, + /// or in textual repr: safeTransferFromWithData(address,address,uint256,bytes) + function safeTransferFromWithData( + address from, + address to, + uint256 tokenId, + bytes memory data + ) public { require(false, stub_error); - admin; + from; + to; + tokenId; + data; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 - function setCollectionNesting(bool enable) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x42842e0e, + /// or in textual repr: safeTransferFrom(address,address,uint256) + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) public { require(false, stub_error); - enable; + from; + to; + tokenId; dummy = 0; } - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 - function setCollectionNesting(bool enable, address[] memory collections) - public - { - require(false, stub_error); - enable; - collections; - dummy = 0; - } - - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c - function setCollectionAccess(uint8 mode) public { + /// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE + /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE + /// THEY MAY BE PERMANENTLY LOST + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this RFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param from The current owner of the NFT + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 tokenId + ) public { require(false, stub_error); - mode; - dummy = 0; - } - - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 - function addToCollectionAllowList(address user) public { - require(false, stub_error); - user; + from; + to; + tokenId; dummy = 0; } - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb - function removeFromCollectionAllowList(address user) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address approved, uint256 tokenId) public { require(false, stub_error); - user; + approved; + tokenId; dummy = 0; } - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 - function setCollectionMintMode(bool mode) public { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xa22cb465, + /// or in textual repr: setApprovalForAll(address,bool) + function setApprovalForAll(address operator, bool approved) public { require(false, stub_error); - mode; + operator; + approved; dummy = 0; } - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 - function isOwnerOrAdmin(address user) public view returns (bool) { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x081812fc, + /// or in textual repr: getApproved(uint256) + function getApproved(uint256 tokenId) public view returns (address) { require(false, stub_error); - user; + tokenId; dummy; - return false; + return 0x0000000000000000000000000000000000000000; } - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 - function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) { + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xe985e9c5, + /// or in textual repr: isApprovedForAll(address,address) + function isApprovedForAll(address owner, address operator) + public + view + returns (address) + { require(false, stub_error); - user; + owner; + operator; dummy; - return false; - } - - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 - function uniqueCollectionType() public returns (string memory) { - require(false, stub_error); - dummy = 0; - return ""; - } - - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 - function setOwner(address newOwner) public { - require(false, stub_error); - newOwner; - dummy = 0; - } - - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f - function setOwnerSubstrate(uint256 newOwner) public { - require(false, stub_error); - newOwner; - dummy = 0; + return 0x0000000000000000000000000000000000000000; } } --- a/pallets/refungible/src/stubs/UniqueRefungibleToken.sol +++ b/pallets/refungible/src/stubs/UniqueRefungibleToken.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -21,19 +21,10 @@ } } -// Inline -contract ERC20Events { - event Transfer(address indexed from, address indexed to, uint256 value); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - -// Selector: 042f1106 +/// @dev the ERC-165 identifier for this interface is 0x042f1106 contract ERC1633UniqueExtensions is Dummy, ERC165 { - // Selector: setParentNFT(address,uint256) 042f1106 + /// @dev EVM selector for this function is: 0x042f1106, + /// or in textual repr: setParentNFT(address,uint256) function setParentNFT(address collection, uint256 nftId) public returns (bool) @@ -46,16 +37,18 @@ } } -// Selector: 5755c3f2 +/// @dev the ERC-165 identifier for this interface is 0x5755c3f2 contract ERC1633 is Dummy, ERC165 { - // Selector: parentToken() 80a54001 + /// @dev EVM selector for this function is: 0x80a54001, + /// or in textual repr: parentToken() function parentToken() public view returns (address) { require(false, stub_error); dummy; return 0x0000000000000000000000000000000000000000; } - // Selector: parentTokenId() d7f083f3 + /// @dev EVM selector for this function is: 0xd7f083f3, + /// or in textual repr: parentTokenId() function parentTokenId() public view returns (uint256) { require(false, stub_error); dummy; @@ -63,49 +56,92 @@ } } -// Selector: 942e8b22 +/// @dev the ERC-165 identifier for this interface is 0xab8deb37 +contract ERC20UniqueExtensions is Dummy, ERC165 { + /// @dev Function that burns an amount of the token of a given account, + /// deducting from the sender's allowance for said account. + /// @param from The account whose tokens will be burnt. + /// @param amount The amount that will be burnt. + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) + function burnFrom(address from, uint256 amount) public returns (bool) { + require(false, stub_error); + from; + amount; + dummy = 0; + return false; + } + + /// @dev Function that changes total amount of the tokens. + /// Throws if `msg.sender` doesn't owns all of the tokens. + /// @param amount New total amount of the tokens. + /// @dev EVM selector for this function is: 0xd2418ca7, + /// or in textual repr: repartition(uint256) + function repartition(uint256 amount) public returns (bool) { + require(false, stub_error); + amount; + dummy = 0; + return false; + } +} + +/// @dev inlined interface +contract ERC20Events { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + +/// @title Standard ERC20 token +/// +/// @dev Implementation of the basic standard token. +/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md +/// @dev the ERC-165 identifier for this interface is 0x942e8b22 contract ERC20 is Dummy, ERC165, ERC20Events { - // @return the name of the token. - // - // Selector: name() 06fdde03 + /// @return the name of the token. + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() function name() public view returns (string memory) { require(false, stub_error); dummy; return ""; } - // @return the symbol of the token. - // - // Selector: symbol() 95d89b41 + /// @return the symbol of the token. + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() function symbol() public view returns (string memory) { require(false, stub_error); dummy; return ""; } - // @dev Total number of tokens in existence - // - // Selector: totalSupply() 18160ddd + /// @dev Total number of tokens in existence + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() function totalSupply() public view returns (uint256) { require(false, stub_error); dummy; return 0; } - // @dev Not supported - // - // Selector: decimals() 313ce567 + /// @dev Not supported + /// @dev EVM selector for this function is: 0x313ce567, + /// or in textual repr: decimals() function decimals() public view returns (uint8) { require(false, stub_error); dummy; return 0; } - // @dev Gets the balance of the specified address. - // @param owner The address to query the balance of. - // @return An uint256 representing the amount owned by the passed address. - // - // Selector: balanceOf(address) 70a08231 + /// @dev Gets the balance of the specified address. + /// @param owner The address to query the balance of. + /// @return An uint256 representing the amount owned by the passed address. + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) function balanceOf(address owner) public view returns (uint256) { require(false, stub_error); owner; @@ -113,11 +149,11 @@ return 0; } - // @dev Transfer token for a specified address - // @param to The address to transfer to. - // @param amount The amount to be transferred. - // - // Selector: transfer(address,uint256) a9059cbb + /// @dev Transfer token for a specified address + /// @param to The address to transfer to. + /// @param amount The amount to be transferred. + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 amount) public returns (bool) { require(false, stub_error); to; @@ -126,12 +162,12 @@ return false; } - // @dev Transfer tokens from one address to another - // @param from address The address which you want to send tokens from - // @param to address The address which you want to transfer to - // @param amount uint256 the amount of tokens to be transferred - // - // Selector: transferFrom(address,address,uint256) 23b872dd + /// @dev Transfer tokens from one address to another + /// @param from address The address which you want to send tokens from + /// @param to address The address which you want to transfer to + /// @param amount uint256 the amount of tokens to be transferred + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) function transferFrom( address from, address to, @@ -145,15 +181,15 @@ return false; } - // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`. - // Beware that changing an allowance with this method brings the risk that someone may use both the old - // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this - // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: - // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - // @param spender The address which will spend the funds. - // @param amount The amount of tokens to be spent. - // - // Selector: approve(address,uint256) 095ea7b3 + /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`. + /// Beware that changing an allowance with this method brings the risk that someone may use both the old + /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this + /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: + /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + /// @param spender The address which will spend the funds. + /// @param amount The amount of tokens to be spent. + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) function approve(address spender, uint256 amount) public returns (bool) { require(false, stub_error); spender; @@ -162,12 +198,12 @@ return false; } - // @dev Function to check the amount of tokens that an owner allowed to a spender. - // @param owner address The address which owns the funds. - // @param spender address The address which will spend the funds. - // @return A uint256 specifying the amount of tokens still available for the spender. - // - // Selector: allowance(address,address) dd62ed3e + /// @dev Function to check the amount of tokens that an owner allowed to a spender. + /// @param owner address The address which owns the funds. + /// @param spender address The address which will spend the funds. + /// @return A uint256 specifying the amount of tokens still available for the spender. + /// @dev EVM selector for this function is: 0xdd62ed3e, + /// or in textual repr: allowance(address,address) function allowance(address owner, address spender) public view @@ -178,35 +214,6 @@ spender; dummy; return 0; - } -} - -// Selector: ab8deb37 -contract ERC20UniqueExtensions is Dummy, ERC165 { - // @dev Function that burns an amount of the token of a given account, - // deducting from the sender's allowance for said account. - // @param from The account whose tokens will be burnt. - // @param amount The amount that will be burnt. - // - // Selector: burnFrom(address,uint256) 79cc6790 - function burnFrom(address from, uint256 amount) public returns (bool) { - require(false, stub_error); - from; - amount; - dummy = 0; - return false; - } - - // @dev Function that changes total amount of the tokens. - // Throws if `msg.sender` doesn't owns all of the tokens. - // @param amount New total amount of the tokens. - // - // Selector: repartition(uint256) d2418ca7 - function repartition(uint256 amount) public returns (bool) { - require(false, stub_error); - amount; - dummy = 0; - return false; } } --- a/pallets/unique/src/eth/mod.rs +++ b/pallets/unique/src/eth/mod.rs @@ -203,7 +203,7 @@ } /// @title Contract, which allows users to operate with collections -#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))] +#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))] impl EvmCollectionHelpers where T: Config + pallet_nonfungible::Config + pallet_refungible::Config, @@ -211,7 +211,7 @@ /// Create an NFT collection /// @param name Name of the collection /// @param description Informative description of the collection - /// @param token_prefix Token prefix to represent the collection tokens in UI and user applications + /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications /// @return address Address of the newly created collection #[weight(>::create_collection())] fn create_nonfungible_collection( @@ -304,7 +304,7 @@ } /// Check if a collection exists - /// @param collection_address Address of the collection in question + /// @param collectionAddress Address of the collection in question /// @return bool Does the collection exist? fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result { if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) { --- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol +++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder contract Dummy { uint8 dummy; string stub_error = "this contract is implemented in native"; @@ -21,7 +21,7 @@ } } -// Inline +/// @dev inlined interface contract CollectionHelpersEvents { event CollectionCreated( address indexed owner, @@ -29,15 +29,16 @@ ); } -// Selector: 675f3074 +/// @title Contract, which allows users to operate with collections +/// @dev the ERC-165 identifier for this interface is 0x675f3074 contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents { - // Create an NFT collection - // @param name Name of the collection - // @param description Informative description of the collection - // @param token_prefix Token prefix to represent the collection tokens in UI and user applications - // @return address Address of the newly created collection - // - // Selector: createNonfungibleCollection(string,string,string) e34a6844 + /// Create an NFT collection + /// @param name Name of the collection + /// @param description Informative description of the collection + /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications + /// @return address Address of the newly created collection + /// @dev EVM selector for this function is: 0xe34a6844, + /// or in textual repr: createNonfungibleCollection(string,string,string) function createNonfungibleCollection( string memory name, string memory description, @@ -51,7 +52,8 @@ return 0x0000000000000000000000000000000000000000; } - // Selector: createERC721MetadataCompatibleCollection(string,string,string,string) a634a5f9 + /// @dev EVM selector for this function is: 0xa634a5f9, + /// or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string) function createERC721MetadataCompatibleCollection( string memory name, string memory description, @@ -67,7 +69,8 @@ return 0x0000000000000000000000000000000000000000; } - // Selector: createRefungibleCollection(string,string,string) 44a68ad5 + /// @dev EVM selector for this function is: 0x44a68ad5, + /// or in textual repr: createRefungibleCollection(string,string,string) function createRefungibleCollection( string memory name, string memory description, @@ -81,7 +84,8 @@ return 0x0000000000000000000000000000000000000000; } - // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a5596388 + /// @dev EVM selector for this function is: 0xa5596388, + /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string) function createERC721MetadataCompatibleRFTCollection( string memory name, string memory description, @@ -97,11 +101,11 @@ return 0x0000000000000000000000000000000000000000; } - // Check if a collection exists - // @param collection_address Address of the collection in question - // @return bool Does the collection exist? - // - // Selector: isCollectionExist(address) c3de1494 + /// Check if a collection exists + /// @param collectionAddress Address of the collection in question + /// @return bool Does the collection exist? + /// @dev EVM selector for this function is: 0xc3de1494, + /// or in textual repr: isCollectionExist(address) function isCollectionExist(address collectionAddress) public view --- a/tests/src/eth/api/CollectionHelpers.sol +++ b/tests/src/eth/api/CollectionHelpers.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder interface Dummy { } @@ -12,7 +12,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Inline +/// @dev inlined interface interface CollectionHelpersEvents { event CollectionCreated( address indexed owner, @@ -20,22 +20,24 @@ ); } -// Selector: 675f3074 +/// @title Contract, which allows users to operate with collections +/// @dev the ERC-165 identifier for this interface is 0x675f3074 interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents { - // Create an NFT collection - // @param name Name of the collection - // @param description Informative description of the collection - // @param token_prefix Token prefix to represent the collection tokens in UI and user applications - // @return address Address of the newly created collection - // - // Selector: createNonfungibleCollection(string,string,string) e34a6844 + /// Create an NFT collection + /// @param name Name of the collection + /// @param description Informative description of the collection + /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications + /// @return address Address of the newly created collection + /// @dev EVM selector for this function is: 0xe34a6844, + /// or in textual repr: createNonfungibleCollection(string,string,string) function createNonfungibleCollection( string memory name, string memory description, string memory tokenPrefix ) external returns (address); - // Selector: createERC721MetadataCompatibleCollection(string,string,string,string) a634a5f9 + /// @dev EVM selector for this function is: 0xa634a5f9, + /// or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string) function createERC721MetadataCompatibleCollection( string memory name, string memory description, @@ -43,14 +45,16 @@ string memory baseUri ) external returns (address); - // Selector: createRefungibleCollection(string,string,string) 44a68ad5 + /// @dev EVM selector for this function is: 0x44a68ad5, + /// or in textual repr: createRefungibleCollection(string,string,string) function createRefungibleCollection( string memory name, string memory description, string memory tokenPrefix ) external returns (address); - // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a5596388 + /// @dev EVM selector for this function is: 0xa5596388, + /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string) function createERC721MetadataCompatibleRFTCollection( string memory name, string memory description, @@ -58,11 +62,11 @@ string memory baseUri ) external returns (address); - // Check if a collection exists - // @param collection_address Address of the collection in question - // @return bool Does the collection exist? - // - // Selector: isCollectionExist(address) c3de1494 + /// Check if a collection exists + /// @param collectionAddress Address of the collection in question + /// @return bool Does the collection exist? + /// @dev EVM selector for this function is: 0xc3de1494, + /// or in textual repr: isCollectionExist(address) function isCollectionExist(address collectionAddress) external view --- a/tests/src/eth/api/ContractHelpers.sol +++ b/tests/src/eth/api/ContractHelpers.sol @@ -3,13 +3,13 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct +/// @dev anonymous struct struct Tuple0 { address field_0; uint256 field_1; } -// Common stubs holder +/// @dev common stubs holder interface Dummy { } @@ -18,124 +18,124 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Selector: 6073d917 +/// @dev the ERC-165 identifier for this interface is 0x6073d917 interface ContractHelpers is Dummy, ERC165 { - // Get contract ovner - // - // @param Contract_address contract for which the owner is being determined. - // @return Contract owner. - // - // Selector: contractOwner(address) 5152b14c + /// Get contract ovner + /// + /// @param contractAddress contract for which the owner is being determined. + /// @return Contract owner. + /// + /// Selector: contractOwner(address) 5152b14c function contractOwner(address contractAddress) external view returns (address); - // Set sponsor. - // - // @param contract_address Contract for which a sponsor is being established. - // @param sponsor User address who set as pending sponsor. - // - // Selector: setSponsor(address,address) f01fba93 + /// Set sponsor. + /// + /// @param contractAddress Contract for which a sponsor is being established. + /// @param sponsor User address who set as pending sponsor. + /// + /// Selector: setSponsor(address,address) f01fba93 function setSponsor(address contractAddress, address sponsor) external; - // Set contract as self sponsored. - // - // @param contract_address Contract for which a self sponsoring is being enabled. - // - // Selector: selfSponsoredEnable(address) 89f7d9ae + /// Set contract as self sponsored. + /// + /// @param contractAddress Contract for which a self sponsoring is being enabled. + /// + /// Selector: selfSponsoredEnable(address) 89f7d9ae function selfSponsoredEnable(address contractAddress) external; - // Remove sponsor. - // - // @param contract_address Contract for which a sponsorship is being removed. - // - // Selector: removeSponsor(address) ef784250 + /// Remove sponsor. + /// + /// @param contractAddress Contract for which a sponsorship is being removed. + /// + /// Selector: removeSponsor(address) ef784250 function removeSponsor(address contractAddress) external; - // Confirm sponsorship. - // - // @dev Caller must be same that set via [`set_sponsor`]. - // - // @param contract_address Сontract for which need to confirm sponsorship. - // - // Selector: confirmSponsorship(address) abc00001 + /// Confirm sponsorship. + /// + /// @dev Caller must be same that set via [`setSponsor`]. + /// + /// @param contractAddress Сontract for which need to confirm sponsorship. + /// + /// Selector: confirmSponsorship(address) abc00001 function confirmSponsorship(address contractAddress) external; - // Get current sponsor. - // - // @param contract_address The contract for which a sponsor is requested. - // @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. - // - // Selector: getSponsor(address) 743fc745 + /// Get current sponsor. + /// + /// @param contractAddress The contract for which a sponsor is requested. + /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw. + /// + /// Selector: getSponsor(address) 743fc745 function getSponsor(address contractAddress) external view returns (Tuple0 memory); - // Check tat contract has confirmed sponsor. - // - // @param contract_address The contract for which the presence of a confirmed sponsor is checked. - // @return **true** if contract has confirmed sponsor. - // - // Selector: hasSponsor(address) 97418603 + /// Check tat contract has confirmed sponsor. + /// + /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked. + /// @return **true** if contract has confirmed sponsor. + /// + /// Selector: hasSponsor(address) 97418603 function hasSponsor(address contractAddress) external view returns (bool); - // Check tat contract has pending sponsor. - // - // @param contract_address The contract for which the presence of a pending sponsor is checked. - // @return **true** if contract has pending sponsor. - // - // Selector: hasPendingSponsor(address) 39b9b242 + /// Check tat contract has pending sponsor. + /// + /// @param contractAddress The contract for which the presence of a pending sponsor is checked. + /// @return **true** if contract has pending sponsor. + /// + /// Selector: hasPendingSponsor(address) 39b9b242 function hasPendingSponsor(address contractAddress) external view returns (bool); - // Selector: sponsoringEnabled(address) 6027dc61 + /// Selector: sponsoringEnabled(address) 6027dc61 function sponsoringEnabled(address contractAddress) external view returns (bool); - // Selector: setSponsoringMode(address,uint8) fde8a560 + /// Selector: setSponsoringMode(address,uint8) fde8a560 function setSponsoringMode(address contractAddress, uint8 mode) external; - // Selector: sponsoringMode(address) b70c7267 + /// Selector: sponsoringMode(address) b70c7267 function sponsoringMode(address contractAddress) external view returns (uint8); - // Selector: setSponsoringRateLimit(address,uint32) 77b6c908 + /// Selector: setSponsoringRateLimit(address,uint32) 77b6c908 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit) external; - // Selector: getSponsoringRateLimit(address) 610cfabd + /// Selector: getSponsoringRateLimit(address) 610cfabd function getSponsoringRateLimit(address contractAddress) external view returns (uint32); - // Selector: allowed(address,address) 5c658165 + /// Selector: allowed(address,address) 5c658165 function allowed(address contractAddress, address user) external view returns (bool); - // Selector: allowlistEnabled(address) c772ef6c + /// Selector: allowlistEnabled(address) c772ef6c function allowlistEnabled(address contractAddress) external view returns (bool); - // Selector: toggleAllowlist(address,bool) 36de20f5 + /// Selector: toggleAllowlist(address,bool) 36de20f5 function toggleAllowlist(address contractAddress, bool enabled) external; - // Selector: toggleAllowed(address,address,bool) 4706cc1c + /// Selector: toggleAllowed(address,address,bool) 4706cc1c function toggleAllowed( address contractAddress, address user, - bool allowed + bool isAllowed ) external; } --- a/tests/src/eth/api/UniqueFungible.sol +++ b/tests/src/eth/api/UniqueFungible.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder interface Dummy { } @@ -12,246 +12,257 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Inline -interface ERC20Events { - event Transfer(address indexed from, address indexed to, uint256 value); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - -// Selector: 79cc6790 -interface ERC20UniqueExtensions is Dummy, ERC165 { - // Selector: burnFrom(address,uint256) 79cc6790 - function burnFrom(address from, uint256 amount) external returns (bool); -} - -// Selector: 942e8b22 -interface ERC20 is Dummy, ERC165, ERC20Events { - // Selector: name() 06fdde03 - function name() external view returns (string memory); - - // Selector: symbol() 95d89b41 - function symbol() external view returns (string memory); - - // Selector: totalSupply() 18160ddd - function totalSupply() external view returns (uint256); - - // Selector: decimals() 313ce567 - function decimals() external view returns (uint8); - - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) external view returns (uint256); - - // Selector: transfer(address,uint256) a9059cbb - function transfer(address to, uint256 amount) external returns (bool); - - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 amount - ) external returns (bool); - - // Selector: approve(address,uint256) 095ea7b3 - function approve(address spender, uint256 amount) external returns (bool); - - // Selector: allowance(address,address) dd62ed3e - function allowance(address owner, address spender) - external - view - returns (uint256); -} - -// Selector: ffe4da23 +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 interface Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) function setCollectionProperty(string memory key, bytes memory value) external; - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) function deleteCollectionProperty(string memory key) external; - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) function collectionProperty(string memory key) external view returns (bytes memory); - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) function setCollectionSponsor(address sponsor) external; - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() function confirmCollectionSponsorship() external; - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) function setCollectionLimit(string memory limit, uint32 value) external; - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) function setCollectionLimit(string memory limit, bool value) external; - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() function contractAddress() external view returns (address); - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) function addCollectionAdminSubstrate(uint256 newAdmin) external; - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) function removeCollectionAdminSubstrate(uint256 admin) external; - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) function addCollectionAdmin(address newAdmin) external; - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) function removeCollectionAdmin(address admin) external; - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) function setCollectionNesting(bool enable) external; - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) function setCollectionNesting(bool enable, address[] memory collections) external; - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) function setCollectionAccess(uint8 mode) external; - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) function addToCollectionAllowList(address user) external; - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) function removeFromCollectionAllowList(address user) external; - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) function setCollectionMintMode(bool mode) external; - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) function isOwnerOrAdmin(address user) external view returns (bool); - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool); - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() function uniqueCollectionType() external returns (string memory); - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) function setOwner(address newOwner) external; - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) function setOwnerSubstrate(uint256 newOwner) external; } +/// @dev the ERC-165 identifier for this interface is 0x79cc6790 +interface ERC20UniqueExtensions is Dummy, ERC165 { + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) + function burnFrom(address from, uint256 amount) external returns (bool); +} + +/// @dev inlined interface +interface ERC20Events { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + +/// @dev the ERC-165 identifier for this interface is 0x942e8b22 +interface ERC20 is Dummy, ERC165, ERC20Events { + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() external view returns (string memory); + + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() external view returns (string memory); + + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() external view returns (uint256); + + /// @dev EVM selector for this function is: 0x313ce567, + /// or in textual repr: decimals() + function decimals() external view returns (uint8); + + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) external view returns (uint256); + + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) + function transfer(address to, uint256 amount) external returns (bool); + + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); + + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address spender, uint256 amount) external returns (bool); + + /// @dev EVM selector for this function is: 0xdd62ed3e, + /// or in textual repr: allowance(address,address) + function allowance(address owner, address spender) + external + view + returns (uint256); +} + interface UniqueFungible is Dummy, ERC165, --- a/tests/src/eth/api/UniqueNFT.sol +++ b/tests/src/eth/api/UniqueNFT.sol @@ -3,55 +3,26 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct -struct Tuple0 { - uint256 field_0; - string field_1; -} - -// Common stubs holder +/// @dev common stubs holder interface Dummy { } interface ERC165 is Dummy { function supportsInterface(bytes4 interfaceID) external view returns (bool); -} - -// Inline -interface ERC721Events { - event Transfer( - address indexed from, - address indexed to, - uint256 indexed tokenId - ); - event Approval( - address indexed owner, - address indexed approved, - uint256 indexed tokenId - ); - event ApprovalForAll( - address indexed owner, - address indexed operator, - bool approved - ); } -// Inline -interface ERC721MintableEvents { - event MintingFinished(); -} - -// Selector: 41369377 +/// @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 0x41369377 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. - // @param key Property key. - // @param is_mutable Permission to mutate property. - // @param collection_admin Permission to mutate property by collection admin if property is mutable. - // @param token_owner Permission to mutate property by token owner if property is mutable. - // - // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa + /// @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, @@ -59,459 +30,497 @@ bool tokenOwner ) external; - // @notice Set 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. - // @param value Property value. - // - // Selector: setProperty(uint256,string,bytes) 1752d67b + /// @notice Set 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. + /// @param value Property value. + /// @dev EVM selector for this function is: 0x1752d67b, + /// or in textual repr: setProperty(uint256,string,bytes) function setProperty( uint256 tokenId, string memory key, bytes memory value ) external; - // @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. - // - // Selector: deleteProperty(uint256,string) 066111d1 + /// @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 Get token property value. - // @dev Throws error if key not found - // @param tokenId ID of the token. - // @param key Property key. - // @return Property value bytes - // - // Selector: property(uint256,string) 7228c327 + /// @notice Get token property value. + /// @dev Throws error if key not found + /// @param tokenId ID of the token. + /// @param key Property key. + /// @return Property value bytes + /// @dev EVM selector for this function is: 0x7228c327, + /// or in textual repr: property(uint256,string) function property(uint256 tokenId, string memory key) external view returns (bytes memory); } -// Selector: 42966c68 -interface ERC721Burnable is Dummy, ERC165 { - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized - // operator of the current owner. - // @param tokenId The NFT to approve - // - // Selector: burn(uint256) 42966c68 - function burn(uint256 tokenId) external; -} +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 +interface Collection is Dummy, ERC165 { + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) + function setCollectionProperty(string memory key, bytes memory value) + external; -// Selector: 58800161 -interface ERC721 is Dummy, ERC165, ERC721Events { - // @notice Count all NFTs assigned to an owner - // @dev NFTs assigned to the zero address are considered invalid, and this - // function throws for queries about the zero address. - // @param owner An address for whom to query the balance - // @return The number of NFTs owned by `owner`, possibly zero - // - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) external view returns (uint256); + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) + function deleteCollectionProperty(string memory key) external; - // @notice Find the owner of an NFT - // @dev NFTs assigned to zero address are considered invalid, and queries - // about them do throw. - // @param tokenId The identifier for an NFT - // @return The address of the owner of the NFT - // - // Selector: ownerOf(uint256) 6352211e - function ownerOf(uint256 tokenId) external view returns (address); + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) + function collectionProperty(string memory key) + external + view + returns (bytes memory); - // @dev Not implemented - // - // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672 - function safeTransferFromWithData( - address from, - address to, - uint256 tokenId, - bytes memory data - ) external; + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) + function setCollectionSponsor(address sponsor) external; - // @dev Not implemented - // - // Selector: safeTransferFrom(address,address,uint256) 42842e0e - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) external; + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() + function confirmCollectionSponsorship() external; - // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE - // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE - // THEY MAY BE PERMANENTLY LOST - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this NFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid NFT. - // @param from The current owner of the NFT - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 tokenId - ) external; + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) + function setCollectionLimit(string memory limit, uint32 value) external; - // @notice Set or reaffirm the approved address for an NFT - // @dev The zero address indicates there is no approved address. - // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized - // operator of the current owner. - // @param approved The new approved NFT controller - // @param tokenId The NFT to approve - // - // Selector: approve(address,uint256) 095ea7b3 - function approve(address approved, uint256 tokenId) external; + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) + function setCollectionLimit(string memory limit, bool value) external; - // @dev Not implemented - // - // Selector: setApprovalForAll(address,bool) a22cb465 - function setApprovalForAll(address operator, bool approved) external; + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() + function contractAddress() external view returns (address); - // @dev Not implemented - // - // Selector: getApproved(uint256) 081812fc - function getApproved(uint256 tokenId) external view returns (address); + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) + function addCollectionAdminSubstrate(uint256 newAdmin) external; + + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) + function removeCollectionAdminSubstrate(uint256 admin) external; + + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) + function addCollectionAdmin(address newAdmin) external; - // @dev Not implemented - // - // Selector: isApprovedForAll(address,address) e985e9c5 - function isApprovedForAll(address owner, address operator) - external - view - returns (address); -} + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) + function removeCollectionAdmin(address admin) external; + + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) + function setCollectionNesting(bool enable) external; -// Selector: 5b5e139f -interface ERC721Metadata is Dummy, ERC165 { - // @notice A descriptive name for a collection of NFTs in this contract - // - // Selector: name() 06fdde03 - function name() external view returns (string memory); + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) + function setCollectionNesting(bool enable, address[] memory collections) + external; - // @notice An abbreviated name for NFTs in this contract - // - // Selector: symbol() 95d89b41 - function symbol() external view returns (string memory); + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) + function setCollectionAccess(uint8 mode) external; - // @notice A distinct Uniform Resource Identifier (URI) for a given asset. - // - // @dev If the token has a `url` property and it is not empty, it is returned. - // 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`. - // If the collection property `baseURI` is empty or absent, return "" (empty string) - // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix - // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). - // - // @return token's const_metadata - // - // Selector: tokenURI(uint256) c87b56dd - function tokenURI(uint256 tokenId) external view returns (string memory); + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) + function addToCollectionAllowList(address user) external; + + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) + function removeFromCollectionAllowList(address user) external; + + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) + function setCollectionMintMode(bool mode) external; + + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) + function isOwnerOrAdmin(address user) external view returns (bool); + + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) + function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool); + + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() + function uniqueCollectionType() external returns (string memory); + + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) + function setOwner(address newOwner) external; + + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) + function setOwnerSubstrate(uint256 newOwner) external; +} + +/// @title ERC721 Token that can be irreversibly burned (destroyed). +/// @dev the ERC-165 identifier for this interface is 0x42966c68 +interface ERC721Burnable is Dummy, ERC165 { + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized + /// operator of the current owner. + /// @param tokenId The NFT to approve + /// @dev EVM selector for this function is: 0x42966c68, + /// or in textual repr: burn(uint256) + function burn(uint256 tokenId) external; } -// Selector: 68ccfe89 +/// @dev inlined interface +interface ERC721MintableEvents { + event MintingFinished(); +} + +/// @title ERC721 minting logic. +/// @dev the ERC-165 identifier for this interface is 0x68ccfe89 interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents { - // Selector: mintingFinished() 05d2035b + /// @dev EVM selector for this function is: 0x05d2035b, + /// or in textual repr: mintingFinished() function mintingFinished() external view returns (bool); - // @notice Function to mint token. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted NFT - // - // Selector: mint(address,uint256) 40c10f19 + /// @notice Function to mint token. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted NFT + /// @dev EVM selector for this function is: 0x40c10f19, + /// or in textual repr: mint(address,uint256) function mint(address to, uint256 tokenId) external returns (bool); - // @notice Function to mint token with the given tokenUri. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted NFT - // @param tokenUri Token URI that would be stored in the NFT properties - // - // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f + /// @notice Function to mint token with the given tokenUri. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted NFT + /// @param tokenUri Token URI that would be stored in the NFT properties + /// @dev EVM selector for this function is: 0x50bb4e7f, + /// or in textual repr: mintWithTokenURI(address,uint256,string) function mintWithTokenURI( address to, uint256 tokenId, string memory tokenUri ) external returns (bool); - // @dev Not implemented - // - // Selector: finishMinting() 7d64bcb4 + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x7d64bcb4, + /// or in textual repr: finishMinting() function finishMinting() external returns (bool); } -// Selector: 780e9d63 -interface ERC721Enumerable is Dummy, ERC165 { - // @notice Enumerate valid NFTs - // @param index A counter less than `totalSupply()` - // @return The token identifier for the `index`th NFT, - // (sort order not specified) - // - // Selector: tokenByIndex(uint256) 4f6ccce7 - function tokenByIndex(uint256 index) external view returns (uint256); - - // @dev Not implemented - // - // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59 - function tokenOfOwnerByIndex(address owner, uint256 index) - external - view - returns (uint256); - - // @notice Count NFTs tracked by this contract - // @return A count of valid NFTs tracked by this contract, where each one of - // them has an assigned and queryable owner not equal to the zero address - // - // Selector: totalSupply() 18160ddd - function totalSupply() external view returns (uint256); -} - -// Selector: d74d154f +/// @title Unique extensions for ERC721. +/// @dev the ERC-165 identifier for this interface is 0xd74d154f interface ERC721UniqueExtensions is Dummy, ERC165 { - // @notice Transfer ownership of an NFT - // @dev Throws unless `msg.sender` is the current owner. Throws if `to` - // is the zero address. Throws if `tokenId` is not a valid NFT. - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transfer(address,uint256) a9059cbb + /// @notice Transfer ownership of an NFT + /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` + /// is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 tokenId) external; - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this NFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid NFT. - // @param from The current owner of the NFT - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: burnFrom(address,uint256) 79cc6790 + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this NFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param from The current owner of the NFT + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) function burnFrom(address from, uint256 tokenId) external; - // @notice Returns next free NFT ID. - // - // Selector: nextTokenId() 75794a3c + /// @notice Returns next free NFT ID. + /// @dev EVM selector for this function is: 0x75794a3c, + /// or in textual repr: nextTokenId() function nextTokenId() external view returns (uint256); - // @notice Function to mint multiple tokens. - // @dev `tokenIds` should be an array of consecutive numbers and first number - // should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokenIds IDs of the minted NFTs - // - // Selector: mintBulk(address,uint256[]) 44a9945e + /// @notice Function to mint multiple tokens. + /// @dev `tokenIds` should be an array of consecutive numbers and first number + /// should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokenIds IDs of the minted NFTs + /// @dev EVM selector for this function is: 0x44a9945e, + /// or in textual repr: mintBulk(address,uint256[]) function mintBulk(address to, uint256[] memory tokenIds) external returns (bool); - // @notice Function to mint multiple tokens with the given tokenUris. - // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive - // numbers and first number should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokens array of pairs of token ID and token URI for minted tokens - // - // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006 - function mintBulkWithTokenURI(address to, Tuple0[] memory tokens) + /// @notice Function to mint multiple tokens with the given tokenUris. + /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive + /// numbers and first number should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokens array of pairs of token ID and token URI for minted tokens + /// @dev EVM selector for this function is: 0x36543006, + /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) + function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool); } -// Selector: ffe4da23 -interface Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 - function setCollectionProperty(string memory key, bytes memory value) - external; +/// @dev anonymous struct +struct Tuple8 { + uint256 field_0; + string field_1; +} - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce - function deleteCollectionProperty(string memory key) external; +/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x780e9d63 +interface ERC721Enumerable is Dummy, ERC165 { + /// @notice Enumerate valid NFTs + /// @param index A counter less than `totalSupply()` + /// @return The token identifier for the `index`th NFT, + /// (sort order not specified) + /// @dev EVM selector for this function is: 0x4f6ccce7, + /// or in textual repr: tokenByIndex(uint256) + function tokenByIndex(uint256 index) external view returns (uint256); - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d - function collectionProperty(string memory key) + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x2f745c59, + /// or in textual repr: tokenOfOwnerByIndex(address,uint256) + function tokenOfOwnerByIndex(address owner, uint256 index) external view - returns (bytes memory); + returns (uint256); - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e - function setCollectionSponsor(address sponsor) external; + /// @notice Count NFTs tracked by this contract + /// @return A count of valid NFTs tracked by this contract, where each one of + /// them has an assigned and queryable owner not equal to the zero address + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() external view returns (uint256); +} - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a - function confirmCollectionSponsorship() external; +/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x5b5e139f +interface ERC721Metadata is Dummy, ERC165 { + /// @notice A descriptive name for a collection of NFTs in this contract + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() external view returns (string memory); - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db - function setCollectionLimit(string memory limit, uint32 value) external; + /// @notice An abbreviated name for NFTs in this contract + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() external view returns (string memory); - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba - function setCollectionLimit(string memory limit, bool value) external; + /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. + /// + /// @dev If the token has a `url` property and it is not empty, it is returned. + /// 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`. + /// If the collection property `baseURI` is empty or absent, return "" (empty string) + /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix + /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). + /// + /// @return token's const_metadata + /// @dev EVM selector for this function is: 0xc87b56dd, + /// or in textual repr: tokenURI(uint256) + function tokenURI(uint256 tokenId) external view returns (string memory); +} - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 - function contractAddress() external view returns (address); +/// @dev inlined interface +interface ERC721Events { + event Transfer( + address indexed from, + address indexed to, + uint256 indexed tokenId + ); + event Approval( + address indexed owner, + address indexed approved, + uint256 indexed tokenId + ); + event ApprovalForAll( + address indexed owner, + address indexed operator, + bool approved + ); +} - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b - function addCollectionAdminSubstrate(uint256 newAdmin) external; +/// @title ERC-721 Non-Fungible Token Standard +/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md +/// @dev the ERC-165 identifier for this interface is 0x80ac58cd +interface ERC721 is Dummy, ERC165, ERC721Events { + /// @notice Count all NFTs assigned to an owner + /// @dev NFTs assigned to the zero address are considered invalid, and this + /// function throws for queries about the zero address. + /// @param owner An address for whom to query the balance + /// @return The number of NFTs owned by `owner`, possibly zero + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) external view returns (uint256); - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 - function removeCollectionAdminSubstrate(uint256 admin) external; - - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 - function addCollectionAdmin(address newAdmin) external; - - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 - function removeCollectionAdmin(address admin) external; - - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 - function setCollectionNesting(bool enable) external; - - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 - function setCollectionNesting(bool enable, address[] memory collections) - external; - - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c - function setCollectionAccess(uint8 mode) external; - - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 - function addToCollectionAllowList(address user) external; + /// @notice Find the owner of an NFT + /// @dev NFTs assigned to zero address are considered invalid, and queries + /// about them do throw. + /// @param tokenId The identifier for an NFT + /// @return The address of the owner of the NFT + /// @dev EVM selector for this function is: 0x6352211e, + /// or in textual repr: ownerOf(uint256) + function ownerOf(uint256 tokenId) external view returns (address); - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb - function removeFromCollectionAllowList(address user) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xb88d4fde, + /// or in textual repr: safeTransferFrom(address,address,uint256,bytes) + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes memory data + ) external; - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 - function setCollectionMintMode(bool mode) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x42842e0e, + /// or in textual repr: safeTransferFrom(address,address,uint256) + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) external; - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 - function isOwnerOrAdmin(address user) external view returns (bool); + /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE + /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE + /// THEY MAY BE PERMANENTLY LOST + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this NFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT. + /// @param from The current owner of the NFT + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 tokenId + ) external; - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 - function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool); + /// @notice Set or reaffirm the approved address for an NFT + /// @dev The zero address indicates there is no approved address. + /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized + /// operator of the current owner. + /// @param approved The new approved NFT controller + /// @param tokenId The NFT to approve + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address approved, uint256 tokenId) external; - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 - function uniqueCollectionType() external returns (string memory); + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xa22cb465, + /// or in textual repr: setApprovalForAll(address,bool) + function setApprovalForAll(address operator, bool approved) external; - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 - function setOwner(address newOwner) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x081812fc, + /// or in textual repr: getApproved(uint256) + function getApproved(uint256 tokenId) external view returns (address); - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f - function setOwnerSubstrate(uint256 newOwner) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xe985e9c5, + /// or in textual repr: isApprovedForAll(address,address) + function isApprovedForAll(address owner, address operator) + external + view + returns (address); } interface UniqueNFT is --- a/tests/src/eth/api/UniqueRefungible.sol +++ b/tests/src/eth/api/UniqueRefungible.sol @@ -3,13 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Anonymous struct -struct Tuple0 { - uint256 field_0; - string field_1; -} - -// Common stubs holder +/// @dev common stubs holder interface Dummy { } @@ -18,40 +12,17 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Inline -interface ERC721Events { - event Transfer( - address indexed from, - address indexed to, - uint256 indexed tokenId - ); - event Approval( - address indexed owner, - address indexed approved, - uint256 indexed tokenId - ); - event ApprovalForAll( - address indexed owner, - address indexed operator, - bool approved - ); -} - -// Inline -interface ERC721MintableEvents { - event MintingFinished(); -} - -// Selector: 41369377 +/// @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 0x41369377 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. - // @param key Property key. - // @param is_mutable Permission to mutate property. - // @param collection_admin Permission to mutate property by collection admin if property is mutable. - // @param token_owner Permission to mutate property by token owner if property is mutable. - // - // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa + /// @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, @@ -59,469 +30,505 @@ bool tokenOwner ) external; - // @notice Set 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. - // @param value Property value. - // - // Selector: setProperty(uint256,string,bytes) 1752d67b + /// @notice Set 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. + /// @param value Property value. + /// @dev EVM selector for this function is: 0x1752d67b, + /// or in textual repr: setProperty(uint256,string,bytes) function setProperty( uint256 tokenId, string memory key, bytes memory value ) external; - // @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. - // - // Selector: deleteProperty(uint256,string) 066111d1 + /// @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 Get token property value. - // @dev Throws error if key not found - // @param tokenId ID of the token. - // @param key Property key. - // @return Property value bytes - // - // Selector: property(uint256,string) 7228c327 + /// @notice Get token property value. + /// @dev Throws error if key not found + /// @param tokenId ID of the token. + /// @param key Property key. + /// @return Property value bytes + /// @dev EVM selector for this function is: 0x7228c327, + /// or in textual repr: property(uint256,string) function property(uint256 tokenId, string memory key) external view returns (bytes memory); } -// Selector: 42966c68 -interface ERC721Burnable is Dummy, ERC165 { - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized - // operator of the current owner. - // @param tokenId The RFT to approve - // - // Selector: burn(uint256) 42966c68 - function burn(uint256 tokenId) external; -} +/// @title A contract that allows you to work with collections. +/// @dev the ERC-165 identifier for this interface is 0xffe4da23 +interface Collection is Dummy, ERC165 { + /// Set collection property. + /// + /// @param key Property key. + /// @param value Propery value. + /// @dev EVM selector for this function is: 0x2f073f66, + /// or in textual repr: setCollectionProperty(string,bytes) + function setCollectionProperty(string memory key, bytes memory value) + external; -// Selector: 58800161 -interface ERC721 is Dummy, ERC165, ERC721Events { - // @notice Count all RFTs assigned to an owner - // @dev RFTs assigned to the zero address are considered invalid, and this - // function throws for queries about the zero address. - // @param owner An address for whom to query the balance - // @return The number of RFTs owned by `owner`, possibly zero - // - // Selector: balanceOf(address) 70a08231 - function balanceOf(address owner) external view returns (uint256); + /// Delete collection property. + /// + /// @param key Property key. + /// @dev EVM selector for this function is: 0x7b7debce, + /// or in textual repr: deleteCollectionProperty(string) + function deleteCollectionProperty(string memory key) external; - // @notice Find the owner of an RFT - // @dev RFTs assigned to zero address are considered invalid, and queries - // about them do throw. - // Returns special 0xffffffffffffffffffffffffffffffffffffffff address for - // the tokens that are partially owned. - // @param tokenId The identifier for an RFT - // @return The address of the owner of the RFT - // - // Selector: ownerOf(uint256) 6352211e - function ownerOf(uint256 tokenId) external view returns (address); + /// Get collection property. + /// + /// @dev Throws error if key not found. + /// + /// @param key Property key. + /// @return bytes The property corresponding to the key. + /// @dev EVM selector for this function is: 0xcf24fd6d, + /// or in textual repr: collectionProperty(string) + function collectionProperty(string memory key) + external + view + returns (bytes memory); - // @dev Not implemented - // - // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672 - function safeTransferFromWithData( - address from, - address to, - uint256 tokenId, - bytes memory data - ) external; + /// Set the sponsor of the collection. + /// + /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. + /// + /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. + /// @dev EVM selector for this function is: 0x7623402e, + /// or in textual repr: setCollectionSponsor(address) + function setCollectionSponsor(address sponsor) external; - // @dev Not implemented - // - // Selector: safeTransferFrom(address,address,uint256) 42842e0e - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) external; + /// Collection sponsorship confirmation. + /// + /// @dev After setting the sponsor for the collection, it must be confirmed with this function. + /// @dev EVM selector for this function is: 0x3c50e97a, + /// or in textual repr: confirmCollectionSponsorship() + function confirmCollectionSponsorship() external; - // @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE - // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE - // THEY MAY BE PERMANENTLY LOST - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this RFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param from The current owner of the NFT - // @param to The new owner - // @param tokenId The NFT to transfer - // @param _value Not used for an NFT - // - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 tokenId - ) external; + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "accountTokenOwnershipLimit", + /// "sponsoredDataSize", + /// "sponsoredDataRateLimit", + /// "tokenLimit", + /// "sponsorTransferTimeout", + /// "sponsorApproveTimeout" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x6a3841db, + /// or in textual repr: setCollectionLimit(string,uint32) + function setCollectionLimit(string memory limit, uint32 value) external; - // @dev Not implemented - // - // Selector: approve(address,uint256) 095ea7b3 - function approve(address approved, uint256 tokenId) external; + /// Set limits for the collection. + /// @dev Throws error if limit not found. + /// @param limit Name of the limit. Valid names: + /// "ownerCanTransfer", + /// "ownerCanDestroy", + /// "transfersEnabled" + /// @param value Value of the limit. + /// @dev EVM selector for this function is: 0x993b7fba, + /// or in textual repr: setCollectionLimit(string,bool) + function setCollectionLimit(string memory limit, bool value) external; - // @dev Not implemented - // - // Selector: setApprovalForAll(address,bool) a22cb465 - function setApprovalForAll(address operator, bool approved) external; + /// Get contract address. + /// @dev EVM selector for this function is: 0xf6b4dfb4, + /// or in textual repr: contractAddress() + function contractAddress() external view returns (address); - // @dev Not implemented - // - // Selector: getApproved(uint256) 081812fc - function getApproved(uint256 tokenId) external view returns (address); + /// Add collection admin by substrate address. + /// @param newAdmin Substrate administrator address. + /// @dev EVM selector for this function is: 0x5730062b, + /// or in textual repr: addCollectionAdminSubstrate(uint256) + function addCollectionAdminSubstrate(uint256 newAdmin) external; - // @dev Not implemented - // - // Selector: isApprovedForAll(address,address) e985e9c5 - function isApprovedForAll(address owner, address operator) - external - view - returns (address); -} + /// Remove collection admin by substrate address. + /// @param admin Substrate administrator address. + /// @dev EVM selector for this function is: 0x4048fcf9, + /// or in textual repr: removeCollectionAdminSubstrate(uint256) + function removeCollectionAdminSubstrate(uint256 admin) external; -// Selector: 5b5e139f -interface ERC721Metadata is Dummy, ERC165 { - // @notice A descriptive name for a collection of RFTs in this contract - // - // Selector: name() 06fdde03 - function name() external view returns (string memory); + /// Add collection admin. + /// @param newAdmin Address of the added administrator. + /// @dev EVM selector for this function is: 0x92e462c7, + /// or in textual repr: addCollectionAdmin(address) + function addCollectionAdmin(address newAdmin) external; - // @notice An abbreviated name for RFTs in this contract - // - // Selector: symbol() 95d89b41 - function symbol() external view returns (string memory); + /// Remove collection admin. + /// + /// @param admin Address of the removed administrator. + /// @dev EVM selector for this function is: 0xfafd7b42, + /// or in textual repr: removeCollectionAdmin(address) + function removeCollectionAdmin(address admin) external; - // @notice A distinct Uniform Resource Identifier (URI) for a given asset. - // - // @dev If the token has a `url` property and it is not empty, it is returned. - // 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`. - // If the collection property `baseURI` is empty or absent, return "" (empty string) - // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix - // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). - // - // @return token's const_metadata - // - // Selector: tokenURI(uint256) c87b56dd - function tokenURI(uint256 tokenId) external view returns (string memory); + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' + /// @dev EVM selector for this function is: 0x112d4586, + /// or in textual repr: setCollectionNesting(bool) + function setCollectionNesting(bool enable) external; + + /// Toggle accessibility of collection nesting. + /// + /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' + /// @param collections Addresses of collections that will be available for nesting. + /// @dev EVM selector for this function is: 0x64872396, + /// or in textual repr: setCollectionNesting(bool,address[]) + function setCollectionNesting(bool enable, address[] memory collections) + external; + + /// Set the collection access method. + /// @param mode Access mode + /// 0 for Normal + /// 1 for AllowList + /// @dev EVM selector for this function is: 0x41835d4c, + /// or in textual repr: setCollectionAccess(uint8) + function setCollectionAccess(uint8 mode) external; + + /// Add the user to the allowed list. + /// + /// @param user Address of a trusted user. + /// @dev EVM selector for this function is: 0x67844fe6, + /// or in textual repr: addToCollectionAllowList(address) + function addToCollectionAllowList(address user) external; + + /// Remove the user from the allowed list. + /// + /// @param user Address of a removed user. + /// @dev EVM selector for this function is: 0x85c51acb, + /// or in textual repr: removeFromCollectionAllowList(address) + function removeFromCollectionAllowList(address user) external; + + /// Switch permission for minting. + /// + /// @param mode Enable if "true". + /// @dev EVM selector for this function is: 0x00018e84, + /// or in textual repr: setCollectionMintMode(bool) + function setCollectionMintMode(bool mode) external; + + /// Check that account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x9811b0c7, + /// or in textual repr: isOwnerOrAdmin(address) + function isOwnerOrAdmin(address user) external view returns (bool); + + /// Check that substrate account is the owner or admin of the collection + /// + /// @param user account to verify + /// @return "true" if account is the owner or admin + /// @dev EVM selector for this function is: 0x68910e00, + /// or in textual repr: isOwnerOrAdminSubstrate(uint256) + function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool); + + /// Returns collection type + /// + /// @return `Fungible` or `NFT` or `ReFungible` + /// @dev EVM selector for this function is: 0xd34b55b8, + /// or in textual repr: uniqueCollectionType() + function uniqueCollectionType() external returns (string memory); + + /// Changes collection owner to another account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner account + /// @dev EVM selector for this function is: 0x13af4035, + /// or in textual repr: setOwner(address) + function setOwner(address newOwner) external; + + /// Changes collection owner to another substrate account + /// + /// @dev Owner can be changed only by current owner + /// @param newOwner new owner substrate account + /// @dev EVM selector for this function is: 0xb212138f, + /// or in textual repr: setOwnerSubstrate(uint256) + function setOwnerSubstrate(uint256 newOwner) external; +} + +/// @title ERC721 Token that can be irreversibly burned (destroyed). +/// @dev the ERC-165 identifier for this interface is 0x42966c68 +interface ERC721Burnable is Dummy, ERC165 { + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized + /// operator of the current owner. + /// @param tokenId The RFT to approve + /// @dev EVM selector for this function is: 0x42966c68, + /// or in textual repr: burn(uint256) + function burn(uint256 tokenId) external; } -// Selector: 68ccfe89 +/// @dev inlined interface +interface ERC721MintableEvents { + event MintingFinished(); +} + +/// @title ERC721 minting logic. +/// @dev the ERC-165 identifier for this interface is 0x68ccfe89 interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents { - // Selector: mintingFinished() 05d2035b + /// @dev EVM selector for this function is: 0x05d2035b, + /// or in textual repr: mintingFinished() function mintingFinished() external view returns (bool); - // @notice Function to mint token. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted RFT - // - // Selector: mint(address,uint256) 40c10f19 + /// @notice Function to mint token. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted RFT + /// @dev EVM selector for this function is: 0x40c10f19, + /// or in textual repr: mint(address,uint256) function mint(address to, uint256 tokenId) external returns (bool); - // @notice Function to mint token with the given tokenUri. - // @dev `tokenId` should be obtained with `nextTokenId` method, - // unlike standard, you can't specify it manually - // @param to The new owner - // @param tokenId ID of the minted RFT - // @param tokenUri Token URI that would be stored in the RFT properties - // - // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f + /// @notice Function to mint token with the given tokenUri. + /// @dev `tokenId` should be obtained with `nextTokenId` method, + /// unlike standard, you can't specify it manually + /// @param to The new owner + /// @param tokenId ID of the minted RFT + /// @param tokenUri Token URI that would be stored in the RFT properties + /// @dev EVM selector for this function is: 0x50bb4e7f, + /// or in textual repr: mintWithTokenURI(address,uint256,string) function mintWithTokenURI( address to, uint256 tokenId, string memory tokenUri ) external returns (bool); - // @dev Not implemented - // - // Selector: finishMinting() 7d64bcb4 + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x7d64bcb4, + /// or in textual repr: finishMinting() function finishMinting() external returns (bool); } - -// Selector: 780e9d63 -interface ERC721Enumerable is Dummy, ERC165 { - // @notice Enumerate valid RFTs - // @param index A counter less than `totalSupply()` - // @return The token identifier for the `index`th NFT, - // (sort order not specified) - // - // Selector: tokenByIndex(uint256) 4f6ccce7 - function tokenByIndex(uint256 index) external view returns (uint256); - // Not implemented - // - // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59 - function tokenOfOwnerByIndex(address owner, uint256 index) - external - view - returns (uint256); - - // @notice Count RFTs tracked by this contract - // @return A count of valid RFTs tracked by this contract, where each one of - // them has an assigned and queryable owner not equal to the zero address - // - // Selector: totalSupply() 18160ddd - function totalSupply() external view returns (uint256); -} - -// Selector: 7c3bef89 +/// @title Unique extensions for ERC721. +/// @dev the ERC-165 identifier for this interface is 0x7c3bef89 interface ERC721UniqueExtensions is Dummy, ERC165 { - // @notice Transfer ownership of an RFT - // @dev Throws unless `msg.sender` is the current owner. Throws if `to` - // is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param to The new owner - // @param tokenId The RFT to transfer - // @param _value Not used for an RFT - // - // Selector: transfer(address,uint256) a9059cbb + /// @notice Transfer ownership of an RFT + /// @dev Throws unless `msg.sender` is the current owner. Throws if `to` + /// is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param to The new owner + /// @param tokenId The RFT to transfer + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 tokenId) external; - // @notice Burns a specific ERC721 token. - // @dev Throws unless `msg.sender` is the current owner or an authorized - // operator for this RFT. Throws if `from` is not the current owner. Throws - // if `to` is the zero address. Throws if `tokenId` is not a valid RFT. - // Throws if RFT pieces have multiple owners. - // @param from The current owner of the RFT - // @param tokenId The RFT to transfer - // @param _value Not used for an RFT - // - // Selector: burnFrom(address,uint256) 79cc6790 + /// @notice Burns a specific ERC721 token. + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this RFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param from The current owner of the RFT + /// @param tokenId The RFT to transfer + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) function burnFrom(address from, uint256 tokenId) external; - // @notice Returns next free RFT ID. - // - // Selector: nextTokenId() 75794a3c + /// @notice Returns next free RFT ID. + /// @dev EVM selector for this function is: 0x75794a3c, + /// or in textual repr: nextTokenId() function nextTokenId() external view returns (uint256); - // @notice Function to mint multiple tokens. - // @dev `tokenIds` should be an array of consecutive numbers and first number - // should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokenIds IDs of the minted RFTs - // - // Selector: mintBulk(address,uint256[]) 44a9945e + /// @notice Function to mint multiple tokens. + /// @dev `tokenIds` should be an array of consecutive numbers and first number + /// should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokenIds IDs of the minted RFTs + /// @dev EVM selector for this function is: 0x44a9945e, + /// or in textual repr: mintBulk(address,uint256[]) function mintBulk(address to, uint256[] memory tokenIds) external returns (bool); - // @notice Function to mint multiple tokens with the given tokenUris. - // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive - // numbers and first number should be obtained with `nextTokenId` method - // @param to The new owner - // @param tokens array of pairs of token ID and token URI for minted tokens - // - // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006 - function mintBulkWithTokenURI(address to, Tuple0[] memory tokens) + /// @notice Function to mint multiple tokens with the given tokenUris. + /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive + /// numbers and first number should be obtained with `nextTokenId` method + /// @param to The new owner + /// @param tokens array of pairs of token ID and token URI for minted tokens + /// @dev EVM selector for this function is: 0x36543006, + /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[]) + function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool); - // Returns EVM address for refungible token - // - // @param token ID of the token - // - // Selector: tokenContractAddress(uint256) ab76fac6 + /// Returns EVM address for refungible token + /// + /// @param token ID of the token + /// @dev EVM selector for this function is: 0xab76fac6, + /// or in textual repr: tokenContractAddress(uint256) function tokenContractAddress(uint256 token) external view returns (address); } -// Selector: ffe4da23 -interface Collection is Dummy, ERC165 { - // Set collection property. - // - // @param key Property key. - // @param value Propery value. - // - // Selector: setCollectionProperty(string,bytes) 2f073f66 - function setCollectionProperty(string memory key, bytes memory value) - external; +/// @dev anonymous struct +struct Tuple8 { + uint256 field_0; + string field_1; +} - // Delete collection property. - // - // @param key Property key. - // - // Selector: deleteCollectionProperty(string) 7b7debce - function deleteCollectionProperty(string memory key) external; +/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension +/// @dev See https://eips.ethereum.org/EIPS/eip-721 +/// @dev the ERC-165 identifier for this interface is 0x780e9d63 +interface ERC721Enumerable is Dummy, ERC165 { + /// @notice Enumerate valid RFTs + /// @param index A counter less than `totalSupply()` + /// @return The token identifier for the `index`th NFT, + /// (sort order not specified) + /// @dev EVM selector for this function is: 0x4f6ccce7, + /// or in textual repr: tokenByIndex(uint256) + function tokenByIndex(uint256 index) external view returns (uint256); - // Get collection property. - // - // @dev Throws error if key not found. - // - // @param key Property key. - // @return bytes The property corresponding to the key. - // - // Selector: collectionProperty(string) cf24fd6d - function collectionProperty(string memory key) + /// Not implemented + /// @dev EVM selector for this function is: 0x2f745c59, + /// or in textual repr: tokenOfOwnerByIndex(address,uint256) + function tokenOfOwnerByIndex(address owner, uint256 index) external view - returns (bytes memory); + returns (uint256); - // Set the sponsor of the collection. - // - // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor. - // - // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract. - // - // Selector: setCollectionSponsor(address) 7623402e - function setCollectionSponsor(address sponsor) external; + /// @notice Count RFTs tracked by this contract + /// @return A count of valid RFTs tracked by this contract, where each one of + /// them has an assigned and queryable owner not equal to the zero address + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() + function totalSupply() external view returns (uint256); +} - // Collection sponsorship confirmation. - // - // @dev After setting the sponsor for the collection, it must be confirmed with this function. - // - // Selector: confirmCollectionSponsorship() 3c50e97a - function confirmCollectionSponsorship() external; +/// @dev the ERC-165 identifier for this interface is 0x5b5e139f +interface ERC721Metadata is Dummy, ERC165 { + /// @notice A descriptive name for a collection of RFTs in this contract + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() + function name() external view returns (string memory); - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "accountTokenOwnershipLimit", - // "sponsoredDataSize", - // "sponsoredDataRateLimit", - // "tokenLimit", - // "sponsorTransferTimeout", - // "sponsorApproveTimeout" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,uint32) 6a3841db - function setCollectionLimit(string memory limit, uint32 value) external; + /// @notice An abbreviated name for RFTs in this contract + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() + function symbol() external view returns (string memory); - // Set limits for the collection. - // @dev Throws error if limit not found. - // @param limit Name of the limit. Valid names: - // "ownerCanTransfer", - // "ownerCanDestroy", - // "transfersEnabled" - // @param value Value of the limit. - // - // Selector: setCollectionLimit(string,bool) 993b7fba - function setCollectionLimit(string memory limit, bool value) external; - - // Get contract address. - // - // Selector: contractAddress() f6b4dfb4 - function contractAddress() external view returns (address); - - // Add collection admin by substrate address. - // @param new_admin Substrate administrator address. - // - // Selector: addCollectionAdminSubstrate(uint256) 5730062b - function addCollectionAdminSubstrate(uint256 newAdmin) external; + /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. + /// + /// @dev If the token has a `url` property and it is not empty, it is returned. + /// 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`. + /// If the collection property `baseURI` is empty or absent, return "" (empty string) + /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix + /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings). + /// + /// @return token's const_metadata + /// @dev EVM selector for this function is: 0xc87b56dd, + /// or in textual repr: tokenURI(uint256) + function tokenURI(uint256 tokenId) external view returns (string memory); +} - // Remove collection admin by substrate address. - // @param admin Substrate administrator address. - // - // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9 - function removeCollectionAdminSubstrate(uint256 admin) external; - - // Add collection admin. - // @param new_admin Address of the added administrator. - // - // Selector: addCollectionAdmin(address) 92e462c7 - function addCollectionAdmin(address newAdmin) external; - - // Remove collection admin. - // - // @param new_admin Address of the removed administrator. - // - // Selector: removeCollectionAdmin(address) fafd7b42 - function removeCollectionAdmin(address admin) external; - - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled' - // - // Selector: setCollectionNesting(bool) 112d4586 - function setCollectionNesting(bool enable) external; - - // Toggle accessibility of collection nesting. - // - // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled' - // @param collections Addresses of collections that will be available for nesting. - // - // Selector: setCollectionNesting(bool,address[]) 64872396 - function setCollectionNesting(bool enable, address[] memory collections) - external; +/// @dev inlined interface +interface ERC721Events { + event Transfer( + address indexed from, + address indexed to, + uint256 indexed tokenId + ); + event Approval( + address indexed owner, + address indexed approved, + uint256 indexed tokenId + ); + event ApprovalForAll( + address indexed owner, + address indexed operator, + bool approved + ); +} - // Set the collection access method. - // @param mode Access mode - // 0 for Normal - // 1 for AllowList - // - // Selector: setCollectionAccess(uint8) 41835d4c - function setCollectionAccess(uint8 mode) external; +/// @title ERC-721 Non-Fungible Token Standard +/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md +/// @dev the ERC-165 identifier for this interface is 0x58800161 +interface ERC721 is Dummy, ERC165, ERC721Events { + /// @notice Count all RFTs assigned to an owner + /// @dev RFTs assigned to the zero address are considered invalid, and this + /// function throws for queries about the zero address. + /// @param owner An address for whom to query the balance + /// @return The number of RFTs owned by `owner`, possibly zero + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) + function balanceOf(address owner) external view returns (uint256); - // Add the user to the allowed list. - // - // @param user Address of a trusted user. - // - // Selector: addToCollectionAllowList(address) 67844fe6 - function addToCollectionAllowList(address user) external; + /// @notice Find the owner of an RFT + /// @dev RFTs assigned to zero address are considered invalid, and queries + /// about them do throw. + /// Returns special 0xffffffffffffffffffffffffffffffffffffffff address for + /// the tokens that are partially owned. + /// @param tokenId The identifier for an RFT + /// @return The address of the owner of the RFT + /// @dev EVM selector for this function is: 0x6352211e, + /// or in textual repr: ownerOf(uint256) + function ownerOf(uint256 tokenId) external view returns (address); - // Remove the user from the allowed list. - // - // @param user Address of a removed user. - // - // Selector: removeFromCollectionAllowList(address) 85c51acb - function removeFromCollectionAllowList(address user) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x60a11672, + /// or in textual repr: safeTransferFromWithData(address,address,uint256,bytes) + function safeTransferFromWithData( + address from, + address to, + uint256 tokenId, + bytes memory data + ) external; - // Switch permission for minting. - // - // @param mode Enable if "true". - // - // Selector: setCollectionMintMode(bool) 00018e84 - function setCollectionMintMode(bool mode) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x42842e0e, + /// or in textual repr: safeTransferFrom(address,address,uint256) + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) external; - // Check that account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdmin(address) 9811b0c7 - function isOwnerOrAdmin(address user) external view returns (bool); + /// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE + /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE + /// THEY MAY BE PERMANENTLY LOST + /// @dev Throws unless `msg.sender` is the current owner or an authorized + /// operator for this RFT. Throws if `from` is not the current owner. Throws + /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT. + /// Throws if RFT pieces have multiple owners. + /// @param from The current owner of the NFT + /// @param to The new owner + /// @param tokenId The NFT to transfer + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) + function transferFrom( + address from, + address to, + uint256 tokenId + ) external; - // Check that substrate account is the owner or admin of the collection - // - // @param user account to verify - // @return "true" if account is the owner or admin - // - // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00 - function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool); + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) + function approve(address approved, uint256 tokenId) external; - // Returns collection type - // - // @return `Fungible` or `NFT` or `ReFungible` - // - // Selector: uniqueCollectionType() d34b55b8 - function uniqueCollectionType() external returns (string memory); + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xa22cb465, + /// or in textual repr: setApprovalForAll(address,bool) + function setApprovalForAll(address operator, bool approved) external; - // Changes collection owner to another account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner account - // - // Selector: setOwner(address) 13af4035 - function setOwner(address newOwner) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0x081812fc, + /// or in textual repr: getApproved(uint256) + function getApproved(uint256 tokenId) external view returns (address); - // Changes collection owner to another substrate account - // - // @dev Owner can be changed only by current owner - // @param newOwner new owner substrate account - // - // Selector: setOwnerSubstrate(uint256) b212138f - function setOwnerSubstrate(uint256 newOwner) external; + /// @dev Not implemented + /// @dev EVM selector for this function is: 0xe985e9c5, + /// or in textual repr: isApprovedForAll(address,address) + function isApprovedForAll(address owner, address operator) + external + view + returns (address); } interface UniqueRefungible is --- a/tests/src/eth/api/UniqueRefungibleToken.sol +++ b/tests/src/eth/api/UniqueRefungibleToken.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; -// Common stubs holder +/// @dev common stubs holder interface Dummy { } @@ -12,120 +12,127 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Inline -interface ERC20Events { - event Transfer(address indexed from, address indexed to, uint256 value); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} - -// Selector: 042f1106 +/// @dev the ERC-165 identifier for this interface is 0x042f1106 interface ERC1633UniqueExtensions is Dummy, ERC165 { - // Selector: setParentNFT(address,uint256) 042f1106 + /// @dev EVM selector for this function is: 0x042f1106, + /// or in textual repr: setParentNFT(address,uint256) function setParentNFT(address collection, uint256 nftId) external returns (bool); } -// Selector: 5755c3f2 +/// @dev the ERC-165 identifier for this interface is 0x5755c3f2 interface ERC1633 is Dummy, ERC165 { - // Selector: parentToken() 80a54001 + /// @dev EVM selector for this function is: 0x80a54001, + /// or in textual repr: parentToken() function parentToken() external view returns (address); - // Selector: parentTokenId() d7f083f3 + /// @dev EVM selector for this function is: 0xd7f083f3, + /// or in textual repr: parentTokenId() function parentTokenId() external view returns (uint256); } -// Selector: 942e8b22 +/// @dev the ERC-165 identifier for this interface is 0xab8deb37 +interface ERC20UniqueExtensions is Dummy, ERC165 { + /// @dev Function that burns an amount of the token of a given account, + /// deducting from the sender's allowance for said account. + /// @param from The account whose tokens will be burnt. + /// @param amount The amount that will be burnt. + /// @dev EVM selector for this function is: 0x79cc6790, + /// or in textual repr: burnFrom(address,uint256) + function burnFrom(address from, uint256 amount) external returns (bool); + + /// @dev Function that changes total amount of the tokens. + /// Throws if `msg.sender` doesn't owns all of the tokens. + /// @param amount New total amount of the tokens. + /// @dev EVM selector for this function is: 0xd2418ca7, + /// or in textual repr: repartition(uint256) + function repartition(uint256 amount) external returns (bool); +} + +/// @dev inlined interface +interface ERC20Events { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} + +/// @title Standard ERC20 token +/// +/// @dev Implementation of the basic standard token. +/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md +/// @dev the ERC-165 identifier for this interface is 0x942e8b22 interface ERC20 is Dummy, ERC165, ERC20Events { - // @return the name of the token. - // - // Selector: name() 06fdde03 + /// @return the name of the token. + /// @dev EVM selector for this function is: 0x06fdde03, + /// or in textual repr: name() function name() external view returns (string memory); - // @return the symbol of the token. - // - // Selector: symbol() 95d89b41 + /// @return the symbol of the token. + /// @dev EVM selector for this function is: 0x95d89b41, + /// or in textual repr: symbol() function symbol() external view returns (string memory); - // @dev Total number of tokens in existence - // - // Selector: totalSupply() 18160ddd + /// @dev Total number of tokens in existence + /// @dev EVM selector for this function is: 0x18160ddd, + /// or in textual repr: totalSupply() function totalSupply() external view returns (uint256); - // @dev Not supported - // - // Selector: decimals() 313ce567 + /// @dev Not supported + /// @dev EVM selector for this function is: 0x313ce567, + /// or in textual repr: decimals() function decimals() external view returns (uint8); - // @dev Gets the balance of the specified address. - // @param owner The address to query the balance of. - // @return An uint256 representing the amount owned by the passed address. - // - // Selector: balanceOf(address) 70a08231 + /// @dev Gets the balance of the specified address. + /// @param owner The address to query the balance of. + /// @return An uint256 representing the amount owned by the passed address. + /// @dev EVM selector for this function is: 0x70a08231, + /// or in textual repr: balanceOf(address) function balanceOf(address owner) external view returns (uint256); - // @dev Transfer token for a specified address - // @param to The address to transfer to. - // @param amount The amount to be transferred. - // - // Selector: transfer(address,uint256) a9059cbb + /// @dev Transfer token for a specified address + /// @param to The address to transfer to. + /// @param amount The amount to be transferred. + /// @dev EVM selector for this function is: 0xa9059cbb, + /// or in textual repr: transfer(address,uint256) function transfer(address to, uint256 amount) external returns (bool); - // @dev Transfer tokens from one address to another - // @param from address The address which you want to send tokens from - // @param to address The address which you want to transfer to - // @param amount uint256 the amount of tokens to be transferred - // - // Selector: transferFrom(address,address,uint256) 23b872dd + /// @dev Transfer tokens from one address to another + /// @param from address The address which you want to send tokens from + /// @param to address The address which you want to transfer to + /// @param amount uint256 the amount of tokens to be transferred + /// @dev EVM selector for this function is: 0x23b872dd, + /// or in textual repr: transferFrom(address,address,uint256) function transferFrom( address from, address to, uint256 amount ) external returns (bool); - // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`. - // Beware that changing an allowance with this method brings the risk that someone may use both the old - // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this - // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: - // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - // @param spender The address which will spend the funds. - // @param amount The amount of tokens to be spent. - // - // Selector: approve(address,uint256) 095ea7b3 + /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`. + /// Beware that changing an allowance with this method brings the risk that someone may use both the old + /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this + /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: + /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + /// @param spender The address which will spend the funds. + /// @param amount The amount of tokens to be spent. + /// @dev EVM selector for this function is: 0x095ea7b3, + /// or in textual repr: approve(address,uint256) function approve(address spender, uint256 amount) external returns (bool); - // @dev Function to check the amount of tokens that an owner allowed to a spender. - // @param owner address The address which owns the funds. - // @param spender address The address which will spend the funds. - // @return A uint256 specifying the amount of tokens still available for the spender. - // - // Selector: allowance(address,address) dd62ed3e + /// @dev Function to check the amount of tokens that an owner allowed to a spender. + /// @param owner address The address which owns the funds. + /// @param spender address The address which will spend the funds. + /// @return A uint256 specifying the amount of tokens still available for the spender. + /// @dev EVM selector for this function is: 0xdd62ed3e, + /// or in textual repr: allowance(address,address) function allowance(address owner, address spender) external view returns (uint256); -} - -// Selector: ab8deb37 -interface ERC20UniqueExtensions is Dummy, ERC165 { - // @dev Function that burns an amount of the token of a given account, - // deducting from the sender's allowance for said account. - // @param from The account whose tokens will be burnt. - // @param amount The amount that will be burnt. - // - // Selector: burnFrom(address,uint256) 79cc6790 - function burnFrom(address from, uint256 amount) external returns (bool); - - // @dev Function that changes total amount of the tokens. - // Throws if `msg.sender` doesn't owns all of the tokens. - // @param amount New total amount of the tokens. - // - // Selector: repartition(uint256) d2418ca7 - function repartition(uint256 amount) external returns (bool); } interface UniqueRefungibleToken is --- a/tests/src/eth/nonFungibleAbi.json +++ b/tests/src/eth/nonFungibleAbi.json @@ -255,7 +255,7 @@ { "internalType": "uint256", "name": "field_0", "type": "uint256" }, { "internalType": "string", "name": "field_1", "type": "string" } ], - "internalType": "struct Tuple0[]", + "internalType": "struct Tuple8[]", "name": "tokens", "type": "tuple[]" } @@ -361,7 +361,7 @@ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" } ], - "name": "safeTransferFromWithData", + "name": "safeTransferFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" --- a/tests/src/eth/reFungibleAbi.json +++ b/tests/src/eth/reFungibleAbi.json @@ -255,7 +255,7 @@ { "internalType": "uint256", "name": "field_0", "type": "uint256" }, { "internalType": "string", "name": "field_1", "type": "string" } ], - "internalType": "struct Tuple0[]", + "internalType": "struct Tuple8[]", "name": "tokens", "type": "tuple[]" } --- a/tests/src/eth/util/contractHelpersAbi.json +++ b/tests/src/eth/util/contractHelpersAbi.json @@ -225,7 +225,7 @@ "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }, - { "internalType": "bool", "name": "allowed", "type": "bool" } + { "internalType": "bool", "name": "isAllowed", "type": "bool" } ], "name": "toggleAllowed", "outputs": [], -- gitstuff