--- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -203,15 +203,17 @@ #[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 { - Ok(decode_utf16(self.name.iter().copied()) - .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER)) - .collect::()) + /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + #[solidity(hide, rename_selector = "name")] + fn name_proxy(&self) -> Result { + self.name() } /// @notice An abbreviated name for NFTs in this contract - fn symbol(&self) -> Result { - Ok(string::from_utf8_lossy(&self.token_prefix).into()) + /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + #[solidity(hide, rename_selector = "symbol")] + fn symbol_proxy(&self) -> Result { + self.symbol() } /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. @@ -571,6 +573,18 @@ /// @title Unique extensions for ERC721. #[solidity_interface(name = ERC721UniqueExtensions)] impl NonfungibleHandle { + /// @notice A descriptive name for a collection of NFTs in this contract + fn name(&self) -> Result { + Ok(decode_utf16(self.name.iter().copied()) + .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER)) + .collect::()) + } + + /// @notice An abbreviated name for NFTs in this contract + fn symbol(&self) -> Result { + Ok(string::from_utf8_lossy(&self.token_prefix).into()) + } + /// @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. --- a/pallets/nonfungible/src/stubs/UniqueNFT.sol +++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol @@ -21,23 +21,25 @@ /// @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; - return ""; - } + // /// @notice A descriptive name for a collection of NFTs in this contract + // /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + // /// @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 ""; + // } - /// @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); - dummy; - return ""; - } + // /// @notice An abbreviated name for NFTs in this contract + // /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + // /// @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 ""; + // } /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. /// @@ -504,8 +506,26 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0xd74d154f +/// @dev the ERC-165 identifier for this interface is 0x4468500d contract ERC721UniqueExtensions 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; + return ""; + } + + /// @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); + dummy; + return ""; + } + /// @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. --- a/tests/src/eth/api/UniqueNFT.sol +++ b/tests/src/eth/api/UniqueNFT.sol @@ -16,15 +16,17 @@ /// @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); + // /// @notice A descriptive name for a collection of NFTs in this contract + // /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + // /// @dev EVM selector for this function is: 0x06fdde03, + // /// or in textual repr: name() + // function name() external view returns (string memory); - /// @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); + // /// @notice An abbreviated name for NFTs in this contract + // /// @dev real implementation of this function lies in `ERC721UniqueExtensions` + // /// @dev EVM selector for this function is: 0x95d89b41, + // /// or in textual repr: symbol() + // function symbol() external view returns (string memory); /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. /// @@ -336,8 +338,18 @@ } /// @title Unique extensions for ERC721. -/// @dev the ERC-165 identifier for this interface is 0xd74d154f +/// @dev the ERC-165 identifier for this interface is 0x4468500d interface ERC721UniqueExtensions 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); + + /// @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); + /// @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.