Skip to content

Commit 68069e9

Browse files
[x402] Add recipientAddress to payment request and replace deprecated payTo
1 parent 080d7f2 commit 68069e9

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

.changeset/loud-apples-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Add optional recipientAddress to x402 settlePayment

.changeset/lucky-meals-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Expose 7702 utility functions

packages/thirdweb/src/exports/wallets/in-app.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
// --- KEEEP IN SYNC with exports/wallets/in-app.native.ts ---
22

3+
export {
4+
type GetCallPoliciesForSignerParams,
5+
getCallPoliciesForSigner,
6+
} from "../../extensions/erc7702/__generated__/MinimalAccount/read/getCallPoliciesForSigner.js";
7+
export {
8+
type GetSessionExpirationForSignerParams,
9+
getSessionExpirationForSigner,
10+
} from "../../extensions/erc7702/__generated__/MinimalAccount/read/getSessionExpirationForSigner.js";
11+
export {
12+
type GetSessionStateForSignerParams,
13+
getSessionStateForSigner,
14+
} from "../../extensions/erc7702/__generated__/MinimalAccount/read/getSessionStateForSigner.js";
15+
export {
16+
type GetTransferPoliciesForSignerParams,
17+
getTransferPoliciesForSigner,
18+
} from "../../extensions/erc7702/__generated__/MinimalAccount/read/getTransferPoliciesForSigner.js";
19+
export {
20+
type IsWildcardSignerParams,
21+
isWildcardSigner,
22+
} from "../../extensions/erc7702/__generated__/MinimalAccount/read/isWildcardSigner.js";
323
//ACCOUNT
424
export {
525
type CreateSessionKeyOptions,
626
createSessionKey,
727
isCreateSessionKeySupported,
828
} from "../../extensions/erc7702/account/createSessionKey.js";
29+
930
export type {
1031
Condition,
1132
LimitType,

packages/thirdweb/src/x402/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function decodePaymentRequest(
4444
price,
4545
network,
4646
facilitator,
47+
payTo,
4748
resourceUrl,
4849
routeConfig = {},
4950
method,
@@ -104,7 +105,7 @@ export async function decodePaymentRequest(
104105
resource: resourceUrl,
105106
description: description ?? "",
106107
mimeType: mimeType ?? "application/json",
107-
payTo: getAddress(facilitator.address),
108+
payTo: getAddress(facilitator.address), // always pay to the facilitator address first
108109
maxTimeoutSeconds: maxTimeoutSeconds ?? 300,
109110
asset: getAddress(asset.address),
110111
outputSchema: {
@@ -117,6 +118,7 @@ export async function decodePaymentRequest(
117118
output: outputSchema,
118119
},
119120
extra: {
121+
recipientAddress: payTo, // input payTo is the final recipient address
120122
...((asset as ERC20TokenAmount["asset"]).eip712 ?? {}),
121123
},
122124
});

packages/thirdweb/src/x402/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type PaymentArgs = {
3434
facilitator: ThirdwebX402Facilitator;
3535
/** Optional configuration for the payment middleware route */
3636
routeConfig?: PaymentMiddlewareConfig;
37-
/** @deprecated Use facilitator.address instead */
37+
/** Optional recipient address to receive the payment if different from your facilitator address */
3838
payTo?: string;
3939
};
4040

0 commit comments

Comments
 (0)