Skip to content

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Jan 14, 2026

Add comprehensive Solana transaction parsing capabilities via WASM,
providing types and structures compatible with BitGoJS's sdk-coin-sol.

Rust Layer

Transaction Deserialization (src/transaction.rs)

  • Deserialize legacy Solana transactions from wire format
  • Extract fee payer, blockhash, signatures, and account keys
  • Provide signable payload for signing operations

Instruction Decoding (src/instructions/)

  • Decode System Program: Transfer, CreateAccount, NonceAdvance, NonceInitialize
  • Decode Stake Program: Initialize, Delegate, Deactivate, Withdraw, Authorize
  • Decode ComputeBudget: SetComputeUnitLimit, SetComputeUnitPrice
  • Decode SPL Token: TransferChecked via token and token-2022 programs
  • Decode ATA Program: CreateAssociatedTokenAccount, CloseAccount
  • Decode Memo Program
  • Unknown instruction fallback with raw data preservation

High-Level Parser (src/parser.rs)

  • Combine CreateAccount + NonceInitialize into CreateNonceAccount
  • Combine CreateAccount + StakeInitialize + DelegateStake into StakingActivate
  • Detect durable nonce transactions and populate durableNonce field
  • Add stakingType field (NATIVE, JITO, MARINADE) to StakingActivate

WASM Bindings (src/wasm/)

  • ParserNamespace::parse_transaction - returns ParsedTransaction as JsValue
  • TransactionNamespace - transaction inspection methods

TypeScript Layer

Transaction Wrapper (js/transaction.ts)

  • Transaction class wrapping WASM with typed methods
  • Access to fee payer, blockhash, signatures, instructions, account keys

Parser Types (js/parser.ts)

  • Full TypeScript interfaces matching BitGoJS InstructionParams
  • ParsedTransaction interface with feePayer, nonce, durableNonce, instructionsData
  • parseTransaction() function with BigInt conversion for SetPriorityFee.fee

Exports (js/index.ts)

  • Export Transaction class and parseTransaction function
  • Re-export all instruction parameter types

Tests

  • BitGoJS compatibility tests using actual transaction fixtures
  • Transaction deserialization and inspection tests
  • Parser instruction type discrimination tests

TICKET: BTC-2929

@lcovar lcovar requested a review from a team as a code owner January 14, 2026 23:47
@lcovar lcovar marked this pull request as draft January 15, 2026 00:30
@lcovar lcovar force-pushed the BTC-2929 branch 2 times, most recently from 8c77915 to 500aca4 Compare January 15, 2026 00:51
@lcovar lcovar marked this pull request as ready for review January 15, 2026 00:58
Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's reduce the API surface a little bit (unless we really need compatibility)

if we really need these funcs for compatibility, a lot of them can be implemented in the TS layer and we can keep the rust/wasm layer smaller

@lcovar lcovar force-pushed the BTC-2929 branch 2 times, most recently from d0bc9ec to 05b7ad6 Compare January 15, 2026 22:46
@lcovar lcovar changed the title feat(wasm-solana): add transaction deserialization feat(wasm-solana): add transaction parsing with BitGoJS compatibility Jan 15, 2026
@lcovar lcovar force-pushed the BTC-2929 branch 2 times, most recently from e689c41 to b5cafec Compare January 15, 2026 23:08
@lcovar lcovar force-pushed the BTC-2929 branch 3 times, most recently from 549a347 to b466932 Compare January 22, 2026 01:22
Add comprehensive Solana transaction parsing capabilities via WASM,
providing types and structures compatible with BitGoJS's sdk-coin-sol.

## Rust Layer

### Transaction Deserialization (src/transaction.rs)
- Deserialize legacy Solana transactions from wire format
- Extract fee payer, blockhash, signatures, and account keys
- Provide signable payload for signing operations

### Instruction Decoding (src/instructions/)
- Decode System Program: Transfer, CreateAccount, NonceAdvance, NonceInitialize
- Decode Stake Program: Initialize, Delegate, Deactivate, Withdraw, Authorize
- Decode ComputeBudget: SetComputeUnitLimit, SetComputeUnitPrice
- Decode SPL Token: TransferChecked via token and token-2022 programs
- Decode ATA Program: CreateAssociatedTokenAccount, CloseAccount
- Decode Memo Program
- Unknown instruction fallback with raw data preservation

### High-Level Parser (src/parser.rs)
- Combine CreateAccount + NonceInitialize into CreateNonceAccount
- Combine CreateAccount + StakeInitialize + DelegateStake into StakingActivate
- Detect durable nonce transactions and populate durableNonce field
- Add stakingType field (NATIVE, JITO, MARINADE) to StakingActivate

### WASM Bindings (src/wasm/)
- ParserNamespace::parse_transaction - returns ParsedTransaction as JsValue
- TransactionNamespace - transaction inspection methods

## TypeScript Layer

### Transaction Wrapper (js/transaction.ts)
- Transaction class wrapping WASM with typed methods
- Access to fee payer, blockhash, signatures, instructions, account keys

### Parser Types (js/parser.ts)
- Full TypeScript interfaces matching BitGoJS InstructionParams
- ParsedTransaction interface with feePayer, nonce, durableNonce, instructionsData
- parseTransaction() function with BigInt conversion for SetPriorityFee.fee

### Exports (js/index.ts)
- Export Transaction class and parseTransaction function
- Re-export all instruction parameter types

## Tests
- BitGoJS compatibility tests using actual transaction fixtures
- Transaction deserialization and inspection tests
- Parser instruction type discrimination tests

TICKET: BTC-2929
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants