From 7d9669d6e375e4702a37a89932ca27229cfcce10 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Thu, 9 Oct 2025 13:12:07 +1300 Subject: [PATCH] [thirdweb] Export missing x402 types --- .changeset/fluffy-cooks-kiss.md | 5 + .changeset/warm-jokes-vanish.md | 5 + .../src/app/wallets/session-keys/page.mdx | 10 ++ packages/engine/src/client/types.gen.ts | 94 ++++++++++++++++++- packages/thirdweb/src/engine/server-wallet.ts | 2 +- packages/thirdweb/src/exports/x402.ts | 1 + 6 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 .changeset/fluffy-cooks-kiss.md create mode 100644 .changeset/warm-jokes-vanish.md diff --git a/.changeset/fluffy-cooks-kiss.md b/.changeset/fluffy-cooks-kiss.md new file mode 100644 index 00000000000..3151f5fec1c --- /dev/null +++ b/.changeset/fluffy-cooks-kiss.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Export missing x402 types diff --git a/.changeset/warm-jokes-vanish.md b/.changeset/warm-jokes-vanish.md new file mode 100644 index 00000000000..3c344de09cf --- /dev/null +++ b/.changeset/warm-jokes-vanish.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/engine": patch +--- + +Update to latest API spec diff --git a/apps/portal/src/app/wallets/session-keys/page.mdx b/apps/portal/src/app/wallets/session-keys/page.mdx index b42c1dc1332..01eb474c7f5 100644 --- a/apps/portal/src/app/wallets/session-keys/page.mdx +++ b/apps/portal/src/app/wallets/session-keys/page.mdx @@ -513,6 +513,11 @@ const serverWallet = Engine.serverWallet({ address: sessionKeyAccountAddress, chain: sepolia, client: client, + executionOptions: { + type: "EIP7702", + sessionKeyAddress: sessionKeyAccountAddress, + accountAddress: account.address, + }, }); // Execute transactions with the session key @@ -596,6 +601,11 @@ async function setupSessionKeyWith7702() { address: sessionKeyAccountAddress, chain: sepolia, client: client, + executionOptions: { + type: "EIP7702", + sessionKeyAddress: sessionKeyAccountAddress, + accountAddress: account.address, + }, }); // Execute a transaction with the session key diff --git a/packages/engine/src/client/types.gen.ts b/packages/engine/src/client/types.gen.ts index 1d05d44f30e..d77e6e6481a 100644 --- a/packages/engine/src/client/types.gen.ts +++ b/packages/engine/src/client/types.gen.ts @@ -148,6 +148,9 @@ export type BatchResultItemEncodeResultSuccessItemEngineError = message: string; type: "THIRDWEB_ERROR"; } + | (SerialisableAwsSignerError & { + type: "AWS_KMS_SIGNER_ERROR"; + }) | { message: string; type: "INTERNAL_ERROR"; @@ -235,6 +238,9 @@ export type BatchResultItemReadResultSuccessItemEngineError = message: string; type: "THIRDWEB_ERROR"; } + | (SerialisableAwsSignerError & { + type: "AWS_KMS_SIGNER_ERROR"; + }) | { message: string; type: "INTERNAL_ERROR"; @@ -331,6 +337,9 @@ export type BatchResultItemSignResultDataEngineError = message: string; type: "THIRDWEB_ERROR"; } + | (SerialisableAwsSignerError & { + type: "AWS_KMS_SIGNER_ERROR"; + }) | { message: string; type: "INTERNAL_ERROR"; @@ -472,13 +481,34 @@ export type ContractWrite = ContractCall & { /** * EIP-7702 Execution Options */ -export type Eip7702ExecutionOptions = { +export type Eip7702ExecutionOptions = + | Eip7702OwnerExecution + | Eip7702SessionKeyExecution; + +/** + * EIP-7702 Owner Execution + */ +export type Eip7702OwnerExecution = { /** - * The EOA address that will sign the EIP-7702 transaction + * The delegated EOA address */ from: AddressDef; }; +/** + * EIP-7702 Session Key Execution + */ +export type Eip7702SessionKeyExecution = { + /** + * The session key address is your server wallet, which has been granted a session key to the `account_address` + */ + sessionKeyAddress: AddressDef; + /** + * The account address is the address of a delegated account you want to execute the transaction on. This account has granted a session key to the `session_key_address` + */ + accountAddress: AddressDef; +}; + export type EmptyIdempotencySetResponse = { queueName: string; message: string; @@ -889,6 +919,64 @@ export type SendTransactionRequest = { webhookOptions?: Array; }; +export type SerialisableAwsSdkError = + | { + message: string; + type: "CONSTRUCTION_FAILURE"; + } + | { + message: string; + type: "TIMEOUT_ERROR"; + } + | { + message: string; + type: "DISPATCH_FAILURE"; + } + | { + message: string; + type: "RESPONSE_ERROR"; + } + | { + message: string; + type: "SERVICE_ERROR"; + } + | { + message: string; + type: "OTHER"; + }; + +export type SerialisableAwsSignerError = + | { + aws_sdk_error: SerialisableAwsSdkError; + type: "SIGN"; + } + | { + aws_sdk_error: SerialisableAwsSdkError; + type: "GET_PUBLIC_KEY"; + } + | { + message: string; + type: "K256"; + } + | { + message: string; + type: "SPKI"; + } + | { + message: string; + type: "HEX"; + } + | { + type: "SIGNATURE_NOT_FOUND"; + } + | { + type: "PUBLIC_KEY_NOT_FOUND"; + } + | { + message: string; + type: "UNKNOWN"; + }; + export type SerializableReqwestError = | { Builder: { @@ -1552,6 +1640,7 @@ export type GetTransactionsResponses = { } | Array; transactionHash: string | null; + status: string | null; confirmedAt: string | null; confirmedAtBlockNumber: string | null; enrichedData: @@ -1712,6 +1801,7 @@ export type SearchTransactionsResponses = { } | Array; transactionHash: string | null; + status: string | null; confirmedAt: string | null; confirmedAtBlockNumber: string | null; enrichedData: diff --git a/packages/thirdweb/src/engine/server-wallet.ts b/packages/thirdweb/src/engine/server-wallet.ts index 1e9cb6df9f7..7009c648581 100644 --- a/packages/thirdweb/src/engine/server-wallet.ts +++ b/packages/thirdweb/src/engine/server-wallet.ts @@ -189,8 +189,8 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet { }; case "EIP7702": return { + ...executionOptions, chainId, - from: address, type: "EIP7702", }; } diff --git a/packages/thirdweb/src/exports/x402.ts b/packages/thirdweb/src/exports/x402.ts index a977d722b9e..63f91a19de3 100644 --- a/packages/thirdweb/src/exports/x402.ts +++ b/packages/thirdweb/src/exports/x402.ts @@ -1,3 +1,4 @@ +export type { Money, PaymentMiddlewareConfig } from "x402/types"; export { decodePayment, encodePayment } from "../x402/encode.js"; export { facilitator,