diff --git a/foundry.toml b/foundry.toml index 07fbd04549..5756bcc99a 100644 --- a/foundry.toml +++ b/foundry.toml @@ -47,6 +47,7 @@ remappings = [ [fmt] line_length = 100 # While we allow up to 120, we lint at 100 for readability. +ignore = ["src/accounts/EIP7702Proxy.sol"] [profile.default.fuzz] runs = 256 diff --git a/src/accounts/ERC1271.sol b/src/accounts/ERC1271.sol index 86d2eaccec..be8fedb8d9 100644 --- a/src/accounts/ERC1271.sol +++ b/src/accounts/ERC1271.sol @@ -114,7 +114,9 @@ abstract contract ERC1271 is EIP712 { virtual returns (bool result) { - if (_erc1271CallerIsSafe()) result = _erc1271IsValidSignatureNowCalldata(hash, signature); + if (_erc1271CallerIsSafe()) { + result = _erc1271IsValidSignatureNowCalldata(hash, signature); + } } /// @dev ERC1271 signature validation (Nested EIP-712 workflow). diff --git a/src/accounts/ERC4337.sol b/src/accounts/ERC4337.sol index d5256f2a0e..0a7cfcc80c 100644 --- a/src/accounts/ERC4337.sol +++ b/src/accounts/ERC4337.sol @@ -340,14 +340,13 @@ abstract contract ERC4337 is Ownable, UUPSUpgradeable, Receiver, ERC1271 { assembly { mstore(0x20, address()) // Store the `account` argument. mstore(0x00, 0x70a08231) // `balanceOf(address)`. - result := - mul( // Returns 0 if the EntryPoint does not exist. - mload(0x20), - and( // The arguments of `and` are evaluated from right to left. - gt(returndatasize(), 0x1f), // At least 32 bytes returned. - staticcall(gas(), ep, 0x1c, 0x24, 0x20, 0x20) - ) + result := mul( // Returns 0 if the EntryPoint does not exist. + mload(0x20), + and( // The arguments of `and` are evaluated from right to left. + gt(returndatasize(), 0x1f), // At least 32 bytes returned. + staticcall(gas(), ep, 0x1c, 0x24, 0x20, 0x20) ) + ) } } @@ -356,6 +355,7 @@ abstract contract ERC4337 is Ownable, UUPSUpgradeable, Receiver, ERC1271 { address ep = entryPoint(); /// @solidity memory-safe-assembly assembly { + // The EntryPoint has balance accounting logic in the `receive()` function, as defined in ERC-4337. // forgefmt: disable-next-item if iszero(mul(extcodesize(ep), call(gas(), ep, callvalue(), codesize(), 0x00, codesize(), 0x00))) { diff --git a/src/accounts/ERC6551.sol b/src/accounts/ERC6551.sol index 7a4ede9285..cd96fb5499 100644 --- a/src/accounts/ERC6551.sol +++ b/src/accounts/ERC6551.sol @@ -111,14 +111,13 @@ abstract contract ERC6551 is UUPSUpgradeable, Receiver, ERC1271 { let tokenContract := mload(0x20) // `tokenId` is already at 0x40. mstore(0x20, 0x6352211e) // `ownerOf(uint256)`. - result := - mul( // Returns `address(0)` on failure or if contract does not exist. - mload(0x20), - and( - gt(returndatasize(), 0x1f), - staticcall(gas(), tokenContract, 0x3c, 0x24, 0x20, 0x20) - ) + result := mul( // Returns `address(0)` on failure or if contract does not exist. + mload(0x20), + and( + gt(returndatasize(), 0x1f), + staticcall(gas(), tokenContract, 0x3c, 0x24, 0x20, 0x20) ) + ) } mstore(0x40, m) // Restore the free memory pointer. } diff --git a/src/accounts/LibERC7579.sol b/src/accounts/LibERC7579.sol index e7a601ab9a..2db15b683c 100644 --- a/src/accounts/LibERC7579.sol +++ b/src/accounts/LibERC7579.sol @@ -248,8 +248,9 @@ library LibERC7579 { function hasOpData(bytes calldata executionData) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { - result := - iszero(or(lt(executionData.length, 0x40), lt(calldataload(executionData.offset), 0x40))) + result := iszero( + or(lt(executionData.length, 0x40), lt(calldataload(executionData.offset), 0x40)) + ) } } diff --git a/src/accounts/Timelock.sol b/src/accounts/Timelock.sol index 0a80f1d940..7b6e02f8f4 100644 --- a/src/accounts/Timelock.sol +++ b/src/accounts/Timelock.sol @@ -69,7 +69,6 @@ contract Timelock is ERC7821, EnumerableRoles { Waiting, // 1. Ready, // 2. Done // 3. - } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ @@ -384,7 +383,9 @@ contract Timelock is ERC7821, EnumerableRoles { Call[] calldata calls, bytes calldata opData ) internal virtual override(ERC7821) { - if (!hasRole(OPEN_ROLE_HOLDER, EXECUTOR_ROLE)) _checkRole(EXECUTOR_ROLE); + if (!hasRole(OPEN_ROLE_HOLDER, EXECUTOR_ROLE)) { + _checkRole(EXECUTOR_ROLE); + } bytes32 id; uint256 s; /// @solidity memory-safe-assembly diff --git a/src/auth/EnumerableRoles.sol b/src/auth/EnumerableRoles.sol index 19164b318d..871a300ad0 100644 --- a/src/auth/EnumerableRoles.sol +++ b/src/auth/EnumerableRoles.sol @@ -296,11 +296,10 @@ abstract contract EnumerableRoles { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x8da5cb5b) // `owner()`. - result := - and( - and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)), - staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20) - ) + result := and( + and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)), + staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20) + ) } } diff --git a/src/auth/TimedRoles.sol b/src/auth/TimedRoles.sol index cc0f68ba29..2206a5bffc 100644 --- a/src/auth/TimedRoles.sol +++ b/src/auth/TimedRoles.sol @@ -167,10 +167,12 @@ abstract contract TimedRoles { } /// @dev Checks that the caller is authorized to set the timed role. - function _authorizeSetTimedRole(address holder, uint256 timedRole, uint40 start, uint40 expires) - internal - virtual - { + function _authorizeSetTimedRole( + address holder, + uint256 timedRole, + uint40 start, + uint40 expires + ) internal virtual { if (!_timedRolesSenderIsContractOwner()) _revertTimedRolesUnauthorized(); // Silence compiler warning on unused variables. (holder, timedRole, start, expires) = (holder, timedRole, start, expires); @@ -193,8 +195,9 @@ abstract contract TimedRoles { encodedTimeRoles := add(0x20, encodedTimeRoles) mstore(0x00, mload(encodedTimeRoles)) let p := sload(keccak256(0x00, 0x38)) - result := - iszero(or(lt(timestamp(), shr(216, p)), gt(timestamp(), and(0xffffffffff, p)))) + result := iszero( + or(lt(timestamp(), shr(216, p)), gt(timestamp(), and(0xffffffffff, p))) + ) } } } @@ -263,11 +266,10 @@ abstract contract TimedRoles { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x8da5cb5b) // `owner()`. - result := - and( - and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)), - staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20) - ) + result := and( + and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)), + staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20) + ) } } diff --git a/src/tokens/ERC4626.sol b/src/tokens/ERC4626.sol index 6860882f1e..b78f60c71f 100644 --- a/src/tokens/ERC4626.sol +++ b/src/tokens/ERC4626.sol @@ -129,13 +129,12 @@ abstract contract ERC4626 is ERC20 { // Store the function selector of `decimals()`. mstore(0x00, 0x313ce567) // Arguments are evaluated last to first. - success := - and( - // Returned value is less than 256, at left-padded to 32 bytes. - and(lt(mload(0x00), 0x100), gt(returndatasize(), 0x1f)), - // The staticcall succeeds. - staticcall(gas(), underlying, 0x1c, 0x04, 0x00, 0x20) - ) + success := and( + // Returned value is less than 256, at left-padded to 32 bytes. + and(lt(mload(0x00), 0x100), gt(returndatasize(), 0x1f)), + // The staticcall succeeds. + staticcall(gas(), underlying, 0x1c, 0x04, 0x00, 0x20) + ) result := mul(mload(0x00), success) } } diff --git a/src/tokens/ERC6909.sol b/src/tokens/ERC6909.sol index 39940cf73b..5f94d32493 100644 --- a/src/tokens/ERC6909.sol +++ b/src/tokens/ERC6909.sol @@ -486,10 +486,7 @@ abstract contract ERC6909 { /// @dev Sets `amount` as the allowance of `spender` for `owner` for token `id`. /// /// Emits a {Approval} event. - function _approve(address owner, address spender, uint256 id, uint256 amount) - internal - virtual - { + function _approve(address owner, address spender, uint256 id, uint256 amount) internal virtual { /// @solidity memory-safe-assembly assembly { // Compute the allowance slot and store the amount. @@ -535,13 +532,11 @@ abstract contract ERC6909 { /// This includes minting and burning. function _beforeTokenTransfer(address from, address to, uint256 id, uint256 amount) internal - virtual - {} + virtual {} /// @dev Hook that is called after any transfer of tokens. /// This includes minting and burning. function _afterTokenTransfer(address from, address to, uint256 id, uint256 amount) internal - virtual - {} + virtual {} } diff --git a/src/utils/Base58.sol b/src/utils/Base58.sol index 760d37e408..a6f6d391ff 100644 --- a/src/utils/Base58.sol +++ b/src/utils/Base58.sol @@ -98,9 +98,10 @@ library Base58 { o := add(o, w) mstore8(o, mload(mod(v, 58))) } - for {} iszero(byte(z, data)) { z := add(z, 1) } {} // Just loop, `z` is often tiny. + for {} // Just loop, `z` is often tiny. + iszero(byte(z, data)) { z := add(z, 1) } {} } - if z { mstore(sub(o, 0x20), mul(div(w, 0xff), 49)) } // '1111...1111' in ASCII. + if z { mstore(sub(o, 0x20), mul(div(w, 0xff), 49))} // '1111...1111' in ASCII. o := sub(o, z) let n := sub(e, o) // Compute the final length. diff --git a/src/utils/Base64.sol b/src/utils/Base64.sol index 357add0cd8..8164fd614e 100644 --- a/src/utils/Base64.sol +++ b/src/utils/Base64.sol @@ -84,11 +84,7 @@ library Base64 { /// @dev Encodes `data` using the base64 encoding described in RFC 4648. /// Equivalent to `encode(data, fileSafe, false)`. - function encode(bytes memory data, bool fileSafe) - internal - pure - returns (string memory result) - { + function encode(bytes memory data, bool fileSafe) internal pure returns (string memory result) { result = encode(data, fileSafe, false); } diff --git a/src/utils/DateTimeLib.sol b/src/utils/DateTimeLib.sol index 00e8f5837b..cb79613437 100644 --- a/src/utils/DateTimeLib.sol +++ b/src/utils/DateTimeLib.sol @@ -181,8 +181,10 @@ library DateTimeLib { assembly { // `daysInMonths = [31,28,31,30,31,30,31,31,30,31,30,31]`. // `result = daysInMonths[month - 1] + isLeapYear(year)`. - result := - add(byte(month, shl(152, 0x1f1c1f1e1f1e1f1f1e1f1e1f)), and(eq(month, 2), flag)) + result := add( + byte(month, shl(152, 0x1f1c1f1e1f1e1f1f1e1f1e1f)), + and(eq(month, 2), flag) + ) } } @@ -206,11 +208,10 @@ library DateTimeLib { uint256 md = daysInMonth(year, month); /// @solidity memory-safe-assembly assembly { - result := - and( - lt(sub(year, 1970), sub(MAX_SUPPORTED_YEAR, 1969)), - and(lt(sub(month, 1), 12), lt(sub(day, 1), md)) - ) + result := and( + lt(sub(year, 1970), sub(MAX_SUPPORTED_YEAR, 1969)), + and(lt(sub(month, 1), 12), lt(sub(day, 1), md)) + ) } } diff --git a/src/utils/DynamicArrayLib.sol b/src/utils/DynamicArrayLib.sol index 2dac234f6c..9756de5f29 100644 --- a/src/utils/DynamicArrayLib.sol +++ b/src/utils/DynamicArrayLib.sol @@ -442,7 +442,9 @@ library DynamicArrayLib { let arrLen := mload(arrData) if iszero(lt(n, arrLen)) { calldatacopy( - add(arrData, shl(5, add(1, arrLen))), calldatasize(), shl(5, sub(n, arrLen)) + add(arrData, shl(5, add(1, arrLen))), + calldatasize(), + shl(5, sub(n, arrLen)) ) } mstore(arrData, n) @@ -802,11 +804,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `uint256[]`. - function asUint256Array(DynamicArray memory a) - internal - pure - returns (uint256[] memory result) - { + function asUint256Array(DynamicArray memory a) internal pure returns (uint256[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) @@ -814,11 +812,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `address[]`. - function asAddressArray(DynamicArray memory a) - internal - pure - returns (address[] memory result) - { + function asAddressArray(DynamicArray memory a) internal pure returns (address[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) @@ -834,11 +828,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `bytes32[]`. - function asBytes32Array(DynamicArray memory a) - internal - pure - returns (bytes32[] memory result) - { + function asBytes32Array(DynamicArray memory a) internal pure returns (bytes32[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) diff --git a/src/utils/ECDSA.sol b/src/utils/ECDSA.sol index c2ba9b1d58..eeee035a5c 100644 --- a/src/utils/ECDSA.sol +++ b/src/utils/ECDSA.sol @@ -29,7 +29,8 @@ library ECDSA { /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The order of the secp256k1 elliptic curve. - uint256 internal constant N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141; + uint256 internal constant N = + 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141; /// @dev `N/2 + 1`. Used for checking the malleability of the signature. uint256 private constant _HALF_N_PLUS_1 = diff --git a/src/utils/EnumerableMapLib.sol b/src/utils/EnumerableMapLib.sol index 57154c6d02..122c807e84 100644 --- a/src/utils/EnumerableMapLib.sol +++ b/src/utils/EnumerableMapLib.sol @@ -149,7 +149,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -230,7 +232,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -311,7 +315,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -392,7 +398,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -473,7 +481,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -554,7 +564,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -635,7 +647,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -716,7 +730,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -797,7 +813,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. diff --git a/src/utils/EnumerableSetLib.sol b/src/utils/EnumerableSetLib.sol index cb770dd1ec..723edb4e28 100644 --- a/src/utils/EnumerableSetLib.sol +++ b/src/utils/EnumerableSetLib.sol @@ -382,7 +382,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -391,7 +393,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -400,7 +404,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -760,11 +766,7 @@ library EnumerableSetLib { } /// @dev Returns the index of `value`. Returns `NOT_FOUND` if the value does not exist. - function indexOf(AddressSet storage set, address value) - internal - view - returns (uint256 result) - { + function indexOf(AddressSet storage set, address value) internal view returns (uint256 result) { result = NOT_FOUND; if (uint160(value) == _ZERO_SENTINEL) return result; bytes32 rootSlot = _rootSlot(set); @@ -798,11 +800,7 @@ library EnumerableSetLib { } /// @dev Returns the index of `value`. Returns `NOT_FOUND` if the value does not exist. - function indexOf(Bytes32Set storage set, bytes32 value) - internal - view - returns (uint256 result) - { + function indexOf(Bytes32Set storage set, bytes32 value) internal view returns (uint256 result) { result = NOT_FOUND; if (uint256(value) == _ZERO_SENTINEL) return result; bytes32 rootSlot = _rootSlot(set); diff --git a/src/utils/FixedPointMathLib.sol b/src/utils/FixedPointMathLib.sol index 235336345a..1eb2a8f8c0 100644 --- a/src/utils/FixedPointMathLib.sol +++ b/src/utils/FixedPointMathLib.sol @@ -350,7 +350,12 @@ library FixedPointMathLib { /// See: https://en.wikipedia.org/wiki/Lambert_W_function /// a.k.a. Product log function. This is an approximation of the principal branch. /// Note: This function is an approximation. Monotonically increasing. - function lambertW0Wad(int256 x) internal pure returns (int256 w) { + function lambertW0Wad(int256 x) + internal + pure + returns (int256 w) + { + // forgefmt: disable-next-item unchecked { if ((w = x) <= -367879441171442322) revert OutOfDomain(); // `x` less than `-1/e`. @@ -495,14 +500,13 @@ library FixedPointMathLib { inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**32 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**64 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**128 - z := - mul( - // Divide [p1 p0] by the factors of two. - // Shift in bits from `p1` into `p0`. For this we need - // to flip `t` such that it is `2**256 / t`. - or(mul(sub(p1, gt(r, z)), add(div(sub(0, t), t), 1)), div(sub(z, r), t)), - mul(sub(2, mul(d, inv)), inv) // inverse mod 2**256 - ) + z := mul( + // Divide [p1 p0] by the factors of two. + // Shift in bits from `p1` into `p0`. For this we need + // to flip `t` such that it is `2**256 / t`. + or(mul(sub(p1, gt(r, z)), add(div(sub(0, t), t), 1)), div(sub(z, r), t)), + mul(sub(2, mul(d, inv)), inv) // inverse mod 2**256 + ) break } z := div(z, d) @@ -533,11 +537,10 @@ library FixedPointMathLib { inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) - z := - mul( - or(mul(sub(p1, gt(r, z)), add(div(sub(0, t), t), 1)), div(sub(z, r), t)), - mul(sub(2, mul(d, inv)), inv) - ) + z := mul( + or(mul(sub(p1, gt(r, z)), add(div(sub(0, t), t), 1)), div(sub(z, r), t)), + mul(sub(2, mul(d, inv)), inv) + ) } } diff --git a/src/utils/JSONParserLib.sol b/src/utils/JSONParserLib.sol index 881993b3d8..76c3e3ff22 100644 --- a/src/utils/JSONParserLib.sol +++ b/src/utils/JSONParserLib.sol @@ -588,6 +588,7 @@ library JSONParserLib { } _item, _pOut := parseValue(s_, _item, _pOut, end_) if _item { + // forgefmt: disable-next-item mstore(_item, setP(or(_PARENT_IS_ARRAY, mload(_item)), _BITPOS_KEY, j_)) @@ -618,6 +619,7 @@ library JSONParserLib { if eq(chr(_pOut), 58) { _item, _pOut := parseValue(s_, _item, add(_pOut, 1), end_) if _item { + // forgefmt: disable-next-item mstore(_item, setP(setP(or(_PARENT_IS_OBJECT, mload(_item)), _BITPOS_KEY_LENGTH, sub(pKeyEnd_, pKeyStart_)), @@ -686,7 +688,11 @@ library JSONParserLib { if eq(chr(_pOut), 46) { _pOut := skip0To9s(add(_pOut, 1), end_, 1) } // '.'. let t_ := mload(_pOut) // 'E', 'e'. - if eq(or(0x20, byte(0, t_)), 101) { + if eq( + or(0x20, byte(0, t_)), + 101 + ) { + // forgefmt: disable-next-item _pOut := skip0To9s(add(byte(sub(byte(1, t_), 14), 0x010001), // '+', '-'. add(_pOut, 1)), end_, 1) diff --git a/src/utils/LibBitmap.sol b/src/utils/LibBitmap.sol index c4094c5393..a9c813a8d5 100644 --- a/src/utils/LibBitmap.sol +++ b/src/utils/LibBitmap.sol @@ -134,7 +134,8 @@ library LibBitmap { } let storageSlot := keccak256(0x00, 0x40) sstore( - storageSlot, and(sload(storageSlot), not(shl(shift, shr(sub(256, amount), not(0))))) + storageSlot, + and(sload(storageSlot), not(shl(shift, shr(sub(256, amount), not(0))))) ) } } diff --git a/src/utils/LibBytes.sol b/src/utils/LibBytes.sol index 7541b5b693..e0b7275807 100644 --- a/src/utils/LibBytes.sol +++ b/src/utils/LibBytes.sol @@ -514,11 +514,7 @@ library LibBytes { /// @dev Reduces the size of `subject` to `n`. /// If `n` is greater than the size of `subject`, this will be a no-op. - function truncate(bytes memory subject, uint256 n) - internal - pure - returns (bytes memory result) - { + function truncate(bytes memory subject, uint256 n) internal pure returns (bytes memory result) { /// @solidity memory-safe-assembly assembly { result := subject @@ -782,11 +778,7 @@ library LibBytes { } /// @dev Returns the word at `offset`, without any bounds checks. - function loadCalldata(bytes calldata a, uint256 offset) - internal - pure - returns (bytes32 result) - { + function loadCalldata(bytes calldata a, uint256 offset) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { result := calldataload(add(a.offset, offset)) diff --git a/src/utils/LibCall.sol b/src/utils/LibCall.sol index 231409509f..5fb657bb3e 100644 --- a/src/utils/LibCall.sol +++ b/src/utils/LibCall.sol @@ -154,8 +154,15 @@ library LibCall { /// @solidity memory-safe-assembly assembly { result := mload(0x40) - success := - call(gasStipend, target, value, add(data, 0x20), mload(data), codesize(), 0x00) + success := call( + gasStipend, + target, + value, + add(data, 0x20), + mload(data), + codesize(), + 0x00 + ) let n := returndatasize() if gt(returndatasize(), and(0xffff, maxCopy)) { n := and(0xffff, maxCopy) @@ -179,8 +186,14 @@ library LibCall { /// @solidity memory-safe-assembly assembly { result := mload(0x40) - success := - staticcall(gasStipend, target, add(data, 0x20), mload(data), codesize(), 0x00) + success := staticcall( + gasStipend, + target, + add(data, 0x20), + mload(data), + codesize(), + 0x00 + ) let n := returndatasize() if gt(returndatasize(), and(0xffff, maxCopy)) { n := and(0xffff, maxCopy) diff --git a/src/utils/LibClone.sol b/src/utils/LibClone.sol index 504e62c4aa..7148aaa67f 100644 --- a/src/utils/LibClone.sol +++ b/src/utils/LibClone.sol @@ -2566,10 +2566,11 @@ library LibClone { } /// @dev Deploys a deterministic ERC1967I beacon proxy with `args` and `salt`. - function deployDeterministicERC1967IBeaconProxy(address beacon, bytes memory args, bytes32 salt) - internal - returns (address instance) - { + function deployDeterministicERC1967IBeaconProxy( + address beacon, + bytes memory args, + bytes32 salt + ) internal returns (address instance) { instance = deployDeterministicERC1967IBeaconProxy(0, beacon, args, salt); } @@ -2603,10 +2604,11 @@ library LibClone { /// @dev Creates a deterministic ERC1967I beacon proxy with `args` and `salt`. /// Note: This method is intended for use in ERC4337 factories, /// which are expected to NOT revert if the proxy is already deployed. - function createDeterministicERC1967IBeaconProxy(address beacon, bytes memory args, bytes32 salt) - internal - returns (bool alreadyDeployed, address instance) - { + function createDeterministicERC1967IBeaconProxy( + address beacon, + bytes memory args, + bytes32 salt + ) internal returns (bool alreadyDeployed, address instance) { return createDeterministicERC1967IBeaconProxy(0, beacon, args, salt); } @@ -2721,11 +2723,7 @@ library LibClone { } /// @dev Equivalent to `argsOnERC1967IBeaconProxy(instance, start, 2 ** 256 - 1)`. - function argsOnERC1967IBeaconProxy(address instance) - internal - view - returns (bytes memory args) - { + function argsOnERC1967IBeaconProxy(address instance) internal view returns (bytes memory args) { /// @solidity memory-safe-assembly assembly { args := mload(0x40) diff --git a/src/utils/LibSort.sol b/src/utils/LibSort.sol index 360bf801fa..ea7fe145ca 100644 --- a/src/utils/LibSort.sol +++ b/src/utils/LibSort.sol @@ -540,11 +540,7 @@ library LibSort { /// @dev Returns the sorted set union of `a` and `b`. /// Note: Behaviour is undefined if inputs are not sorted and uniquified. - function union(int256[] memory a, int256[] memory b) - internal - pure - returns (int256[] memory c) - { + function union(int256[] memory a, int256[] memory b) internal pure returns (int256[] memory c) { c = _toInts(_union(_toUints(a), _toUints(b), 1 << 255)); } diff --git a/src/utils/LibString.sol b/src/utils/LibString.sol index 3d40155025..708004f41f 100644 --- a/src/utils/LibString.sol +++ b/src/utils/LibString.sol @@ -676,7 +676,8 @@ library LibString { assembly { result := mload(0x40) let n := 0 - for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(n, s) { n := add(n, 1) } {} mstore(result, n) // Store the length. let o := add(result, 0x20) mstore(o, s) // Store the bytes of the string. @@ -689,7 +690,8 @@ library LibString { function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { - for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(result, s) { result := add(result, 1) } {} mstore(0x00, s) mstore(result, 0x00) result := mload(0x00) @@ -889,14 +891,13 @@ library LibString { assembly { // We don't need to zero right pad the string, // since this is our own custom non-standard packing scheme. - result := - mul( - // Load the length and the bytes. - mload(add(a, 0x1f)), - // `length != 0 && length < 32`. Abuses underflow. - // Assumes that the length is valid and within the block gas limit. - lt(sub(mload(a), 1), 0x1f) - ) + result := mul( + // Load the length and the bytes. + mload(add(a, 0x1f)), + // `length != 0 && length < 32`. Abuses underflow. + // Assumes that the length is valid and within the block gas limit. + lt(sub(mload(a), 1), 0x1f) + ) } } @@ -922,14 +923,15 @@ library LibString { let aLen := mload(a) // We don't need to zero right pad the strings, // since this is our own custom non-standard packing scheme. - result := - mul( - or( // Load the length and the bytes of `a` and `b`. - shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), mload(sub(add(b, 0x1e), aLen))), - // `totalLen != 0 && totalLen < 31`. Abuses underflow. - // Assumes that the lengths are valid and within the block gas limit. - lt(sub(add(aLen, mload(b)), 1), 0x1e) - ) + result := mul( + or( // Load the length and the bytes of `a` and `b`. + shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), + mload(sub(add(b, 0x1e), aLen)) + ), + // `totalLen != 0 && totalLen < 31`. Abuses underflow. + // Assumes that the lengths are valid and within the block gas limit. + lt(sub(add(aLen, mload(b)), 1), 0x1e) + ) } } diff --git a/src/utils/MerkleProofLib.sol b/src/utils/MerkleProofLib.sol index 967eb98e2d..1998d54caa 100644 --- a/src/utils/MerkleProofLib.sol +++ b/src/utils/MerkleProofLib.sol @@ -167,13 +167,12 @@ library MerkleProofLib { hashesBack := add(hashesBack, 0x20) if iszero(lt(hashesBack, flagsLength)) { break } } - isValid := - and( - // Checks if the last value in the queue is same as the root. - eq(mload(sub(hashesBack, 0x20)), root), - // And whether all the proofs are used, if required. - eq(proofEnd, proof) - ) + isValid := and( + // Checks if the last value in the queue is same as the root. + eq(mload(sub(hashesBack, 0x20)), root), + // And whether all the proofs are used, if required. + eq(proofEnd, proof) + ) break } } @@ -207,7 +206,10 @@ library MerkleProofLib { // If the number of flags is correct. for {} eq(add(leaves.length, proof.length), add(flags.length, 1)) {} { // For the case where `proof.length + leaves.length == 1`. - if iszero(flags.length) { + if iszero( + flags.length + ) { + // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`. // forgefmt: disable-next-item isValid := eq( @@ -267,13 +269,12 @@ library MerkleProofLib { hashesBack := add(hashesBack, 0x20) if iszero(lt(hashesBack, flags.length)) { break } } - isValid := - and( - // Checks if the last value in the queue is same as the root. - eq(mload(sub(hashesBack, 0x20)), root), - // And whether all the proofs are used, if required. - eq(proofEnd, proof.offset) - ) + isValid := and( + // Checks if the last value in the queue is same as the root. + eq(mload(sub(hashesBack, 0x20)), root), + // And whether all the proofs are used, if required. + eq(proofEnd, proof.offset) + ) break } } diff --git a/src/utils/MerkleTreeLib.sol b/src/utils/MerkleTreeLib.sol index 260fac58cd..a50021cb9f 100644 --- a/src/utils/MerkleTreeLib.sol +++ b/src/utils/MerkleTreeLib.sol @@ -95,11 +95,7 @@ library MerkleTreeLib { } /// @dev Returns the leaf at `leafIndex`. - function leaf(bytes32[] memory tree, uint256 leafIndex) - internal - pure - returns (bytes32 result) - { + function leaf(bytes32[] memory tree, uint256 leafIndex) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { let n := mload(tree) diff --git a/src/utils/MetadataReaderLib.sol b/src/utils/MetadataReaderLib.sol index b4b83dcda0..ca671ee47d 100644 --- a/src/utils/MetadataReaderLib.sol +++ b/src/utils/MetadataReaderLib.sol @@ -174,7 +174,8 @@ library MetadataReaderLib { returndatacopy(s, 0, n) // Copy the string's bytes. mstore8(add(s, n), 0) // Place a '\0' at the end. let i := s // Pointer to the next byte to scan. - for {} byte(0, mload(i)) { i := add(i, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(0, mload(i)) { i := add(i, 1) } {} mstore(m, sub(i, s)) // Store the string's length. mstore(i, 0) // Zeroize the slot after the string. mstore(0x40, add(0x20, i)) // Allocate memory for the string. @@ -192,14 +193,13 @@ library MetadataReaderLib { { /// @solidity memory-safe-assembly assembly { - result := - mul( - mload(0x20), - and( // The arguments of `and` are evaluated from right to left. - gt(returndatasize(), 0x1f), // At least 32 bytes returned. - staticcall(gasStipend, target, add(ptr, 0x20), mload(ptr), 0x20, 0x20) - ) + result := mul( + mload(0x20), + and( // The arguments of `and` are evaluated from right to left. + gt(returndatasize(), 0x1f), // At least 32 bytes returned. + staticcall(gasStipend, target, add(ptr, 0x20), mload(ptr), 0x20, 0x20) ) + ) } } diff --git a/src/utils/P256.sol b/src/utils/P256.sol index 57419e1074..b7d207a8ee 100644 --- a/src/utils/P256.sol +++ b/src/utils/P256.sol @@ -30,7 +30,8 @@ library P256 { address internal constant RIP_PRECOMPILE = 0x0000000000000000000000000000000000000100; /// @dev The order of the secp256r1 elliptic curve. - uint256 internal constant N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; + uint256 internal constant N = + 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; /// @dev `N/2`. Used for checking the malleability of the signature. uint256 private constant _HALF_N = diff --git a/src/utils/SafeTransferLib.sol b/src/utils/SafeTransferLib.sol index 2e86732891..ba7c83efe1 100644 --- a/src/utils/SafeTransferLib.sol +++ b/src/utils/SafeTransferLib.sol @@ -165,6 +165,7 @@ library SafeTransferLib { function forceSafeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { + // forgefmt: disable-next-item if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. @@ -187,10 +188,7 @@ library SafeTransferLib { } /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`. - function trySafeTransferAllETH(address to, uint256 gasStipend) - internal - returns (bool success) - { + function trySafeTransferAllETH(address to, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00) @@ -444,14 +442,13 @@ library SafeTransferLib { assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. - amount := - mul( // The arguments of `mul` are evaluated from right to left. - mload(0x20), - and( // The arguments of `and` are evaluated from right to left. - gt(returndatasize(), 0x1f), // At least 32 bytes returned. - staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) - ) + amount := mul( // The arguments of `mul` are evaluated from right to left. + mload(0x20), + and( // The arguments of `and` are evaluated from right to left. + gt(returndatasize(), 0x1f), // At least 32 bytes returned. + staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) ) + ) } } @@ -467,11 +464,10 @@ library SafeTransferLib { assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. - implemented := - and( // The arguments of `and` are evaluated from right to left. - gt(returndatasize(), 0x1f), // At least 32 bytes returned. - staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) - ) + implemented := and( // The arguments of `and` are evaluated from right to left. + gt(returndatasize(), 0x1f), // At least 32 bytes returned. + staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) + ) amount := mul(mload(0x20), implemented) } } @@ -505,9 +501,7 @@ library SafeTransferLib { /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2. /// Reverts upon failure. - function permit2TransferFrom(address token, address from, address to, uint256 amount) - internal - { + function permit2TransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) @@ -637,7 +631,8 @@ library SafeTransferLib { mstore(add(m, 0x160), s) mstore(add(m, 0x180), shl(248, v)) if iszero( // Revert if token does not have code, or if the call fails. - mul(extcodesize(token), call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00))) { + mul(extcodesize(token), call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) + ) { mstore(0x00, 0x6b836e6b) // `Permit2Failed()`. revert(0x1c, 0x04) } diff --git a/src/utils/SemVerLib.sol b/src/utils/SemVerLib.sol index 09b5e09a6e..237a3fb76d 100644 --- a/src/utils/SemVerLib.sol +++ b/src/utils/SemVerLib.sol @@ -42,8 +42,8 @@ library SemVerLib { let u := eq(byte(i, a), 46) // `.` let v := eq(byte(j, b), 46) // `.` if iszero(lt(result, or(u, v))) { break } - if u { u, i := mmp(add(i, 1), a) } // `.` - if v { v, j := mmp(add(j, 1), b) } // `.` + if u { u, i := mmp(add(i, 1), a)} // `.` + if v { v, j := mmp(add(j, 1), b)} // `.` result := sub(gt(u, v), lt(u, v)) } if iszero(result) { diff --git a/src/utils/SignatureCheckerLib.sol b/src/utils/SignatureCheckerLib.sol index c4f69f5530..2ef62b9063 100644 --- a/src/utils/SignatureCheckerLib.sol +++ b/src/utils/SignatureCheckerLib.sol @@ -278,11 +278,13 @@ library SignatureCheckerLib { /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash` /// for an ERC1271 `signer` contract. - function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s) - internal - view - returns (bool isValid) - { + function isValidERC1271SignatureNow( + address signer, + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) diff --git a/src/utils/UUPSUpgradeable.sol b/src/utils/UUPSUpgradeable.sol index 124c3a3fe0..946e02a832 100644 --- a/src/utils/UUPSUpgradeable.sol +++ b/src/utils/UUPSUpgradeable.sol @@ -93,8 +93,9 @@ abstract contract UUPSUpgradeable is CallContextChecker { // Forwards the `data` to `newImplementation` via delegatecall. let m := mload(0x40) calldatacopy(m, data.offset, data.length) - if iszero(delegatecall(gas(), newImplementation, m, data.length, codesize(), 0x00)) - { + if iszero( + delegatecall(gas(), newImplementation, m, data.length, codesize(), 0x00) + ) { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) diff --git a/src/utils/WebAuthn.sol b/src/utils/WebAuthn.sol index e2facb56da..ed8ae504f1 100644 --- a/src/utils/WebAuthn.sol +++ b/src/utils/WebAuthn.sol @@ -103,19 +103,18 @@ library WebAuthn { let l := mload(encoded) // Cache `encoded`'s length. let q := add(l, 0x0d) // Length of `encoded` prefixed with '"challenge":"'. mstore(encoded, shr(152, '"challenge":"')) // Temp prefix with '"challenge":"'. - result := + result := and( + // 11. Verify JSON's type. Also checks for possible addition overflows. and( - // 11. Verify JSON's type. Also checks for possible addition overflows. - and( - eq(shr(88, mload(add(o, t))), shr(88, '"type":"webauthn.get"')), - lt(shr(128, or(t, c)), lt(add(0x14, t), n)) - ), - // 12. Verify JSON's challenge. Includes a check for the closing '"'. - and( - eq(keccak256(add(o, c), q), keccak256(add(encoded, 0x13), q)), - and(eq(byte(0, mload(add(add(o, c), q))), 34), lt(add(q, c), n)) - ) + eq(shr(88, mload(add(o, t))), shr(88, '"type":"webauthn.get"')), + lt(shr(128, or(t, c)), lt(add(0x14, t), n)) + ), + // 12. Verify JSON's challenge. Includes a check for the closing '"'. + and( + eq(keccak256(add(o, c), q), keccak256(add(encoded, 0x13), q)), + and(eq(byte(0, mload(add(add(o, c), q))), 34), lt(add(q, c), n)) ) + ) mstore(encoded, l) // Restore `encoded`'s length, in case of string interning. } // Skip 13., 14., 15. diff --git a/src/utils/ext/delegatexyz/DelegateCheckerLib.sol b/src/utils/ext/delegatexyz/DelegateCheckerLib.sol index 7ca3eb242f..34daab0d95 100644 --- a/src/utils/ext/delegatexyz/DelegateCheckerLib.sol +++ b/src/utils/ext/delegatexyz/DelegateCheckerLib.sol @@ -40,8 +40,10 @@ library DelegateCheckerLib { isValid := eq(mload(staticcall(gas(), DELEGATE_REGISTRY_V2, 0x1c, 0x64, 0x01, 0x20)), 1) if iszero(isValid) { mstore(0x01, 0x9c395bc200) // `checkDelegateForAll(address,address)`. - isValid := - eq(mload(staticcall(gas(), DELEGATE_REGISTRY_V1, 0x1c, 0x44, 0x01, 0x20)), 1) + isValid := eq( + mload(staticcall(gas(), DELEGATE_REGISTRY_V1, 0x1c, 0x44, 0x01, 0x20)), + 1 + ) } mstore(0x40, m) // Restore the free memory pointer. } @@ -67,8 +69,10 @@ library DelegateCheckerLib { isValid := eq(mload(staticcall(gas(), DELEGATE_REGISTRY_V2, 0x1c, 0x64, 0x01, 0x20)), 1) if iszero(or(rights, isValid)) { mstore(0x01, 0x9c395bc200) // `checkDelegateForAll(address,address)`. - isValid := - eq(mload(staticcall(gas(), DELEGATE_REGISTRY_V1, 0x1c, 0x44, 0x01, 0x20)), 1) + isValid := eq( + mload(staticcall(gas(), DELEGATE_REGISTRY_V1, 0x1c, 0x44, 0x01, 0x20)), + 1 + ) } mstore(0x40, m) // Restore the free memory pointer. mstore(0x60, 0) // Restore the zero pointer. diff --git a/src/utils/ext/ithaca/BLS.sol b/src/utils/ext/ithaca/BLS.sol index 8c21ad997c..88ea7f8e35 100644 --- a/src/utils/ext/ithaca/BLS.sol +++ b/src/utils/ext/ithaca/BLS.sol @@ -292,7 +292,9 @@ library BLS { mcopy(add(s_, 0x60), b_, 0x40) if iszero( and(eq(returndatasize(), 0x40), staticcall(gas(), 5, s_, 0x100, b_, 0x40)) - ) { revert(calldatasize(), 0x00) } + ) { + revert(calldatasize(), 0x00) + } } function mapToG2(s_, r_) { diff --git a/src/utils/ext/zksync/SafeTransferLib.sol b/src/utils/ext/zksync/SafeTransferLib.sol index a968359483..e0894d501f 100644 --- a/src/utils/ext/zksync/SafeTransferLib.sol +++ b/src/utils/ext/zksync/SafeTransferLib.sol @@ -146,10 +146,7 @@ library SafeTransferLib { } /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`. - function trySafeTransferAllETH(address to, uint256 gasStipend) - internal - returns (bool success) - { + function trySafeTransferAllETH(address to, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, selfbalance(), 0x00, 0x00, 0x00, 0x00) @@ -358,14 +355,13 @@ library SafeTransferLib { assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. - amount := - mul( // The arguments of `mul` are evaluated from right to left. - mload(0x20), - and( // The arguments of `and` are evaluated from right to left. - gt(returndatasize(), 0x1f), // At least 32 bytes returned. - staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) - ) + amount := mul( // The arguments of `mul` are evaluated from right to left. + mload(0x20), + and( // The arguments of `and` are evaluated from right to left. + gt(returndatasize(), 0x1f), // At least 32 bytes returned. + staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) ) + ) } } diff --git a/src/utils/ext/zksync/SignatureCheckerLib.sol b/src/utils/ext/zksync/SignatureCheckerLib.sol index 6120e8766c..5543a2eeb5 100644 --- a/src/utils/ext/zksync/SignatureCheckerLib.sol +++ b/src/utils/ext/zksync/SignatureCheckerLib.sol @@ -286,11 +286,13 @@ library SignatureCheckerLib { /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash` /// for an ERC1271 `signer` contract. - function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s) - internal - view - returns (bool isValid) - { + function isValidERC1271SignatureNow( + address signer, + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) diff --git a/src/utils/g/DynamicArrayLib.sol b/src/utils/g/DynamicArrayLib.sol index 61cbd518c3..6cc3d549b6 100644 --- a/src/utils/g/DynamicArrayLib.sol +++ b/src/utils/g/DynamicArrayLib.sol @@ -446,7 +446,9 @@ library DynamicArrayLib { let arrLen := mload(arrData) if iszero(lt(n, arrLen)) { calldatacopy( - add(arrData, shl(5, add(1, arrLen))), calldatasize(), shl(5, sub(n, arrLen)) + add(arrData, shl(5, add(1, arrLen))), + calldatasize(), + shl(5, sub(n, arrLen)) ) } mstore(arrData, n) @@ -806,11 +808,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `uint256[]`. - function asUint256Array(DynamicArray memory a) - internal - pure - returns (uint256[] memory result) - { + function asUint256Array(DynamicArray memory a) internal pure returns (uint256[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) @@ -818,11 +816,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `address[]`. - function asAddressArray(DynamicArray memory a) - internal - pure - returns (address[] memory result) - { + function asAddressArray(DynamicArray memory a) internal pure returns (address[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) @@ -838,11 +832,7 @@ library DynamicArrayLib { } /// @dev Returns the underlying array as a `bytes32[]`. - function asBytes32Array(DynamicArray memory a) - internal - pure - returns (bytes32[] memory result) - { + function asBytes32Array(DynamicArray memory a) internal pure returns (bytes32[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(a) diff --git a/src/utils/g/EnumerableMapLib.sol b/src/utils/g/EnumerableMapLib.sol index 8a7f961a97..3fffc9d1cf 100644 --- a/src/utils/g/EnumerableMapLib.sol +++ b/src/utils/g/EnumerableMapLib.sol @@ -161,7 +161,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -242,7 +244,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -323,7 +327,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -404,7 +410,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -485,7 +493,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -566,7 +576,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -647,7 +659,9 @@ library EnumerableMapLib { view returns (bytes32 value) { - if ((value = map._values[key]) == bytes32(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == bytes32(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -728,7 +742,9 @@ library EnumerableMapLib { view returns (uint256 value) { - if ((value = map._values[key]) == uint256(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == uint256(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. @@ -809,7 +825,9 @@ library EnumerableMapLib { view returns (address value) { - if ((value = map._values[key]) == address(0)) if (!contains(map, key)) _revertNotFound(); + if ((value = map._values[key]) == address(0)) { + if (!contains(map, key)) _revertNotFound(); + } } /// @dev Returns the keys. May run out-of-gas if the map is too big. diff --git a/src/utils/g/EnumerableSetLib.sol b/src/utils/g/EnumerableSetLib.sol index dc879f1849..2a240a9ab5 100644 --- a/src/utils/g/EnumerableSetLib.sol +++ b/src/utils/g/EnumerableSetLib.sol @@ -390,7 +390,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -399,7 +401,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -408,7 +412,9 @@ library EnumerableSetLib { internal returns (bool result) { - if (result = add(set, value)) if (length(set) > cap) revert ExceedsCapacity(); + if (result = add(set, value)) { + if (length(set) > cap) revert ExceedsCapacity(); + } } /// @dev Adds `value` to the set. Returns whether `value` was not in the set. @@ -768,11 +774,7 @@ library EnumerableSetLib { } /// @dev Returns the index of `value`. Returns `NOT_FOUND` if the value does not exist. - function indexOf(AddressSet storage set, address value) - internal - view - returns (uint256 result) - { + function indexOf(AddressSet storage set, address value) internal view returns (uint256 result) { result = NOT_FOUND; if (uint160(value) == _ZERO_SENTINEL) return result; bytes32 rootSlot = _rootSlot(set); @@ -806,11 +808,7 @@ library EnumerableSetLib { } /// @dev Returns the index of `value`. Returns `NOT_FOUND` if the value does not exist. - function indexOf(Bytes32Set storage set, bytes32 value) - internal - view - returns (uint256 result) - { + function indexOf(Bytes32Set storage set, bytes32 value) internal view returns (uint256 result) { result = NOT_FOUND; if (uint256(value) == _ZERO_SENTINEL) return result; bytes32 rootSlot = _rootSlot(set); diff --git a/src/utils/g/JSONParserLib.sol b/src/utils/g/JSONParserLib.sol index 6a3faed711..e44433af69 100644 --- a/src/utils/g/JSONParserLib.sol +++ b/src/utils/g/JSONParserLib.sol @@ -592,6 +592,7 @@ library JSONParserLib { } _item, _pOut := parseValue(s_, _item, _pOut, end_) if _item { + // forgefmt: disable-next-item mstore(_item, setP(or(_PARENT_IS_ARRAY, mload(_item)), _BITPOS_KEY, j_)) @@ -622,6 +623,7 @@ library JSONParserLib { if eq(chr(_pOut), 58) { _item, _pOut := parseValue(s_, _item, add(_pOut, 1), end_) if _item { + // forgefmt: disable-next-item mstore(_item, setP(setP(or(_PARENT_IS_OBJECT, mload(_item)), _BITPOS_KEY_LENGTH, sub(pKeyEnd_, pKeyStart_)), @@ -690,7 +692,11 @@ library JSONParserLib { if eq(chr(_pOut), 46) { _pOut := skip0To9s(add(_pOut, 1), end_, 1) } // '.'. let t_ := mload(_pOut) // 'E', 'e'. - if eq(or(0x20, byte(0, t_)), 101) { + if eq( + or(0x20, byte(0, t_)), + 101 + ) { + // forgefmt: disable-next-item _pOut := skip0To9s(add(byte(sub(byte(1, t_), 14), 0x010001), // '+', '-'. add(_pOut, 1)), end_, 1) diff --git a/src/utils/g/LibBitmap.sol b/src/utils/g/LibBitmap.sol index 91af771b00..b936e1d5fa 100644 --- a/src/utils/g/LibBitmap.sol +++ b/src/utils/g/LibBitmap.sol @@ -138,7 +138,8 @@ library LibBitmap { } let storageSlot := keccak256(0x00, 0x40) sstore( - storageSlot, and(sload(storageSlot), not(shl(shift, shr(sub(256, amount), not(0))))) + storageSlot, + and(sload(storageSlot), not(shl(shift, shr(sub(256, amount), not(0))))) ) } } diff --git a/src/utils/g/LibBytes.sol b/src/utils/g/LibBytes.sol index a536ad4d7d..189da23f73 100644 --- a/src/utils/g/LibBytes.sol +++ b/src/utils/g/LibBytes.sol @@ -518,11 +518,7 @@ library LibBytes { /// @dev Reduces the size of `subject` to `n`. /// If `n` is greater than the size of `subject`, this will be a no-op. - function truncate(bytes memory subject, uint256 n) - internal - pure - returns (bytes memory result) - { + function truncate(bytes memory subject, uint256 n) internal pure returns (bytes memory result) { /// @solidity memory-safe-assembly assembly { result := subject @@ -786,11 +782,7 @@ library LibBytes { } /// @dev Returns the word at `offset`, without any bounds checks. - function loadCalldata(bytes calldata a, uint256 offset) - internal - pure - returns (bytes32 result) - { + function loadCalldata(bytes calldata a, uint256 offset) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { result := calldataload(add(a.offset, offset)) diff --git a/src/utils/g/LibString.sol b/src/utils/g/LibString.sol index 8dd862bd3f..b20eabf136 100644 --- a/src/utils/g/LibString.sol +++ b/src/utils/g/LibString.sol @@ -680,7 +680,8 @@ library LibString { assembly { result := mload(0x40) let n := 0 - for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(n, s) { n := add(n, 1) } {} mstore(result, n) // Store the length. let o := add(result, 0x20) mstore(o, s) // Store the bytes of the string. @@ -693,7 +694,8 @@ library LibString { function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { - for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(result, s) { result := add(result, 1) } {} mstore(0x00, s) mstore(result, 0x00) result := mload(0x00) @@ -893,14 +895,13 @@ library LibString { assembly { // We don't need to zero right pad the string, // since this is our own custom non-standard packing scheme. - result := - mul( - // Load the length and the bytes. - mload(add(a, 0x1f)), - // `length != 0 && length < 32`. Abuses underflow. - // Assumes that the length is valid and within the block gas limit. - lt(sub(mload(a), 1), 0x1f) - ) + result := mul( + // Load the length and the bytes. + mload(add(a, 0x1f)), + // `length != 0 && length < 32`. Abuses underflow. + // Assumes that the length is valid and within the block gas limit. + lt(sub(mload(a), 1), 0x1f) + ) } } @@ -926,14 +927,15 @@ library LibString { let aLen := mload(a) // We don't need to zero right pad the strings, // since this is our own custom non-standard packing scheme. - result := - mul( - or( // Load the length and the bytes of `a` and `b`. - shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), mload(sub(add(b, 0x1e), aLen))), - // `totalLen != 0 && totalLen < 31`. Abuses underflow. - // Assumes that the lengths are valid and within the block gas limit. - lt(sub(add(aLen, mload(b)), 1), 0x1e) - ) + result := mul( + or( // Load the length and the bytes of `a` and `b`. + shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), + mload(sub(add(b, 0x1e), aLen)) + ), + // `totalLen != 0 && totalLen < 31`. Abuses underflow. + // Assumes that the lengths are valid and within the block gas limit. + lt(sub(add(aLen, mload(b)), 1), 0x1e) + ) } } diff --git a/src/utils/g/WebAuthn.sol b/src/utils/g/WebAuthn.sol index d9b66f92c2..a30e89b0a5 100644 --- a/src/utils/g/WebAuthn.sol +++ b/src/utils/g/WebAuthn.sol @@ -107,19 +107,18 @@ library WebAuthn { let l := mload(encoded) // Cache `encoded`'s length. let q := add(l, 0x0d) // Length of `encoded` prefixed with '"challenge":"'. mstore(encoded, shr(152, '"challenge":"')) // Temp prefix with '"challenge":"'. - result := + result := and( + // 11. Verify JSON's type. Also checks for possible addition overflows. and( - // 11. Verify JSON's type. Also checks for possible addition overflows. - and( - eq(shr(88, mload(add(o, t))), shr(88, '"type":"webauthn.get"')), - lt(shr(128, or(t, c)), lt(add(0x14, t), n)) - ), - // 12. Verify JSON's challenge. Includes a check for the closing '"'. - and( - eq(keccak256(add(o, c), q), keccak256(add(encoded, 0x13), q)), - and(eq(byte(0, mload(add(add(o, c), q))), 34), lt(add(q, c), n)) - ) + eq(shr(88, mload(add(o, t))), shr(88, '"type":"webauthn.get"')), + lt(shr(128, or(t, c)), lt(add(0x14, t), n)) + ), + // 12. Verify JSON's challenge. Includes a check for the closing '"'. + and( + eq(keccak256(add(o, c), q), keccak256(add(encoded, 0x13), q)), + and(eq(byte(0, mload(add(add(o, c), q))), 34), lt(add(q, c), n)) ) + ) mstore(encoded, l) // Restore `encoded`'s length, in case of string interning. } // Skip 13., 14., 15. diff --git a/src/utils/legacy/LibCWIA.sol b/src/utils/legacy/LibCWIA.sol index c00dbe2225..93525df56e 100644 --- a/src/utils/legacy/LibCWIA.sol +++ b/src/utils/legacy/LibCWIA.sol @@ -144,7 +144,8 @@ library LibCWIA { ) // `keccak256("ReceiveETH(uint256)")` mstore( - sub(data, 0x3a), 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff + sub(data, 0x3a), + 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff ) mstore( // Do a out-of-gas revert if `extraLength` is too big. 0xffff - 0x62 + 0x01 = 0xff9e. @@ -207,7 +208,8 @@ library LibCWIA { ) // `keccak256("ReceiveETH(uint256)")` mstore( - sub(data, 0x3a), 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff + sub(data, 0x3a), + 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff ) mstore( // Do a out-of-gas revert if `extraLength` is too big. 0xffff - 0x62 + 0x01 = 0xff9e. @@ -317,7 +319,8 @@ library LibCWIA { ) // `keccak256("ReceiveETH(uint256)")` mstore( - sub(data, 0x3a), 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff + sub(data, 0x3a), + 0x9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff ) mstore( sub(data, 0x5a), diff --git a/test/Base64.t.sol b/test/Base64.t.sol index 727128a58f..957e787f2a 100644 --- a/test/Base64.t.sol +++ b/test/Base64.t.sol @@ -84,7 +84,8 @@ contract Base64Test is SoladyTest { assertEq( Base64.decode( "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4=" - ).length, + ) + .length, 56 ); } @@ -121,9 +122,11 @@ contract Base64Test is SoladyTest { } } - function testBase64EncodeFileSafeAndNoPadding(bytes memory input, bool fileSafe, bool noPadding) - public - { + function testBase64EncodeFileSafeAndNoPadding( + bytes memory input, + bool fileSafe, + bool noPadding + ) public { string memory expectedEncoded = Base64.encode(input); if (fileSafe) { diff --git a/test/CREATE3.t.sol b/test/CREATE3.t.sol index 218ee7f1af..2b01efe28a 100644 --- a/test/CREATE3.t.sol +++ b/test/CREATE3.t.sol @@ -15,7 +15,9 @@ contract CREATE3Test is SoladyTest { MockERC20 deployed = MockERC20( this.deployDeterministic( - abi.encodePacked(type(MockERC20).creationCode, abi.encode("Mock Token", "MOCK", 18)), + abi.encodePacked( + type(MockERC20).creationCode, abi.encode("Mock Token", "MOCK", 18) + ), salt ) ); diff --git a/test/ERC1155.t.sol b/test/ERC1155.t.sol index 06e38542bf..3962a895c4 100644 --- a/test/ERC1155.t.sol +++ b/test/ERC1155.t.sol @@ -145,11 +145,13 @@ contract MockERC1155WithHooks is MockERC1155 { beforeCounter++; } - function _afterTokenTransfer(address, address, uint256[] memory, uint256[] memory, bytes memory) - internal - virtual - override - { + function _afterTokenTransfer( + address, + address, + uint256[] memory, + uint256[] memory, + bytes memory + ) internal virtual override { afterCounter++; } } @@ -360,9 +362,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { _expectBurnEvent(address(this), from, id, amount); } - function _expectBurnEvent(address operator, address from, uint256 id, uint256 amount) - internal - { + function _expectBurnEvent(address operator, address from, uint256 id, uint256 amount) internal { _expectTransferEvent(operator, from, address(0), id, amount); } @@ -381,9 +381,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { emit TransferSingle(operator, from, to, id, amount); } - function _expectMintEvent(address to, uint256[] memory ids, uint256[] memory amounts) - internal - { + function _expectMintEvent(address to, uint256[] memory ids, uint256[] memory amounts) internal { _expectMintEvent(address(this), to, ids, amounts); } @@ -435,9 +433,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { _expectApprovalForAllEvent(address(this), operator, isApproved); } - function _expectApprovalForAllEvent(address owner, address operator, bool isApproved) - internal - { + function _expectApprovalForAllEvent(address owner, address operator, bool isApproved) internal { vm.expectEmit(true, true, true, true); emit ApprovalForAll(owner, operator, isApproved); } diff --git a/test/ERC1271.t.sol b/test/ERC1271.t.sol index 839f2100da..5befe9fc32 100644 --- a/test/ERC1271.t.sol +++ b/test/ERC1271.t.sol @@ -377,9 +377,10 @@ contract ERC1271Test is SoladyTest { function testSupportsERC7739() public { _TestTemps memory t = _testTemps(); assertEq( - t.account.isValidSignature( - 0x7739773977397739773977397739773977397739773977397739773977397739, "" - ), + t.account + .isValidSignature( + 0x7739773977397739773977397739773977397739773977397739773977397739, "" + ), bytes4(0x77390001) ); } diff --git a/test/ERC4626.t.sol b/test/ERC4626.t.sol index e6d9b0b3c4..0ac74b8b55 100644 --- a/test/ERC4626.t.sol +++ b/test/ERC4626.t.sol @@ -37,12 +37,10 @@ contract ERC4626Test is SoladyTest { function testDifferentialFullMulDiv(uint256 x, uint256 y, uint256 d) public { d = type(uint256).max - d % 4; - (bool success0,) = address(this).call( - abi.encodeWithSignature("fullMulDivChecked(uint256,uint256,uint256)", x, y, d) - ); - (bool success1,) = address(this).call( - abi.encodeWithSignature("fullMulDivUnchecked(uint256,uint256,uint256)", x, y, d) - ); + (bool success0,) = address(this) + .call(abi.encodeWithSignature("fullMulDivChecked(uint256,uint256,uint256)", x, y, d)); + (bool success1,) = address(this) + .call(abi.encodeWithSignature("fullMulDivUnchecked(uint256,uint256,uint256)", x, y, d)); if (d == type(uint256).max) { assertFalse(success0); assertFalse(success1); diff --git a/test/ERC6551.t.sol b/test/ERC6551.t.sol index 5160567f74..9f83c8d8f1 100644 --- a/test/ERC6551.t.sol +++ b/test/ERC6551.t.sol @@ -159,9 +159,8 @@ contract ERC6551Test is SoladyTest { t[i] = _testTemps(); if (i != 0) { vm.prank(t[i].owner); - MockERC721(_erc721).safeTransferFrom( - t[i].owner, address(t[i - 1].account), t[i].tokenId - ); + MockERC721(_erc721) + .safeTransferFrom(t[i].owner, address(t[i - 1].account), t[i].tokenId); t[i].owner = address(t[i - 1].account); } } @@ -169,19 +168,16 @@ contract ERC6551Test is SoladyTest { for (uint256 j = i; j != n; ++j) { vm.prank(t[i].owner); vm.expectRevert(ERC6551.SelfOwnDetected.selector); - MockERC721(_erc721).safeTransferFrom( - t[i].owner, address(t[j].account), t[i].tokenId - ); + MockERC721(_erc721) + .safeTransferFrom(t[i].owner, address(t[j].account), t[i].tokenId); } for (uint256 j; j != i; ++j) { vm.prank(t[i].owner); - MockERC721(_erc721).safeTransferFrom( - t[i].owner, address(t[j].account), t[i].tokenId - ); + MockERC721(_erc721) + .safeTransferFrom(t[i].owner, address(t[j].account), t[i].tokenId); vm.prank(address(t[j].account)); - MockERC721(_erc721).safeTransferFrom( - address(t[j].account), t[i].owner, t[i].tokenId - ); + MockERC721(_erc721) + .safeTransferFrom(address(t[j].account), t[i].owner, t[i].tokenId); } } @@ -199,9 +195,8 @@ contract ERC6551Test is SoladyTest { t[i] = _testTemps(); if (i != 0) { vm.prank(t[i].owner); - MockERC721(_erc721).safeTransferFrom( - t[i].owner, address(t[i - 1].account), t[i].tokenId - ); + MockERC721(_erc721) + .safeTransferFrom(t[i].owner, address(t[i - 1].account), t[i].tokenId); t[i].owner = address(t[i - 1].account); } } @@ -269,15 +264,13 @@ contract ERC6551Test is SoladyTest { vm.prank(t.owner); vm.expectRevert(abi.encodeWithSignature("TargetError(bytes)", data)); - t.account.execute( - target, 123, abi.encodeWithSignature("revertWithTargetError(bytes)", data), 0 - ); + t.account + .execute(target, 123, abi.encodeWithSignature("revertWithTargetError(bytes)", data), 0); vm.prank(t.owner); vm.expectRevert(ERC6551.OperationNotSupported.selector); - t.account.execute( - target, 123, abi.encodeWithSignature("revertWithTargetError(bytes)", data), 1 - ); + t.account + .execute(target, 123, abi.encodeWithSignature("revertWithTargetError(bytes)", data), 1); } function testExecuteBatch() public { diff --git a/test/ERC721.t.sol b/test/ERC721.t.sol index bc4781825d..6ce389dc28 100644 --- a/test/ERC721.t.sol +++ b/test/ERC721.t.sol @@ -962,9 +962,7 @@ contract ERC721Test is SoladyTest { token.safeMint(to, id); } - function testSafeMintToNonERC721RecipientWithDataReverts(uint256 id, bytes memory data) - public - { + function testSafeMintToNonERC721RecipientWithDataReverts(uint256 id, bytes memory data) public { address to = address(new NonERC721Recipient()); vm.expectRevert(ERC721.TransferToNonERC721ReceiverImplementer.selector); token.safeMint(to, id, data); @@ -990,9 +988,10 @@ contract ERC721Test is SoladyTest { token.safeMint(to, id); } - function testSafeMintToERC721RecipientWithWrongReturnDataWithData(uint256 id, bytes memory data) - public - { + function testSafeMintToERC721RecipientWithWrongReturnDataWithData( + uint256 id, + bytes memory data + ) public { address to = address(new WrongReturnDataERC721Recipient()); vm.expectRevert(ERC721.TransferToNonERC721ReceiverImplementer.selector); token.safeMint(to, id, data); diff --git a/test/FixedPointMathLib.t.sol b/test/FixedPointMathLib.t.sol index d9dcb2d132..edc37f066c 100644 --- a/test/FixedPointMathLib.t.sol +++ b/test/FixedPointMathLib.t.sol @@ -1184,12 +1184,12 @@ contract FixedPointMathLibTest is SoladyTest { } function testFullMulDivN(uint256 a, uint256 b, uint8 n) public { - (bool success0, bytes memory result0) = address(this).staticcall( - abi.encodeWithSignature("fullMulDiv(uint256,uint256,uint256)", a, b, 1 << n) - ); - (bool success1, bytes memory result1) = address(this).staticcall( - abi.encodeWithSignature("fullMulDivN(uint256,uint256,uint8)", a, b, n) - ); + (bool success0, bytes memory result0) = address(this) + .staticcall( + abi.encodeWithSignature("fullMulDiv(uint256,uint256,uint256)", a, b, 1 << n) + ); + (bool success1, bytes memory result1) = address(this) + .staticcall(abi.encodeWithSignature("fullMulDivN(uint256,uint256,uint8)", a, b, n)); assertEq(success0, success1); if (success0) { assertEq(abi.decode(result0, (uint256)), abi.decode(result1, (uint256))); @@ -1381,8 +1381,9 @@ contract FixedPointMathLibTest is SoladyTest { view returns (bool) { - bytes memory data = - abi.encodeWithSignature("mulDivOriginal(uint256,uint256,uint256)", x, y, denominator); + bytes memory data = abi.encodeWithSignature( + "mulDivOriginal(uint256,uint256,uint256)", x, y, denominator + ); (bool success,) = address(this).staticcall(data); return !success; } diff --git a/test/Initializable.t.sol b/test/Initializable.t.sol index b7b525599d..5ed5071047 100644 --- a/test/Initializable.t.sol +++ b/test/Initializable.t.sol @@ -147,7 +147,8 @@ contract InitializableTest is SoladyTest { uint64 initializedVersion, uint64 version ) public { - bool expected = initializing == true || initializedVersion >= version; + bool expected = + initializing == true || initializedVersion >= version; bool computed; /// @solidity memory-safe-assembly assembly { diff --git a/test/JSONParserLib.t.sol b/test/JSONParserLib.t.sol index 32475ed948..81c02de774 100644 --- a/test/JSONParserLib.t.sol +++ b/test/JSONParserLib.t.sol @@ -168,9 +168,7 @@ contract JSONParserLibTest is SoladyTest { } } - function _checkSoloEmptyObject(JSONParserLib.Item memory item, string memory trimmed) - internal - { + function _checkSoloEmptyObject(JSONParserLib.Item memory item, string memory trimmed) internal { for (uint256 i; i != 2; ++i) { assertEq(item.getType(), JSONParserLib.TYPE_OBJECT); assertEq(item.isObject(), true); @@ -771,12 +769,7 @@ contract JSONParserLibTest is SoladyTest { this.decodeString(s); } - function decodeString(string memory s) - public - view - miniBrutalizeMemory - returns (string memory) - { + function decodeString(string memory s) public view miniBrutalizeMemory returns (string memory) { return JSONParserLib.decodeString(s); } diff --git a/test/LibBytes.t.sol b/test/LibBytes.t.sol index a1285f8537..ca94902f3f 100644 --- a/test/LibBytes.t.sol +++ b/test/LibBytes.t.sol @@ -62,9 +62,8 @@ contract LibBytesTest is SoladyTest { function testDirectReturn(uint256 seed) public { bytes[] memory expected = _generateBytesArray(seed); - (bool success, bytes memory encoded) = address(this).call( - abi.encodeWithSignature("generateBytesArray(uint256,bool)", seed, true) - ); + (bool success, bytes memory encoded) = address(this) + .call(abi.encodeWithSignature("generateBytesArray(uint256,bool)", seed, true)); assertTrue(success); bytes[] memory computed; /// @solidity memory-safe-assembly @@ -321,9 +320,7 @@ contract LibBytesTest is SoladyTest { return 0; } - function testIndexOfByteDifferential(bytes memory subject, bytes1 needle, uint256 from) - public - { + function testIndexOfByteDifferential(bytes memory subject, bytes1 needle, uint256 from) public { if (_randomChance(2)) _brutalizeMemory(); if (_randomChance(2)) _misalignFreeMemoryPointer(); if (_randomChance(2)) { diff --git a/test/LibCWIA.t.sol b/test/LibCWIA.t.sol index ef585a8e0d..e0765d6581 100644 --- a/test/LibCWIA.t.sol +++ b/test/LibCWIA.t.sol @@ -140,8 +140,9 @@ contract LibCWIATest is SoladyTest, CWIA { uint64 argUint64, uint8 argUint8 ) public { - bytes memory data = - abi.encodePacked(argAddress, argUint256, argUint256Array, argUint64, argUint8); + bytes memory data = abi.encodePacked( + argAddress, argUint256, argUint256Array, argUint64, argUint8 + ); LibCWIATest clone = LibCWIATest(LibCWIA.clone(address(this), data)); _shouldBehaveLikeClone(address(clone), value_); diff --git a/test/LibClone.t.sol b/test/LibClone.t.sol index 7f89858aa6..d3866180b2 100644 --- a/test/LibClone.t.sol +++ b/test/LibClone.t.sol @@ -1453,8 +1453,9 @@ contract LibCloneTest is SoladyTest { maybeBrutalizeMemory returns (address instance) { - address predicted = - LibClone.predictDeterministicAddressERC1967(implementation, salt, address(this)); + address predicted = LibClone.predictDeterministicAddressERC1967( + implementation, salt, address(this) + ); bool alreadyDeployed = predicted.code.length != 0; bool deployed; (deployed, instance) = @@ -1483,8 +1484,9 @@ contract LibCloneTest is SoladyTest { maybeBrutalizeMemory returns (address instance) { - address predicted = - LibClone.predictDeterministicAddressERC1967I(implementation, salt, address(this)); + address predicted = LibClone.predictDeterministicAddressERC1967I( + implementation, salt, address(this) + ); bool alreadyDeployed = predicted.code.length != 0; bool deployed; (deployed, instance) = @@ -1614,11 +1616,11 @@ contract LibCloneTest is SoladyTest { assertEq(instance, predicted); } - function deployDeterministicERC1967IBeaconProxy(address beacon, bytes memory args, bytes32 salt) - external - maybeBrutalizeMemory - returns (address instance) - { + function deployDeterministicERC1967IBeaconProxy( + address beacon, + bytes memory args, + bytes32 salt + ) external maybeBrutalizeMemory returns (address instance) { instance = LibClone.deployDeterministicERC1967IBeaconProxy(_brutalized(beacon), args, salt); address predicted = LibClone.predictDeterministicAddressERC1967IBeaconProxy( beacon, args, salt, address(this) @@ -1631,8 +1633,9 @@ contract LibCloneTest is SoladyTest { maybeBrutalizeMemory returns (address instance) { - address predicted = - LibClone.predictDeterministicAddressERC1967BeaconProxy(beacon, salt, address(this)); + address predicted = LibClone.predictDeterministicAddressERC1967BeaconProxy( + beacon, salt, address(this) + ); bool alreadyDeployed = predicted.code.length != 0; bool deployed; (deployed, instance) = @@ -1646,8 +1649,9 @@ contract LibCloneTest is SoladyTest { maybeBrutalizeMemory returns (address instance) { - address predicted = - LibClone.predictDeterministicAddressERC1967IBeaconProxy(beacon, salt, address(this)); + address predicted = LibClone.predictDeterministicAddressERC1967IBeaconProxy( + beacon, salt, address(this) + ); bool alreadyDeployed = predicted.code.length != 0; bool deployed; (deployed, instance) = @@ -1700,11 +1704,11 @@ contract LibCloneTest is SoladyTest { assertEq(instance, predicted); } - function createDeterministicERC1967IBeaconProxy(address beacon, bytes memory args, bytes32 salt) - external - maybeBrutalizeMemory - returns (address instance) - { + function createDeterministicERC1967IBeaconProxy( + address beacon, + bytes memory args, + bytes32 salt + ) external maybeBrutalizeMemory returns (address instance) { address predicted = LibClone.predictDeterministicAddressERC1967IBeaconProxy( beacon, args, salt, address(this) ); diff --git a/test/LibERC6551.t.sol b/test/LibERC6551.t.sol index 05ad566739..258243a9b3 100644 --- a/test/LibERC6551.t.sol +++ b/test/LibERC6551.t.sol @@ -45,8 +45,9 @@ contract LibERC6551Test is SoladyTest { address tokenContract, uint256 tokenId ) public { - bytes memory initCode = - LibERC6551.initCode(implementation, salt, chainId, tokenContract, tokenId); + bytes memory initCode = LibERC6551.initCode( + implementation, salt, chainId, tokenContract, tokenId + ); if (_randomChance(8)) _brutalizeMemory(); bytes32 initCodeHash = LibERC6551.initCodeHash(implementation, salt, chainId, tokenContract, tokenId); diff --git a/test/LibERC7579.t.sol b/test/LibERC7579.t.sol index 2f70702e80..491d5a100a 100644 --- a/test/LibERC7579.t.sol +++ b/test/LibERC7579.t.sol @@ -253,21 +253,22 @@ contract LibERC7579Test is SoladyTest { } function testDecodeBatchEdgeCase2() public { - (bool success,) = address(this).call( - abi.encodePacked( - bytes4(keccak256("propose2(bytes32,bytes,uint256)")), - hex"0100000000007821000100000000000000000000000000000000000000000000", - hex"0000000000000000000000000000000000000000000000000000000000000060", // offset to executionData - _randomUniform(), - uint256(32 * 5), // length of executionData (THIS SHOULD ACTUALLY BE 32 * 6 BUT WE REDUCE TO 32 * 5) - hex"0000000000000000000000000000000000000000000000000000000000000020", // offset to pointers array - hex"0000000000000000000000000000000000000000000000000000000000000004", // pointers array length - hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[0] - hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[1] - hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[2] - hex"0000000000000000000000000000000000000000000000000000000000000000" // offset to pointers[3] - ) - ); + (bool success,) = address(this) + .call( + abi.encodePacked( + bytes4(keccak256("propose2(bytes32,bytes,uint256)")), + hex"0100000000007821000100000000000000000000000000000000000000000000", + hex"0000000000000000000000000000000000000000000000000000000000000060", // offset to executionData + _randomUniform(), + uint256(32 * 5), // length of executionData (THIS SHOULD ACTUALLY BE 32 * 6 BUT WE REDUCE TO 32 * 5) + hex"0000000000000000000000000000000000000000000000000000000000000020", // offset to pointers array + hex"0000000000000000000000000000000000000000000000000000000000000004", // pointers array length + hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[0] + hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[1] + hex"0000000000000000000000000000000000000000000000000000000000000000", // offset to pointers[2] + hex"0000000000000000000000000000000000000000000000000000000000000000" // offset to pointers[3] + ) + ); assertFalse(success); } diff --git a/test/LibString.t.sol b/test/LibString.t.sol index 9afbdf0b39..2abdc0c212 100644 --- a/test/LibString.t.sol +++ b/test/LibString.t.sol @@ -530,7 +530,10 @@ contract LibStringTest is SoladyTest { assertEq(LibString.replace("abc", "d", "x"), "abc"); } - function testStringReplaceMedium() public { + function testStringReplaceMedium() + public + { + // forgefmt: disable-next-item string memory subject = "70708741044725766535585242414884609539555049888764130733849700923779599488691391677696419266840"; string memory search = "46095395550498887641307338497009"; @@ -540,7 +543,10 @@ contract LibStringTest is SoladyTest { assertEq(LibString.replace(subject, search, replacement), expectedResult); } - function testStringReplaceLong() public { + function testStringReplaceLong() + public + { + // forgefmt: disable-next-item string memory subject = "01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search"; string memory search = "search_search_search_search_search_search"; @@ -1266,17 +1272,13 @@ contract LibStringTest is SoladyTest { // ensure they are characters 0-9 or A-F or a-f and therefore hexadecimal require( - ( - (byteU8_1 >= 48 && byteU8_1 <= 57) || (byteU8_1 >= 65 && byteU8_1 <= 70) - || (byteU8_1 >= 97 && byteU8_1 <= 102) - ), + ((byteU8_1 >= 48 && byteU8_1 <= 57) || (byteU8_1 >= 65 && byteU8_1 <= 70) + || (byteU8_1 >= 97 && byteU8_1 <= 102)), "invalid encoded string" ); require( - ( - (byteU8_2 >= 48 && byteU8_2 <= 57) || (byteU8_2 >= 65 && byteU8_2 <= 70) - || (byteU8_2 >= 97 && byteU8_2 <= 102) - ), + ((byteU8_2 >= 48 && byteU8_2 <= 57) || (byteU8_2 >= 65 && byteU8_2 <= 70) + || (byteU8_2 >= 97 && byteU8_2 <= 102)), "invalid encoded string" ); @@ -1704,7 +1706,8 @@ contract LibStringTest is SoladyTest { assembly { let b := byte(0, mload(add(add(subject, 0x20), i))) mstore8( - add(add(result, 0x20), i), add(b, mul(0x20, and(lt(0x40, b), lt(b, 0x5b)))) + add(add(result, 0x20), i), + add(b, mul(0x20, and(lt(0x40, b), lt(b, 0x5b)))) ) } } @@ -1720,7 +1723,8 @@ contract LibStringTest is SoladyTest { assembly { let b := byte(0, mload(add(add(subject, 0x20), i))) mstore8( - add(add(result, 0x20), i), sub(b, mul(0x20, and(lt(0x60, b), lt(b, 0x7b)))) + add(add(result, 0x20), i), + sub(b, mul(0x20, and(lt(0x60, b), lt(b, 0x7b)))) ) } } diff --git a/test/LibTransient.t.sol b/test/LibTransient.t.sol index 1a279d2e65..499f473503 100644 --- a/test/LibTransient.t.sol +++ b/test/LibTransient.t.sol @@ -396,22 +396,23 @@ contract LibTransientTest is SoladyTest { bool success; if (newAdminRaw >> 160 == 0) { if (_randomChance(2)) { - (success,) = LibTransient.REGISTRY.call( - abi.encodeWithSignature("changeAdmin(bytes32,address)", key, newAdminRaw) - ); + (success,) = LibTransient.REGISTRY + .call( + abi.encodeWithSignature( + "changeAdmin(bytes32,address)", key, newAdminRaw + ) + ); assertTrue(success); } else { this.registryChangeAdmin(key, newAdmin); } } else { - (success,) = LibTransient.REGISTRY.call( - abi.encodeWithSignature("changeAdmin(bytes32,address)", key, newAdminRaw) - ); + (success,) = LibTransient.REGISTRY + .call(abi.encodeWithSignature("changeAdmin(bytes32,address)", key, newAdminRaw)); assertFalse(success); newAdminRaw = (newAdminRaw << 96) >> 96; - (success,) = LibTransient.REGISTRY.call( - abi.encodeWithSignature("changeAdmin(bytes32,address)", key, newAdminRaw) - ); + (success,) = LibTransient.REGISTRY + .call(abi.encodeWithSignature("changeAdmin(bytes32,address)", key, newAdminRaw)); assertTrue(success); } diff --git a/test/LibZip.t.sol b/test/LibZip.t.sol index 34ff31d45c..bc41b8ff87 100644 --- a/test/LibZip.t.sol +++ b/test/LibZip.t.sol @@ -521,7 +521,8 @@ contract LibZipTest is SoladyTest { /// @solidity memory-safe-assembly assembly { let n := 0 - for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'. + for {} // Scan for '\0'. + byte(n, s) { n := add(n, 1) } {} expected := n let m := 0x7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F let x := not(or(or(add(and(s, m), m), s), m)) diff --git a/test/P256.t.sol b/test/P256.t.sol index c38b16dd52..d036c3de15 100644 --- a/test/P256.t.sol +++ b/test/P256.t.sol @@ -60,16 +60,20 @@ contract P256VerifierEtcher is SoladyTest { contract P256Test is P256VerifierEtcher { // Public key x and y. - uint256 private constant _X = 0x65a2fa44daad46eab0278703edb6c4dcf5e30b8a9aec09fdc71a56f52aa392e4; - uint256 private constant _Y = 0x4a7a9e4604aa36898209997288e902ac544a555e4b5e0a9efef2b59233f3f437; - uint256 private constant _R = 0x01655c1753db6b61a9717e4ccc5d6c4bf7681623dd54c2d6babc55125756661c; + uint256 private constant _X = + 0x65a2fa44daad46eab0278703edb6c4dcf5e30b8a9aec09fdc71a56f52aa392e4; + uint256 private constant _Y = + 0x4a7a9e4604aa36898209997288e902ac544a555e4b5e0a9efef2b59233f3f437; + uint256 private constant _R = + 0x01655c1753db6b61a9717e4ccc5d6c4bf7681623dd54c2d6babc55125756661c; uint256 private constant _NON_MALLEABLE_S = 0xf8cfdc3921ecf0f7aef50be09b0f98383392dd8079014df95fde2a04b79023a; uint256 private constant _MALLEABLE_S = 0xf073023b6de130f18510af41f64f067c39adccd59f8789a55dbbe822b0ea2317; bytes32 private constant _HASH = 0x267f9ea080b54bbea2443dff8aa543604564329783b6a515c6663a691c555490; - uint256 private constant _N = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551; + uint256 private constant _N = + 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551; uint256 private constant _MALLEABILITY_THRESHOLD = 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3192a8; @@ -288,10 +292,14 @@ library P256PublicKey { 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296; uint256 internal constant GY = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5; - uint256 internal constant P = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF; - uint256 internal constant N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; - uint256 internal constant A = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC; - uint256 internal constant B = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B; + uint256 internal constant P = + 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF; + uint256 internal constant N = + 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; + uint256 internal constant A = + 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC; + uint256 internal constant B = + 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B; uint256 internal constant P1DIV4 = 0x3fffffffc0000000400000000000000000000000400000000000000000000000; uint256 internal constant HALF_N = @@ -350,12 +358,11 @@ library P256PublicKey { mstore(0x00, mulmod(4, mulmod(x, yy, p), p)) mstore(0x20, addmod(mulmod(3, mulmod(x, x, p), p), mulmod(A, mulmod(zz, zz, p), p), p)) rx := addmod(mulmod(mload(0x20), mload(0x20), p), sub(p, mulmod(2, mload(0x00), p)), p) - ry := - addmod( - mulmod(mload(0x20), addmod(mload(0x00), sub(p, rx), p), p), - sub(p, mulmod(8, mulmod(yy, yy, p), p)), - p - ) + ry := addmod( + mulmod(mload(0x20), addmod(mload(0x00), sub(p, rx), p), p), + sub(p, mulmod(8, mulmod(yy, yy, p), p)), + p + ) rz := mulmod(2, mulmod(y, z, p), p) } } @@ -376,18 +383,16 @@ library P256PublicKey { let hh := mulmod(mload(0x60), mload(0x60), p) let hhh := mulmod(mload(0x60), hh, p) let r := addmod(mulmod(y2, mulmod(zz1, z1, p), p), sub(p, mload(0x20)), p) - rx := - addmod( - addmod(mulmod(r, r, p), sub(p, hhh), p), - sub(p, mulmod(2, mulmod(mload(0x00), hh, p), p)), - p - ) - ry := - addmod( - mulmod(r, addmod(mulmod(mload(0x00), hh, p), sub(p, rx), p), p), - sub(p, mulmod(mload(0x20), hhh, p)), - p - ) + rx := addmod( + addmod(mulmod(r, r, p), sub(p, hhh), p), + sub(p, mulmod(2, mulmod(mload(0x00), hh, p), p)), + p + ) + ry := addmod( + mulmod(r, addmod(mulmod(mload(0x00), hh, p), sub(p, rx), p), p), + sub(p, mulmod(mload(0x20), hhh, p)), + p + ) rz := mulmod(mload(0x60), mulmod(z1, z2, p), p) mstore(0x60, 0) } diff --git a/test/SafeTransferLib.t.sol b/test/SafeTransferLib.t.sol index be5565505a..224206d2f7 100644 --- a/test/SafeTransferLib.t.sol +++ b/test/SafeTransferLib.t.sol @@ -439,9 +439,7 @@ contract SafeTransferLibTest is SoladyTest { SafeTransferLib.safeTransferAllFrom(address(erc20), address(this), address(1)); } - function testTransferAllFromWithStandardERC20(address from, address to, uint256 amount) - public - { + function testTransferAllFromWithStandardERC20(address from, address to, uint256 amount) public { while (!(to != from && to != address(this) && from != address(this))) { to = _randomNonZeroAddress(); from = _randomNonZeroAddress(); @@ -636,9 +634,7 @@ contract SafeTransferLibTest is SoladyTest { verifySafeTransferFrom(address(returnsFalse), from, to, amount, _REVERTS_WITH_SELECTOR); } - function testTransferFromWithRevertingReverts(address from, address to, uint256 amount) - public - { + function testTransferFromWithRevertingReverts(address from, address to, uint256 amount) public { verifySafeTransferFrom(address(reverting), from, to, amount, _REVERTS_WITH_ANY); } @@ -696,11 +692,12 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.TransferFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeTransfer(address,address,uint256)", token, to, amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeTransfer(address,address,uint256)", token, to, amount + ) + ); assertFalse(success); return; } @@ -734,15 +731,16 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.TransferFromFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeTransferFrom(address,address,address,uint256)", - token, - from, - to, - amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeTransferFrom(address,address,address,uint256)", + token, + from, + to, + amount + ) + ); assertFalse(success); return; } @@ -778,11 +776,12 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.ApproveFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeApprove(address,address,uint256)", token, to, amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeApprove(address,address,uint256)", token, to, amount + ) + ); assertFalse(success); return; } diff --git a/test/SignatureCheckerLib.t.sol b/test/SignatureCheckerLib.t.sol index 1023252054..e60b837e4f 100644 --- a/test/SignatureCheckerLib.t.sol +++ b/test/SignatureCheckerLib.t.sol @@ -219,26 +219,25 @@ contract SignatureCheckerLibTest is SoladyTest { // We have to do the call in assembly to ensure that Solidity does not // clean up the brutalized bits. - callResult := + callResult := and( and( - and( - // Whether the returndata is equal to 1. - eq(mload(0x00), 1), - // Whether the returndata is exactly 0x20 bytes (1 word) long . - eq(returndatasize(), 0x20) - ), - // Whether the staticcall does not revert. - // This must be placed at the end of the `and` clause, - // as the arguments are evaluated from right to left. - staticcall( - gas(), // Remaining gas. - address(), // The current contract's address. - m, // Offset of calldata in memory. - 0xe4, // Length of calldata in memory. - 0x00, // Offset of returndata. - 0x20 // Length of returndata to write. - ) + // Whether the returndata is equal to 1. + eq(mload(0x00), 1), + // Whether the returndata is exactly 0x20 bytes (1 word) long . + eq(returndatasize(), 0x20) + ), + // Whether the staticcall does not revert. + // This must be placed at the end of the `and` clause, + // as the arguments are evaluated from right to left. + staticcall( + gas(), // Remaining gas. + address(), // The current contract's address. + m, // Offset of calldata in memory. + 0xe4, // Length of calldata in memory. + 0x00, // Offset of returndata. + 0x20 // Length of returndata to write. ) + ) } assertEq(callResult, expectedResult); diff --git a/test/WebAuthn.t.sol b/test/WebAuthn.t.sol index 05042baf0f..55ea8b2c12 100644 --- a/test/WebAuthn.t.sol +++ b/test/WebAuthn.t.sol @@ -36,7 +36,7 @@ contract WebAuthnTest is P256VerifierEtcher { _TestTemps memory t = _testTemps(); WebAuthn.WebAuthnAuth memory auth; auth.authenticatorData = - hex"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000101"; + hex"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000101"; auth.clientDataJSON = string( abi.encodePacked( '{"type":"webauthn.get","challenge":"', @@ -57,7 +57,7 @@ contract WebAuthnTest is P256VerifierEtcher { _TestTemps memory t = _testTemps(); WebAuthn.WebAuthnAuth memory auth; auth.authenticatorData = - hex"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000010a"; + hex"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000010a"; auth.clientDataJSON = string( abi.encodePacked( '{"type":"webauthn.get","challenge":"', @@ -147,10 +147,7 @@ contract WebAuthnTest is P256VerifierEtcher { if (!_randomChance(4)) result = s; } - function _sampleChallengeIndex(string memory clientDataJSON) - internal - returns (uint256 result) - { + function _sampleChallengeIndex(string memory clientDataJSON) internal returns (uint256 result) { if (!_randomChance(4)) { result = LibString.indexOf(clientDataJSON, '"challenge":"'); if (result <= 0xffffffff) return result; diff --git a/test/ext/delegatexyz/DelegateCheckerLib.t.sol b/test/ext/delegatexyz/DelegateCheckerLib.t.sol index 35f4750725..cb2d808343 100644 --- a/test/ext/delegatexyz/DelegateCheckerLib.t.sol +++ b/test/ext/delegatexyz/DelegateCheckerLib.t.sol @@ -8,8 +8,7 @@ import {FixedPointMathLib} from "../../../src/utils/FixedPointMathLib.sol"; interface IDelegateRegistryV1 { function delegateForAll(address delegate, bool value) external; function delegateForContract(address delegate, address contract_, bool value) external; - function delegateForToken(address delegate, address contract_, uint256 id, bool value) - external; + function delegateForToken(address delegate, address contract_, uint256 id, bool value) external; function checkDelegateForAll(address delegate, address vault) external view returns (bool); function checkDelegateForContract(address delegate, address vault, address contract_) external diff --git a/test/ext/ithaca/BLS.t.sol b/test/ext/ithaca/BLS.t.sol index 7e3e3d2a9f..63a4948f61 100644 --- a/test/ext/ithaca/BLS.t.sol +++ b/test/ext/ithaca/BLS.t.sol @@ -235,30 +235,31 @@ contract BLSTest is SoladyTest { // passing two bytes32 instead of bytes memory saves approx 700 gas per call // Computes the mod against the bls12-381 field modulus function _modfield(bytes32 _b1, bytes32 _b2) private view returns (BLS.Fp memory r) { - (bool success, bytes memory output) = address(0x5).staticcall( - abi.encode( - // arg[0] = base.length - 0x40, - // arg[1] = exp.length - 0x20, - // arg[2] = mod.length - 0x40, - // arg[3] = base.bits - // places the first 32 bytes of _b1 and the last 32 bytes of _b2 - _b1, - _b2, - // arg[4] = exp - // exponent always 1 - 1, - // arg[5] = mod - // this field_modulus as hex 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 - // we add the 0 prefix so that the result will be exactly 64 bytes - // saves 300 gas per call instead of sending it along every time - // places the first 32 bytes and the last 32 bytes of the field modulus - 0x000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd7, - 0x64774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab - ) - ); + (bool success, bytes memory output) = address(0x5) + .staticcall( + abi.encode( + // arg[0] = base.length + 0x40, + // arg[1] = exp.length + 0x20, + // arg[2] = mod.length + 0x40, + // arg[3] = base.bits + // places the first 32 bytes of _b1 and the last 32 bytes of _b2 + _b1, + _b2, + // arg[4] = exp + // exponent always 1 + 1, + // arg[5] = mod + // this field_modulus as hex 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 + // we add the 0 prefix so that the result will be exactly 64 bytes + // saves 300 gas per call instead of sending it along every time + // places the first 32 bytes and the last 32 bytes of the field modulus + 0x000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd7, + 0x64774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab + ) + ); require(success, "MODEXP failed"); return abi.decode(output, (BLS.Fp)); } diff --git a/test/ext/zksync/ERC1155.t.sol b/test/ext/zksync/ERC1155.t.sol index a7dbbb639b..027bf9568c 100644 --- a/test/ext/zksync/ERC1155.t.sol +++ b/test/ext/zksync/ERC1155.t.sol @@ -145,11 +145,13 @@ contract MockERC1155WithHooks is MockERC1155 { beforeCounter++; } - function _afterTokenTransfer(address, address, uint256[] memory, uint256[] memory, bytes memory) - internal - virtual - override - { + function _afterTokenTransfer( + address, + address, + uint256[] memory, + uint256[] memory, + bytes memory + ) internal virtual override { afterCounter++; } } @@ -360,9 +362,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { _expectBurnEvent(address(this), from, id, amount); } - function _expectBurnEvent(address operator, address from, uint256 id, uint256 amount) - internal - { + function _expectBurnEvent(address operator, address from, uint256 id, uint256 amount) internal { _expectTransferEvent(operator, from, address(0), id, amount); } @@ -381,9 +381,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { emit TransferSingle(operator, from, to, id, amount); } - function _expectMintEvent(address to, uint256[] memory ids, uint256[] memory amounts) - internal - { + function _expectMintEvent(address to, uint256[] memory ids, uint256[] memory amounts) internal { _expectMintEvent(address(this), to, ids, amounts); } @@ -435,9 +433,7 @@ contract ERC1155Test is SoladyTest, ERC1155TokenReceiver { _expectApprovalForAllEvent(address(this), operator, isApproved); } - function _expectApprovalForAllEvent(address owner, address operator, bool isApproved) - internal - { + function _expectApprovalForAllEvent(address owner, address operator, bool isApproved) internal { vm.expectEmit(true, true, true, true); emit ApprovalForAll(owner, operator, isApproved); } diff --git a/test/ext/zksync/ERC721.t.sol b/test/ext/zksync/ERC721.t.sol index a713b9912b..b3348c0b18 100644 --- a/test/ext/zksync/ERC721.t.sol +++ b/test/ext/zksync/ERC721.t.sol @@ -962,9 +962,7 @@ contract ERC721Test is SoladyTest { token.safeMint(to, id); } - function testSafeMintToNonERC721RecipientWithDataReverts(uint256 id, bytes memory data) - public - { + function testSafeMintToNonERC721RecipientWithDataReverts(uint256 id, bytes memory data) public { address to = address(new NonERC721Recipient()); vm.expectRevert(ERC721.TransferToNonERC721ReceiverImplementer.selector); token.safeMint(to, id, data); @@ -990,9 +988,10 @@ contract ERC721Test is SoladyTest { token.safeMint(to, id); } - function testSafeMintToERC721RecipientWithWrongReturnDataWithData(uint256 id, bytes memory data) - public - { + function testSafeMintToERC721RecipientWithWrongReturnDataWithData( + uint256 id, + bytes memory data + ) public { address to = address(new WrongReturnDataERC721Recipient()); vm.expectRevert(ERC721.TransferToNonERC721ReceiverImplementer.selector); token.safeMint(to, id, data); diff --git a/test/ext/zksync/SafeTransferLib.t.sol b/test/ext/zksync/SafeTransferLib.t.sol index 7f9e80bfe2..fcd631bd1c 100644 --- a/test/ext/zksync/SafeTransferLib.t.sol +++ b/test/ext/zksync/SafeTransferLib.t.sol @@ -276,9 +276,7 @@ contract SafeTransferLibTest is SoladyTest { SafeTransferLib.safeTransferAllFrom(address(erc20), address(this), address(1)); } - function testTransferAllFromWithStandardERC20(address from, address to, uint256 amount) - public - { + function testTransferAllFromWithStandardERC20(address from, address to, uint256 amount) public { while (!(to != from && to != address(this) && from != address(this))) { to = _randomNonZeroAddress(); from = _randomNonZeroAddress(); @@ -473,9 +471,7 @@ contract SafeTransferLibTest is SoladyTest { verifySafeTransferFrom(address(returnsFalse), from, to, amount, _REVERTS_WITH_SELECTOR); } - function testTransferFromWithRevertingReverts(address from, address to, uint256 amount) - public - { + function testTransferFromWithRevertingReverts(address from, address to, uint256 amount) public { verifySafeTransferFrom(address(reverting), from, to, amount, _REVERTS_WITH_ANY); } @@ -533,11 +529,12 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.TransferFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeTransfer(address,address,uint256)", token, to, amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeTransfer(address,address,uint256)", token, to, amount + ) + ); assertFalse(success); return; } @@ -571,15 +568,16 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.TransferFromFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeTransferFrom(address,address,address,uint256)", - token, - from, - to, - amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeTransferFrom(address,address,address,uint256)", + token, + from, + to, + amount + ) + ); assertFalse(success); return; } @@ -615,11 +613,12 @@ contract SafeTransferLibTest is SoladyTest { if (mode == _REVERTS_WITH_SELECTOR) { vm.expectRevert(SafeTransferLib.ApproveFailed.selector); } else if (mode == _REVERTS_WITH_ANY) { - (bool success,) = address(this).call( - abi.encodeWithSignature( - "verifySafeApprove(address,address,uint256)", token, to, amount - ) - ); + (bool success,) = address(this) + .call( + abi.encodeWithSignature( + "verifySafeApprove(address,address,uint256)", token, to, amount + ) + ); assertFalse(success); return; } diff --git a/test/ext/zksync/SignatureCheckerLib.t.sol b/test/ext/zksync/SignatureCheckerLib.t.sol index aa4647a263..40a9d59a1e 100644 --- a/test/ext/zksync/SignatureCheckerLib.t.sol +++ b/test/ext/zksync/SignatureCheckerLib.t.sol @@ -218,26 +218,25 @@ contract SignatureCheckerLibTest is SoladyTest { // We have to do the call in assembly to ensure that Solidity does not // clean up the brutalized bits. - callResult := + callResult := and( and( - and( - // Whether the returndata is equal to 1. - eq(mload(0x00), 1), - // Whether the returndata is exactly 0x20 bytes (1 word) long . - eq(returndatasize(), 0x20) - ), - // Whether the staticcall does not revert. - // This must be placed at the end of the `and` clause, - // as the arguments are evaluated from right to left. - staticcall( - gas(), // Remaining gas. - address(), // The current contract's address. - m, // Offset of calldata in memory. - 0xe4, // Length of calldata in memory. - 0x00, // Offset of returndata. - 0x20 // Length of returndata to write. - ) + // Whether the returndata is equal to 1. + eq(mload(0x00), 1), + // Whether the returndata is exactly 0x20 bytes (1 word) long . + eq(returndatasize(), 0x20) + ), + // Whether the staticcall does not revert. + // This must be placed at the end of the `and` clause, + // as the arguments are evaluated from right to left. + staticcall( + gas(), // Remaining gas. + address(), // The current contract's address. + m, // Offset of calldata in memory. + 0xe4, // Length of calldata in memory. + 0x00, // Offset of returndata. + 0x20 // Length of returndata to write. ) + ) } assertEq(callResult, expectedResult); diff --git a/test/utils/TestPlus.sol b/test/utils/TestPlus.sol index b9aac8fdac..d12428b7cc 100644 --- a/test/utils/TestPlus.sol +++ b/test/utils/TestPlus.sol @@ -568,11 +568,7 @@ contract TestPlus is Brutalizer { /// @dev Truncate the bytes to `n` bytes. /// Returns the result for function chaining. - function _truncateBytes(bytes memory b, uint256 n) - internal - pure - returns (bytes memory result) - { + function _truncateBytes(bytes memory b, uint256 n) internal pure returns (bytes memory result) { /// @solidity memory-safe-assembly assembly { if gt(mload(b), n) { mstore(b, n) } diff --git a/test/utils/forge-std/Test.sol b/test/utils/forge-std/Test.sol index fa4c6e4f28..7d620e9437 100644 --- a/test/utils/forge-std/Test.sol +++ b/test/utils/forge-std/Test.sol @@ -110,10 +110,7 @@ abstract contract Test is Script { if (!__eq(left, right)) vm.assertEq(left, right); } - function assertEq(string memory left, string memory right, string memory err) - internal - virtual - { + function assertEq(string memory left, string memory right, string memory err) internal virtual { if (!__eq(left, right)) vm.assertEq(left, right, err); } @@ -129,10 +126,7 @@ abstract contract Test is Script { if (!__eq(left, right)) vm.assertEq(left, right); } - function assertEq(bool[] memory left, bool[] memory right, string memory err) - internal - virtual - { + function assertEq(bool[] memory left, bool[] memory right, string memory err) internal virtual { if (!__eq(left, right)) vm.assertEq(left, right, err); } @@ -556,10 +550,12 @@ abstract contract Test is Script { vm.assertApproxEqAbs(left, right, maxDelta, err); } - function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) - internal - virtual - { + function assertApproxEqAbsDecimal( + int256 left, + int256 right, + uint256 maxDelta, + uint256 decimals + ) internal virtual { vm.assertApproxEqAbsDecimal(left, right, maxDelta, decimals); } @@ -577,7 +573,10 @@ abstract contract Test is Script { uint256 left, uint256 right, uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100% - ) internal virtual { + ) + internal + virtual + { vm.assertApproxEqRel(left, right, maxPercentDelta); } @@ -692,11 +691,7 @@ abstract contract Test is Script { } } - function __eq(int256[] memory left, int256[] memory right) - internal - pure - returns (bool result) - { + function __eq(int256[] memory left, int256[] memory right) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { result := keccak256(left, shl(5, add(1, mload(left)))) @@ -716,11 +711,7 @@ abstract contract Test is Script { } } - function __eq(string[] memory left, string[] memory right) - internal - pure - returns (bool result) - { + function __eq(string[] memory left, string[] memory right) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let n := mload(left) diff --git a/test/utils/forge-std/Vm.sol b/test/utils/forge-std/Vm.sol index dc644b9c26..74fbde47ba 100644 --- a/test/utils/forge-std/Vm.sol +++ b/test/utils/forge-std/Vm.sol @@ -272,10 +272,7 @@ interface VmSafe { /// Gets the environment variable `name` and parses it as `uint256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. - function envOr(string calldata name, uint256 defaultValue) - external - view - returns (uint256 value); + function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value); /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. /// Reverts if the variable could not be parsed. @@ -312,26 +309,17 @@ interface VmSafe { /// Gets the environment variable `name` and parses it as `int256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. - function envOr(string calldata name, int256 defaultValue) - external - view - returns (int256 value); + function envOr(string calldata name, int256 defaultValue) external view returns (int256 value); /// Gets the environment variable `name` and parses it as `address`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. - function envOr(string calldata name, address defaultValue) - external - view - returns (address value); + function envOr(string calldata name, address defaultValue) external view returns (address value); /// Gets the environment variable `name` and parses it as `bytes32`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. - function envOr(string calldata name, bytes32 defaultValue) - external - view - returns (bytes32 value); + function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value); /// Gets the environment variable `name` and parses it as `string`. /// Reverts if the variable could not be parsed. @@ -434,9 +422,7 @@ interface VmSafe { returns (bool found, bytes32 key, bytes32 parent); /// Gets the number of elements in the mapping at the given slot, for a given address. - function getMappingLength(address target, bytes32 mappingSlot) - external - returns (uint256 length); + function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); /// Gets the elements at index idx of the mapping at the given slot, for a given address. The /// index must be less than the length of the mapping (i.e. the number of keys in the mapping). @@ -624,10 +610,7 @@ interface VmSafe { function keyExists(string calldata json, string calldata key) external view returns (bool); /// Checks if `key` exists in a JSON object. - function keyExistsJson(string calldata json, string calldata key) - external - view - returns (bool); + function keyExistsJson(string calldata json, string calldata key) external view returns (bool); /// Parses a string of JSON data at `key` and coerces it to `address`. function parseJsonAddress(string calldata json, string calldata key) @@ -642,10 +625,7 @@ interface VmSafe { returns (address[] memory); /// Parses a string of JSON data at `key` and coerces it to `bool`. - function parseJsonBool(string calldata json, string calldata key) - external - pure - returns (bool); + function parseJsonBool(string calldata json, string calldata key) external pure returns (bool); /// Parses a string of JSON data at `key` and coerces it to `bool[]`. function parseJsonBoolArray(string calldata json, string calldata key) @@ -678,10 +658,7 @@ interface VmSafe { returns (bytes[] memory); /// Parses a string of JSON data at `key` and coerces it to `int256`. - function parseJsonInt(string calldata json, string calldata key) - external - pure - returns (int256); + function parseJsonInt(string calldata json, string calldata key) external pure returns (int256); /// Parses a string of JSON data at `key` and coerces it to `int256[]`. function parseJsonIntArray(string calldata json, string calldata key) @@ -883,16 +860,10 @@ interface VmSafe { returns (bytes32 parsedValue); /// Parses the given `string` into a `int256`. - function parseInt(string calldata stringifiedValue) - external - pure - returns (int256 parsedValue); + function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue); /// Parses the given `string` into a `uint256`. - function parseUint(string calldata stringifiedValue) - external - pure - returns (uint256 parsedValue); + function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); /// Replaces occurrences of `from` in the given `string` with `to`. function replace(string calldata input, string calldata from, string calldata to) @@ -913,10 +884,7 @@ interface VmSafe { function toString(address value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. - function toString(bytes calldata value) - external - pure - returns (string memory stringifiedValue); + function toString(bytes calldata value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(bytes32 value) external pure returns (string memory stringifiedValue); @@ -959,9 +927,12 @@ interface VmSafe { /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. - function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) - external - pure; + function assertApproxEqAbsDecimal( + int256 left, + int256 right, + uint256 maxDelta, + uint256 decimals + ) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. Includes error message into revert string on failure. @@ -978,9 +949,12 @@ interface VmSafe { /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. /// Includes error message into revert string on failure. - function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) - external - pure; + function assertApproxEqAbs( + uint256 left, + uint256 right, + uint256 maxDelta, + string calldata error + ) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure; @@ -1035,9 +1009,7 @@ interface VmSafe { /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% - function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) - external - pure; + function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure; /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% @@ -1478,10 +1450,7 @@ interface VmSafe { // ::::::: Toml ::::::: /// Checks if `key` exists in a TOML table. - function keyExistsToml(string calldata toml, string calldata key) - external - view - returns (bool); + function keyExistsToml(string calldata toml, string calldata key) external view returns (bool); /// Parses a string of TOML data at `key` and coerces it to `address`. function parseTomlAddress(string calldata toml, string calldata key) @@ -1496,10 +1465,7 @@ interface VmSafe { returns (address[] memory); /// Parses a string of TOML data at `key` and coerces it to `bool`. - function parseTomlBool(string calldata toml, string calldata key) - external - pure - returns (bool); + function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool); /// Parses a string of TOML data at `key` and coerces it to `bool[]`. function parseTomlBoolArray(string calldata toml, string calldata key) @@ -1532,10 +1498,7 @@ interface VmSafe { returns (bytes[] memory); /// Parses a string of TOML data at `key` and coerces it to `int256`. - function parseTomlInt(string calldata toml, string calldata key) - external - pure - returns (int256); + function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256); /// Parses a string of TOML data at `key` and coerces it to `int256[]`. function parseTomlIntArray(string calldata toml, string calldata key) @@ -1605,10 +1568,7 @@ interface VmSafe { returns (address); /// Compute the address a contract will be deployed at for a given deployer address and nonce. - function computeCreateAddress(address deployer, uint256 nonce) - external - pure - returns (address); + function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); /// Derives a private key from the name, labels the account with that name, and returns the wallet. function createWallet(string calldata walletLabel) external returns (Wallet memory wallet); @@ -1781,8 +1741,7 @@ interface Vm is VmSafe { function makePersistent(address[] calldata accounts) external; /// Reverts a call to an address with specified revert data. - function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) - external; + function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; /// Reverts a call to an address with a specific `msg.value`, with specified revert data. function mockCallRevert( @@ -1930,8 +1889,7 @@ interface Vm is VmSafe { external; /// Expect a call to an address with the specified `msg.value`, gas, and calldata. - function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) - external; + function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external; /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata. function expectCall( diff --git a/test/utils/mocks/MockERC4337.sol b/test/utils/mocks/MockERC4337.sol index ca90e80421..df273f5c91 100644 --- a/test/utils/mocks/MockERC4337.sol +++ b/test/utils/mocks/MockERC4337.sol @@ -25,12 +25,7 @@ contract MockERC4337 is ERC4337, Brutalizer { return super.executeBatch(calls); } - function _domainNameAndVersion() - internal - pure - override - returns (string memory, string memory) - { + function _domainNameAndVersion() internal pure override returns (string memory, string memory) { return ("Milady", "1"); } diff --git a/test/utils/mocks/MockERC6551.sol b/test/utils/mocks/MockERC6551.sol index 4da4f64fc0..b2ed9c506f 100644 --- a/test/utils/mocks/MockERC6551.sol +++ b/test/utils/mocks/MockERC6551.sol @@ -20,12 +20,7 @@ contract MockERC6551 is ERC6551, Brutalizer { return super.executeBatch(calls, operation); } - function _domainNameAndVersion() - internal - pure - override - returns (string memory, string memory) - { + function _domainNameAndVersion() internal pure override returns (string memory, string memory) { return ("Milady", "1"); } diff --git a/test/utils/mocks/MockEntryPoint.sol b/test/utils/mocks/MockEntryPoint.sol index af2b8df34d..a3cc93d778 100644 --- a/test/utils/mocks/MockEntryPoint.sol +++ b/test/utils/mocks/MockEntryPoint.sol @@ -24,8 +24,8 @@ contract MockEntryPoint { bytes32 userOpHash, uint256 missingAccountFunds ) public payable returns (uint256 validationData) { - validationData = - ERC4337(payable(account)).validateUserOp(userOp, userOpHash, missingAccountFunds); + validationData = ERC4337(payable(account)) + .validateUserOp(userOp, userOpHash, missingAccountFunds); } receive() external payable { diff --git a/test/utils/mocks/MockReentrancyGuard.sol b/test/utils/mocks/MockReentrancyGuard.sol index 156f23891e..377946d6f8 100644 --- a/test/utils/mocks/MockReentrancyGuard.sol +++ b/test/utils/mocks/MockReentrancyGuard.sol @@ -102,14 +102,15 @@ contract MockReentrancyGuard is ReentrancyGuard { if (recursion > 0) { enterTimes++; - (bool success, bytes memory data) = address(this).call( - abi.encodeWithSignature( - guarded - ? "countGuardedIndirectRecursive(uint256)" - : "countUnguardedIndirectRecursive(uint256)", - recursion - 1 - ) - ); + (bool success, bytes memory data) = address(this) + .call( + abi.encodeWithSignature( + guarded + ? "countGuardedIndirectRecursive(uint256)" + : "countUnguardedIndirectRecursive(uint256)", + recursion - 1 + ) + ); if (!success) { /// @solidity memory-safe-assembly diff --git a/test/utils/mocks/MockReentrancyGuardTransient.sol b/test/utils/mocks/MockReentrancyGuardTransient.sol index 18d64303a9..cf803e7d05 100644 --- a/test/utils/mocks/MockReentrancyGuardTransient.sol +++ b/test/utils/mocks/MockReentrancyGuardTransient.sol @@ -112,14 +112,15 @@ contract MockReentrancyGuardTransient is ReentrancyGuardTransient { if (recursion > 0) { enterTimes++; - (bool success, bytes memory data) = address(this).call( - abi.encodeWithSignature( - guarded - ? "countGuardedIndirectRecursive(uint256)" - : "countUnguardedIndirectRecursive(uint256)", - recursion - 1 - ) - ); + (bool success, bytes memory data) = address(this) + .call( + abi.encodeWithSignature( + guarded + ? "countGuardedIndirectRecursive(uint256)" + : "countUnguardedIndirectRecursive(uint256)", + recursion - 1 + ) + ); if (!success) { /// @solidity memory-safe-assembly