git.delta.rocks / unique-network / refs/commits / 8ad09da9d2af

difftreelog

fix(nft) name/symbol should be always callable

Yaroslav Bolyukin2022-10-13parent: #f8b7b18.patch.diff
in: master

4 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -203,15 +203,17 @@
 #[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
 impl<T: Config> NonfungibleHandle<T> {
 	/// @notice A descriptive name for a collection of NFTs in this contract
-	fn name(&self) -> Result<string> {
-		Ok(decode_utf16(self.name.iter().copied())
-			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
-			.collect::<string>())
+	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
+	#[solidity(hide, rename_selector = "name")]
+	fn name_proxy(&self) -> Result<string> {
+		self.name()
 	}
 
 	/// @notice An abbreviated name for NFTs in this contract
-	fn symbol(&self) -> Result<string> {
-		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<string> {
+		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<T: Config> NonfungibleHandle<T> {
+	/// @notice A descriptive name for a collection of NFTs in this contract
+	fn name(&self) -> Result<string> {
+		Ok(decode_utf16(self.name.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
+	/// @notice An abbreviated name for NFTs in this contract
+	fn symbol(&self) -> Result<string> {
+		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.
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
21/// @dev See https://eips.ethereum.org/EIPS/eip-72121/// @dev See https://eips.ethereum.org/EIPS/eip-721
22/// @dev the ERC-165 identifier for this interface is 0x5b5e139f22/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
23contract ERC721Metadata is Dummy, ERC165 {23contract ERC721Metadata is Dummy, ERC165 {
24 /// @notice A descriptive name for a collection of NFTs in this contract24 // /// @notice A descriptive name for a collection of NFTs in this contract
25 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
25 /// @dev EVM selector for this function is: 0x06fdde03,26 // /// @dev EVM selector for this function is: 0x06fdde03,
26 /// or in textual repr: name()27 // /// or in textual repr: name()
27 function name() public view returns (string memory) {28 // function name() public view returns (string memory) {
28 require(false, stub_error);29 // require(false, stub_error);
29 dummy;30 // dummy;
30 return "";31 // return "";
31 }32 // }
3233
33 /// @notice An abbreviated name for NFTs in this contract34 // /// @notice An abbreviated name for NFTs in this contract
35 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
34 /// @dev EVM selector for this function is: 0x95d89b41,36 // /// @dev EVM selector for this function is: 0x95d89b41,
35 /// or in textual repr: symbol()37 // /// or in textual repr: symbol()
36 function symbol() public view returns (string memory) {38 // function symbol() public view returns (string memory) {
37 require(false, stub_error);39 // require(false, stub_error);
38 dummy;40 // dummy;
39 return "";41 // return "";
40 }42 // }
4143
42 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.44 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
43 ///45 ///
504}506}
505507
506/// @title Unique extensions for ERC721.508/// @title Unique extensions for ERC721.
507/// @dev the ERC-165 identifier for this interface is 0xd74d154f509/// @dev the ERC-165 identifier for this interface is 0x4468500d
508contract ERC721UniqueExtensions is Dummy, ERC165 {510contract ERC721UniqueExtensions is Dummy, ERC165 {
511 /// @notice A descriptive name for a collection of NFTs in this contract
512 /// @dev EVM selector for this function is: 0x06fdde03,
513 /// or in textual repr: name()
514 function name() public view returns (string memory) {
515 require(false, stub_error);
516 dummy;
517 return "";
518 }
519
520 /// @notice An abbreviated name for NFTs in this contract
521 /// @dev EVM selector for this function is: 0x95d89b41,
522 /// or in textual repr: symbol()
523 function symbol() public view returns (string memory) {
524 require(false, stub_error);
525 dummy;
526 return "";
527 }
528
509 /// @notice Transfer ownership of an NFT529 /// @notice Transfer ownership of an NFT
510 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`530 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- 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.