Skip to content

feat: add explainSolTransaction using @bitgo/wasm-solana#7957

Open
lcovar wants to merge 4 commits intomasterfrom
BTC-0-draft-example-sol-decoding
Open

feat: add explainSolTransaction using @bitgo/wasm-solana#7957
lcovar wants to merge 4 commits intomasterfrom
BTC-0-draft-example-sol-decoding

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Jan 21, 2026

Summary

Add a standalone explainSolTransaction() function to sdk-coin-sol that uses @bitgo/wasm-solana to explain Solana transactions without depending on @solana/web3.js.

This is a thin ~100-line adapter that replaces the need for the legacy 800+ line Transaction class explain logic. The heavy lifting (parsing, instruction combining, type derivation) happens in @bitgo/wasm-solana — this adapter only handles:

  • Token name resolution (mint address → sol:usdc via @bitgo/statics)
  • bigint → string conversion at the serialization boundary
  • StakingAuthorizeStakingAuthorizeRaw type mapping for downstream compatibility
  • Mapping to TransactionExplanation interface

Changes

  • explainTransactionWasm.ts (new): Standalone adapter that calls @bitgo/wasm-solana's explainTransaction(), resolves token names, maps staking authorize fields, and returns TransactionExplanation including inputs and feePayer
  • transaction.ts: Route tsol through WASM-based explain (validates against production traffic before replacing legacy for all networks)
  • sol.ts: Add explainTransactionWithWasm() method at coin class level
  • iface.ts: Add ataOwnerMap and stakingAuthorize to TransactionExplanation interface
  • instructionParamsFactory.ts: Add Jito stake pool operations (StakePoolDepositSol, StakePoolWithdrawStake)
  • jitoWasmVerification.ts: New test file verifying Jito liquid staking explain output
  • transaction.ts tests: Updated assertions for WASM parity (fee defaults to '0' instead of 'UNAVAILABLE', ataOwnerMap, inputs, feePayer, token name via statics)
  • sol.ts tests: Updated explain assertions to include inputs and feePayer returned by WASM path
  • webpack config: Add WASM asset handling for @bitgo/wasm-solana
  • package.json: Add @bitgo/wasm-solana dependency

Key decisions

  • tsol only: WASM path is gated to testnet (tsol) to validate against production traffic before replacing the legacy path for mainnet
  • Fee behavior: Returns fee: '0' and feeRate: undefined when fee info not provided (instead of 'UNAVAILABLE'). Downstream already converts UNAVAILABLE → '0', so this is a no-op change
  • StakingAuthorizeRaw: WASM can decode both raw and non-raw authorize instructions natively, but downstream expects the StakingAuthorizeRaw type name, so the adapter maps it
  • Token names: Resolved via @bitgo/statics. Tokens not in statics return the raw mint address
  • inputs/feePayer: Now included in the return so consumers (e.g. wallet-platform) can use the SDK as a single source of truth without calling wasm-solana directly
  • Test updates: 26 test assertions updated to include inputs and feePayer — these fields were already on the TransactionExplanation interface but weren't populated by the WASM path until now

Depends on

  • BitGoWASM PR #166explainTransaction() with StakingAuthorizeInfo, optional lamportsPerSignature (defaults to 5000n)

Test Plan

  • All existing sdk-coin-sol tests pass with updated assertions
  • New Jito WASM verification tests pass
  • Parity verified against legacy Transaction class output for all transaction types

TICKET: BTC-3025

@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 27 times, most recently from d32c089 to bb885ad Compare January 28, 2026 18:16
@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 2 times, most recently from f5732ce to 97c511d Compare January 28, 2026 18:36
@lcovar lcovar requested a review from Marzooqa February 10, 2026 19:39
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.

we can move towards bigint a little bit more

where external interfaces force us to string keep it

@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 2 times, most recently from 38e4bc7 to da3dc95 Compare February 11, 2026 19:20
@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 3 times, most recently from 0b3225b to 3cb4054 Compare February 12, 2026 20:22
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.

counting on you claude

@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch from 3cb4054 to 009f956 Compare February 13, 2026 10:24
@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 2 times, most recently from c071f3c to e1a4c9d Compare February 14, 2026 06:33
@lcovar lcovar marked this pull request as draft February 15, 2026 05:32
@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch from 01ddba7 to 9400a94 Compare February 15, 2026 05:58
@lcovar lcovar changed the title feat(sdk-coin-sol): add WASM-based transaction parsing via @bitgo/wasm-solana feat: add explainSolTransaction using @bitgo/wasm-solana Feb 15, 2026
@lcovar lcovar force-pushed the BTC-0-draft-example-sol-decoding branch 4 times, most recently from a59880d to 9e38c95 Compare February 17, 2026 21:51
@lcovar lcovar marked this pull request as ready for review February 17, 2026 22:36
Add a standalone `explainSolTransaction()` function that calls
@bitgo/wasm-solana's `explainTransaction()` directly and resolves
token names via `@bitgo/statics`.

This is a thin adapter (~40 lines) that:
- Converts wasm-solana's bigint amounts to strings at the boundary
- Resolves mint addresses to token names via @bitgo/statics
- Maps to the existing TransactionExplanation interface

No legacy code is modified. The adapter coexists alongside the
existing Transaction class and builders. For tsol (testnet),
explainTransaction() routes through the WASM adapter. For sol
(mainnet), the legacy builder path is preserved.

Changes:
- sol.ts: add explainSolTransaction() + explainTransactionWithWasm()
- iface.ts: add inputs, feePayer, ataOwnerMap to TransactionExplanation
- instructionParamsFactory.ts: export findTokenName (used by adapter)
- package.json: add @bitgo/wasm-solana dependency
- webpack config: add WASM asset handling
- New tests: Jito WASM verification + explain tests for all tx types

BTC-3025

TICKET: BTC-0
Follow the *Wasm.ts naming convention used by abstract-utxo
(explainPsbtWasm.ts, signPsbtWasm.ts). Moves the standalone WASM
explain adapter out of sol.ts into its own module with a dedicated
interface, barrel-exported from lib/index.ts.

BTC-0

TICKET: BTC-0
Route tsol transactions through the WASM-based explainSolTransaction()
in Transaction.explainTransaction(), validating the WASM path against
production traffic before replacing the legacy implementation for all
networks.

Changes:
- transaction.ts: tsol uses explainSolTransaction() instead of the
  legacy switch/case block (no @solana/web3.js dependency)
- explainTransactionWasm.ts: add StakingAuthorizeRaw type mapping and
  stakingAuthorize field support for full parity with legacy
- explainTransactionWasm.ts: return fee '0' with feeRate undefined
  when feeInfo is not provided (matches downstream expectations)
- Update test assertions for WASM output shape (ataOwnerMap, fee
  values, unresolvable token names)

BTC-0

TICKET: BTC-0
Populate the inputs and feePayer fields in explainSolTransaction so
consumers (wallet-platform) can call the SDK instead of wasm-solana
directly. Update 26 test assertions to expect these new fields.

BTC-3025

TICKET: BTC-0
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.

2 participants

Comments