@bitgo/wasm-solana 1.6.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/js/builder.d.ts +8 -402
- package/dist/cjs/js/builder.js +9 -62
- package/dist/cjs/js/index.d.ts +3 -3
- package/dist/cjs/js/index.js +2 -2
- package/dist/cjs/js/transaction.d.ts +4 -5
- package/dist/cjs/js/transaction.js +3 -4
- package/dist/cjs/js/versioned.d.ts +4 -13
- package/dist/cjs/js/versioned.js +3 -17
- package/dist/cjs/js/wasm/wasm_solana.d.ts +10 -68
- package/dist/cjs/js/wasm/wasm_solana.js +23 -97
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm.d.ts +11 -12
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/esm/js/builder.d.ts +8 -402
- package/dist/esm/js/builder.js +9 -61
- package/dist/esm/js/index.d.ts +3 -3
- package/dist/esm/js/index.js +2 -2
- package/dist/esm/js/transaction.d.ts +4 -5
- package/dist/esm/js/transaction.js +3 -4
- package/dist/esm/js/versioned.d.ts +4 -13
- package/dist/esm/js/versioned.js +3 -17
- package/dist/esm/js/wasm/wasm_solana.d.ts +10 -68
- package/dist/esm/js/wasm/wasm_solana_bg.js +23 -97
- package/dist/esm/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm.d.ts +11 -12
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +2 -4
package/dist/cjs/js/builder.d.ts
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Transaction
|
|
2
|
+
* Versioned Transaction Building from Raw MessageV0 Data.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This module provides `buildFromVersionedData` for building versioned transactions
|
|
5
|
+
* from pre-compiled MessageV0 data. This is used for:
|
|
6
|
+
* - WalletConnect/Jupiter pre-compiled versioned transactions
|
|
7
|
+
* - Custom transaction pass-through (customTx intent)
|
|
8
|
+
*
|
|
9
|
+
* Unlike the intent-based builder, this takes already-compiled instruction
|
|
10
|
+
* data with account indexes, not high-level instructions.
|
|
6
11
|
*/
|
|
7
|
-
import { Transaction } from "./transaction.js";
|
|
8
12
|
import { VersionedTransaction } from "./versioned.js";
|
|
9
|
-
/** Use a recent blockhash for the transaction */
|
|
10
|
-
export interface BlockhashNonceSource {
|
|
11
|
-
type: "blockhash";
|
|
12
|
-
/** The recent blockhash value (base58) */
|
|
13
|
-
value: string;
|
|
14
|
-
}
|
|
15
|
-
/** Use a durable nonce account for the transaction */
|
|
16
|
-
export interface DurableNonceSource {
|
|
17
|
-
type: "durable";
|
|
18
|
-
/** The nonce account address (base58) */
|
|
19
|
-
address: string;
|
|
20
|
-
/** The nonce authority address (base58) */
|
|
21
|
-
authority: string;
|
|
22
|
-
/** The nonce value stored in the account (base58) - this becomes the blockhash */
|
|
23
|
-
value: string;
|
|
24
|
-
}
|
|
25
|
-
/** Nonce source for the transaction */
|
|
26
|
-
export type NonceSource = BlockhashNonceSource | DurableNonceSource;
|
|
27
13
|
/**
|
|
28
14
|
* Address Lookup Table data for versioned transactions.
|
|
29
15
|
*
|
|
@@ -38,386 +24,6 @@ export interface AddressLookupTable {
|
|
|
38
24
|
/** Indices of readonly accounts in the lookup table */
|
|
39
25
|
readonlyIndexes: number[];
|
|
40
26
|
}
|
|
41
|
-
/** SOL transfer instruction */
|
|
42
|
-
export interface TransferInstruction {
|
|
43
|
-
type: "transfer";
|
|
44
|
-
/** Source account (base58) */
|
|
45
|
-
from: string;
|
|
46
|
-
/** Destination account (base58) */
|
|
47
|
-
to: string;
|
|
48
|
-
/** Amount in lamports */
|
|
49
|
-
lamports: bigint;
|
|
50
|
-
}
|
|
51
|
-
/** Create new account instruction */
|
|
52
|
-
export interface CreateAccountInstruction {
|
|
53
|
-
type: "createAccount";
|
|
54
|
-
/** Funding account (base58) */
|
|
55
|
-
from: string;
|
|
56
|
-
/** New account address (base58) */
|
|
57
|
-
newAccount: string;
|
|
58
|
-
/** Lamports to transfer */
|
|
59
|
-
lamports: bigint;
|
|
60
|
-
/** Space to allocate in bytes */
|
|
61
|
-
space: number;
|
|
62
|
-
/** Owner program (base58) */
|
|
63
|
-
owner: string;
|
|
64
|
-
}
|
|
65
|
-
/** Advance durable nonce instruction */
|
|
66
|
-
export interface NonceAdvanceInstruction {
|
|
67
|
-
type: "nonceAdvance";
|
|
68
|
-
/** Nonce account address (base58) */
|
|
69
|
-
nonce: string;
|
|
70
|
-
/** Nonce authority (base58) */
|
|
71
|
-
authority: string;
|
|
72
|
-
}
|
|
73
|
-
/** Initialize nonce account instruction */
|
|
74
|
-
export interface NonceInitializeInstruction {
|
|
75
|
-
type: "nonceInitialize";
|
|
76
|
-
/** Nonce account address (base58) */
|
|
77
|
-
nonce: string;
|
|
78
|
-
/** Nonce authority (base58) */
|
|
79
|
-
authority: string;
|
|
80
|
-
}
|
|
81
|
-
/** Allocate space instruction */
|
|
82
|
-
export interface AllocateInstruction {
|
|
83
|
-
type: "allocate";
|
|
84
|
-
/** Account to allocate (base58) */
|
|
85
|
-
account: string;
|
|
86
|
-
/** Space to allocate in bytes */
|
|
87
|
-
space: number;
|
|
88
|
-
}
|
|
89
|
-
/** Assign account to program instruction */
|
|
90
|
-
export interface AssignInstruction {
|
|
91
|
-
type: "assign";
|
|
92
|
-
/** Account to assign (base58) */
|
|
93
|
-
account: string;
|
|
94
|
-
/** New owner program (base58) */
|
|
95
|
-
owner: string;
|
|
96
|
-
}
|
|
97
|
-
/** Memo instruction */
|
|
98
|
-
export interface MemoInstruction {
|
|
99
|
-
type: "memo";
|
|
100
|
-
/** The memo message */
|
|
101
|
-
message: string;
|
|
102
|
-
}
|
|
103
|
-
/** Compute budget instruction */
|
|
104
|
-
export interface ComputeBudgetInstruction {
|
|
105
|
-
type: "computeBudget";
|
|
106
|
-
/** Compute unit limit (optional) */
|
|
107
|
-
unitLimit?: number;
|
|
108
|
-
/** Compute unit price in micro-lamports (optional) */
|
|
109
|
-
unitPrice?: number;
|
|
110
|
-
}
|
|
111
|
-
/** Initialize a stake account instruction */
|
|
112
|
-
export interface StakeInitializeInstruction {
|
|
113
|
-
type: "stakeInitialize";
|
|
114
|
-
/** Stake account address (base58) */
|
|
115
|
-
stake: string;
|
|
116
|
-
/** Authorized staker pubkey (base58) */
|
|
117
|
-
staker: string;
|
|
118
|
-
/** Authorized withdrawer pubkey (base58) */
|
|
119
|
-
withdrawer: string;
|
|
120
|
-
}
|
|
121
|
-
/** Delegate stake to a validator instruction */
|
|
122
|
-
export interface StakeDelegateInstruction {
|
|
123
|
-
type: "stakeDelegate";
|
|
124
|
-
/** Stake account address (base58) */
|
|
125
|
-
stake: string;
|
|
126
|
-
/** Vote account (validator) to delegate to (base58) */
|
|
127
|
-
vote: string;
|
|
128
|
-
/** Stake authority (base58) */
|
|
129
|
-
authority: string;
|
|
130
|
-
}
|
|
131
|
-
/** Deactivate a stake account instruction */
|
|
132
|
-
export interface StakeDeactivateInstruction {
|
|
133
|
-
type: "stakeDeactivate";
|
|
134
|
-
/** Stake account address (base58) */
|
|
135
|
-
stake: string;
|
|
136
|
-
/** Stake authority (base58) */
|
|
137
|
-
authority: string;
|
|
138
|
-
}
|
|
139
|
-
/** Withdraw from a stake account instruction */
|
|
140
|
-
export interface StakeWithdrawInstruction {
|
|
141
|
-
type: "stakeWithdraw";
|
|
142
|
-
/** Stake account address (base58) */
|
|
143
|
-
stake: string;
|
|
144
|
-
/** Recipient address (base58) */
|
|
145
|
-
recipient: string;
|
|
146
|
-
/** Amount in lamports to withdraw */
|
|
147
|
-
lamports: bigint;
|
|
148
|
-
/** Withdraw authority (base58) */
|
|
149
|
-
authority: string;
|
|
150
|
-
}
|
|
151
|
-
/** Change stake account authorization instruction */
|
|
152
|
-
export interface StakeAuthorizeInstruction {
|
|
153
|
-
type: "stakeAuthorize";
|
|
154
|
-
/** Stake account address (base58) */
|
|
155
|
-
stake: string;
|
|
156
|
-
/** New authority pubkey (base58) */
|
|
157
|
-
newAuthority: string;
|
|
158
|
-
/** Authorization type: "staker" or "withdrawer" */
|
|
159
|
-
authorizeType: "staker" | "withdrawer";
|
|
160
|
-
/** Current authority (base58) */
|
|
161
|
-
authority: string;
|
|
162
|
-
}
|
|
163
|
-
/** Split stake account instruction (for partial deactivation) */
|
|
164
|
-
export interface StakeSplitInstruction {
|
|
165
|
-
type: "stakeSplit";
|
|
166
|
-
/** Source stake account address (base58) */
|
|
167
|
-
stake: string;
|
|
168
|
-
/** Destination stake account (must be uninitialized/created first) (base58) */
|
|
169
|
-
splitStake: string;
|
|
170
|
-
/** Stake authority (base58) */
|
|
171
|
-
authority: string;
|
|
172
|
-
/** Amount in lamports to split */
|
|
173
|
-
lamports: bigint;
|
|
174
|
-
}
|
|
175
|
-
/** Transfer tokens instruction (uses TransferChecked) */
|
|
176
|
-
export interface TokenTransferInstruction {
|
|
177
|
-
type: "tokenTransfer";
|
|
178
|
-
/** Source token account (base58) */
|
|
179
|
-
source: string;
|
|
180
|
-
/** Destination token account (base58) */
|
|
181
|
-
destination: string;
|
|
182
|
-
/** Token mint address (base58) */
|
|
183
|
-
mint: string;
|
|
184
|
-
/** Amount of tokens (in smallest units) */
|
|
185
|
-
amount: bigint;
|
|
186
|
-
/** Number of decimals for the token */
|
|
187
|
-
decimals: number;
|
|
188
|
-
/** Owner/authority of the source account (base58) */
|
|
189
|
-
authority: string;
|
|
190
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
191
|
-
programId?: string;
|
|
192
|
-
}
|
|
193
|
-
/** Create an Associated Token Account instruction */
|
|
194
|
-
export interface CreateAssociatedTokenAccountInstruction {
|
|
195
|
-
type: "createAssociatedTokenAccount";
|
|
196
|
-
/** Payer for account creation (base58) */
|
|
197
|
-
payer: string;
|
|
198
|
-
/** Owner of the new ATA (base58) */
|
|
199
|
-
owner: string;
|
|
200
|
-
/** Token mint address (base58) */
|
|
201
|
-
mint: string;
|
|
202
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
203
|
-
tokenProgramId?: string;
|
|
204
|
-
}
|
|
205
|
-
/** Close an Associated Token Account instruction */
|
|
206
|
-
export interface CloseAssociatedTokenAccountInstruction {
|
|
207
|
-
type: "closeAssociatedTokenAccount";
|
|
208
|
-
/** Token account to close (base58) */
|
|
209
|
-
account: string;
|
|
210
|
-
/** Destination for remaining lamports (base58) */
|
|
211
|
-
destination: string;
|
|
212
|
-
/** Authority of the account (base58) */
|
|
213
|
-
authority: string;
|
|
214
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
215
|
-
programId?: string;
|
|
216
|
-
}
|
|
217
|
-
/** Mint tokens to an account instruction */
|
|
218
|
-
export interface MintToInstruction {
|
|
219
|
-
type: "mintTo";
|
|
220
|
-
/** Token mint address (base58) */
|
|
221
|
-
mint: string;
|
|
222
|
-
/** Destination token account (base58) */
|
|
223
|
-
destination: string;
|
|
224
|
-
/** Mint authority (base58) */
|
|
225
|
-
authority: string;
|
|
226
|
-
/** Amount of tokens to mint (in smallest units) */
|
|
227
|
-
amount: bigint;
|
|
228
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
229
|
-
programId?: string;
|
|
230
|
-
}
|
|
231
|
-
/** Burn tokens from an account instruction */
|
|
232
|
-
export interface BurnInstruction {
|
|
233
|
-
type: "burn";
|
|
234
|
-
/** Token mint address (base58) */
|
|
235
|
-
mint: string;
|
|
236
|
-
/** Source token account to burn from (base58) */
|
|
237
|
-
account: string;
|
|
238
|
-
/** Token account authority (base58) */
|
|
239
|
-
authority: string;
|
|
240
|
-
/** Amount of tokens to burn (in smallest units) */
|
|
241
|
-
amount: bigint;
|
|
242
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
243
|
-
programId?: string;
|
|
244
|
-
}
|
|
245
|
-
/** Approve a delegate to transfer tokens instruction */
|
|
246
|
-
export interface ApproveInstruction {
|
|
247
|
-
type: "approve";
|
|
248
|
-
/** Token account to approve delegation for (base58) */
|
|
249
|
-
account: string;
|
|
250
|
-
/** Delegate address (who can transfer) (base58) */
|
|
251
|
-
delegate: string;
|
|
252
|
-
/** Token account owner (base58) */
|
|
253
|
-
owner: string;
|
|
254
|
-
/** Amount of tokens to approve (in smallest units) */
|
|
255
|
-
amount: bigint;
|
|
256
|
-
/** Token program ID (optional, defaults to SPL Token) */
|
|
257
|
-
programId?: string;
|
|
258
|
-
}
|
|
259
|
-
/** Deposit SOL into a stake pool (Jito liquid staking) */
|
|
260
|
-
export interface StakePoolDepositSolInstruction {
|
|
261
|
-
type: "stakePoolDepositSol";
|
|
262
|
-
/** Stake pool address (base58) */
|
|
263
|
-
stakePool: string;
|
|
264
|
-
/** Withdraw authority PDA (base58) */
|
|
265
|
-
withdrawAuthority: string;
|
|
266
|
-
/** Reserve stake account (base58) */
|
|
267
|
-
reserveStake: string;
|
|
268
|
-
/** Funding account (SOL source, signer) (base58) */
|
|
269
|
-
fundingAccount: string;
|
|
270
|
-
/** Destination for pool tokens (base58) */
|
|
271
|
-
destinationPoolAccount: string;
|
|
272
|
-
/** Manager fee account (base58) */
|
|
273
|
-
managerFeeAccount: string;
|
|
274
|
-
/** Referral pool account (base58) */
|
|
275
|
-
referralPoolAccount: string;
|
|
276
|
-
/** Pool mint address (base58) */
|
|
277
|
-
poolMint: string;
|
|
278
|
-
/** Amount in lamports to deposit */
|
|
279
|
-
lamports: bigint;
|
|
280
|
-
}
|
|
281
|
-
/** Withdraw stake from a stake pool (Jito liquid staking) */
|
|
282
|
-
export interface StakePoolWithdrawStakeInstruction {
|
|
283
|
-
type: "stakePoolWithdrawStake";
|
|
284
|
-
/** Stake pool address (base58) */
|
|
285
|
-
stakePool: string;
|
|
286
|
-
/** Validator list account (base58) */
|
|
287
|
-
validatorList: string;
|
|
288
|
-
/** Withdraw authority PDA (base58) */
|
|
289
|
-
withdrawAuthority: string;
|
|
290
|
-
/** Validator stake account to split from (base58) */
|
|
291
|
-
validatorStake: string;
|
|
292
|
-
/** Destination stake account (uninitialized) (base58) */
|
|
293
|
-
destinationStake: string;
|
|
294
|
-
/** Authority for the destination stake account (base58) */
|
|
295
|
-
destinationStakeAuthority: string;
|
|
296
|
-
/** Source pool token account authority (signer) (base58) */
|
|
297
|
-
sourceTransferAuthority: string;
|
|
298
|
-
/** Source pool token account (base58) */
|
|
299
|
-
sourcePoolAccount: string;
|
|
300
|
-
/** Manager fee account (base58) */
|
|
301
|
-
managerFeeAccount: string;
|
|
302
|
-
/** Pool mint address (base58) */
|
|
303
|
-
poolMint: string;
|
|
304
|
-
/** Amount of pool tokens to burn */
|
|
305
|
-
poolTokens: bigint;
|
|
306
|
-
}
|
|
307
|
-
/** Account metadata for custom instructions */
|
|
308
|
-
export interface CustomAccountMeta {
|
|
309
|
-
/** Account public key (base58) */
|
|
310
|
-
pubkey: string;
|
|
311
|
-
/** Whether the account is a signer */
|
|
312
|
-
isSigner: boolean;
|
|
313
|
-
/** Whether the account is writable */
|
|
314
|
-
isWritable: boolean;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Custom instruction for invoking any program.
|
|
318
|
-
* Enables passthrough of arbitrary instructions for extensibility.
|
|
319
|
-
*/
|
|
320
|
-
export interface CustomInstruction {
|
|
321
|
-
type: "custom";
|
|
322
|
-
/** The program ID to invoke (base58) */
|
|
323
|
-
programId: string;
|
|
324
|
-
/** Account metas for the instruction */
|
|
325
|
-
accounts: CustomAccountMeta[];
|
|
326
|
-
/** Instruction data (base64 or hex encoded) */
|
|
327
|
-
data: string;
|
|
328
|
-
/** Encoding of the data field: "base64" (default) or "hex" */
|
|
329
|
-
encoding?: "base64" | "hex";
|
|
330
|
-
}
|
|
331
|
-
/** Union of all instruction types */
|
|
332
|
-
export type Instruction = TransferInstruction | CreateAccountInstruction | NonceAdvanceInstruction | NonceInitializeInstruction | AllocateInstruction | AssignInstruction | MemoInstruction | ComputeBudgetInstruction | StakeInitializeInstruction | StakeDelegateInstruction | StakeDeactivateInstruction | StakeWithdrawInstruction | StakeAuthorizeInstruction | StakeSplitInstruction | TokenTransferInstruction | CreateAssociatedTokenAccountInstruction | CloseAssociatedTokenAccountInstruction | MintToInstruction | BurnInstruction | ApproveInstruction | StakePoolDepositSolInstruction | StakePoolWithdrawStakeInstruction | CustomInstruction;
|
|
333
|
-
/**
|
|
334
|
-
* A declarative intent to build a Solana transaction.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* const intent: TransactionIntent = {
|
|
339
|
-
* feePayer: 'DgT9qyYwYKBRDyDw3EfR12LHQCQjtNrKu2qMsXHuosmB',
|
|
340
|
-
* nonce: {
|
|
341
|
-
* type: 'blockhash',
|
|
342
|
-
* value: 'GWaQEymC3Z9SHM2gkh8u12xL1zJPMHPCSVR3pSDpEXE4'
|
|
343
|
-
* },
|
|
344
|
-
* instructions: [
|
|
345
|
-
* { type: 'transfer', from: '...', to: '...', lamports: '1000000' }
|
|
346
|
-
* ]
|
|
347
|
-
* };
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
export interface TransactionIntent {
|
|
351
|
-
/** The fee payer's public key (base58) */
|
|
352
|
-
feePayer: string;
|
|
353
|
-
/** The nonce source (blockhash or durable nonce) */
|
|
354
|
-
nonce: NonceSource;
|
|
355
|
-
/** List of instructions to include */
|
|
356
|
-
instructions: Instruction[];
|
|
357
|
-
/**
|
|
358
|
-
* Address Lookup Tables for versioned transactions.
|
|
359
|
-
* If provided, builds a MessageV0 transaction instead of legacy.
|
|
360
|
-
*/
|
|
361
|
-
addressLookupTables?: AddressLookupTable[];
|
|
362
|
-
/**
|
|
363
|
-
* Static account keys (for versioned transaction round-trip).
|
|
364
|
-
* These are the accounts stored directly in the message.
|
|
365
|
-
*/
|
|
366
|
-
staticAccountKeys?: string[];
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Build a Solana transaction from a high-level intent.
|
|
370
|
-
*
|
|
371
|
-
* This function takes a declarative TransactionIntent and produces a Transaction
|
|
372
|
-
* object that can be inspected, signed, and serialized.
|
|
373
|
-
*
|
|
374
|
-
* The returned transaction is unsigned - signatures should be added via
|
|
375
|
-
* `addSignature()` before serializing with `toBytes()` and broadcasting.
|
|
376
|
-
*
|
|
377
|
-
* @param intent - The transaction intent describing what to build
|
|
378
|
-
* @returns A Transaction object that can be inspected, signed, and serialized
|
|
379
|
-
* @throws Error if the intent cannot be built (e.g., invalid addresses)
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* import { buildTransaction } from '@bitgo/wasm-solana';
|
|
384
|
-
*
|
|
385
|
-
* // Build a simple SOL transfer
|
|
386
|
-
* const tx = buildTransaction({
|
|
387
|
-
* feePayer: sender,
|
|
388
|
-
* nonce: { type: 'blockhash', value: blockhash },
|
|
389
|
-
* instructions: [
|
|
390
|
-
* { type: 'transfer', from: sender, to: recipient, lamports: 1000000n }
|
|
391
|
-
* ]
|
|
392
|
-
* });
|
|
393
|
-
*
|
|
394
|
-
* // Inspect the transaction
|
|
395
|
-
* console.log(tx.feePayer);
|
|
396
|
-
* console.log(tx.recentBlockhash);
|
|
397
|
-
*
|
|
398
|
-
* // Get the signable payload for signing
|
|
399
|
-
* const payload = tx.signablePayload();
|
|
400
|
-
*
|
|
401
|
-
* // Add signature and serialize
|
|
402
|
-
* tx.addSignature(signerPubkey, signature);
|
|
403
|
-
* const txBytes = tx.toBytes();
|
|
404
|
-
* ```
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* ```typescript
|
|
408
|
-
* // Build with durable nonce and priority fee
|
|
409
|
-
* const tx = buildTransaction({
|
|
410
|
-
* feePayer: sender,
|
|
411
|
-
* nonce: { type: 'durable', address: nonceAccount, authority: sender, value: nonceValue },
|
|
412
|
-
* instructions: [
|
|
413
|
-
* { type: 'computeBudget', unitLimit: 200000, unitPrice: 5000 },
|
|
414
|
-
* { type: 'transfer', from: sender, to: recipient, lamports: 1000000n },
|
|
415
|
-
* { type: 'memo', message: 'BitGo transfer' }
|
|
416
|
-
* ]
|
|
417
|
-
* });
|
|
418
|
-
* ```
|
|
419
|
-
*/
|
|
420
|
-
export declare function buildTransaction(intent: TransactionIntent): Transaction;
|
|
421
27
|
/**
|
|
422
28
|
* A pre-compiled versioned instruction (uses indexes, not pubkeys).
|
|
423
29
|
* This is the format used in MessageV0 transactions.
|
package/dist/cjs/js/builder.js
CHANGED
|
@@ -1,75 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Transaction
|
|
3
|
+
* Versioned Transaction Building from Raw MessageV0 Data.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* This module provides `buildFromVersionedData` for building versioned transactions
|
|
6
|
+
* from pre-compiled MessageV0 data. This is used for:
|
|
7
|
+
* - WalletConnect/Jupiter pre-compiled versioned transactions
|
|
8
|
+
* - Custom transaction pass-through (customTx intent)
|
|
9
|
+
*
|
|
10
|
+
* Unlike the intent-based builder, this takes already-compiled instruction
|
|
11
|
+
* data with account indexes, not high-level instructions.
|
|
7
12
|
*/
|
|
8
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.buildTransaction = buildTransaction;
|
|
10
14
|
exports.buildFromVersionedData = buildFromVersionedData;
|
|
11
15
|
const wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
12
|
-
const transaction_js_1 = require("./transaction.js");
|
|
13
16
|
const versioned_js_1 = require("./versioned.js");
|
|
14
17
|
// =============================================================================
|
|
15
|
-
//
|
|
18
|
+
// buildFromVersionedData function
|
|
16
19
|
// =============================================================================
|
|
17
|
-
/**
|
|
18
|
-
* Build a Solana transaction from a high-level intent.
|
|
19
|
-
*
|
|
20
|
-
* This function takes a declarative TransactionIntent and produces a Transaction
|
|
21
|
-
* object that can be inspected, signed, and serialized.
|
|
22
|
-
*
|
|
23
|
-
* The returned transaction is unsigned - signatures should be added via
|
|
24
|
-
* `addSignature()` before serializing with `toBytes()` and broadcasting.
|
|
25
|
-
*
|
|
26
|
-
* @param intent - The transaction intent describing what to build
|
|
27
|
-
* @returns A Transaction object that can be inspected, signed, and serialized
|
|
28
|
-
* @throws Error if the intent cannot be built (e.g., invalid addresses)
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { buildTransaction } from '@bitgo/wasm-solana';
|
|
33
|
-
*
|
|
34
|
-
* // Build a simple SOL transfer
|
|
35
|
-
* const tx = buildTransaction({
|
|
36
|
-
* feePayer: sender,
|
|
37
|
-
* nonce: { type: 'blockhash', value: blockhash },
|
|
38
|
-
* instructions: [
|
|
39
|
-
* { type: 'transfer', from: sender, to: recipient, lamports: 1000000n }
|
|
40
|
-
* ]
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* // Inspect the transaction
|
|
44
|
-
* console.log(tx.feePayer);
|
|
45
|
-
* console.log(tx.recentBlockhash);
|
|
46
|
-
*
|
|
47
|
-
* // Get the signable payload for signing
|
|
48
|
-
* const payload = tx.signablePayload();
|
|
49
|
-
*
|
|
50
|
-
* // Add signature and serialize
|
|
51
|
-
* tx.addSignature(signerPubkey, signature);
|
|
52
|
-
* const txBytes = tx.toBytes();
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* // Build with durable nonce and priority fee
|
|
58
|
-
* const tx = buildTransaction({
|
|
59
|
-
* feePayer: sender,
|
|
60
|
-
* nonce: { type: 'durable', address: nonceAccount, authority: sender, value: nonceValue },
|
|
61
|
-
* instructions: [
|
|
62
|
-
* { type: 'computeBudget', unitLimit: 200000, unitPrice: 5000 },
|
|
63
|
-
* { type: 'transfer', from: sender, to: recipient, lamports: 1000000n },
|
|
64
|
-
* { type: 'memo', message: 'BitGo transfer' }
|
|
65
|
-
* ]
|
|
66
|
-
* });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
function buildTransaction(intent) {
|
|
70
|
-
const wasm = wasm_solana_js_1.BuilderNamespace.build_transaction(intent);
|
|
71
|
-
return transaction_js_1.Transaction.fromWasm(wasm);
|
|
72
|
-
}
|
|
73
20
|
/**
|
|
74
21
|
* Build a versioned transaction directly from raw MessageV0 data.
|
|
75
22
|
*
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export { Transaction } from "./transaction.js";
|
|
|
9
9
|
export { VersionedTransaction, isVersionedTransaction } from "./versioned.js";
|
|
10
10
|
export type { AddressLookupTableData } from "./versioned.js";
|
|
11
11
|
export { parseTransaction } from "./parser.js";
|
|
12
|
-
export {
|
|
13
|
-
export { buildFromIntent } from "./intentBuilder.js";
|
|
12
|
+
export { buildFromVersionedData } from "./builder.js";
|
|
13
|
+
export { buildFromIntent, buildFromIntent as buildTransactionFromIntent } from "./intentBuilder.js";
|
|
14
14
|
export type { BaseIntent, PaymentIntent, StakeIntent, UnstakeIntent, ClaimIntent, DeactivateIntent, DelegateIntent, EnableTokenIntent, CloseAtaIntent, ConsolidateIntent, SolanaIntent, StakePoolConfig, BuildFromIntentParams, BuildFromIntentResult, GeneratedKeypair, NonceSource, BlockhashNonce, DurableNonce, } from "./intentBuilder.js";
|
|
15
15
|
export { system_program_id as systemProgramId, stake_program_id as stakeProgramId, compute_budget_program_id as computeBudgetProgramId, memo_program_id as memoProgramId, token_program_id as tokenProgramId, token_2022_program_id as token2022ProgramId, ata_program_id as ataProgramId, stake_pool_program_id as stakePoolProgramId, stake_account_space as stakeAccountSpace, nonce_account_space as nonceAccountSpace, sysvar_recent_blockhashes as sysvarRecentBlockhashes, get_associated_token_address as getAssociatedTokenAddress, find_withdraw_authority_program_address as findWithdrawAuthorityProgramAddress, } from "./wasm/wasm_solana.js";
|
|
16
16
|
export type { AccountMeta, Instruction } from "./transaction.js";
|
|
17
17
|
export type { TransactionInput, ParsedTransaction, DurableNonce as ParsedDurableNonce, InstructionParams, TransferParams, CreateAccountParams, NonceAdvanceParams, CreateNonceAccountParams, NonceInitializeParams, StakeInitializeParams, StakingActivateParams, StakingDeactivateParams, StakingWithdrawParams, StakingDelegateParams, StakingAuthorizeParams, SetComputeUnitLimitParams, SetPriorityFeeParams, TokenTransferParams, CreateAtaParams, CloseAtaParams, MemoParams, StakePoolDepositSolParams, StakePoolWithdrawStakeParams, UnknownInstructionParams, } from "./parser.js";
|
|
18
|
-
export type {
|
|
18
|
+
export type { AddressLookupTable as BuilderAddressLookupTable, RawVersionedTransactionData, VersionedInstruction as BuilderVersionedInstruction, MessageHeader, } from "./builder.js";
|
package/dist/cjs/js/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.findWithdrawAuthorityProgramAddress = exports.getAssociatedTokenAddress = exports.sysvarRecentBlockhashes = exports.nonceAccountSpace = exports.stakeAccountSpace = exports.stakePoolProgramId = exports.ataProgramId = exports.token2022ProgramId = exports.tokenProgramId = exports.memoProgramId = exports.computeBudgetProgramId = exports.stakeProgramId = exports.systemProgramId = exports.
|
|
36
|
+
exports.findWithdrawAuthorityProgramAddress = exports.getAssociatedTokenAddress = exports.sysvarRecentBlockhashes = exports.nonceAccountSpace = exports.stakeAccountSpace = exports.stakePoolProgramId = exports.ataProgramId = exports.token2022ProgramId = exports.tokenProgramId = exports.memoProgramId = exports.computeBudgetProgramId = exports.stakeProgramId = exports.systemProgramId = exports.buildTransactionFromIntent = exports.buildFromIntent = exports.buildFromVersionedData = exports.parseTransaction = exports.isVersionedTransaction = exports.VersionedTransaction = exports.Transaction = exports.Pubkey = exports.Keypair = exports.builder = exports.parser = exports.transaction = exports.pubkey = exports.keypair = void 0;
|
|
37
37
|
const wasm = __importStar(require("./wasm/wasm_solana.js"));
|
|
38
38
|
// Force webpack to include the WASM module
|
|
39
39
|
void wasm;
|
|
@@ -58,10 +58,10 @@ Object.defineProperty(exports, "isVersionedTransaction", { enumerable: true, get
|
|
|
58
58
|
var parser_js_1 = require("./parser.js");
|
|
59
59
|
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return parser_js_1.parseTransaction; } });
|
|
60
60
|
var builder_js_1 = require("./builder.js");
|
|
61
|
-
Object.defineProperty(exports, "buildTransaction", { enumerable: true, get: function () { return builder_js_1.buildTransaction; } });
|
|
62
61
|
Object.defineProperty(exports, "buildFromVersionedData", { enumerable: true, get: function () { return builder_js_1.buildFromVersionedData; } });
|
|
63
62
|
var intentBuilder_js_1 = require("./intentBuilder.js");
|
|
64
63
|
Object.defineProperty(exports, "buildFromIntent", { enumerable: true, get: function () { return intentBuilder_js_1.buildFromIntent; } });
|
|
64
|
+
Object.defineProperty(exports, "buildTransactionFromIntent", { enumerable: true, get: function () { return intentBuilder_js_1.buildFromIntent; } });
|
|
65
65
|
// Program ID constants (from WASM)
|
|
66
66
|
var wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
67
67
|
Object.defineProperty(exports, "systemProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.system_program_id; } });
|
|
@@ -72,7 +72,7 @@ export declare class Transaction {
|
|
|
72
72
|
* Get the transaction ID (first signature as base58).
|
|
73
73
|
*
|
|
74
74
|
* For Solana, the transaction ID is the first signature.
|
|
75
|
-
* Returns
|
|
75
|
+
* Returns `undefined` if the transaction is unsigned (no signatures or all-zeros signature).
|
|
76
76
|
*
|
|
77
77
|
* @example
|
|
78
78
|
* ```typescript
|
|
@@ -81,7 +81,7 @@ export declare class Transaction {
|
|
|
81
81
|
* console.log(tx.id); // Base58 encoded signature
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
get id(): string;
|
|
84
|
+
get id(): string | undefined;
|
|
85
85
|
/**
|
|
86
86
|
* Get the signable message payload (what gets signed)
|
|
87
87
|
* This is the serialized message that signers sign
|
|
@@ -91,10 +91,9 @@ export declare class Transaction {
|
|
|
91
91
|
/**
|
|
92
92
|
* Serialize the message portion of the transaction.
|
|
93
93
|
* Alias for signablePayload() - provides compatibility with @solana/web3.js API.
|
|
94
|
-
*
|
|
95
|
-
* @returns The serialized message bytes as a Buffer
|
|
94
|
+
* @returns The serialized message bytes
|
|
96
95
|
*/
|
|
97
|
-
serializeMessage():
|
|
96
|
+
serializeMessage(): Uint8Array;
|
|
98
97
|
/**
|
|
99
98
|
* Serialize the transaction to bytes
|
|
100
99
|
* @returns The serialized transaction bytes
|
|
@@ -66,7 +66,7 @@ class Transaction {
|
|
|
66
66
|
* Get the transaction ID (first signature as base58).
|
|
67
67
|
*
|
|
68
68
|
* For Solana, the transaction ID is the first signature.
|
|
69
|
-
* Returns
|
|
69
|
+
* Returns `undefined` if the transaction is unsigned (no signatures or all-zeros signature).
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
@@ -89,11 +89,10 @@ class Transaction {
|
|
|
89
89
|
/**
|
|
90
90
|
* Serialize the message portion of the transaction.
|
|
91
91
|
* Alias for signablePayload() - provides compatibility with @solana/web3.js API.
|
|
92
|
-
*
|
|
93
|
-
* @returns The serialized message bytes as a Buffer
|
|
92
|
+
* @returns The serialized message bytes
|
|
94
93
|
*/
|
|
95
94
|
serializeMessage() {
|
|
96
|
-
return
|
|
95
|
+
return this.signablePayload();
|
|
97
96
|
}
|
|
98
97
|
/**
|
|
99
98
|
* Serialize the transaction to bytes
|
|
@@ -63,10 +63,6 @@ export declare class VersionedTransaction {
|
|
|
63
63
|
* Automatically handles both legacy and versioned formats.
|
|
64
64
|
*/
|
|
65
65
|
static fromBytes(bytes: Uint8Array): VersionedTransaction;
|
|
66
|
-
/**
|
|
67
|
-
* Deserialize a transaction from base64 string.
|
|
68
|
-
*/
|
|
69
|
-
static fromBase64(base64: string): VersionedTransaction;
|
|
70
66
|
/**
|
|
71
67
|
* Create a VersionedTransaction from a WasmVersionedTransaction instance.
|
|
72
68
|
* @internal Used by builder functions
|
|
@@ -126,9 +122,9 @@ export declare class VersionedTransaction {
|
|
|
126
122
|
* Get the transaction ID (first signature as base58).
|
|
127
123
|
*
|
|
128
124
|
* For Solana, the transaction ID is the first signature.
|
|
129
|
-
* Returns
|
|
125
|
+
* Returns `undefined` if the transaction is unsigned (no signatures or all-zeros signature).
|
|
130
126
|
*/
|
|
131
|
-
get id(): string;
|
|
127
|
+
get id(): string | undefined;
|
|
132
128
|
/**
|
|
133
129
|
* Get the signable message payload.
|
|
134
130
|
*/
|
|
@@ -136,18 +132,13 @@ export declare class VersionedTransaction {
|
|
|
136
132
|
/**
|
|
137
133
|
* Serialize the message portion of the transaction.
|
|
138
134
|
* Alias for signablePayload() - provides compatibility with @solana/web3.js API.
|
|
139
|
-
*
|
|
140
|
-
* @returns The serialized message bytes as a Buffer
|
|
135
|
+
* @returns The serialized message bytes
|
|
141
136
|
*/
|
|
142
|
-
serializeMessage():
|
|
137
|
+
serializeMessage(): Uint8Array;
|
|
143
138
|
/**
|
|
144
139
|
* Serialize the transaction to bytes.
|
|
145
140
|
*/
|
|
146
141
|
toBytes(): Uint8Array;
|
|
147
|
-
/**
|
|
148
|
-
* Serialize the transaction to base64.
|
|
149
|
-
*/
|
|
150
|
-
toBase64(): string;
|
|
151
142
|
/**
|
|
152
143
|
* Serialize to network broadcast format.
|
|
153
144
|
* @returns The transaction as bytes ready for broadcast
|