-
Notifications
You must be signed in to change notification settings - Fork 969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #161: Add EIP-165 support in DefaultCallbackHandler #285
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,11 @@ pragma solidity >=0.7.0 <0.9.0; | |
import "../interfaces/ERC1155TokenReceiver.sol"; | ||
import "../interfaces/ERC721TokenReceiver.sol"; | ||
import "../interfaces/ERC777TokensRecipient.sol"; | ||
import "../interfaces/IERC165.sol"; | ||
|
||
/// @title Default Callback Handler - returns true for known token callbacks | ||
/// @author Richard Meissner - <[email protected]> | ||
contract DefaultCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver { | ||
contract DefaultCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 { | ||
|
||
string public constant NAME = "Default Callback Handler"; | ||
string public constant VERSION = "1.0.0"; | ||
|
@@ -48,4 +49,17 @@ contract DefaultCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, | |
// We implement this for completeness, doesn't really have any value | ||
} | ||
|
||
|
||
function supportsInterface(bytes4 interfaceId) | ||
virtual | ||
override | ||
external | ||
view | ||
returns (bool) | ||
{ | ||
return interfaceId == type(ERC1155TokenReceiver).interfaceId | ||
|| interfaceId == type(ERC721TokenReceiver).interfaceId | ||
|| interfaceId == type(IERC165).interfaceId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I guess this is the same that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so yes ... I just went with this as it was more in line we the statements above. |
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol | ||
interface IERC165 { | ||
/** | ||
* @dev Returns true if this contract implements the interface defined by | ||
* `interfaceId`. See the corresponding | ||
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] | ||
* to learn more about how these ids are created. | ||
* | ||
* This function call must use less than 30 000 gas. | ||
*/ | ||
function supportsInterface(bytes4 interfaceId) external view returns (bool); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know
interfaceId
was introduced in Solidity some months ago, nice