@bitgo/wasm-solana 1.4.2 → 1.6.0
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/index.d.ts +4 -2
- package/dist/cjs/js/index.js +3 -1
- package/dist/cjs/js/intentBuilder.d.ts +197 -0
- package/dist/cjs/js/intentBuilder.js +70 -0
- package/dist/cjs/js/keypair.d.ts +5 -0
- package/dist/cjs/js/keypair.js +8 -0
- package/dist/cjs/js/transaction.d.ts +19 -0
- package/dist/cjs/js/transaction.js +23 -0
- package/dist/cjs/js/versioned.d.ts +12 -0
- package/dist/cjs/js/versioned.js +16 -0
- package/dist/cjs/js/wasm/wasm_solana.d.ts +60 -0
- package/dist/cjs/js/wasm/wasm_solana.js +176 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm.d.ts +28 -23
- package/dist/esm/js/index.d.ts +4 -2
- package/dist/esm/js/index.js +1 -0
- package/dist/esm/js/intentBuilder.d.ts +197 -0
- package/dist/esm/js/intentBuilder.js +67 -0
- package/dist/esm/js/keypair.d.ts +5 -0
- package/dist/esm/js/keypair.js +8 -0
- package/dist/esm/js/transaction.d.ts +19 -0
- package/dist/esm/js/transaction.js +23 -0
- package/dist/esm/js/versioned.d.ts +12 -0
- package/dist/esm/js/versioned.js +16 -0
- package/dist/esm/js/wasm/wasm_solana.d.ts +60 -0
- package/dist/esm/js/wasm/wasm_solana_bg.js +175 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm.d.ts +28 -23
- package/package.json +1 -1
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export { VersionedTransaction, isVersionedTransaction } from "./versioned.js";
|
|
|
10
10
|
export type { AddressLookupTableData } from "./versioned.js";
|
|
11
11
|
export { parseTransaction } from "./parser.js";
|
|
12
12
|
export { buildTransaction, buildFromVersionedData } from "./builder.js";
|
|
13
|
+
export { buildFromIntent } from "./intentBuilder.js";
|
|
14
|
+
export type { BaseIntent, PaymentIntent, StakeIntent, UnstakeIntent, ClaimIntent, DeactivateIntent, DelegateIntent, EnableTokenIntent, CloseAtaIntent, ConsolidateIntent, SolanaIntent, StakePoolConfig, BuildFromIntentParams, BuildFromIntentResult, GeneratedKeypair, NonceSource, BlockhashNonce, DurableNonce, } from "./intentBuilder.js";
|
|
13
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";
|
|
14
16
|
export type { AccountMeta, Instruction } from "./transaction.js";
|
|
15
|
-
export type { TransactionInput, ParsedTransaction, DurableNonce, InstructionParams, TransferParams, CreateAccountParams, NonceAdvanceParams, CreateNonceAccountParams, NonceInitializeParams, StakeInitializeParams, StakingActivateParams, StakingDeactivateParams, StakingWithdrawParams, StakingDelegateParams, StakingAuthorizeParams, SetComputeUnitLimitParams, SetPriorityFeeParams, TokenTransferParams, CreateAtaParams, CloseAtaParams, MemoParams, StakePoolDepositSolParams, StakePoolWithdrawStakeParams, UnknownInstructionParams, } from "./parser.js";
|
|
16
|
-
export type { TransactionIntent, NonceSource, BlockhashNonceSource, DurableNonceSource, AddressLookupTable as BuilderAddressLookupTable, Instruction as BuilderInstruction, TransferInstruction, CreateAccountInstruction, NonceAdvanceInstruction, NonceInitializeInstruction, AllocateInstruction, AssignInstruction, MemoInstruction, ComputeBudgetInstruction, StakeInitializeInstruction, StakeDelegateInstruction, StakeDeactivateInstruction, StakeWithdrawInstruction, StakeAuthorizeInstruction, StakeSplitInstruction, TokenTransferInstruction, CreateAssociatedTokenAccountInstruction, CloseAssociatedTokenAccountInstruction, MintToInstruction, BurnInstruction, ApproveInstruction, StakePoolDepositSolInstruction, StakePoolWithdrawStakeInstruction, CustomInstruction as BuilderCustomInstruction, CustomAccountMeta, RawVersionedTransactionData, VersionedInstruction as BuilderVersionedInstruction, MessageHeader, } from "./builder.js";
|
|
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 { TransactionIntent, NonceSource as BuilderNonceSource, BlockhashNonceSource, DurableNonceSource, AddressLookupTable as BuilderAddressLookupTable, Instruction as BuilderInstruction, TransferInstruction, CreateAccountInstruction, NonceAdvanceInstruction, NonceInitializeInstruction, AllocateInstruction, AssignInstruction, MemoInstruction, ComputeBudgetInstruction, StakeInitializeInstruction, StakeDelegateInstruction, StakeDeactivateInstruction, StakeWithdrawInstruction, StakeAuthorizeInstruction, StakeSplitInstruction, TokenTransferInstruction, CreateAssociatedTokenAccountInstruction, CloseAssociatedTokenAccountInstruction, MintToInstruction, BurnInstruction, ApproveInstruction, StakePoolDepositSolInstruction, StakePoolWithdrawStakeInstruction, CustomInstruction as BuilderCustomInstruction, CustomAccountMeta, 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.buildFromVersionedData = exports.buildTransaction = exports.parseTransaction = exports.isVersionedTransaction = exports.VersionedTransaction = exports.Transaction = exports.Pubkey = exports.Keypair = exports.builder = exports.parser = exports.transaction = exports.pubkey = exports.keypair = void 0;
|
|
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.buildFromIntent = exports.buildFromVersionedData = exports.buildTransaction = 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;
|
|
@@ -60,6 +60,8 @@ Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: func
|
|
|
60
60
|
var builder_js_1 = require("./builder.js");
|
|
61
61
|
Object.defineProperty(exports, "buildTransaction", { enumerable: true, get: function () { return builder_js_1.buildTransaction; } });
|
|
62
62
|
Object.defineProperty(exports, "buildFromVersionedData", { enumerable: true, get: function () { return builder_js_1.buildFromVersionedData; } });
|
|
63
|
+
var intentBuilder_js_1 = require("./intentBuilder.js");
|
|
64
|
+
Object.defineProperty(exports, "buildFromIntent", { enumerable: true, get: function () { return intentBuilder_js_1.buildFromIntent; } });
|
|
63
65
|
// Program ID constants (from WASM)
|
|
64
66
|
var wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
65
67
|
Object.defineProperty(exports, "systemProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.system_program_id; } });
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level intent-based transaction building.
|
|
3
|
+
*
|
|
4
|
+
* This module provides `buildFromIntent()` which accepts BitGo intent objects
|
|
5
|
+
* directly and builds Solana transactions without requiring the caller to
|
|
6
|
+
* construct low-level instructions.
|
|
7
|
+
*
|
|
8
|
+
* The intent → transaction mapping happens entirely in Rust/WASM for simplicity.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { buildFromIntent } from '@bitgo/wasm-solana';
|
|
13
|
+
*
|
|
14
|
+
* const result = buildFromIntent(intent, {
|
|
15
|
+
* feePayer: walletRootAddress,
|
|
16
|
+
* nonce: { type: 'blockhash', value: recentBlockhash },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // result.transaction - Transaction object
|
|
20
|
+
* // result.generatedKeypairs - any keypairs generated (e.g., stake accounts)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { Transaction } from "./transaction.js";
|
|
24
|
+
/** Nonce source - blockhash or durable nonce */
|
|
25
|
+
export type NonceSource = BlockhashNonce | DurableNonce;
|
|
26
|
+
export interface BlockhashNonce {
|
|
27
|
+
type: "blockhash";
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export interface DurableNonce {
|
|
31
|
+
type: "durable";
|
|
32
|
+
address: string;
|
|
33
|
+
authority: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
/** Parameters for building a transaction from intent */
|
|
37
|
+
export interface BuildFromIntentParams {
|
|
38
|
+
/** Fee payer address (wallet root) */
|
|
39
|
+
feePayer: string;
|
|
40
|
+
/** Nonce source - blockhash or durable nonce */
|
|
41
|
+
nonce: NonceSource;
|
|
42
|
+
}
|
|
43
|
+
/** A keypair generated during transaction building */
|
|
44
|
+
export interface GeneratedKeypair {
|
|
45
|
+
/** Purpose of this keypair */
|
|
46
|
+
purpose: "stakeAccount" | "unstakeAccount" | "transferAuthority";
|
|
47
|
+
/** Public address (base58) */
|
|
48
|
+
address: string;
|
|
49
|
+
/** Secret key (base58) */
|
|
50
|
+
secretKey: string;
|
|
51
|
+
}
|
|
52
|
+
/** Result from building a transaction from intent */
|
|
53
|
+
export interface BuildFromIntentResult {
|
|
54
|
+
/** The built transaction */
|
|
55
|
+
transaction: Transaction;
|
|
56
|
+
/** Generated keypairs (for stake accounts, etc.) */
|
|
57
|
+
generatedKeypairs: GeneratedKeypair[];
|
|
58
|
+
}
|
|
59
|
+
/** Base intent - all intents have intentType */
|
|
60
|
+
export interface BaseIntent {
|
|
61
|
+
intentType: string;
|
|
62
|
+
memo?: string;
|
|
63
|
+
}
|
|
64
|
+
/** Payment intent */
|
|
65
|
+
export interface PaymentIntent extends BaseIntent {
|
|
66
|
+
intentType: "payment";
|
|
67
|
+
recipients?: Array<{
|
|
68
|
+
address?: {
|
|
69
|
+
address: string;
|
|
70
|
+
};
|
|
71
|
+
amount?: {
|
|
72
|
+
value: bigint;
|
|
73
|
+
symbol?: string;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/** Stake intent */
|
|
78
|
+
export interface StakeIntent extends BaseIntent {
|
|
79
|
+
intentType: "stake";
|
|
80
|
+
validatorAddress: string;
|
|
81
|
+
amount?: {
|
|
82
|
+
value: bigint;
|
|
83
|
+
};
|
|
84
|
+
stakingType?: "NATIVE" | "JITO" | "MARINADE";
|
|
85
|
+
stakePoolConfig?: StakePoolConfig;
|
|
86
|
+
}
|
|
87
|
+
/** Stake pool configuration (for Jito) */
|
|
88
|
+
export interface StakePoolConfig {
|
|
89
|
+
stakePoolAddress: string;
|
|
90
|
+
withdrawAuthority: string;
|
|
91
|
+
reserveStake: string;
|
|
92
|
+
destinationPoolAccount: string;
|
|
93
|
+
managerFeeAccount: string;
|
|
94
|
+
referralPoolAccount?: string;
|
|
95
|
+
poolMint: string;
|
|
96
|
+
validatorList?: string;
|
|
97
|
+
sourcePoolAccount?: string;
|
|
98
|
+
}
|
|
99
|
+
/** Unstake intent */
|
|
100
|
+
export interface UnstakeIntent extends BaseIntent {
|
|
101
|
+
intentType: "unstake";
|
|
102
|
+
stakingAddress: string;
|
|
103
|
+
validatorAddress?: string;
|
|
104
|
+
amount?: {
|
|
105
|
+
value: bigint;
|
|
106
|
+
};
|
|
107
|
+
remainingStakingAmount?: {
|
|
108
|
+
value: bigint;
|
|
109
|
+
};
|
|
110
|
+
stakingType?: "NATIVE" | "JITO" | "MARINADE";
|
|
111
|
+
stakePoolConfig?: StakePoolConfig;
|
|
112
|
+
}
|
|
113
|
+
/** Claim intent (withdraw from deactivated stake) */
|
|
114
|
+
export interface ClaimIntent extends BaseIntent {
|
|
115
|
+
intentType: "claim";
|
|
116
|
+
stakingAddress: string;
|
|
117
|
+
amount?: {
|
|
118
|
+
value: bigint;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Deactivate intent */
|
|
122
|
+
export interface DeactivateIntent extends BaseIntent {
|
|
123
|
+
intentType: "deactivate";
|
|
124
|
+
stakingAddress?: string;
|
|
125
|
+
stakingAddresses?: string[];
|
|
126
|
+
}
|
|
127
|
+
/** Delegate intent */
|
|
128
|
+
export interface DelegateIntent extends BaseIntent {
|
|
129
|
+
intentType: "delegate";
|
|
130
|
+
validatorAddress: string;
|
|
131
|
+
stakingAddress?: string;
|
|
132
|
+
stakingAddresses?: string[];
|
|
133
|
+
}
|
|
134
|
+
/** Enable token intent (create ATA) */
|
|
135
|
+
export interface EnableTokenIntent extends BaseIntent {
|
|
136
|
+
intentType: "enableToken";
|
|
137
|
+
recipientAddress?: string;
|
|
138
|
+
tokenAddress?: string;
|
|
139
|
+
tokenProgramId?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Close ATA intent */
|
|
142
|
+
export interface CloseAtaIntent extends BaseIntent {
|
|
143
|
+
intentType: "closeAssociatedTokenAccount";
|
|
144
|
+
tokenAccountAddress?: string;
|
|
145
|
+
tokenProgramId?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Consolidate intent - transfer from child address to root */
|
|
148
|
+
export interface ConsolidateIntent extends BaseIntent {
|
|
149
|
+
intentType: "consolidate";
|
|
150
|
+
/** The child address to consolidate from (sender) */
|
|
151
|
+
receiveAddress: string;
|
|
152
|
+
/** Recipients (root address for SOL, ATAs for tokens) */
|
|
153
|
+
recipients?: Array<{
|
|
154
|
+
address?: {
|
|
155
|
+
address: string;
|
|
156
|
+
};
|
|
157
|
+
amount?: {
|
|
158
|
+
value: bigint;
|
|
159
|
+
};
|
|
160
|
+
}>;
|
|
161
|
+
}
|
|
162
|
+
/** Union of all supported intent types */
|
|
163
|
+
export type SolanaIntent = PaymentIntent | StakeIntent | UnstakeIntent | ClaimIntent | DeactivateIntent | DelegateIntent | EnableTokenIntent | CloseAtaIntent | ConsolidateIntent;
|
|
164
|
+
/**
|
|
165
|
+
* Build a Solana transaction from a BitGo intent.
|
|
166
|
+
*
|
|
167
|
+
* This function passes the intent directly to Rust/WASM which handles
|
|
168
|
+
* all the intent-to-transaction mapping internally.
|
|
169
|
+
*
|
|
170
|
+
* @param intent - The BitGo intent (with intentType, etc.)
|
|
171
|
+
* @param params - Build parameters (feePayer, nonce)
|
|
172
|
+
* @returns Transaction object and any generated keypairs
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Payment intent
|
|
177
|
+
* const result = buildFromIntent(
|
|
178
|
+
* {
|
|
179
|
+
* intentType: 'payment',
|
|
180
|
+
* recipients: [{ address: { address: recipient }, amount: { value: 1000000n } }]
|
|
181
|
+
* },
|
|
182
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
183
|
+
* );
|
|
184
|
+
*
|
|
185
|
+
* // Native staking - generates a new stake account keypair
|
|
186
|
+
* const result = buildFromIntent(
|
|
187
|
+
* {
|
|
188
|
+
* intentType: 'stake',
|
|
189
|
+
* validatorAddress: validator,
|
|
190
|
+
* amount: { value: 1000000000n }
|
|
191
|
+
* },
|
|
192
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
193
|
+
* );
|
|
194
|
+
* // result.generatedKeypairs[0] contains the stake account keypair
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function buildFromIntent(intent: BaseIntent, params: BuildFromIntentParams): BuildFromIntentResult;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* High-level intent-based transaction building.
|
|
4
|
+
*
|
|
5
|
+
* This module provides `buildFromIntent()` which accepts BitGo intent objects
|
|
6
|
+
* directly and builds Solana transactions without requiring the caller to
|
|
7
|
+
* construct low-level instructions.
|
|
8
|
+
*
|
|
9
|
+
* The intent → transaction mapping happens entirely in Rust/WASM for simplicity.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { buildFromIntent } from '@bitgo/wasm-solana';
|
|
14
|
+
*
|
|
15
|
+
* const result = buildFromIntent(intent, {
|
|
16
|
+
* feePayer: walletRootAddress,
|
|
17
|
+
* nonce: { type: 'blockhash', value: recentBlockhash },
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // result.transaction - Transaction object
|
|
21
|
+
* // result.generatedKeypairs - any keypairs generated (e.g., stake accounts)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.buildFromIntent = buildFromIntent;
|
|
26
|
+
const wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
27
|
+
const transaction_js_1 = require("./transaction.js");
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// Main Function
|
|
30
|
+
// =============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Build a Solana transaction from a BitGo intent.
|
|
33
|
+
*
|
|
34
|
+
* This function passes the intent directly to Rust/WASM which handles
|
|
35
|
+
* all the intent-to-transaction mapping internally.
|
|
36
|
+
*
|
|
37
|
+
* @param intent - The BitGo intent (with intentType, etc.)
|
|
38
|
+
* @param params - Build parameters (feePayer, nonce)
|
|
39
|
+
* @returns Transaction object and any generated keypairs
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Payment intent
|
|
44
|
+
* const result = buildFromIntent(
|
|
45
|
+
* {
|
|
46
|
+
* intentType: 'payment',
|
|
47
|
+
* recipients: [{ address: { address: recipient }, amount: { value: 1000000n } }]
|
|
48
|
+
* },
|
|
49
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* // Native staking - generates a new stake account keypair
|
|
53
|
+
* const result = buildFromIntent(
|
|
54
|
+
* {
|
|
55
|
+
* intentType: 'stake',
|
|
56
|
+
* validatorAddress: validator,
|
|
57
|
+
* amount: { value: 1000000000n }
|
|
58
|
+
* },
|
|
59
|
+
* { feePayer: walletRoot, nonce: { type: 'blockhash', value: blockhash } }
|
|
60
|
+
* );
|
|
61
|
+
* // result.generatedKeypairs[0] contains the stake account keypair
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function buildFromIntent(intent, params) {
|
|
65
|
+
const result = wasm_solana_js_1.IntentNamespace.build_from_intent(intent, params);
|
|
66
|
+
return {
|
|
67
|
+
transaction: transaction_js_1.Transaction.fromWasm(result.transaction),
|
|
68
|
+
generatedKeypairs: result.generatedKeypairs,
|
|
69
|
+
};
|
|
70
|
+
}
|
package/dist/cjs/js/keypair.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ import { WasmKeypair } from "./wasm/wasm_solana.js";
|
|
|
8
8
|
export declare class Keypair {
|
|
9
9
|
private _wasm;
|
|
10
10
|
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Generate a new random keypair
|
|
13
|
+
* @returns A new Keypair instance with randomly generated keys
|
|
14
|
+
*/
|
|
15
|
+
static generate(): Keypair;
|
|
11
16
|
/**
|
|
12
17
|
* Create a keypair from a 32-byte secret key
|
|
13
18
|
* @param secretKey - The 32-byte Ed25519 secret key
|
package/dist/cjs/js/keypair.js
CHANGED
|
@@ -13,6 +13,14 @@ class Keypair {
|
|
|
13
13
|
constructor(_wasm) {
|
|
14
14
|
this._wasm = _wasm;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Generate a new random keypair
|
|
18
|
+
* @returns A new Keypair instance with randomly generated keys
|
|
19
|
+
*/
|
|
20
|
+
static generate() {
|
|
21
|
+
const wasm = wasm_solana_js_1.WasmKeypair.generate();
|
|
22
|
+
return new Keypair(wasm);
|
|
23
|
+
}
|
|
16
24
|
/**
|
|
17
25
|
* Create a keypair from a 32-byte secret key
|
|
18
26
|
* @param secretKey - The 32-byte Ed25519 secret key
|
|
@@ -68,6 +68,20 @@ export declare class Transaction {
|
|
|
68
68
|
* Get the number of signatures in the transaction
|
|
69
69
|
*/
|
|
70
70
|
get numSignatures(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Get the transaction ID (first signature as base58).
|
|
73
|
+
*
|
|
74
|
+
* For Solana, the transaction ID is the first signature.
|
|
75
|
+
* Returns "UNSIGNED" if the transaction has no valid signatures.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const tx = Transaction.fromBytes(txBytes);
|
|
80
|
+
* tx.addSignature(pubkey, signature);
|
|
81
|
+
* console.log(tx.id); // Base58 encoded signature
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
get id(): string;
|
|
71
85
|
/**
|
|
72
86
|
* Get the signable message payload (what gets signed)
|
|
73
87
|
* This is the serialized message that signers sign
|
|
@@ -86,6 +100,11 @@ export declare class Transaction {
|
|
|
86
100
|
* @returns The serialized transaction bytes
|
|
87
101
|
*/
|
|
88
102
|
toBytes(): Uint8Array;
|
|
103
|
+
/**
|
|
104
|
+
* Serialize to network broadcast format.
|
|
105
|
+
* @returns The transaction as bytes ready for broadcast
|
|
106
|
+
*/
|
|
107
|
+
toBroadcastFormat(): Uint8Array;
|
|
89
108
|
/**
|
|
90
109
|
* Get all account keys as Pubkey instances
|
|
91
110
|
* @returns Array of account public keys
|
|
@@ -62,6 +62,22 @@ class Transaction {
|
|
|
62
62
|
get numSignatures() {
|
|
63
63
|
return this._wasm.num_signatures;
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Get the transaction ID (first signature as base58).
|
|
67
|
+
*
|
|
68
|
+
* For Solana, the transaction ID is the first signature.
|
|
69
|
+
* Returns "UNSIGNED" if the transaction has no valid signatures.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const tx = Transaction.fromBytes(txBytes);
|
|
74
|
+
* tx.addSignature(pubkey, signature);
|
|
75
|
+
* console.log(tx.id); // Base58 encoded signature
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
get id() {
|
|
79
|
+
return this._wasm.id;
|
|
80
|
+
}
|
|
65
81
|
/**
|
|
66
82
|
* Get the signable message payload (what gets signed)
|
|
67
83
|
* This is the serialized message that signers sign
|
|
@@ -86,6 +102,13 @@ class Transaction {
|
|
|
86
102
|
toBytes() {
|
|
87
103
|
return this._wasm.to_bytes();
|
|
88
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Serialize to network broadcast format.
|
|
107
|
+
* @returns The transaction as bytes ready for broadcast
|
|
108
|
+
*/
|
|
109
|
+
toBroadcastFormat() {
|
|
110
|
+
return this.toBytes();
|
|
111
|
+
}
|
|
89
112
|
/**
|
|
90
113
|
* Get all account keys as Pubkey instances
|
|
91
114
|
* @returns Array of account public keys
|
|
@@ -122,6 +122,13 @@ export declare class VersionedTransaction {
|
|
|
122
122
|
* Get the number of signatures.
|
|
123
123
|
*/
|
|
124
124
|
get numSignatures(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Get the transaction ID (first signature as base58).
|
|
127
|
+
*
|
|
128
|
+
* For Solana, the transaction ID is the first signature.
|
|
129
|
+
* Returns "UNSIGNED" if the transaction has no valid signatures.
|
|
130
|
+
*/
|
|
131
|
+
get id(): string;
|
|
125
132
|
/**
|
|
126
133
|
* Get the signable message payload.
|
|
127
134
|
*/
|
|
@@ -141,6 +148,11 @@ export declare class VersionedTransaction {
|
|
|
141
148
|
* Serialize the transaction to base64.
|
|
142
149
|
*/
|
|
143
150
|
toBase64(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Serialize to network broadcast format.
|
|
153
|
+
* @returns The transaction as bytes ready for broadcast
|
|
154
|
+
*/
|
|
155
|
+
toBroadcastFormat(): Uint8Array;
|
|
144
156
|
/**
|
|
145
157
|
* Get static account keys (accounts stored directly in the message).
|
|
146
158
|
* For versioned transactions, additional accounts may be referenced via ALTs.
|
package/dist/cjs/js/versioned.js
CHANGED
|
@@ -115,6 +115,15 @@ class VersionedTransaction {
|
|
|
115
115
|
get numSignatures() {
|
|
116
116
|
return this.inner.num_signatures;
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the transaction ID (first signature as base58).
|
|
120
|
+
*
|
|
121
|
+
* For Solana, the transaction ID is the first signature.
|
|
122
|
+
* Returns "UNSIGNED" if the transaction has no valid signatures.
|
|
123
|
+
*/
|
|
124
|
+
get id() {
|
|
125
|
+
return this.inner.id;
|
|
126
|
+
}
|
|
118
127
|
/**
|
|
119
128
|
* Get the signable message payload.
|
|
120
129
|
*/
|
|
@@ -142,6 +151,13 @@ class VersionedTransaction {
|
|
|
142
151
|
toBase64() {
|
|
143
152
|
return Buffer.from(this.toBytes()).toString("base64");
|
|
144
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Serialize to network broadcast format.
|
|
156
|
+
* @returns The transaction as bytes ready for broadcast
|
|
157
|
+
*/
|
|
158
|
+
toBroadcastFormat() {
|
|
159
|
+
return this.toBytes();
|
|
160
|
+
}
|
|
145
161
|
/**
|
|
146
162
|
* Get static account keys (accounts stored directly in the message).
|
|
147
163
|
* For versioned transactions, additional accounts may be referenced via ALTs.
|
|
@@ -372,6 +372,48 @@ export class Instructions {
|
|
|
372
372
|
push(instruction: Instruction): void;
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
export class IntentNamespace {
|
|
376
|
+
private constructor();
|
|
377
|
+
free(): void;
|
|
378
|
+
[Symbol.dispose](): void;
|
|
379
|
+
/**
|
|
380
|
+
* Build a transaction directly from a BitGo intent.
|
|
381
|
+
*
|
|
382
|
+
* This function takes the full intent as-is and builds the transaction
|
|
383
|
+
* without requiring the caller to construct instructions.
|
|
384
|
+
*
|
|
385
|
+
* # Arguments
|
|
386
|
+
*
|
|
387
|
+
* * `intent` - The full BitGo intent object (with intentType, etc.)
|
|
388
|
+
* * `params` - Build parameters: { feePayer, nonce }
|
|
389
|
+
*
|
|
390
|
+
* # Returns
|
|
391
|
+
*
|
|
392
|
+
* An object with:
|
|
393
|
+
* * `transaction` - WasmTransaction object
|
|
394
|
+
* * `generatedKeypairs` - Array of keypairs generated (for stake accounts, etc.)
|
|
395
|
+
*
|
|
396
|
+
* # Example
|
|
397
|
+
*
|
|
398
|
+
* ```javascript
|
|
399
|
+
* const result = IntentNamespace.build_from_intent(
|
|
400
|
+
* {
|
|
401
|
+
* intentType: 'stake',
|
|
402
|
+
* validatorAddress: '...',
|
|
403
|
+
* amount: { value: 1000000000n }
|
|
404
|
+
* },
|
|
405
|
+
* {
|
|
406
|
+
* feePayer: 'DgT9...',
|
|
407
|
+
* nonce: { type: 'blockhash', value: 'GWaQ...' }
|
|
408
|
+
* }
|
|
409
|
+
* );
|
|
410
|
+
* // result.transaction - WasmTransaction object
|
|
411
|
+
* // result.generatedKeypairs - [{ purpose, address, secretKey }]
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
static build_from_intent(intent: any, params: any): any;
|
|
415
|
+
}
|
|
416
|
+
|
|
375
417
|
export class Keypair {
|
|
376
418
|
free(): void;
|
|
377
419
|
[Symbol.dispose](): void;
|
|
@@ -697,6 +739,10 @@ export class WasmKeypair {
|
|
|
697
739
|
* Get the address as a base58 string.
|
|
698
740
|
*/
|
|
699
741
|
address(): string;
|
|
742
|
+
/**
|
|
743
|
+
* Generate a new random keypair.
|
|
744
|
+
*/
|
|
745
|
+
static generate(): WasmKeypair;
|
|
700
746
|
/**
|
|
701
747
|
* Get the public key as a base58 string.
|
|
702
748
|
*/
|
|
@@ -804,6 +850,13 @@ export class WasmTransaction {
|
|
|
804
850
|
* Get the recent blockhash as a base58 string.
|
|
805
851
|
*/
|
|
806
852
|
readonly recent_blockhash: string;
|
|
853
|
+
/**
|
|
854
|
+
* Get the transaction ID (first signature as base58).
|
|
855
|
+
*
|
|
856
|
+
* For Solana, the transaction ID is the first signature.
|
|
857
|
+
* Returns "UNSIGNED" if the first signature is all zeros (unsigned transaction).
|
|
858
|
+
*/
|
|
859
|
+
readonly id: string;
|
|
807
860
|
/**
|
|
808
861
|
* Get the fee payer address as a base58 string.
|
|
809
862
|
*
|
|
@@ -891,6 +944,13 @@ export class WasmVersionedTransaction {
|
|
|
891
944
|
* Get the recent blockhash as a base58 string.
|
|
892
945
|
*/
|
|
893
946
|
readonly recent_blockhash: string;
|
|
947
|
+
/**
|
|
948
|
+
* Get the transaction ID (first signature as base58).
|
|
949
|
+
*
|
|
950
|
+
* For Solana, the transaction ID is the first signature.
|
|
951
|
+
* Returns "UNSIGNED" if the first signature is all zeros (unsigned transaction).
|
|
952
|
+
*/
|
|
953
|
+
readonly id: string;
|
|
894
954
|
/**
|
|
895
955
|
* Get the fee payer address as a base58 string.
|
|
896
956
|
*/
|