From acd97fd82c6dc56872d70ddb9546de54597fbd10 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Wed, 11 Jan 2023 08:46:42 -0400 Subject: [PATCH 01/19] Remove isContract --- contracts/mocks/AddressImpl.sol | 4 -- contracts/mocks/UUPS/UUPSLegacy.sol | 2 +- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 6 +-- contracts/proxy/beacon/UpgradeableBeacon.sol | 3 +- contracts/proxy/utils/Initializable.sol | 2 +- contracts/token/ERC1155/ERC1155.sol | 8 ++-- contracts/token/ERC721/ERC721.sol | 4 +- .../ERC721/extensions/ERC721Consecutive.sol | 4 +- contracts/token/ERC777/ERC777.sol | 2 +- contracts/utils/Address.sol | 38 +------------------ contracts/utils/StorageSlot.sol | 2 +- docs/modules/ROOT/pages/utilities.adoc | 2 - test/utils/Address.test.js | 11 ------ 13 files changed, 16 insertions(+), 72 deletions(-) diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index b06bec37284..27f954e0000 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -9,10 +9,6 @@ contract AddressImpl { event CallReturnValue(string data); - function isContract(address account) external view returns (bool) { - return Address.isContract(account); - } - function sendValue(address payable receiver, uint256 amount) external { Address.sendValue(receiver, amount); } diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index 7a3002889bf..29e089958a4 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -13,7 +13,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { // ERC1967Upgrade._setImplementation is private so we reproduce it here. // An extra underscore prevents a name clash error. function __setImplementation(address newImplementation) private { - require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); + require(newImplementation.code.length > 0, "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } diff --git a/contracts/proxy/ERC1967/ERC1967Upgrade.sol b/contracts/proxy/ERC1967/ERC1967Upgrade.sol index 38ea7ea1bf9..58f65fe881f 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -43,7 +43,7 @@ abstract contract ERC1967Upgrade { * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { - require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); + require(newImplementation.code.length > 0, "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } @@ -153,9 +153,9 @@ abstract contract ERC1967Upgrade { * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { - require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); + require(newBeacon.code.length > 0, "ERC1967: new beacon is not a contract"); require( - Address.isContract(IBeacon(newBeacon).implementation()), + IBeacon(newBeacon).implementation().code.length > 0, "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; diff --git a/contracts/proxy/beacon/UpgradeableBeacon.sol b/contracts/proxy/beacon/UpgradeableBeacon.sol index 5d83ceb3b4f..342db4a422a 100644 --- a/contracts/proxy/beacon/UpgradeableBeacon.sol +++ b/contracts/proxy/beacon/UpgradeableBeacon.sol @@ -5,7 +5,6 @@ pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../../access/Ownable.sol"; -import "../../utils/Address.sol"; /** * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their @@ -59,7 +58,7 @@ contract UpgradeableBeacon is IBeacon, Ownable { * - `newImplementation` must be a contract. */ function _setImplementation(address newImplementation) private { - require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract"); + require(newImplementation.code.length > 0, "UpgradeableBeacon: implementation is not a contract"); _implementation = newImplementation; } } diff --git a/contracts/proxy/utils/Initializable.sol b/contracts/proxy/utils/Initializable.sol index b454b5d95b7..c87e2a9008e 100644 --- a/contracts/proxy/utils/Initializable.sol +++ b/contracts/proxy/utils/Initializable.sol @@ -83,7 +83,7 @@ abstract contract Initializable { modifier initializer() { bool isTopLevelCall = !_initializing; require( - (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), + (isTopLevelCall && _initialized < 1) || (!(address(this).code.length > 0) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index e491a23100b..c3aba9a82f0 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -6,7 +6,6 @@ pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; -import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; @@ -18,8 +17,7 @@ import "../../utils/introspection/ERC165.sol"; * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { - using Address for address; - + // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; @@ -344,7 +342,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount, bytes memory data ) private { - if (to.isContract()) { + if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); @@ -365,7 +363,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory amounts, bytes memory data ) private { - if (to.isContract()) { + if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 6bf620b4f24..24afee63f05 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -6,7 +6,6 @@ pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; -import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; @@ -17,7 +16,6 @@ import "../../utils/introspection/ERC165.sol"; * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { - using Address for address; using Strings for uint256; // Token name @@ -402,7 +400,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { uint256 tokenId, bytes memory data ) private returns (bool) { - if (to.isContract()) { + if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index e6843f1fa12..91042642b6a 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -86,7 +86,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { // minting a batch of size 0 is a no-op if (batchSize > 0) { - require(!Address.isContract(address(this)), "ERC721Consecutive: batch minting restricted to constructor"); + require(!(address(this).code.length > 0), "ERC721Consecutive: batch minting restricted to constructor"); require(to != address(0), "ERC721Consecutive: mint to the zero address"); require(batchSize <= _maxBatchSize(), "ERC721Consecutive: batch too large"); @@ -112,7 +112,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { * After construction, {_mintConsecutive} is no longer available and {_mint} becomes available. */ function _mint(address to, uint256 tokenId) internal virtual override { - require(Address.isContract(address(this)), "ERC721Consecutive: can't mint during construction"); + require(address(this).code.length > 0, "ERC721Consecutive: can't mint during construction"); super._mint(to, tokenId); } diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index c1503c4dfc3..3803568d571 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -472,7 +472,7 @@ contract ERC777 is Context, IERC777, IERC20 { if (implementer != address(0)) { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); } else if (requireReceptionAck) { - require(!to.isContract(), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); + require(!(to.code.length > 0), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); } } diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 70d03e3d212..e08cdc75492 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -7,40 +7,6 @@ pragma solidity ^0.8.1; * @dev Collection of functions related to the address type */ library Address { - /** - * @dev Returns true if `account` is a contract. - * - * [IMPORTANT] - * ==== - * It is unsafe to assume that an address for which this function returns - * false is an externally-owned account (EOA) and not a contract. - * - * Among others, `isContract` will return false for the following - * types of addresses: - * - * - an externally-owned account - * - a contract in construction - * - an address where a contract will be created - * - an address where a contract lived, but was destroyed - * ==== - * - * [IMPORTANT] - * ==== - * You shouldn't rely on `isContract` to protect against flash loan attacks! - * - * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets - * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract - * constructor. - * ==== - */ - function isContract(address account) internal view returns (bool) { - // This method relies on extcodesize/address.code.length, which returns 0 - // for contracts in construction, since the code is only stored at the end - // of the constructor execution. - - return account.code.length > 0; - } - /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. @@ -196,9 +162,9 @@ library Address { ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { - // only check isContract if the call was successful and the return data is empty + // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract - require(isContract(target), "Address: call to non-contract"); + require(target.code.length > 0, "Address: call to non-contract"); } return returndata; } else { diff --git a/contracts/utils/StorageSlot.sol b/contracts/utils/StorageSlot.sol index 6ab8f5dc6bc..5941ee9d418 100644 --- a/contracts/utils/StorageSlot.sol +++ b/contracts/utils/StorageSlot.sol @@ -21,7 +21,7 @@ pragma solidity ^0.8.0; * } * * function _setImplementation(address newImplementation) internal { - * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); + * require(newImplementation.code.length > 0, "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } diff --git a/docs/modules/ROOT/pages/utilities.adoc b/docs/modules/ROOT/pages/utilities.adoc index 4231a6a746e..88207f0e109 100644 --- a/docs/modules/ROOT/pages/utilities.adoc +++ b/docs/modules/ROOT/pages/utilities.adoc @@ -99,8 +99,6 @@ If you need support for more powerful collections than Solidity's native arrays [[misc]] == Misc -Want to check if an address is a contract? Use xref:api:utils.adoc#Address[`Address`] and xref:api:utils.adoc#Address-isContract-address-[`Address.isContract()`]. - Want to keep track of some numbers that increment by 1 every time you want another one? Check out xref:api:utils.adoc#Counters[`Counters`]. This is useful for lots of things, like creating incremental identifiers, as shown on the xref:erc721.adoc[ERC721 guide]. === Base64 diff --git a/test/utils/Address.test.js b/test/utils/Address.test.js index 1bdfad48366..d6edac8863c 100644 --- a/test/utils/Address.test.js +++ b/test/utils/Address.test.js @@ -12,17 +12,6 @@ contract('Address', function (accounts) { this.mock = await AddressImpl.new(); }); - describe('isContract', function () { - it('returns false for account address', async function () { - expect(await this.mock.isContract(other)).to.equal(false); - }); - - it('returns true for contract address', async function () { - const contract = await AddressImpl.new(); - expect(await this.mock.isContract(contract.address)).to.equal(true); - }); - }); - describe('sendValue', function () { beforeEach(async function () { this.recipientTracker = await balance.tracker(recipient); From a87bd43012f9fb4cf1ba188923d9f60d02c225d7 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Wed, 11 Jan 2023 08:49:02 -0400 Subject: [PATCH 02/19] improve format --- .../polygon/CrossChainEnabledPolygonChild.sol | 2 +- contracts/finance/VestingWallet.sol | 6 +- contracts/governance/Governor.sol | 27 ++++--- contracts/governance/TimelockController.sol | 20 ++++- .../GovernorCompatibilityBravo.sol | 17 ++-- .../IGovernorCompatibilityBravo.sol | 8 +- .../extensions/GovernorCountingSimple.sol | 13 ++- .../extensions/GovernorSettings.sol | 6 +- .../extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/IVotes.sol | 9 ++- contracts/governance/utils/Votes.sol | 12 ++- contracts/interfaces/IERC1363.sol | 25 +++++- contracts/interfaces/IERC1363Spender.sol | 6 +- contracts/interfaces/IERC2981.sol | 8 +- contracts/interfaces/IERC4626.sol | 12 ++- contracts/metatx/MinimalForwarder.sol | 9 ++- contracts/mocks/AddressImpl.sol | 6 +- contracts/mocks/CheckpointsMock.sol | 30 ++++++- contracts/mocks/ClonesMock.sol | 6 +- contracts/mocks/ContextMock.sol | 6 +- contracts/mocks/Create2Impl.sol | 6 +- contracts/mocks/DummyImplementation.sol | 6 +- contracts/mocks/ECDSAMock.sol | 13 ++- contracts/mocks/EIP712External.sol | 7 +- contracts/mocks/ERC1155BurnableMock.sol | 7 +- contracts/mocks/ERC1155Mock.sol | 26 +++++- contracts/mocks/ERC1155ReceiverMock.sol | 7 +- contracts/mocks/ERC20CappedMock.sol | 6 +- contracts/mocks/ERC20DecimalsMock.sol | 6 +- contracts/mocks/ERC20Mock.sol | 12 ++- contracts/mocks/ERC3156FlashBorrowerMock.sol | 2 +- contracts/mocks/ERC4626Mock.sol | 32 +++++--- contracts/mocks/ERC721BurnableMock.sol | 6 +- .../mocks/ERC721ConsecutiveEnumerableMock.sol | 10 ++- contracts/mocks/ERC721EnumerableMock.sol | 6 +- contracts/mocks/ERC721Mock.sol | 6 +- contracts/mocks/ERC721PausableMock.sol | 6 +- contracts/mocks/ERC721RoyaltyMock.sol | 6 +- contracts/mocks/ERC721URIStorageMock.sol | 6 +- contracts/mocks/ERC777Mock.sol | 20 ++++- contracts/mocks/ERC777SenderRecipientMock.sol | 13 ++- .../mocks/GovernorCompatibilityBravoMock.sol | 27 ++++--- .../mocks/GovernorPreventLateQuorumMock.sol | 9 ++- .../mocks/GovernorTimelockCompoundMock.sol | 27 ++++--- .../mocks/GovernorTimelockControlMock.sol | 18 +++-- contracts/mocks/MathMock.sol | 7 +- contracts/mocks/MerkleProofWrapper.sol | 12 ++- .../MultipleInheritanceInitializableMocks.sol | 7 +- contracts/mocks/SafeERC20Helper.sol | 18 ++++- contracts/mocks/SafeMathMock.sol | 18 ++++- contracts/mocks/SignatureCheckerMock.sol | 6 +- contracts/mocks/UUPS/UUPSLegacy.sol | 6 +- contracts/mocks/crosschain/bridges.sol | 12 ++- contracts/mocks/wizard/MyGovernor1.sol | 28 ++++--- contracts/mocks/wizard/MyGovernor2.sol | 28 ++++--- contracts/mocks/wizard/MyGovernor3.sol | 37 ++++++--- contracts/proxy/Clones.sol | 9 ++- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 18 ++++- .../TransparentUpgradeableProxy.sol | 6 +- contracts/token/ERC1155/ERC1155.sol | 52 +++++++++--- contracts/token/ERC1155/IERC1155.sol | 16 ++-- .../ERC1155/extensions/ERC1155Burnable.sol | 12 ++- contracts/token/ERC20/ERC20.sol | 30 +++++-- contracts/token/ERC20/IERC20.sol | 6 +- .../token/ERC20/extensions/ERC20Capped.sol | 6 +- .../token/ERC20/extensions/ERC20Pausable.sol | 6 +- .../token/ERC20/extensions/ERC20Snapshot.sol | 6 +- .../token/ERC20/extensions/ERC20Votes.sol | 6 +- contracts/token/ERC20/extensions/ERC4626.sol | 19 ++++- contracts/token/ERC20/utils/SafeERC20.sol | 31 +++++-- contracts/token/ERC20/utils/TokenTimelock.sol | 6 +- contracts/token/ERC721/ERC721.sol | 53 +++++++++--- contracts/token/ERC721/IERC721.sol | 19 ++++- contracts/token/ERC721/utils/ERC721Holder.sol | 7 +- contracts/token/ERC777/ERC777.sol | 56 ++++++++++--- contracts/token/ERC777/IERC777.sol | 13 ++- contracts/token/common/ERC2981.sol | 6 +- contracts/utils/Address.sol | 6 +- contracts/utils/Checkpoints.sol | 80 ++++++++++++++----- contracts/utils/Create2.sol | 12 ++- contracts/utils/cryptography/ECDSA.sol | 26 +++++- contracts/utils/cryptography/MerkleProof.sol | 12 ++- .../utils/cryptography/SignatureChecker.sol | 6 +- .../utils/introspection/ERC165Checker.sol | 9 ++- .../introspection/ERC1820Implementer.sol | 11 ++- .../utils/introspection/IERC1820Registry.sol | 6 +- contracts/utils/math/Math.sol | 41 ++++++---- contracts/utils/math/SafeMath.sol | 18 ++++- contracts/utils/structs/BitMaps.sol | 6 +- contracts/utils/structs/EnumerableMap.sol | 36 +++++++-- contracts/vendor/amb/IAMB.sol | 14 +++- contracts/vendor/arbitrum/IArbSys.sol | 9 ++- contracts/vendor/arbitrum/IBridge.sol | 9 ++- contracts/vendor/arbitrum/IOutbox.sol | 6 +- .../vendor/optimism/ICrossDomainMessenger.sol | 6 +- .../vendor/polygon/IFxMessageProcessor.sol | 6 +- test/utils/math/Math.t.sol | 42 +++++++--- 97 files changed, 1115 insertions(+), 328 deletions(-) diff --git a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol index fa099483499..3918bfe25d8 100644 --- a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +++ b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol @@ -59,7 +59,7 @@ abstract contract CrossChainEnabledPolygonChild is IFxMessageProcessor, CrossCha * then security could be compromised. */ function processMessageFromRoot( - uint256 /* stateId */, + uint256, /* stateId */ address rootMessageSender, bytes calldata data ) external override nonReentrant { diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index fe67eb54ff6..0feac4ac6ab 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -29,7 +29,11 @@ contract VestingWallet is Context { /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. */ - constructor(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) payable { + constructor( + address beneficiaryAddress, + uint64 startTimestamp, + uint64 durationSeconds + ) payable { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 8235fb5ecb1..84b3128ff0c 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -314,7 +314,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Internal execution mechanism. Can be overridden to implement different execution mechanism */ function _execute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, uint256[] memory values, bytes[] memory calldatas, @@ -331,9 +331,9 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook before execution is triggered. */ function _beforeExecute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, - uint256[] memory /* values */, + uint256[] memory, /* values */ bytes[] memory calldatas, bytes32 /*descriptionHash*/ ) internal virtual { @@ -350,10 +350,10 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook after execution is triggered. */ function _afterExecute( - uint256 /* proposalId */, - address[] memory /* targets */, - uint256[] memory /* values */, - bytes[] memory /* calldatas */, + uint256, /* proposalId */ + address[] memory, /* targets */ + uint256[] memory, /* values */ + bytes[] memory, /* calldatas */ bytes32 /*descriptionHash*/ ) internal virtual { if (_executor() != address(this)) { @@ -540,7 +540,11 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. * Note that if the executor is simply the governor itself, use of `relay` is redundant. */ - function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance { + function relay( + address target, + uint256 value, + bytes calldata data + ) external payable virtual onlyGovernance { (bool success, bytes memory returndata) = target.call{value: value}(data); Address.verifyCallResult(success, returndata, "Governor: relay reverted without message"); } @@ -556,7 +560,12 @@ 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 override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 67e6d206c2d..43eedd23468 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -73,7 +73,12 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver * administration through timelocked proposals. Previous versions of this contract would assign * this admin to the deployer automatically and should be renounced as well. */ - constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) { + constructor( + uint256 minDelay, + address[] memory proposers, + address[] memory executors, + address admin + ) { // self administration _grantRole(DEFAULT_ADMIN_ROLE, address(this)); @@ -331,7 +336,11 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev Execute an operation's call. */ - function _execute(address target, uint256 value, bytes calldata data) internal virtual { + function _execute( + address target, + uint256 value, + bytes calldata data + ) internal virtual { (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); } @@ -371,7 +380,12 @@ 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 override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol index 8d74742c5bb..8d96be7d676 100644 --- a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol @@ -118,10 +118,11 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev Encodes calldatas with optional function signature. */ - function _encodeCalldata( - string[] memory signatures, - bytes[] memory calldatas - ) private pure returns (bytes[] memory) { + function _encodeCalldata(string[] memory signatures, bytes[] memory calldatas) + private + pure + returns (bytes[] memory) + { bytes[] memory fullcalldatas = new bytes[](calldatas.length); for (uint256 i = 0; i < signatures.length; ++i) { @@ -162,9 +163,7 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-proposals}. */ - function proposals( - uint256 proposalId - ) + function proposals(uint256 proposalId) public view virtual @@ -201,9 +200,7 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-getActions}. */ - function getActions( - uint256 proposalId - ) + function getActions(uint256 proposalId) public view virtual diff --git a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol index d1ec0337d00..83e4e1ae9c0 100644 --- a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol @@ -50,9 +50,7 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"The official record of all proposals ever proposed"_. */ - function proposals( - uint256 - ) + function proposals(uint256) public view virtual @@ -98,9 +96,7 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"Gets actions of a proposal"_. */ - function getActions( - uint256 proposalId - ) + function getActions(uint256 proposalId) public view virtual diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index f3eea9d7fa4..5611fc6692c 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -47,9 +47,16 @@ abstract contract GovernorCountingSimple is Governor { /** * @dev Accessor to the internal vote counts. */ - function proposalVotes( - uint256 proposalId - ) public view virtual returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) { + function proposalVotes(uint256 proposalId) + public + view + virtual + returns ( + uint256 againstVotes, + uint256 forVotes, + uint256 abstainVotes + ) + { ProposalVote storage proposalVote = _proposalVotes[proposalId]; return (proposalVote.againstVotes, proposalVote.forVotes, proposalVote.abstainVotes); } diff --git a/contracts/governance/extensions/GovernorSettings.sol b/contracts/governance/extensions/GovernorSettings.sol index 527f41cd8a8..a3187c6e16e 100644 --- a/contracts/governance/extensions/GovernorSettings.sol +++ b/contracts/governance/extensions/GovernorSettings.sol @@ -22,7 +22,11 @@ abstract contract GovernorSettings is Governor { /** * @dev Initialize the governance parameters. */ - constructor(uint256 initialVotingDelay, uint256 initialVotingPeriod, uint256 initialProposalThreshold) { + constructor( + uint256 initialVotingDelay, + uint256 initialVotingPeriod, + uint256 initialProposalThreshold + ) { _setVotingDelay(initialVotingDelay); _setVotingPeriod(initialVotingPeriod); _setProposalThreshold(initialProposalThreshold); diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index 6aa2556abf1..aaeaf940926 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -110,7 +110,7 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { * @dev Overridden execute function that run the already queued proposal through the timelock. */ function _execute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, uint256[] memory values, bytes[] memory calldatas, diff --git a/contracts/governance/utils/IVotes.sol b/contracts/governance/utils/IVotes.sol index 0bef3f92079..6317d7752e0 100644 --- a/contracts/governance/utils/IVotes.sol +++ b/contracts/governance/utils/IVotes.sol @@ -50,5 +50,12 @@ interface IVotes { /** * @dev Delegates votes from signer to `delegatee`. */ - function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; + function delegateBySig( + address delegatee, + uint256 nonce, + uint256 expiry, + uint8 v, + bytes32 r, + bytes32 s + ) external; } diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 492c1afb157..801be3bcd32 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -134,7 +134,11 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to` * should be zero. Total supply of voting units will be adjusted with mints and burns. */ - function _transferVotingUnits(address from, address to, uint256 amount) internal virtual { + function _transferVotingUnits( + address from, + address to, + uint256 amount + ) internal virtual { if (from == address(0)) { _totalCheckpoints.push(_add, amount); } @@ -147,7 +151,11 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { /** * @dev Moves delegated votes from one delegate to another. */ - function _moveDelegateVotes(address from, address to, uint256 amount) private { + function _moveDelegateVotes( + address from, + address to, + uint256 amount + ) private { if (from != to && amount > 0) { if (from != address(0)) { (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount); diff --git a/contracts/interfaces/IERC1363.sol b/contracts/interfaces/IERC1363.sol index 1a8dc79f438..5fad104c223 100644 --- a/contracts/interfaces/IERC1363.sol +++ b/contracts/interfaces/IERC1363.sol @@ -38,7 +38,11 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool); + function transferAndCall( + address to, + uint256 value, + bytes memory data + ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -47,7 +51,11 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ - function transferFromAndCall(address from, address to, uint256 value) external returns (bool); + function transferFromAndCall( + address from, + address to, + uint256 value + ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -57,7 +65,12 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool); + function transferFromAndCall( + address from, + address to, + uint256 value, + bytes memory data + ) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender @@ -74,5 +87,9 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ - function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool); + function approveAndCall( + address spender, + uint256 value, + bytes memory data + ) external returns (bool); } diff --git a/contracts/interfaces/IERC1363Spender.sol b/contracts/interfaces/IERC1363Spender.sol index 28775e1406b..48f6fd56d6d 100644 --- a/contracts/interfaces/IERC1363Spender.sol +++ b/contracts/interfaces/IERC1363Spender.sol @@ -22,5 +22,9 @@ interface IERC1363Spender { * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ - function onApprovalReceived(address owner, uint256 value, bytes memory data) external returns (bytes4); + function onApprovalReceived( + address owner, + uint256 value, + bytes memory data + ) external returns (bytes4); } diff --git a/contracts/interfaces/IERC2981.sol b/contracts/interfaces/IERC2981.sol index 1c9448a9147..6b0558169ea 100644 --- a/contracts/interfaces/IERC2981.sol +++ b/contracts/interfaces/IERC2981.sol @@ -18,8 +18,8 @@ interface IERC2981 is IERC165 { * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ - function royaltyInfo( - uint256 tokenId, - uint256 salePrice - ) external view returns (address receiver, uint256 royaltyAmount); + function royaltyInfo(uint256 tokenId, uint256 salePrice) + external + view + returns (address receiver, uint256 royaltyAmount); } diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index 08e5de7176b..f7c5397a0fa 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -187,7 +187,11 @@ interface IERC4626 is IERC20, IERC20Metadata { * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); + function withdraw( + uint256 assets, + address receiver, + address owner + ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, @@ -228,5 +232,9 @@ interface IERC4626 is IERC20, IERC20Metadata { * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); + function redeem( + uint256 shares, + address receiver, + address owner + ) external returns (uint256 assets); } diff --git a/contracts/metatx/MinimalForwarder.sol b/contracts/metatx/MinimalForwarder.sol index 9298ae6751c..bb49c794dbb 100644 --- a/contracts/metatx/MinimalForwarder.sol +++ b/contracts/metatx/MinimalForwarder.sol @@ -44,10 +44,11 @@ contract MinimalForwarder is EIP712 { return _nonces[req.from] == req.nonce && signer == req.from; } - function execute( - ForwardRequest calldata req, - bytes calldata signature - ) public payable returns (bool, bytes memory) { + function execute(ForwardRequest calldata req, bytes calldata signature) + public + payable + returns (bool, bytes memory) + { require(verify(req, signature), "MinimalForwarder: signature does not match request"); _nonces[req.from] = req.nonce + 1; diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index 27f954e0000..8dc7886c1fd 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -18,7 +18,11 @@ contract AddressImpl { emit CallReturnValue(abi.decode(returnData, (string))); } - function functionCallWithValue(address target, bytes calldata data, uint256 value) external payable { + function functionCallWithValue( + address target, + bytes calldata data, + uint256 value + ) external payable { bytes memory returnData = Address.functionCallWithValue(target, data, value); emit CallReturnValue(abi.decode(returnData, (string))); } diff --git a/contracts/mocks/CheckpointsMock.sol b/contracts/mocks/CheckpointsMock.sol index 874a1d1f213..f1dadabaf7d 100644 --- a/contracts/mocks/CheckpointsMock.sol +++ b/contracts/mocks/CheckpointsMock.sol @@ -14,7 +14,15 @@ contract CheckpointsMock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint256, uint256) { + function latestCheckpoint() + public + view + returns ( + bool, + uint256, + uint256 + ) + { return _totalCheckpoints.latestCheckpoint(); } @@ -44,7 +52,15 @@ contract Checkpoints224Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint32, uint224) { + function latestCheckpoint() + public + view + returns ( + bool, + uint32, + uint224 + ) + { return _totalCheckpoints.latestCheckpoint(); } @@ -74,7 +90,15 @@ contract Checkpoints160Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint96, uint160) { + function latestCheckpoint() + public + view + returns ( + bool, + uint96, + uint160 + ) + { return _totalCheckpoints.latestCheckpoint(); } diff --git a/contracts/mocks/ClonesMock.sol b/contracts/mocks/ClonesMock.sol index c65d30cc3b0..3719b0a7835 100644 --- a/contracts/mocks/ClonesMock.sol +++ b/contracts/mocks/ClonesMock.sol @@ -15,7 +15,11 @@ contract ClonesMock { _initAndEmit(implementation.clone(), initdata); } - function cloneDeterministic(address implementation, bytes32 salt, bytes calldata initdata) public payable { + function cloneDeterministic( + address implementation, + bytes32 salt, + bytes calldata initdata + ) public payable { _initAndEmit(implementation.cloneDeterministic(salt), initdata); } diff --git a/contracts/mocks/ContextMock.sol b/contracts/mocks/ContextMock.sol index 7759f350639..f17af38a49a 100644 --- a/contracts/mocks/ContextMock.sol +++ b/contracts/mocks/ContextMock.sol @@ -23,7 +23,11 @@ contract ContextMockCaller { context.msgSender(); } - function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { + function callData( + ContextMock context, + uint256 integerValue, + string memory stringValue + ) public { context.msgData(integerValue, stringValue); } } diff --git a/contracts/mocks/Create2Impl.sol b/contracts/mocks/Create2Impl.sol index 6b2f4b712e5..070ad3671c5 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -6,7 +6,11 @@ import "../utils/Create2.sol"; import "../utils/introspection/ERC1820Implementer.sol"; contract Create2Impl { - function deploy(uint256 value, bytes32 salt, bytes memory code) public { + function deploy( + uint256 value, + bytes32 salt, + bytes memory code + ) public { Create2.deploy(value, salt, code); } diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index ddcca660439..d8651340d1b 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -27,7 +27,11 @@ contract DummyImplementation { value = _value; } - function initialize(uint256 _value, string memory _text, uint256[] memory _values) public { + function initialize( + uint256 _value, + string memory _text, + uint256[] memory _values + ) public { value = _value; text = _text; values = _values; diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index cfc37d26ea6..97bd46669a6 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -13,12 +13,21 @@ contract ECDSAMock { } // solhint-disable-next-line func-name-mixedcase - function recover_v_r_s(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { + function recover_v_r_s( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) public pure returns (address) { return hash.recover(v, r, s); } // solhint-disable-next-line func-name-mixedcase - function recover_r_vs(bytes32 hash, bytes32 r, bytes32 vs) public pure returns (address) { + function recover_r_vs( + bytes32 hash, + bytes32 r, + bytes32 vs + ) public pure returns (address) { return hash.recover(r, vs); } diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index bc5b1269f7c..93f77d54946 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -12,7 +12,12 @@ contract EIP712External is EIP712 { return _domainSeparatorV4(); } - function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view { + function verify( + bytes memory signature, + address signer, + address mailTo, + string memory mailContents + ) external view { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) ); diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 3334523cf74..62138f28da6 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -7,7 +7,12 @@ import "../token/ERC1155/extensions/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { constructor(string memory uri) ERC1155(uri) {} - function mint(address to, uint256 id, uint256 value, bytes memory data) public { + function mint( + address to, + uint256 id, + uint256 value, + bytes memory data + ) public { _mint(to, id, value, data); } } diff --git a/contracts/mocks/ERC1155Mock.sol b/contracts/mocks/ERC1155Mock.sol index 6bfc86ceaf3..0518ac26c17 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -15,19 +15,37 @@ contract ERC1155Mock is ERC1155 { _setURI(newuri); } - function mint(address to, uint256 id, uint256 value, bytes memory data) public { + function mint( + address to, + uint256 id, + uint256 value, + bytes memory data + ) public { _mint(to, id, value, data); } - function mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) public { + function mintBatch( + address to, + uint256[] memory ids, + uint256[] memory values, + bytes memory data + ) public { _mintBatch(to, ids, values, data); } - function burn(address owner, uint256 id, uint256 value) public { + function burn( + address owner, + uint256 id, + uint256 value + ) public { _burn(owner, id, value); } - function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public { + function burnBatch( + address owner, + uint256[] memory ids, + uint256[] memory values + ) public { _burnBatch(owner, ids, values); } } diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index b2d505c0a86..6443a56c7ae 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -14,7 +14,12 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver { event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas); event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas); - constructor(bytes4 recRetval, bool recReverts, bytes4 batRetval, bool batReverts) { + constructor( + bytes4 recRetval, + bool recReverts, + bytes4 batRetval, + bool batReverts + ) { _recRetval = recRetval; _recReverts = recReverts; _batRetval = batRetval; diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index e69aadfdf30..edb36f20531 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -5,7 +5,11 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Capped.sol"; contract ERC20CappedMock is ERC20Capped { - constructor(string memory name, string memory symbol, uint256 cap) ERC20(name, symbol) ERC20Capped(cap) {} + constructor( + string memory name, + string memory symbol, + uint256 cap + ) ERC20(name, symbol) ERC20Capped(cap) {} function mint(address to, uint256 tokenId) public { _mint(to, tokenId); diff --git a/contracts/mocks/ERC20DecimalsMock.sol b/contracts/mocks/ERC20DecimalsMock.sol index 7677e9dd1d1..3721f6c393b 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -7,7 +7,11 @@ import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { uint8 private immutable _decimals; - constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) { + constructor( + string memory name_, + string memory symbol_, + uint8 decimals_ + ) ERC20(name_, symbol_) { _decimals = decimals_; } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index 16ffad19fe5..fd7f991baf0 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -23,11 +23,19 @@ contract ERC20Mock is ERC20 { _burn(account, amount); } - function transferInternal(address from, address to, uint256 value) public { + function transferInternal( + address from, + address to, + uint256 value + ) public { _transfer(from, to, value); } - function approveInternal(address owner, address spender, uint256 value) public { + function approveInternal( + address owner, + address spender, + uint256 value + ) public { _approve(owner, spender, value); } } diff --git a/contracts/mocks/ERC3156FlashBorrowerMock.sol b/contracts/mocks/ERC3156FlashBorrowerMock.sol index 6a4410fcb1d..288a278fb80 100644 --- a/contracts/mocks/ERC3156FlashBorrowerMock.sol +++ b/contracts/mocks/ERC3156FlashBorrowerMock.sol @@ -28,7 +28,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { } function onFlashLoan( - address /*initiator*/, + address, /*initiator*/ address token, uint256 amount, uint256 fee, diff --git a/contracts/mocks/ERC4626Mock.sol b/contracts/mocks/ERC4626Mock.sol index 9c13346f059..4f80b4bd75b 100644 --- a/contracts/mocks/ERC4626Mock.sol +++ b/contracts/mocks/ERC4626Mock.sol @@ -5,7 +5,11 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC4626.sol"; contract ERC4626Mock is ERC4626 { - constructor(IERC20Metadata asset, string memory name, string memory symbol) ERC20(name, symbol) ERC4626(asset) {} + constructor( + IERC20Metadata asset, + string memory name, + string memory symbol + ) ERC20(name, symbol) ERC4626(asset) {} function mockMint(address account, uint256 amount) public { _mint(account, amount); @@ -34,17 +38,23 @@ contract ERC4626DecimalMock is ERC4626Mock { return _decimals; } - function _initialConvertToShares( - uint256 assets, - Math.Rounding rounding - ) internal view virtual override returns (uint256 shares) { - return assets.mulDiv(10 ** decimals(), 10 ** super.decimals(), rounding); + function _initialConvertToShares(uint256 assets, Math.Rounding rounding) + internal + view + virtual + override + returns (uint256 shares) + { + return assets.mulDiv(10**decimals(), 10**super.decimals(), rounding); } - function _initialConvertToAssets( - uint256 shares, - Math.Rounding rounding - ) internal view virtual override returns (uint256 assets) { - return shares.mulDiv(10 ** super.decimals(), 10 ** decimals(), rounding); + function _initialConvertToAssets(uint256 shares, Math.Rounding rounding) + internal + view + virtual + override + returns (uint256 assets) + { + return shares.mulDiv(10**super.decimals(), 10**decimals(), rounding); } } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index ecf42768182..b30dbf53dfb 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -19,7 +19,11 @@ contract ERC721BurnableMock is ERC721Burnable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } } diff --git a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol index f4f5c5832be..cde3bd86cff 100644 --- a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol +++ b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol @@ -17,9 +17,13 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable } } - function supportsInterface( - bytes4 interfaceId - ) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + virtual + override(ERC721, ERC721Enumerable) + returns (bool) + { return super.supportsInterface(interfaceId); } diff --git a/contracts/mocks/ERC721EnumerableMock.sol b/contracts/mocks/ERC721EnumerableMock.sol index b7ea94ee3f2..a747925e69d 100644 --- a/contracts/mocks/ERC721EnumerableMock.sol +++ b/contracts/mocks/ERC721EnumerableMock.sol @@ -37,7 +37,11 @@ contract ERC721EnumerableMock is ERC721Enumerable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index a3bc839ae7b..74a09233469 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -27,7 +27,11 @@ contract ERC721Mock is ERC721 { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 753842e902b..8d8e818fb17 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -31,7 +31,11 @@ contract ERC721PausableMock is ERC721Pausable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721RoyaltyMock.sol b/contracts/mocks/ERC721RoyaltyMock.sol index 6f19d5248d2..83a9074e2c1 100644 --- a/contracts/mocks/ERC721RoyaltyMock.sol +++ b/contracts/mocks/ERC721RoyaltyMock.sol @@ -7,7 +7,11 @@ import "../token/ERC721/extensions/ERC721Royalty.sol"; contract ERC721RoyaltyMock is ERC721Royalty { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} - function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) public { + function setTokenRoyalty( + uint256 tokenId, + address recipient, + uint96 fraction + ) public { _setTokenRoyalty(tokenId, recipient, fraction); } diff --git a/contracts/mocks/ERC721URIStorageMock.sol b/contracts/mocks/ERC721URIStorageMock.sol index 4bb26b1ada7..60f9f7b7c1a 100644 --- a/contracts/mocks/ERC721URIStorageMock.sol +++ b/contracts/mocks/ERC721URIStorageMock.sol @@ -41,7 +41,11 @@ contract ERC721URIStorageMock is ERC721URIStorage { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC777Mock.sol b/contracts/mocks/ERC777Mock.sol index 59c00b30756..f8a3b67849d 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -18,7 +18,12 @@ contract ERC777Mock is Context, ERC777 { _mint(initialHolder, initialBalance, "", ""); } - function mintInternal(address to, uint256 amount, bytes memory userData, bytes memory operatorData) public { + function mintInternal( + address to, + uint256 amount, + bytes memory userData, + bytes memory operatorData + ) public { _mint(to, amount, userData, operatorData); } @@ -32,11 +37,20 @@ contract ERC777Mock is Context, ERC777 { _mint(to, amount, userData, operatorData, requireReceptionAck); } - function approveInternal(address holder, address spender, uint256 value) public { + function approveInternal( + address holder, + address spender, + uint256 value + ) public { _approve(holder, spender, value); } - function _beforeTokenTransfer(address, address, address, uint256) internal override { + function _beforeTokenTransfer( + address, + address, + address, + uint256 + ) internal override { emit BeforeTokenTransfer(); } } diff --git a/contracts/mocks/ERC777SenderRecipientMock.sol b/contracts/mocks/ERC777SenderRecipientMock.sol index 8e8c749ceda..169912f699b 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -141,12 +141,21 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, _shouldRevertReceive = shouldRevert; } - function send(IERC777 token, address to, uint256 amount, bytes memory data) public { + function send( + IERC777 token, + address to, + uint256 amount, + bytes memory data + ) public { // This is 777's send function, not the Solidity send function token.send(to, amount, data); // solhint-disable-line check-send-result } - function burn(IERC777 token, uint256 amount, bytes memory data) public { + function burn( + IERC777 token, + uint256 amount, + bytes memory data + ) public { token.burn(amount, data); } } diff --git a/contracts/mocks/GovernorCompatibilityBravoMock.sol b/contracts/mocks/GovernorCompatibilityBravoMock.sol index d3b4f707d16..1ef0f94b92e 100644 --- a/contracts/mocks/GovernorCompatibilityBravoMock.sol +++ b/contracts/mocks/GovernorCompatibilityBravoMock.sol @@ -27,9 +27,12 @@ contract GovernorCompatibilityBravoMock is GovernorVotesComp(token_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(IERC165, Governor, GovernorTimelockCompound) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(IERC165, Governor, GovernorTimelockCompound) + returns (bool) + { return super.supportsInterface(interfaceId); } @@ -37,15 +40,21 @@ contract GovernorCompatibilityBravoMock is return 0; } - function state( - uint256 proposalId - ) public view override(IGovernor, Governor, GovernorTimelockCompound) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(IGovernor, Governor, GovernorTimelockCompound) + returns (ProposalState) + { return super.state(proposalId); } - function proposalEta( - uint256 proposalId - ) public view override(IGovernorTimelock, GovernorTimelockCompound) returns (uint256) { + function proposalEta(uint256 proposalId) + public + view + override(IGovernorTimelock, GovernorTimelockCompound) + returns (uint256) + { return super.proposalEta(proposalId); } diff --git a/contracts/mocks/GovernorPreventLateQuorumMock.sol b/contracts/mocks/GovernorPreventLateQuorumMock.sol index b6b5e761970..d868ab22b62 100644 --- a/contracts/mocks/GovernorPreventLateQuorumMock.sol +++ b/contracts/mocks/GovernorPreventLateQuorumMock.sol @@ -35,9 +35,12 @@ contract GovernorPreventLateQuorumMock is return _quorum; } - function proposalDeadline( - uint256 proposalId - ) public view override(Governor, GovernorPreventLateQuorum) returns (uint256) { + function proposalDeadline(uint256 proposalId) + public + view + override(Governor, GovernorPreventLateQuorum) + returns (uint256) + { return super.proposalDeadline(proposalId); } diff --git a/contracts/mocks/GovernorTimelockCompoundMock.sol b/contracts/mocks/GovernorTimelockCompoundMock.sol index 75a2f3c144c..becc72a06ef 100644 --- a/contracts/mocks/GovernorTimelockCompoundMock.sol +++ b/contracts/mocks/GovernorTimelockCompoundMock.sol @@ -28,15 +28,21 @@ contract GovernorTimelockCompoundMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockCompound) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockCompound) + returns (bool) + { return super.supportsInterface(interfaceId); } - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -52,9 +58,12 @@ contract GovernorTimelockCompoundMock is /** * Overriding nightmare */ - function state( - uint256 proposalId - ) public view override(Governor, GovernorTimelockCompound) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(Governor, GovernorTimelockCompound) + returns (ProposalState) + { return super.state(proposalId); } diff --git a/contracts/mocks/GovernorTimelockControlMock.sol b/contracts/mocks/GovernorTimelockControlMock.sol index 671a1e0ea03..ca412d1ca60 100644 --- a/contracts/mocks/GovernorTimelockControlMock.sol +++ b/contracts/mocks/GovernorTimelockControlMock.sol @@ -28,15 +28,21 @@ contract GovernorTimelockControlMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index be935f91dee..c6b1e872318 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -21,7 +21,12 @@ contract MathMock { return Math.ceilDiv(a, b); } - function mulDiv(uint256 a, uint256 b, uint256 denominator, Math.Rounding direction) public pure returns (uint256) { + function mulDiv( + uint256 a, + uint256 b, + uint256 denominator, + Math.Rounding direction + ) public pure returns (uint256) { return Math.mulDiv(a, b, denominator, direction); } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index 60741e41c03..b74459dc890 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,11 +5,19 @@ pragma solidity ^0.8.0; import "../utils/cryptography/MerkleProof.sol"; contract MerkleProofWrapper { - function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) { + function verify( + bytes32[] memory proof, + bytes32 root, + bytes32 leaf + ) public pure returns (bool) { return MerkleProof.verify(proof, root, leaf); } - function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) public pure returns (bool) { + function verifyCalldata( + bytes32[] calldata proof, + bytes32 root, + bytes32 leaf + ) public pure returns (bool) { return MerkleProof.verifyCalldata(proof, root, leaf); } diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index b8cf9d9d5d3..f6d6440654f 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -108,7 +108,12 @@ contract SampleFather is Initializable, SampleGramps { contract SampleChild is Initializable, SampleMother, SampleFather { uint256 public child; - function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer { + function initialize( + uint256 _mother, + string memory _gramps, + uint256 _father, + uint256 _child + ) public initializer { __SampleChild_init(_mother, _gramps, _father, _child); } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 237e32041c4..98fdc644490 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -19,7 +19,11 @@ contract ERC20ReturnFalseMock is Context { return false; } - function transferFrom(address, address, uint256) public returns (bool) { + function transferFrom( + address, + address, + uint256 + ) public returns (bool) { _dummy = 0; return false; } @@ -47,7 +51,11 @@ contract ERC20ReturnTrueMock is Context { return true; } - function transferFrom(address, address, uint256) public returns (bool) { + function transferFrom( + address, + address, + uint256 + ) public returns (bool) { _dummy = 0; return true; } @@ -77,7 +85,11 @@ contract ERC20NoReturnMock is Context { _dummy = 0; } - function transferFrom(address, address, uint256) public { + function transferFrom( + address, + address, + uint256 + ) public { _dummy = 0; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index ef504e3ab90..3d1f4727ee5 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -47,15 +47,27 @@ contract SafeMathMock { return SafeMath.mod(a, b); } - function subWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function subWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.sub(a, b, errorMessage); } - function divWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function divWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.div(a, b, errorMessage); } - function modWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function modWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.mod(a, b, errorMessage); } diff --git a/contracts/mocks/SignatureCheckerMock.sol b/contracts/mocks/SignatureCheckerMock.sol index 5671540ec4a..3b399c1aeaa 100644 --- a/contracts/mocks/SignatureCheckerMock.sol +++ b/contracts/mocks/SignatureCheckerMock.sol @@ -7,7 +7,11 @@ import "../utils/cryptography/SignatureChecker.sol"; contract SignatureCheckerMock { using SignatureChecker for address; - function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) public view returns (bool) { + function isValidSignatureNow( + address signer, + bytes32 hash, + bytes memory signature + ) public view returns (bool) { return signer.isValidSignatureNow(hash, signature); } } diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index 29e089958a4..2c70a390663 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -17,7 +17,11 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } - function _upgradeToAndCallSecureLegacyV1(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCallSecureLegacyV1( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call diff --git a/contracts/mocks/crosschain/bridges.sol b/contracts/mocks/crosschain/bridges.sol index 41baffed805..35c7f4c0625 100644 --- a/contracts/mocks/crosschain/bridges.sol +++ b/contracts/mocks/crosschain/bridges.sol @@ -12,7 +12,11 @@ abstract contract BaseRelayMock { address internal _currentSender; - function relayAs(address target, bytes calldata data, address sender) external virtual { + function relayAs( + address target, + bytes calldata data, + address sender + ) external virtual { address previousSender = _currentSender; _currentSender = sender; @@ -88,7 +92,11 @@ contract BridgeOptimismMock is BaseRelayMock { * Polygon */ contract BridgePolygonChildMock is BaseRelayMock { - function relayAs(address target, bytes calldata data, address sender) external override { + function relayAs( + address target, + bytes calldata data, + address sender + ) external override { IFxMessageProcessor(target).processMessageFromRoot(0, sender, data); } } diff --git a/contracts/mocks/wizard/MyGovernor1.sol b/contracts/mocks/wizard/MyGovernor1.sol index 37ecfd57d8b..a80d8400c5e 100644 --- a/contracts/mocks/wizard/MyGovernor1.sol +++ b/contracts/mocks/wizard/MyGovernor1.sol @@ -14,10 +14,12 @@ contract MyGovernor1 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -29,9 +31,12 @@ contract MyGovernor1 is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -71,9 +76,12 @@ contract MyGovernor1 is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor2.sol b/contracts/mocks/wizard/MyGovernor2.sol index 1472b67d588..34c608c5cc2 100644 --- a/contracts/mocks/wizard/MyGovernor2.sol +++ b/contracts/mocks/wizard/MyGovernor2.sol @@ -16,10 +16,12 @@ contract MyGovernor2 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -35,9 +37,12 @@ contract MyGovernor2 is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -77,9 +82,12 @@ contract MyGovernor2 is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor3.sol b/contracts/mocks/wizard/MyGovernor3.sol index 320342290a5..70e4e87f046 100644 --- a/contracts/mocks/wizard/MyGovernor3.sol +++ b/contracts/mocks/wizard/MyGovernor3.sol @@ -14,10 +14,12 @@ contract MyGovernor is GovernorVotes, GovernorVotesQuorumFraction { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -33,15 +35,21 @@ contract MyGovernor is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } - function state( - uint256 proposalId - ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(Governor, IGovernor, GovernorTimelockControl) + returns (ProposalState) + { return super.state(proposalId); } @@ -77,9 +85,12 @@ contract MyGovernor is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, IERC165, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/proxy/Clones.sol b/contracts/proxy/Clones.sol index 712519892ef..93ea0cec77e 100644 --- a/contracts/proxy/Clones.sol +++ b/contracts/proxy/Clones.sol @@ -79,10 +79,11 @@ library Clones { /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ - function predictDeterministicAddress( - address implementation, - bytes32 salt - ) internal view returns (address predicted) { + function predictDeterministicAddress(address implementation, bytes32 salt) + internal + view + returns (address predicted) + { return predictDeterministicAddress(implementation, salt, address(this)); } } diff --git a/contracts/proxy/ERC1967/ERC1967Upgrade.sol b/contracts/proxy/ERC1967/ERC1967Upgrade.sol index 58f65fe881f..31309f63e44 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -62,7 +62,11 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCall( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); @@ -74,7 +78,11 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCallUUPS( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. @@ -167,7 +175,11 @@ abstract contract ERC1967Upgrade { * * Emits a {BeaconUpgraded} event. */ - function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { + function _upgradeBeaconToAndCall( + address newBeacon, + bytes memory data, + bool forceCall + ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index ffc97ff4855..57417296d6e 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -31,7 +31,11 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ - constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { + constructor( + address _logic, + address admin_, + bytes memory _data + ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index c3aba9a82f0..d7a3e2c0899 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -17,7 +17,6 @@ import "../../utils/introspection/ERC165.sol"; * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { - // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; @@ -77,10 +76,13 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch( - address[] memory accounts, - uint256[] memory ids - ) public view virtual override returns (uint256[] memory) { + function balanceOfBatch(address[] memory accounts, uint256[] memory ids) + public + view + virtual + override + returns (uint256[] memory) + { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); @@ -205,7 +207,13 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) internal { + function _safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal { require(to != address(0), "ERC1155: transfer to the zero address"); require(from != address(0), "ERC1155: transfer from the zero address"); uint256[] memory ids = _asSingletonArray(id); @@ -269,7 +277,12 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal { + function _mint( + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal { require(to != address(0), "ERC1155: mint to the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -287,7 +300,12 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal { + function _mintBatch( + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal { require(to != address(0), "ERC1155: mint to the zero address"); _update(address(0), to, ids, amounts, data); } @@ -302,7 +320,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ - function _burn(address from, uint256 id, uint256 amount) internal { + function _burn( + address from, + uint256 id, + uint256 amount + ) internal { require(from != address(0), "ERC1155: burn from the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -318,7 +340,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `ids` and `amounts` must have the same length. */ - function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal { + function _burnBatch( + address from, + uint256[] memory ids, + uint256[] memory amounts + ) internal { require(from != address(0), "ERC1155: burn from the zero address"); _update(from, address(0), ids, amounts, ""); } @@ -328,7 +354,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { + function _setApprovalForAll( + address owner, + address operator, + bool approved + ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index eae0b7029f6..05f74dc4f32 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -60,10 +60,10 @@ interface IERC1155 is IERC165 { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch( - address[] calldata accounts, - uint256[] calldata ids - ) external view returns (uint256[] memory); + function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) + external + view + returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, @@ -96,7 +96,13 @@ interface IERC1155 is IERC165 { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; + function safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes calldata data + ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index cc81957a7fe..cfaa2359dbd 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -12,7 +12,11 @@ import "../ERC1155.sol"; * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { - function burn(address account, uint256 id, uint256 value) public virtual { + function burn( + address account, + uint256 id, + uint256 value + ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" @@ -21,7 +25,11 @@ abstract contract ERC1155Burnable is ERC1155 { _burn(account, id, value); } - function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { + function burnBatch( + address account, + uint256[] memory ids, + uint256[] memory values + ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index f9be8b68965..261a46f2253 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -154,7 +154,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ - function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { + function transferFrom( + address from, + address to, + uint256 amount + ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); @@ -214,7 +218,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * NOTE: This function is not virtual, {_update} should be overridden instead. */ - function _transfer(address from, address to, uint256 amount) internal { + function _transfer( + address from, + address to, + uint256 amount + ) internal { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _update(from, to, amount); @@ -226,7 +234,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Emits a {Transfer} event. */ - function _update(address from, address to, uint256 amount) internal virtual { + function _update( + address from, + address to, + uint256 amount + ) internal virtual { if (from == address(0)) { _totalSupply += amount; unchecked { @@ -294,7 +306,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ - function _approve(address owner, address spender, uint256 amount) internal virtual { + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); @@ -310,7 +326,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Might emit an {Approval} event. */ - function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { + function _spendAllowance( + address owner, + address spender, + uint256 amount + ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 66c4e4d88fe..b816bfed086 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -74,5 +74,9 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom(address from, address to, uint256 amount) external returns (bool); + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); } diff --git a/contracts/token/ERC20/extensions/ERC20Capped.sol b/contracts/token/ERC20/extensions/ERC20Capped.sol index d80fb2a4ccd..3be9ff805d7 100644 --- a/contracts/token/ERC20/extensions/ERC20Capped.sol +++ b/contracts/token/ERC20/extensions/ERC20Capped.sol @@ -30,7 +30,11 @@ abstract contract ERC20Capped is ERC20 { /** * @dev See {ERC20-_transfer}. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { if (from == address(0)) { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); } diff --git a/contracts/token/ERC20/extensions/ERC20Pausable.sol b/contracts/token/ERC20/extensions/ERC20Pausable.sol index 85dd164d37b..92d764932a9 100644 --- a/contracts/token/ERC20/extensions/ERC20Pausable.sol +++ b/contracts/token/ERC20/extensions/ERC20Pausable.sol @@ -21,7 +21,11 @@ abstract contract ERC20Pausable is ERC20, Pausable { * * - the contract must not be paused. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { require(!paused(), "ERC20Pausable: token transfer while paused"); super._update(from, to, amount); } diff --git a/contracts/token/ERC20/extensions/ERC20Snapshot.sol b/contracts/token/ERC20/extensions/ERC20Snapshot.sol index 3bc1a74eecc..2c34e226809 100644 --- a/contracts/token/ERC20/extensions/ERC20Snapshot.sol +++ b/contracts/token/ERC20/extensions/ERC20Snapshot.sol @@ -120,7 +120,11 @@ abstract contract ERC20Snapshot is ERC20 { // Update balance and/or total supply snapshots before the values are modified. This is executed // for _mint, _burn, and _transfer operations. - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { if (from == address(0)) { // mint _updateAccountSnapshot(to); diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 225d08c443e..7f9f36b7603 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -35,7 +35,11 @@ abstract contract ERC20Votes is ERC20, Votes { * * Emits a {IVotes-DelegateVotesChanged} event. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { super._update(from, to, amount); if (from == address(0)) { require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); diff --git a/contracts/token/ERC20/extensions/ERC4626.sol b/contracts/token/ERC20/extensions/ERC4626.sol index 9b26aefebed..3ffcd7bfd5a 100644 --- a/contracts/token/ERC20/extensions/ERC4626.sol +++ b/contracts/token/ERC20/extensions/ERC4626.sol @@ -153,7 +153,11 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-withdraw}. */ - function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) { + function withdraw( + uint256 assets, + address receiver, + address owner + ) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); @@ -163,7 +167,11 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-redeem}. */ - function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) { + function redeem( + uint256 shares, + address receiver, + address owner + ) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); @@ -222,7 +230,12 @@ abstract contract ERC4626 is ERC20, IERC4626 { /** * @dev Deposit/mint common workflow. */ - function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { + function _deposit( + address caller, + address receiver, + uint256 assets, + uint256 shares + ) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. diff --git a/contracts/token/ERC20/utils/SafeERC20.sol b/contracts/token/ERC20/utils/SafeERC20.sol index 028711ddf29..bfc381f9b4a 100644 --- a/contracts/token/ERC20/utils/SafeERC20.sol +++ b/contracts/token/ERC20/utils/SafeERC20.sol @@ -19,11 +19,20 @@ import "../../../utils/Address.sol"; library SafeERC20 { using Address for address; - function safeTransfer(IERC20 token, address to, uint256 value) internal { + function safeTransfer( + IERC20 token, + address to, + uint256 value + ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } - function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { + function safeTransferFrom( + IERC20 token, + address from, + address to, + uint256 value + ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } @@ -34,7 +43,11 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove(IERC20 token, address spender, uint256 value) internal { + function safeApprove( + IERC20 token, + address spender, + uint256 value + ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' @@ -45,12 +58,20 @@ library SafeERC20 { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } - function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { + function safeIncreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } - function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { + function safeDecreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); diff --git a/contracts/token/ERC20/utils/TokenTimelock.sol b/contracts/token/ERC20/utils/TokenTimelock.sol index ed855b7bcb4..d879a7e7d72 100644 --- a/contracts/token/ERC20/utils/TokenTimelock.sol +++ b/contracts/token/ERC20/utils/TokenTimelock.sol @@ -29,7 +29,11 @@ contract TokenTimelock { * `beneficiary_` when {release} is invoked after `releaseTime_`. The release time is specified as a Unix timestamp * (in seconds). */ - constructor(IERC20 token_, address beneficiary_, uint256 releaseTime_) { + constructor( + IERC20 token_, + address beneficiary_, + uint256 releaseTime_ + ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 24afee63f05..75cc2a22bed 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -145,7 +145,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-transferFrom}. */ - function transferFrom(address from, address to, uint256 tokenId) public virtual override { + function transferFrom( + address from, + address to, + uint256 tokenId + ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); @@ -155,14 +159,23 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes memory data + ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } @@ -185,7 +198,12 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { + function _safeTransfer( + address from, + address to, + uint256 tokenId, + bytes memory data + ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } @@ -239,7 +257,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ - function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { + function _safeMint( + address to, + uint256 tokenId, + bytes memory data + ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), @@ -328,7 +350,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _transfer(address from, address to, uint256 tokenId) internal virtual { + function _transfer( + address from, + address to, + uint256 tokenId + ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); @@ -371,7 +397,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { + function _setApprovalForAll( + address owner, + address operator, + bool approved + ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); @@ -435,7 +465,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { function _beforeTokenTransfer( address from, address to, - uint256 /* firstTokenId */, + uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { @@ -462,5 +492,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} + function _afterTokenTransfer( + address from, + address to, + uint256 firstTokenId, + uint256 batchSize + ) internal virtual {} } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 646530aa568..22020bab0bf 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -51,7 +51,12 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes calldata data + ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients @@ -67,7 +72,11 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom(address from, address to, uint256 tokenId) external; + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. @@ -85,7 +94,11 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function transferFrom(address from, address to, uint256 tokenId) external; + function transferFrom( + address from, + address to, + uint256 tokenId + ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index cfa533a47b1..394926d51ed 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -17,7 +17,12 @@ contract ERC721Holder is IERC721Receiver { * * Always returns `IERC721Receiver.onERC721Received.selector`. */ - function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { + function onERC721Received( + address, + address, + uint256, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 3803568d571..5fd3a63cb30 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -57,7 +57,11 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev `defaultOperators` may be an empty array. */ - constructor(string memory name_, string memory symbol_, address[] memory defaultOperators_) { + constructor( + string memory name_, + string memory symbol_, + address[] memory defaultOperators_ + ) { _name = name_; _symbol = symbol_; @@ -123,7 +127,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ - function send(address recipient, uint256 amount, bytes memory data) public virtual override { + function send( + address recipient, + uint256 amount, + bytes memory data + ) public virtual override { _send(_msgSender(), recipient, amount, data, "", true); } @@ -264,7 +272,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ - function transferFrom(address holder, address recipient, uint256 amount) public virtual override returns (bool) { + function transferFrom( + address holder, + address recipient, + uint256 amount + ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(holder, spender, amount); _send(holder, recipient, amount, "", "", false); @@ -289,7 +301,12 @@ contract ERC777 is Context, IERC777, IERC20 { * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ - function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData) internal virtual { + function _mint( + address account, + uint256 amount, + bytes memory userData, + bytes memory operatorData + ) internal virtual { _mint(account, amount, userData, operatorData, true); } @@ -370,7 +387,12 @@ contract ERC777 is Context, IERC777, IERC20 { * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ - function _burn(address from, uint256 amount, bytes memory data, bytes memory operatorData) internal virtual { + function _burn( + address from, + uint256 amount, + bytes memory data, + bytes memory operatorData + ) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); @@ -417,7 +439,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Note that accounts cannot have allowance issued by their operators. */ - function _approve(address holder, address spender, uint256 value) internal virtual { + function _approve( + address holder, + address spender, + uint256 value + ) internal virtual { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); @@ -472,7 +498,10 @@ contract ERC777 is Context, IERC777, IERC20 { if (implementer != address(0)) { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); } else if (requireReceptionAck) { - require(!(to.code.length > 0), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); + require( + !(to.code.length > 0), + "ERC777: token recipient contract has no implementer for ERC777TokensRecipient" + ); } } @@ -484,7 +513,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Might emit an {IERC20-Approval} event. */ - function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { + function _spendAllowance( + address owner, + address spender, + uint256 amount + ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC777: insufficient allowance"); @@ -508,5 +541,10 @@ contract ERC777 is Context, IERC777, IERC20 { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual {} + function _beforeTokenTransfer( + address operator, + address from, + address to, + uint256 amount + ) internal virtual {} } diff --git a/contracts/token/ERC777/IERC777.sol b/contracts/token/ERC777/IERC777.sol index d3bede62610..2af7771b03e 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -83,7 +83,11 @@ interface IERC777 { * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ - function send(address recipient, uint256 amount, bytes calldata data) external; + function send( + address recipient, + uint256 amount, + bytes calldata data + ) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the @@ -187,7 +191,12 @@ interface IERC777 { * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ - function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external; + function operatorBurn( + address account, + uint256 amount, + bytes calldata data, + bytes calldata operatorData + ) external; event Sent( address indexed operator, diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index 84cb6b8deb4..604dba3046a 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -91,7 +91,11 @@ abstract contract ERC2981 is IERC2981, ERC165 { * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ - function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { + function _setTokenRoyalty( + uint256 tokenId, + address receiver, + uint96 feeNumerator + ) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index e08cdc75492..0da5959d864 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -77,7 +77,11 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + function functionCallWithValue( + address target, + bytes memory data, + uint256 value + ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } diff --git a/contracts/utils/Checkpoints.sol b/contracts/utils/Checkpoints.sol index 76203edd2ce..f20601c6a81 100644 --- a/contracts/utils/Checkpoints.sol +++ b/contracts/utils/Checkpoints.sol @@ -111,9 +111,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint( - History storage self - ) internal view returns (bool exists, uint32 _blockNumber, uint224 _value) { + function latestCheckpoint(History storage self) + internal + view + returns ( + bool exists, + uint32 _blockNumber, + uint224 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -134,7 +140,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { + function _insert( + Checkpoint[] storage self, + uint32 key, + uint224 value + ) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -227,7 +237,11 @@ library Checkpoints { * * Returns previous value and new value. */ - function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { + function push( + Trace224 storage self, + uint32 key, + uint224 value + ) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } @@ -261,7 +275,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { + function latestCheckpoint(Trace224 storage self) + internal + view + returns ( + bool exists, + uint32 _key, + uint224 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -282,7 +304,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { + function _insert( + Checkpoint224[] storage self, + uint32 key, + uint224 value + ) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -354,10 +380,11 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess( - Checkpoint224[] storage self, - uint256 pos - ) private pure returns (Checkpoint224 storage result) { + function _unsafeAccess(Checkpoint224[] storage self, uint256 pos) + private + pure + returns (Checkpoint224 storage result) + { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) @@ -378,7 +405,11 @@ library Checkpoints { * * Returns previous value and new value. */ - function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { + function push( + Trace160 storage self, + uint96 key, + uint160 value + ) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } @@ -412,7 +443,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { + function latestCheckpoint(Trace160 storage self) + internal + view + returns ( + bool exists, + uint96 _key, + uint160 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -433,7 +472,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { + function _insert( + Checkpoint160[] storage self, + uint96 key, + uint160 value + ) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { @@ -505,10 +548,11 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess( - Checkpoint160[] storage self, - uint256 pos - ) private pure returns (Checkpoint160 storage result) { + function _unsafeAccess(Checkpoint160[] storage self, uint256 pos) + private + pure + returns (Checkpoint160 storage result) + { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index 2255a4df8b7..8df86d66999 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -27,7 +27,11 @@ library Create2 { * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ - function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) { + function deploy( + uint256 amount, + bytes32 salt, + bytes memory bytecode + ) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly @@ -49,7 +53,11 @@ library Create2 { * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ - function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) { + function computeAddress( + bytes32 salt, + bytes32 bytecodeHash, + address deployer + ) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer diff --git a/contracts/utils/cryptography/ECDSA.sol b/contracts/utils/cryptography/ECDSA.sol index 3f996520efd..4b1d66b092d 100644 --- a/contracts/utils/cryptography/ECDSA.sol +++ b/contracts/utils/cryptography/ECDSA.sol @@ -98,7 +98,11 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { + function tryRecover( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); @@ -109,7 +113,11 @@ library ECDSA { * * _Available since v4.2._ */ - function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { + function recover( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; @@ -121,7 +129,12 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { + function tryRecover( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most @@ -148,7 +161,12 @@ library ECDSA { * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ - function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { + function recover( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index 0ce87faf283..47c60eb0118 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -24,7 +24,11 @@ library MerkleProof { * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ - function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { + function verify( + bytes32[] memory proof, + bytes32 root, + bytes32 leaf + ) internal pure returns (bool) { return processProof(proof, leaf) == root; } @@ -33,7 +37,11 @@ library MerkleProof { * * _Available since v4.7._ */ - function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { + function verifyCalldata( + bytes32[] calldata proof, + bytes32 root, + bytes32 leaf + ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } diff --git a/contracts/utils/cryptography/SignatureChecker.sol b/contracts/utils/cryptography/SignatureChecker.sol index e06778debd7..77fe98282bf 100644 --- a/contracts/utils/cryptography/SignatureChecker.sol +++ b/contracts/utils/cryptography/SignatureChecker.sol @@ -21,7 +21,11 @@ library SignatureChecker { * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ - function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { + function isValidSignatureNow( + address signer, + bytes32 hash, + bytes memory signature + ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; diff --git a/contracts/utils/introspection/ERC165Checker.sol b/contracts/utils/introspection/ERC165Checker.sol index 40ffd68f73f..4c5fe2092df 100644 --- a/contracts/utils/introspection/ERC165Checker.sol +++ b/contracts/utils/introspection/ERC165Checker.sol @@ -48,10 +48,11 @@ library ERC165Checker { * * _Available since v3.4._ */ - function getSupportedInterfaces( - address account, - bytes4[] memory interfaceIds - ) internal view returns (bool[] memory) { + function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) + internal + view + returns (bool[] memory) + { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); diff --git a/contracts/utils/introspection/ERC1820Implementer.sol b/contracts/utils/introspection/ERC1820Implementer.sol index ac5a884c02a..1b5139658bd 100644 --- a/contracts/utils/introspection/ERC1820Implementer.sol +++ b/contracts/utils/introspection/ERC1820Implementer.sol @@ -21,10 +21,13 @@ contract ERC1820Implementer is IERC1820Implementer { /** * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function canImplementInterfaceForAddress( - bytes32 interfaceHash, - address account - ) public view virtual override returns (bytes32) { + function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) + public + view + virtual + override + returns (bytes32) + { return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00); } diff --git a/contracts/utils/introspection/IERC1820Registry.sol b/contracts/utils/introspection/IERC1820Registry.sol index a146bc2a68b..42cf46a8ae8 100644 --- a/contracts/utils/introspection/IERC1820Registry.sol +++ b/contracts/utils/introspection/IERC1820Registry.sol @@ -64,7 +64,11 @@ interface IERC1820Registry { * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; + function setInterfaceImplementer( + address account, + bytes32 _interfaceHash, + address implementer + ) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such diff --git a/contracts/utils/math/Math.sol b/contracts/utils/math/Math.sol index f3a83b0ffab..0ed5460e05f 100644 --- a/contracts/utils/math/Math.sol +++ b/contracts/utils/math/Math.sol @@ -52,7 +52,11 @@ library Math { * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ - function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { + function mulDiv( + uint256 x, + uint256 y, + uint256 denominator + ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 @@ -133,7 +137,12 @@ library Math { /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ - function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { + function mulDiv( + uint256 x, + uint256 y, + uint256 denominator, + Rounding rounding + ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; @@ -249,31 +258,31 @@ library Math { function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { - if (value >= 10 ** 64) { - value /= 10 ** 64; + if (value >= 10**64) { + value /= 10**64; result += 64; } - if (value >= 10 ** 32) { - value /= 10 ** 32; + if (value >= 10**32) { + value /= 10**32; result += 32; } - if (value >= 10 ** 16) { - value /= 10 ** 16; + if (value >= 10**16) { + value /= 10**16; result += 16; } - if (value >= 10 ** 8) { - value /= 10 ** 8; + if (value >= 10**8) { + value /= 10**8; result += 8; } - if (value >= 10 ** 4) { - value /= 10 ** 4; + if (value >= 10**4) { + value /= 10**4; result += 4; } - if (value >= 10 ** 2) { - value /= 10 ** 2; + if (value >= 10**2) { + value /= 10**2; result += 2; } - if (value >= 10 ** 1) { + if (value >= 10**1) { result += 1; } } @@ -287,7 +296,7 @@ library Math { function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); - return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); + return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } diff --git a/contracts/utils/math/SafeMath.sol b/contracts/utils/math/SafeMath.sol index 2f48fb7360a..550f0e779b1 100644 --- a/contracts/utils/math/SafeMath.sol +++ b/contracts/utils/math/SafeMath.sol @@ -165,7 +165,11 @@ library SafeMath { * * - Subtraction cannot overflow. */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; @@ -184,7 +188,11 @@ library SafeMath { * * - The divisor cannot be zero. */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; @@ -206,7 +214,11 @@ library SafeMath { * * - The divisor cannot be zero. */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index eb67bfab081..a2ddc47098f 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -23,7 +23,11 @@ library BitMaps { /** * @dev Sets the bit at `index` to the boolean `value`. */ - function setTo(BitMap storage bitmap, uint256 index, bool value) internal { + function setTo( + BitMap storage bitmap, + uint256 index, + bool value + ) internal { if (value) { set(bitmap, index); } else { diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index d359671f461..a3fda61d802 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -70,7 +70,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { + function set( + Bytes32ToBytes32Map storage map, + bytes32 key, + bytes32 value + ) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } @@ -169,7 +173,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { + function set( + UintToUintMap storage map, + uint256 key, + uint256 value + ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } @@ -236,7 +244,11 @@ library EnumerableMap { * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ - function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) { + function get( + UintToUintMap storage map, + uint256 key, + string memory errorMessage + ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } @@ -253,7 +265,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { + function set( + UintToAddressMap storage map, + uint256 key, + address value + ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } @@ -341,7 +357,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { + function set( + AddressToUintMap storage map, + address key, + uint256 value + ) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } @@ -429,7 +449,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { + function set( + Bytes32ToUintMap storage map, + bytes32 key, + uint256 value + ) internal returns (bool) { return set(map._inner, key, bytes32(value)); } diff --git a/contracts/vendor/amb/IAMB.sol b/contracts/vendor/amb/IAMB.sol index 73a2bd24bcb..1a5d7080f8b 100644 --- a/contracts/vendor/amb/IAMB.sol +++ b/contracts/vendor/amb/IAMB.sol @@ -31,9 +31,17 @@ interface IAMB { function failedMessageSender(bytes32 _messageId) external view returns (address); - function requireToPassMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); - - function requireToConfirmMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); + function requireToPassMessage( + address _contract, + bytes calldata _data, + uint256 _gas + ) external returns (bytes32); + + function requireToConfirmMessage( + address _contract, + bytes calldata _data, + uint256 _gas + ) external returns (bytes32); function sourceChainId() external view returns (uint256); diff --git a/contracts/vendor/arbitrum/IArbSys.sol b/contracts/vendor/arbitrum/IArbSys.sol index 9b79d5c16a2..aac5dd53a9e 100644 --- a/contracts/vendor/arbitrum/IArbSys.sol +++ b/contracts/vendor/arbitrum/IArbSys.sol @@ -92,7 +92,14 @@ interface IArbSys { * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ - function sendMerkleTreeState() external view returns (uint256 size, bytes32 root, bytes32[] memory partials); + function sendMerkleTreeState() + external + view + returns ( + uint256 size, + bytes32 root, + bytes32[] memory partials + ); /** * @notice creates a send txn from L2 to L1 diff --git a/contracts/vendor/arbitrum/IBridge.sol b/contracts/vendor/arbitrum/IBridge.sol index e71bedce012..7518f5d13cc 100644 --- a/contracts/vendor/arbitrum/IBridge.sol +++ b/contracts/vendor/arbitrum/IBridge.sol @@ -77,7 +77,14 @@ interface IBridge { uint256 afterDelayedMessagesRead, uint256 prevMessageCount, uint256 newMessageCount - ) external returns (uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc); + ) + external + returns ( + uint256 seqMessageIndex, + bytes32 beforeAcc, + bytes32 delayedAcc, + bytes32 acc + ); /** * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type diff --git a/contracts/vendor/arbitrum/IOutbox.sol b/contracts/vendor/arbitrum/IOutbox.sol index 22fa58f405a..4f809dbf43e 100644 --- a/contracts/vendor/arbitrum/IOutbox.sol +++ b/contracts/vendor/arbitrum/IOutbox.sol @@ -113,5 +113,9 @@ interface IOutbox { bytes calldata data ) external pure returns (bytes32); - function calculateMerkleRoot(bytes32[] memory proof, uint256 path, bytes32 item) external pure returns (bytes32); + function calculateMerkleRoot( + bytes32[] memory proof, + uint256 path, + bytes32 item + ) external pure returns (bytes32); } diff --git a/contracts/vendor/optimism/ICrossDomainMessenger.sol b/contracts/vendor/optimism/ICrossDomainMessenger.sol index cc01a48ab9a..9cc797701bf 100644 --- a/contracts/vendor/optimism/ICrossDomainMessenger.sol +++ b/contracts/vendor/optimism/ICrossDomainMessenger.sol @@ -30,5 +30,9 @@ interface ICrossDomainMessenger { * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ - function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external; + function sendMessage( + address _target, + bytes calldata _message, + uint32 _gasLimit + ) external; } diff --git a/contracts/vendor/polygon/IFxMessageProcessor.sol b/contracts/vendor/polygon/IFxMessageProcessor.sol index be73e6f53cd..9f42eb64709 100644 --- a/contracts/vendor/polygon/IFxMessageProcessor.sol +++ b/contracts/vendor/polygon/IFxMessageProcessor.sol @@ -3,5 +3,9 @@ pragma solidity ^0.8.0; interface IFxMessageProcessor { - function processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes calldata data) external; + function processMessageFromRoot( + uint256 stateId, + address rootMessageSender, + bytes calldata data + ) external; } diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index 5542baf9d94..c1c6f447d3a 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -70,16 +70,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf2Bigger(result + 1, input)); } else { - assertEq(2 ** result, input); + assertEq(2**result, input); } } function _powerOf2Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 256 || 2 ** value > ref; // 2**256 overflows uint256 + return value >= 256 || 2**value > ref; // 2**256 overflows uint256 } function _powerOf2Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 2 ** value < ref; + return 2**value < ref; } // LOG10 @@ -97,16 +97,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf10Bigger(result + 1, input)); } else { - assertEq(10 ** result, input); + assertEq(10**result, input); } } function _powerOf10Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 78 || 10 ** value > ref; // 10**78 overflows uint256 + return value >= 78 || 10**value > ref; // 10**78 overflows uint256 } function _powerOf10Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 10 ** value < ref; + return 10**value < ref; } // LOG256 @@ -124,20 +124,24 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf256Bigger(result + 1, input)); } else { - assertEq(256 ** result, input); + assertEq(256**result, input); } } function _powerOf256Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 32 || 256 ** value > ref; // 256**32 overflows uint256 + return value >= 32 || 256**value > ref; // 256**32 overflows uint256 } function _powerOf256Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 256 ** value < ref; + return 256**value < ref; } // MULDIV - function testMulDiv(uint256 x, uint256 y, uint256 d) public { + function testMulDiv( + uint256 x, + uint256 y, + uint256 d + ) public { // Full precision for x * y (uint256 xyHi, uint256 xyLo) = _mulHighLow(x, y); @@ -159,7 +163,11 @@ contract MathTest is Test { assertEq(xyLo, qdRemLo); } - function testMulDivDomain(uint256 x, uint256 y, uint256 d) public { + function testMulDivDomain( + uint256 x, + uint256 y, + uint256 d + ) public { (uint256 xyHi, ) = _mulHighLow(x, y); // Violate {testMulDiv} assumption (covers d is 0 and result overflow) @@ -172,7 +180,11 @@ contract MathTest is Test { } // External call - function muldiv(uint256 x, uint256 y, uint256 d) external pure returns (uint256) { + function muldiv( + uint256 x, + uint256 y, + uint256 d + ) external pure returns (uint256) { return Math.mulDiv(x, y, d); } @@ -182,7 +194,11 @@ contract MathTest is Test { return Math.Rounding(r); } - function _mulmod(uint256 x, uint256 y, uint256 z) private pure returns (uint256 r) { + function _mulmod( + uint256 x, + uint256 y, + uint256 z + ) private pure returns (uint256 r) { assembly { r := mulmod(x, y, z) } From 81667ae8416fc899270541450f62d0a6078e8869 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Wed, 11 Jan 2023 08:58:54 -0400 Subject: [PATCH 03/19] bump pragma --- contracts/mocks/UUPS/UUPSLegacy.sol | 2 +- contracts/proxy/beacon/UpgradeableBeacon.sol | 2 +- contracts/token/ERC1155/ERC1155.sol | 2 +- contracts/token/ERC721/ERC721.sol | 2 +- contracts/token/ERC721/extensions/ERC721Consecutive.sol | 2 +- contracts/token/ERC777/ERC777.sol | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index 2c70a390663..f1fb3d0b3f3 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "./UUPSUpgradeableMock.sol"; diff --git a/contracts/proxy/beacon/UpgradeableBeacon.sol b/contracts/proxy/beacon/UpgradeableBeacon.sol index 342db4a422a..9eeb149a69e 100644 --- a/contracts/proxy/beacon/UpgradeableBeacon.sol +++ b/contracts/proxy/beacon/UpgradeableBeacon.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol) -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "./IBeacon.sol"; import "../../access/Ownable.sol"; diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index d7a3e2c0899..eda19070e3c 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol) -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 75cc2a22bed..8d8794c23c9 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "./IERC721.sol"; import "./IERC721Receiver.sol"; diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index 91042642b6a..4e32c2344f2 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Consecutive.sol) -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "../ERC721.sol"; import "../../../interfaces/IERC2309.sol"; diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 5fd3a63cb30..60f4ea1b1a5 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC777/ERC777.sol) -pragma solidity ^0.8.0; +pragma solidity ^0.8.1; import "./IERC777.sol"; import "./IERC777Recipient.sol"; From 26863ed00a448f9d5cfd8af880254d7437b69cb7 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Wed, 11 Jan 2023 09:00:16 -0400 Subject: [PATCH 04/19] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a31fb22c30c..e251201b584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * `ProxyAdmin`: Removed `getProxyAdmin` and `getProxyImplementation` getters. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) * `ERC20`, `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, added a new internal `_update` function for customizations, and refactored all extensions using those hooks to use `_update` instead. ([#3838](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3838), [#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876)) * `ERC165Storage`: Removed this contract in favor of inheritance based approach. ([#3880](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3880)) + * `Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. ([#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945)) ### How to upgrade from 4.x From 8ad9f9f9aae715a10903337370dd50001e29a265 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Wed, 11 Jan 2023 09:08:31 -0400 Subject: [PATCH 05/19] run lint --- .../polygon/CrossChainEnabledPolygonChild.sol | 2 +- contracts/finance/VestingWallet.sol | 6 +- contracts/governance/Governor.sol | 27 +++---- contracts/governance/TimelockController.sol | 20 +---- .../GovernorCompatibilityBravo.sol | 17 ++-- .../IGovernorCompatibilityBravo.sol | 8 +- .../extensions/GovernorCountingSimple.sol | 13 +-- .../extensions/GovernorSettings.sol | 6 +- .../extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/IVotes.sol | 9 +-- contracts/governance/utils/Votes.sol | 12 +-- contracts/interfaces/IERC1363.sol | 25 +----- contracts/interfaces/IERC1363Spender.sol | 6 +- contracts/interfaces/IERC2981.sol | 8 +- contracts/interfaces/IERC4626.sol | 12 +-- contracts/metatx/MinimalForwarder.sol | 9 +-- contracts/mocks/AddressImpl.sol | 6 +- contracts/mocks/CheckpointsMock.sol | 30 +------ contracts/mocks/ClonesMock.sol | 6 +- contracts/mocks/ContextMock.sol | 6 +- contracts/mocks/Create2Impl.sol | 6 +- contracts/mocks/DummyImplementation.sol | 6 +- contracts/mocks/ECDSAMock.sol | 13 +-- contracts/mocks/EIP712External.sol | 7 +- contracts/mocks/ERC1155BurnableMock.sol | 7 +- contracts/mocks/ERC1155Mock.sol | 26 +----- contracts/mocks/ERC1155ReceiverMock.sol | 7 +- contracts/mocks/ERC20CappedMock.sol | 6 +- contracts/mocks/ERC20DecimalsMock.sol | 6 +- contracts/mocks/ERC20Mock.sol | 12 +-- contracts/mocks/ERC3156FlashBorrowerMock.sol | 2 +- contracts/mocks/ERC4626Mock.sol | 32 +++----- contracts/mocks/ERC721BurnableMock.sol | 6 +- .../mocks/ERC721ConsecutiveEnumerableMock.sol | 10 +-- contracts/mocks/ERC721EnumerableMock.sol | 6 +- contracts/mocks/ERC721Mock.sol | 6 +- contracts/mocks/ERC721PausableMock.sol | 6 +- contracts/mocks/ERC721RoyaltyMock.sol | 6 +- contracts/mocks/ERC721URIStorageMock.sol | 6 +- contracts/mocks/ERC777Mock.sol | 20 +---- contracts/mocks/ERC777SenderRecipientMock.sol | 13 +-- .../mocks/GovernorCompatibilityBravoMock.sol | 27 +++---- .../mocks/GovernorPreventLateQuorumMock.sol | 9 +-- .../mocks/GovernorTimelockCompoundMock.sol | 27 +++---- .../mocks/GovernorTimelockControlMock.sol | 18 ++--- contracts/mocks/MathMock.sol | 7 +- contracts/mocks/MerkleProofWrapper.sol | 12 +-- .../MultipleInheritanceInitializableMocks.sol | 7 +- contracts/mocks/SafeERC20Helper.sol | 18 +---- contracts/mocks/SafeMathMock.sol | 18 +---- contracts/mocks/SignatureCheckerMock.sol | 6 +- contracts/mocks/UUPS/UUPSLegacy.sol | 6 +- contracts/mocks/crosschain/bridges.sol | 12 +-- contracts/mocks/wizard/MyGovernor1.sol | 28 +++---- contracts/mocks/wizard/MyGovernor2.sol | 28 +++---- contracts/mocks/wizard/MyGovernor3.sol | 37 +++------ contracts/proxy/Clones.sol | 9 +-- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 18 +---- .../TransparentUpgradeableProxy.sol | 6 +- contracts/token/ERC1155/ERC1155.sol | 51 +++--------- contracts/token/ERC1155/IERC1155.sol | 16 ++-- .../ERC1155/extensions/ERC1155Burnable.sol | 12 +-- contracts/token/ERC20/ERC20.sol | 30 ++----- contracts/token/ERC20/IERC20.sol | 6 +- .../token/ERC20/extensions/ERC20Capped.sol | 6 +- .../token/ERC20/extensions/ERC20Pausable.sol | 6 +- .../token/ERC20/extensions/ERC20Snapshot.sol | 6 +- .../token/ERC20/extensions/ERC20Votes.sol | 6 +- contracts/token/ERC20/extensions/ERC4626.sol | 19 +---- contracts/token/ERC20/utils/SafeERC20.sol | 31 ++----- contracts/token/ERC20/utils/TokenTimelock.sol | 6 +- contracts/token/ERC721/ERC721.sol | 53 +++--------- contracts/token/ERC721/IERC721.sol | 19 +---- contracts/token/ERC721/utils/ERC721Holder.sol | 7 +- contracts/token/ERC777/ERC777.sol | 51 ++---------- contracts/token/ERC777/IERC777.sol | 13 +-- contracts/token/common/ERC2981.sol | 6 +- contracts/utils/Address.sol | 6 +- contracts/utils/Checkpoints.sol | 80 +++++-------------- contracts/utils/Create2.sol | 12 +-- contracts/utils/cryptography/ECDSA.sol | 26 +----- contracts/utils/cryptography/MerkleProof.sol | 12 +-- .../utils/cryptography/SignatureChecker.sol | 6 +- .../utils/introspection/ERC165Checker.sol | 9 +-- .../introspection/ERC1820Implementer.sol | 11 +-- .../utils/introspection/IERC1820Registry.sol | 6 +- contracts/utils/math/Math.sol | 41 ++++------ contracts/utils/math/SafeMath.sol | 18 +---- contracts/utils/structs/BitMaps.sol | 6 +- contracts/utils/structs/EnumerableMap.sol | 36 ++------- contracts/vendor/amb/IAMB.sol | 14 +--- contracts/vendor/arbitrum/IArbSys.sol | 9 +-- contracts/vendor/arbitrum/IBridge.sol | 9 +-- contracts/vendor/arbitrum/IOutbox.sol | 6 +- .../vendor/optimism/ICrossDomainMessenger.sol | 6 +- .../vendor/polygon/IFxMessageProcessor.sol | 6 +- test/utils/math/Math.t.sol | 42 +++------- 97 files changed, 326 insertions(+), 1111 deletions(-) diff --git a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol index 3918bfe25d8..fa099483499 100644 --- a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +++ b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol @@ -59,7 +59,7 @@ abstract contract CrossChainEnabledPolygonChild is IFxMessageProcessor, CrossCha * then security could be compromised. */ function processMessageFromRoot( - uint256, /* stateId */ + uint256 /* stateId */, address rootMessageSender, bytes calldata data ) external override nonReentrant { diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index 0feac4ac6ab..fe67eb54ff6 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -29,11 +29,7 @@ contract VestingWallet is Context { /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. */ - constructor( - address beneficiaryAddress, - uint64 startTimestamp, - uint64 durationSeconds - ) payable { + constructor(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) payable { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 84b3128ff0c..8235fb5ecb1 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -314,7 +314,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Internal execution mechanism. Can be overridden to implement different execution mechanism */ function _execute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, @@ -331,9 +331,9 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook before execution is triggered. */ function _beforeExecute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, - uint256[] memory, /* values */ + uint256[] memory /* values */, bytes[] memory calldatas, bytes32 /*descriptionHash*/ ) internal virtual { @@ -350,10 +350,10 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook after execution is triggered. */ function _afterExecute( - uint256, /* proposalId */ - address[] memory, /* targets */ - uint256[] memory, /* values */ - bytes[] memory, /* calldatas */ + uint256 /* proposalId */, + address[] memory /* targets */, + uint256[] memory /* values */, + bytes[] memory /* calldatas */, bytes32 /*descriptionHash*/ ) internal virtual { if (_executor() != address(this)) { @@ -540,11 +540,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. * Note that if the executor is simply the governor itself, use of `relay` is redundant. */ - function relay( - address target, - uint256 value, - bytes calldata data - ) external payable virtual onlyGovernance { + function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance { (bool success, bytes memory returndata) = target.call{value: value}(data); Address.verifyCallResult(success, returndata, "Governor: relay reverted without message"); } @@ -560,12 +556,7 @@ 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 override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 43eedd23468..67e6d206c2d 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -73,12 +73,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver * administration through timelocked proposals. Previous versions of this contract would assign * this admin to the deployer automatically and should be renounced as well. */ - constructor( - uint256 minDelay, - address[] memory proposers, - address[] memory executors, - address admin - ) { + constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) { // self administration _grantRole(DEFAULT_ADMIN_ROLE, address(this)); @@ -336,11 +331,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev Execute an operation's call. */ - function _execute( - address target, - uint256 value, - bytes calldata data - ) internal virtual { + function _execute(address target, uint256 value, bytes calldata data) internal virtual { (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); } @@ -380,12 +371,7 @@ 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 override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol index 8d96be7d676..8d74742c5bb 100644 --- a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol @@ -118,11 +118,10 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev Encodes calldatas with optional function signature. */ - function _encodeCalldata(string[] memory signatures, bytes[] memory calldatas) - private - pure - returns (bytes[] memory) - { + function _encodeCalldata( + string[] memory signatures, + bytes[] memory calldatas + ) private pure returns (bytes[] memory) { bytes[] memory fullcalldatas = new bytes[](calldatas.length); for (uint256 i = 0; i < signatures.length; ++i) { @@ -163,7 +162,9 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-proposals}. */ - function proposals(uint256 proposalId) + function proposals( + uint256 proposalId + ) public view virtual @@ -200,7 +201,9 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-getActions}. */ - function getActions(uint256 proposalId) + function getActions( + uint256 proposalId + ) public view virtual diff --git a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol index 83e4e1ae9c0..d1ec0337d00 100644 --- a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol @@ -50,7 +50,9 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"The official record of all proposals ever proposed"_. */ - function proposals(uint256) + function proposals( + uint256 + ) public view virtual @@ -96,7 +98,9 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"Gets actions of a proposal"_. */ - function getActions(uint256 proposalId) + function getActions( + uint256 proposalId + ) public view virtual diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index 5611fc6692c..f3eea9d7fa4 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -47,16 +47,9 @@ abstract contract GovernorCountingSimple is Governor { /** * @dev Accessor to the internal vote counts. */ - function proposalVotes(uint256 proposalId) - public - view - virtual - returns ( - uint256 againstVotes, - uint256 forVotes, - uint256 abstainVotes - ) - { + function proposalVotes( + uint256 proposalId + ) public view virtual returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) { ProposalVote storage proposalVote = _proposalVotes[proposalId]; return (proposalVote.againstVotes, proposalVote.forVotes, proposalVote.abstainVotes); } diff --git a/contracts/governance/extensions/GovernorSettings.sol b/contracts/governance/extensions/GovernorSettings.sol index a3187c6e16e..527f41cd8a8 100644 --- a/contracts/governance/extensions/GovernorSettings.sol +++ b/contracts/governance/extensions/GovernorSettings.sol @@ -22,11 +22,7 @@ abstract contract GovernorSettings is Governor { /** * @dev Initialize the governance parameters. */ - constructor( - uint256 initialVotingDelay, - uint256 initialVotingPeriod, - uint256 initialProposalThreshold - ) { + constructor(uint256 initialVotingDelay, uint256 initialVotingPeriod, uint256 initialProposalThreshold) { _setVotingDelay(initialVotingDelay); _setVotingPeriod(initialVotingPeriod); _setProposalThreshold(initialProposalThreshold); diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index aaeaf940926..6aa2556abf1 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -110,7 +110,7 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { * @dev Overridden execute function that run the already queued proposal through the timelock. */ function _execute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, diff --git a/contracts/governance/utils/IVotes.sol b/contracts/governance/utils/IVotes.sol index 6317d7752e0..0bef3f92079 100644 --- a/contracts/governance/utils/IVotes.sol +++ b/contracts/governance/utils/IVotes.sol @@ -50,12 +50,5 @@ interface IVotes { /** * @dev Delegates votes from signer to `delegatee`. */ - function delegateBySig( - address delegatee, - uint256 nonce, - uint256 expiry, - uint8 v, - bytes32 r, - bytes32 s - ) external; + function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; } diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 801be3bcd32..492c1afb157 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -134,11 +134,7 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to` * should be zero. Total supply of voting units will be adjusted with mints and burns. */ - function _transferVotingUnits( - address from, - address to, - uint256 amount - ) internal virtual { + function _transferVotingUnits(address from, address to, uint256 amount) internal virtual { if (from == address(0)) { _totalCheckpoints.push(_add, amount); } @@ -151,11 +147,7 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { /** * @dev Moves delegated votes from one delegate to another. */ - function _moveDelegateVotes( - address from, - address to, - uint256 amount - ) private { + function _moveDelegateVotes(address from, address to, uint256 amount) private { if (from != to && amount > 0) { if (from != address(0)) { (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount); diff --git a/contracts/interfaces/IERC1363.sol b/contracts/interfaces/IERC1363.sol index 5fad104c223..1a8dc79f438 100644 --- a/contracts/interfaces/IERC1363.sol +++ b/contracts/interfaces/IERC1363.sol @@ -38,11 +38,7 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferAndCall( - address to, - uint256 value, - bytes memory data - ) external returns (bool); + function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -51,11 +47,7 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ - function transferFromAndCall( - address from, - address to, - uint256 value - ) external returns (bool); + function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -65,12 +57,7 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferFromAndCall( - address from, - address to, - uint256 value, - bytes memory data - ) external returns (bool); + function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender @@ -87,9 +74,5 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ - function approveAndCall( - address spender, - uint256 value, - bytes memory data - ) external returns (bool); + function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool); } diff --git a/contracts/interfaces/IERC1363Spender.sol b/contracts/interfaces/IERC1363Spender.sol index 48f6fd56d6d..28775e1406b 100644 --- a/contracts/interfaces/IERC1363Spender.sol +++ b/contracts/interfaces/IERC1363Spender.sol @@ -22,9 +22,5 @@ interface IERC1363Spender { * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ - function onApprovalReceived( - address owner, - uint256 value, - bytes memory data - ) external returns (bytes4); + function onApprovalReceived(address owner, uint256 value, bytes memory data) external returns (bytes4); } diff --git a/contracts/interfaces/IERC2981.sol b/contracts/interfaces/IERC2981.sol index 6b0558169ea..1c9448a9147 100644 --- a/contracts/interfaces/IERC2981.sol +++ b/contracts/interfaces/IERC2981.sol @@ -18,8 +18,8 @@ interface IERC2981 is IERC165 { * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ - function royaltyInfo(uint256 tokenId, uint256 salePrice) - external - view - returns (address receiver, uint256 royaltyAmount); + function royaltyInfo( + uint256 tokenId, + uint256 salePrice + ) external view returns (address receiver, uint256 royaltyAmount); } diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index f7c5397a0fa..08e5de7176b 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -187,11 +187,7 @@ interface IERC4626 is IERC20, IERC20Metadata { * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function withdraw( - uint256 assets, - address receiver, - address owner - ) external returns (uint256 shares); + function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, @@ -232,9 +228,5 @@ interface IERC4626 is IERC20, IERC20Metadata { * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function redeem( - uint256 shares, - address receiver, - address owner - ) external returns (uint256 assets); + function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); } diff --git a/contracts/metatx/MinimalForwarder.sol b/contracts/metatx/MinimalForwarder.sol index bb49c794dbb..9298ae6751c 100644 --- a/contracts/metatx/MinimalForwarder.sol +++ b/contracts/metatx/MinimalForwarder.sol @@ -44,11 +44,10 @@ contract MinimalForwarder is EIP712 { return _nonces[req.from] == req.nonce && signer == req.from; } - function execute(ForwardRequest calldata req, bytes calldata signature) - public - payable - returns (bool, bytes memory) - { + function execute( + ForwardRequest calldata req, + bytes calldata signature + ) public payable returns (bool, bytes memory) { require(verify(req, signature), "MinimalForwarder: signature does not match request"); _nonces[req.from] = req.nonce + 1; diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index 8dc7886c1fd..27f954e0000 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -18,11 +18,7 @@ contract AddressImpl { emit CallReturnValue(abi.decode(returnData, (string))); } - function functionCallWithValue( - address target, - bytes calldata data, - uint256 value - ) external payable { + function functionCallWithValue(address target, bytes calldata data, uint256 value) external payable { bytes memory returnData = Address.functionCallWithValue(target, data, value); emit CallReturnValue(abi.decode(returnData, (string))); } diff --git a/contracts/mocks/CheckpointsMock.sol b/contracts/mocks/CheckpointsMock.sol index f1dadabaf7d..874a1d1f213 100644 --- a/contracts/mocks/CheckpointsMock.sol +++ b/contracts/mocks/CheckpointsMock.sol @@ -14,15 +14,7 @@ contract CheckpointsMock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint256, - uint256 - ) - { + function latestCheckpoint() public view returns (bool, uint256, uint256) { return _totalCheckpoints.latestCheckpoint(); } @@ -52,15 +44,7 @@ contract Checkpoints224Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint32, - uint224 - ) - { + function latestCheckpoint() public view returns (bool, uint32, uint224) { return _totalCheckpoints.latestCheckpoint(); } @@ -90,15 +74,7 @@ contract Checkpoints160Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint96, - uint160 - ) - { + function latestCheckpoint() public view returns (bool, uint96, uint160) { return _totalCheckpoints.latestCheckpoint(); } diff --git a/contracts/mocks/ClonesMock.sol b/contracts/mocks/ClonesMock.sol index 3719b0a7835..c65d30cc3b0 100644 --- a/contracts/mocks/ClonesMock.sol +++ b/contracts/mocks/ClonesMock.sol @@ -15,11 +15,7 @@ contract ClonesMock { _initAndEmit(implementation.clone(), initdata); } - function cloneDeterministic( - address implementation, - bytes32 salt, - bytes calldata initdata - ) public payable { + function cloneDeterministic(address implementation, bytes32 salt, bytes calldata initdata) public payable { _initAndEmit(implementation.cloneDeterministic(salt), initdata); } diff --git a/contracts/mocks/ContextMock.sol b/contracts/mocks/ContextMock.sol index f17af38a49a..7759f350639 100644 --- a/contracts/mocks/ContextMock.sol +++ b/contracts/mocks/ContextMock.sol @@ -23,11 +23,7 @@ contract ContextMockCaller { context.msgSender(); } - function callData( - ContextMock context, - uint256 integerValue, - string memory stringValue - ) public { + function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { context.msgData(integerValue, stringValue); } } diff --git a/contracts/mocks/Create2Impl.sol b/contracts/mocks/Create2Impl.sol index 070ad3671c5..6b2f4b712e5 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -6,11 +6,7 @@ import "../utils/Create2.sol"; import "../utils/introspection/ERC1820Implementer.sol"; contract Create2Impl { - function deploy( - uint256 value, - bytes32 salt, - bytes memory code - ) public { + function deploy(uint256 value, bytes32 salt, bytes memory code) public { Create2.deploy(value, salt, code); } diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index d8651340d1b..ddcca660439 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -27,11 +27,7 @@ contract DummyImplementation { value = _value; } - function initialize( - uint256 _value, - string memory _text, - uint256[] memory _values - ) public { + function initialize(uint256 _value, string memory _text, uint256[] memory _values) public { value = _value; text = _text; values = _values; diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index 97bd46669a6..cfc37d26ea6 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -13,21 +13,12 @@ contract ECDSAMock { } // solhint-disable-next-line func-name-mixedcase - function recover_v_r_s( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) public pure returns (address) { + function recover_v_r_s(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { return hash.recover(v, r, s); } // solhint-disable-next-line func-name-mixedcase - function recover_r_vs( - bytes32 hash, - bytes32 r, - bytes32 vs - ) public pure returns (address) { + function recover_r_vs(bytes32 hash, bytes32 r, bytes32 vs) public pure returns (address) { return hash.recover(r, vs); } diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index 93f77d54946..bc5b1269f7c 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -12,12 +12,7 @@ contract EIP712External is EIP712 { return _domainSeparatorV4(); } - function verify( - bytes memory signature, - address signer, - address mailTo, - string memory mailContents - ) external view { + function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) ); diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 62138f28da6..3334523cf74 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -7,12 +7,7 @@ import "../token/ERC1155/extensions/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { constructor(string memory uri) ERC1155(uri) {} - function mint( - address to, - uint256 id, - uint256 value, - bytes memory data - ) public { + function mint(address to, uint256 id, uint256 value, bytes memory data) public { _mint(to, id, value, data); } } diff --git a/contracts/mocks/ERC1155Mock.sol b/contracts/mocks/ERC1155Mock.sol index 0518ac26c17..6bfc86ceaf3 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -15,37 +15,19 @@ contract ERC1155Mock is ERC1155 { _setURI(newuri); } - function mint( - address to, - uint256 id, - uint256 value, - bytes memory data - ) public { + function mint(address to, uint256 id, uint256 value, bytes memory data) public { _mint(to, id, value, data); } - function mintBatch( - address to, - uint256[] memory ids, - uint256[] memory values, - bytes memory data - ) public { + function mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) public { _mintBatch(to, ids, values, data); } - function burn( - address owner, - uint256 id, - uint256 value - ) public { + function burn(address owner, uint256 id, uint256 value) public { _burn(owner, id, value); } - function burnBatch( - address owner, - uint256[] memory ids, - uint256[] memory values - ) public { + function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public { _burnBatch(owner, ids, values); } } diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index 6443a56c7ae..b2d505c0a86 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -14,12 +14,7 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver { event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas); event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas); - constructor( - bytes4 recRetval, - bool recReverts, - bytes4 batRetval, - bool batReverts - ) { + constructor(bytes4 recRetval, bool recReverts, bytes4 batRetval, bool batReverts) { _recRetval = recRetval; _recReverts = recReverts; _batRetval = batRetval; diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index edb36f20531..e69aadfdf30 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -5,11 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Capped.sol"; contract ERC20CappedMock is ERC20Capped { - constructor( - string memory name, - string memory symbol, - uint256 cap - ) ERC20(name, symbol) ERC20Capped(cap) {} + constructor(string memory name, string memory symbol, uint256 cap) ERC20(name, symbol) ERC20Capped(cap) {} function mint(address to, uint256 tokenId) public { _mint(to, tokenId); diff --git a/contracts/mocks/ERC20DecimalsMock.sol b/contracts/mocks/ERC20DecimalsMock.sol index 3721f6c393b..7677e9dd1d1 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -7,11 +7,7 @@ import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { uint8 private immutable _decimals; - constructor( - string memory name_, - string memory symbol_, - uint8 decimals_ - ) ERC20(name_, symbol_) { + constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) { _decimals = decimals_; } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index fd7f991baf0..16ffad19fe5 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -23,19 +23,11 @@ contract ERC20Mock is ERC20 { _burn(account, amount); } - function transferInternal( - address from, - address to, - uint256 value - ) public { + function transferInternal(address from, address to, uint256 value) public { _transfer(from, to, value); } - function approveInternal( - address owner, - address spender, - uint256 value - ) public { + function approveInternal(address owner, address spender, uint256 value) public { _approve(owner, spender, value); } } diff --git a/contracts/mocks/ERC3156FlashBorrowerMock.sol b/contracts/mocks/ERC3156FlashBorrowerMock.sol index 288a278fb80..6a4410fcb1d 100644 --- a/contracts/mocks/ERC3156FlashBorrowerMock.sol +++ b/contracts/mocks/ERC3156FlashBorrowerMock.sol @@ -28,7 +28,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { } function onFlashLoan( - address, /*initiator*/ + address /*initiator*/, address token, uint256 amount, uint256 fee, diff --git a/contracts/mocks/ERC4626Mock.sol b/contracts/mocks/ERC4626Mock.sol index 4f80b4bd75b..9c13346f059 100644 --- a/contracts/mocks/ERC4626Mock.sol +++ b/contracts/mocks/ERC4626Mock.sol @@ -5,11 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC4626.sol"; contract ERC4626Mock is ERC4626 { - constructor( - IERC20Metadata asset, - string memory name, - string memory symbol - ) ERC20(name, symbol) ERC4626(asset) {} + constructor(IERC20Metadata asset, string memory name, string memory symbol) ERC20(name, symbol) ERC4626(asset) {} function mockMint(address account, uint256 amount) public { _mint(account, amount); @@ -38,23 +34,17 @@ contract ERC4626DecimalMock is ERC4626Mock { return _decimals; } - function _initialConvertToShares(uint256 assets, Math.Rounding rounding) - internal - view - virtual - override - returns (uint256 shares) - { - return assets.mulDiv(10**decimals(), 10**super.decimals(), rounding); + function _initialConvertToShares( + uint256 assets, + Math.Rounding rounding + ) internal view virtual override returns (uint256 shares) { + return assets.mulDiv(10 ** decimals(), 10 ** super.decimals(), rounding); } - function _initialConvertToAssets(uint256 shares, Math.Rounding rounding) - internal - view - virtual - override - returns (uint256 assets) - { - return shares.mulDiv(10**super.decimals(), 10**decimals(), rounding); + function _initialConvertToAssets( + uint256 shares, + Math.Rounding rounding + ) internal view virtual override returns (uint256 assets) { + return shares.mulDiv(10 ** super.decimals(), 10 ** decimals(), rounding); } } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index b30dbf53dfb..ecf42768182 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -19,11 +19,7 @@ contract ERC721BurnableMock is ERC721Burnable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } } diff --git a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol index cde3bd86cff..f4f5c5832be 100644 --- a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol +++ b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol @@ -17,13 +17,9 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable } } - function supportsInterface(bytes4 interfaceId) - public - view - virtual - override(ERC721, ERC721Enumerable) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } diff --git a/contracts/mocks/ERC721EnumerableMock.sol b/contracts/mocks/ERC721EnumerableMock.sol index a747925e69d..b7ea94ee3f2 100644 --- a/contracts/mocks/ERC721EnumerableMock.sol +++ b/contracts/mocks/ERC721EnumerableMock.sol @@ -37,11 +37,7 @@ contract ERC721EnumerableMock is ERC721Enumerable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index 74a09233469..a3bc839ae7b 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -27,11 +27,7 @@ contract ERC721Mock is ERC721 { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 8d8e818fb17..753842e902b 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -31,11 +31,7 @@ contract ERC721PausableMock is ERC721Pausable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721RoyaltyMock.sol b/contracts/mocks/ERC721RoyaltyMock.sol index 83a9074e2c1..6f19d5248d2 100644 --- a/contracts/mocks/ERC721RoyaltyMock.sol +++ b/contracts/mocks/ERC721RoyaltyMock.sol @@ -7,11 +7,7 @@ import "../token/ERC721/extensions/ERC721Royalty.sol"; contract ERC721RoyaltyMock is ERC721Royalty { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} - function setTokenRoyalty( - uint256 tokenId, - address recipient, - uint96 fraction - ) public { + function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) public { _setTokenRoyalty(tokenId, recipient, fraction); } diff --git a/contracts/mocks/ERC721URIStorageMock.sol b/contracts/mocks/ERC721URIStorageMock.sol index 60f9f7b7c1a..4bb26b1ada7 100644 --- a/contracts/mocks/ERC721URIStorageMock.sol +++ b/contracts/mocks/ERC721URIStorageMock.sol @@ -41,11 +41,7 @@ contract ERC721URIStorageMock is ERC721URIStorage { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC777Mock.sol b/contracts/mocks/ERC777Mock.sol index f8a3b67849d..59c00b30756 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -18,12 +18,7 @@ contract ERC777Mock is Context, ERC777 { _mint(initialHolder, initialBalance, "", ""); } - function mintInternal( - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) public { + function mintInternal(address to, uint256 amount, bytes memory userData, bytes memory operatorData) public { _mint(to, amount, userData, operatorData); } @@ -37,20 +32,11 @@ contract ERC777Mock is Context, ERC777 { _mint(to, amount, userData, operatorData, requireReceptionAck); } - function approveInternal( - address holder, - address spender, - uint256 value - ) public { + function approveInternal(address holder, address spender, uint256 value) public { _approve(holder, spender, value); } - function _beforeTokenTransfer( - address, - address, - address, - uint256 - ) internal override { + function _beforeTokenTransfer(address, address, address, uint256) internal override { emit BeforeTokenTransfer(); } } diff --git a/contracts/mocks/ERC777SenderRecipientMock.sol b/contracts/mocks/ERC777SenderRecipientMock.sol index 169912f699b..8e8c749ceda 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -141,21 +141,12 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, _shouldRevertReceive = shouldRevert; } - function send( - IERC777 token, - address to, - uint256 amount, - bytes memory data - ) public { + function send(IERC777 token, address to, uint256 amount, bytes memory data) public { // This is 777's send function, not the Solidity send function token.send(to, amount, data); // solhint-disable-line check-send-result } - function burn( - IERC777 token, - uint256 amount, - bytes memory data - ) public { + function burn(IERC777 token, uint256 amount, bytes memory data) public { token.burn(amount, data); } } diff --git a/contracts/mocks/GovernorCompatibilityBravoMock.sol b/contracts/mocks/GovernorCompatibilityBravoMock.sol index 1ef0f94b92e..d3b4f707d16 100644 --- a/contracts/mocks/GovernorCompatibilityBravoMock.sol +++ b/contracts/mocks/GovernorCompatibilityBravoMock.sol @@ -27,12 +27,9 @@ contract GovernorCompatibilityBravoMock is GovernorVotesComp(token_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(IERC165, Governor, GovernorTimelockCompound) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(IERC165, Governor, GovernorTimelockCompound) returns (bool) { return super.supportsInterface(interfaceId); } @@ -40,21 +37,15 @@ contract GovernorCompatibilityBravoMock is return 0; } - function state(uint256 proposalId) - public - view - override(IGovernor, Governor, GovernorTimelockCompound) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(IGovernor, Governor, GovernorTimelockCompound) returns (ProposalState) { return super.state(proposalId); } - function proposalEta(uint256 proposalId) - public - view - override(IGovernorTimelock, GovernorTimelockCompound) - returns (uint256) - { + function proposalEta( + uint256 proposalId + ) public view override(IGovernorTimelock, GovernorTimelockCompound) returns (uint256) { return super.proposalEta(proposalId); } diff --git a/contracts/mocks/GovernorPreventLateQuorumMock.sol b/contracts/mocks/GovernorPreventLateQuorumMock.sol index d868ab22b62..b6b5e761970 100644 --- a/contracts/mocks/GovernorPreventLateQuorumMock.sol +++ b/contracts/mocks/GovernorPreventLateQuorumMock.sol @@ -35,12 +35,9 @@ contract GovernorPreventLateQuorumMock is return _quorum; } - function proposalDeadline(uint256 proposalId) - public - view - override(Governor, GovernorPreventLateQuorum) - returns (uint256) - { + function proposalDeadline( + uint256 proposalId + ) public view override(Governor, GovernorPreventLateQuorum) returns (uint256) { return super.proposalDeadline(proposalId); } diff --git a/contracts/mocks/GovernorTimelockCompoundMock.sol b/contracts/mocks/GovernorTimelockCompoundMock.sol index becc72a06ef..75a2f3c144c 100644 --- a/contracts/mocks/GovernorTimelockCompoundMock.sol +++ b/contracts/mocks/GovernorTimelockCompoundMock.sol @@ -28,21 +28,15 @@ contract GovernorTimelockCompoundMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockCompound) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockCompound) returns (bool) { return super.supportsInterface(interfaceId); } - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -58,12 +52,9 @@ contract GovernorTimelockCompoundMock is /** * Overriding nightmare */ - function state(uint256 proposalId) - public - view - override(Governor, GovernorTimelockCompound) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(Governor, GovernorTimelockCompound) returns (ProposalState) { return super.state(proposalId); } diff --git a/contracts/mocks/GovernorTimelockControlMock.sol b/contracts/mocks/GovernorTimelockControlMock.sol index ca412d1ca60..671a1e0ea03 100644 --- a/contracts/mocks/GovernorTimelockControlMock.sol +++ b/contracts/mocks/GovernorTimelockControlMock.sol @@ -28,21 +28,15 @@ contract GovernorTimelockControlMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index c6b1e872318..be935f91dee 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -21,12 +21,7 @@ contract MathMock { return Math.ceilDiv(a, b); } - function mulDiv( - uint256 a, - uint256 b, - uint256 denominator, - Math.Rounding direction - ) public pure returns (uint256) { + function mulDiv(uint256 a, uint256 b, uint256 denominator, Math.Rounding direction) public pure returns (uint256) { return Math.mulDiv(a, b, denominator, direction); } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index b74459dc890..60741e41c03 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,19 +5,11 @@ pragma solidity ^0.8.0; import "../utils/cryptography/MerkleProof.sol"; contract MerkleProofWrapper { - function verify( - bytes32[] memory proof, - bytes32 root, - bytes32 leaf - ) public pure returns (bool) { + function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) { return MerkleProof.verify(proof, root, leaf); } - function verifyCalldata( - bytes32[] calldata proof, - bytes32 root, - bytes32 leaf - ) public pure returns (bool) { + function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) public pure returns (bool) { return MerkleProof.verifyCalldata(proof, root, leaf); } diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index f6d6440654f..b8cf9d9d5d3 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -108,12 +108,7 @@ contract SampleFather is Initializable, SampleGramps { contract SampleChild is Initializable, SampleMother, SampleFather { uint256 public child; - function initialize( - uint256 _mother, - string memory _gramps, - uint256 _father, - uint256 _child - ) public initializer { + function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer { __SampleChild_init(_mother, _gramps, _father, _child); } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 98fdc644490..237e32041c4 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -19,11 +19,7 @@ contract ERC20ReturnFalseMock is Context { return false; } - function transferFrom( - address, - address, - uint256 - ) public returns (bool) { + function transferFrom(address, address, uint256) public returns (bool) { _dummy = 0; return false; } @@ -51,11 +47,7 @@ contract ERC20ReturnTrueMock is Context { return true; } - function transferFrom( - address, - address, - uint256 - ) public returns (bool) { + function transferFrom(address, address, uint256) public returns (bool) { _dummy = 0; return true; } @@ -85,11 +77,7 @@ contract ERC20NoReturnMock is Context { _dummy = 0; } - function transferFrom( - address, - address, - uint256 - ) public { + function transferFrom(address, address, uint256) public { _dummy = 0; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index 3d1f4727ee5..ef504e3ab90 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -47,27 +47,15 @@ contract SafeMathMock { return SafeMath.mod(a, b); } - function subWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function subWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.sub(a, b, errorMessage); } - function divWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function divWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.div(a, b, errorMessage); } - function modWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function modWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.mod(a, b, errorMessage); } diff --git a/contracts/mocks/SignatureCheckerMock.sol b/contracts/mocks/SignatureCheckerMock.sol index 3b399c1aeaa..5671540ec4a 100644 --- a/contracts/mocks/SignatureCheckerMock.sol +++ b/contracts/mocks/SignatureCheckerMock.sol @@ -7,11 +7,7 @@ import "../utils/cryptography/SignatureChecker.sol"; contract SignatureCheckerMock { using SignatureChecker for address; - function isValidSignatureNow( - address signer, - bytes32 hash, - bytes memory signature - ) public view returns (bool) { + function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) public view returns (bool) { return signer.isValidSignatureNow(hash, signature); } } diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index f1fb3d0b3f3..ba68e604668 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -17,11 +17,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } - function _upgradeToAndCallSecureLegacyV1( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCallSecureLegacyV1(address newImplementation, bytes memory data, bool forceCall) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call diff --git a/contracts/mocks/crosschain/bridges.sol b/contracts/mocks/crosschain/bridges.sol index 35c7f4c0625..41baffed805 100644 --- a/contracts/mocks/crosschain/bridges.sol +++ b/contracts/mocks/crosschain/bridges.sol @@ -12,11 +12,7 @@ abstract contract BaseRelayMock { address internal _currentSender; - function relayAs( - address target, - bytes calldata data, - address sender - ) external virtual { + function relayAs(address target, bytes calldata data, address sender) external virtual { address previousSender = _currentSender; _currentSender = sender; @@ -92,11 +88,7 @@ contract BridgeOptimismMock is BaseRelayMock { * Polygon */ contract BridgePolygonChildMock is BaseRelayMock { - function relayAs( - address target, - bytes calldata data, - address sender - ) external override { + function relayAs(address target, bytes calldata data, address sender) external override { IFxMessageProcessor(target).processMessageFromRoot(0, sender, data); } } diff --git a/contracts/mocks/wizard/MyGovernor1.sol b/contracts/mocks/wizard/MyGovernor1.sol index a80d8400c5e..37ecfd57d8b 100644 --- a/contracts/mocks/wizard/MyGovernor1.sol +++ b/contracts/mocks/wizard/MyGovernor1.sol @@ -14,12 +14,10 @@ contract MyGovernor1 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -31,12 +29,9 @@ contract MyGovernor1 is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -76,12 +71,9 @@ contract MyGovernor1 is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor2.sol b/contracts/mocks/wizard/MyGovernor2.sol index 34c608c5cc2..1472b67d588 100644 --- a/contracts/mocks/wizard/MyGovernor2.sol +++ b/contracts/mocks/wizard/MyGovernor2.sol @@ -16,12 +16,10 @@ contract MyGovernor2 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -37,12 +35,9 @@ contract MyGovernor2 is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -82,12 +77,9 @@ contract MyGovernor2 is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor3.sol b/contracts/mocks/wizard/MyGovernor3.sol index 70e4e87f046..320342290a5 100644 --- a/contracts/mocks/wizard/MyGovernor3.sol +++ b/contracts/mocks/wizard/MyGovernor3.sol @@ -14,12 +14,10 @@ contract MyGovernor is GovernorVotes, GovernorVotesQuorumFraction { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -35,21 +33,15 @@ contract MyGovernor is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } - function state(uint256 proposalId) - public - view - override(Governor, IGovernor, GovernorTimelockControl) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) { return super.state(proposalId); } @@ -85,12 +77,9 @@ contract MyGovernor is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, IERC165, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/proxy/Clones.sol b/contracts/proxy/Clones.sol index 93ea0cec77e..712519892ef 100644 --- a/contracts/proxy/Clones.sol +++ b/contracts/proxy/Clones.sol @@ -79,11 +79,10 @@ library Clones { /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ - function predictDeterministicAddress(address implementation, bytes32 salt) - internal - view - returns (address predicted) - { + function predictDeterministicAddress( + address implementation, + bytes32 salt + ) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } } diff --git a/contracts/proxy/ERC1967/ERC1967Upgrade.sol b/contracts/proxy/ERC1967/ERC1967Upgrade.sol index 31309f63e44..58f65fe881f 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -62,11 +62,7 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCall( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); @@ -78,11 +74,7 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCallUUPS( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. @@ -175,11 +167,7 @@ abstract contract ERC1967Upgrade { * * Emits a {BeaconUpgraded} event. */ - function _upgradeBeaconToAndCall( - address newBeacon, - bytes memory data, - bool forceCall - ) internal { + function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index 57417296d6e..ffc97ff4855 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -31,11 +31,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ - constructor( - address _logic, - address admin_, - bytes memory _data - ) payable ERC1967Proxy(_logic, _data) { + constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index eda19070e3c..c720267340c 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -76,13 +76,10 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch(address[] memory accounts, uint256[] memory ids) - public - view - virtual - override - returns (uint256[] memory) - { + function balanceOfBatch( + address[] memory accounts, + uint256[] memory ids + ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); @@ -207,13 +204,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _safeTransferFrom( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal { + function _safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) internal { require(to != address(0), "ERC1155: transfer to the zero address"); require(from != address(0), "ERC1155: transfer from the zero address"); uint256[] memory ids = _asSingletonArray(id); @@ -277,12 +268,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _mint( - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal { + function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal { require(to != address(0), "ERC1155: mint to the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -300,12 +286,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function _mintBatch( - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal { + function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal { require(to != address(0), "ERC1155: mint to the zero address"); _update(address(0), to, ids, amounts, data); } @@ -320,11 +301,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ - function _burn( - address from, - uint256 id, - uint256 amount - ) internal { + function _burn(address from, uint256 id, uint256 amount) internal { require(from != address(0), "ERC1155: burn from the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -340,11 +317,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `ids` and `amounts` must have the same length. */ - function _burnBatch( - address from, - uint256[] memory ids, - uint256[] memory amounts - ) internal { + function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal { require(from != address(0), "ERC1155: burn from the zero address"); _update(from, address(0), ids, amounts, ""); } @@ -354,11 +327,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll( - address owner, - address operator, - bool approved - ) internal virtual { + function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index 05f74dc4f32..eae0b7029f6 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -60,10 +60,10 @@ interface IERC1155 is IERC165 { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) - external - view - returns (uint256[] memory); + function balanceOfBatch( + address[] calldata accounts, + uint256[] calldata ids + ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, @@ -96,13 +96,7 @@ interface IERC1155 is IERC165 { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function safeTransferFrom( - address from, - address to, - uint256 id, - uint256 amount, - bytes calldata data - ) external; + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index cfaa2359dbd..cc81957a7fe 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -12,11 +12,7 @@ import "../ERC1155.sol"; * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { - function burn( - address account, - uint256 id, - uint256 value - ) public virtual { + function burn(address account, uint256 id, uint256 value) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" @@ -25,11 +21,7 @@ abstract contract ERC1155Burnable is ERC1155 { _burn(account, id, value); } - function burnBatch( - address account, - uint256[] memory ids, - uint256[] memory values - ) public virtual { + function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 261a46f2253..f9be8b68965 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -154,11 +154,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ - function transferFrom( - address from, - address to, - uint256 amount - ) public virtual override returns (bool) { + function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); @@ -218,11 +214,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * NOTE: This function is not virtual, {_update} should be overridden instead. */ - function _transfer( - address from, - address to, - uint256 amount - ) internal { + function _transfer(address from, address to, uint256 amount) internal { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _update(from, to, amount); @@ -234,11 +226,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Emits a {Transfer} event. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual { + function _update(address from, address to, uint256 amount) internal virtual { if (from == address(0)) { _totalSupply += amount; unchecked { @@ -306,11 +294,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ - function _approve( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); @@ -326,11 +310,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Might emit an {Approval} event. */ - function _spendAllowance( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index b816bfed086..66c4e4d88fe 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -74,9 +74,5 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom( - address from, - address to, - uint256 amount - ) external returns (bool); + function transferFrom(address from, address to, uint256 amount) external returns (bool); } diff --git a/contracts/token/ERC20/extensions/ERC20Capped.sol b/contracts/token/ERC20/extensions/ERC20Capped.sol index 3be9ff805d7..d80fb2a4ccd 100644 --- a/contracts/token/ERC20/extensions/ERC20Capped.sol +++ b/contracts/token/ERC20/extensions/ERC20Capped.sol @@ -30,11 +30,7 @@ abstract contract ERC20Capped is ERC20 { /** * @dev See {ERC20-_transfer}. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { if (from == address(0)) { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); } diff --git a/contracts/token/ERC20/extensions/ERC20Pausable.sol b/contracts/token/ERC20/extensions/ERC20Pausable.sol index 92d764932a9..85dd164d37b 100644 --- a/contracts/token/ERC20/extensions/ERC20Pausable.sol +++ b/contracts/token/ERC20/extensions/ERC20Pausable.sol @@ -21,11 +21,7 @@ abstract contract ERC20Pausable is ERC20, Pausable { * * - the contract must not be paused. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { require(!paused(), "ERC20Pausable: token transfer while paused"); super._update(from, to, amount); } diff --git a/contracts/token/ERC20/extensions/ERC20Snapshot.sol b/contracts/token/ERC20/extensions/ERC20Snapshot.sol index 2c34e226809..3bc1a74eecc 100644 --- a/contracts/token/ERC20/extensions/ERC20Snapshot.sol +++ b/contracts/token/ERC20/extensions/ERC20Snapshot.sol @@ -120,11 +120,7 @@ abstract contract ERC20Snapshot is ERC20 { // Update balance and/or total supply snapshots before the values are modified. This is executed // for _mint, _burn, and _transfer operations. - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { if (from == address(0)) { // mint _updateAccountSnapshot(to); diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 7f9f36b7603..225d08c443e 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -35,11 +35,7 @@ abstract contract ERC20Votes is ERC20, Votes { * * Emits a {IVotes-DelegateVotesChanged} event. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { super._update(from, to, amount); if (from == address(0)) { require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); diff --git a/contracts/token/ERC20/extensions/ERC4626.sol b/contracts/token/ERC20/extensions/ERC4626.sol index 3ffcd7bfd5a..9b26aefebed 100644 --- a/contracts/token/ERC20/extensions/ERC4626.sol +++ b/contracts/token/ERC20/extensions/ERC4626.sol @@ -153,11 +153,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-withdraw}. */ - function withdraw( - uint256 assets, - address receiver, - address owner - ) public virtual override returns (uint256) { + function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); @@ -167,11 +163,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-redeem}. */ - function redeem( - uint256 shares, - address receiver, - address owner - ) public virtual override returns (uint256) { + function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); @@ -230,12 +222,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { /** * @dev Deposit/mint common workflow. */ - function _deposit( - address caller, - address receiver, - uint256 assets, - uint256 shares - ) internal virtual { + function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. diff --git a/contracts/token/ERC20/utils/SafeERC20.sol b/contracts/token/ERC20/utils/SafeERC20.sol index bfc381f9b4a..028711ddf29 100644 --- a/contracts/token/ERC20/utils/SafeERC20.sol +++ b/contracts/token/ERC20/utils/SafeERC20.sol @@ -19,20 +19,11 @@ import "../../../utils/Address.sol"; library SafeERC20 { using Address for address; - function safeTransfer( - IERC20 token, - address to, - uint256 value - ) internal { + function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } - function safeTransferFrom( - IERC20 token, - address from, - address to, - uint256 value - ) internal { + function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } @@ -43,11 +34,7 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' @@ -58,20 +45,12 @@ library SafeERC20 { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } - function safeIncreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } - function safeDecreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); diff --git a/contracts/token/ERC20/utils/TokenTimelock.sol b/contracts/token/ERC20/utils/TokenTimelock.sol index d879a7e7d72..ed855b7bcb4 100644 --- a/contracts/token/ERC20/utils/TokenTimelock.sol +++ b/contracts/token/ERC20/utils/TokenTimelock.sol @@ -29,11 +29,7 @@ contract TokenTimelock { * `beneficiary_` when {release} is invoked after `releaseTime_`. The release time is specified as a Unix timestamp * (in seconds). */ - constructor( - IERC20 token_, - address beneficiary_, - uint256 releaseTime_ - ) { + constructor(IERC20 token_, address beneficiary_, uint256 releaseTime_) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 8d8794c23c9..0d159f609f4 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -145,11 +145,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-transferFrom}. */ - function transferFrom( - address from, - address to, - uint256 tokenId - ) public virtual override { + function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); @@ -159,23 +155,14 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) public virtual override { + function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId, - bytes memory data - ) public virtual override { + function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } @@ -198,12 +185,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _safeTransfer( - address from, - address to, - uint256 tokenId, - bytes memory data - ) internal virtual { + function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } @@ -257,11 +239,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ - function _safeMint( - address to, - uint256 tokenId, - bytes memory data - ) internal virtual { + function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), @@ -350,11 +328,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _transfer( - address from, - address to, - uint256 tokenId - ) internal virtual { + function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); @@ -397,11 +371,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll( - address owner, - address operator, - bool approved - ) internal virtual { + function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); @@ -465,7 +435,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { function _beforeTokenTransfer( address from, address to, - uint256, /* firstTokenId */ + uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { @@ -492,10 +462,5 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _afterTokenTransfer( - address from, - address to, - uint256 firstTokenId, - uint256 batchSize - ) internal virtual {} + function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 22020bab0bf..646530aa568 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -51,12 +51,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId, - bytes calldata data - ) external; + function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients @@ -72,11 +67,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) external; + function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. @@ -94,11 +85,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function transferFrom( - address from, - address to, - uint256 tokenId - ) external; + function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index 394926d51ed..cfa533a47b1 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -17,12 +17,7 @@ contract ERC721Holder is IERC721Receiver { * * Always returns `IERC721Receiver.onERC721Received.selector`. */ - function onERC721Received( - address, - address, - uint256, - bytes memory - ) public virtual override returns (bytes4) { + function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 60f4ea1b1a5..679c054f642 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -57,11 +57,7 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev `defaultOperators` may be an empty array. */ - constructor( - string memory name_, - string memory symbol_, - address[] memory defaultOperators_ - ) { + constructor(string memory name_, string memory symbol_, address[] memory defaultOperators_) { _name = name_; _symbol = symbol_; @@ -127,11 +123,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ - function send( - address recipient, - uint256 amount, - bytes memory data - ) public virtual override { + function send(address recipient, uint256 amount, bytes memory data) public virtual override { _send(_msgSender(), recipient, amount, data, "", true); } @@ -272,11 +264,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ - function transferFrom( - address holder, - address recipient, - uint256 amount - ) public virtual override returns (bool) { + function transferFrom(address holder, address recipient, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(holder, spender, amount); _send(holder, recipient, amount, "", "", false); @@ -301,12 +289,7 @@ contract ERC777 is Context, IERC777, IERC20 { * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ - function _mint( - address account, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) internal virtual { + function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData) internal virtual { _mint(account, amount, userData, operatorData, true); } @@ -387,12 +370,7 @@ contract ERC777 is Context, IERC777, IERC20 { * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ - function _burn( - address from, - uint256 amount, - bytes memory data, - bytes memory operatorData - ) internal virtual { + function _burn(address from, uint256 amount, bytes memory data, bytes memory operatorData) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); @@ -439,11 +417,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Note that accounts cannot have allowance issued by their operators. */ - function _approve( - address holder, - address spender, - uint256 value - ) internal virtual { + function _approve(address holder, address spender, uint256 value) internal virtual { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); @@ -513,11 +487,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Might emit an {IERC20-Approval} event. */ - function _spendAllowance( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC777: insufficient allowance"); @@ -541,10 +511,5 @@ contract ERC777 is Context, IERC777, IERC20 { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256 amount - ) internal virtual {} + function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual {} } diff --git a/contracts/token/ERC777/IERC777.sol b/contracts/token/ERC777/IERC777.sol index 2af7771b03e..d3bede62610 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -83,11 +83,7 @@ interface IERC777 { * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ - function send( - address recipient, - uint256 amount, - bytes calldata data - ) external; + function send(address recipient, uint256 amount, bytes calldata data) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the @@ -191,12 +187,7 @@ interface IERC777 { * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ - function operatorBurn( - address account, - uint256 amount, - bytes calldata data, - bytes calldata operatorData - ) external; + function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external; event Sent( address indexed operator, diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index 604dba3046a..84cb6b8deb4 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -91,11 +91,7 @@ abstract contract ERC2981 is IERC2981, ERC165 { * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ - function _setTokenRoyalty( - uint256 tokenId, - address receiver, - uint96 feeNumerator - ) internal virtual { + function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 0da5959d864..e08cdc75492 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -77,11 +77,7 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue( - address target, - bytes memory data, - uint256 value - ) internal returns (bytes memory) { + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } diff --git a/contracts/utils/Checkpoints.sol b/contracts/utils/Checkpoints.sol index f20601c6a81..76203edd2ce 100644 --- a/contracts/utils/Checkpoints.sol +++ b/contracts/utils/Checkpoints.sol @@ -111,15 +111,9 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(History storage self) - internal - view - returns ( - bool exists, - uint32 _blockNumber, - uint224 _value - ) - { + function latestCheckpoint( + History storage self + ) internal view returns (bool exists, uint32 _blockNumber, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -140,11 +134,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint[] storage self, - uint32 key, - uint224 value - ) private returns (uint224, uint224) { + function _insert(Checkpoint[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -237,11 +227,7 @@ library Checkpoints { * * Returns previous value and new value. */ - function push( - Trace224 storage self, - uint32 key, - uint224 value - ) internal returns (uint224, uint224) { + function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } @@ -275,15 +261,7 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace224 storage self) - internal - view - returns ( - bool exists, - uint32 _key, - uint224 _value - ) - { + function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -304,11 +282,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint224[] storage self, - uint32 key, - uint224 value - ) private returns (uint224, uint224) { + function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -380,11 +354,10 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess(Checkpoint224[] storage self, uint256 pos) - private - pure - returns (Checkpoint224 storage result) - { + function _unsafeAccess( + Checkpoint224[] storage self, + uint256 pos + ) private pure returns (Checkpoint224 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) @@ -405,11 +378,7 @@ library Checkpoints { * * Returns previous value and new value. */ - function push( - Trace160 storage self, - uint96 key, - uint160 value - ) internal returns (uint160, uint160) { + function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } @@ -443,15 +412,7 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace160 storage self) - internal - view - returns ( - bool exists, - uint96 _key, - uint160 _value - ) - { + function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -472,11 +433,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint160[] storage self, - uint96 key, - uint160 value - ) private returns (uint160, uint160) { + function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { @@ -548,11 +505,10 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess(Checkpoint160[] storage self, uint256 pos) - private - pure - returns (Checkpoint160 storage result) - { + function _unsafeAccess( + Checkpoint160[] storage self, + uint256 pos + ) private pure returns (Checkpoint160 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index 8df86d66999..2255a4df8b7 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -27,11 +27,7 @@ library Create2 { * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ - function deploy( - uint256 amount, - bytes32 salt, - bytes memory bytecode - ) internal returns (address addr) { + function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly @@ -53,11 +49,7 @@ library Create2 { * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ - function computeAddress( - bytes32 salt, - bytes32 bytecodeHash, - address deployer - ) internal pure returns (address addr) { + function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer diff --git a/contracts/utils/cryptography/ECDSA.sol b/contracts/utils/cryptography/ECDSA.sol index 4b1d66b092d..3f996520efd 100644 --- a/contracts/utils/cryptography/ECDSA.sol +++ b/contracts/utils/cryptography/ECDSA.sol @@ -98,11 +98,7 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address, RecoverError) { + function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); @@ -113,11 +109,7 @@ library ECDSA { * * _Available since v4.2._ */ - function recover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address) { + function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; @@ -129,12 +121,7 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) internal pure returns (address, RecoverError) { + function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most @@ -161,12 +148,7 @@ library ECDSA { * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ - function recover( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) internal pure returns (address) { + function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index 47c60eb0118..0ce87faf283 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -24,11 +24,7 @@ library MerkleProof { * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ - function verify( - bytes32[] memory proof, - bytes32 root, - bytes32 leaf - ) internal pure returns (bool) { + function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } @@ -37,11 +33,7 @@ library MerkleProof { * * _Available since v4.7._ */ - function verifyCalldata( - bytes32[] calldata proof, - bytes32 root, - bytes32 leaf - ) internal pure returns (bool) { + function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } diff --git a/contracts/utils/cryptography/SignatureChecker.sol b/contracts/utils/cryptography/SignatureChecker.sol index 77fe98282bf..e06778debd7 100644 --- a/contracts/utils/cryptography/SignatureChecker.sol +++ b/contracts/utils/cryptography/SignatureChecker.sol @@ -21,11 +21,7 @@ library SignatureChecker { * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ - function isValidSignatureNow( - address signer, - bytes32 hash, - bytes memory signature - ) internal view returns (bool) { + function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; diff --git a/contracts/utils/introspection/ERC165Checker.sol b/contracts/utils/introspection/ERC165Checker.sol index 4c5fe2092df..40ffd68f73f 100644 --- a/contracts/utils/introspection/ERC165Checker.sol +++ b/contracts/utils/introspection/ERC165Checker.sol @@ -48,11 +48,10 @@ library ERC165Checker { * * _Available since v3.4._ */ - function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) - internal - view - returns (bool[] memory) - { + function getSupportedInterfaces( + address account, + bytes4[] memory interfaceIds + ) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); diff --git a/contracts/utils/introspection/ERC1820Implementer.sol b/contracts/utils/introspection/ERC1820Implementer.sol index 1b5139658bd..ac5a884c02a 100644 --- a/contracts/utils/introspection/ERC1820Implementer.sol +++ b/contracts/utils/introspection/ERC1820Implementer.sol @@ -21,13 +21,10 @@ contract ERC1820Implementer is IERC1820Implementer { /** * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) - public - view - virtual - override - returns (bytes32) - { + function canImplementInterfaceForAddress( + bytes32 interfaceHash, + address account + ) public view virtual override returns (bytes32) { return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00); } diff --git a/contracts/utils/introspection/IERC1820Registry.sol b/contracts/utils/introspection/IERC1820Registry.sol index 42cf46a8ae8..a146bc2a68b 100644 --- a/contracts/utils/introspection/IERC1820Registry.sol +++ b/contracts/utils/introspection/IERC1820Registry.sol @@ -64,11 +64,7 @@ interface IERC1820Registry { * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function setInterfaceImplementer( - address account, - bytes32 _interfaceHash, - address implementer - ) external; + function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such diff --git a/contracts/utils/math/Math.sol b/contracts/utils/math/Math.sol index 0ed5460e05f..f3a83b0ffab 100644 --- a/contracts/utils/math/Math.sol +++ b/contracts/utils/math/Math.sol @@ -52,11 +52,7 @@ library Math { * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ - function mulDiv( - uint256 x, - uint256 y, - uint256 denominator - ) internal pure returns (uint256 result) { + function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 @@ -137,12 +133,7 @@ library Math { /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ - function mulDiv( - uint256 x, - uint256 y, - uint256 denominator, - Rounding rounding - ) internal pure returns (uint256) { + function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; @@ -258,31 +249,31 @@ library Math { function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { - if (value >= 10**64) { - value /= 10**64; + if (value >= 10 ** 64) { + value /= 10 ** 64; result += 64; } - if (value >= 10**32) { - value /= 10**32; + if (value >= 10 ** 32) { + value /= 10 ** 32; result += 32; } - if (value >= 10**16) { - value /= 10**16; + if (value >= 10 ** 16) { + value /= 10 ** 16; result += 16; } - if (value >= 10**8) { - value /= 10**8; + if (value >= 10 ** 8) { + value /= 10 ** 8; result += 8; } - if (value >= 10**4) { - value /= 10**4; + if (value >= 10 ** 4) { + value /= 10 ** 4; result += 4; } - if (value >= 10**2) { - value /= 10**2; + if (value >= 10 ** 2) { + value /= 10 ** 2; result += 2; } - if (value >= 10**1) { + if (value >= 10 ** 1) { result += 1; } } @@ -296,7 +287,7 @@ library Math { function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); - return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); + return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } diff --git a/contracts/utils/math/SafeMath.sol b/contracts/utils/math/SafeMath.sol index 550f0e779b1..2f48fb7360a 100644 --- a/contracts/utils/math/SafeMath.sol +++ b/contracts/utils/math/SafeMath.sol @@ -165,11 +165,7 @@ library SafeMath { * * - Subtraction cannot overflow. */ - function sub( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; @@ -188,11 +184,7 @@ library SafeMath { * * - The divisor cannot be zero. */ - function div( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; @@ -214,11 +206,7 @@ library SafeMath { * * - The divisor cannot be zero. */ - function mod( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index a2ddc47098f..eb67bfab081 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -23,11 +23,7 @@ library BitMaps { /** * @dev Sets the bit at `index` to the boolean `value`. */ - function setTo( - BitMap storage bitmap, - uint256 index, - bool value - ) internal { + function setTo(BitMap storage bitmap, uint256 index, bool value) internal { if (value) { set(bitmap, index); } else { diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index a3fda61d802..d359671f461 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -70,11 +70,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - Bytes32ToBytes32Map storage map, - bytes32 key, - bytes32 value - ) internal returns (bool) { + function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } @@ -173,11 +169,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - UintToUintMap storage map, - uint256 key, - uint256 value - ) internal returns (bool) { + function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } @@ -244,11 +236,7 @@ library EnumerableMap { * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ - function get( - UintToUintMap storage map, - uint256 key, - string memory errorMessage - ) internal view returns (uint256) { + function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } @@ -265,11 +253,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - UintToAddressMap storage map, - uint256 key, - address value - ) internal returns (bool) { + function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } @@ -357,11 +341,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - AddressToUintMap storage map, - address key, - uint256 value - ) internal returns (bool) { + function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } @@ -449,11 +429,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - Bytes32ToUintMap storage map, - bytes32 key, - uint256 value - ) internal returns (bool) { + function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { return set(map._inner, key, bytes32(value)); } diff --git a/contracts/vendor/amb/IAMB.sol b/contracts/vendor/amb/IAMB.sol index 1a5d7080f8b..73a2bd24bcb 100644 --- a/contracts/vendor/amb/IAMB.sol +++ b/contracts/vendor/amb/IAMB.sol @@ -31,17 +31,9 @@ interface IAMB { function failedMessageSender(bytes32 _messageId) external view returns (address); - function requireToPassMessage( - address _contract, - bytes calldata _data, - uint256 _gas - ) external returns (bytes32); - - function requireToConfirmMessage( - address _contract, - bytes calldata _data, - uint256 _gas - ) external returns (bytes32); + function requireToPassMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); + + function requireToConfirmMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); function sourceChainId() external view returns (uint256); diff --git a/contracts/vendor/arbitrum/IArbSys.sol b/contracts/vendor/arbitrum/IArbSys.sol index aac5dd53a9e..9b79d5c16a2 100644 --- a/contracts/vendor/arbitrum/IArbSys.sol +++ b/contracts/vendor/arbitrum/IArbSys.sol @@ -92,14 +92,7 @@ interface IArbSys { * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ - function sendMerkleTreeState() - external - view - returns ( - uint256 size, - bytes32 root, - bytes32[] memory partials - ); + function sendMerkleTreeState() external view returns (uint256 size, bytes32 root, bytes32[] memory partials); /** * @notice creates a send txn from L2 to L1 diff --git a/contracts/vendor/arbitrum/IBridge.sol b/contracts/vendor/arbitrum/IBridge.sol index 7518f5d13cc..e71bedce012 100644 --- a/contracts/vendor/arbitrum/IBridge.sol +++ b/contracts/vendor/arbitrum/IBridge.sol @@ -77,14 +77,7 @@ interface IBridge { uint256 afterDelayedMessagesRead, uint256 prevMessageCount, uint256 newMessageCount - ) - external - returns ( - uint256 seqMessageIndex, - bytes32 beforeAcc, - bytes32 delayedAcc, - bytes32 acc - ); + ) external returns (uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc); /** * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type diff --git a/contracts/vendor/arbitrum/IOutbox.sol b/contracts/vendor/arbitrum/IOutbox.sol index 4f809dbf43e..22fa58f405a 100644 --- a/contracts/vendor/arbitrum/IOutbox.sol +++ b/contracts/vendor/arbitrum/IOutbox.sol @@ -113,9 +113,5 @@ interface IOutbox { bytes calldata data ) external pure returns (bytes32); - function calculateMerkleRoot( - bytes32[] memory proof, - uint256 path, - bytes32 item - ) external pure returns (bytes32); + function calculateMerkleRoot(bytes32[] memory proof, uint256 path, bytes32 item) external pure returns (bytes32); } diff --git a/contracts/vendor/optimism/ICrossDomainMessenger.sol b/contracts/vendor/optimism/ICrossDomainMessenger.sol index 9cc797701bf..cc01a48ab9a 100644 --- a/contracts/vendor/optimism/ICrossDomainMessenger.sol +++ b/contracts/vendor/optimism/ICrossDomainMessenger.sol @@ -30,9 +30,5 @@ interface ICrossDomainMessenger { * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ - function sendMessage( - address _target, - bytes calldata _message, - uint32 _gasLimit - ) external; + function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external; } diff --git a/contracts/vendor/polygon/IFxMessageProcessor.sol b/contracts/vendor/polygon/IFxMessageProcessor.sol index 9f42eb64709..be73e6f53cd 100644 --- a/contracts/vendor/polygon/IFxMessageProcessor.sol +++ b/contracts/vendor/polygon/IFxMessageProcessor.sol @@ -3,9 +3,5 @@ pragma solidity ^0.8.0; interface IFxMessageProcessor { - function processMessageFromRoot( - uint256 stateId, - address rootMessageSender, - bytes calldata data - ) external; + function processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes calldata data) external; } diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index c1c6f447d3a..5542baf9d94 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -70,16 +70,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf2Bigger(result + 1, input)); } else { - assertEq(2**result, input); + assertEq(2 ** result, input); } } function _powerOf2Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 256 || 2**value > ref; // 2**256 overflows uint256 + return value >= 256 || 2 ** value > ref; // 2**256 overflows uint256 } function _powerOf2Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 2**value < ref; + return 2 ** value < ref; } // LOG10 @@ -97,16 +97,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf10Bigger(result + 1, input)); } else { - assertEq(10**result, input); + assertEq(10 ** result, input); } } function _powerOf10Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 78 || 10**value > ref; // 10**78 overflows uint256 + return value >= 78 || 10 ** value > ref; // 10**78 overflows uint256 } function _powerOf10Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 10**value < ref; + return 10 ** value < ref; } // LOG256 @@ -124,24 +124,20 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf256Bigger(result + 1, input)); } else { - assertEq(256**result, input); + assertEq(256 ** result, input); } } function _powerOf256Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 32 || 256**value > ref; // 256**32 overflows uint256 + return value >= 32 || 256 ** value > ref; // 256**32 overflows uint256 } function _powerOf256Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 256**value < ref; + return 256 ** value < ref; } // MULDIV - function testMulDiv( - uint256 x, - uint256 y, - uint256 d - ) public { + function testMulDiv(uint256 x, uint256 y, uint256 d) public { // Full precision for x * y (uint256 xyHi, uint256 xyLo) = _mulHighLow(x, y); @@ -163,11 +159,7 @@ contract MathTest is Test { assertEq(xyLo, qdRemLo); } - function testMulDivDomain( - uint256 x, - uint256 y, - uint256 d - ) public { + function testMulDivDomain(uint256 x, uint256 y, uint256 d) public { (uint256 xyHi, ) = _mulHighLow(x, y); // Violate {testMulDiv} assumption (covers d is 0 and result overflow) @@ -180,11 +172,7 @@ contract MathTest is Test { } // External call - function muldiv( - uint256 x, - uint256 y, - uint256 d - ) external pure returns (uint256) { + function muldiv(uint256 x, uint256 y, uint256 d) external pure returns (uint256) { return Math.mulDiv(x, y, d); } @@ -194,11 +182,7 @@ contract MathTest is Test { return Math.Rounding(r); } - function _mulmod( - uint256 x, - uint256 y, - uint256 z - ) private pure returns (uint256 r) { + function _mulmod(uint256 x, uint256 y, uint256 z) private pure returns (uint256 r) { assembly { r := mulmod(x, y, z) } From df7ff4624baeeb09c882c79e0a4b3861e5a28c2e Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 12 Jan 2023 11:34:49 -0400 Subject: [PATCH 06/19] Update contracts/token/ERC777/ERC777.sol Co-authored-by: Francisco --- contracts/token/ERC777/ERC777.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 679c054f642..1f426c3baec 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -473,7 +473,7 @@ contract ERC777 is Context, IERC777, IERC20 { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); } else if (requireReceptionAck) { require( - !(to.code.length > 0), + to.code.length == 0, "ERC777: token recipient contract has no implementer for ERC777TokensRecipient" ); } From aa1a1580fd9ea2915a40a8c0a35bbde8e2fe15bd Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 12 Jan 2023 11:34:55 -0400 Subject: [PATCH 07/19] Update contracts/token/ERC721/extensions/ERC721Consecutive.sol Co-authored-by: Francisco --- contracts/token/ERC721/extensions/ERC721Consecutive.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index 4e32c2344f2..fe67032efa6 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -86,7 +86,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { // minting a batch of size 0 is a no-op if (batchSize > 0) { - require(!(address(this).code.length > 0), "ERC721Consecutive: batch minting restricted to constructor"); + require(address(this).code.length == 0, "ERC721Consecutive: batch minting restricted to constructor"); require(to != address(0), "ERC721Consecutive: mint to the zero address"); require(batchSize <= _maxBatchSize(), "ERC721Consecutive: batch too large"); From 3e9c380aa2ffc02281967b5091ad7a45825ca547 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 12 Jan 2023 11:35:00 -0400 Subject: [PATCH 08/19] Update contracts/proxy/utils/Initializable.sol Co-authored-by: Francisco --- contracts/proxy/utils/Initializable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/proxy/utils/Initializable.sol b/contracts/proxy/utils/Initializable.sol index c87e2a9008e..4ad0b9826b8 100644 --- a/contracts/proxy/utils/Initializable.sol +++ b/contracts/proxy/utils/Initializable.sol @@ -83,7 +83,7 @@ abstract contract Initializable { modifier initializer() { bool isTopLevelCall = !_initializing; require( - (isTopLevelCall && _initialized < 1) || (!(address(this).code.length > 0) && _initialized == 1), + (isTopLevelCall && _initialized < 1) || (address(this).code.length == 0 && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; From c484d047c521045161f8bfea51389ca70dbb932b Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 12 Jan 2023 14:30:20 -0400 Subject: [PATCH 09/19] add documentation --- docs/modules/ROOT/pages/knowledge.adoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/modules/ROOT/pages/knowledge.adoc diff --git a/docs/modules/ROOT/pages/knowledge.adoc b/docs/modules/ROOT/pages/knowledge.adoc new file mode 100644 index 00000000000..b784aeb67b9 --- /dev/null +++ b/docs/modules/ROOT/pages/knowledge.adoc @@ -0,0 +1,14 @@ +Can I restrict a function to EOAs only? + +It is possible to restrict a function to an EOA only by learning to differentiate it from a contract address. When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. + +Some criteria to discard an address as a contract address can be: + + - an externally-owned account, meaning, an address with no code + - a contract in construction address + - an address where a contract will be created + - an address where a contract lived, but was destroyed + +Furthermore, a contract address can still be considered a contract if the target contract within the same transaction is already scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of a transaction. + +Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. From 0fb4423bd400da7c71cebb42db319a4ce5bec674 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 12 Jan 2023 16:11:32 -0400 Subject: [PATCH 10/19] Update nav --- docs/modules/ROOT/nav.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 6604c2de58f..e9b27662d12 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -19,3 +19,5 @@ * xref:crosschain.adoc[Crosschain] * xref:utilities.adoc[Utilities] + +* xref:knowledge.adoc[Knowledge] From 23b8f57576a66f30481bf3ef02fd48b9f957312b Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 16 Jan 2023 08:47:02 -0400 Subject: [PATCH 11/19] Update documentation --- docs/modules/ROOT/nav.adoc | 2 +- docs/modules/ROOT/pages/faq.adoc | 14 ++++++++++++++ docs/modules/ROOT/pages/knowledge.adoc | 14 -------------- 3 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 docs/modules/ROOT/pages/faq.adoc delete mode 100644 docs/modules/ROOT/pages/knowledge.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index e9b27662d12..a6249d3345b 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -20,4 +20,4 @@ * xref:utilities.adoc[Utilities] -* xref:knowledge.adoc[Knowledge] +* xref:fag.adoc[FAQ] diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc new file mode 100644 index 00000000000..9460db97b53 --- /dev/null +++ b/docs/modules/ROOT/pages/faq.adoc @@ -0,0 +1,14 @@ +Can I restrict a function to EOAs only? + +When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. + +Some criteria to discard an address as a contract address can be: + + - an address with no code + - a contract in construction address + - an address where a contract will be created + - an address where a contract lived, but was destroyed + +Furthermore, a contract address can still be considered a contract if the target contract within the same transaction is already scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of a transaction. +Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA. + diff --git a/docs/modules/ROOT/pages/knowledge.adoc b/docs/modules/ROOT/pages/knowledge.adoc deleted file mode 100644 index b784aeb67b9..00000000000 --- a/docs/modules/ROOT/pages/knowledge.adoc +++ /dev/null @@ -1,14 +0,0 @@ -Can I restrict a function to EOAs only? - -It is possible to restrict a function to an EOA only by learning to differentiate it from a contract address. When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. - -Some criteria to discard an address as a contract address can be: - - - an externally-owned account, meaning, an address with no code - - a contract in construction address - - an address where a contract will be created - - an address where a contract lived, but was destroyed - -Furthermore, a contract address can still be considered a contract if the target contract within the same transaction is already scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of a transaction. - -Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. From 79814747e28ac52a9437dcabb4f377acb0c2d31d Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 23 Jan 2023 15:08:58 -0400 Subject: [PATCH 12/19] Update faq.adoc --- docs/modules/ROOT/pages/faq.adoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 9460db97b53..3bbffe7ffca 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -2,13 +2,10 @@ Can I restrict a function to EOAs only? When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. -Some criteria to discard an address as a contract address can be: +Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA.Some counterexamples are: - - an address with no code - a contract in construction address - an address where a contract will be created - an address where a contract lived, but was destroyed Furthermore, a contract address can still be considered a contract if the target contract within the same transaction is already scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of a transaction. -Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA. - From ba6ca2093f01403672d52b77efa266945abf81bc Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 24 Jan 2023 09:30:09 -0400 Subject: [PATCH 13/19] Update docs/modules/ROOT/pages/faq.adoc Co-authored-by: Hadrien Croubois --- docs/modules/ROOT/pages/faq.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 3bbffe7ffca..625b30c7e86 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -2,7 +2,7 @@ Can I restrict a function to EOAs only? When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. -Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA.Some counterexamples are: +Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA. Some counterexamples are: - a contract in construction address - an address where a contract will be created From 300f4ff1f5ce178d25ae5f3429d62622a9e4dfcd Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 24 Jan 2023 11:21:24 -0400 Subject: [PATCH 14/19] Create changeset --- .changeset/unlucky-snakes-drive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/unlucky-snakes-drive.md diff --git a/.changeset/unlucky-snakes-drive.md b/.changeset/unlucky-snakes-drive.md new file mode 100644 index 00000000000..3dcb2b949df --- /dev/null +++ b/.changeset/unlucky-snakes-drive.md @@ -0,0 +1,5 @@ +--- +"@fake-scope/fake-pkg": patch +--- + +`Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. ([#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945)) From f8d0f400259710c2126028ff4d8f6bae7459ccde Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 24 Jan 2023 17:50:28 -0300 Subject: [PATCH 15/19] fix changeset package name --- .changeset/unlucky-snakes-drive.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/unlucky-snakes-drive.md b/.changeset/unlucky-snakes-drive.md index 3dcb2b949df..4c09e184f9f 100644 --- a/.changeset/unlucky-snakes-drive.md +++ b/.changeset/unlucky-snakes-drive.md @@ -1,5 +1,5 @@ --- -"@fake-scope/fake-pkg": patch +'openzeppelin-solidity': patch --- `Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. ([#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945)) From 46d68bf93247b1fdde166db67ecf78f1017ca49d Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 24 Jan 2023 17:51:44 -0300 Subject: [PATCH 16/19] remove from changelog since there is a changeset --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43fbf0c3ba6..7b21c1d6189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ * `ProxyAdmin`: Removed `getProxyAdmin` and `getProxyImplementation` getters. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) * `ERC20`, `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, added a new internal `_update` function for customizations, and refactored all extensions using those hooks to use `_update` instead. ([#3838](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3838), [#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876)) * `ERC165Storage`: Removed this contract in favor of inheritance based approach. ([#3880](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3880)) - * `Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. ([#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945)) ### How to upgrade from 4.x From e6977665c29bcb510f2542738db3dfec383f9482 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 24 Jan 2023 17:52:05 -0300 Subject: [PATCH 17/19] remove pr link from changeset --- .changeset/unlucky-snakes-drive.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/unlucky-snakes-drive.md b/.changeset/unlucky-snakes-drive.md index 4c09e184f9f..d4c78dd50b1 100644 --- a/.changeset/unlucky-snakes-drive.md +++ b/.changeset/unlucky-snakes-drive.md @@ -2,4 +2,4 @@ 'openzeppelin-solidity': patch --- -`Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. ([#3945](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3945)) +`Address`: Removed `isContract` because of its ambiguous nature and potential for misuse. From 33b55af8e0b9783764d71c735bf10df31fac50de Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 24 Jan 2023 17:53:32 -0300 Subject: [PATCH 18/19] add faq titles --- docs/modules/ROOT/pages/faq.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 625b30c7e86..3d64b83d15f 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -1,4 +1,6 @@ -Can I restrict a function to EOAs only? += Frequently Asked Questions + +== Can I restrict a function to EOAs only? When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. From 91802e57711d12f296f0319ab2e59fd383f2d8ff Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 24 Jan 2023 17:57:52 -0300 Subject: [PATCH 19/19] tweak wording --- docs/modules/ROOT/pages/faq.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 3d64b83d15f..81c34bbf562 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -2,12 +2,12 @@ == Can I restrict a function to EOAs only? -When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. +When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Attempting to prevent calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor. Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA. Some counterexamples are: - - a contract in construction address - - an address where a contract will be created - - an address where a contract lived, but was destroyed + - address of a contract in construction + - address where a contract will be created + - address where a contract lived, but was destroyed -Furthermore, a contract address can still be considered a contract if the target contract within the same transaction is already scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of a transaction. +Furthermore, an address will be considered a contract within the same transaction where it is scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of the entire transaction.