From b7da617d8dd999c48ca0deeeb16b1c336d372873 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Sat, 2 Sep 2023 06:31:59 +0200 Subject: [PATCH] Define ERC-4906 interfaceId in a private constant (#4560) Co-authored-by: Francisco Giordano --- contracts/token/ERC721/extensions/ERC721URIStorage.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contracts/token/ERC721/extensions/ERC721URIStorage.sol b/contracts/token/ERC721/extensions/ERC721URIStorage.sol index dbcf3d4e6..0a4f57322 100644 --- a/contracts/token/ERC721/extensions/ERC721URIStorage.sol +++ b/contracts/token/ERC721/extensions/ERC721URIStorage.sol @@ -14,6 +14,10 @@ import {IERC165} from "../../../interfaces/IERC165.sol"; abstract contract ERC721URIStorage is IERC4906, ERC721 { using Strings for uint256; + // Interface ID as defined in ERC-4906. This does not correspond to a traditional interface ID as ERC-4906 only + // defines events and does not include any external function. + bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906); + // Optional mapping for token URIs mapping(uint256 tokenId => string) private _tokenURIs; @@ -21,7 +25,7 @@ abstract contract ERC721URIStorage is IERC4906, ERC721 { * @dev See {IERC165-supportsInterface} */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) { - return interfaceId == bytes4(0x49064906) || super.supportsInterface(interfaceId); + return interfaceId == ERC4906_INTERFACE_ID || super.supportsInterface(interfaceId); } /**