@bitgo/wasm-solana 2.0.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/wasm/wasm_solana.d.ts +6 -64
- package/dist/cjs/js/wasm/wasm_solana.js +7 -81
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm.d.ts +17 -18
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- 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/wasm/wasm_solana.d.ts +6 -64
- package/dist/esm/js/wasm/wasm_solana_bg.js +7 -81
- package/dist/esm/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm.d.ts +17 -18
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
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; } });
|
|
@@ -88,76 +88,18 @@ export class BuilderNamespace {
|
|
|
88
88
|
free(): void;
|
|
89
89
|
[Symbol.dispose](): void;
|
|
90
90
|
/**
|
|
91
|
-
* Build a
|
|
91
|
+
* Build a versioned transaction from raw MessageV0 data.
|
|
92
92
|
*
|
|
93
|
-
*
|
|
93
|
+
* This is used for WalletConnect/Jupiter transactions where we receive
|
|
94
|
+
* pre-compiled versioned transaction data and just need to serialize it.
|
|
94
95
|
*
|
|
95
|
-
* #
|
|
96
|
-
*
|
|
97
|
-
* ```json
|
|
98
|
-
* {
|
|
99
|
-
* "feePayer": "DgT9qyYwYKBRDyDw3EfR12LHQCQjtNrKu2qMsXHuosmB",
|
|
100
|
-
* "nonce": {
|
|
101
|
-
* "type": "blockhash",
|
|
102
|
-
* "value": "GWaQEymC3Z9SHM2gkh8u12xL1zJPMHPCSVR3pSDpEXE4"
|
|
103
|
-
* },
|
|
104
|
-
* "instructions": [
|
|
105
|
-
* { "type": "transfer", "from": "...", "to": "...", "lamports": "1000000" },
|
|
106
|
-
* { "type": "memo", "message": "BitGo tx" }
|
|
107
|
-
* ]
|
|
108
|
-
* }
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* # Instruction Types
|
|
96
|
+
* # Arguments
|
|
112
97
|
*
|
|
113
|
-
*
|
|
114
|
-
* - `createAccount`: Create new account (from, newAccount, lamports, space, owner)
|
|
115
|
-
* - `nonceAdvance`: Advance durable nonce (nonce, authority)
|
|
116
|
-
* - `nonceInitialize`: Initialize nonce account (nonce, authority)
|
|
117
|
-
* - `allocate`: Allocate space (account, space)
|
|
118
|
-
* - `assign`: Assign to program (account, owner)
|
|
119
|
-
* - `memo`: Add memo (message)
|
|
120
|
-
* - `computeBudget`: Set compute units (unitLimit, unitPrice)
|
|
98
|
+
* * `data` - Raw versioned transaction data (from JavaScript)
|
|
121
99
|
*
|
|
122
100
|
* # Returns
|
|
123
101
|
*
|
|
124
|
-
* A
|
|
125
|
-
* The transaction will have empty signature placeholders that can be
|
|
126
|
-
* filled in later by signing via `addSignature()`.
|
|
127
|
-
*
|
|
128
|
-
* @param intent - The transaction intent as a JSON object
|
|
129
|
-
* @returns Transaction object
|
|
130
|
-
*/
|
|
131
|
-
static build_transaction(intent: any): WasmTransaction;
|
|
132
|
-
/**
|
|
133
|
-
* Build a versioned transaction directly from raw MessageV0 data.
|
|
134
|
-
*
|
|
135
|
-
* This function is used for the `fromVersionedTransactionData()` path where we already
|
|
136
|
-
* have pre-compiled versioned data (indexes + ALT refs). No instruction compilation
|
|
137
|
-
* is needed - we just serialize the raw structure to bytes.
|
|
138
|
-
*
|
|
139
|
-
* # Data Structure
|
|
140
|
-
*
|
|
141
|
-
* ```json
|
|
142
|
-
* {
|
|
143
|
-
* "staticAccountKeys": ["pubkey1", "pubkey2", ...],
|
|
144
|
-
* "addressLookupTables": [
|
|
145
|
-
* { "accountKey": "altPubkey", "writableIndexes": [0, 1], "readonlyIndexes": [2] }
|
|
146
|
-
* ],
|
|
147
|
-
* "versionedInstructions": [
|
|
148
|
-
* { "programIdIndex": 0, "accountKeyIndexes": [1, 2], "data": "base58EncodedData" }
|
|
149
|
-
* ],
|
|
150
|
-
* "messageHeader": {
|
|
151
|
-
* "numRequiredSignatures": 1,
|
|
152
|
-
* "numReadonlySignedAccounts": 0,
|
|
153
|
-
* "numReadonlyUnsignedAccounts": 3
|
|
154
|
-
* },
|
|
155
|
-
* "recentBlockhash": "blockhash"
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* @param data - Raw versioned transaction data as a JSON object
|
|
160
|
-
* @returns VersionedTransaction object
|
|
102
|
+
* A WasmVersionedTransaction instance
|
|
161
103
|
*/
|
|
162
104
|
static build_from_versioned_data(data: any): WasmVersionedTransaction;
|
|
163
105
|
}
|