-
Notifications
You must be signed in to change notification settings - Fork 603
[SDK] Add x402 recipientAddress to payment request and replace deprecated payTo #8226
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 x402 recipientAddress to payment request and replace deprecated payTo #8226
Conversation
🦋 Changeset detectedLatest commit: e8f9793 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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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. |
b15a72c
to
3bb4d0b
Compare
WalkthroughAdds an optional recipientAddress surface to x402 payment handling: Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Decoder as decodePaymentRequest
participant API as x402.SettlePayment
Note right of Decoder #D3F3E0: map `payTo` → `extra.recipientAddress` (new)
Client->>Decoder: call with payment args (may include `payTo`)
Decoder-->>Client: decoded requirement (includes extra.recipientAddress if present)
Client->>API: call SettlePayment(..., recipientAddress?)
API-->>Client: settlement result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Git: Failed to clone repository. Please run the Comment |
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/common.ts (1)
120-123
: Consider validating and normalizing the recipient address.The
recipientAddress
is added to theextra
payload without validation or normalization, which differs from how other addresses are handled in this file (e.g.,getAddress()
is used on lines 108 and 110).Consider applying these improvements:
- Normalize the address format for consistency with other addresses in the code
- Conditionally add to extra to avoid including
undefined
propertiesextra: { - recipientAddress, + ...(recipientAddress ? { recipientAddress: getAddress(recipientAddress) } : {}), ...((asset as ERC20TokenAmount["asset"]).eip712 ?? {}), },This ensures:
- Address format consistency (checksummed addresses)
- Cleaner payload when
recipientAddress
is not provided- Early validation of address format (throws if invalid)
📜 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 (3)
.changeset/loud-apples-poke.md
(1 hunks)packages/thirdweb/src/x402/common.ts
(2 hunks)packages/thirdweb/src/x402/types.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless 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@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless 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/types.ts
packages/thirdweb/src/x402/common.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/types.ts
packages/thirdweb/src/x402/common.ts
**/types.ts
📄 CodeRabbit inference engine (AGENTS.md)
Provide and re‑use local type barrels in a
types.ts
file
Files:
packages/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@example
and 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/types.ts
packages/thirdweb/src/x402/common.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md
: Each change inpackages/*
must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/loud-apples-poke.md
⏰ 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: E2E Tests (pnpm, esbuild)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Size
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
.changeset/loud-apples-poke.md (1)
1-5
: LGTM!The changeset follows the proper format and correctly documents a patch version bump for the API addition.
packages/thirdweb/src/x402/types.ts (1)
37-38
: Add comprehensive TSDoc with an example.The inline comment is helpful, but coding guidelines require comprehensive TSDoc with at least one compiling
@example
for every public symbol in the thirdweb package.As per coding guidelines for
packages/thirdweb/**/*.{ts,tsx}
:Every public symbol must have comprehensive TSDoc with at least one compiling
@example
and a custom tag (@beta
,@internal
,@experimental
, etc.)Consider adding TSDoc in this format:
- /** Optional recipient address to receive the payment if different from your facilitator address */ - recipientAddress?: string; + /** + * Optional recipient address to receive the payment if different from your facilitator address. + * When specified, the facilitator will forward the payment to this address after processing. + * + * @example + * ```ts + * const result = await settlePayment({ + * // ... other required fields + * recipientAddress: "0x1234567890123456789012345678901234567890", + * }); + * ``` + * + * @public + */ + recipientAddress?: string;
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/common.ts (1)
120-124
: Consider conditionally including recipientAddress in the extra object.When
recipientAddress
isundefined
, the current implementation will create an explicitundefined
property in theextra
object. Consider conditionally including it only when defined to keep the payload cleaner.Apply this diff to conditionally include
recipientAddress
:extra: { - recipientAddress, + ...(recipientAddress && { recipientAddress }), ...((asset as ERC20TokenAmount["asset"]).eip712 ?? {}), },
📜 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 (3)
.changeset/loud-apples-poke.md
(1 hunks)packages/thirdweb/src/x402/common.ts
(2 hunks)packages/thirdweb/src/x402/types.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md
: Each change inpackages/*
must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/loud-apples-poke.md
**/*.{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@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless 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@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless 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.ts
packages/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.ts
packages/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@example
and 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.ts
packages/thirdweb/src/x402/types.ts
**/types.ts
📄 CodeRabbit inference engine (AGENTS.md)
Provide and re‑use local type barrels in a
types.ts
file
Files:
packages/thirdweb/src/x402/types.ts
🔇 Additional comments (3)
packages/thirdweb/src/x402/common.ts (1)
47-47
: LGTM! Correct destructuring of the new parameter.The destructuring of
recipientAddress
from the input arguments is correctly implemented..changeset/loud-apples-poke.md (1)
1-5
: LGTM! Appropriate patch-level changeset.The changeset correctly uses a patch version bump for adding an optional parameter, which is backward compatible. The description is clear and concise.
packages/thirdweb/src/x402/types.ts (1)
37-38
: Confirm payTo removal impact on external clientsNo references to
payTo
were found in the codebase. Please verify that removing this property won’t break downstream integrations.
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/thirdweb/src/x402/common.ts (1)
35-39
: Update TSDoc to reflect the new recipientAddress parameter.The function comment does not mention the
recipientAddress
parameter. Per coding guidelines, public symbols should have comprehensive TSDoc that documents all parameters.Apply this diff to update the TSDoc:
/** * Decodes a payment request and returns the payment requirements, selected payment requirements, and decoded payment * @param args + * @param args.recipientAddress - Optional recipient address to receive the payment if different from the facilitator address * @returns The payment requirements, selected payment requirements, and decoded payment */
🧹 Nitpick comments (1)
packages/thirdweb/src/x402/common.ts (1)
40-52
: Validate and normalizerecipientAddress
withgetAddress
Wrap the extractedrecipientAddress
in the existinggetAddress
utility before adding it toextra
(e.g.recipientAddress: getAddress(recipientAddress)
).
📜 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 (3)
.changeset/loud-apples-poke.md
(1 hunks)packages/thirdweb/src/x402/common.ts
(2 hunks)packages/thirdweb/src/x402/types.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless 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@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless 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/types.ts
packages/thirdweb/src/x402/common.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/types.ts
packages/thirdweb/src/x402/common.ts
**/types.ts
📄 CodeRabbit inference engine (AGENTS.md)
Provide and re‑use local type barrels in a
types.ts
file
Files:
packages/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@example
and 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/types.ts
packages/thirdweb/src/x402/common.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md
: Each change inpackages/*
must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/loud-apples-poke.md
⏰ 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: E2E Tests (pnpm, esbuild)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Size
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/x402/types.ts (1)
37-38
: LGTM! Clear deprecation and replacement.The replacement of
payTo
withrecipientAddress
is well-documented and maintains backward compatibility through optional typing. The documentation clearly explains the parameter's purpose..changeset/loud-apples-poke.md (1)
1-5
: Consider whether this qualifies as a minor version bump.The coding guidelines state: "patch for non-API changes; minor for new/modified public API." While the new
recipientAddress
parameter is optional and backward-compatible, it does modify the public API surface.Additionally, the description could mention that this change deprecates the
payTo
property in favor ofrecipientAddress
, providing a more complete picture of the API evolution.Based on coding guidelines.
packages/thirdweb/src/x402/common.ts (1)
101-124
: Clarify payTo vs recipientAddress usage The code assignspayTo
to the facilitator and nestsrecipientAddress
inextra
, but I couldn’t locate where each is processed. Please confirm that funds are sent topayTo
for processing and then forwarded torecipientAddress
, and add a brief comment explaining their distinct roles.
size-limit report 📦
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8226 +/- ##
=======================================
Coverage 55.02% 55.02%
=======================================
Files 919 919
Lines 60583 60583
Branches 4126 4127 +1
=======================================
+ Hits 33333 33338 +5
+ Misses 27146 27142 -4
+ Partials 104 103 -1
🚀 New features to boost your workflow:
|
2835e47
to
68069e9
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: 2
📜 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 (5)
.changeset/loud-apples-poke.md
(1 hunks).changeset/lucky-meals-join.md
(1 hunks)packages/thirdweb/src/exports/wallets/in-app.ts
(1 hunks)packages/thirdweb/src/x402/common.ts
(3 hunks)packages/thirdweb/src/x402/types.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .changeset/lucky-meals-join.md
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/thirdweb/src/x402/types.ts
- packages/thirdweb/src/x402/common.ts
🧰 Additional context used
📓 Path-based instructions (5)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md
: Each change inpackages/*
must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/loud-apples-poke.md
**/*.{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@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless 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@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless 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/exports/wallets/in-app.ts
packages/thirdweb/src/exports/**
📄 CodeRabbit inference engine (CLAUDE.md)
packages/thirdweb/src/exports/**
: Export everything viaexports/
directory, grouped by feature in the SDK public API
Every public symbol must have comprehensive TSDoc with at least one@example
block that compiles and custom annotation tags (@beta
,@internal
,@experimental
)
Files:
packages/thirdweb/src/exports/wallets/in-app.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/exports/wallets/in-app.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@example
and 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/exports/wallets/in-app.ts
🧠 Learnings (2)
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Unified `Wallet` and `Account` interfaces in wallet architecture
Applied to files:
packages/thirdweb/src/exports/wallets/in-app.ts
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : EIP-1193, EIP-5792, EIP-7702 standard support in wallet modules
Applied to files:
packages/thirdweb/src/exports/wallets/in-app.ts
🔇 Additional comments (1)
packages/thirdweb/src/exports/wallets/in-app.ts (1)
3-22
: All new ERC7702 signer exports include proper TSDoc with@example
and custom tags.
68069e9
to
e8f9793
Compare
PR-Codex overview
This PR focuses on enhancing the payment functionality in the
thirdweb
package by introducing an optionalrecipientAddress
parameter in thex402 settlePayment
method, allowing payments to be directed to a different address from the facilitator.Detailed summary
recipientAddress
parameter tox402 settlePayment
.payTo
to clarify its purpose.decodePaymentRequest
to includerecipientAddress
in the output.Summary by CodeRabbit