Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/SimpleFunder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ contract SimpleFunder is EIP712, Ownable, IFunder {
if gt(amount, allowance) {
mstore(m, 0x095ea7b3) // `approve(address,uint256)`.
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) // type(uint256).max
mstore(add(m, 0x40), not(0)) // type(uint256).max
// Orchestrator checks for token transfer success, so we don't need to check it here.
pop(call(gas(), token, 0, add(m, 0x1c), 0x44, 0x00, 0x00))
}
Expand Down
13 changes: 13 additions & 0 deletions test/SimpleFunder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ contract SimpleFunderTest is Test {
assertGt(token.allowance(address(simpleFunder), orchestrator), allowanceBefore + 100 ether);
}

function test_fund_setsMaxUint256Allowance() public {
ICommon.Transfer[] memory transfers = new ICommon.Transfer[](1);
transfers[0] = ICommon.Transfer({token: address(token), amount: 100 ether});

bytes32 digest = keccak256("test digest");
(uint8 v, bytes32 r, bytes32 s) = vm.sign(funderPrivateKey, digest);
bytes memory signature = abi.encodePacked(r, s, v);

simpleFunder.fund(digest, transfers, signature);

assertEq(token.allowance(address(simpleFunder), orchestrator), type(uint256).max);
}

function test_fund_withInvalidSignature_reverts() public {
ICommon.Transfer[] memory transfers = new ICommon.Transfer[](1);
transfers[0] = ICommon.Transfer({token: address(token), amount: 100 ether});
Expand Down