diff --git a/src/SimpleFunder.sol b/src/SimpleFunder.sol index e74947fb..85f7e397 100644 --- a/src/SimpleFunder.sol +++ b/src/SimpleFunder.sol @@ -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)) } diff --git a/test/SimpleFunder.t.sol b/test/SimpleFunder.t.sol index b1c4608e..35988c3f 100644 --- a/test/SimpleFunder.t.sol +++ b/test/SimpleFunder.t.sol @@ -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});