Skip to content

Commit 7d9669d

Browse files
[thirdweb] Export missing x402 types
1 parent 62cfbb7 commit 7d9669d

File tree

6 files changed

+114
-3
lines changed

6 files changed

+114
-3
lines changed

.changeset/fluffy-cooks-kiss.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+
Export missing x402 types

.changeset/warm-jokes-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/engine": patch
3+
---
4+
5+
Update to latest API spec

apps/portal/src/app/wallets/session-keys/page.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ const serverWallet = Engine.serverWallet({
513513
address: sessionKeyAccountAddress,
514514
chain: sepolia,
515515
client: client,
516+
executionOptions: {
517+
type: "EIP7702",
518+
sessionKeyAddress: sessionKeyAccountAddress,
519+
accountAddress: account.address,
520+
},
516521
});
517522

518523
// Execute transactions with the session key
@@ -596,6 +601,11 @@ async function setupSessionKeyWith7702() {
596601
address: sessionKeyAccountAddress,
597602
chain: sepolia,
598603
client: client,
604+
executionOptions: {
605+
type: "EIP7702",
606+
sessionKeyAddress: sessionKeyAccountAddress,
607+
accountAddress: account.address,
608+
},
599609
});
600610

601611
// Execute a transaction with the session key

packages/engine/src/client/types.gen.ts

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export type BatchResultItemEncodeResultSuccessItemEngineError =
148148
message: string;
149149
type: "THIRDWEB_ERROR";
150150
}
151+
| (SerialisableAwsSignerError & {
152+
type: "AWS_KMS_SIGNER_ERROR";
153+
})
151154
| {
152155
message: string;
153156
type: "INTERNAL_ERROR";
@@ -235,6 +238,9 @@ export type BatchResultItemReadResultSuccessItemEngineError =
235238
message: string;
236239
type: "THIRDWEB_ERROR";
237240
}
241+
| (SerialisableAwsSignerError & {
242+
type: "AWS_KMS_SIGNER_ERROR";
243+
})
238244
| {
239245
message: string;
240246
type: "INTERNAL_ERROR";
@@ -331,6 +337,9 @@ export type BatchResultItemSignResultDataEngineError =
331337
message: string;
332338
type: "THIRDWEB_ERROR";
333339
}
340+
| (SerialisableAwsSignerError & {
341+
type: "AWS_KMS_SIGNER_ERROR";
342+
})
334343
| {
335344
message: string;
336345
type: "INTERNAL_ERROR";
@@ -472,13 +481,34 @@ export type ContractWrite = ContractCall & {
472481
/**
473482
* EIP-7702 Execution Options
474483
*/
475-
export type Eip7702ExecutionOptions = {
484+
export type Eip7702ExecutionOptions =
485+
| Eip7702OwnerExecution
486+
| Eip7702SessionKeyExecution;
487+
488+
/**
489+
* EIP-7702 Owner Execution
490+
*/
491+
export type Eip7702OwnerExecution = {
476492
/**
477-
* The EOA address that will sign the EIP-7702 transaction
493+
* The delegated EOA address
478494
*/
479495
from: AddressDef;
480496
};
481497

498+
/**
499+
* EIP-7702 Session Key Execution
500+
*/
501+
export type Eip7702SessionKeyExecution = {
502+
/**
503+
* The session key address is your server wallet, which has been granted a session key to the `account_address`
504+
*/
505+
sessionKeyAddress: AddressDef;
506+
/**
507+
* 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`
508+
*/
509+
accountAddress: AddressDef;
510+
};
511+
482512
export type EmptyIdempotencySetResponse = {
483513
queueName: string;
484514
message: string;
@@ -889,6 +919,64 @@ export type SendTransactionRequest = {
889919
webhookOptions?: Array<WebhookOptions>;
890920
};
891921

922+
export type SerialisableAwsSdkError =
923+
| {
924+
message: string;
925+
type: "CONSTRUCTION_FAILURE";
926+
}
927+
| {
928+
message: string;
929+
type: "TIMEOUT_ERROR";
930+
}
931+
| {
932+
message: string;
933+
type: "DISPATCH_FAILURE";
934+
}
935+
| {
936+
message: string;
937+
type: "RESPONSE_ERROR";
938+
}
939+
| {
940+
message: string;
941+
type: "SERVICE_ERROR";
942+
}
943+
| {
944+
message: string;
945+
type: "OTHER";
946+
};
947+
948+
export type SerialisableAwsSignerError =
949+
| {
950+
aws_sdk_error: SerialisableAwsSdkError;
951+
type: "SIGN";
952+
}
953+
| {
954+
aws_sdk_error: SerialisableAwsSdkError;
955+
type: "GET_PUBLIC_KEY";
956+
}
957+
| {
958+
message: string;
959+
type: "K256";
960+
}
961+
| {
962+
message: string;
963+
type: "SPKI";
964+
}
965+
| {
966+
message: string;
967+
type: "HEX";
968+
}
969+
| {
970+
type: "SIGNATURE_NOT_FOUND";
971+
}
972+
| {
973+
type: "PUBLIC_KEY_NOT_FOUND";
974+
}
975+
| {
976+
message: string;
977+
type: "UNKNOWN";
978+
};
979+
892980
export type SerializableReqwestError =
893981
| {
894982
Builder: {
@@ -1552,6 +1640,7 @@ export type GetTransactionsResponses = {
15521640
}
15531641
| Array<unknown>;
15541642
transactionHash: string | null;
1643+
status: string | null;
15551644
confirmedAt: string | null;
15561645
confirmedAtBlockNumber: string | null;
15571646
enrichedData:
@@ -1712,6 +1801,7 @@ export type SearchTransactionsResponses = {
17121801
}
17131802
| Array<unknown>;
17141803
transactionHash: string | null;
1804+
status: string | null;
17151805
confirmedAt: string | null;
17161806
confirmedAtBlockNumber: string | null;
17171807
enrichedData:

packages/thirdweb/src/engine/server-wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
189189
};
190190
case "EIP7702":
191191
return {
192+
...executionOptions,
192193
chainId,
193-
from: address,
194194
type: "EIP7702",
195195
};
196196
}

packages/thirdweb/src/exports/x402.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export type { Money, PaymentMiddlewareConfig } from "x402/types";
12
export { decodePayment, encodePayment } from "../x402/encode.js";
23
export {
34
facilitator,

0 commit comments

Comments
 (0)