Skip to content

Commit

Permalink
Merge branch 'main' into better-calldata-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Sep 4, 2024
2 parents c755eed + c2be266 commit a0a4052
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
6 changes: 2 additions & 4 deletions src/base/Permit2Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract Permit2Forwarder {
/// @notice the Permit2 contract to forward approvals
IAllowanceTransfer public immutable permit2;

error Wrap__Permit2Reverted(address _permit2, bytes reason);

constructor(IAllowanceTransfer _permit2) {
permit2 = _permit2;
}
Expand All @@ -28,7 +26,7 @@ contract Permit2Forwarder {
// use try/catch in case an actor front-runs the permit, which would DOS multicalls
try permit2.permit(owner, permitSingle, signature) {}
catch (bytes memory reason) {
err = abi.encodeWithSelector(Wrap__Permit2Reverted.selector, address(permit2), reason);
err = reason;
}
}

Expand All @@ -45,7 +43,7 @@ contract Permit2Forwarder {
// use try/catch in case an actor front-runs the permit, which would DOS multicalls
try permit2.permit(owner, _permitBatch, signature) {}
catch (bytes memory reason) {
err = abi.encodeWithSelector(Wrap__Permit2Reverted.selector, address(permit2), reason);
err = reason;
}
}
}
33 changes: 3 additions & 30 deletions test/position-managers/PositionManager.multicall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -422,26 +422,8 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest
lpm.ownerOf(tokenId); // token does not exist

bytes[] memory results = lpm.multicall(calls);
assertEq(
results[0],
abi.encode(
abi.encodeWithSelector(
Permit2Forwarder.Wrap__Permit2Reverted.selector,
address(permit2),
abi.encodeWithSelector(InvalidNonce.selector)
)
)
);
assertEq(
results[1],
abi.encode(
abi.encodeWithSelector(
Permit2Forwarder.Wrap__Permit2Reverted.selector,
address(permit2),
abi.encodeWithSelector(InvalidNonce.selector)
)
)
);
assertEq(results[0], abi.encode(abi.encodeWithSelector(InvalidNonce.selector)));
assertEq(results[1], abi.encode(abi.encodeWithSelector(InvalidNonce.selector)));

assertEq(lpm.ownerOf(tokenId), charlie);
}
Expand Down Expand Up @@ -491,16 +473,7 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest
lpm.ownerOf(tokenId); // token does not exist

bytes[] memory results = lpm.multicall(calls);
assertEq(
results[0],
abi.encode(
abi.encodeWithSelector(
Permit2Forwarder.Wrap__Permit2Reverted.selector,
address(permit2),
abi.encodeWithSelector(InvalidNonce.selector)
)
)
);
assertEq(results[0], abi.encode(abi.encodeWithSelector(InvalidNonce.selector)));

assertEq(lpm.ownerOf(tokenId), charlie);
}
Expand Down

0 comments on commit a0a4052

Please sign in to comment.