Skip to content

Commit 9d86d87

Browse files
committed
removed openzeppelin dependency
1 parent f24edd7 commit 9d86d87

File tree

6 files changed

+6045
-765
lines changed

6 files changed

+6045
-765
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
2+
build
23
temp
34
keys.json
Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,61 @@
11
// SPDX-License-Identifier: MIT;
2-
pragma solidity ^0.6.0;
2+
pragma solidity 0.6.2;
33

4-
import "@openzeppelin/contracts/introspection/ERC165.sol";
4+
import "./IERC165.sol";
55

66
/**
77
* @dev Custom implementation of the IERC165 interface.
88
* This is contract implemented by OpenZeppelin but extended with
99
* _removeInterface function
1010
*/
11-
contract ERC165Removable is ERC165 {
12-
/**
13-
* @dev Removes support of the interface
14-
* @param interfaceId Interface Id
15-
*/
16-
function _removeInterface(bytes4 interfaceId) internal {
17-
require(_supportedInterfaces[interfaceId], "ERC165: unknown interface id");
18-
_supportedInterfaces[interfaceId] = false;
19-
}
11+
contract ERC165Removable is IERC165 {
12+
/**
13+
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
14+
*/
15+
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
16+
17+
/**
18+
* @dev Mapping of interface ids to whether or not it's supported.
19+
*/
20+
mapping(bytes4 => bool) private _supportedInterfaces;
21+
22+
constructor () internal {
23+
// Derived contracts need only register support for their own interfaces,
24+
// we register support for ERC165 itself here
25+
_registerInterface(_INTERFACE_ID_ERC165);
26+
}
27+
28+
/**
29+
* @dev See {IERC165-supportsInterface}.
30+
*
31+
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
32+
*/
33+
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
34+
return _supportedInterfaces[interfaceId];
35+
}
36+
37+
/**
38+
* @dev Registers the contract as an implementer of the interface defined by
39+
* `interfaceId`. Support of the actual ERC165 interface is automatic and
40+
* registering its interface id is not required.
41+
*
42+
* See {IERC165-supportsInterface}.
43+
*
44+
* Requirements:
45+
*
46+
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
47+
*/
48+
function _registerInterface(bytes4 interfaceId) internal virtual {
49+
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
50+
_supportedInterfaces[interfaceId] = true;
51+
}
52+
53+
/**
54+
* @dev Removes support of the interface
55+
* @param interfaceId Interface Id
56+
*/
57+
function _removeInterface(bytes4 interfaceId) internal {
58+
require(_supportedInterfaces[interfaceId], "ERC165: unknown interface id");
59+
_supportedInterfaces[interfaceId] = false;
60+
}
2061
}

contracts/ERC165/IERC165.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.6.0;
4+
5+
/**
6+
* @dev Interface of the ERC165 standard, as defined in the
7+
* https://eips.ethereum.org/EIPS/eip-165[EIP].
8+
*
9+
* Implementers can declare support of contract interfaces, which can then be
10+
* queried by others ({ERC165Checker}).
11+
*
12+
* For an implementation, see {ERC165}.
13+
*/
14+
interface IERC165 {
15+
/**
16+
* @dev Returns true if this contract implements the interface defined by
17+
* `interfaceId`. See the corresponding
18+
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
19+
* to learn more about how these ids are created.
20+
*
21+
* This function call must use less than 30 000 gas.
22+
*/
23+
function supportsInterface(bytes4 interfaceId) external view returns (bool);
24+
}

0 commit comments

Comments
 (0)