-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
6,045 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
build | ||
temp | ||
keys.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,61 @@ | ||
// SPDX-License-Identifier: MIT; | ||
pragma solidity ^0.6.0; | ||
pragma solidity 0.6.2; | ||
|
||
import "@openzeppelin/contracts/introspection/ERC165.sol"; | ||
import "./IERC165.sol"; | ||
|
||
/** | ||
* @dev Custom implementation of the IERC165 interface. | ||
* This is contract implemented by OpenZeppelin but extended with | ||
* _removeInterface function | ||
*/ | ||
contract ERC165Removable is ERC165 { | ||
/** | ||
* @dev Removes support of the interface | ||
* @param interfaceId Interface Id | ||
*/ | ||
function _removeInterface(bytes4 interfaceId) internal { | ||
require(_supportedInterfaces[interfaceId], "ERC165: unknown interface id"); | ||
_supportedInterfaces[interfaceId] = false; | ||
} | ||
contract ERC165Removable is IERC165 { | ||
/** | ||
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 | ||
*/ | ||
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; | ||
|
||
/** | ||
* @dev Mapping of interface ids to whether or not it's supported. | ||
*/ | ||
mapping(bytes4 => bool) private _supportedInterfaces; | ||
|
||
constructor () internal { | ||
// Derived contracts need only register support for their own interfaces, | ||
// we register support for ERC165 itself here | ||
_registerInterface(_INTERFACE_ID_ERC165); | ||
} | ||
|
||
/** | ||
* @dev See {IERC165-supportsInterface}. | ||
* | ||
* Time complexity O(1), guaranteed to always use less than 30 000 gas. | ||
*/ | ||
function supportsInterface(bytes4 interfaceId) public view override returns (bool) { | ||
return _supportedInterfaces[interfaceId]; | ||
} | ||
|
||
/** | ||
* @dev Registers the contract as an implementer of the interface defined by | ||
* `interfaceId`. Support of the actual ERC165 interface is automatic and | ||
* registering its interface id is not required. | ||
* | ||
* See {IERC165-supportsInterface}. | ||
* | ||
* Requirements: | ||
* | ||
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). | ||
*/ | ||
function _registerInterface(bytes4 interfaceId) internal virtual { | ||
require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); | ||
_supportedInterfaces[interfaceId] = true; | ||
} | ||
|
||
/** | ||
* @dev Removes support of the interface | ||
* @param interfaceId Interface Id | ||
*/ | ||
function _removeInterface(bytes4 interfaceId) internal { | ||
require(_supportedInterfaces[interfaceId], "ERC165: unknown interface id"); | ||
_supportedInterfaces[interfaceId] = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.6.0; | ||
|
||
/** | ||
* @dev Interface of the ERC165 standard, as defined in the | ||
* https://eips.ethereum.org/EIPS/eip-165[EIP]. | ||
* | ||
* Implementers can declare support of contract interfaces, which can then be | ||
* queried by others ({ERC165Checker}). | ||
* | ||
* For an implementation, see {ERC165}. | ||
*/ | ||
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); | ||
} |
Oops, something went wrong.