Skip to content

Commit f48c02f

Browse files
committed
Refactor Solana sign transaction API for flexible inputs
Reworked the Solana sign transaction API to accept more flexible input types, supporting both instructions and pre-built transactions. Updated type definitions and endpoint URL, and removed the old implementation to improve usability and consistency.
1 parent 915d955 commit f48c02f

File tree

3 files changed

+122
-75
lines changed

3 files changed

+122
-75
lines changed

.changeset/salty-squids-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/engine": minor
3+
---
4+
5+
Reworked Solana SIgn Transaction API that accepts more flexible inputs

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,33 @@ export const sendSolanaTransaction = <ThrowOnError extends boolean = false>(
274274
});
275275
};
276276

277+
/**
278+
* Sign Solana Transaction
279+
* Sign a Solana transaction without broadcasting it
280+
*/
281+
export const signSolanaTransaction = <ThrowOnError extends boolean = false>(
282+
options: Options<SignSolanaTransactionData, ThrowOnError>,
283+
) => {
284+
return (options.client ?? _heyApiClient).post<
285+
SignSolanaTransactionResponses,
286+
unknown,
287+
ThrowOnError
288+
>({
289+
security: [
290+
{
291+
name: "x-secret-key",
292+
type: "apiKey",
293+
},
294+
],
295+
url: "/v1/solana/sign/transaction",
296+
...options,
297+
headers: {
298+
"Content-Type": "application/json",
299+
...options.headers,
300+
},
301+
});
302+
};
303+
277304
/**
278305
* Cancel Transaction
279306
* 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 = <ThrowOnError extends boolean = false>(
424451
});
425452
};
426453

427-
/**
428-
* Sign Solana Transaction
429-
* Sign a serialized Solana transaction.
430-
*/
431-
export const signSolanaTransaction = <ThrowOnError extends boolean = false>(
432-
options?: Options<SignSolanaTransactionData, ThrowOnError>,
433-
) => {
434-
return (options?.client ?? _heyApiClient).post<
435-
SignSolanaTransactionResponses,
436-
unknown,
437-
ThrowOnError
438-
>({
439-
security: [
440-
{
441-
name: "x-secret-key",
442-
type: "apiKey",
443-
},
444-
],
445-
url: "/v1/solana/sign-transaction",
446-
...options,
447-
headers: {
448-
"Content-Type": "application/json",
449-
...options?.headers,
450-
},
451-
});
452-
};
453-
454454
/**
455455
* Get Transactions
456456
* Search transactions with various filters and pagination

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

Lines changed: 90 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ export type Eip7702OwnerExecution = {
556556
* The delegated EOA address
557557
*/
558558
from: AddressDef;
559+
/**
560+
* Optional fleet ID to route the transaction to a specific bundler fleet
561+
*/
562+
fleetId?: string | null;
559563
};
560564

561565
/**
@@ -570,6 +574,10 @@ export type Eip7702SessionKeyExecution = {
570574
* 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`
571575
*/
572576
accountAddress: AddressDef;
577+
/**
578+
* Optional fleet ID to route the transaction to a specific bundler fleet
579+
*/
580+
fleetId?: string | null;
573581
};
574582

575583
export type EmptyIdempotencySetResponse = {
@@ -1000,15 +1008,11 @@ export type RpcErrorResponse = {
10001008
/**
10011009
* Request to send a Solana transaction
10021010
*/
1003-
export type SendSolanaTransactionRequest = {
1011+
export type SendSolanaTransactionRequest = SolanaTransactionInput & {
10041012
/**
10051013
* Idempotency key for this transaction (defaults to random UUID)
10061014
*/
10071015
idempotencyKey?: string;
1008-
/**
1009-
* List of Solana instructions to execute
1010-
*/
1011-
instructions: Array<SolanaInstructionData>;
10121016
/**
10131017
* Solana execution options
10141018
*/
@@ -1188,6 +1192,30 @@ export type SignResultData = {
11881192
signedData: string;
11891193
};
11901194

1195+
/**
1196+
* Request to sign a Solana transaction
1197+
*/
1198+
export type SignSolanaTransactionRequest = SolanaTransactionInput & {
1199+
/**
1200+
* Solana execution options
1201+
*/
1202+
executionOptions: SolanaExecutionOptions;
1203+
};
1204+
1205+
/**
1206+
* Data returned from successful signing
1207+
*/
1208+
export type SignSolanaTransactionResponse = {
1209+
/**
1210+
* The signature (base58-encoded)
1211+
*/
1212+
signature: string;
1213+
/**
1214+
* The signed serialized transaction (base64-encoded)
1215+
*/
1216+
signedTransaction: string;
1217+
};
1218+
11911219
/**
11921220
* Request to sign typed data
11931221
*/
@@ -1452,6 +1480,21 @@ export type SolanaRpcResponseErrorData =
14521480
type: "NODE_UNHEALTHY";
14531481
};
14541482

1483+
/**
1484+
* Input for Solana transaction - either build from instructions or use pre-built
1485+
*/
1486+
export type SolanaTransactionInput =
1487+
| SolanaTransactionInputInstructions
1488+
| SolanaTransactionInputSerialized;
1489+
1490+
export type SolanaTransactionInputInstructions = {
1491+
instructions: Array<SolanaInstructionData>;
1492+
};
1493+
1494+
export type SolanaTransactionInputSerialized = {
1495+
transaction: string;
1496+
};
1497+
14551498
/**
14561499
* Execution Option Variants
14571500
* All supported specific execution options are contained here
@@ -1503,6 +1546,22 @@ export type SuccessResponseQueuedTransactionsResponse = {
15031546
};
15041547
};
15051548

1549+
export type SuccessResponseSignSolanaTransactionResponse = {
1550+
/**
1551+
* Data returned from successful signing
1552+
*/
1553+
result: {
1554+
/**
1555+
* The signature (base58-encoded)
1556+
*/
1557+
signature: string;
1558+
/**
1559+
* The signed serialized transaction (base64-encoded)
1560+
*/
1561+
signedTransaction: string;
1562+
};
1563+
};
1564+
15061565
export type ThirdwebError =
15071566
| {
15081567
error: ThirdwebSerializationError;
@@ -1847,6 +1906,32 @@ export type SendSolanaTransactionResponses = {
18471906
export type SendSolanaTransactionResponse =
18481907
SendSolanaTransactionResponses[keyof SendSolanaTransactionResponses];
18491908

1909+
export type SignSolanaTransactionData = {
1910+
/**
1911+
* Sign Solana transaction request
1912+
*/
1913+
body: SignSolanaTransactionRequest;
1914+
headers?: {
1915+
/**
1916+
* Vault access token
1917+
*/
1918+
"x-vault-access-token"?: string | null;
1919+
};
1920+
path?: never;
1921+
query?: never;
1922+
url: "/v1/solana/sign/transaction";
1923+
};
1924+
1925+
export type SignSolanaTransactionResponses = {
1926+
/**
1927+
* Successfully signed Solana transaction
1928+
*/
1929+
200: SuccessResponseSignSolanaTransactionResponse;
1930+
};
1931+
1932+
export type SignSolanaTransactionResponse2 =
1933+
SignSolanaTransactionResponses[keyof SignSolanaTransactionResponses];
1934+
18501935
export type CancelTransactionData = {
18511936
body?: never;
18521937
path: {
@@ -2076,49 +2161,6 @@ export type SignSolanaMessageResponses = {
20762161
export type SignSolanaMessageResponse =
20772162
SignSolanaMessageResponses[keyof SignSolanaMessageResponses];
20782163

2079-
export type SignSolanaTransactionData = {
2080-
body?: {
2081-
/**
2082-
* Base58 encoded Solana public key
2083-
*/
2084-
from: string;
2085-
/**
2086-
* Base64 encoded Solana transaction
2087-
*/
2088-
transaction: string;
2089-
};
2090-
headers?: {
2091-
/**
2092-
* Vault Access Token used to access your EOA
2093-
*/
2094-
"x-vault-access-token"?: string;
2095-
};
2096-
path?: never;
2097-
query?: never;
2098-
url: "/v1/solana/sign-transaction";
2099-
};
2100-
2101-
export type SignSolanaTransactionResponses = {
2102-
/**
2103-
* Transaction signed
2104-
*/
2105-
200: {
2106-
result: {
2107-
/**
2108-
* Base58 encoded signature
2109-
*/
2110-
signature: string;
2111-
/**
2112-
* Base58 encoded Solana public key
2113-
*/
2114-
signerPublicKey: string;
2115-
};
2116-
};
2117-
};
2118-
2119-
export type SignSolanaTransactionResponse =
2120-
SignSolanaTransactionResponses[keyof SignSolanaTransactionResponses];
2121-
21222164
export type GetTransactionsData = {
21232165
body?: never;
21242166
path?: never;

0 commit comments

Comments
 (0)