Skip to content

Commit

Permalink
Override supportsInterface in ERC721 and ERC1155 tokens (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev authored May 26, 2021
1 parent 235c81d commit fca0e37
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
23 changes: 22 additions & 1 deletion contracts/tokens/ERC1155BridgeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token {
_;
}

/**
* @dev Tells if this contract implements the interface defined by
* `interfaceId`. See the corresponding EIP165.
* @return true, if interface is implemented.
*/
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
bytes4 INTERFACE_ID_ERC165 = 0x01ffc9a7;
bytes4 INTERFACE_ID_ERC1155 = 0xd9b67a26;
bytes4 INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c;
return
interfaceId == INTERFACE_ID_ERC165 ||
interfaceId == INTERFACE_ID_ERC1155 ||
interfaceId == INTERFACE_ID_ERC1155_METADATA_URI;
}

/**
* @dev Stub for preventing unneeded storage writes.
* All supported interfaces are hardcoded in the supportsInterface function.
*/
function _registerInterface(bytes4) internal override {}

/**
* @dev Mint a batch of new ERC1155 tokens.
* Only bridge contract is authorized to mint tokens.
Expand Down Expand Up @@ -128,6 +149,6 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token {
uint64 patch
)
{
return (1, 0, 0);
return (1, 0, 1);
}
}
25 changes: 24 additions & 1 deletion contracts/tokens/ERC721BridgeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token {
_;
}

/**
* @dev Tells if this contract implements the interface defined by
* `interfaceId`. See the corresponding EIP165.
* @return true, if interface is implemented.
*/
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
bytes4 INTERFACE_ID_ERC165 = 0x01ffc9a7;
bytes4 INTERFACE_ID_ERC721 = 0x80ac58cd;
bytes4 INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
bytes4 INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
return
interfaceId == INTERFACE_ID_ERC165 ||
interfaceId == INTERFACE_ID_ERC721 ||
interfaceId == INTERFACE_ID_ERC721_METADATA ||
interfaceId == INTERFACE_ID_ERC721_ENUMERABLE;
}

/**
* @dev Stub for preventing unneeded storage writes.
* All supported interfaces are hardcoded in the supportsInterface function.
*/
function _registerInterface(bytes4) internal override {}

/**
* @dev Mint new ERC721 token.
* Only bridge contract is authorized to mint tokens.
Expand Down Expand Up @@ -95,6 +118,6 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token {
uint64 patch
)
{
return (1, 0, 0);
return (1, 0, 1);
}
}

0 comments on commit fca0e37

Please sign in to comment.