fix(helpers)!: require explicit name/version domain in x402rDefaults#209
Open
vraspar wants to merge 3 commits into
Open
fix(helpers)!: require explicit name/version domain in x402rDefaults#209vraspar wants to merge 3 commits into
vraspar wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
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.
What
x402rDefaultsno longer silently defaults the EIP-712 token domain toname:'USDC'/version:'2'. Bothnameandversionare now required inputs (enforced at the type level, with a runtimeValidationErrorguard for JS consumers).Why
x402rDefaultsnever receives the token address, so it cannot know the correct EIP-712 domain. The silentUSDC/2default was a latent footgun: for any token whose domain differs — including USDC on Base mainnet, whose canonicalname()isUSD Coin(notUSDC) — the wrong domain produces a signature the contract rejects, causing a silent on-chain settle revert discovered only at settlement time. Making the fields required surfaces the decision at construction, where it's cheap to get right.This does not change verify-time behavior (payer and facilitator both read the signed
extra.name/version); it removes the on-chain settle-revert class of bug.Changes
name/versionare required onX402rDefaultsInput;DEFAULT_TOKEN_NAME/DEFAULT_TOKEN_VERSIONremoved.ValidationErrorfor empty/missingnameorversion.USD Coin/1) + guard coverage for emptyname/version.@x402r/helpers, minor — 0.x breaking).Breaking change & migration
Callers must pass the token's EIP-712 domain explicitly. For the testnet USDC used in the SDK examples:
name: 'USDC', version: '2'. For mainnet USDC:name: 'USD Coin', version: '2'.Testing
pnpm typecheck(repo-wide): 6/6 clean — confirms no un-updated caller.pnpm --filter @x402r/helpers test: green.pnpm --filter @x402r/helpers build: clean (attw + publint).Part of the authCapture upstream-alignment Phase 3 work.