Skip to content
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

Remove override interface implementations #4315

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4daab31
AccessControl
RenanSouza2 Jun 5, 2023
ebf635c
AccessControlEnumerable
RenanSouza2 Jun 5, 2023
7a0466f
Governor
RenanSouza2 Jun 5, 2023
f377dd4
IGovernor
RenanSouza2 Jun 5, 2023
6b50b81
TimelockController
RenanSouza2 Jun 5, 2023
bec26fc
Votes
RenanSouza2 Jun 5, 2023
17401ed
ERC1271WalletMock
RenanSouza2 Jun 5, 2023
8db131c
ERC3156FlashBorrowerMock
RenanSouza2 Jun 5, 2023
5d29695
ERC20VotesLegacyMock
RenanSouza2 Jun 5, 2023
75cb14f
ERC721ReceiverMock
RenanSouza2 Jun 5, 2023
92dad67
ERC1155ReceiverMock
RenanSouza2 Jun 5, 2023
f20a8d1
UpgradeableBeacon
RenanSouza2 Jun 5, 2023
86519c3
UUPSUpgradeable
RenanSouza2 Jun 5, 2023
88e9853
ERC2981
RenanSouza2 Jun 5, 2023
cdf8b1d
ERC1155
RenanSouza2 Jun 5, 2023
4326964
ERC20
RenanSouza2 Jun 5, 2023
320a0c2
ERC20FlashMint
RenanSouza2 Jun 5, 2023
5da5221
ERC20Permit
RenanSouza2 Jun 5, 2023
9fb85db
ERC4626
RenanSouza2 Jun 5, 2023
8cc7431
ERC721
RenanSouza2 Jun 5, 2023
ff241a8
ERC721Enumerable
RenanSouza2 Jun 5, 2023
da12258
ERC721Wrapper
RenanSouza2 Jun 5, 2023
6ee337d
ERC721Holder
RenanSouza2 Jun 5, 2023
3cdda53
EIP712
RenanSouza2 Jun 5, 2023
307c154
EIP165
RenanSouza2 Jun 5, 2023
1372aeb
Recover comments
RenanSouza2 Jun 5, 2023
ac0a4b2
Add changeset
RenanSouza2 Jun 5, 2023
13b211b
Fix changeset
RenanSouza2 Jun 6, 2023
e6d8ee1
Update .changeset/violet-dancers-cough.md
ernestognw Jun 6, 2023
52229bf
Merge remote-tracking branch 'upstream/master' into remove-override-i…
RenanSouza2 Jun 6, 2023
6ab19df
Merge branch 'master' into remove-override-interface-implementations
RenanSouza2 Jun 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-dancers-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

Remove the `override` specifier from functions that only override a single interface function.
10 changes: 5 additions & 5 deletions contracts/access/AccessControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].members[account];
}

Expand Down Expand Up @@ -126,7 +126,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}

Expand All @@ -142,7 +142,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}

Expand All @@ -157,7 +157,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}

Expand All @@ -177,7 +177,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");

_revokeRole(role, account);
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/AccessControlEnumerable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessCon
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {
return _roleMembers[role].at(index);
}

/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {
return _roleMembers[role].length();
}

Expand Down
12 changes: 3 additions & 9 deletions contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -605,20 +605,14 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive
/**
* @dev See {IERC721Receiver-onERC721Received}.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
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 override returns (bytes4) {
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}

Expand All @@ -631,7 +625,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
) public virtual returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
4 changes: 2 additions & 2 deletions contracts/governance/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ abstract contract IGovernor is IERC165, IERC6372 {
* @notice module:core
* @dev See {IERC6372}
*/
function clock() public view virtual override returns (uint48);
function clock() public view virtual returns (uint48);

/**
* @notice module:core
* @dev See EIP-6372.
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() public view virtual override returns (string memory);
function CLOCK_MODE() public view virtual returns (string memory);

/**
* @notice module:voting
Expand Down
12 changes: 3 additions & 9 deletions contracts/governance/TimelockController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,14 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver
/**
* @dev See {IERC721Receiver-onERC721Received}.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
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 override returns (bytes4) {
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}

Expand All @@ -410,7 +404,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
) public virtual returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
16 changes: 8 additions & 8 deletions contracts/governance/utils/Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based
* checkpoints (and voting), in which case {CLOCK_MODE} should be overridden as well to match.
*/
function clock() public view virtual override returns (uint48) {
function clock() public view virtual returns (uint48) {
return SafeCast.toUint48(block.number);
}

/**
* @dev Machine-readable description of the clock as specified in EIP-6372.
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() public view virtual override returns (string memory) {
function CLOCK_MODE() public view virtual returns (string memory) {
// Check that the clock was not modified
require(clock() == block.number, "Votes: broken clock mode");
return "mode=blocknumber&from=default";
Expand All @@ -63,7 +63,7 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
/**
* @dev Returns the current amount of votes that `account` has.
*/
function getVotes(address account) public view virtual override returns (uint256) {
function getVotes(address account) public view virtual returns (uint256) {
return _delegateCheckpoints[account].latest();
}

Expand All @@ -75,7 +75,7 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
*
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
*/
function getPastVotes(address account, uint256 timepoint) public view virtual override returns (uint256) {
function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256) {
require(timepoint < clock(), "Votes: future lookup");
return _delegateCheckpoints[account].upperLookupRecent(SafeCast.toUint32(timepoint));
}
Expand All @@ -92,7 +92,7 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
*
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
*/
function getPastTotalSupply(uint256 timepoint) public view virtual override returns (uint256) {
function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256) {
require(timepoint < clock(), "Votes: future lookup");
return _totalCheckpoints.upperLookupRecent(SafeCast.toUint32(timepoint));
}
Expand All @@ -107,14 +107,14 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
/**
* @dev Returns the delegate that `account` has chosen.
*/
function delegates(address account) public view virtual override returns (address) {
function delegates(address account) public view virtual returns (address) {
return _delegation[account];
}

/**
* @dev Delegates votes from the sender to `delegatee`.
*/
function delegate(address delegatee) public virtual override {
function delegate(address delegatee) public virtual {
address account = _msgSender();
_delegate(account, delegatee);
}
Expand All @@ -129,7 +129,7 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
) public virtual {
require(block.timestamp <= expiry, "Votes: signature expired");
address signer = ECDSA.recover(
_hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/ERC1271WalletMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import "../utils/cryptography/ECDSA.sol";
contract ERC1271WalletMock is Ownable, IERC1271 {
constructor(address originalOwner) Ownable(originalOwner) {}

function isValidSignature(bytes32 hash, bytes memory signature) public view override returns (bytes4 magicValue) {
function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magicValue) {
return ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0);
}
}

contract ERC1271MaliciousMock is IERC1271 {
function isValidSignature(bytes32, bytes memory) public pure override returns (bytes4) {
function isValidSignature(bytes32, bytes memory) public pure returns (bytes4) {
assembly {
mstore(0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
return(0, 32)
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ERC3156FlashBorrowerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower {
uint256 amount,
uint256 fee,
bytes calldata data
) public override returns (bytes32) {
) public returns (bytes32) {
require(msg.sender == token);

emit BalanceOf(token, address(this), IERC20(token).balanceOf(address(this)));
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/token/ERC1155ReceiverMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver {
uint256 id,
uint256 value,
bytes calldata data
) external override returns (bytes4) {
) external returns (bytes4) {
require(!_recReverts, "ERC1155ReceiverMock: reverting on receive");
emit Received(operator, from, id, value, data, gasleft());
return _recRetval;
Expand All @@ -39,7 +39,7 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver {
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external override returns (bytes4) {
) external returns (bytes4) {
require(!_batReverts, "ERC1155ReceiverMock: reverting on batch receive");
emit BatchReceived(operator, from, ids, values, data, gasleft());
return _batRetval;
Expand Down
12 changes: 6 additions & 6 deletions contracts/mocks/token/ERC20VotesLegacyMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ abstract contract ERC20VotesLegacyMock is IVotes, ERC20Permit {
/**
* @dev Get the address `account` is currently delegating to.
*/
function delegates(address account) public view virtual override returns (address) {
function delegates(address account) public view virtual returns (address) {
return _delegates[account];
}

/**
* @dev Gets the current votes balance for `account`
*/
function getVotes(address account) public view virtual override returns (uint256) {
function getVotes(address account) public view virtual returns (uint256) {
uint256 pos = _checkpoints[account].length;
unchecked {
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
Expand All @@ -62,7 +62,7 @@ abstract contract ERC20VotesLegacyMock is IVotes, ERC20Permit {
*
* - `blockNumber` must have been already mined
*/
function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {
function getPastVotes(address account, uint256 blockNumber) public view virtual returns (uint256) {
require(blockNumber < block.number, "ERC20Votes: block not yet mined");
return _checkpointsLookup(_checkpoints[account], blockNumber);
}
Expand All @@ -75,7 +75,7 @@ abstract contract ERC20VotesLegacyMock is IVotes, ERC20Permit {
*
* - `blockNumber` must have been already mined
*/
function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {
function getPastTotalSupply(uint256 blockNumber) public view virtual returns (uint256) {
require(blockNumber < block.number, "ERC20Votes: block not yet mined");
return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);
}
Expand Down Expand Up @@ -127,7 +127,7 @@ abstract contract ERC20VotesLegacyMock is IVotes, ERC20Permit {
/**
* @dev Delegate votes from the sender to `delegatee`.
*/
function delegate(address delegatee) public virtual override {
function delegate(address delegatee) public virtual {
_delegate(_msgSender(), delegatee);
}

Expand All @@ -141,7 +141,7 @@ abstract contract ERC20VotesLegacyMock is IVotes, ERC20Permit {
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
) public virtual {
require(block.timestamp <= expiry, "ERC20Votes: signature expired");
address signer = ECDSA.recover(
_hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/token/ERC721ReceiverMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract ERC721ReceiverMock is IERC721Receiver {
address from,
uint256 tokenId,
bytes memory data
) public override returns (bytes4) {
) public returns (bytes4) {
if (_error == Error.RevertWithMessage) {
revert("ERC721ReceiverMock: reverting");
} else if (_error == Error.RevertWithoutMessage) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/beacon/UpgradeableBeacon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract UpgradeableBeacon is IBeacon, Ownable {
/**
* @dev Returns the current implementation address.
*/
function implementation() public view virtual override returns (address) {
function implementation() public view virtual returns (address) {
return _implementation;
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/proxy/utils/UUPSUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade {
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade {
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
Expand Down
Loading