Skip to content

Commit

Permalink
perf: use directly IERC165 in inheritance instead of ERC165
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Sep 20, 2023
1 parent 7112a50 commit 219a0f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
9 changes: 6 additions & 3 deletions implementations/contracts/ERC725.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.5;

// interfaces
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";
import {ERC725XCore} from "./ERC725XCore.sol";
import {ERC725YCore} from "./ERC725YCore.sol";


// constants
import {_INTERFACEID_ERC725X, _INTERFACEID_ERC725Y} from "./constants.sol";

Expand Down Expand Up @@ -37,14 +40,14 @@ contract ERC725 is ERC725XCore, ERC725YCore {
}

/**
* @inheritdoc ERC165
* @inheritdoc ERC725XCore
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC725XCore, ERC725YCore) returns (bool) {
return
interfaceId == _INTERFACEID_ERC725X ||
interfaceId == _INTERFACEID_ERC725Y ||
super.supportsInterface(interfaceId);
interfaceId == type(IERC165).interfaceId;
}
}
9 changes: 6 additions & 3 deletions implementations/contracts/ERC725InitAbstract.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.5;

// interfaces
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {
Initializable
} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";
import {ERC725XCore} from "./ERC725XCore.sol";
import {ERC725YCore} from "./ERC725YCore.sol";


// constants
import {_INTERFACEID_ERC725X, _INTERFACEID_ERC725Y} from "./constants.sol";

Expand Down Expand Up @@ -45,14 +48,14 @@ abstract contract ERC725InitAbstract is
}

/**
* @inheritdoc ERC165
* @inheritdoc IERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC725XCore, ERC725YCore) returns (bool) {
return
interfaceId == _INTERFACEID_ERC725X ||
interfaceId == _INTERFACEID_ERC725Y ||
super.supportsInterface(interfaceId);
interfaceId == type(IERC165).interfaceId;
}
}
9 changes: 4 additions & 5 deletions implementations/contracts/ERC725XCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";

// constants
Expand All @@ -33,7 +32,7 @@ import "./errors.sol";
* It also allows to deploy and create new contracts via both the `create` and `create2` opcodes.
* This is the basis for a smart contract based account system, but could also be used as a proxy account system.
*/
abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X {
abstract contract ERC725XCore is OwnableUnset, IERC165, IERC725X {
/**
* @inheritdoc IERC725X
* @custom:requirements
Expand Down Expand Up @@ -76,14 +75,14 @@ abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X {
}

/**
* @inheritdoc ERC165
* @inheritdoc IERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, ERC165) returns (bool) {
) public view virtual override returns (bool) {
return
interfaceId == _INTERFACEID_ERC725X ||
super.supportsInterface(interfaceId);
interfaceId == type(IERC165).interfaceId;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions implementations/contracts/ERC725YCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {IERC725Y} from "./interfaces/IERC725Y.sol";

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";

// constants
Expand All @@ -20,7 +19,7 @@ import "./errors.sol";
* @dev ERC725Y provides the ability to set arbitrary data key/value pairs that can be changed over time.
* It is intended to standardise certain data key/value pairs to allow automated read and writes from/to the contract storage.
*/
abstract contract ERC725YCore is OwnableUnset, ERC165, IERC725Y {
abstract contract ERC725YCore is OwnableUnset, IERC165, IERC725Y {
/**
* @dev Map `bytes32` data keys to their `bytes` data values.
*/
Expand Down Expand Up @@ -149,13 +148,13 @@ abstract contract ERC725YCore is OwnableUnset, ERC165, IERC725Y {
}

/**
* @inheritdoc ERC165
* @inheritdoc IERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, ERC165) returns (bool) {
) public view virtual override returns (bool) {
return
interfaceId == _INTERFACEID_ERC725Y ||
super.supportsInterface(interfaceId);
interfaceId == type(IERC165).interfaceId;
}
}

0 comments on commit 219a0f8

Please sign in to comment.