Skip to content

Commit 2f5fdca

Browse files
committed
feat(wasm-solana): add authorize and customTx intent handlers
Add support for two new Solana intent types in the WASM transaction builder: - authorize: Decodes a pre-built transaction message (base64/bincode) and wraps it as an unsigned Transaction. Bypasses nonce/memo since the message is already complete. - customTx: Parses solInstructions array (programId, keys, data) into native Solana Instructions. Goes through normal nonce/memo path. Also adds corresponding types (AuthorizeIntent, CustomTxIntent, CustomTxInstruction, CustomTxKey) and unit tests for both handlers. BTC-3025
1 parent 86824a5 commit 2f5fdca

3 files changed

Lines changed: 302 additions & 54 deletions

File tree

packages/wasm-solana/js/intentBuilder.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,40 @@ export interface ConsolidateIntent extends BaseIntent {
176176
}>;
177177
}
178178

179+
/** Authorize intent - pre-built transaction message */
180+
export interface AuthorizeIntent extends BaseIntent {
181+
intentType: "authorize";
182+
/** Base64-encoded bincode-serialized Solana Message */
183+
transactionMessage: string;
184+
}
185+
186+
/** Custom transaction intent */
187+
export interface CustomTxIntent extends BaseIntent {
188+
intentType: "customTx";
189+
/** Custom instructions to include in the transaction */
190+
solInstructions: CustomTxInstruction[];
191+
}
192+
193+
/** A single custom instruction */
194+
export interface CustomTxInstruction {
195+
/** Program ID (base58) */
196+
programId: string;
197+
/** Account keys for the instruction */
198+
keys: CustomTxKey[];
199+
/** Instruction data (base64) */
200+
data: string;
201+
}
202+
203+
/** Account key for a custom instruction */
204+
export interface CustomTxKey {
205+
/** Account public key (base58) */
206+
pubkey: string;
207+
/** Whether this account must sign the transaction */
208+
isSigner: boolean;
209+
/** Whether this account is writable */
210+
isWritable: boolean;
211+
}
212+
179213
/** Union of all supported intent types */
180214
export type SolanaIntent =
181215
| PaymentIntent
@@ -186,7 +220,9 @@ export type SolanaIntent =
186220
| DelegateIntent
187221
| EnableTokenIntent
188222
| CloseAtaIntent
189-
| ConsolidateIntent;
223+
| ConsolidateIntent
224+
| AuthorizeIntent
225+
| CustomTxIntent;
190226

191227
// =============================================================================
192228
// Main Function

0 commit comments

Comments
 (0)