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
7 changes: 2 additions & 5 deletions src/AuthCaptureEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,7 @@ contract AuthCaptureEscrow is ReentrancyGuardTransient {
/// @return The operator's token store address
function getTokenStore(address operator) public view returns (address) {
return LibClone.predictDeterministicAddress({
implementation: tokenStoreImplementation,
salt: bytes32(bytes20(operator)),
deployer: address(this)
implementation: tokenStoreImplementation, salt: bytes32(bytes20(operator)), deployer: address(this)
});
}

Expand Down Expand Up @@ -440,8 +438,7 @@ contract AuthCaptureEscrow is ReentrancyGuardTransient {
} else if (tokenStore.code.length == 0) {
// Call failed from undeployed TokenStore, deploy and try again
tokenStore = LibClone.cloneDeterministic({
implementation: tokenStoreImplementation,
salt: bytes32(bytes20(operator))
implementation: tokenStoreImplementation, salt: bytes32(bytes20(operator))
});
emit TokenStoreCreated(operator, tokenStore);
TokenStore(tokenStore).sendTokens(token, recipient, amount);
Expand Down
19 changes: 10 additions & 9 deletions src/collectors/ERC3009PaymentCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ contract ERC3009PaymentCollector is TokenCollector, ERC6492SignatureHandler {
uint256 maxAmount = paymentInfo.maxAmount;

// Pull tokens into this contract
IERC3009(token).receiveWithAuthorization({
from: payer,
to: address(this),
value: maxAmount,
validAfter: 0,
validBefore: paymentInfo.preApprovalExpiry,
nonce: _getHashPayerAgnostic(paymentInfo),
signature: _handleERC6492Signature(collectorData)
});
IERC3009(token)
.receiveWithAuthorization({
from: payer,
to: address(this),
value: maxAmount,
validAfter: 0,
validBefore: paymentInfo.preApprovalExpiry,
nonce: _getHashPayerAgnostic(paymentInfo),
signature: _handleERC6492Signature(collectorData)
});

// Return any excess tokens to payer
if (maxAmount > amount) SafeERC20.safeTransfer(IERC20(token), payer, maxAmount - amount);
Expand Down
4 changes: 3 additions & 1 deletion src/collectors/Permit2PaymentCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ contract Permit2PaymentCollector is TokenCollector, ERC6492SignatureHandler {
) internal override {
permit2.permitTransferFrom({
permit: ISignatureTransfer.PermitTransferFrom({
permitted: ISignatureTransfer.TokenPermissions({token: paymentInfo.token, amount: paymentInfo.maxAmount}),
permitted: ISignatureTransfer.TokenPermissions({
token: paymentInfo.token, amount: paymentInfo.maxAmount
}),
nonce: uint256(_getHashPayerAgnostic(paymentInfo)),
deadline: paymentInfo.preApprovalExpiry
}),
Expand Down
5 changes: 1 addition & 4 deletions src/interfaces/IMulticall3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ interface IMulticall3 {
bytes returnData;
}

function aggregate(Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes[] memory returnData);
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData);

function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);

Expand Down
5 changes: 3 additions & 2 deletions test/base/AuthCaptureEscrowBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ contract AuthCaptureEscrowBase is Test, DeployPermit2 {
uint256 validBefore,
bytes32 nonce
) internal view returns (bytes32) {
bytes32 structHash =
keccak256(abi.encode(_RECEIVE_WITH_AUTHORIZATION_TYPEHASH, from, to, value, validAfter, validBefore, nonce));
bytes32 structHash = keccak256(
abi.encode(_RECEIVE_WITH_AUTHORIZATION_TYPEHASH, from, to, value, validAfter, validBefore, nonce)
);
return keccak256(abi.encodePacked("\x19\x01", IERC3009(token).DOMAIN_SEPARATOR(), structHash));
}

Expand Down
6 changes: 1 addition & 5 deletions test/base/AuthCaptureEscrowSmartWalletBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ contract AuthCaptureEscrowSmartWalletBase is AuthCaptureEscrowBase {
uint256 nonce = uint256(hashPortion);

return MagicSpend.WithdrawRequest({
asset: address(0),
amount: 0,
nonce: nonce,
expiry: type(uint48).max,
signature: new bytes(0)
asset: address(0), amount: 0, nonce: nonce, expiry: type(uint48).max, signature: new bytes(0)
});
}

Expand Down
4 changes: 1 addition & 3 deletions test/src/PaymentEscrow/authorize.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,7 @@ contract AuthorizeTest is AuthCaptureEscrowSmartWalletBase {
vm.assume(maxAmount >= amount && amount > 0);
mockERC3009Token.mint(address(smartWalletDeployed), amount);
AuthCaptureEscrow.PaymentInfo memory paymentInfo = _createPaymentInfo({
payer: address(smartWalletDeployed),
maxAmount: maxAmount,
token: address(mockERC3009Token)
payer: address(smartWalletDeployed), maxAmount: maxAmount, token: address(mockERC3009Token)
});

// Create and sign the spend permission
Expand Down
12 changes: 3 additions & 9 deletions test/src/collectors/SpendPermissionPaymentCollector.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ contract SpendPermissionPaymentCollectorTest is AuthCaptureEscrowSmartWalletBase
MockERC3009Token(address(mockERC3009Token)).mint(address(smartWalletDeployed), amount);

AuthCaptureEscrow.PaymentInfo memory paymentInfo = _createPaymentInfo({
payer: address(smartWalletDeployed),
maxAmount: amount,
token: address(mockERC3009Token)
payer: address(smartWalletDeployed), maxAmount: amount, token: address(mockERC3009Token)
});
address tokenStore = authCaptureEscrow.getTokenStore(paymentInfo.operator);

Expand All @@ -47,9 +45,7 @@ contract SpendPermissionPaymentCollectorTest is AuthCaptureEscrowSmartWalletBase
MockERC3009Token(address(mockERC3009Token)).mint(address(smartWalletDeployed), amount);

AuthCaptureEscrow.PaymentInfo memory paymentInfo = _createPaymentInfo({
payer: address(smartWalletDeployed),
maxAmount: amount,
token: address(mockERC3009Token)
payer: address(smartWalletDeployed), maxAmount: amount, token: address(mockERC3009Token)
});
address tokenStore = authCaptureEscrow.getTokenStore(paymentInfo.operator);

Expand All @@ -69,9 +65,7 @@ contract SpendPermissionPaymentCollectorTest is AuthCaptureEscrowSmartWalletBase
mockERC3009Token.mint(address(magicSpend), amount);

AuthCaptureEscrow.PaymentInfo memory paymentInfo = _createPaymentInfo({
payer: address(smartWalletDeployed),
maxAmount: amount,
token: address(mockERC3009Token)
payer: address(smartWalletDeployed), maxAmount: amount, token: address(mockERC3009Token)
});
address tokenStore = authCaptureEscrow.getTokenStore(paymentInfo.operator);

Expand Down