diff --git a/.changeset/salty-squids-repair.md b/.changeset/salty-squids-repair.md new file mode 100644 index 00000000000..a7163a9d94d --- /dev/null +++ b/.changeset/salty-squids-repair.md @@ -0,0 +1,6 @@ +--- +"@thirdweb-dev/engine": minor +--- + +Reworked Solana Sign Transaction API that accepts more flexible inputs + diff --git a/packages/engine/src/client/sdk.gen.ts b/packages/engine/src/client/sdk.gen.ts index c0297a7fd7f..a10df7f1b2b 100644 --- a/packages/engine/src/client/sdk.gen.ts +++ b/packages/engine/src/client/sdk.gen.ts @@ -274,6 +274,33 @@ export const sendSolanaTransaction = ( }); }; +/** + * Sign Solana Transaction + * Sign a Solana transaction without broadcasting it + */ +export const signSolanaTransaction = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).post< + SignSolanaTransactionResponses, + unknown, + ThrowOnError + >({ + security: [ + { + name: "x-secret-key", + type: "apiKey", + }, + ], + url: "/v1/solana/sign/transaction", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); +}; + /** * Cancel Transaction * Attempt to cancel a queued transaction. Transactions that have been sent and are waiting for mine cannot be cancelled. @@ -424,33 +451,6 @@ export const signSolanaMessage = ( }); }; -/** - * Sign Solana Transaction - * Sign a serialized Solana transaction. - */ -export const signSolanaTransaction = ( - options?: Options, -) => { - return (options?.client ?? _heyApiClient).post< - SignSolanaTransactionResponses, - unknown, - ThrowOnError - >({ - security: [ - { - name: "x-secret-key", - type: "apiKey", - }, - ], - url: "/v1/solana/sign-transaction", - ...options, - headers: { - "Content-Type": "application/json", - ...options?.headers, - }, - }); -}; - /** * Get Transactions * Search transactions with various filters and pagination diff --git a/packages/engine/src/client/types.gen.ts b/packages/engine/src/client/types.gen.ts index 963cfabf2c4..a348a752cc3 100644 --- a/packages/engine/src/client/types.gen.ts +++ b/packages/engine/src/client/types.gen.ts @@ -556,6 +556,10 @@ export type Eip7702OwnerExecution = { * The delegated EOA address */ from: AddressDef; + /** + * Optional fleet ID to route the transaction to a specific bundler fleet + */ + fleetId?: string | null; }; /** @@ -570,6 +574,10 @@ export type Eip7702SessionKeyExecution = { * 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; + /** + * Optional fleet ID to route the transaction to a specific bundler fleet + */ + fleetId?: string | null; }; export type EmptyIdempotencySetResponse = { @@ -1000,15 +1008,11 @@ export type RpcErrorResponse = { /** * Request to send a Solana transaction */ -export type SendSolanaTransactionRequest = { +export type SendSolanaTransactionRequest = SolanaTransactionInput & { /** * Idempotency key for this transaction (defaults to random UUID) */ idempotencyKey?: string; - /** - * List of Solana instructions to execute - */ - instructions: Array; /** * Solana execution options */ @@ -1188,6 +1192,30 @@ export type SignResultData = { signedData: string; }; +/** + * Request to sign a Solana transaction + */ +export type SignSolanaTransactionRequest = SolanaTransactionInput & { + /** + * Solana execution options + */ + executionOptions: SolanaExecutionOptions; +}; + +/** + * Data returned from successful signing + */ +export type SignSolanaTransactionResponse = { + /** + * The signature (base58-encoded) + */ + signature: string; + /** + * The signed serialized transaction (base64-encoded) + */ + signedTransaction: string; +}; + /** * Request to sign typed data */ @@ -1452,6 +1480,21 @@ export type SolanaRpcResponseErrorData = type: "NODE_UNHEALTHY"; }; +/** + * Input for Solana transaction - either build from instructions or use pre-built + */ +export type SolanaTransactionInput = + | SolanaTransactionInputInstructions + | SolanaTransactionInputSerialized; + +export type SolanaTransactionInputInstructions = { + instructions: Array; +}; + +export type SolanaTransactionInputSerialized = { + transaction: string; +}; + /** * Execution Option Variants * All supported specific execution options are contained here @@ -1503,6 +1546,22 @@ export type SuccessResponseQueuedTransactionsResponse = { }; }; +export type SuccessResponseSignSolanaTransactionResponse = { + /** + * Data returned from successful signing + */ + result: { + /** + * The signature (base58-encoded) + */ + signature: string; + /** + * The signed serialized transaction (base64-encoded) + */ + signedTransaction: string; + }; +}; + export type ThirdwebError = | { error: ThirdwebSerializationError; @@ -1847,6 +1906,32 @@ export type SendSolanaTransactionResponses = { export type SendSolanaTransactionResponse = SendSolanaTransactionResponses[keyof SendSolanaTransactionResponses]; +export type SignSolanaTransactionData = { + /** + * Sign Solana transaction request + */ + body: SignSolanaTransactionRequest; + headers?: { + /** + * Vault access token + */ + "x-vault-access-token"?: string | null; + }; + path?: never; + query?: never; + url: "/v1/solana/sign/transaction"; +}; + +export type SignSolanaTransactionResponses = { + /** + * Successfully signed Solana transaction + */ + 200: SuccessResponseSignSolanaTransactionResponse; +}; + +export type SignSolanaTransactionResponse2 = + SignSolanaTransactionResponses[keyof SignSolanaTransactionResponses]; + export type CancelTransactionData = { body?: never; path: { @@ -2076,49 +2161,6 @@ export type SignSolanaMessageResponses = { export type SignSolanaMessageResponse = SignSolanaMessageResponses[keyof SignSolanaMessageResponses]; -export type SignSolanaTransactionData = { - body?: { - /** - * Base58 encoded Solana public key - */ - from: string; - /** - * Base64 encoded Solana transaction - */ - transaction: string; - }; - headers?: { - /** - * Vault Access Token used to access your EOA - */ - "x-vault-access-token"?: string; - }; - path?: never; - query?: never; - url: "/v1/solana/sign-transaction"; -}; - -export type SignSolanaTransactionResponses = { - /** - * Transaction signed - */ - 200: { - result: { - /** - * Base58 encoded signature - */ - signature: string; - /** - * Base58 encoded Solana public key - */ - signerPublicKey: string; - }; - }; -}; - -export type SignSolanaTransactionResponse = - SignSolanaTransactionResponses[keyof SignSolanaTransactionResponses]; - export type GetTransactionsData = { body?: never; path?: never;