From c014c8f1484b2fcbac5fae9c05b6d63771f0d716 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 15 Jun 2023 23:27:36 +0200 Subject: [PATCH] Use ERC721Holder & ERC1155Holder in the TimelockController (#4284) Co-authored-by: Francisco --- contracts/governance/TimelockController.sol | 39 ++++----------------- scripts/checks/inheritance-ordering.js | 2 +- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 4772a252f..a25cd7b4a 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.19; import "../access/AccessControl.sol"; -import "../token/ERC721/IERC721Receiver.sol"; -import "../token/ERC1155/IERC1155Receiver.sol"; +import "../token/ERC721/utils/ERC721Holder.sol"; +import "../token/ERC1155/utils/ERC1155Holder.sol"; import "../utils/Address.sol"; /** @@ -23,7 +23,7 @@ import "../utils/Address.sol"; * * _Available since v3.3._ */ -contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver { +contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder { bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE"); bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE"); bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE"); @@ -155,8 +155,10 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev See {IERC165-supportsInterface}. */ - function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) { - return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(AccessControl, ERC1155Receiver) returns (bool) { + return super.supportsInterface(interfaceId); } /** @@ -430,31 +432,4 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; } - - /** - * @dev See {IERC721Receiver-onERC721Received}. - */ - function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) { - return this.onERC721Received.selector; - } - - /** - * @dev See {IERC1155Receiver-onERC1155Received}. - */ - function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual returns (bytes4) { - return this.onERC1155Received.selector; - } - - /** - * @dev See {IERC1155Receiver-onERC1155BatchReceived}. - */ - function onERC1155BatchReceived( - address, - address, - uint256[] memory, - uint256[] memory, - bytes memory - ) public virtual returns (bytes4) { - return this.onERC1155BatchReceived.selector; - } } diff --git a/scripts/checks/inheritance-ordering.js b/scripts/checks/inheritance-ordering.js index 45c707e6f..72aa37ef7 100755 --- a/scripts/checks/inheritance-ordering.js +++ b/scripts/checks/inheritance-ordering.js @@ -13,7 +13,7 @@ for (const artifact of artifacts) { const linearized = []; for (const source in solcOutput.contracts) { - if (source.includes('/mocks/')) { + if (['contracts-exposed/', 'contracts/mocks/'].some(pattern => source.startsWith(pattern))) { continue; }