From b0cf6fbb7a70f31527f36579ad644e1cf12fdf4e Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Mon, 7 Jun 2021 17:33:03 +0200 Subject: [PATCH] Add Prettier for linting and fix Solhint config (#2697) Co-authored-by: Francisco Giordano --- .prettierrc | 11 + .solhint.json | 17 +- contracts/access/AccessControl.sol | 29 +- contracts/access/AccessControlEnumerable.sol | 6 +- contracts/access/Ownable.sol | 3 +- contracts/finance/PaymentSplitter.sol | 7 +- contracts/governance/TimelockController.sol | 79 +- contracts/interfaces/IERC1271.sol | 12 +- contracts/interfaces/IERC3156.sol | 11 +- contracts/metatx/ERC2771Context.sol | 8 +- contracts/metatx/MinimalForwarder.sol | 26 +- contracts/mocks/AddressImpl.sol | 8 +- contracts/mocks/ArraysImpl.sol | 2 +- contracts/mocks/BadBeacon.sol | 3 +- contracts/mocks/ClashingImplementation.sol | 14 +- contracts/mocks/ClonesMock.sol | 6 +- contracts/mocks/ContextMock.sol | 6 +- contracts/mocks/Create2Impl.sol | 13 +- contracts/mocks/DummyImplementation.sol | 76 +- contracts/mocks/EIP712External.sol | 15 +- contracts/mocks/ERC1155BurnableMock.sol | 9 +- contracts/mocks/ERC1155Mock.sol | 30 +- contracts/mocks/ERC1155PausableMock.sol | 6 +- contracts/mocks/ERC1155ReceiverMock.sol | 17 +- contracts/mocks/ERC1155SupplyMock.sol | 28 +- .../ERC165/ERC165InterfacesSupported.sol | 4 +- contracts/mocks/ERC165/ERC165NotSupported.sol | 2 +- contracts/mocks/ERC165Mock.sol | 3 +- contracts/mocks/ERC20BurnableMock.sol | 2 +- contracts/mocks/ERC20CappedMock.sol | 8 +- contracts/mocks/ERC20DecimalsMock.sol | 8 +- contracts/mocks/ERC20FlashMintMock.sol | 3 +- contracts/mocks/ERC20Mock.sol | 14 +- contracts/mocks/ERC20PausableMock.sol | 2 +- contracts/mocks/ERC20PermitMock.sol | 3 +- contracts/mocks/ERC20SnapshotMock.sol | 1 - contracts/mocks/ERC20VotesCompMock.sol | 6 +- contracts/mocks/ERC20VotesMock.sol | 6 +- contracts/mocks/ERC2771ContextMock.sol | 4 +- contracts/mocks/ERC3156FlashBorrowerMock.sol | 7 +- contracts/mocks/ERC721BurnableMock.sol | 8 +- contracts/mocks/ERC721EnumerableMock.sol | 8 +- contracts/mocks/ERC721Mock.sol | 8 +- contracts/mocks/ERC721PausableMock.sol | 8 +- contracts/mocks/ERC721ReceiverMock.sol | 11 +- contracts/mocks/ERC721URIStorageMock.sol | 8 +- contracts/mocks/ERC777Mock.sol | 17 +- contracts/mocks/ERC777SenderRecipientMock.sol | 17 +- contracts/mocks/EnumerableMapMock.sol | 1 - contracts/mocks/EtherReceiverMock.sol | 2 +- contracts/mocks/InitializableMock.sol | 36 +- contracts/mocks/MerkleProofWrapper.sol | 6 +- contracts/mocks/MulticallTest.sol | 10 +- contracts/mocks/MulticallTokenMock.sol | 2 +- .../MultipleInheritanceInitializableMocks.sol | 55 +- contracts/mocks/OwnableMock.sol | 2 +- contracts/mocks/PausableMock.sol | 2 +- contracts/mocks/PullPaymentMock.sol | 2 +- contracts/mocks/ReentrancyAttack.sol | 4 +- contracts/mocks/ReentrancyMock.sol | 5 +- contracts/mocks/RegressionImplementation.sol | 69 +- contracts/mocks/SafeCastMock.sol | 32 +- contracts/mocks/SafeERC20Helper.sol | 24 +- contracts/mocks/SafeMathMock.sol | 89 +- contracts/mocks/SignatureCheckerMock.sol | 6 +- .../SingleInheritanceInitializableMocks.sol | 40 +- contracts/mocks/StorageSlotMock.sol | 40 +- contracts/mocks/StringsMock.sol | 2 + contracts/mocks/UUPS/TestInProd.sol | 1 - contracts/proxy/Clones.sol | 15 +- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 28 +- contracts/proxy/Proxy.sol | 16 +- contracts/proxy/transparent/ProxyAdmin.sol | 7 +- .../TransparentUpgradeableProxy.sol | 6 +- contracts/proxy/utils/Initializable.sol | 2 - contracts/security/Pausable.sol | 2 +- contracts/security/PullPayment.sol | 6 +- contracts/security/ReentrancyGuard.sol | 2 +- contracts/token/ERC1155/ERC1155.sol | 87 +- contracts/token/ERC1155/IERC1155.sol | 29 +- contracts/token/ERC1155/IERC1155Receiver.sol | 9 +- .../ERC1155/extensions/ERC1155Burnable.sol | 12 +- .../ERC1155/extensions/ERC1155Pausable.sol | 6 +- .../ERC1155/extensions/ERC1155Supply.sol | 30 +- .../presets/ERC1155PresetMinterPauser.sol | 26 +- .../token/ERC1155/utils/ERC1155Holder.sol | 16 +- .../token/ERC1155/utils/ERC1155Receiver.sol | 3 +- contracts/token/ERC20/ERC20.sol | 30 +- contracts/token/ERC20/IERC20.sol | 6 +- .../token/ERC20/extensions/ERC20Capped.sol | 4 +- .../token/ERC20/extensions/ERC20FlashMint.sol | 11 +- .../token/ERC20/extensions/ERC20Pausable.sol | 6 +- .../token/ERC20/extensions/ERC20Snapshot.sol | 42 +- .../token/ERC20/extensions/ERC20Votes.sol | 66 +- .../token/ERC20/extensions/ERC20VotesComp.sol | 1 + .../ERC20/extensions/draft-ERC20Permit.sol | 30 +- .../ERC20/extensions/draft-IERC20Permit.sol | 10 +- .../ERC20/presets/ERC20PresetMinterPauser.sol | 6 +- contracts/token/ERC20/utils/SafeERC20.sol | 39 +- contracts/token/ERC20/utils/TokenTimelock.sol | 14 +- contracts/token/ERC721/ERC721.sol | 85 +- contracts/token/ERC721/IERC721.sol | 43 +- contracts/token/ERC721/IERC721Receiver.sol | 7 +- .../ERC721/extensions/ERC721Enumerable.sol | 9 +- .../ERC721/extensions/ERC721Pausable.sol | 6 +- .../ERC721/extensions/ERC721URIStorage.sol | 2 +- .../ERC721/extensions/IERC721Enumerable.sol | 1 - .../ERC721/extensions/IERC721Metadata.sol | 1 - .../ERC721PresetMinterPauserAutoId.sol | 28 +- contracts/token/ERC721/utils/ERC721Holder.sol | 20 +- contracts/token/ERC777/ERC777.sol | 99 +- contracts/token/ERC777/IERC777.sol | 6 +- contracts/utils/Address.sol | 53 +- contracts/utils/Arrays.sol | 2 +- contracts/utils/Create2.sol | 17 +- contracts/utils/Multicall.sol | 6 +- contracts/utils/Strings.sol | 5 +- contracts/utils/cryptography/ECDSA.sol | 14 +- contracts/utils/cryptography/MerkleProof.sol | 6 +- .../utils/cryptography/SignatureChecker.sol | 6 +- contracts/utils/cryptography/draft-EIP712.sol | 21 +- contracts/utils/escrow/Escrow.sol | 26 +- contracts/utils/escrow/RefundEscrow.sol | 12 +- .../utils/introspection/ERC165Checker.sol | 14 +- .../introspection/ERC1820Implementer.sol | 8 +- .../utils/introspection/IERC1820Registry.sol | 6 +- contracts/utils/math/Math.sol | 2 +- contracts/utils/math/SafeCast.sol | 24 +- contracts/utils/math/SafeMath.sol | 18 +- contracts/utils/structs/EnumerableMap.sol | 65 +- contracts/utils/structs/EnumerableSet.sol | 87 +- hardhat.config.js | 1 - package-lock.json | 1035 ++++++----------- package.json | 10 +- 134 files changed, 1816 insertions(+), 1526 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..5c11cc223 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "overrides": [ + { + "files": "*.sol", + "options": { + "printWidth": 120, + "explicitTypes": "always" + } + } + ] +} diff --git a/.solhint.json b/.solhint.json index 072ceedcc..ed0a5d3de 100644 --- a/.solhint.json +++ b/.solhint.json @@ -1,12 +1,15 @@ { - "extends": "solhint:recommended", "rules": { - "func-order": "off", - "mark-callable-contracts": "off", - "no-empty-blocks": "off", - "compiler-version": "off", + "no-unused-vars": "error", "private-vars-leading-underscore": "error", - "reason-string": "off", - "func-visibility": ["error", { "ignoreConstructors": true }] + "const-name-snakecase": "error", + "contract-name-camelcase": "error", + "event-name-camelcase": "error", + "func-name-mixedcase": "error", + "func-param-name-mixedcase": "error", + "modifier-name-mixedcase": "error", + "private-vars-leading-underscore": "error", + "var-name-mixedcase": "error", + "imports-on-top": "error" } } diff --git a/contracts/access/AccessControl.sol b/contracts/access/AccessControl.sol index cf62500f8..3f52b8c38 100644 --- a/contracts/access/AccessControl.sol +++ b/contracts/access/AccessControl.sol @@ -11,9 +11,13 @@ import "../utils/introspection/ERC165.sol"; */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); + function getRoleAdmin(bytes32 role) external view returns (bytes32); + function grantRole(bytes32 role, address account) external; + function revokeRole(bytes32 role, address account) external; + function renounceRole(bytes32 role, address account) external; } @@ -57,11 +61,11 @@ interface IAccessControl { */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { - mapping (address => bool) members; + mapping(address => bool) members; bytes32 adminRole; } - mapping (bytes32 => RoleData) private _roles; + mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; @@ -111,8 +115,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 { * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(IAccessControl).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** @@ -130,13 +133,17 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 { * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { - if(!hasRole(role, account)) { - revert(string(abi.encodePacked( - "AccessControl: account ", - Strings.toHexString(uint160(account), 20), - " is missing role ", - Strings.toHexString(uint256(role), 32) - ))); + if (!hasRole(role, account)) { + revert( + string( + abi.encodePacked( + "AccessControl: account ", + Strings.toHexString(uint160(account), 20), + " is missing role ", + Strings.toHexString(uint256(role), 32) + ) + ) + ); } } diff --git a/contracts/access/AccessControlEnumerable.sol b/contracts/access/AccessControlEnumerable.sol index c1522aa1a..64bb9a738 100644 --- a/contracts/access/AccessControlEnumerable.sol +++ b/contracts/access/AccessControlEnumerable.sol @@ -10,6 +10,7 @@ import "../utils/structs/EnumerableSet.sol"; */ interface IAccessControlEnumerable { function getRoleMember(bytes32 role, uint256 index) external view returns (address); + function getRoleMemberCount(bytes32 role) external view returns (uint256); } @@ -19,14 +20,13 @@ interface IAccessControlEnumerable { abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; - mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; + mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(IAccessControlEnumerable).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** diff --git a/contracts/access/Ownable.sol b/contracts/access/Ownable.sol index bdad22b22..ec2ac0785 100644 --- a/contracts/access/Ownable.sol +++ b/contracts/access/Ownable.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.0; import "../utils/Context.sol"; + /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to @@ -23,7 +24,7 @@ abstract contract Ownable is Context { /** * @dev Initializes the contract setting the deployer as the initial owner. */ - constructor () { + constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); diff --git a/contracts/finance/PaymentSplitter.sol b/contracts/finance/PaymentSplitter.sol index 62a0e9260..ffa79a34a 100644 --- a/contracts/finance/PaymentSplitter.sol +++ b/contracts/finance/PaymentSplitter.sol @@ -38,8 +38,7 @@ contract PaymentSplitter is Context { * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ - constructor (address[] memory payees, uint256[] memory shares_) payable { - // solhint-disable-next-line max-line-length + constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); @@ -57,7 +56,7 @@ contract PaymentSplitter is Context { * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ - receive () external payable virtual { + receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } @@ -104,7 +103,7 @@ contract PaymentSplitter is Context { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + _totalReleased; - uint256 payment = totalReceived * _shares[account] / _totalShares - _released[account]; + uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 02fc3dbc5..10aeb4ee4 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -31,7 +31,15 @@ contract TimelockController is AccessControl { /** * @dev Emitted when a call is scheduled as part of operation `id`. */ - event CallScheduled(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data, bytes32 predecessor, uint256 delay); + event CallScheduled( + bytes32 indexed id, + uint256 indexed index, + address target, + uint256 value, + bytes data, + bytes32 predecessor, + uint256 delay + ); /** * @dev Emitted when a call is performed as part of operation `id`. @@ -51,7 +59,11 @@ contract TimelockController is AccessControl { /** * @dev Initializes the contract with a given `minDelay`. */ - constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) { + constructor( + uint256 minDelay, + address[] memory proposers, + address[] memory executors + ) { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE); @@ -112,7 +124,6 @@ contract TimelockController is AccessControl { */ function isOperationReady(bytes32 id) public view virtual returns (bool ready) { uint256 timestamp = getTimestamp(id); - // solhint-disable-next-line not-rely-on-time return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp; } @@ -144,7 +155,13 @@ contract TimelockController is AccessControl { * @dev Returns the identifier of an operation containing a single * transaction. */ - function hashOperation(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public pure virtual returns (bytes32 hash) { + function hashOperation( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt + ) public pure virtual returns (bytes32 hash) { return keccak256(abi.encode(target, value, data, predecessor, salt)); } @@ -152,7 +169,13 @@ contract TimelockController is AccessControl { * @dev Returns the identifier of an operation containing a batch of * transactions. */ - function hashOperationBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public pure virtual returns (bytes32 hash) { + function hashOperationBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt + ) public pure virtual returns (bytes32 hash) { return keccak256(abi.encode(targets, values, datas, predecessor, salt)); } @@ -165,7 +188,14 @@ contract TimelockController is AccessControl { * * - the caller must have the 'proposer' role. */ - function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) { + function schedule( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt, + uint256 delay + ) public virtual onlyRole(PROPOSER_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _schedule(id, delay); emit CallScheduled(id, 0, target, value, data, predecessor, delay); @@ -180,7 +210,14 @@ contract TimelockController is AccessControl { * * - the caller must have the 'proposer' role. */ - function scheduleBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) { + function scheduleBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt, + uint256 delay + ) public virtual onlyRole(PROPOSER_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); @@ -197,7 +234,6 @@ contract TimelockController is AccessControl { function _schedule(bytes32 id, uint256 delay) private { require(!isOperation(id), "TimelockController: operation already scheduled"); require(delay >= getMinDelay(), "TimelockController: insufficient delay"); - // solhint-disable-next-line not-rely-on-time _timestamps[id] = block.timestamp + delay; } @@ -224,7 +260,13 @@ contract TimelockController is AccessControl { * * - the caller must have the 'executor' role. */ - function execute(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { + function execute( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt + ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(predecessor); _call(id, 0, target, value, data); @@ -240,7 +282,13 @@ contract TimelockController is AccessControl { * * - the caller must have the 'executor' role. */ - function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { + function executeBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt + ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); @@ -272,9 +320,14 @@ contract TimelockController is AccessControl { * * Emits a {CallExecuted} event. */ - function _call(bytes32 id, uint256 index, address target, uint256 value, bytes calldata data) private { - // solhint-disable-next-line avoid-low-level-calls - (bool success,) = target.call{value: value}(data); + function _call( + bytes32 id, + uint256 index, + address target, + uint256 value, + bytes calldata data + ) private { + (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); emit CallExecuted(id, index, target, value, data); diff --git a/contracts/interfaces/IERC1271.sol b/contracts/interfaces/IERC1271.sol index b15147fc0..0e02b47f0 100644 --- a/contracts/interfaces/IERC1271.sol +++ b/contracts/interfaces/IERC1271.sol @@ -9,10 +9,10 @@ pragma solidity ^0.8.0; * _Available since v4.1._ */ interface IERC1271 { - /** - * @dev Should return whether the signature provided is valid for the provided data - * @param hash Hash of the data to be signed - * @param signature Signature byte array associated with _data - */ - function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); + /** + * @dev Should return whether the signature provided is valid for the provided data + * @param hash Hash of the data to be signed + * @param signature Signature byte array associated with _data + */ + function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); } diff --git a/contracts/interfaces/IERC3156.sol b/contracts/interfaces/IERC3156.sol index 4b0cb5547..ad970d432 100644 --- a/contracts/interfaces/IERC3156.sol +++ b/contracts/interfaces/IERC3156.sol @@ -37,9 +37,7 @@ interface IERC3156FlashLender { * @param token The loan currency. * @return The amount of `token` that can be borrowed. */ - function maxFlashLoan( - address token - ) external view returns (uint256); + function maxFlashLoan(address token) external view returns (uint256); /** * @dev The fee to be charged for a given loan. @@ -47,10 +45,7 @@ interface IERC3156FlashLender { * @param amount The amount of tokens lent. * @return The amount of `token` to be charged for the loan, on top of the returned principal. */ - function flashFee( - address token, - uint256 amount - ) external view returns (uint256); + function flashFee(address token, uint256 amount) external view returns (uint256); /** * @dev Initiate a flash loan. @@ -65,4 +60,4 @@ interface IERC3156FlashLender { uint256 amount, bytes calldata data ) external returns (bool); - } +} diff --git a/contracts/metatx/ERC2771Context.sol b/contracts/metatx/ERC2771Context.sol index 5ab22f5d9..78890e494 100644 --- a/contracts/metatx/ERC2771Context.sol +++ b/contracts/metatx/ERC2771Context.sol @@ -14,14 +14,16 @@ abstract contract ERC2771Context is Context { _trustedForwarder = trustedForwarder; } - function isTrustedForwarder(address forwarder) public view virtual returns(bool) { + function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return forwarder == _trustedForwarder; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. - assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } + assembly { + sender := shr(96, calldataload(sub(calldatasize(), 20))) + } } else { return super._msgSender(); } @@ -29,7 +31,7 @@ abstract contract ERC2771Context is Context { function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { - return msg.data[:msg.data.length-20]; + return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } diff --git a/contracts/metatx/MinimalForwarder.sol b/contracts/metatx/MinimalForwarder.sol index ee1e1523f..340e88748 100644 --- a/contracts/metatx/MinimalForwarder.sol +++ b/contracts/metatx/MinimalForwarder.sol @@ -20,7 +20,8 @@ contract MinimalForwarder is EIP712 { bytes data; } - bytes32 private constant TYPEHASH = keccak256("ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)"); + bytes32 private constant _TYPEHASH = + keccak256("ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)"); mapping(address => uint256) private _nonces; @@ -31,24 +32,23 @@ contract MinimalForwarder is EIP712 { } function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) { - address signer = _hashTypedDataV4(keccak256(abi.encode( - TYPEHASH, - req.from, - req.to, - req.value, - req.gas, - req.nonce, - keccak256(req.data) - ))).recover(signature); + address signer = _hashTypedDataV4( + keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data))) + ).recover(signature); 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; - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(abi.encodePacked(req.data, req.from)); + (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}( + abi.encodePacked(req.data, req.from) + ); // Validate that the relayer has sent enough gas for the call. // See https://ronan.eth.link/blog/ethereum-gas-dangers/ assert(gasleft() > req.gas / 63); diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index eabd31543..702093c73 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -22,7 +22,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))); } @@ -38,5 +42,5 @@ contract AddressImpl { } // sendValue's tests require the contract to hold Ether - receive () external payable { } + receive() external payable {} } diff --git a/contracts/mocks/ArraysImpl.sol b/contracts/mocks/ArraysImpl.sol index e70ced6c5..f720524b8 100644 --- a/contracts/mocks/ArraysImpl.sol +++ b/contracts/mocks/ArraysImpl.sol @@ -9,7 +9,7 @@ contract ArraysImpl { uint256[] private _array; - constructor (uint256[] memory array) { + constructor(uint256[] memory array) { _array = array; } diff --git a/contracts/mocks/BadBeacon.sol b/contracts/mocks/BadBeacon.sol index 7fe486dd8..bedcfed84 100644 --- a/contracts/mocks/BadBeacon.sol +++ b/contracts/mocks/BadBeacon.sol @@ -2,8 +2,7 @@ pragma solidity ^0.8.0; -contract BadBeaconNoImpl { -} +contract BadBeaconNoImpl {} contract BadBeaconNotContract { function implementation() external pure returns (address) { diff --git a/contracts/mocks/ClashingImplementation.sol b/contracts/mocks/ClashingImplementation.sol index d954d0a22..80aca0c29 100644 --- a/contracts/mocks/ClashingImplementation.sol +++ b/contracts/mocks/ClashingImplementation.sol @@ -2,19 +2,17 @@ pragma solidity ^0.8.0; - /** * @dev Implementation contract with an admin() function made to clash with * @dev TransparentUpgradeableProxy's to test correct functioning of the * @dev Transparent Proxy feature. */ contract ClashingImplementation { + function admin() external pure returns (address) { + return 0x0000000000000000000000000000000011111142; + } - function admin() external pure returns (address) { - return 0x0000000000000000000000000000000011111142; - } - - function delegatedFunction() external pure returns (bool) { - return true; - } + function delegatedFunction() external pure returns (bool) { + return true; + } } diff --git a/contracts/mocks/ClonesMock.sol b/contracts/mocks/ClonesMock.sol index c65d30cc3..3719b0a78 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 7759f3506..f17af38a4 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 b06271739..070ad3671 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -6,12 +6,15 @@ 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); } function deployERC1820Implementer(uint256 value, bytes32 salt) public { - // solhint-disable-next-line indent Create2.deploy(value, salt, type(ERC1820Implementer).creationCode); } @@ -19,7 +22,11 @@ contract Create2Impl { return Create2.computeAddress(salt, codeHash); } - function computeAddressWithDeployer(bytes32 salt, bytes32 codeHash, address deployer) public pure returns (address) { + function computeAddressWithDeployer( + bytes32 salt, + bytes32 codeHash, + address deployer + ) public pure returns (address) { return Create2.computeAddress(salt, codeHash, deployer); } diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index d4c1d7d84..d8651340d 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -3,55 +3,59 @@ pragma solidity ^0.8.0; abstract contract Impl { - function version() public pure virtual returns (string memory); + function version() public pure virtual returns (string memory); } contract DummyImplementation { - uint256 public value; - string public text; - uint256[] public values; + uint256 public value; + string public text; + uint256[] public values; - function initializeNonPayable() public { - value = 10; - } + function initializeNonPayable() public { + value = 10; + } - function initializePayable() public payable { - value = 100; - } + function initializePayable() public payable { + value = 100; + } - function initializeNonPayableWithValue(uint256 _value) public { - value = _value; - } + function initializeNonPayableWithValue(uint256 _value) public { + value = _value; + } - function initializePayableWithValue(uint256 _value) public payable { - value = _value; - } + function initializePayableWithValue(uint256 _value) public payable { + value = _value; + } - function initialize(uint256 _value, string memory _text, uint256[] memory _values) public { - value = _value; - text = _text; - values = _values; - } + function initialize( + uint256 _value, + string memory _text, + uint256[] memory _values + ) public { + value = _value; + text = _text; + values = _values; + } - function get() public pure returns (bool) { - return true; - } + function get() public pure returns (bool) { + return true; + } - function version() public pure virtual returns (string memory) { - return "V1"; - } + function version() public pure virtual returns (string memory) { + return "V1"; + } - function reverts() public pure { - require(false, "DummyImplementation reverted"); - } + function reverts() public pure { + require(false, "DummyImplementation reverted"); + } } contract DummyImplementationV2 is DummyImplementation { - function migrate(uint256 newVal) public payable { - value = newVal; - } + function migrate(uint256 newVal) public payable { + value = newVal; + } - function version() public pure override returns (string memory) { - return "V2"; - } + function version() public pure override returns (string memory) { + return "V2"; + } } diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index 943556f25..6f2446900 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -12,12 +12,15 @@ contract EIP712External is EIP712 { return _domainSeparatorV4(); } - 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)) - ))); + 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)))) + ); address recoveredSigner = ECDSA.recover(digest, signature); require(recoveredSigner == signer); } diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 8485eecfa..62138f28d 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -5,9 +5,14 @@ pragma solidity ^0.8.0; import "../token/ERC1155/extensions/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { - constructor(string memory uri) ERC1155(uri) { } + 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 b99f6d37c..0518ac26c 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -9,27 +9,43 @@ import "../token/ERC1155/ERC1155.sol"; * This mock just publicizes internal functions for testing purposes */ contract ERC1155Mock is ERC1155 { - constructor (string memory uri) ERC1155(uri) { - // solhint-disable-previous-line no-empty-blocks - } + constructor(string memory uri) ERC1155(uri) {} function setURI(string memory newuri) public { _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/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index c4e4dd7be..b1a4a8e1e 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -6,7 +6,7 @@ import "./ERC1155Mock.sol"; import "../token/ERC1155/extensions/ERC1155Pausable.sol"; contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { - constructor(string memory uri) ERC1155Mock(uri) { } + constructor(string memory uri) ERC1155Mock(uri) {} function pause() external { _pause(); @@ -23,9 +23,7 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - internal virtual override(ERC1155, ERC1155Pausable) - { + ) internal virtual override(ERC1155, ERC1155Pausable) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } } diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index a8babdc0d..1d9def93d 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -14,13 +14,12 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165 { 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 ( + constructor( bytes4 recRetval, bool recReverts, bytes4 batRetval, bool batReverts - ) - { + ) { _recRetval = recRetval; _recReverts = recReverts; _batRetval = batRetval; @@ -33,11 +32,7 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165 { uint256 id, uint256 value, bytes calldata data - ) - external - override - returns(bytes4) - { + ) external override returns (bytes4) { require(!_recReverts, "ERC1155ReceiverMock: reverting on receive"); emit Received(operator, from, id, value, data, gasleft()); return _recRetval; @@ -49,11 +44,7 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165 { uint256[] calldata ids, uint256[] calldata values, bytes calldata data - ) - external - override - returns(bytes4) - { + ) external override returns (bytes4) { require(!_batReverts, "ERC1155ReceiverMock: reverting on batch receive"); emit BatchReceived(operator, from, ids, values, data, gasleft()); return _batRetval; diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index 995b88a68..96b436ae5 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -6,21 +6,39 @@ import "./ERC1155Mock.sol"; import "../token/ERC1155/extensions/ERC1155Supply.sol"; contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { - constructor(string memory uri) ERC1155Mock(uri) { } + constructor(string memory uri) ERC1155Mock(uri) {} - function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual override(ERC1155, ERC1155Supply) { + function _mint( + address account, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Supply) { super._mint(account, id, amount, data); } - function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override(ERC1155, ERC1155Supply) { + function _mintBatch( + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Supply) { super._mintBatch(to, ids, amounts, data); } - function _burn(address account, uint256 id, uint256 amount) internal virtual override(ERC1155, ERC1155Supply) { + function _burn( + address account, + uint256 id, + uint256 amount + ) internal virtual override(ERC1155, ERC1155Supply) { super._burn(account, id, amount); } - function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual override(ERC1155, ERC1155Supply) { + function _burnBatch( + address account, + uint256[] memory ids, + uint256[] memory amounts + ) internal virtual override(ERC1155, ERC1155Supply) { super._burnBatch(account, ids, amounts); } } diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index ecc4579d9..7a5e5bc67 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -29,7 +29,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself. */ - constructor () { + constructor() { _registerInterface(INTERFACE_ID_ERC165); } @@ -50,7 +50,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { } contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { - constructor (bytes4[] memory interfaceIds) { + constructor(bytes4[] memory interfaceIds) { for (uint256 i = 0; i < interfaceIds.length; i++) { _registerInterface(interfaceIds[i]); } diff --git a/contracts/mocks/ERC165/ERC165NotSupported.sol b/contracts/mocks/ERC165/ERC165NotSupported.sol index 8fa2c1bf6..486c7f0a4 100644 --- a/contracts/mocks/ERC165/ERC165NotSupported.sol +++ b/contracts/mocks/ERC165/ERC165NotSupported.sol @@ -2,4 +2,4 @@ pragma solidity ^0.8.0; -contract ERC165NotSupported { } +contract ERC165NotSupported {} diff --git a/contracts/mocks/ERC165Mock.sol b/contracts/mocks/ERC165Mock.sol index ee5e540a1..c123d0ab2 100644 --- a/contracts/mocks/ERC165Mock.sol +++ b/contracts/mocks/ERC165Mock.sol @@ -4,5 +4,4 @@ pragma solidity ^0.8.0; import "../utils/introspection/ERC165.sol"; -contract ERC165Mock is ERC165 { -} +contract ERC165Mock is ERC165 {} diff --git a/contracts/mocks/ERC20BurnableMock.sol b/contracts/mocks/ERC20BurnableMock.sol index 72d4e0b16..0ed6c0c98 100644 --- a/contracts/mocks/ERC20BurnableMock.sol +++ b/contracts/mocks/ERC20BurnableMock.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Burnable.sol"; contract ERC20BurnableMock is ERC20Burnable { - constructor ( + constructor( string memory name, string memory symbol, address initialAccount, diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index e5e3feb5f..edb36f205 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -5,9 +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 ef48eb1da..924c3af31 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -5,9 +5,13 @@ pragma solidity ^0.8.0; import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { - uint8 immutable private _decimals; + 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/ERC20FlashMintMock.sol b/contracts/mocks/ERC20FlashMintMock.sol index 33dba245d..0bb7871fc 100644 --- a/contracts/mocks/ERC20FlashMintMock.sol +++ b/contracts/mocks/ERC20FlashMintMock.sol @@ -2,11 +2,10 @@ pragma solidity ^0.8.0; - import "../token/ERC20/extensions/ERC20FlashMint.sol"; contract ERC20FlashMintMock is ERC20FlashMint { - constructor ( + constructor( string memory name, string memory symbol, address initialAccount, diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index b78d101af..fd7f991ba 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -6,7 +6,7 @@ import "../token/ERC20/ERC20.sol"; // mock class using ERC20 contract ERC20Mock is ERC20 { - constructor ( + constructor( string memory name, string memory symbol, address initialAccount, @@ -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/ERC20PausableMock.sol b/contracts/mocks/ERC20PausableMock.sol index 6e61800df..19160ba6c 100644 --- a/contracts/mocks/ERC20PausableMock.sol +++ b/contracts/mocks/ERC20PausableMock.sol @@ -6,7 +6,7 @@ import "../token/ERC20/extensions/ERC20Pausable.sol"; // mock class using ERC20Pausable contract ERC20PausableMock is ERC20Pausable { - constructor ( + constructor( string memory name, string memory symbol, address initialAccount, diff --git a/contracts/mocks/ERC20PermitMock.sol b/contracts/mocks/ERC20PermitMock.sol index e9f2daf5e..20302bfa0 100644 --- a/contracts/mocks/ERC20PermitMock.sol +++ b/contracts/mocks/ERC20PermitMock.sol @@ -2,11 +2,10 @@ pragma solidity ^0.8.0; - import "../token/ERC20/extensions/draft-ERC20Permit.sol"; contract ERC20PermitMock is ERC20Permit { - constructor ( + constructor( string memory name, string memory symbol, address initialAccount, diff --git a/contracts/mocks/ERC20SnapshotMock.sol b/contracts/mocks/ERC20SnapshotMock.sol index 792bee199..cb3048322 100644 --- a/contracts/mocks/ERC20SnapshotMock.sol +++ b/contracts/mocks/ERC20SnapshotMock.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Snapshot.sol"; - contract ERC20SnapshotMock is ERC20Snapshot { constructor( string memory name, diff --git a/contracts/mocks/ERC20VotesCompMock.sol b/contracts/mocks/ERC20VotesCompMock.sol index 81f9d1b5f..171071fd5 100644 --- a/contracts/mocks/ERC20VotesCompMock.sol +++ b/contracts/mocks/ERC20VotesCompMock.sol @@ -2,14 +2,10 @@ pragma solidity ^0.8.0; - import "../token/ERC20/extensions/ERC20VotesComp.sol"; contract ERC20VotesCompMock is ERC20VotesComp { - constructor (string memory name, string memory symbol) - ERC20(name, symbol) - ERC20Permit(name) - {} + constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {} function mint(address account, uint256 amount) public { _mint(account, amount); diff --git a/contracts/mocks/ERC20VotesMock.sol b/contracts/mocks/ERC20VotesMock.sol index 7eb12228e..0975e8b9f 100644 --- a/contracts/mocks/ERC20VotesMock.sol +++ b/contracts/mocks/ERC20VotesMock.sol @@ -2,14 +2,10 @@ pragma solidity ^0.8.0; - import "../token/ERC20/extensions/ERC20Votes.sol"; contract ERC20VotesMock is ERC20Votes { - constructor (string memory name, string memory symbol) - ERC20(name, symbol) - ERC20Permit(name) - {} + constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {} function mint(address account, uint256 amount) public { _mint(account, amount); diff --git a/contracts/mocks/ERC2771ContextMock.sol b/contracts/mocks/ERC2771ContextMock.sol index 14c5b104c..7bc1c4538 100644 --- a/contracts/mocks/ERC2771ContextMock.sol +++ b/contracts/mocks/ERC2771ContextMock.sol @@ -9,11 +9,11 @@ import "../metatx/ERC2771Context.sol"; contract ERC2771ContextMock is ContextMock, ERC2771Context { constructor(address trustedForwarder) ERC2771Context(trustedForwarder) {} - function _msgSender() internal override(Context, ERC2771Context) view virtual returns (address) { + function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) { return ERC2771Context._msgSender(); } - function _msgData() internal override(Context, ERC2771Context) view virtual returns (bytes calldata) { + function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) { return ERC2771Context._msgData(); } } diff --git a/contracts/mocks/ERC3156FlashBorrowerMock.sol b/contracts/mocks/ERC3156FlashBorrowerMock.sol index 63eb8ef2e..288a278fb 100644 --- a/contracts/mocks/ERC3156FlashBorrowerMock.sol +++ b/contracts/mocks/ERC3156FlashBorrowerMock.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.0; - import "../token/ERC20/IERC20.sol"; import "../interfaces/IERC3156.sol"; import "../utils/Address.sol"; @@ -15,7 +14,7 @@ import "../utils/Address.sol"; * live networks. */ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { - bytes32 constant internal RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan"); + bytes32 internal constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan"); bool immutable _enableApprove; bool immutable _enableReturn; @@ -29,7 +28,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { } function onFlashLoan( - address /*initiator*/, + address, /*initiator*/ address token, uint256 amount, uint256 fee, @@ -49,6 +48,6 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { IERC20(token).approve(token, amount + fee); } - return _enableReturn ? RETURN_VALUE : bytes32(0); + return _enableReturn ? _RETURN_VALUE : bytes32(0); } } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index de15340ea..b30dbf53d 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC721/extensions/ERC721Burnable.sol"; contract ERC721BurnableMock is ERC721Burnable { - constructor(string memory name, string memory symbol) ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) {} function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); @@ -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/ERC721EnumerableMock.sol b/contracts/mocks/ERC721EnumerableMock.sol index f64f37eb6..73aee9d04 100644 --- a/contracts/mocks/ERC721EnumerableMock.sol +++ b/contracts/mocks/ERC721EnumerableMock.sol @@ -11,7 +11,7 @@ import "../token/ERC721/extensions/ERC721Enumerable.sol"; contract ERC721EnumerableMock is ERC721Enumerable { string private _baseTokenURI; - constructor (string memory name, string memory symbol) ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) {} function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; @@ -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 c4aabdbfe..74a092334 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -9,7 +9,7 @@ import "../token/ERC721/ERC721.sol"; * This mock just provides a public safeMint, mint, and burn functions for testing purposes */ contract ERC721Mock is ERC721 { - constructor (string memory name, string memory symbol) ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) {} function baseURI() public view returns (string memory) { return _baseURI(); @@ -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 8541c8996..8d8e818fb 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -9,7 +9,7 @@ import "../token/ERC721/extensions/ERC721Pausable.sol"; * This mock just provides a public mint, burn and exists functions for testing purposes */ contract ERC721PausableMock is ERC721Pausable { - constructor (string memory name, string memory symbol) ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) {} function pause() external { _pause(); @@ -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/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 0ba5035e8..a4923bfd5 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -17,14 +17,17 @@ contract ERC721ReceiverMock is IERC721Receiver { event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas); - constructor (bytes4 retval, Error error) { + constructor(bytes4 retval, Error error) { _retval = retval; _error = error; } - function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) - public override returns (bytes4) - { + function onERC721Received( + address operator, + address from, + uint256 tokenId, + bytes memory data + ) public override returns (bytes4) { if (_error == Error.RevertWithMessage) { revert("ERC721ReceiverMock: reverting"); } else if (_error == Error.RevertWithoutMessage) { diff --git a/contracts/mocks/ERC721URIStorageMock.sol b/contracts/mocks/ERC721URIStorageMock.sol index 4c355d19a..9c3480f71 100644 --- a/contracts/mocks/ERC721URIStorageMock.sol +++ b/contracts/mocks/ERC721URIStorageMock.sol @@ -11,7 +11,7 @@ import "../token/ERC721/extensions/ERC721URIStorage.sol"; contract ERC721URIStorageMock is ERC721URIStorage { string private _baseTokenURI; - constructor (string memory name, string memory symbol) ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) {} function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; @@ -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 319a483e2..f8a3b6784 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -18,7 +18,7 @@ contract ERC777Mock is Context, ERC777 { _mint(initialHolder, initialBalance, "", ""); } - function mintInternal ( + function mintInternal( address to, uint256 amount, bytes memory userData, @@ -27,7 +27,7 @@ contract ERC777Mock is Context, ERC777 { _mint(to, amount, userData, operatorData); } - function mintInternalExtended ( + function mintInternalExtended( address to, uint256 amount, bytes memory userData, @@ -37,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 3a92d999c..169912f69 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -42,8 +42,8 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); - bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender"); - bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); + bytes32 private constant _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender"); + bytes32 private constant _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); function tokensToSend( address operator, @@ -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/EnumerableMapMock.sol b/contracts/mocks/EnumerableMapMock.sol index bacbf6743..510647b58 100644 --- a/contracts/mocks/EnumerableMapMock.sol +++ b/contracts/mocks/EnumerableMapMock.sol @@ -33,7 +33,6 @@ contract EnumerableMapMock { return _map.at(index); } - function tryGet(uint256 key) public view returns (bool, address) { return _map.tryGet(key); } diff --git a/contracts/mocks/EtherReceiverMock.sol b/contracts/mocks/EtherReceiverMock.sol index 41cb88139..a11e646fb 100644 --- a/contracts/mocks/EtherReceiverMock.sol +++ b/contracts/mocks/EtherReceiverMock.sol @@ -9,7 +9,7 @@ contract EtherReceiverMock { _acceptEther = acceptEther; } - receive () external payable { + receive() external payable { if (!_acceptEther) { revert(); } diff --git a/contracts/mocks/InitializableMock.sol b/contracts/mocks/InitializableMock.sol index d5d60286d..0d3e77dfa 100644 --- a/contracts/mocks/InitializableMock.sol +++ b/contracts/mocks/InitializableMock.sol @@ -9,28 +9,26 @@ import "../proxy/utils/Initializable.sol"; * @dev This contract is a mock to test initializable functionality */ contract InitializableMock is Initializable { + bool public initializerRan; + uint256 public x; - bool public initializerRan; - uint256 public x; + function initialize() public initializer { + initializerRan = true; + } - function initialize() public initializer { - initializerRan = true; - } + function initializeNested() public initializer { + initialize(); + } - function initializeNested() public initializer { - initialize(); - } + function initializeWithX(uint256 _x) public payable initializer { + x = _x; + } - function initializeWithX(uint256 _x) public payable initializer { - x = _x; - } - - function nonInitializable(uint256 _x) public payable { - x = _x; - } - - function fail() public pure { - require(false, "InitializableMock forced failure"); - } + function nonInitializable(uint256 _x) public payable { + x = _x; + } + function fail() public pure { + require(false, "InitializableMock forced failure"); + } } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index bf1c6e4df..6189eb4ae 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,7 +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); } } diff --git a/contracts/mocks/MulticallTest.sol b/contracts/mocks/MulticallTest.sol index 4a7393717..f1a3a9cfe 100644 --- a/contracts/mocks/MulticallTest.sol +++ b/contracts/mocks/MulticallTest.sol @@ -5,14 +5,18 @@ pragma solidity ^0.8.0; import "./MulticallTokenMock.sol"; contract MulticallTest { - function testReturnValues(MulticallTokenMock multicallToken, address[] calldata recipients, uint256[] calldata amounts) external { + function testReturnValues( + MulticallTokenMock multicallToken, + address[] calldata recipients, + uint256[] calldata amounts + ) external { bytes[] memory calls = new bytes[](recipients.length); - for (uint i = 0; i < recipients.length; i++) { + for (uint256 i = 0; i < recipients.length; i++) { calls[i] = abi.encodeWithSignature("transfer(address,uint256)", recipients[i], amounts[i]); } bytes[] memory results = multicallToken.multicall(calls); - for (uint i = 0; i < results.length; i++) { + for (uint256 i = 0; i < results.length; i++) { require(abi.decode(results[i], (bool))); } } diff --git a/contracts/mocks/MulticallTokenMock.sol b/contracts/mocks/MulticallTokenMock.sol index 468705636..de379681b 100644 --- a/contracts/mocks/MulticallTokenMock.sol +++ b/contracts/mocks/MulticallTokenMock.sol @@ -6,5 +6,5 @@ import "../utils/Multicall.sol"; import "./ERC20Mock.sol"; contract MulticallTokenMock is ERC20Mock, Multicall { - constructor (uint256 initialBalance) ERC20Mock("MulticallToken", "BCT", msg.sender, initialBalance) {} + constructor(uint256 initialBalance) ERC20Mock("MulticallToken", "BCT", msg.sender, initialBalance) {} } diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index f10ccd8f8..1a008e8d8 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -19,58 +19,63 @@ import "../proxy/utils/Initializable.sol"; * Sample base intializable contract that is a human */ contract SampleHuman is Initializable { - bool public isHuman; + bool public isHuman; - function initialize() public initializer { - isHuman = true; - } + function initialize() public initializer { + isHuman = true; + } } /** * Sample base intializable contract that defines a field mother */ contract SampleMother is Initializable, SampleHuman { - uint256 public mother; + uint256 public mother; - function initialize(uint256 value) public initializer virtual { - SampleHuman.initialize(); - mother = value; - } + function initialize(uint256 value) public virtual initializer { + SampleHuman.initialize(); + mother = value; + } } /** * Sample base intializable contract that defines a field gramps */ contract SampleGramps is Initializable, SampleHuman { - string public gramps; + string public gramps; - function initialize(string memory value) public initializer virtual { - SampleHuman.initialize(); - gramps = value; - } + function initialize(string memory value) public virtual initializer { + SampleHuman.initialize(); + gramps = value; + } } /** * Sample base intializable contract that defines a field father and extends from gramps */ contract SampleFather is Initializable, SampleGramps { - uint256 public father; + uint256 public father; - function initialize(string memory _gramps, uint256 _father) public initializer { - SampleGramps.initialize(_gramps); - father = _father; - } + function initialize(string memory _gramps, uint256 _father) public initializer { + SampleGramps.initialize(_gramps); + father = _father; + } } /** * Child extends from mother, father (gramps) */ contract SampleChild is Initializable, SampleMother, SampleFather { - uint256 public child; + uint256 public child; - function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer { - SampleMother.initialize(_mother); - SampleFather.initialize(_gramps, _father); - child = _child; - } + function initialize( + uint256 _mother, + string memory _gramps, + uint256 _father, + uint256 _child + ) public initializer { + SampleMother.initialize(_mother); + SampleFather.initialize(_gramps, _father); + child = _child; + } } diff --git a/contracts/mocks/OwnableMock.sol b/contracts/mocks/OwnableMock.sol index 4751ed4b7..d60f1c40d 100644 --- a/contracts/mocks/OwnableMock.sol +++ b/contracts/mocks/OwnableMock.sol @@ -4,4 +4,4 @@ pragma solidity ^0.8.0; import "../access/Ownable.sol"; -contract OwnableMock is Ownable { } +contract OwnableMock is Ownable {} diff --git a/contracts/mocks/PausableMock.sol b/contracts/mocks/PausableMock.sol index eebc2be4a..98bcfd593 100644 --- a/contracts/mocks/PausableMock.sol +++ b/contracts/mocks/PausableMock.sol @@ -8,7 +8,7 @@ contract PausableMock is Pausable { bool public drasticMeasureTaken; uint256 public count; - constructor () { + constructor() { drasticMeasureTaken = false; count = 0; } diff --git a/contracts/mocks/PullPaymentMock.sol b/contracts/mocks/PullPaymentMock.sol index 929659da6..8a708e30c 100644 --- a/contracts/mocks/PullPaymentMock.sol +++ b/contracts/mocks/PullPaymentMock.sol @@ -6,7 +6,7 @@ import "../security/PullPayment.sol"; // mock class using PullPayment contract PullPaymentMock is PullPayment { - constructor () payable { } + constructor() payable {} // test helper function to call asyncTransfer function callTransfer(address dest, uint256 amount) public { diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index de95aa41a..4de181205 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import "../utils/Context.sol"; + contract ReentrancyAttack is Context { function callSender(bytes4 data) public { - // solhint-disable-next-line avoid-low-level-calls - (bool success,) = _msgSender().call(abi.encodeWithSelector(data)); + (bool success, ) = _msgSender().call(abi.encodeWithSelector(data)); require(success, "ReentrancyAttack: failed call"); } } diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index c561dbbb9..43425dd6e 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -8,7 +8,7 @@ import "./ReentrancyAttack.sol"; contract ReentrancyMock is ReentrancyGuard { uint256 public counter; - constructor () { + constructor() { counter = 0; } @@ -26,8 +26,7 @@ contract ReentrancyMock is ReentrancyGuard { function countThisRecursive(uint256 n) public nonReentrant { if (n > 0) { _count(); - // solhint-disable-next-line avoid-low-level-calls - (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); + (bool success, ) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); require(success, "ReentrancyMock: failed call"); } } diff --git a/contracts/mocks/RegressionImplementation.sol b/contracts/mocks/RegressionImplementation.sol index 201570715..be6b501c1 100644 --- a/contracts/mocks/RegressionImplementation.sol +++ b/contracts/mocks/RegressionImplementation.sol @@ -5,62 +5,57 @@ pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; contract Implementation1 is Initializable { - uint internal _value; + uint256 internal _value; - function initialize() public initializer { - } + function initialize() public initializer {} - function setValue(uint _number) public { - _value = _number; - } + function setValue(uint256 _number) public { + _value = _number; + } } contract Implementation2 is Initializable { - uint internal _value; + uint256 internal _value; - function initialize() public initializer { - } + function initialize() public initializer {} - function setValue(uint _number) public { - _value = _number; - } + function setValue(uint256 _number) public { + _value = _number; + } - function getValue() public view returns (uint) { - return _value; - } + function getValue() public view returns (uint256) { + return _value; + } } contract Implementation3 is Initializable { - uint internal _value; + uint256 internal _value; - function initialize() public initializer { - } + function initialize() public initializer {} - function setValue(uint _number) public { - _value = _number; - } + function setValue(uint256 _number) public { + _value = _number; + } - function getValue(uint _number) public view returns (uint) { - return _value + _number; - } + function getValue(uint256 _number) public view returns (uint256) { + return _value + _number; + } } contract Implementation4 is Initializable { - uint internal _value; + uint256 internal _value; - function initialize() public initializer { - } + function initialize() public initializer {} - function setValue(uint _number) public { - _value = _number; - } + function setValue(uint256 _number) public { + _value = _number; + } - function getValue() public view returns (uint) { - return _value; - } + function getValue() public view returns (uint256) { + return _value; + } - // solhint-disable-next-line payable-fallback - fallback() external { - _value = 1; - } + fallback() external { + _value = 1; + } } diff --git a/contracts/mocks/SafeCastMock.sol b/contracts/mocks/SafeCastMock.sol index 16f24c8b1..d1f1aaaba 100644 --- a/contracts/mocks/SafeCastMock.sol +++ b/contracts/mocks/SafeCastMock.sol @@ -5,62 +5,62 @@ pragma solidity ^0.8.0; import "../utils/math/SafeCast.sol"; contract SafeCastMock { - using SafeCast for uint; - using SafeCast for int; + using SafeCast for uint256; + using SafeCast for int256; - function toUint256(int a) public pure returns (uint256) { + function toUint256(int256 a) public pure returns (uint256) { return a.toUint256(); } - function toUint224(uint a) public pure returns (uint224) { + function toUint224(uint256 a) public pure returns (uint224) { return a.toUint224(); } - function toUint128(uint a) public pure returns (uint128) { + function toUint128(uint256 a) public pure returns (uint128) { return a.toUint128(); } - function toUint96(uint a) public pure returns (uint96) { + function toUint96(uint256 a) public pure returns (uint96) { return a.toUint96(); } - function toUint64(uint a) public pure returns (uint64) { + function toUint64(uint256 a) public pure returns (uint64) { return a.toUint64(); } - function toUint32(uint a) public pure returns (uint32) { + function toUint32(uint256 a) public pure returns (uint32) { return a.toUint32(); } - function toUint16(uint a) public pure returns (uint16) { + function toUint16(uint256 a) public pure returns (uint16) { return a.toUint16(); } - function toUint8(uint a) public pure returns (uint8) { + function toUint8(uint256 a) public pure returns (uint8) { return a.toUint8(); } - function toInt256(uint a) public pure returns (int256) { + function toInt256(uint256 a) public pure returns (int256) { return a.toInt256(); } - function toInt128(int a) public pure returns (int128) { + function toInt128(int256 a) public pure returns (int128) { return a.toInt128(); } - function toInt64(int a) public pure returns (int64) { + function toInt64(int256 a) public pure returns (int64) { return a.toInt64(); } - function toInt32(int a) public pure returns (int32) { + function toInt32(int256 a) public pure returns (int32) { return a.toInt32(); } - function toInt16(int a) public pure returns (int16) { + function toInt16(int256 a) public pure returns (int16) { return a.toInt16(); } - function toInt8(int a) public pure returns (int8) { + function toInt8(int256 a) public pure returns (int8) { return a.toInt8(); } } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index d51c38de7..9e3442b35 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -18,7 +18,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; } @@ -35,7 +39,7 @@ contract ERC20ReturnFalseMock is Context { } contract ERC20ReturnTrueMock is Context { - mapping (address => uint256) private _allowances; + mapping(address => uint256) private _allowances; // IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings, // we write to a dummy state variable. @@ -46,7 +50,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; } @@ -66,7 +74,7 @@ contract ERC20ReturnTrueMock is Context { } contract ERC20NoReturnMock is Context { - mapping (address => uint256) private _allowances; + mapping(address => uint256) private _allowances; // IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings, // we write to a dummy state variable. @@ -76,7 +84,11 @@ contract ERC20NoReturnMock is Context { _dummy = 0; } - function transferFrom(address, address, uint256) public { + function transferFrom( + address, + address, + uint256 + ) public { _dummy = 0; } @@ -98,7 +110,7 @@ contract SafeERC20Wrapper is Context { IERC20 private _token; - constructor (IERC20 token) { + constructor(IERC20 token) { _token = token; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index 7158cf740..3d1f4727e 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -47,61 +47,92 @@ 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); } function addMemoryCheck() public pure returns (uint256 mem) { uint256 length = 32; - // solhint-disable-next-line no-inline-assembly - assembly { mem := mload(0x40) } - for (uint256 i = 0; i < length; ++i) { SafeMath.add(1, 1); } - // solhint-disable-next-line no-inline-assembly - assembly { mem := sub(mload(0x40), mem) } + assembly { + mem := mload(0x40) + } + for (uint256 i = 0; i < length; ++i) { + SafeMath.add(1, 1); + } + assembly { + mem := sub(mload(0x40), mem) + } } function subMemoryCheck() public pure returns (uint256 mem) { uint256 length = 32; - // solhint-disable-next-line no-inline-assembly - assembly { mem := mload(0x40) } - for (uint256 i = 0; i < length; ++i) { SafeMath.sub(1, 1); } - // solhint-disable-next-line no-inline-assembly - assembly { mem := sub(mload(0x40), mem) } + assembly { + mem := mload(0x40) + } + for (uint256 i = 0; i < length; ++i) { + SafeMath.sub(1, 1); + } + assembly { + mem := sub(mload(0x40), mem) + } } function mulMemoryCheck() public pure returns (uint256 mem) { uint256 length = 32; - // solhint-disable-next-line no-inline-assembly - assembly { mem := mload(0x40) } - for (uint256 i = 0; i < length; ++i) { SafeMath.mul(1, 1); } - // solhint-disable-next-line no-inline-assembly - assembly { mem := sub(mload(0x40), mem) } + assembly { + mem := mload(0x40) + } + for (uint256 i = 0; i < length; ++i) { + SafeMath.mul(1, 1); + } + assembly { + mem := sub(mload(0x40), mem) + } } function divMemoryCheck() public pure returns (uint256 mem) { uint256 length = 32; - // solhint-disable-next-line no-inline-assembly - assembly { mem := mload(0x40) } - for (uint256 i = 0; i < length; ++i) { SafeMath.div(1, 1); } - // solhint-disable-next-line no-inline-assembly - assembly { mem := sub(mload(0x40), mem) } + assembly { + mem := mload(0x40) + } + for (uint256 i = 0; i < length; ++i) { + SafeMath.div(1, 1); + } + assembly { + mem := sub(mload(0x40), mem) + } } function modMemoryCheck() public pure returns (uint256 mem) { uint256 length = 32; - // solhint-disable-next-line no-inline-assembly - assembly { mem := mload(0x40) } - for (uint256 i = 0; i < length; ++i) { SafeMath.mod(1, 1); } - // solhint-disable-next-line no-inline-assembly - assembly { mem := sub(mload(0x40), mem) } + assembly { + mem := mload(0x40) + } + for (uint256 i = 0; i < length; ++i) { + SafeMath.mod(1, 1); + } + assembly { + mem := sub(mload(0x40), mem) + } } - } diff --git a/contracts/mocks/SignatureCheckerMock.sol b/contracts/mocks/SignatureCheckerMock.sol index 5671540ec..3b399c1ae 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/SingleInheritanceInitializableMocks.sol b/contracts/mocks/SingleInheritanceInitializableMocks.sol index eee4bb8f6..6c82dd20c 100644 --- a/contracts/mocks/SingleInheritanceInitializableMocks.sol +++ b/contracts/mocks/SingleInheritanceInitializableMocks.sol @@ -9,11 +9,11 @@ import "../proxy/utils/Initializable.sol"; * @dev This contract is a mock to test initializable functionality through migrations */ contract MigratableMockV1 is Initializable { - uint256 public x; + uint256 public x; - function initialize(uint256 value) public payable initializer { - x = value; - } + function initialize(uint256 value) public payable initializer { + x = value; + } } /** @@ -21,15 +21,15 @@ contract MigratableMockV1 is Initializable { * @dev This contract is a mock to test migratable functionality with params */ contract MigratableMockV2 is MigratableMockV1 { - bool internal _migratedV2; - uint256 public y; + bool internal _migratedV2; + uint256 public y; - function migrate(uint256 value, uint256 anotherValue) public payable { - require(!_migratedV2); - x = value; - y = anotherValue; - _migratedV2 = true; - } + function migrate(uint256 value, uint256 anotherValue) public payable { + require(!_migratedV2); + x = value; + y = anotherValue; + _migratedV2 = true; + } } /** @@ -37,13 +37,13 @@ contract MigratableMockV2 is MigratableMockV1 { * @dev This contract is a mock to test migratable functionality without params */ contract MigratableMockV3 is MigratableMockV2 { - bool internal _migratedV3; + bool internal _migratedV3; - function migrate() public payable { - require(!_migratedV3); - uint256 oldX = x; - x = y; - y = oldX; - _migratedV3 = true; - } + function migrate() public payable { + require(!_migratedV3); + uint256 oldX = x; + x = y; + y = oldX; + _migratedV3 = true; + } } diff --git a/contracts/mocks/StorageSlotMock.sol b/contracts/mocks/StorageSlotMock.sol index 5cbb02a5f..5d099fca8 100644 --- a/contracts/mocks/StorageSlotMock.sol +++ b/contracts/mocks/StorageSlotMock.sol @@ -6,12 +6,36 @@ import "../utils/StorageSlot.sol"; contract StorageSlotMock { using StorageSlot for bytes32; - function setBoolean(bytes32 slot, bool value) public { slot.getBooleanSlot().value = value; } - function setAddress(bytes32 slot, address value) public { slot.getAddressSlot().value = value; } - function setBytes32(bytes32 slot, bytes32 value) public { slot.getBytes32Slot().value = value; } - function setUint256(bytes32 slot, uint256 value) public { slot.getUint256Slot().value = value; } - function getBoolean(bytes32 slot) public view returns (bool) { return slot.getBooleanSlot().value; } - function getAddress(bytes32 slot) public view returns (address) { return slot.getAddressSlot().value; } - function getBytes32(bytes32 slot) public view returns (bytes32) { return slot.getBytes32Slot().value; } - function getUint256(bytes32 slot) public view returns (uint256) { return slot.getUint256Slot().value; } + + function setBoolean(bytes32 slot, bool value) public { + slot.getBooleanSlot().value = value; + } + + function setAddress(bytes32 slot, address value) public { + slot.getAddressSlot().value = value; + } + + function setBytes32(bytes32 slot, bytes32 value) public { + slot.getBytes32Slot().value = value; + } + + function setUint256(bytes32 slot, uint256 value) public { + slot.getUint256Slot().value = value; + } + + function getBoolean(bytes32 slot) public view returns (bool) { + return slot.getBooleanSlot().value; + } + + function getAddress(bytes32 slot) public view returns (address) { + return slot.getAddressSlot().value; + } + + function getBytes32(bytes32 slot) public view returns (bytes32) { + return slot.getBytes32Slot().value; + } + + function getUint256(bytes32 slot) public view returns (uint256) { + return slot.getUint256Slot().value; + } } diff --git a/contracts/mocks/StringsMock.sol b/contracts/mocks/StringsMock.sol index 3cc396bac..f257734e7 100644 --- a/contracts/mocks/StringsMock.sol +++ b/contracts/mocks/StringsMock.sol @@ -8,9 +8,11 @@ contract StringsMock { function fromUint256(uint256 value) public pure returns (string memory) { return Strings.toString(value); } + function fromUint256Hex(uint256 value) public pure returns (string memory) { return Strings.toHexString(value); } + function fromUint256HexFixed(uint256 value, uint256 length) public pure returns (string memory) { return Strings.toHexString(value, length); } diff --git a/contracts/mocks/UUPS/TestInProd.sol b/contracts/mocks/UUPS/TestInProd.sol index 13339ec7a..bbb610300 100644 --- a/contracts/mocks/UUPS/TestInProd.sol +++ b/contracts/mocks/UUPS/TestInProd.sol @@ -28,5 +28,4 @@ contract UUPSUpgradeableBrokenMock is UUPSUpgradeableMock { function upgradeToAndCall(address, bytes memory) external payable virtual override { // pass } - } diff --git a/contracts/proxy/Clones.sol b/contracts/proxy/Clones.sol index 65a8c16ab..498fc91de 100644 --- a/contracts/proxy/Clones.sol +++ b/contracts/proxy/Clones.sol @@ -22,7 +22,6 @@ library Clones { * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { - // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) @@ -41,7 +40,6 @@ library Clones { * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { - // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) @@ -55,8 +53,11 @@ library Clones { /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ - function predictDeterministicAddress(address implementation, bytes32 salt, address deployer) internal pure returns (address predicted) { - // solhint-disable-next-line no-inline-assembly + function predictDeterministicAddress( + address implementation, + bytes32 salt, + address deployer + ) internal pure returns (address predicted) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) @@ -72,7 +73,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 7d5231a88..0e6384718 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -60,7 +60,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 { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0 || forceCall) { @@ -73,7 +77,11 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCallSecure( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call @@ -89,10 +97,7 @@ abstract contract ERC1967Upgrade { rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, - abi.encodeWithSignature( - "upgradeTo(address)", - oldImplementation - ) + abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective @@ -109,7 +114,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) { @@ -176,10 +185,7 @@ 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(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" diff --git a/contracts/proxy/Proxy.sol b/contracts/proxy/Proxy.sol index efdab3be0..e2d6bc92f 100644 --- a/contracts/proxy/Proxy.sol +++ b/contracts/proxy/Proxy.sol @@ -19,7 +19,6 @@ abstract contract Proxy { * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { - // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the @@ -35,8 +34,12 @@ abstract contract Proxy { switch result // delegatecall returns 0 on error. - case 0 { revert(0, returndatasize()) } - default { return(0, returndatasize()) } + case 0 { + revert(0, returndatasize()) + } + default { + return(0, returndatasize()) + } } } @@ -60,7 +63,7 @@ abstract contract Proxy { * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ - fallback () external payable virtual { + fallback() external payable virtual { _fallback(); } @@ -68,7 +71,7 @@ abstract contract Proxy { * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ - receive () external payable virtual { + receive() external payable virtual { _fallback(); } @@ -78,6 +81,5 @@ abstract contract Proxy { * * If overriden should call `super._beforeFallback()`. */ - function _beforeFallback() internal virtual { - } + function _beforeFallback() internal virtual {} } diff --git a/contracts/proxy/transparent/ProxyAdmin.sol b/contracts/proxy/transparent/ProxyAdmin.sol index f68c9ae04..a98a83193 100644 --- a/contracts/proxy/transparent/ProxyAdmin.sol +++ b/contracts/proxy/transparent/ProxyAdmin.sol @@ -10,7 +10,6 @@ import "../../access/Ownable.sol"; * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { - /** * @dev Returns the current implementation of `proxy`. * @@ -71,7 +70,11 @@ contract ProxyAdmin is Ownable { * * - This contract must be the admin of `proxy`. */ - function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner { + function upgradeAndCall( + TransparentUpgradeableProxy proxy, + address implementation, + bytes memory data + ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } } diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index 7ec03fbd1..c8a61eede 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -30,7 +30,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) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } diff --git a/contracts/proxy/utils/Initializable.sol b/contracts/proxy/utils/Initializable.sol index af397bfca..7bd696bd8 100644 --- a/contracts/proxy/utils/Initializable.sol +++ b/contracts/proxy/utils/Initializable.sol @@ -1,6 +1,5 @@ // SPDX-License-Identifier: MIT -// solhint-disable-next-line compiler-version pragma solidity ^0.8.0; /** @@ -16,7 +15,6 @@ pragma solidity ^0.8.0; * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { - /** * @dev Indicates that the contract has been initialized. */ diff --git a/contracts/security/Pausable.sol b/contracts/security/Pausable.sol index dd0db6e6b..3c943ce4e 100644 --- a/contracts/security/Pausable.sol +++ b/contracts/security/Pausable.sol @@ -29,7 +29,7 @@ abstract contract Pausable is Context { /** * @dev Initializes the contract in unpaused state. */ - constructor () { + constructor() { _paused = false; } diff --git a/contracts/security/PullPayment.sol b/contracts/security/PullPayment.sol index 5170d6a7a..dad32f085 100644 --- a/contracts/security/PullPayment.sol +++ b/contracts/security/PullPayment.sol @@ -23,9 +23,9 @@ import "../utils/escrow/Escrow.sol"; * payments with {payments}, and retrieve them with {withdrawPayments}. */ abstract contract PullPayment { - Escrow immutable private _escrow; + Escrow private immutable _escrow; - constructor () { + constructor() { _escrow = new Escrow(); } @@ -64,6 +64,6 @@ abstract contract PullPayment { * @param amount The amount to transfer. */ function _asyncTransfer(address dest, uint256 amount) internal virtual { - _escrow.deposit{ value: amount }(dest); + _escrow.deposit{value: amount}(dest); } } diff --git a/contracts/security/ReentrancyGuard.sol b/contracts/security/ReentrancyGuard.sol index baa779c24..067a2c94e 100644 --- a/contracts/security/ReentrancyGuard.sol +++ b/contracts/security/ReentrancyGuard.sol @@ -35,7 +35,7 @@ abstract contract ReentrancyGuard { uint256 private _status; - constructor () { + constructor() { _status = _NOT_ENTERED; } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 3b89fbeb2..240d9cd88 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -20,10 +20,10 @@ 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; + mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals - mapping (address => mapping(address => bool)) private _operatorApprovals; + mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; @@ -31,7 +31,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { /** * @dev See {_setURI}. */ - constructor (string memory uri_) { + constructor(string memory uri_) { _setURI(uri_); } @@ -39,9 +39,10 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC1155).interfaceId - || interfaceId == type(IERC1155MetadataURI).interfaceId - || super.supportsInterface(interfaceId); + return + interfaceId == type(IERC1155).interfaceId || + interfaceId == type(IERC1155MetadataURI).interfaceId || + super.supportsInterface(interfaceId); } /** @@ -77,10 +78,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch( - address[] memory accounts, - uint256[] memory ids - ) + function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual @@ -124,11 +122,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount, bytes memory data - ) - public - virtual - override - { + ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" @@ -145,11 +139,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - public - virtual - override - { + ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" @@ -175,10 +165,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount, bytes memory data - ) - internal - virtual - { + ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); @@ -213,10 +200,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - internal - virtual - { + ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); @@ -275,7 +259,12 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual { + function _mint( + address account, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); @@ -297,7 +286,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 virtual { + function _mintBatch( + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); @@ -305,7 +299,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); - for (uint i = 0; i < ids.length; i++) { + for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } @@ -322,7 +316,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ - function _burn(address account, uint256 id, uint256 amount) internal virtual { + function _burn( + address account, + uint256 id, + uint256 amount + ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); @@ -345,7 +343,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `ids` and `amounts` must have the same length. */ - function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual { + function _burnBatch( + address account, + uint256[] memory ids, + uint256[] memory amounts + ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); @@ -353,7 +355,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); - for (uint i = 0; i < ids.length; i++) { + for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; @@ -394,10 +396,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - internal - virtual - { } + ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, @@ -406,9 +405,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount, bytes memory data - ) - private - { + ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver(to).onERC1155Received.selector) { @@ -429,11 +426,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - private - { + ) private { if (to.isContract()) { - try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (bytes4 response) { + try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( + bytes4 response + ) { if (response != IERC1155Receiver(to).onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index 6335adf7a..39abed8ee 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -20,7 +20,13 @@ interface IERC1155 is IERC165 { * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ - event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); + event TransferBatch( + address indexed operator, + address indexed from, + address indexed to, + uint256[] ids, + uint256[] values + ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to @@ -53,7 +59,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`, @@ -86,7 +95,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}. @@ -99,5 +114,11 @@ interface IERC1155 is IERC165 { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; + function safeBatchTransferFrom( + address from, + address to, + uint256[] calldata ids, + uint256[] calldata amounts, + bytes calldata data + ) external; } diff --git a/contracts/token/ERC1155/IERC1155Receiver.sol b/contracts/token/ERC1155/IERC1155Receiver.sol index 39a8b979a..fe2a0590f 100644 --- a/contracts/token/ERC1155/IERC1155Receiver.sol +++ b/contracts/token/ERC1155/IERC1155Receiver.sol @@ -8,7 +8,6 @@ import "../../utils/introspection/IERC165.sol"; * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { - /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. @@ -28,9 +27,7 @@ interface IERC1155Receiver is IERC165 { uint256 id, uint256 value, bytes calldata data - ) - external - returns(bytes4); + ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function @@ -51,7 +48,5 @@ interface IERC1155Receiver is IERC165 { uint256[] calldata ids, uint256[] calldata values, bytes calldata data - ) - external - returns(bytes4); + ) external returns (bytes4); } diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index ddf9dd479..f69d66ed4 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -11,7 +11,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 owner nor approved" @@ -20,7 +24,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 owner nor approved" diff --git a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol index abfae3cfe..5612351b7 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol @@ -29,11 +29,7 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - internal - virtual - override - { + ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index 6ec3b9b05..2f6838815 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -13,7 +13,7 @@ import "../ERC1155.sol"; * same id are not going to be minted. */ abstract contract ERC1155Supply is ERC1155 { - mapping (uint256 => uint256) private _totalSupply; + mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. @@ -25,14 +25,19 @@ abstract contract ERC1155Supply is ERC1155 { /** * @dev Indicates weither any token exist with a given id, or not. */ - function exists(uint256 id) public view virtual returns(bool) { + function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_mint}. */ - function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual override { + function _mint( + address account, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override { super._mint(account, id, amount, data); _totalSupply[id] += amount; } @@ -40,7 +45,12 @@ abstract contract ERC1155Supply is ERC1155 { /** * @dev See {ERC1155-_mintBatch}. */ - function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override { + function _mintBatch( + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual override { super._mintBatch(to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; @@ -50,7 +60,11 @@ abstract contract ERC1155Supply is ERC1155 { /** * @dev See {ERC1155-_burn}. */ - function _burn(address account, uint256 id, uint256 amount) internal virtual override { + function _burn( + address account, + uint256 id, + uint256 amount + ) internal virtual override { super._burn(account, id, amount); _totalSupply[id] -= amount; } @@ -58,7 +72,11 @@ abstract contract ERC1155Supply is ERC1155 { /** * @dev See {ERC1155-_burnBatch}. */ - function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual override { + function _burnBatch( + address account, + uint256[] memory ids, + uint256[] memory amounts + ) internal virtual override { super._burnBatch(account, ids, amounts); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; diff --git a/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol b/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol index 3ff5e02f8..9238e6aea 100644 --- a/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol +++ b/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol @@ -46,7 +46,12 @@ contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155B * * - the caller must have the `MINTER_ROLE`. */ - function mint(address to, uint256 id, uint256 amount, bytes memory data) public virtual { + function mint( + address to, + uint256 id, + uint256 amount, + bytes memory data + ) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint"); _mint(to, id, amount, data); @@ -55,7 +60,12 @@ contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155B /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}. */ - function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public virtual { + function mintBatch( + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint"); _mintBatch(to, ids, amounts, data); @@ -92,7 +102,13 @@ contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155B /** * @dev See {IERC165-supportsInterface}. */ - function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerable, ERC1155) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + virtual + override(AccessControlEnumerable, ERC1155) + returns (bool) + { return super.supportsInterface(interfaceId); } @@ -103,9 +119,7 @@ contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155B uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) - internal virtual override(ERC1155, ERC1155Pausable) - { + ) internal virtual override(ERC1155, ERC1155Pausable) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/utils/ERC1155Holder.sol b/contracts/token/ERC1155/utils/ERC1155Holder.sol index 4468f65cc..ccd9e37e4 100644 --- a/contracts/token/ERC1155/utils/ERC1155Holder.sol +++ b/contracts/token/ERC1155/utils/ERC1155Holder.sol @@ -8,11 +8,23 @@ import "./ERC1155Receiver.sol"; * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { - function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) { + function onERC1155Received( + address, + address, + uint256, + uint256, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } - function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) { + function onERC1155BatchReceived( + address, + address, + uint256[] memory, + uint256[] memory, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } } diff --git a/contracts/token/ERC1155/utils/ERC1155Receiver.sol b/contracts/token/ERC1155/utils/ERC1155Receiver.sol index aca156b06..22b9e7548 100644 --- a/contracts/token/ERC1155/utils/ERC1155Receiver.sol +++ b/contracts/token/ERC1155/utils/ERC1155Receiver.sol @@ -13,7 +13,6 @@ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC1155Receiver).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 862581f63..575571f8a 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -31,9 +31,9 @@ import "../../utils/Context.sol"; * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { - mapping (address => uint256) private _balances; + mapping(address => uint256) private _balances; - mapping (address => mapping (address => uint256)) private _allowances; + mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; @@ -49,7 +49,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * All two of these values are immutable: they can only be set once during * construction. */ - constructor (string memory name_, string memory symbol_) { + constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } @@ -145,7 +145,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ - function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; @@ -212,7 +216,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ - function _transfer(address sender, address recipient, uint256 amount) internal virtual { + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); @@ -286,7 +294,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"); @@ -308,5 +320,9 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} } diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 1d0863fff..08a04ad74 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -59,7 +59,11 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to diff --git a/contracts/token/ERC20/extensions/ERC20Capped.sol b/contracts/token/ERC20/extensions/ERC20Capped.sol index 296f16afe..c8d8b7f69 100644 --- a/contracts/token/ERC20/extensions/ERC20Capped.sol +++ b/contracts/token/ERC20/extensions/ERC20Capped.sol @@ -8,13 +8,13 @@ import "../ERC20.sol"; * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { - uint256 immutable private _cap; + uint256 private immutable _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ - constructor (uint256 cap_) { + constructor(uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } diff --git a/contracts/token/ERC20/extensions/ERC20FlashMint.sol b/contracts/token/ERC20/extensions/ERC20FlashMint.sol index 36d23218c..f77f4eafa 100644 --- a/contracts/token/ERC20/extensions/ERC20FlashMint.sol +++ b/contracts/token/ERC20/extensions/ERC20FlashMint.sol @@ -15,7 +15,7 @@ import "../ERC20.sol"; * _Available since v4.1._ */ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender { - bytes32 constant private RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan"); + bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan"); /** * @dev Returns the maximum amount of tokens available for loan. @@ -60,12 +60,13 @@ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender { address token, uint256 amount, bytes calldata data - ) - public virtual override returns (bool) - { + ) public virtual override returns (bool) { uint256 fee = flashFee(token, amount); _mint(address(receiver), amount); - require(receiver.onFlashLoan(msg.sender, token, amount, fee, data) == RETURN_VALUE, "ERC20FlashMint: invalid return value"); + require( + receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE, + "ERC20FlashMint: invalid return value" + ); uint256 currentAllowance = allowance(address(receiver), address(this)); require(currentAllowance >= amount + fee, "ERC20FlashMint: allowance does not allow refund"); _approve(address(receiver), address(this), currentAllowance - amount - fee); diff --git a/contracts/token/ERC20/extensions/ERC20Pausable.sol b/contracts/token/ERC20/extensions/ERC20Pausable.sol index f08656d02..cba16edd1 100644 --- a/contracts/token/ERC20/extensions/ERC20Pausable.sol +++ b/contracts/token/ERC20/extensions/ERC20Pausable.sol @@ -20,7 +20,11 @@ abstract contract ERC20Pausable is ERC20, Pausable { * * - the contract must not be paused. */ - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); diff --git a/contracts/token/ERC20/extensions/ERC20Snapshot.sol b/contracts/token/ERC20/extensions/ERC20Snapshot.sol index 349a758fa..9754631fe 100644 --- a/contracts/token/ERC20/extensions/ERC20Snapshot.sol +++ b/contracts/token/ERC20/extensions/ERC20Snapshot.sol @@ -52,7 +52,7 @@ abstract contract ERC20Snapshot is ERC20 { uint256[] values; } - mapping (address => Snapshots) private _accountBalanceSnapshots; + mapping(address => Snapshots) private _accountBalanceSnapshots; Snapshots private _totalSupplySnapshots; // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid. @@ -111,7 +111,7 @@ abstract contract ERC20Snapshot is ERC20 { /** * @dev Retrieves the total supply at the time `snapshotId` was created. */ - function totalSupplyAt(uint256 snapshotId) public view virtual returns(uint256) { + function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) { (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots); return snapshotted ? value : totalSupply(); @@ -119,27 +119,29 @@ abstract contract ERC20Snapshot is ERC20 { // Update balance and/or total supply snapshots before the values are modified. This is implemented // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations. - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { - super._beforeTokenTransfer(from, to, amount); + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual override { + super._beforeTokenTransfer(from, to, amount); - if (from == address(0)) { - // mint - _updateAccountSnapshot(to); - _updateTotalSupplySnapshot(); - } else if (to == address(0)) { - // burn - _updateAccountSnapshot(from); - _updateTotalSupplySnapshot(); - } else { - // transfer - _updateAccountSnapshot(from); - _updateAccountSnapshot(to); - } + if (from == address(0)) { + // mint + _updateAccountSnapshot(to); + _updateTotalSupplySnapshot(); + } else if (to == address(0)) { + // burn + _updateAccountSnapshot(from); + _updateTotalSupplySnapshot(); + } else { + // transfer + _updateAccountSnapshot(from); + _updateAccountSnapshot(to); + } } - function _valueAt(uint256 snapshotId, Snapshots storage snapshots) - private view returns (bool, uint256) - { + function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { require(snapshotId > 0, "ERC20Snapshot: id is 0"); require(snapshotId <= _getCurrentSnapshotId(), "ERC20Snapshot: nonexistent id"); diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 074e7bc4f..9f765ccb0 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -26,14 +26,15 @@ import "../../../utils/cryptography/ECDSA.sol"; */ abstract contract ERC20Votes is ERC20Permit { struct Checkpoint { - uint32 fromBlock; + uint32 fromBlock; uint224 votes; } - bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); + bytes32 private constant _DELEGATION_TYPEHASH = + keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); - mapping (address => address) private _delegates; - mapping (address => Checkpoint[]) private _checkpoints; + mapping(address => address) private _delegates; + mapping(address => Checkpoint[]) private _checkpoints; Checkpoint[] private _totalSupplyCheckpoints; /** @@ -139,18 +140,20 @@ abstract contract ERC20Votes is ERC20Permit { /** * @dev Delegates votes from signer to `delegatee` */ - function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) - public virtual - { + function delegateBySig( + address delegatee, + uint256 nonce, + uint256 expiry, + uint8 v, + bytes32 r, + bytes32 s + ) public virtual { require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( - _hashTypedDataV4(keccak256(abi.encode( - _DELEGATION_TYPEHASH, - delegatee, - nonce, - expiry - ))), - v, r, s + _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))), + v, + r, + s ); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); return _delegate(signer, delegatee); @@ -170,7 +173,7 @@ abstract contract ERC20Votes is ERC20Permit { super._mint(account, amount); require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); - _writeCheckpoint(_totalSupplyCheckpoints, add, amount); + _writeCheckpoint(_totalSupplyCheckpoints, _add, amount); } /** @@ -179,7 +182,7 @@ abstract contract ERC20Votes is ERC20Permit { function _burn(address account, uint256 amount) internal virtual override { super._burn(account, amount); - _writeCheckpoint(_totalSupplyCheckpoints, subtract, amount); + _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount); } /** @@ -187,7 +190,11 @@ abstract contract ERC20Votes is ERC20Permit { * * Emits a {DelegateVotesChanged} event. */ - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual override { _moveVotingPower(delegates(from), delegates(to), amount); } @@ -206,15 +213,19 @@ abstract contract ERC20Votes is ERC20Permit { _moveVotingPower(currentDelegate, delegatee, delegatorBalance); } - function _moveVotingPower(address src, address dst, uint256 amount) private { + function _moveVotingPower( + address src, + address dst, + uint256 amount + ) private { if (src != dst && amount > 0) { if (src != address(0)) { - (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], subtract, amount); + (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount); emit DelegateVotesChanged(src, oldWeight, newWeight); } if (dst != address(0)) { - (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], add, amount); + (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount); emit DelegateVotesChanged(dst, oldWeight, newWeight); } } @@ -222,11 +233,9 @@ abstract contract ERC20Votes is ERC20Permit { function _writeCheckpoint( Checkpoint[] storage ckpts, - function (uint256, uint256) view returns (uint256) op, + function(uint256, uint256) view returns (uint256) op, uint256 delta - ) - private returns (uint256 oldWeight, uint256 newWeight) - { + ) private returns (uint256 oldWeight, uint256 newWeight) { uint256 pos = ckpts.length; oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes; newWeight = op(oldWeight, delta); @@ -234,18 +243,15 @@ abstract contract ERC20Votes is ERC20Permit { if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) { ckpts[pos - 1].votes = SafeCast.toUint224(newWeight); } else { - ckpts.push(Checkpoint({ - fromBlock: SafeCast.toUint32(block.number), - votes: SafeCast.toUint224(newWeight) - })); + ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)})); } } - function add(uint256 a, uint256 b) private pure returns (uint256) { + function _add(uint256 a, uint256 b) private pure returns (uint256) { return a + b; } - function subtract(uint256 a, uint256 b) private pure returns (uint256) { + function _subtract(uint256 a, uint256 b) private pure returns (uint256) { return a - b; } } diff --git a/contracts/token/ERC20/extensions/ERC20VotesComp.sol b/contracts/token/ERC20/extensions/ERC20VotesComp.sol index d75ae4ef8..87cba8085 100644 --- a/contracts/token/ERC20/extensions/ERC20VotesComp.sol +++ b/contracts/token/ERC20/extensions/ERC20VotesComp.sol @@ -30,6 +30,7 @@ abstract contract ERC20VotesComp is ERC20Votes { function getCurrentVotes(address account) external view returns (uint96) { return SafeCast.toUint96(getVotes(account)); } + /** * @dev Comp version of the {getPastVotes} accessor, with `uint96` return type. */ diff --git a/contracts/token/ERC20/extensions/draft-ERC20Permit.sol b/contracts/token/ERC20/extensions/draft-ERC20Permit.sol index e1341eceb..631435e11 100644 --- a/contracts/token/ERC20/extensions/draft-ERC20Permit.sol +++ b/contracts/token/ERC20/extensions/draft-ERC20Permit.sol @@ -21,36 +21,34 @@ import "../../../utils/Counters.sol"; abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; - mapping (address => Counters.Counter) private _nonces; + mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase - bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); + bytes32 private immutable _PERMIT_TYPEHASH = + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ - constructor(string memory name) EIP712(name, "1") { - } + constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ - function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override { - // solhint-disable-next-line not-rely-on-time + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); - bytes32 structHash = keccak256( - abi.encode( - _PERMIT_TYPEHASH, - owner, - spender, - value, - _useNonce(owner), - deadline - ) - ); + bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); diff --git a/contracts/token/ERC20/extensions/draft-IERC20Permit.sol b/contracts/token/ERC20/extensions/draft-IERC20Permit.sol index 1a8731a58..33eb295ea 100644 --- a/contracts/token/ERC20/extensions/draft-IERC20Permit.sol +++ b/contracts/token/ERC20/extensions/draft-IERC20Permit.sol @@ -32,7 +32,15 @@ interface IERC20Permit { * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ - function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; /** * @dev Returns the current nonce for `owner`. This value must be diff --git a/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol b/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol index a9151c630..60c4762c7 100644 --- a/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol +++ b/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol @@ -81,7 +81,11 @@ contract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burna _unpause(); } - function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } } diff --git a/contracts/token/ERC20/utils/SafeERC20.sol b/contracts/token/ERC20/utils/SafeERC20.sol index 197da6667..954b2707e 100644 --- a/contracts/token/ERC20/utils/SafeERC20.sol +++ b/contracts/token/ERC20/utils/SafeERC20.sol @@ -17,11 +17,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)); } @@ -32,23 +41,35 @@ 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' - // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), + require( + (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _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"); @@ -69,8 +90,8 @@ library SafeERC20 { // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); - if (returndata.length > 0) { // Return data is optional - // solhint-disable-next-line max-line-length + if (returndata.length > 0) { + // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } diff --git a/contracts/token/ERC20/utils/TokenTimelock.sol b/contracts/token/ERC20/utils/TokenTimelock.sol index 5568c353c..0ba42f1ea 100644 --- a/contracts/token/ERC20/utils/TokenTimelock.sol +++ b/contracts/token/ERC20/utils/TokenTimelock.sol @@ -15,16 +15,19 @@ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held - IERC20 immutable private _token; + IERC20 private immutable _token; // beneficiary of tokens after they are released - address immutable private _beneficiary; + address private immutable _beneficiary; // timestamp when token release is enabled - uint256 immutable private _releaseTime; + uint256 private immutable _releaseTime; - constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) { - // solhint-disable-next-line not-rely-on-time + constructor( + IERC20 token_, + address beneficiary_, + uint256 releaseTime_ + ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; @@ -56,7 +59,6 @@ contract TokenTimelock { * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { - // solhint-disable-next-line not-rely-on-time require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index d26ee2d15..5a2494c6f 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -26,21 +26,21 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { string private _symbol; // Mapping from token ID to owner address - mapping (uint256 => address) private _owners; + mapping(uint256 => address) private _owners; // Mapping owner address to token count - mapping (address => uint256) private _balances; + mapping(address => uint256) private _balances; // Mapping from token ID to approved address - mapping (uint256 => address) private _tokenApprovals; + mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals - mapping (address => mapping (address => bool)) private _operatorApprovals; + mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ - constructor (string memory name_, string memory symbol_) { + constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } @@ -49,9 +49,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC721).interfaceId - || interfaceId == type(IERC721Metadata).interfaceId - || super.supportsInterface(interfaceId); + return + interfaceId == type(IERC721).interfaceId || + interfaceId == type(IERC721Metadata).interfaceId || + super.supportsInterface(interfaceId); } /** @@ -92,14 +93,12 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); - return bytes(baseURI).length > 0 - ? string(abi.encodePacked(baseURI, tokenId.toString())) - : ''; + return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each - * token will be the concatenation of the `baseURI` and the `tokenId`. Empty + * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { @@ -113,7 +112,8 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); - require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), + require( + _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); @@ -149,7 +149,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: transfer caller is not owner nor approved"); @@ -159,14 +163,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: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } @@ -189,7 +202,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"); } @@ -237,9 +255,16 @@ 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), "ERC721: transfer to non ERC721Receiver implementer"); + require( + _checkOnERC721Received(address(0), to, tokenId, _data), + "ERC721: transfer to non ERC721Receiver implementer" + ); } /** @@ -301,7 +326,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 of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); @@ -337,9 +366,12 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ - function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) - private returns (bool) - { + function _checkOnERC721Received( + address from, + address to, + uint256 tokenId, + bytes memory _data + ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; @@ -347,7 +379,6 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { - // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } @@ -372,5 +403,9 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } + function _beforeTokenTransfer( + address from, + address to, + uint256 tokenId + ) internal virtual {} } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 5811e7994..873ec6794 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -51,7 +51,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`. @@ -67,7 +71,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. @@ -113,17 +121,22 @@ interface IERC721 is IERC165 { function isApprovedForAll(address owner, address operator) external view returns (bool); /** - * @dev Safely transfers `tokenId` token from `from` to `to`. - * - * Requirements: - * - * - `from` cannot be the zero address. - * - `to` cannot be the zero address. - * - `tokenId` token must exist and be owned by `from`. - * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. - * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. - * - * Emits a {Transfer} event. - */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; + * @dev Safely transfers `tokenId` token from `from` to `to`. + * + * Requirements: + * + * - `from` cannot be the zero address. + * - `to` cannot be the zero address. + * - `tokenId` token must exist and be owned by `from`. + * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. + * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. + * + * Emits a {Transfer} event. + */ + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes calldata data + ) external; } diff --git a/contracts/token/ERC721/IERC721Receiver.sol b/contracts/token/ERC721/IERC721Receiver.sol index 081f4ab8d..9683f4a04 100644 --- a/contracts/token/ERC721/IERC721Receiver.sol +++ b/contracts/token/ERC721/IERC721Receiver.sol @@ -17,5 +17,10 @@ interface IERC721Receiver { * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ - function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); + function onERC721Received( + address operator, + address from, + uint256 tokenId, + bytes calldata data + ) external returns (bytes4); } diff --git a/contracts/token/ERC721/extensions/ERC721Enumerable.sol b/contracts/token/ERC721/extensions/ERC721Enumerable.sol index 8cdcdf827..d064bdd65 100644 --- a/contracts/token/ERC721/extensions/ERC721Enumerable.sol +++ b/contracts/token/ERC721/extensions/ERC721Enumerable.sol @@ -27,8 +27,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { - return interfaceId == type(IERC721Enumerable).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** @@ -69,7 +68,11 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { + function _beforeTokenTransfer( + address from, + address to, + uint256 tokenId + ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { diff --git a/contracts/token/ERC721/extensions/ERC721Pausable.sol b/contracts/token/ERC721/extensions/ERC721Pausable.sol index 9f2fabf7b..2949b3cac 100644 --- a/contracts/token/ERC721/extensions/ERC721Pausable.sol +++ b/contracts/token/ERC721/extensions/ERC721Pausable.sol @@ -20,7 +20,11 @@ abstract contract ERC721Pausable is ERC721, Pausable { * * - the contract must not be paused. */ - function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { + function _beforeTokenTransfer( + address from, + address to, + uint256 tokenId + ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); diff --git a/contracts/token/ERC721/extensions/ERC721URIStorage.sol b/contracts/token/ERC721/extensions/ERC721URIStorage.sol index 10ba8a21d..5b96e70b0 100644 --- a/contracts/token/ERC721/extensions/ERC721URIStorage.sol +++ b/contracts/token/ERC721/extensions/ERC721URIStorage.sol @@ -11,7 +11,7 @@ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs - mapping (uint256 => string) private _tokenURIs; + mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. diff --git a/contracts/token/ERC721/extensions/IERC721Enumerable.sol b/contracts/token/ERC721/extensions/IERC721Enumerable.sol index 6cf0f8369..c04295ba1 100644 --- a/contracts/token/ERC721/extensions/IERC721Enumerable.sol +++ b/contracts/token/ERC721/extensions/IERC721Enumerable.sol @@ -9,7 +9,6 @@ import "../IERC721.sol"; * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { - /** * @dev Returns the total amount of tokens stored by the contract. */ diff --git a/contracts/token/ERC721/extensions/IERC721Metadata.sol b/contracts/token/ERC721/extensions/IERC721Metadata.sol index 2379baca9..cb9af0033 100644 --- a/contracts/token/ERC721/extensions/IERC721Metadata.sol +++ b/contracts/token/ERC721/extensions/IERC721Metadata.sol @@ -9,7 +9,6 @@ import "../IERC721.sol"; * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { - /** * @dev Returns the token collection name. */ diff --git a/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol b/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol index 77b3fd17e..c23176535 100644 --- a/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol +++ b/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol @@ -25,7 +25,13 @@ import "../../../utils/Counters.sol"; * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ -contract ERC721PresetMinterPauserAutoId is Context, AccessControlEnumerable, ERC721Enumerable, ERC721Burnable, ERC721Pausable { +contract ERC721PresetMinterPauserAutoId is + Context, + AccessControlEnumerable, + ERC721Enumerable, + ERC721Burnable, + ERC721Pausable +{ using Counters for Counters.Counter; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); @@ -42,7 +48,11 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControlEnumerable, ERC * Token URIs will be autogenerated based on `baseURI` and their token IDs. * See {ERC721-tokenURI}. */ - constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) { + constructor( + string memory name, + string memory symbol, + string memory baseTokenURI + ) ERC721(name, symbol) { _baseTokenURI = baseTokenURI; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); @@ -103,14 +113,24 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControlEnumerable, ERC _unpause(); } - function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { + function _beforeTokenTransfer( + address from, + address to, + uint256 tokenId + ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } /** * @dev See {IERC165-supportsInterface}. */ - function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerable, ERC721, ERC721Enumerable) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + virtual + override(AccessControlEnumerable, ERC721, ERC721Enumerable) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index 1174ec053..64463808e 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -4,20 +4,24 @@ pragma solidity ^0.8.0; import "../IERC721Receiver.sol"; - /** - * @dev Implementation of the {IERC721Receiver} interface. - * - * Accepts all token transfers. - * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. - */ +/** + * @dev Implementation of the {IERC721Receiver} interface. + * + * Accepts all token transfers. + * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. + */ contract ERC721Holder is IERC721Receiver { - /** * @dev See {IERC721Receiver-onERC721Received}. * * 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 1666ec671..35296a0e7 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -28,7 +28,7 @@ import "../../utils/introspection/IERC1820Registry.sol"; contract ERC777 is Context, IERC777, IERC20 { using Address for address; - IERC1820Registry constant internal _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); + IERC1820Registry internal constant _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); mapping(address => uint256) private _balances; @@ -126,7 +126,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); } @@ -157,7 +161,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ - function burn(uint256 amount, bytes memory data) public virtual override { + function burn(uint256 amount, bytes memory data) public virtual override { _burn(_msgSender(), amount, data, ""); } @@ -165,7 +169,8 @@ contract ERC777 is Context, IERC777, IERC20 { * @dev See {IERC777-isOperatorFor}. */ function isOperatorFor(address operator, address tokenHolder) public view virtual override returns (bool) { - return operator == tokenHolder || + return + operator == tokenHolder || (_defaultOperators[operator] && !_revokedDefaultOperators[tokenHolder][operator]) || _operators[tokenHolder][operator]; } @@ -173,7 +178,7 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev See {IERC777-authorizeOperator}. */ - function authorizeOperator(address operator) public virtual override { + function authorizeOperator(address operator) public virtual override { require(_msgSender() != operator, "ERC777: authorizing self as operator"); if (_defaultOperators[operator]) { @@ -188,7 +193,7 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev See {IERC777-revokeOperator}. */ - function revokeOperator(address operator) public virtual override { + function revokeOperator(address operator) public virtual override { require(operator != _msgSender(), "ERC777: revoking self as operator"); if (_defaultOperators[operator]) { @@ -218,11 +223,7 @@ contract ERC777 is Context, IERC777, IERC20 { uint256 amount, bytes memory data, bytes memory operatorData - ) - public - virtual - override - { + ) public virtual override { require(isOperatorFor(_msgSender(), sender), "ERC777: caller is not an operator for holder"); _send(sender, recipient, amount, data, operatorData, true); } @@ -232,7 +233,12 @@ contract ERC777 is Context, IERC777, IERC20 { * * Emits {Burned} and {IERC20-Transfer} events. */ - function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public virtual override { + function operatorBurn( + address account, + uint256 amount, + bytes memory data, + bytes memory operatorData + ) public virtual override { require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); _burn(account, amount, data, operatorData); } @@ -259,16 +265,20 @@ contract ERC777 is Context, IERC777, IERC20 { return true; } - /** - * @dev See {IERC20-transferFrom}. - * - * Note that operator and allowance concepts are orthogonal: operators cannot - * call `transferFrom` (unless they have allowance), and accounts with - * allowance cannot call `operatorSend` (unless they are operators). - * - * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. - */ - function transferFrom(address holder, address recipient, uint256 amount) public virtual override returns (bool) { + /** + * @dev See {IERC20-transferFrom}. + * + * Note that operator and allowance concepts are orthogonal: operators cannot + * call `transferFrom` (unless they have allowance), and accounts with + * allowance cannot call `operatorSend` (unless they are operators). + * + * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. + */ + function transferFrom( + address holder, + address recipient, + uint256 amount + ) public virtual override returns (bool) { require(recipient != address(0), "ERC777: transfer to the zero address"); require(holder != address(0), "ERC777: transfer from the zero address"); @@ -309,10 +319,7 @@ contract ERC777 is Context, IERC777, IERC20 { uint256 amount, bytes memory userData, bytes memory operatorData - ) - internal - virtual - { + ) internal virtual { _mint(account, amount, userData, operatorData, true); } @@ -340,10 +347,7 @@ contract ERC777 is Context, IERC777, IERC20 { bytes memory userData, bytes memory operatorData, bool requireReceptionAck - ) - internal - virtual - { + ) internal virtual { require(account != address(0), "ERC777: mint to the zero address"); address operator = _msgSender(); @@ -376,10 +380,7 @@ contract ERC777 is Context, IERC777, IERC20 { bytes memory userData, bytes memory operatorData, bool requireReceptionAck - ) - internal - virtual - { + ) internal virtual { require(from != address(0), "ERC777: send from the zero address"); require(to != address(0), "ERC777: send to the zero address"); @@ -404,10 +405,7 @@ contract ERC777 is Context, IERC777, IERC20 { uint256 amount, bytes memory data, bytes memory operatorData - ) - internal - virtual - { + ) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); @@ -435,9 +433,7 @@ contract ERC777 is Context, IERC777, IERC20 { uint256 amount, bytes memory userData, bytes memory operatorData - ) - private - { + ) private { _beforeTokenTransfer(operator, from, to, amount); uint256 fromBalance = _balances[from]; @@ -456,7 +452,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 { + function _approve( + address holder, + address spender, + uint256 value + ) internal { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); @@ -480,9 +480,7 @@ contract ERC777 is Context, IERC777, IERC20 { uint256 amount, bytes memory userData, bytes memory operatorData - ) - private - { + ) private { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(from, _TOKENS_SENDER_INTERFACE_HASH); if (implementer != address(0)) { IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData); @@ -508,9 +506,7 @@ contract ERC777 is Context, IERC777, IERC20 { bytes memory userData, bytes memory operatorData, bool requireReceptionAck - ) - private - { + ) private { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(to, _TOKENS_RECIPIENT_INTERFACE_HASH); if (implementer != address(0)) { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); @@ -533,5 +529,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 ad2beeb4c..c037d1a32 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -58,7 +58,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 diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index bd9a5e072..7cfe6b812 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -29,8 +29,9 @@ library Address { // constructor execution. uint256 size; - // solhint-disable-next-line no-inline-assembly - assembly { size := extcodesize(account) } + assembly { + size := extcodesize(account) + } return size > 0; } @@ -53,8 +54,7 @@ library Address { function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); - // solhint-disable-next-line avoid-low-level-calls, avoid-call-value - (bool success, ) = recipient.call{ value: amount }(""); + (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } @@ -77,7 +77,7 @@ library Address { * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { - return functionCall(target, data, "Address: low-level call failed"); + return functionCall(target, data, "Address: low-level call failed"); } /** @@ -86,7 +86,11 @@ library Address { * * _Available since v3.1._ */ - function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + function functionCall( + address target, + bytes memory data, + string memory errorMessage + ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } @@ -101,7 +105,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"); } @@ -111,12 +119,16 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + function functionCallWithValue( + address target, + bytes memory data, + uint256 value, + string memory errorMessage + ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = target.call{ value: value }(data); + (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } @@ -136,10 +148,13 @@ library Address { * * _Available since v3.3._ */ - function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { + function functionStaticCall( + address target, + bytes memory data, + string memory errorMessage + ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); - // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } @@ -160,15 +175,22 @@ library Address { * * _Available since v3.4._ */ - function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + function functionDelegateCall( + address target, + bytes memory data, + string memory errorMessage + ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); - // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } - function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { + function _verifyCallResult( + bool success, + bytes memory returndata, + string memory errorMessage + ) private pure returns (bytes memory) { if (success) { return returndata; } else { @@ -176,7 +198,6 @@ library Address { if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly - // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) diff --git a/contracts/utils/Arrays.sol b/contracts/utils/Arrays.sol index 9a6e7ae04..1ad43db40 100644 --- a/contracts/utils/Arrays.sol +++ b/contracts/utils/Arrays.sol @@ -8,7 +8,7 @@ import "./math/Math.sol"; * @dev Collection of functions related to array types. */ library Arrays { - /** + /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index e4bfcb16d..72377d659 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -26,11 +26,14 @@ 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) { + function deploy( + uint256 amount, + bytes32 salt, + bytes memory bytecode + ) internal returns (address) { address addr; require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); - // solhint-disable-next-line no-inline-assembly assembly { addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt) } @@ -50,10 +53,12 @@ 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) { - bytes32 _data = keccak256( - abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash) - ); + function computeAddress( + bytes32 salt, + bytes32 bytecodeHash, + address deployer + ) internal pure returns (address) { + bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash)); return address(uint160(uint256(_data))); } } diff --git a/contracts/utils/Multicall.sol b/contracts/utils/Multicall.sol index 43244bdd0..06912a0cf 100644 --- a/contracts/utils/Multicall.sol +++ b/contracts/utils/Multicall.sol @@ -11,11 +11,11 @@ import "./Address.sol"; */ abstract contract Multicall { /** - * @dev Receives and executes a batch of function calls on this contract. - */ + * @dev Receives and executes a batch of function calls on this contract. + */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); - for (uint i = 0; i < data.length; i++) { + for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } return results; diff --git a/contracts/utils/Strings.sol b/contracts/utils/Strings.sol index dac2f35e7..42fe4944b 100644 --- a/contracts/utils/Strings.sol +++ b/contracts/utils/Strings.sol @@ -6,7 +6,7 @@ pragma solidity ^0.8.0; * @dev String operations. */ library Strings { - bytes16 private constant alphabet = "0123456789abcdef"; + bytes16 private constant _ALPHABET = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. @@ -57,11 +57,10 @@ library Strings { buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { - buffer[i] = alphabet[value & 0xf]; + buffer[i] = _ALPHABET[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } - } diff --git a/contracts/utils/cryptography/ECDSA.sol b/contracts/utils/cryptography/ECDSA.sol index 10a36a2df..944686844 100644 --- a/contracts/utils/cryptography/ECDSA.sol +++ b/contracts/utils/cryptography/ECDSA.sol @@ -39,7 +39,6 @@ library ECDSA { if (signature.length == 65) { // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. - // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) @@ -48,7 +47,6 @@ library ECDSA { } else if (signature.length == 64) { // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. - // solhint-disable-next-line no-inline-assembly assembly { let vs := mload(add(signature, 0x40)) r := mload(add(signature, 0x20)) @@ -66,7 +64,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) { // 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most @@ -76,7 +79,10 @@ library ECDSA { // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. - require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); + require( + uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, + "ECDSA: invalid signature 's' value" + ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index 9c9e94511..b3b4871de 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -18,7 +18,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) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { diff --git a/contracts/utils/cryptography/SignatureChecker.sol b/contracts/utils/cryptography/SignatureChecker.sol index c678a52b6..38f1dfef4 100644 --- a/contracts/utils/cryptography/SignatureChecker.sol +++ b/contracts/utils/cryptography/SignatureChecker.sol @@ -17,7 +17,11 @@ import "../../interfaces/IERC1271.sol"; * _Available since v4.1._ */ library SignatureChecker { - 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) { if (Address.isContract(signer)) { try IERC1271(signer).isValidSignature(hash, signature) returns (bytes4 magicValue) { return magicValue == IERC1271(signer).isValidSignature.selector; diff --git a/contracts/utils/cryptography/draft-EIP712.sol b/contracts/utils/cryptography/draft-EIP712.sol index 044f50aae..2704605e3 100644 --- a/contracts/utils/cryptography/draft-EIP712.sol +++ b/contracts/utils/cryptography/draft-EIP712.sol @@ -33,6 +33,7 @@ abstract contract EIP712 { bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; + /* solhint-enable var-name-mixedcase */ /** @@ -50,7 +51,9 @@ abstract contract EIP712 { constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); - bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); + bytes32 typeHash = keccak256( + "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" + ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; @@ -69,16 +72,12 @@ abstract contract EIP712 { } } - function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) { - return keccak256( - abi.encode( - typeHash, - name, - version, - block.chainid, - address(this) - ) - ); + function _buildDomainSeparator( + bytes32 typeHash, + bytes32 name, + bytes32 version + ) private view returns (bytes32) { + return keccak256(abi.encode(typeHash, name, version, block.chainid, address(this))); } /** diff --git a/contracts/utils/escrow/Escrow.sol b/contracts/utils/escrow/Escrow.sol index 9f4128896..c5ed1913c 100644 --- a/contracts/utils/escrow/Escrow.sol +++ b/contracts/utils/escrow/Escrow.sol @@ -5,19 +5,19 @@ pragma solidity ^0.8.0; import "../../access/Ownable.sol"; import "../Address.sol"; - /** - * @title Escrow - * @dev Base escrow contract, holds funds designated for a payee until they - * withdraw them. - * - * Intended usage: This contract (and derived escrow contracts) should be a - * standalone contract, that only interacts with the contract that instantiated - * it. That way, it is guaranteed that all Ether will be handled according to - * the `Escrow` rules, and there is no need to check for payable functions or - * transfers in the inheritance tree. The contract that uses the escrow as its - * payment method should be its owner, and provide public methods redirecting - * to the escrow's deposit and withdraw. - */ +/** + * @title Escrow + * @dev Base escrow contract, holds funds designated for a payee until they + * withdraw them. + * + * Intended usage: This contract (and derived escrow contracts) should be a + * standalone contract, that only interacts with the contract that instantiated + * it. That way, it is guaranteed that all Ether will be handled according to + * the `Escrow` rules, and there is no need to check for payable functions or + * transfers in the inheritance tree. The contract that uses the escrow as its + * payment method should be its owner, and provide public methods redirecting + * to the escrow's deposit and withdraw. + */ contract Escrow is Ownable { using Address for address payable; diff --git a/contracts/utils/escrow/RefundEscrow.sol b/contracts/utils/escrow/RefundEscrow.sol index 1a0875c14..ac8ce60bf 100644 --- a/contracts/utils/escrow/RefundEscrow.sol +++ b/contracts/utils/escrow/RefundEscrow.sol @@ -17,19 +17,23 @@ import "./ConditionalEscrow.sol"; contract RefundEscrow is ConditionalEscrow { using Address for address payable; - enum State { Active, Refunding, Closed } + enum State { + Active, + Refunding, + Closed + } event RefundsClosed(); event RefundsEnabled(); State private _state; - address payable immutable private _beneficiary; + address payable private immutable _beneficiary; /** * @dev Constructor. * @param beneficiary_ The beneficiary of the deposits. */ - constructor (address payable beneficiary_) { + constructor(address payable beneficiary_) { require(beneficiary_ != address(0), "RefundEscrow: beneficiary is the zero address"); _beneficiary = beneficiary_; _state = State.Active; @@ -71,7 +75,7 @@ contract RefundEscrow is ConditionalEscrow { /** * @dev Allows for refunds to take place, rejecting further deposits. */ - function enableRefunds() public onlyOwner virtual { + function enableRefunds() public virtual onlyOwner { require(state() == State.Active, "RefundEscrow: can only enable refunds while active"); _state = State.Refunding; emit RefundsEnabled(); diff --git a/contracts/utils/introspection/ERC165Checker.sol b/contracts/utils/introspection/ERC165Checker.sol index 8a31efa61..de34da916 100644 --- a/contracts/utils/introspection/ERC165Checker.sol +++ b/contracts/utils/introspection/ERC165Checker.sol @@ -21,7 +21,8 @@ library ERC165Checker { function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid - return _supportsERC165Interface(account, type(IERC165).interfaceId) && + return + _supportsERC165Interface(account, type(IERC165).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } @@ -33,8 +34,7 @@ library ERC165Checker { */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId - return supportsERC165(account) && - _supportsERC165Interface(account, interfaceId); + return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** @@ -47,7 +47,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); @@ -101,7 +105,7 @@ library ERC165Checker { */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165(account).supportsInterface.selector, interfaceId); - (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams); + (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (bool)); } diff --git a/contracts/utils/introspection/ERC1820Implementer.sol b/contracts/utils/introspection/ERC1820Implementer.sol index 8775d780e..15a87596e 100644 --- a/contracts/utils/introspection/ERC1820Implementer.sol +++ b/contracts/utils/introspection/ERC1820Implementer.sol @@ -20,7 +20,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 5ecd520a5..a93e37b9d 100644 --- a/contracts/utils/introspection/IERC1820Registry.sol +++ b/contracts/utils/introspection/IERC1820Registry.sol @@ -59,7 +59,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 3979e0e1e..66bb22005 100644 --- a/contracts/utils/math/Math.sol +++ b/contracts/utils/math/Math.sol @@ -26,7 +26,7 @@ library Math { */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute. - return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); + return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); } /** diff --git a/contracts/utils/math/SafeCast.sol b/contracts/utils/math/SafeCast.sol index 42e6ff338..8f54e39c7 100644 --- a/contracts/utils/math/SafeCast.sol +++ b/contracts/utils/math/SafeCast.sol @@ -29,7 +29,7 @@ library SafeCast { * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { - require(value <= type(uint224).max, "SafeCast: value doesn\'t fit in 224 bits"); + require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } @@ -44,7 +44,7 @@ library SafeCast { * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { - require(value <= type(uint128).max, "SafeCast: value doesn\'t fit in 128 bits"); + require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } @@ -59,7 +59,7 @@ library SafeCast { * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { - require(value <= type(uint96).max, "SafeCast: value doesn\'t fit in 96 bits"); + require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } @@ -74,7 +74,7 @@ library SafeCast { * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { - require(value <= type(uint64).max, "SafeCast: value doesn\'t fit in 64 bits"); + require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } @@ -89,7 +89,7 @@ library SafeCast { * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { - require(value <= type(uint32).max, "SafeCast: value doesn\'t fit in 32 bits"); + require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } @@ -104,7 +104,7 @@ library SafeCast { * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { - require(value <= type(uint16).max, "SafeCast: value doesn\'t fit in 16 bits"); + require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } @@ -119,7 +119,7 @@ library SafeCast { * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { - require(value <= type(uint8).max, "SafeCast: value doesn\'t fit in 8 bits"); + require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } @@ -149,7 +149,7 @@ library SafeCast { * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { - require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn\'t fit in 128 bits"); + require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } @@ -167,7 +167,7 @@ library SafeCast { * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { - require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn\'t fit in 64 bits"); + require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } @@ -185,7 +185,7 @@ library SafeCast { * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { - require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn\'t fit in 32 bits"); + require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } @@ -203,7 +203,7 @@ library SafeCast { * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { - require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn\'t fit in 16 bits"); + require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } @@ -221,7 +221,7 @@ library SafeCast { * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { - require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn\'t fit in 8 bits"); + require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } diff --git a/contracts/utils/math/SafeMath.sol b/contracts/utils/math/SafeMath.sol index de7084968..112eed1a8 100644 --- a/contracts/utils/math/SafeMath.sol +++ b/contracts/utils/math/SafeMath.sol @@ -164,7 +164,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; @@ -183,7 +187,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; @@ -205,7 +213,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/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index afcf47ab9..a853f3b4c 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -43,8 +43,7 @@ library EnumerableMap { struct Map { // Storage of keys EnumerableSet.Bytes32Set _keys; - - mapping (bytes32 => bytes32) _values; + mapping(bytes32 => bytes32) _values; } /** @@ -54,7 +53,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { + function _set( + Map storage map, + bytes32 key, + bytes32 value + ) private returns (bool) { map._values[key] = value; return map._keys.add(key); } @@ -83,16 +86,16 @@ library EnumerableMap { return map._keys.length(); } - /** - * @dev Returns the key-value pair stored at position `index` in the map. O(1). - * - * Note that there are no guarantees on the ordering of entries inside the - * array, and it may change when more entries are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the key-value pair stored at position `index` in the map. O(1). + * + * Note that there are no guarantees on the ordering of entries inside the + * array, and it may change when more entries are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); @@ -130,7 +133,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(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { + function _get( + Map storage map, + bytes32 key, + string memory errorMessage + ) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), errorMessage); return value; @@ -149,7 +156,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)))); } @@ -176,15 +187,15 @@ library EnumerableMap { return _length(map._inner); } - /** - * @dev Returns the element stored at position `index` in the set. O(1). - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the element stored at position `index` in the set. O(1). + * Note that there are no guarantees on the ordering of values inside the + * array, and it may change when more values are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); @@ -218,7 +229,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(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { + function get( + UintToAddressMap storage map, + uint256 key, + string memory errorMessage + ) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } diff --git a/contracts/utils/structs/EnumerableSet.sol b/contracts/utils/structs/EnumerableSet.sol index ca1dac159..e90d55ded 100644 --- a/contracts/utils/structs/EnumerableSet.sol +++ b/contracts/utils/structs/EnumerableSet.sol @@ -39,10 +39,9 @@ library EnumerableSet { struct Set { // Storage of set values bytes32[] _values; - // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. - mapping (bytes32 => uint256) _indexes; + mapping(bytes32 => uint256) _indexes; } /** @@ -73,7 +72,8 @@ library EnumerableSet { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; - if (valueIndex != 0) { // Equivalent to contains(set, value) + if (valueIndex != 0) { + // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. @@ -116,16 +116,16 @@ library EnumerableSet { return set._values.length; } - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the value stored at position `index` in the set. O(1). + * + * Note that there are no guarantees on the ordering of values inside the + * array, and it may change when more values are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } @@ -170,16 +170,16 @@ library EnumerableSet { return _length(set._inner); } - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the value stored at position `index` in the set. O(1). + * + * Note that there are no guarantees on the ordering of values inside the + * array, and it may change when more values are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } @@ -224,21 +224,20 @@ library EnumerableSet { return _length(set._inner); } - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the value stored at position `index` in the set. O(1). + * + * Note that there are no guarantees on the ordering of values inside the + * array, and it may change when more values are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } - // UintSet struct UintSet { @@ -279,16 +278,16 @@ library EnumerableSet { return _length(set._inner); } - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ + /** + * @dev Returns the value stored at position `index` in the set. O(1). + * + * Note that there are no guarantees on the ordering of values inside the + * array, and it may change when more values are added or removed. + * + * Requirements: + * + * - `index` must be strictly less than {length}. + */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } diff --git a/hardhat.config.js b/hardhat.config.js index 1fdef4e73..eeead6d95 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -13,7 +13,6 @@ const argv = require('yargs/yargs')() .argv; require('@nomiclabs/hardhat-truffle5'); -require('@nomiclabs/hardhat-solhint'); require('solidity-coverage'); if (argv.enableGasReport) { diff --git a/package-lock.json b/package-lock.json index ba9bd4539..08a2f95a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "openzeppelin-contracts-migrate-imports": "scripts/migrate-imports.js" }, "devDependencies": { - "@nomiclabs/hardhat-solhint": "^2.0.0", "@nomiclabs/hardhat-truffle5": "^2.0.0", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.0", @@ -36,8 +35,10 @@ "merkletreejs": "^0.2.13", "micromatch": "^4.0.2", "mocha": "^8.0.1", + "prettier": "^2.3.0", + "prettier-plugin-solidity": "^1.0.0-beta.13", "rimraf": "^3.0.2", - "solhint": "^3.2.0", + "solhint": "^3.3.6", "solidity-coverage": "^0.7.11", "solidity-docgen": "^0.5.3", "web3": "^1.3.0", @@ -796,352 +797,6 @@ "node": ">= 8" } }, - "node_modules/@nomiclabs/hardhat-solhint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-solhint/-/hardhat-solhint-2.0.0.tgz", - "integrity": "sha512-fn+izC923/oCnfbGyp7YwOXZYtwcrDIrTLlFVeEgeSAHe2ZnipRRtNCxEClZuzCptHmTzIIayBmAaijsTmEAoA==", - "dev": true, - "dependencies": { - "solhint": "^2.0.0" - }, - "peerDependencies": { - "hardhat": "^2.0.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/acorn": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", - "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "dependencies": { - "restore-cursor": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", - "dev": true - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/commander": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.18.0.tgz", - "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==", - "dev": true - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^6.14.0 || ^8.10.0 || >=9.10.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", - "dev": true, - "dependencies": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", - "dev": true, - "dependencies": { - "acorn": "^6.0.7", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "dependencies": { - "escape-string-regexp": "^1.0.5" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/inquirer": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", - "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", - "dev": true, - "dependencies": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.12", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.1.0", - "through": "^2.3.6" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/inquirer/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "dependencies": { - "mimic-fn": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "dependencies": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/solhint": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.3.1.tgz", - "integrity": "sha512-wP/G+Dqj8LNWlCI9Mt6XiQRWQfZwv1rkZe/V+HKtip5SAZJVvp144PdH28KE45ZvR99Hhrp/Mujt74fSmXsFiw==", - "dev": true, - "dependencies": { - "ajv": "^6.6.1", - "antlr4": "4.7.1", - "chalk": "^2.4.2", - "commander": "2.18.0", - "cosmiconfig": "^5.0.7", - "eslint": "^5.6.0", - "fast-diff": "^1.1.2", - "glob": "^7.1.3", - "ignore": "^4.0.6", - "js-yaml": "^3.12.0", - "lodash": "^4.17.11", - "semver": "^6.3.0" - }, - "bin": { - "solhint": "solhint.js" - }, - "optionalDependencies": { - "prettier": "^1.14.3" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/solhint/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@nomiclabs/hardhat-solhint/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@nomiclabs/hardhat-truffle5": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-truffle5/-/hardhat-truffle5-2.0.0.tgz", @@ -7331,7 +6986,104 @@ "bundleDependencies": [ "source-map-support", "yargs", - "ethereumjs-util" + "ethereumjs-util", + "@types/bn.js", + "@types/node", + "@types/pbkdf2", + "@types/secp256k1", + "ansi-regex", + "ansi-styles", + "base-x", + "blakejs", + "bn.js", + "brorand", + "browserify-aes", + "bs58", + "bs58check", + "buffer-from", + "buffer-xor", + "camelcase", + "cipher-base", + "cliui", + "color-convert", + "color-name", + "create-hash", + "create-hmac", + "cross-spawn", + "decamelize", + "elliptic", + "emoji-regex", + "end-of-stream", + "ethereum-cryptography", + "ethjs-util", + "evp_bytestokey", + "execa", + "find-up", + "get-caller-file", + "get-stream", + "hash-base", + "hash.js", + "hmac-drbg", + "inherits", + "invert-kv", + "is-fullwidth-code-point", + "is-hex-prefixed", + "is-stream", + "isexe", + "keccak", + "lcid", + "locate-path", + "map-age-cleaner", + "md5.js", + "mem", + "mimic-fn", + "minimalistic-assert", + "minimalistic-crypto-utils", + "nice-try", + "node-addon-api", + "node-gyp-build", + "npm-run-path", + "once", + "os-locale", + "p-defer", + "p-finally", + "p-is-promise", + "p-limit", + "p-locate", + "p-try", + "path-exists", + "path-key", + "pbkdf2", + "pump", + "randombytes", + "readable-stream", + "require-directory", + "require-main-filename", + "ripemd160", + "rlp", + "safe-buffer", + "scrypt-js", + "secp256k1", + "semver", + "set-blocking", + "setimmediate", + "sha.js", + "shebang-command", + "shebang-regex", + "signal-exit", + "source-map", + "string_decoder", + "string-width", + "strip-ansi", + "strip-eof", + "strip-hex-prefix", + "util-deprecate", + "which", + "which-module", + "wrap-ansi", + "wrappy", + "y18n", + "yargs-parser" ], "dev": true, "dependencies": { @@ -13199,18 +12951,147 @@ } }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.0.tgz", + "integrity": "sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==", "dev": true, - "optional": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { - "node": ">=4" + "node": ">=10.13.0" } }, + "node_modules/prettier-plugin-solidity": { + "version": "1.0.0-beta.13", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.13.tgz", + "integrity": "sha512-AWMDRSabpNQMX7EqdDKgx/UVtQY6e3/Iu4gSPYDGvgiWl+OY8kYhAMll2NZHK/X+F0YYpPHYpebkDh7MGxbB1g==", + "dev": true, + "dependencies": { + "@solidity-parser/parser": "^0.13.2", + "emoji-regex": "^9.2.2", + "escape-string-regexp": "^4.0.0", + "semver": "^7.3.5", + "solidity-comments-extractor": "^0.0.7", + "string-width": "^4.2.2" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "prettier": "^2.3.0" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/@solidity-parser/parser": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.2.tgz", + "integrity": "sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==", + "dev": true, + "dependencies": { + "antlr4ts": "^0.5.0-alpha.4" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/prettier-plugin-solidity/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/string-width/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/prettier-plugin-solidity/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/prettier-plugin-solidity/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/printj": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", @@ -14692,12 +14573,12 @@ } }, "node_modules/solhint": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-3.3.5.tgz", - "integrity": "sha512-GhEZS/C5O6U34fYKc63nyqCQ7/F5qTZ9YWjfBTUOVE8OXy4E8raApwk4jXplv+CoM8olQdRgTm0o4gsmte8JmA==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-3.3.6.tgz", + "integrity": "sha512-HWUxTAv2h7hx3s3hAab3ifnlwb02ZWhwFU/wSudUHqteMS3ll9c+m1FlGn9V8ztE2rf3Z82fQZA005Wv7KpcFA==", "dev": true, "dependencies": { - "@solidity-parser/parser": "^0.13.0-rc.8", + "@solidity-parser/parser": "^0.13.2", "ajv": "^6.6.1", "antlr4": "4.7.1", "ast-parents": "0.0.1", @@ -14720,9 +14601,9 @@ } }, "node_modules/solhint/node_modules/@solidity-parser/parser": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.0.tgz", - "integrity": "sha512-7ItU1sO9MCM0Xt2+hJPMP4cC9C4S86N3hm4jk4Cp+/S7e0kpmWDHfejQ0Pi/gBNPbxTxgYkVNzRCjJELRbwr6Q==", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.2.tgz", + "integrity": "sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==", "dev": true, "dependencies": { "antlr4ts": "^0.5.0-alpha.4" @@ -15002,6 +14883,19 @@ "node": ">=4" } }, + "node_modules/solhint/node_modules/prettier": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "dev": true, + "optional": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/solhint/node_modules/restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -15045,6 +14939,12 @@ "node": ">=4" } }, + "node_modules/solidity-comments-extractor": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz", + "integrity": "sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==", + "dev": true + }, "node_modules/solidity-coverage": { "version": "0.7.16", "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.7.16.tgz", @@ -18288,284 +18188,6 @@ "fastq": "^1.6.0" } }, - "@nomiclabs/hardhat-solhint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-solhint/-/hardhat-solhint-2.0.0.tgz", - "integrity": "sha512-fn+izC923/oCnfbGyp7YwOXZYtwcrDIrTLlFVeEgeSAHe2ZnipRRtNCxEClZuzCptHmTzIIayBmAaijsTmEAoA==", - "dev": true, - "requires": { - "solhint": "^2.0.0" - }, - "dependencies": { - "acorn": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", - "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", - "dev": true - }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "^2.0.0" - } - }, - "cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", - "dev": true - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "commander": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.18.0.tgz", - "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==", - "dev": true - }, - "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0" - } - }, - "eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", - "dev": true, - "requires": { - "acorn": "^6.0.7", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" - } - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "inquirer": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", - "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", - "dev": true, - "requires": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.12", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.1.0", - "through": "^2.3.6" - }, - "dependencies": { - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } - }, - "solhint": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.3.1.tgz", - "integrity": "sha512-wP/G+Dqj8LNWlCI9Mt6XiQRWQfZwv1rkZe/V+HKtip5SAZJVvp144PdH28KE45ZvR99Hhrp/Mujt74fSmXsFiw==", - "dev": true, - "requires": { - "ajv": "^6.6.1", - "antlr4": "4.7.1", - "chalk": "^2.4.2", - "commander": "2.18.0", - "cosmiconfig": "^5.0.7", - "eslint": "^5.6.0", - "fast-diff": "^1.1.2", - "glob": "^7.1.3", - "ignore": "^4.0.6", - "js-yaml": "^3.12.0", - "lodash": "^4.17.11", - "prettier": "^1.14.3", - "semver": "^6.3.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "@nomiclabs/hardhat-truffle5": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-truffle5/-/hardhat-truffle5-2.0.0.tgz", @@ -28283,11 +27905,111 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.0.tgz", + "integrity": "sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==", + "dev": true + }, + "prettier-plugin-solidity": { + "version": "1.0.0-beta.13", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.13.tgz", + "integrity": "sha512-AWMDRSabpNQMX7EqdDKgx/UVtQY6e3/Iu4gSPYDGvgiWl+OY8kYhAMll2NZHK/X+F0YYpPHYpebkDh7MGxbB1g==", "dev": true, - "optional": true + "requires": { + "@solidity-parser/parser": "^0.13.2", + "emoji-regex": "^9.2.2", + "escape-string-regexp": "^4.0.0", + "semver": "^7.3.5", + "solidity-comments-extractor": "^0.0.7", + "string-width": "^4.2.2" + }, + "dependencies": { + "@solidity-parser/parser": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.2.tgz", + "integrity": "sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==", + "dev": true, + "requires": { + "antlr4ts": "^0.5.0-alpha.4" + } + }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + } + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } }, "printj": { "version": "1.1.2", @@ -29456,12 +29178,12 @@ } }, "solhint": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-3.3.5.tgz", - "integrity": "sha512-GhEZS/C5O6U34fYKc63nyqCQ7/F5qTZ9YWjfBTUOVE8OXy4E8raApwk4jXplv+CoM8olQdRgTm0o4gsmte8JmA==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-3.3.6.tgz", + "integrity": "sha512-HWUxTAv2h7hx3s3hAab3ifnlwb02ZWhwFU/wSudUHqteMS3ll9c+m1FlGn9V8ztE2rf3Z82fQZA005Wv7KpcFA==", "dev": true, "requires": { - "@solidity-parser/parser": "^0.13.0-rc.8", + "@solidity-parser/parser": "^0.13.2", "ajv": "^6.6.1", "antlr4": "4.7.1", "ast-parents": "0.0.1", @@ -29479,9 +29201,9 @@ }, "dependencies": { "@solidity-parser/parser": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.0.tgz", - "integrity": "sha512-7ItU1sO9MCM0Xt2+hJPMP4cC9C4S86N3hm4jk4Cp+/S7e0kpmWDHfejQ0Pi/gBNPbxTxgYkVNzRCjJELRbwr6Q==", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.13.2.tgz", + "integrity": "sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==", "dev": true, "requires": { "antlr4ts": "^0.5.0-alpha.4" @@ -29708,6 +29430,13 @@ "mimic-fn": "^1.0.0" } }, + "prettier": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "dev": true, + "optional": true + }, "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -29741,6 +29470,12 @@ } } }, + "solidity-comments-extractor": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz", + "integrity": "sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==", + "dev": true + }, "solidity-coverage": { "version": "0.7.16", "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.7.16.tgz", diff --git a/package.json b/package.json index 8fc103885..eb4acc2ad 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,11 @@ "docs:watch": "npm run docs watch contracts 'docs/*.hbs'", "prepare-docs": "scripts/prepare-docs.sh", "lint": "npm run lint:js && npm run lint:sol", - "lint:fix": "npm run lint:js:fix", + "lint:fix": "npm run lint:js:fix && npm run lint:sol:fix", "lint:js": "eslint --ignore-path .gitignore .", "lint:js:fix": "eslint --ignore-path .gitignore . --fix", - "lint:sol": "echo 'solidity linter currently disabled' # solhint --max-warnings 0 \"contracts/**/*.sol\"", + "lint:sol": "solhint 'contracts/**/*.sol' && prettier -c 'contracts/**/*.sol'", + "lint:sol:fix": "prettier --write \"contracts/**/*.sol\"", "prepublish": "rimraf build contracts/build artifacts cache", "prepare": "env COMPILE_MODE=production npm run compile", "prepack": "scripts/prepack.sh", @@ -48,7 +49,6 @@ }, "homepage": "https://openzeppelin.com/contracts/", "devDependencies": { - "@nomiclabs/hardhat-solhint": "^2.0.0", "@nomiclabs/hardhat-truffle5": "^2.0.0", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.0", @@ -72,8 +72,10 @@ "merkletreejs": "^0.2.13", "micromatch": "^4.0.2", "mocha": "^8.0.1", + "prettier": "^2.3.0", + "prettier-plugin-solidity": "^1.0.0-beta.13", "rimraf": "^3.0.2", - "solhint": "^3.2.0", + "solhint": "^3.3.6", "solidity-coverage": "^0.7.11", "solidity-docgen": "^0.5.3", "web3": "^1.3.0",