Skip to content

Commit

Permalink
update base contract
Browse files Browse the repository at this point in the history
  • Loading branch information
amiecorso committed Oct 8, 2024
1 parent 1ee5491 commit 2608e81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 12 additions & 7 deletions test/base/SpendPermissionsBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ contract SpendPermissionsBase {
mockSpendPermissions = new MockSpendPermissions();
}

function _createRecurringAllowance(uint48 start, uint48 period, uint160 allowance)
internal
pure
returns (SpendPermissions.RecurringAllowance memory)
{
return SpendPermissions.RecurringAllowance(start, period, allowance);
function _createRecurringAllowance(
address account,
address spender,
address token,
uint48 start,
uint48 end,
uint48 period,
uint160 allowance
) internal pure returns (SpendPermissions.RecurringAllowance memory) {
return SpendPermissions.RecurringAllowance(account, spender, token, start, end, period, allowance);
}

// we'll keep this around until we know we do or don't need it
function _safeAdd(uint48 a, uint48 b) internal pure returns (uint48 c) {
bool overflow = uint256(a) + uint256(b) > type(uint48).max;
return overflow ? type(uint48).max : a + b;
}
}
}
5 changes: 2 additions & 3 deletions test/mocks/MockSpendPermissions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ pragma solidity ^0.8.23;
import {SpendPermissions} from "../../src/SpendPermissions.sol";

contract MockSpendPermissions is SpendPermissions {

// TODO: what other internal functions should be exposed?

// function initializeRecurringAllowance(
// address account,
// bytes32 permissionHash,
Expand All @@ -18,4 +17,4 @@ contract MockSpendPermissions is SpendPermissions {
function useRecurringAllowance(RecurringAllowance memory recurringAllowance, uint256 value) public {
_useRecurringAllowance(recurringAllowance, value);
}
}
}

0 comments on commit 2608e81

Please sign in to comment.