Skip to content

Conversation

@apmcdermott
Copy link
Contributor

Description

Tests

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

- 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
@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
x402 Ready Ready Preview, Comment Jan 17, 2026 2:45am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Changes to core v2 packages typescript

Development

Successfully merging this pull request may close these issues.

1 participant