@bitgo/wasm-solana 1.4.0 → 1.4.2
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 +499 -0
- package/dist/cjs/js/builder.js +113 -0
- package/dist/cjs/js/index.d.ts +16 -0
- package/dist/cjs/js/index.js +79 -0
- package/dist/cjs/js/keypair.d.ts +47 -0
- package/dist/cjs/js/keypair.js +69 -0
- package/dist/cjs/js/parser.d.ts +253 -0
- package/dist/cjs/js/parser.js +58 -0
- package/dist/cjs/js/pubkey.d.ts +54 -0
- package/dist/cjs/js/pubkey.js +76 -0
- package/dist/cjs/js/transaction.d.ts +156 -0
- package/dist/cjs/js/transaction.js +176 -0
- package/dist/cjs/js/versioned.d.ts +177 -0
- package/dist/cjs/js/versioned.js +197 -0
- package/dist/cjs/js/wasm/wasm_solana.d.ts +1030 -0
- package/dist/cjs/js/wasm/wasm_solana.js +6216 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_solana_bg.wasm.d.ts +341 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/js/builder.d.ts +499 -0
- package/dist/esm/js/builder.js +109 -0
- package/dist/esm/js/index.d.ts +16 -0
- package/dist/esm/js/index.js +24 -0
- package/dist/esm/js/keypair.d.ts +47 -0
- package/dist/esm/js/keypair.js +65 -0
- package/dist/esm/js/parser.d.ts +253 -0
- package/dist/esm/js/parser.js +55 -0
- package/dist/esm/js/pubkey.d.ts +54 -0
- package/dist/esm/js/pubkey.js +72 -0
- package/dist/esm/js/transaction.d.ts +156 -0
- package/dist/esm/js/transaction.js +172 -0
- package/dist/esm/js/versioned.d.ts +177 -0
- package/dist/esm/js/versioned.js +192 -0
- package/dist/esm/js/wasm/wasm_solana.d.ts +1030 -0
- package/dist/esm/js/wasm/wasm_solana.js +4 -0
- package/dist/esm/js/wasm/wasm_solana_bg.js +6138 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_solana_bg.wasm.d.ts +341 -0
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
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;
|
|
37
|
+
const wasm = __importStar(require("./wasm/wasm_solana.js"));
|
|
38
|
+
// Force webpack to include the WASM module
|
|
39
|
+
void wasm;
|
|
40
|
+
// Namespace exports for explicit imports
|
|
41
|
+
exports.keypair = __importStar(require("./keypair.js"));
|
|
42
|
+
exports.pubkey = __importStar(require("./pubkey.js"));
|
|
43
|
+
exports.transaction = __importStar(require("./transaction.js"));
|
|
44
|
+
exports.parser = __importStar(require("./parser.js"));
|
|
45
|
+
exports.builder = __importStar(require("./builder.js"));
|
|
46
|
+
// Top-level class exports for convenience
|
|
47
|
+
var keypair_js_1 = require("./keypair.js");
|
|
48
|
+
Object.defineProperty(exports, "Keypair", { enumerable: true, get: function () { return keypair_js_1.Keypair; } });
|
|
49
|
+
var pubkey_js_1 = require("./pubkey.js");
|
|
50
|
+
Object.defineProperty(exports, "Pubkey", { enumerable: true, get: function () { return pubkey_js_1.Pubkey; } });
|
|
51
|
+
var transaction_js_1 = require("./transaction.js");
|
|
52
|
+
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return transaction_js_1.Transaction; } });
|
|
53
|
+
// Versioned transaction support
|
|
54
|
+
var versioned_js_1 = require("./versioned.js");
|
|
55
|
+
Object.defineProperty(exports, "VersionedTransaction", { enumerable: true, get: function () { return versioned_js_1.VersionedTransaction; } });
|
|
56
|
+
Object.defineProperty(exports, "isVersionedTransaction", { enumerable: true, get: function () { return versioned_js_1.isVersionedTransaction; } });
|
|
57
|
+
// Top-level function exports
|
|
58
|
+
var parser_js_1 = require("./parser.js");
|
|
59
|
+
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return parser_js_1.parseTransaction; } });
|
|
60
|
+
var builder_js_1 = require("./builder.js");
|
|
61
|
+
Object.defineProperty(exports, "buildTransaction", { enumerable: true, get: function () { return builder_js_1.buildTransaction; } });
|
|
62
|
+
Object.defineProperty(exports, "buildFromVersionedData", { enumerable: true, get: function () { return builder_js_1.buildFromVersionedData; } });
|
|
63
|
+
// Program ID constants (from WASM)
|
|
64
|
+
var wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
65
|
+
Object.defineProperty(exports, "systemProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.system_program_id; } });
|
|
66
|
+
Object.defineProperty(exports, "stakeProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.stake_program_id; } });
|
|
67
|
+
Object.defineProperty(exports, "computeBudgetProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.compute_budget_program_id; } });
|
|
68
|
+
Object.defineProperty(exports, "memoProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.memo_program_id; } });
|
|
69
|
+
Object.defineProperty(exports, "tokenProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.token_program_id; } });
|
|
70
|
+
Object.defineProperty(exports, "token2022ProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.token_2022_program_id; } });
|
|
71
|
+
Object.defineProperty(exports, "ataProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.ata_program_id; } });
|
|
72
|
+
Object.defineProperty(exports, "stakePoolProgramId", { enumerable: true, get: function () { return wasm_solana_js_1.stake_pool_program_id; } });
|
|
73
|
+
Object.defineProperty(exports, "stakeAccountSpace", { enumerable: true, get: function () { return wasm_solana_js_1.stake_account_space; } });
|
|
74
|
+
Object.defineProperty(exports, "nonceAccountSpace", { enumerable: true, get: function () { return wasm_solana_js_1.nonce_account_space; } });
|
|
75
|
+
// Sysvar addresses
|
|
76
|
+
Object.defineProperty(exports, "sysvarRecentBlockhashes", { enumerable: true, get: function () { return wasm_solana_js_1.sysvar_recent_blockhashes; } });
|
|
77
|
+
// PDA derivation functions (eliminates @solana/web3.js dependency)
|
|
78
|
+
Object.defineProperty(exports, "getAssociatedTokenAddress", { enumerable: true, get: function () { return wasm_solana_js_1.get_associated_token_address; } });
|
|
79
|
+
Object.defineProperty(exports, "findWithdrawAuthorityProgramAddress", { enumerable: true, get: function () { return wasm_solana_js_1.find_withdraw_authority_program_address; } });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WasmKeypair } from "./wasm/wasm_solana.js";
|
|
2
|
+
/**
|
|
3
|
+
* Solana Ed25519 Keypair for address generation and signing
|
|
4
|
+
*
|
|
5
|
+
* A keypair consists of a 32-byte secret key and a 32-byte public key.
|
|
6
|
+
* The public key (base58-encoded) is the Solana address.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Keypair {
|
|
9
|
+
private _wasm;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Create a keypair from a 32-byte secret key
|
|
13
|
+
* @param secretKey - The 32-byte Ed25519 secret key
|
|
14
|
+
* @returns A Keypair instance
|
|
15
|
+
*/
|
|
16
|
+
static fromSecretKey(secretKey: Uint8Array): Keypair;
|
|
17
|
+
/**
|
|
18
|
+
* Create a keypair from a 64-byte Solana secret key (secret + public concatenated)
|
|
19
|
+
* This is the format used by @solana/web3.js Keypair.fromSecretKey()
|
|
20
|
+
* @param secretKey - The 64-byte Solana secret key
|
|
21
|
+
* @returns A Keypair instance
|
|
22
|
+
*/
|
|
23
|
+
static fromSolanaSecretKey(secretKey: Uint8Array): Keypair;
|
|
24
|
+
/**
|
|
25
|
+
* Get the public key as a 32-byte Uint8Array
|
|
26
|
+
*/
|
|
27
|
+
get publicKey(): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Get the secret key as a 32-byte Uint8Array
|
|
30
|
+
*/
|
|
31
|
+
get secretKey(): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Get the Solana address (base58-encoded public key)
|
|
34
|
+
* @returns The address as a base58 string
|
|
35
|
+
*/
|
|
36
|
+
getAddress(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the public key as a base58 string
|
|
39
|
+
* @returns The public key as a base58 string
|
|
40
|
+
*/
|
|
41
|
+
toBase58(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the underlying WASM instance (internal use only)
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
get wasm(): WasmKeypair;
|
|
47
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Keypair = void 0;
|
|
4
|
+
const wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
5
|
+
/**
|
|
6
|
+
* Solana Ed25519 Keypair for address generation and signing
|
|
7
|
+
*
|
|
8
|
+
* A keypair consists of a 32-byte secret key and a 32-byte public key.
|
|
9
|
+
* The public key (base58-encoded) is the Solana address.
|
|
10
|
+
*/
|
|
11
|
+
class Keypair {
|
|
12
|
+
_wasm;
|
|
13
|
+
constructor(_wasm) {
|
|
14
|
+
this._wasm = _wasm;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a keypair from a 32-byte secret key
|
|
18
|
+
* @param secretKey - The 32-byte Ed25519 secret key
|
|
19
|
+
* @returns A Keypair instance
|
|
20
|
+
*/
|
|
21
|
+
static fromSecretKey(secretKey) {
|
|
22
|
+
const wasm = wasm_solana_js_1.WasmKeypair.from_secret_key(secretKey);
|
|
23
|
+
return new Keypair(wasm);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a keypair from a 64-byte Solana secret key (secret + public concatenated)
|
|
27
|
+
* This is the format used by @solana/web3.js Keypair.fromSecretKey()
|
|
28
|
+
* @param secretKey - The 64-byte Solana secret key
|
|
29
|
+
* @returns A Keypair instance
|
|
30
|
+
*/
|
|
31
|
+
static fromSolanaSecretKey(secretKey) {
|
|
32
|
+
const wasm = wasm_solana_js_1.WasmKeypair.from_solana_secret_key(secretKey);
|
|
33
|
+
return new Keypair(wasm);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the public key as a 32-byte Uint8Array
|
|
37
|
+
*/
|
|
38
|
+
get publicKey() {
|
|
39
|
+
return this._wasm.public_key;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the secret key as a 32-byte Uint8Array
|
|
43
|
+
*/
|
|
44
|
+
get secretKey() {
|
|
45
|
+
return this._wasm.secret_key;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the Solana address (base58-encoded public key)
|
|
49
|
+
* @returns The address as a base58 string
|
|
50
|
+
*/
|
|
51
|
+
getAddress() {
|
|
52
|
+
return this._wasm.address();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the public key as a base58 string
|
|
56
|
+
* @returns The public key as a base58 string
|
|
57
|
+
*/
|
|
58
|
+
toBase58() {
|
|
59
|
+
return this._wasm.to_base58();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the underlying WASM instance (internal use only)
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
get wasm() {
|
|
66
|
+
return this._wasm;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Keypair = Keypair;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level transaction parsing.
|
|
3
|
+
*
|
|
4
|
+
* Provides types and functions for parsing Solana transactions into semantic data
|
|
5
|
+
* matching BitGoJS's TxData format.
|
|
6
|
+
*
|
|
7
|
+
* All monetary amounts (amount, fee, lamports, poolTokens) are returned as bigint.
|
|
8
|
+
* Accepts both raw bytes and Transaction objects for convenience.
|
|
9
|
+
*/
|
|
10
|
+
import type { Transaction } from "./transaction.js";
|
|
11
|
+
import type { VersionedTransaction } from "./versioned.js";
|
|
12
|
+
/**
|
|
13
|
+
* Input type for parseTransaction - accepts bytes or Transaction objects.
|
|
14
|
+
*/
|
|
15
|
+
export type TransactionInput = Uint8Array | Transaction | VersionedTransaction;
|
|
16
|
+
/** SOL transfer parameters */
|
|
17
|
+
export interface TransferParams {
|
|
18
|
+
type: "Transfer";
|
|
19
|
+
fromAddress: string;
|
|
20
|
+
toAddress: string;
|
|
21
|
+
amount: bigint;
|
|
22
|
+
}
|
|
23
|
+
/** Create account parameters */
|
|
24
|
+
export interface CreateAccountParams {
|
|
25
|
+
type: "CreateAccount";
|
|
26
|
+
fromAddress: string;
|
|
27
|
+
newAddress: string;
|
|
28
|
+
amount: bigint;
|
|
29
|
+
space: number;
|
|
30
|
+
owner: string;
|
|
31
|
+
}
|
|
32
|
+
/** Nonce advance parameters */
|
|
33
|
+
export interface NonceAdvanceParams {
|
|
34
|
+
type: "NonceAdvance";
|
|
35
|
+
walletNonceAddress: string;
|
|
36
|
+
authWalletAddress: string;
|
|
37
|
+
}
|
|
38
|
+
/** Create nonce account parameters (combined type) */
|
|
39
|
+
export interface CreateNonceAccountParams {
|
|
40
|
+
type: "CreateNonceAccount";
|
|
41
|
+
fromAddress: string;
|
|
42
|
+
nonceAddress: string;
|
|
43
|
+
authAddress: string;
|
|
44
|
+
amount: bigint;
|
|
45
|
+
}
|
|
46
|
+
/** Nonce initialize parameters (intermediate - combined into CreateNonceAccount) */
|
|
47
|
+
export interface NonceInitializeParams {
|
|
48
|
+
type: "NonceInitialize";
|
|
49
|
+
nonceAddress: string;
|
|
50
|
+
authAddress: string;
|
|
51
|
+
}
|
|
52
|
+
/** Stake initialize parameters (intermediate - combined into StakingActivate) */
|
|
53
|
+
export interface StakeInitializeParams {
|
|
54
|
+
type: "StakeInitialize";
|
|
55
|
+
stakingAddress: string;
|
|
56
|
+
staker: string;
|
|
57
|
+
withdrawer: string;
|
|
58
|
+
}
|
|
59
|
+
/** Staking activate parameters (combined type) */
|
|
60
|
+
export interface StakingActivateParams {
|
|
61
|
+
type: "StakingActivate";
|
|
62
|
+
fromAddress: string;
|
|
63
|
+
stakingAddress: string;
|
|
64
|
+
amount: bigint;
|
|
65
|
+
validator: string;
|
|
66
|
+
stakingType: "NATIVE" | "JITO" | "MARINADE";
|
|
67
|
+
}
|
|
68
|
+
/** Staking deactivate parameters */
|
|
69
|
+
export interface StakingDeactivateParams {
|
|
70
|
+
type: "StakingDeactivate";
|
|
71
|
+
stakingAddress: string;
|
|
72
|
+
fromAddress: string;
|
|
73
|
+
}
|
|
74
|
+
/** Staking withdraw parameters */
|
|
75
|
+
export interface StakingWithdrawParams {
|
|
76
|
+
type: "StakingWithdraw";
|
|
77
|
+
fromAddress: string;
|
|
78
|
+
stakingAddress: string;
|
|
79
|
+
amount: bigint;
|
|
80
|
+
}
|
|
81
|
+
/** Staking delegate parameters */
|
|
82
|
+
export interface StakingDelegateParams {
|
|
83
|
+
type: "StakingDelegate";
|
|
84
|
+
stakingAddress: string;
|
|
85
|
+
fromAddress: string;
|
|
86
|
+
validator: string;
|
|
87
|
+
}
|
|
88
|
+
/** Staking authorize parameters */
|
|
89
|
+
export interface StakingAuthorizeParams {
|
|
90
|
+
type: "StakingAuthorize";
|
|
91
|
+
stakingAddress: string;
|
|
92
|
+
oldAuthorizeAddress: string;
|
|
93
|
+
newAuthorizeAddress: string;
|
|
94
|
+
authorizeType: "Staker" | "Withdrawer";
|
|
95
|
+
custodianAddress?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Stake initialize parameters (intermediate type) */
|
|
98
|
+
export interface StakeInitializeParams {
|
|
99
|
+
type: "StakeInitialize";
|
|
100
|
+
stakingAddress: string;
|
|
101
|
+
staker: string;
|
|
102
|
+
withdrawer: string;
|
|
103
|
+
}
|
|
104
|
+
/** Set compute unit limit parameters */
|
|
105
|
+
export interface SetComputeUnitLimitParams {
|
|
106
|
+
type: "SetComputeUnitLimit";
|
|
107
|
+
units: number;
|
|
108
|
+
}
|
|
109
|
+
/** Set priority fee parameters */
|
|
110
|
+
export interface SetPriorityFeeParams {
|
|
111
|
+
type: "SetPriorityFee";
|
|
112
|
+
fee: bigint;
|
|
113
|
+
}
|
|
114
|
+
/** Token transfer parameters */
|
|
115
|
+
export interface TokenTransferParams {
|
|
116
|
+
type: "TokenTransfer";
|
|
117
|
+
fromAddress: string;
|
|
118
|
+
toAddress: string;
|
|
119
|
+
amount: bigint;
|
|
120
|
+
sourceAddress: string;
|
|
121
|
+
tokenAddress?: string;
|
|
122
|
+
programId: string;
|
|
123
|
+
decimalPlaces?: number;
|
|
124
|
+
}
|
|
125
|
+
/** Create associated token account parameters */
|
|
126
|
+
export interface CreateAtaParams {
|
|
127
|
+
type: "CreateAssociatedTokenAccount";
|
|
128
|
+
mintAddress: string;
|
|
129
|
+
ataAddress: string;
|
|
130
|
+
ownerAddress: string;
|
|
131
|
+
payerAddress: string;
|
|
132
|
+
programId: string;
|
|
133
|
+
}
|
|
134
|
+
/** Close associated token account parameters */
|
|
135
|
+
export interface CloseAtaParams {
|
|
136
|
+
type: "CloseAssociatedTokenAccount";
|
|
137
|
+
accountAddress: string;
|
|
138
|
+
destinationAddress: string;
|
|
139
|
+
authorityAddress: string;
|
|
140
|
+
}
|
|
141
|
+
/** Memo parameters */
|
|
142
|
+
export interface MemoParams {
|
|
143
|
+
type: "Memo";
|
|
144
|
+
memo: string;
|
|
145
|
+
}
|
|
146
|
+
/** Stake pool deposit SOL parameters (Jito liquid staking) */
|
|
147
|
+
export interface StakePoolDepositSolParams {
|
|
148
|
+
type: "StakePoolDepositSol";
|
|
149
|
+
stakePool: string;
|
|
150
|
+
withdrawAuthority: string;
|
|
151
|
+
reserveStake: string;
|
|
152
|
+
fundingAccount: string;
|
|
153
|
+
destinationPoolAccount: string;
|
|
154
|
+
managerFeeAccount: string;
|
|
155
|
+
referralPoolAccount: string;
|
|
156
|
+
poolMint: string;
|
|
157
|
+
lamports: bigint;
|
|
158
|
+
}
|
|
159
|
+
/** Stake pool withdraw stake parameters (Jito liquid staking) */
|
|
160
|
+
export interface StakePoolWithdrawStakeParams {
|
|
161
|
+
type: "StakePoolWithdrawStake";
|
|
162
|
+
stakePool: string;
|
|
163
|
+
validatorList: string;
|
|
164
|
+
withdrawAuthority: string;
|
|
165
|
+
validatorStake: string;
|
|
166
|
+
destinationStake: string;
|
|
167
|
+
destinationStakeAuthority: string;
|
|
168
|
+
sourceTransferAuthority: string;
|
|
169
|
+
sourcePoolAccount: string;
|
|
170
|
+
managerFeeAccount: string;
|
|
171
|
+
poolMint: string;
|
|
172
|
+
poolTokens: bigint;
|
|
173
|
+
}
|
|
174
|
+
/** Account metadata for unknown instructions */
|
|
175
|
+
export interface AccountMeta {
|
|
176
|
+
pubkey: string;
|
|
177
|
+
isSigner: boolean;
|
|
178
|
+
isWritable: boolean;
|
|
179
|
+
}
|
|
180
|
+
/** Unknown instruction parameters */
|
|
181
|
+
export interface UnknownInstructionParams {
|
|
182
|
+
type: "Unknown";
|
|
183
|
+
programId: string;
|
|
184
|
+
accounts: AccountMeta[];
|
|
185
|
+
data: string;
|
|
186
|
+
}
|
|
187
|
+
/** Union of all instruction parameter types */
|
|
188
|
+
export type InstructionParams = TransferParams | CreateAccountParams | NonceAdvanceParams | CreateNonceAccountParams | NonceInitializeParams | StakingActivateParams | StakingDeactivateParams | StakingWithdrawParams | StakingDelegateParams | StakingAuthorizeParams | StakeInitializeParams | SetComputeUnitLimitParams | SetPriorityFeeParams | TokenTransferParams | CreateAtaParams | CloseAtaParams | MemoParams | StakePoolDepositSolParams | StakePoolWithdrawStakeParams | UnknownInstructionParams;
|
|
189
|
+
/** Durable nonce information */
|
|
190
|
+
export interface DurableNonce {
|
|
191
|
+
walletNonceAddress: string;
|
|
192
|
+
authWalletAddress: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A fully parsed Solana transaction with decoded instructions.
|
|
196
|
+
*
|
|
197
|
+
* This structure matches BitGoJS's TxData interface for seamless integration.
|
|
198
|
+
* All monetary amounts are returned as bigint directly from WASM.
|
|
199
|
+
*/
|
|
200
|
+
export interface ParsedTransaction {
|
|
201
|
+
/** The fee payer address (base58) */
|
|
202
|
+
feePayer: string;
|
|
203
|
+
/** Number of required signatures */
|
|
204
|
+
numSignatures: number;
|
|
205
|
+
/** The blockhash or nonce value (base58) */
|
|
206
|
+
nonce: string;
|
|
207
|
+
/** If this is a durable nonce transaction, contains the nonce info */
|
|
208
|
+
durableNonce?: DurableNonce;
|
|
209
|
+
/** All decoded instructions with semantic types */
|
|
210
|
+
instructionsData: InstructionParams[];
|
|
211
|
+
/** All account keys (base58 strings) */
|
|
212
|
+
accountKeys: string[];
|
|
213
|
+
/** All signatures (base58 strings). Non-empty signatures indicate signed transaction. */
|
|
214
|
+
signatures: string[];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Parse a Solana transaction into structured data.
|
|
218
|
+
*
|
|
219
|
+
* This is the main entry point for transaction parsing. It deserializes the
|
|
220
|
+
* transaction and decodes all instructions into semantic types.
|
|
221
|
+
*
|
|
222
|
+
* All monetary amounts (amount, fee, lamports, poolTokens) are returned as bigint
|
|
223
|
+
* directly from WASM - no post-processing needed.
|
|
224
|
+
*
|
|
225
|
+
* Note: This returns the raw parsed data including NonceAdvance instructions.
|
|
226
|
+
* Consumers (like BitGoJS) may choose to filter NonceAdvance from instructionsData
|
|
227
|
+
* since that info is also available in durableNonce.
|
|
228
|
+
*
|
|
229
|
+
* @param input - Raw transaction bytes, Transaction, or VersionedTransaction
|
|
230
|
+
* @returns A ParsedTransaction with all instructions decoded
|
|
231
|
+
* @throws Error if the transaction cannot be parsed
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* import { parseTransaction, buildTransaction, Transaction } from '@bitgo/wasm-solana';
|
|
236
|
+
*
|
|
237
|
+
* // From bytes
|
|
238
|
+
* const txBytes = Buffer.from(base64EncodedTx, 'base64');
|
|
239
|
+
* const parsed = parseTransaction(txBytes);
|
|
240
|
+
*
|
|
241
|
+
* // Directly from a Transaction object (no roundtrip through bytes)
|
|
242
|
+
* const tx = buildTransaction(intent);
|
|
243
|
+
* const parsed = parseTransaction(tx);
|
|
244
|
+
*
|
|
245
|
+
* console.log(parsed.feePayer);
|
|
246
|
+
* for (const instr of parsed.instructionsData) {
|
|
247
|
+
* if (instr.type === 'Transfer') {
|
|
248
|
+
* console.log(`Transfer ${instr.amount} from ${instr.fromAddress} to ${instr.toAddress}`);
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export declare function parseTransaction(input: TransactionInput): ParsedTransaction;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* High-level transaction parsing.
|
|
4
|
+
*
|
|
5
|
+
* Provides types and functions for parsing Solana transactions into semantic data
|
|
6
|
+
* matching BitGoJS's TxData format.
|
|
7
|
+
*
|
|
8
|
+
* All monetary amounts (amount, fee, lamports, poolTokens) are returned as bigint.
|
|
9
|
+
* Accepts both raw bytes and Transaction objects for convenience.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseTransaction = parseTransaction;
|
|
13
|
+
const wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// parseTransaction function
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Parse a Solana transaction into structured data.
|
|
19
|
+
*
|
|
20
|
+
* This is the main entry point for transaction parsing. It deserializes the
|
|
21
|
+
* transaction and decodes all instructions into semantic types.
|
|
22
|
+
*
|
|
23
|
+
* All monetary amounts (amount, fee, lamports, poolTokens) are returned as bigint
|
|
24
|
+
* directly from WASM - no post-processing needed.
|
|
25
|
+
*
|
|
26
|
+
* Note: This returns the raw parsed data including NonceAdvance instructions.
|
|
27
|
+
* Consumers (like BitGoJS) may choose to filter NonceAdvance from instructionsData
|
|
28
|
+
* since that info is also available in durableNonce.
|
|
29
|
+
*
|
|
30
|
+
* @param input - Raw transaction bytes, Transaction, or VersionedTransaction
|
|
31
|
+
* @returns A ParsedTransaction with all instructions decoded
|
|
32
|
+
* @throws Error if the transaction cannot be parsed
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { parseTransaction, buildTransaction, Transaction } from '@bitgo/wasm-solana';
|
|
37
|
+
*
|
|
38
|
+
* // From bytes
|
|
39
|
+
* const txBytes = Buffer.from(base64EncodedTx, 'base64');
|
|
40
|
+
* const parsed = parseTransaction(txBytes);
|
|
41
|
+
*
|
|
42
|
+
* // Directly from a Transaction object (no roundtrip through bytes)
|
|
43
|
+
* const tx = buildTransaction(intent);
|
|
44
|
+
* const parsed = parseTransaction(tx);
|
|
45
|
+
*
|
|
46
|
+
* console.log(parsed.feePayer);
|
|
47
|
+
* for (const instr of parsed.instructionsData) {
|
|
48
|
+
* if (instr.type === 'Transfer') {
|
|
49
|
+
* console.log(`Transfer ${instr.amount} from ${instr.fromAddress} to ${instr.toAddress}`);
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
function parseTransaction(input) {
|
|
55
|
+
// If input is a Transaction or VersionedTransaction, extract bytes
|
|
56
|
+
const bytes = input instanceof Uint8Array ? input : input.toBytes();
|
|
57
|
+
return wasm_solana_js_1.ParserNamespace.parse_transaction(bytes);
|
|
58
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { WasmPubkey } from "./wasm/wasm_solana.js";
|
|
2
|
+
/**
|
|
3
|
+
* Solana public key (address)
|
|
4
|
+
*
|
|
5
|
+
* A Solana address is a 32-byte Ed25519 public key, typically represented as a base58 string.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Pubkey {
|
|
8
|
+
private _wasm;
|
|
9
|
+
private constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Create a Pubkey from a base58 string
|
|
12
|
+
* @param address - The base58-encoded address
|
|
13
|
+
* @returns A Pubkey instance
|
|
14
|
+
*/
|
|
15
|
+
static fromBase58(address: string): Pubkey;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Pubkey from raw bytes (32 bytes)
|
|
18
|
+
* @param bytes - The 32-byte public key
|
|
19
|
+
* @returns A Pubkey instance
|
|
20
|
+
*/
|
|
21
|
+
static fromBytes(bytes: Uint8Array): Pubkey;
|
|
22
|
+
/**
|
|
23
|
+
* Convert to base58 string (the standard Solana address format)
|
|
24
|
+
* @returns The address as a base58 string
|
|
25
|
+
*/
|
|
26
|
+
toBase58(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get as raw bytes (32 bytes)
|
|
29
|
+
* @returns The public key as a Uint8Array
|
|
30
|
+
*/
|
|
31
|
+
toBytes(): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Check if two pubkeys are equal
|
|
34
|
+
* @param other - The other Pubkey to compare
|
|
35
|
+
* @returns true if the pubkeys are equal
|
|
36
|
+
*/
|
|
37
|
+
equals(other: Pubkey): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Check if this public key is on the Ed25519 curve.
|
|
40
|
+
*
|
|
41
|
+
* Regular Solana keypair addresses are on the curve, while Program Derived Addresses (PDAs)
|
|
42
|
+
* are intentionally off the curve to ensure they can only be signed by programs.
|
|
43
|
+
*
|
|
44
|
+
* This is equivalent to `@solana/web3.js` `PublicKey.isOnCurve()`.
|
|
45
|
+
*
|
|
46
|
+
* @returns true if the public key is on the Ed25519 curve
|
|
47
|
+
*/
|
|
48
|
+
isOnCurve(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the underlying WASM instance (internal use only)
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
get wasm(): WasmPubkey;
|
|
54
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pubkey = void 0;
|
|
4
|
+
const wasm_solana_js_1 = require("./wasm/wasm_solana.js");
|
|
5
|
+
/**
|
|
6
|
+
* Solana public key (address)
|
|
7
|
+
*
|
|
8
|
+
* A Solana address is a 32-byte Ed25519 public key, typically represented as a base58 string.
|
|
9
|
+
*/
|
|
10
|
+
class Pubkey {
|
|
11
|
+
_wasm;
|
|
12
|
+
constructor(_wasm) {
|
|
13
|
+
this._wasm = _wasm;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a Pubkey from a base58 string
|
|
17
|
+
* @param address - The base58-encoded address
|
|
18
|
+
* @returns A Pubkey instance
|
|
19
|
+
*/
|
|
20
|
+
static fromBase58(address) {
|
|
21
|
+
const wasm = wasm_solana_js_1.WasmPubkey.from_base58(address);
|
|
22
|
+
return new Pubkey(wasm);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a Pubkey from raw bytes (32 bytes)
|
|
26
|
+
* @param bytes - The 32-byte public key
|
|
27
|
+
* @returns A Pubkey instance
|
|
28
|
+
*/
|
|
29
|
+
static fromBytes(bytes) {
|
|
30
|
+
const wasm = wasm_solana_js_1.WasmPubkey.from_bytes(bytes);
|
|
31
|
+
return new Pubkey(wasm);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert to base58 string (the standard Solana address format)
|
|
35
|
+
* @returns The address as a base58 string
|
|
36
|
+
*/
|
|
37
|
+
toBase58() {
|
|
38
|
+
return this._wasm.to_base58();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get as raw bytes (32 bytes)
|
|
42
|
+
* @returns The public key as a Uint8Array
|
|
43
|
+
*/
|
|
44
|
+
toBytes() {
|
|
45
|
+
return this._wasm.to_bytes();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if two pubkeys are equal
|
|
49
|
+
* @param other - The other Pubkey to compare
|
|
50
|
+
* @returns true if the pubkeys are equal
|
|
51
|
+
*/
|
|
52
|
+
equals(other) {
|
|
53
|
+
return this._wasm.equals(other._wasm);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if this public key is on the Ed25519 curve.
|
|
57
|
+
*
|
|
58
|
+
* Regular Solana keypair addresses are on the curve, while Program Derived Addresses (PDAs)
|
|
59
|
+
* are intentionally off the curve to ensure they can only be signed by programs.
|
|
60
|
+
*
|
|
61
|
+
* This is equivalent to `@solana/web3.js` `PublicKey.isOnCurve()`.
|
|
62
|
+
*
|
|
63
|
+
* @returns true if the public key is on the Ed25519 curve
|
|
64
|
+
*/
|
|
65
|
+
isOnCurve() {
|
|
66
|
+
return this._wasm.is_on_curve();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the underlying WASM instance (internal use only)
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
get wasm() {
|
|
73
|
+
return this._wasm;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.Pubkey = Pubkey;
|