-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: exact evm permit2 sdk updates #983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
apmcdermott
wants to merge
11
commits into
feat/exact-evm-permit-2
Choose a base branch
from
feat/exact-evm-permit2-sdk-updates
base: feat/exact-evm-permit-2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: exact evm permit2 sdk updates #983
apmcdermott
wants to merge
11
commits into
feat/exact-evm-permit-2
from
feat/exact-evm-permit2-sdk-updates
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add AssetTransferMethod type ('eip3009' | 'permit2')
- Add ExactPermit2Payload type for Permit2 authorization flow
- Add Permit2Witness, Permit2Authorization types matching contract structs
- Add EIP2612PermitParams for gasless approval extension
- Add permit2WitnessTypes and eip2612PermitTypes for EIP-712 signing
- Add isPermit2Payload() and isEIP3009Payload() type guards
- Export all new types and constants from package index
- Add Permit2 payload types and EIP-712 signing constants - Split client payload creation into separate eip3009.ts and permit2.ts modules - Refactor scheme.ts as orchestrator routing based on assetTransferMethod - Add createPermit2Nonce utility for 256-bit nonces - Support permit2Authorization with witness pattern for x402Permit2Proxy - Default to eip3009, allow permit2 override via PaymentRequirements.extra
- Add optional extra field to ResourceConfig interface - Pass extra through buildPaymentRequirementsFromOptions - Merge resourceConfig.extra with parsedPrice.extra in buildPaymentRequirements - Allows servers to specify assetTransferMethod: 'eip3009' | 'permit2'
Client changes: - Add EIP2612_GAS_SPONSORING_EXTENSION constant and interface - Update createPermit2Payload to accept context with optional eip2612Nonce - Create EIP-2612 permit signature when facilitator supports extension - Export extension types from client index Facilitator changes: - Add type guards to reject Permit2 payloads (unsupported_payload_type) - EIP-3009 payloads continue to work as before - Permit2 facilitator support will be added in future release
- Add createPermit2ApprovalTx() to create ERC20.approve(Permit2) tx data - Add getPermit2AllowanceReadParams() to check existing allowance - Export erc20AllowanceAbi for custom queries - Extract MAX_UINT256 constant for reuse
- Add type guard tests for isEIP3009Payload and isPermit2Payload - Add ExactPermit2Payload type structure tests - Add createPaymentPayload tests for assetTransferMethod routing - Add Permit2 payload structure validation tests - Add createPermit2ApprovalTx helper tests - Add getPermit2AllowanceReadParams helper tests
- Add verifyPermit2() method with full validation: - Scheme and network matching - Spender must be x402Permit2Proxy address - witness.to must match payTo - permitted.token must match asset - permitted.amount must be >= required amount - deadline and validBefore must be in the future - validAfter must not be in the future - Signature verification using Permit2 EIP-712 domain - Balance check - Route Permit2 payloads to verifyPermit2() in verify() - Add comprehensive unit tests for Permit2 verification Correct type errors in tests
- Add settlePermit2() method to handle Permit2 payment settlement - Call x402Permit2Proxy.settle() for standard Permit2 flow - Call x402Permit2Proxy.settleWith2612() when eip2612GasSponsoring extension is present - Route Permit2 payloads from settle() to settlePermit2()
- Test successful Permit2 settlement via settle() - Test settleWith2612() when eip2612GasSponsoring extension present - Test error handling for verification failures - Test error handling for transaction failures and reverts
- Add buildPermit2PaymentRequirements helper - Add integration test for Permit2 verify and settle flow - Verify payload structure includes permit2Authorization - Verify spender is x402Permit2Proxy and witness.to is payTo
- Check existing Permit2 allowance before test - Send approval transaction if allowance is insufficient - Use createPermit2ApprovalTx() and getPermit2AllowanceReadParams() helpers Fix test
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Tests
Checklist