Skip to content

Commit d23d541

Browse files
committed
fix(wasm-solana): return token program for CreateATA programId
Fix the parser to return the token program (from account index 5) instead of the ATA program for CreateAssociatedTokenAccount instructions. BitGoJS uses programId to indicate which token program owns the ATA (Token Program or Token-2022), not the program executing the instruction. Ticket: BTC-2955
1 parent 4d3ab6a commit d23d541

File tree

12 files changed

+253
-238
lines changed

12 files changed

+253
-238
lines changed
2.03 KB
Binary file not shown.

packages/wasm-solana/js/builder.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export interface TransferInstruction {
4343
from: string;
4444
/** Destination account (base58) */
4545
to: string;
46-
/** Amount in lamports (as string for BigInt compatibility) */
47-
lamports: string;
46+
/** Amount in lamports */
47+
lamports: bigint;
4848
}
4949

5050
/** Create new account instruction */
@@ -54,8 +54,8 @@ export interface CreateAccountInstruction {
5454
from: string;
5555
/** New account address (base58) */
5656
newAccount: string;
57-
/** Lamports to transfer (as string) */
58-
lamports: string;
57+
/** Lamports to transfer */
58+
lamports: bigint;
5959
/** Space to allocate in bytes */
6060
space: number;
6161
/** Owner program (base58) */
@@ -156,8 +156,8 @@ export interface StakeWithdrawInstruction {
156156
stake: string;
157157
/** Recipient address (base58) */
158158
recipient: string;
159-
/** Amount in lamports to withdraw (as string) */
160-
lamports: string;
159+
/** Amount in lamports to withdraw */
160+
lamports: bigint;
161161
/** Withdraw authority (base58) */
162162
authority: string;
163163
}
@@ -184,8 +184,8 @@ export interface StakeSplitInstruction {
184184
splitStake: string;
185185
/** Stake authority (base58) */
186186
authority: string;
187-
/** Amount in lamports to split (as string) */
188-
lamports: string;
187+
/** Amount in lamports to split */
188+
lamports: bigint;
189189
}
190190

191191
// =============================================================================
@@ -201,8 +201,8 @@ export interface TokenTransferInstruction {
201201
destination: string;
202202
/** Token mint address (base58) */
203203
mint: string;
204-
/** Amount of tokens (as string, in smallest units) */
205-
amount: string;
204+
/** Amount of tokens (in smallest units) */
205+
amount: bigint;
206206
/** Number of decimals for the token */
207207
decimals: number;
208208
/** Owner/authority of the source account (base58) */
@@ -246,8 +246,8 @@ export interface MintToInstruction {
246246
destination: string;
247247
/** Mint authority (base58) */
248248
authority: string;
249-
/** Amount of tokens to mint (as string, in smallest units) */
250-
amount: string;
249+
/** Amount of tokens to mint (in smallest units) */
250+
amount: bigint;
251251
/** Token program ID (optional, defaults to SPL Token) */
252252
programId?: string;
253253
}
@@ -261,8 +261,8 @@ export interface BurnInstruction {
261261
account: string;
262262
/** Token account authority (base58) */
263263
authority: string;
264-
/** Amount of tokens to burn (as string, in smallest units) */
265-
amount: string;
264+
/** Amount of tokens to burn (in smallest units) */
265+
amount: bigint;
266266
/** Token program ID (optional, defaults to SPL Token) */
267267
programId?: string;
268268
}
@@ -276,8 +276,8 @@ export interface ApproveInstruction {
276276
delegate: string;
277277
/** Token account owner (base58) */
278278
owner: string;
279-
/** Amount of tokens to approve (as string, in smallest units) */
280-
amount: string;
279+
/** Amount of tokens to approve (in smallest units) */
280+
amount: bigint;
281281
/** Token program ID (optional, defaults to SPL Token) */
282282
programId?: string;
283283
}
@@ -305,8 +305,8 @@ export interface StakePoolDepositSolInstruction {
305305
referralPoolAccount: string;
306306
/** Pool mint address (base58) */
307307
poolMint: string;
308-
/** Amount in lamports to deposit (as string) */
309-
lamports: string;
308+
/** Amount in lamports to deposit */
309+
lamports: bigint;
310310
}
311311

312312
/** Withdraw stake from a stake pool (Jito liquid staking) */
@@ -332,8 +332,8 @@ export interface StakePoolWithdrawStakeInstruction {
332332
managerFeeAccount: string;
333333
/** Pool mint address (base58) */
334334
poolMint: string;
335-
/** Amount of pool tokens to burn (as string) */
336-
poolTokens: string;
335+
/** Amount of pool tokens to burn */
336+
poolTokens: bigint;
337337
}
338338

339339
/** Union of all instruction types */

packages/wasm-solana/js/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ export { Transaction } from "./transaction.js";
1919
export { parseTransaction } from "./parser.js";
2020
export { buildTransaction } from "./builder.js";
2121

22+
// Program ID constants (from WASM)
23+
export {
24+
system_program_id as systemProgramId,
25+
stake_program_id as stakeProgramId,
26+
compute_budget_program_id as computeBudgetProgramId,
27+
memo_program_id as memoProgramId,
28+
token_program_id as tokenProgramId,
29+
token_2022_program_id as token2022ProgramId,
30+
ata_program_id as ataProgramId,
31+
stake_pool_program_id as stakePoolProgramId,
32+
stake_account_space as stakeAccountSpace,
33+
nonce_account_space as nonceAccountSpace,
34+
} from "./wasm/wasm_solana.js";
35+
2236
// Type exports
2337
export type { AccountMeta, Instruction } from "./transaction.js";
2438
export type {

0 commit comments

Comments
 (0)