Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-cooks-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Export missing x402 types
5 changes: 5 additions & 0 deletions .changeset/warm-jokes-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/engine": patch
---

Update to latest API spec
10 changes: 10 additions & 0 deletions apps/portal/src/app/wallets/session-keys/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
94 changes: 92 additions & 2 deletions packages/engine/src/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export type BatchResultItemEncodeResultSuccessItemEngineError =
message: string;
type: "THIRDWEB_ERROR";
}
| (SerialisableAwsSignerError & {
type: "AWS_KMS_SIGNER_ERROR";
})
| {
message: string;
type: "INTERNAL_ERROR";
Expand Down Expand Up @@ -235,6 +238,9 @@ export type BatchResultItemReadResultSuccessItemEngineError =
message: string;
type: "THIRDWEB_ERROR";
}
| (SerialisableAwsSignerError & {
type: "AWS_KMS_SIGNER_ERROR";
})
| {
message: string;
type: "INTERNAL_ERROR";
Expand Down Expand Up @@ -331,6 +337,9 @@ export type BatchResultItemSignResultDataEngineError =
message: string;
type: "THIRDWEB_ERROR";
}
| (SerialisableAwsSignerError & {
type: "AWS_KMS_SIGNER_ERROR";
})
| {
message: string;
type: "INTERNAL_ERROR";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -889,6 +919,64 @@ export type SendTransactionRequest = {
webhookOptions?: Array<WebhookOptions>;
};

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: {
Expand Down Expand Up @@ -1552,6 +1640,7 @@ export type GetTransactionsResponses = {
}
| Array<unknown>;
transactionHash: string | null;
status: string | null;
confirmedAt: string | null;
confirmedAtBlockNumber: string | null;
enrichedData:
Expand Down Expand Up @@ -1712,6 +1801,7 @@ export type SearchTransactionsResponses = {
}
| Array<unknown>;
transactionHash: string | null;
status: string | null;
confirmedAt: string | null;
confirmedAtBlockNumber: string | null;
enrichedData:
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/engine/server-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
};
case "EIP7702":
return {
...executionOptions,

Check warning on line 192 in packages/thirdweb/src/engine/server-wallet.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L192 was not covered by tests
chainId,
from: address,
type: "EIP7702",
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/thirdweb/src/exports/x402.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type { Money, PaymentMiddlewareConfig } from "x402/types";
export { decodePayment, encodePayment } from "../x402/encode.js";
export {
facilitator,
Expand Down
Loading