Skip to content

Commit 7e6fe43

Browse files
committed
feat(wasm-solana): add transaction parsing with full instruction decoding
Add comprehensive Solana transaction parsing to wasm-solana package with BitGoJS-compatible output format. Core Features: - Parse serialized transactions into structured ParsedTransaction - Decode all major instruction types to semantic InstructionParams - Support for durable nonce transactions with NonceAdvance detection - Full account metadata preservation for unknown instructions Supported Programs: - System Program: Transfer, CreateAccount, NonceAdvance, NonceInitialize - Stake Program: Initialize, Delegate, Deactivate, Withdraw, Authorize, AuthorizeChecked - SPL Token: Transfer, TransferChecked (with programId and decimalPlaces) - SPL Associated Token Account: Create, Close - Compute Budget: SetComputeUnitLimit, SetPriorityFee - Memo Program: Memo instructions - SPL Stake Pool (Jito): DepositSol, WithdrawStake Instruction Combining (TypeScript): - CreateAccount + NonceInitialize → CreateNonceAccount - Staking patterns detected for NATIVE, JITO, and MARINADE types The parser returns raw instructions; combining logic lives in TypeScript for flexibility and easier maintenance. Ticket: BTC-2929
1 parent 739b7e1 commit 7e6fe43

File tree

19 files changed

+5010
-260
lines changed

19 files changed

+5010
-260
lines changed

packages/wasm-solana/Cargo.lock

Lines changed: 2566 additions & 237 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/wasm-solana/Cargo.toml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "wasm-solana"
33
version = "0.1.0"
44
edition = "2021"
55

6+
[package.metadata.wasm-pack.profile.release]
7+
wasm-opt = false
8+
69
[lib]
710
crate-type = ["cdylib", "rlib"]
811

@@ -12,17 +15,26 @@ all = "warn"
1215
[dependencies]
1316
wasm-bindgen = "0.2"
1417
js-sys = "0.3"
18+
serde = { version = "1.0", features = ["derive"] }
19+
serde_json = "1.0"
1520
# Solana SDK crates
1621
solana-pubkey = { version = "2.0", features = ["curve25519"] }
1722
solana-keypair = "2.0"
1823
solana-signer = "2.0"
19-
# Ed25519 for deriving pubkey from 32-byte seed (solana-keypair expects 64-byte format)
20-
ed25519-dalek = { version = "2.1", default-features = false, features = ["std"] }
24+
solana-transaction = { version = "3.0", features = ["serde", "bincode"] }
25+
# Instruction decoder interfaces (official Solana crates)
26+
solana-system-interface = { version = "2.0", features = ["bincode"] }
27+
solana-stake-interface = { version = "2.0", features = ["bincode"] }
28+
solana-compute-budget-interface = { version = "2.0", features = ["borsh"] }
29+
# Serialization
30+
bincode = "1.3"
31+
borsh = "1.5"
32+
base64 = "0.22"
33+
serde-wasm-bindgen = "0.6"
34+
spl-stake-pool = { version = "2.0.3", features = ["no-entrypoint"] }
2135

2236
[dev-dependencies]
2337
wasm-bindgen-test = "0.3"
24-
serde = { version = "1.0", features = ["derive"] }
25-
serde_json = "1.0"
2638
hex = "0.4"
2739

2840
[profile.release]
389 KB
Binary file not shown.

packages/wasm-solana/js/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,41 @@ void wasm;
66
// Namespace exports for explicit imports
77
export * as keypair from "./keypair.js";
88
export * as pubkey from "./pubkey.js";
9+
export * as transaction from "./transaction.js";
10+
export * as parser from "./parser.js";
911

1012
// Top-level class exports for convenience
1113
export { Keypair } from "./keypair.js";
1214
export { Pubkey } from "./pubkey.js";
15+
export { Transaction } from "./transaction.js";
16+
17+
// Top-level function exports
18+
export { parseTransaction } from "./parser.js";
19+
20+
// Type exports
21+
export type { AccountMeta, Instruction } from "./transaction.js";
22+
export type {
23+
ParsedTransaction,
24+
DurableNonce,
25+
InstructionParams,
26+
TransferParams,
27+
CreateAccountParams,
28+
NonceAdvanceParams,
29+
CreateNonceAccountParams,
30+
NonceInitializeParams,
31+
StakeInitializeParams,
32+
StakingActivateParams,
33+
StakingDeactivateParams,
34+
StakingWithdrawParams,
35+
StakingDelegateParams,
36+
StakingAuthorizeParams,
37+
SetComputeUnitLimitParams,
38+
SetPriorityFeeParams,
39+
TokenTransferParams,
40+
CreateAtaParams,
41+
CloseAtaParams,
42+
MemoParams,
43+
StakePoolDepositSolParams,
44+
StakePoolWithdrawStakeParams,
45+
UnknownInstructionParams,
46+
} from "./parser.js";

0 commit comments

Comments
 (0)