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
203#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]203#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
204impl<T: Config> NonfungibleHandle<T> {204impl<T: Config> NonfungibleHandle<T> {
205 /// @notice A descriptive name for a collection of NFTs in this contract205 /// @notice A descriptive name for a collection of NFTs in this contract
206 /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
207 #[solidity(hide, rename_selector = "name")]
206 fn name(&self) -> Result<string> {208 fn name_proxy(&self) -> Result<string> {
207 Ok(decode_utf16(self.name.iter().copied())209 self.name()
208 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
209 .collect::<string>())
210 }210 }
211211
212 /// @notice An abbreviated name for NFTs in this contract212 /// @notice An abbreviated name for NFTs in this contract
213 /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
214 #[solidity(hide, rename_selector = "symbol")]
213 fn symbol(&self) -> Result<string> {215 fn symbol_proxy(&self) -> Result<string> {
214 Ok(string::from_utf8_lossy(&self.token_prefix).into())216 self.symbol()
215 }217 }
216218
217 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.219 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
571/// @title Unique extensions for ERC721.573/// @title Unique extensions for ERC721.
572#[solidity_interface(name = ERC721UniqueExtensions)]574#[solidity_interface(name = ERC721UniqueExtensions)]
573impl<T: Config> NonfungibleHandle<T> {575impl<T: Config> NonfungibleHandle<T> {
576 /// @notice A descriptive name for a collection of NFTs in this contract
577 fn name(&self) -> Result<string> {
578 Ok(decode_utf16(self.name.iter().copied())
579 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
580 .collect::<string>())
581 }
582
583 /// @notice An abbreviated name for NFTs in this contract
584 fn symbol(&self) -> Result<string> {
585 Ok(string::from_utf8_lossy(&self.token_prefix).into())
586 }
587
574 /// @notice Transfer ownership of an NFT588 /// @notice Transfer ownership of an NFT
575 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`589 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
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
16/// @dev See https://eips.ethereum.org/EIPS/eip-72116/// @dev See https://eips.ethereum.org/EIPS/eip-721
17/// @dev the ERC-165 identifier for this interface is 0x5b5e139f17/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
18interface ERC721Metadata is Dummy, ERC165 {18interface ERC721Metadata is Dummy, ERC165 {
19 /// @notice A descriptive name for a collection of NFTs in this contract19 // /// @notice A descriptive name for a collection of NFTs in this contract
20 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
20 /// @dev EVM selector for this function is: 0x06fdde03,21 // /// @dev EVM selector for this function is: 0x06fdde03,
21 /// or in textual repr: name()22 // /// or in textual repr: name()
22 function name() external view returns (string memory);23 // function name() external view returns (string memory);
2324
24 /// @notice An abbreviated name for NFTs in this contract25 // /// @notice An abbreviated name for NFTs in this contract
26 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`
25 /// @dev EVM selector for this function is: 0x95d89b41,27 // /// @dev EVM selector for this function is: 0x95d89b41,
26 /// or in textual repr: symbol()28 // /// or in textual repr: symbol()
27 function symbol() external view returns (string memory);29 // function symbol() external view returns (string memory);
2830
29 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.31 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
30 ///32 ///
336}338}
337339
338/// @title Unique extensions for ERC721.340/// @title Unique extensions for ERC721.
339/// @dev the ERC-165 identifier for this interface is 0xd74d154f341/// @dev the ERC-165 identifier for this interface is 0x4468500d
340interface ERC721UniqueExtensions is Dummy, ERC165 {342interface ERC721UniqueExtensions is Dummy, ERC165 {
343 /// @notice A descriptive name for a collection of NFTs in this contract
344 /// @dev EVM selector for this function is: 0x06fdde03,
345 /// or in textual repr: name()
346 function name() external view returns (string memory);
347
348 /// @notice An abbreviated name for NFTs in this contract
349 /// @dev EVM selector for this function is: 0x95d89b41,
350 /// or in textual repr: symbol()
351 function symbol() external view returns (string memory);
352
341 /// @notice Transfer ownership of an NFT353 /// @notice Transfer ownership of an NFT
342 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`354 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`