-
Notifications
You must be signed in to change notification settings - Fork 617
[SDK] Add support for extra metadata in x402 payment requests #8358
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
[SDK] Add support for extra metadata in x402 payment requests #8358
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ef731a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
WalkthroughThreaded an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as decodePaymentRequest
participant Fac as facilitator.accepts
participant Server as x402 facilitator server
Caller->>Fac: POST /accepts { amount, chainId, request, extraMetadata }
Note right of Caller `#DDEBF7`: extraMetadata forwarded from PaymentArgs
Fac->>Server: HTTP POST (payload includes extraMetadata)
Server-->>Fac: 402 + response body/headers
Fac-->>Caller: structured response (status, headers, body)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
c756994 to
ef731a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/thirdweb/src/x402/types.ts (1)
38-39: LGTM! Clean addition of optional metadata field.The type
Record<string, unknown>appropriately allows flexible metadata while avoidingany. The documentation clearly describes the purpose.Consider enhancing the comment to mention serialization requirements or provide an example of typical usage, but the current documentation is sufficient.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/four-ghosts-tickle.md(1 hunks)packages/thirdweb/src/x402/common.ts(2 hunks)packages/thirdweb/src/x402/facilitator.ts(1 hunks)packages/thirdweb/src/x402/types.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .changeset/four-ghosts-tickle.md
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/thirdweb/src/x402/facilitator.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/x402/common.tspackages/thirdweb/src/x402/types.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/x402/common.tspackages/thirdweb/src/x402/types.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/x402/common.tspackages/thirdweb/src/x402/types.ts
**/types.ts
📄 CodeRabbit inference engine (AGENTS.md)
Provide and re‑use local type barrels in a
types.tsfile
Files:
packages/thirdweb/src/x402/types.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/x402/common.ts (2)
47-47: Correct destructuring of the new optional field.The
extraMetadatafield is properly extracted from the args parameter.
58-58: Verified: facilitator.accepts() correctly handles extraMetadata.The implementation properly includes
extraMetadatafrom the args parameter in the request payload (line 284, packages/thirdweb/src/x402/facilitator.ts). The field is correctly serialized alongside other request parameters and passed to the/acceptsendpoint without issues.
size-limit report 📦
|

PR-Codex overview
This PR introduces support for
extraMetadatain the x402 payment requirements, allowing additional data to be included in payment requests.Detailed summary
extraMetadatato the payment request infacilitator.ts.extraMetadatain the function parameters incommon.ts.decodePaymentRequestfunction to acceptextraMetadata.extraMetadataas an optional field intypes.ts.Summary by CodeRabbit
New Features
Chores