Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/accounts/ERC1271.sol
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ abstract contract ERC1271 is EIP712 {
let e := 0 // Length of `contentsName` in explicit mode.
for { let q := sub(add(p, c), 1) } 1 {} {
e := add(e, 1) // Scan backwards until we encounter a ')'.
if iszero(gt(lt(e, c), eq(byte(0, mload(sub(q, e))), 41))) { break }
if iszero(gt(lt(e, c), eq(byte(0, mload(sub(q, e))), 41))) {
break
}
}
c := sub(c, e) // Truncate `contentsDescription` to `contentsType`.
calldatacopy(p, add(add(o, 0x40), c), e) // Copy `contentsName`.
Expand Down
8 changes: 6 additions & 2 deletions src/accounts/LibEIP7702.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ library LibEIP7702 {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0)
if iszero(staticcall(gas(), account, 0x00, 0x01, 0x00, 0x20)) { revert(0x00, 0x00) }
if iszero(staticcall(gas(), account, 0x00, 0x01, 0x00, 0x20)) {
revert(0x00, 0x00)
}
implementation := mload(0x00)
}
}
Expand All @@ -91,7 +93,9 @@ library LibEIP7702 {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0)
if iszero(staticcall(gas(), target, 0x00, 0x01, 0x00, 0x20)) { revert(0x00, 0x00) }
if iszero(staticcall(gas(), target, 0x00, 0x01, 0x00, 0x20)) {
revert(0x00, 0x00)
}
result := mload(0x00)
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/auth/TimedRoles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ 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);
Expand Down
4 changes: 3 additions & 1 deletion src/tokens/ERC20Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ abstract contract ERC20Votes is ERC20 {
let checkpointPacked := sload(add(i, lengthSlot))
checkpointClock := and(0xffffffffffff, checkpointPacked)
checkpointValue := shr(96, checkpointPacked)
if eq(checkpointValue, address()) { checkpointValue := sload(not(add(i, lengthSlot))) }
if eq(checkpointValue, address()) {
checkpointValue := sload(not(add(i, lengthSlot)))
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/utils/LibBit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ library LibBit {
let l := shl(5, shr(5, n))
s := add(s, 0x20)
for { let i } xor(i, l) { i := add(i, 0x20) } { c := add(czb(mload(add(s, i))), c) }
if lt(l, n) { c := add(czb(or(shr(shl(3, sub(n, l)), not(0)), mload(add(s, l)))), c) }
if lt(l, n) {
c := add(czb(or(shr(shl(3, sub(n, l)), not(0)), mload(add(s, l)))), c)
}
}
}

Expand Down Expand Up @@ -209,8 +211,8 @@ library LibBit {
mstore(add(o, add(i, i)),
and(0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f, or(shl(4, x), x)))
}
mstore(add(o, add(s, s)), 0) // Zeroize slot after result.
mstore(0x40, add(0x40, add(o, add(s, s)))) // Allocate memory.
mstore(add(o, mload(result)), 0) // Zeroize slot after result.
mstore(0x40, add(0x40, add(o, mload(result)))) // Allocate memory.
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/utils/LibBytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ library LibBytes {
if iszero(gt(needleLen, mload(subject))) {
let subjectSearchEnd := add(sub(mload(0x00), needleLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(needleLen, 0x20)) { h := keccak256(add(needle, 0x20), needleLen) }
if iszero(lt(needleLen, 0x20)) {
h := keccak256(add(needle, 0x20), needleLen)
}
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(needleLen, 0x1f))) } 1 {} {
let t := mload(i)
Expand Down Expand Up @@ -552,7 +554,9 @@ library LibBytes {
let o := add(result, 0x20)
let subjectSearchEnd := add(sub(add(i, mload(subject)), searchLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(searchLen, 0x20)) { h := keccak256(add(needle, 0x20), searchLen) }
if iszero(lt(searchLen, 0x20)) {
h := keccak256(add(needle, 0x20), searchLen)
}
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(searchLen, 0x1f))) } 1 {} {
let t := mload(i)
Expand Down
18 changes: 8 additions & 10 deletions src/utils/LibClone.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2566,11 +2566,10 @@ 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);
}

Expand Down Expand Up @@ -2604,11 +2603,10 @@ 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);
}

Expand Down
12 changes: 9 additions & 3 deletions src/utils/RedBlackTreeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ library RedBlackTreeLib {
for {} 1 {} {
if iszero(result) { break }
packed := sload(or(nodes, result))
if iszero(eq(target, and(shr(R, packed), _BITMASK_KEY))) { break }
if iszero(eq(target, and(shr(R, packed), _BITMASK_KEY))) {
break
}
target := result
result := and(shr(_BITPOS_PARENT, packed), _BITMASK_KEY)
}
Expand Down Expand Up @@ -427,7 +429,9 @@ library RedBlackTreeLib {
let s_ := or(nodes_, cursor_)
let cPacked_ := sload(s_)
let cValue_ := shr(_BITPOS_PACKED_VALUE, cPacked_)
if iszero(cValue_) { cValue_ := sload(or(s_, _BIT_FULL_VALUE_SLOT)) }
if iszero(cValue_) {
cValue_ := sload(or(s_, _BIT_FULL_VALUE_SLOT))
}
if iszero(lt(x_, cValue_)) {
sstore(s_, setKey(cPacked_, _BITPOS_RIGHT, totalNodes_))
break
Expand Down Expand Up @@ -598,7 +602,9 @@ library RedBlackTreeLib {
key_ := t_
}

if iszero(and(_BITMASK_RED, cursorPacked_)) { removeFixup(nodes_, probe_) }
if iszero(and(_BITMASK_RED, cursorPacked_)) {
removeFixup(nodes_, probe_)
}

// Remove last workflow:

Expand Down
4 changes: 3 additions & 1 deletion src/utils/SafeTransferLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ library SafeTransferLib {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
if iszero(create(selfbalance(), 0x0b, 0x16)) {
revert(codesize(), codesize())
} // For gas estimation.
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/utils/SignatureCheckerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,11 @@ 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)
Expand Down
4 changes: 3 additions & 1 deletion src/utils/ext/zksync/SafeTransferLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ library SafeTransferLib {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, shr(96, shl(96, to)))
if iszero(call(gas(), vault, amount, 0x00, 0x20, 0x00, 0x00)) { revert(0x00, 0x00) }
if iszero(call(gas(), vault, amount, 0x00, 0x20, 0x00, 0x00)) {
revert(0x00, 0x00)
}
}
emit SingleUseETHVaultCreated(to, amount, vault);
}
Expand Down
12 changes: 5 additions & 7 deletions src/utils/ext/zksync/SignatureCheckerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,11 @@ 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)
Expand Down
8 changes: 6 additions & 2 deletions src/utils/g/LibBytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ library LibBytes {
if iszero(gt(needleLen, mload(subject))) {
let subjectSearchEnd := add(sub(mload(0x00), needleLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(needleLen, 0x20)) { h := keccak256(add(needle, 0x20), needleLen) }
if iszero(lt(needleLen, 0x20)) {
h := keccak256(add(needle, 0x20), needleLen)
}
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(needleLen, 0x1f))) } 1 {} {
let t := mload(i)
Expand Down Expand Up @@ -556,7 +558,9 @@ library LibBytes {
let o := add(result, 0x20)
let subjectSearchEnd := add(sub(add(i, mload(subject)), searchLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(searchLen, 0x20)) { h := keccak256(add(needle, 0x20), searchLen) }
if iszero(lt(searchLen, 0x20)) {
h := keccak256(add(needle, 0x20), searchLen)
}
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(searchLen, 0x1f))) } 1 {} {
let t := mload(i)
Expand Down
12 changes: 9 additions & 3 deletions src/utils/g/RedBlackTreeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ library RedBlackTreeLib {
for {} 1 {} {
if iszero(result) { break }
packed := sload(or(nodes, result))
if iszero(eq(target, and(shr(R, packed), _BITMASK_KEY))) { break }
if iszero(eq(target, and(shr(R, packed), _BITMASK_KEY))) {
break
}
target := result
result := and(shr(_BITPOS_PARENT, packed), _BITMASK_KEY)
}
Expand Down Expand Up @@ -431,7 +433,9 @@ library RedBlackTreeLib {
let s_ := or(nodes_, cursor_)
let cPacked_ := sload(s_)
let cValue_ := shr(_BITPOS_PACKED_VALUE, cPacked_)
if iszero(cValue_) { cValue_ := sload(or(s_, _BIT_FULL_VALUE_SLOT)) }
if iszero(cValue_) {
cValue_ := sload(or(s_, _BIT_FULL_VALUE_SLOT))
}
if iszero(lt(x_, cValue_)) {
sstore(s_, setKey(cPacked_, _BITPOS_RIGHT, totalNodes_))
break
Expand Down Expand Up @@ -602,7 +606,9 @@ library RedBlackTreeLib {
key_ := t_
}

if iszero(and(_BITMASK_RED, cursorPacked_)) { removeFixup(nodes_, probe_) }
if iszero(and(_BITMASK_RED, cursorPacked_)) {
removeFixup(nodes_, probe_)
}

// Remove last workflow:

Expand Down
5 changes: 5 additions & 0 deletions test/Base58.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.4;
import "./utils/SoladyTest.sol";
import {Base58} from "../src/utils/Base58.sol";
import {LibString} from "../src/utils/LibString.sol";
import {LibBytes} from "../src/utils/LibBytes.sol";

contract Base58Test is SoladyTest {
function testBase58DecodeRevertsIfInvalidCharacter(bytes1 c) public {
Expand All @@ -28,6 +29,10 @@ contract Base58Test is SoladyTest {
}

function testBase58EncodeDecode(bytes memory data, uint256 r) public {
if (data.length > 1000) {
LibBytes.truncate(data, 1000);
}

if (r & 0x00f == 0) {
_brutalizeMemory();
}
Expand Down
8 changes: 3 additions & 5 deletions test/Base64.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ 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) {
Expand Down
12 changes: 5 additions & 7 deletions test/ERC1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ 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++;
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/ERC20Votes.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ contract ERC20VotesTest is SoladyTest {
let checkpointPacked := sload(add(i, lengthSlot))
checkpointClock := and(0xffffffffffff, checkpointPacked)
checkpointValue := shr(96, checkpointPacked)
if eq(checkpointValue, address()) { checkpointValue := sload(not(add(i, lengthSlot))) }
if eq(checkpointValue, address()) {
checkpointValue := sload(not(add(i, lengthSlot)))
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions test/ERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,9 @@ 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);
Expand Down
Loading