feat: add explainTransaction, unified parseTransaction, and TransactionType enum#166
Open
feat: add explainTransaction, unified parseTransaction, and TransactionType enum#166
Conversation
ddbac4e to
28a7549
Compare
OttoAllmendinger
requested changes
Feb 14, 2026
packages/wasm-solana/js/explain.ts
Outdated
|
|
||
| export interface ExplainedInput { | ||
| address: string; | ||
| value: string; |
packages/wasm-solana/js/explain.ts
Outdated
| durableNonce?: { walletNonceAddress: string; authWalletAddress: string }; | ||
| outputs: ExplainedOutput[]; | ||
| inputs: ExplainedInput[]; | ||
| outputAmount: string; |
packages/wasm-solana/js/explain.ts
Outdated
| id: string | undefined; | ||
| type: string; | ||
| feePayer: string; | ||
| fee: string; |
| interface CombinedStakeActivate { | ||
| fromAddress: string; | ||
| stakingAddress: string; | ||
| amount: bigint; |
packages/wasm-solana/js/explain.ts
Outdated
| instructions: InstructionParams[], | ||
| combined: CombinedStakeActivate | null, | ||
| memo: string | undefined, | ||
| ): string { |
3 tasks
6c2bfe5 to
151936f
Compare
Add high-level explainTransaction() to @bitgo/wasm-solana that builds on parseTransaction (WASM) to provide structured transaction explanation: type derivation, instruction combining, fee calculation, outputs/inputs, and ATA owner mapping. Also export AuthorizeIntent type that was missing from public API. BTC-3025
parseTransaction(bytes) now returns a Transaction instance that can be both inspected and signed, matching wasm-utxo's PSBT pattern. Use .parse() on the returned Transaction to get decoded instruction data. - Transaction.parse() returns ParsedTransaction (decoded instructions) - parseTransactionData() exported for internal/low-level use - explainTransaction() updated to use parseTransactionData internally - Tests updated to use parseTransactionData for direct data access BTC-3025
151936f to
1aee8f1
Compare
…nd optional lamportsPerSignature - Detect CreateAccount + NonceInitialize pattern as WalletInitialization - Add tokenEnablements (ATA address + mint address) to ExplainedTransaction - Add StakingAuthorizeInfo to ExplainedTransaction for staking authority changes - lamportsPerSignature defaults to 5000 (Solana protocol constant) when not provided, simplifying the API for consumers - Export StakingAuthorizeInfo type from the public API BTC-3025
1aee8f1 to
a066017
Compare
Contributor
Author
|
@OttoAllmendinger made a hefty change, see new pr description and re-review pls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
explainTransaction()to@bitgo/wasm-solana— a high-level TypeScript function that takes raw transaction bytes and returns a structured explanation (type, outputs, inputs, fee, memo, token enablements, staking authorize details).What's included
explainTransaction()injs/explain.ts— combines raw WASM-parsed instructions into higher-level operations:CreateAccount + StakeInitialize [+ Delegate]→StakingActivate(native/Marinade)Transfer + Memo("PrepareForRevoke")→StakingDeactivate(Marinade)StakePoolDepositSol→StakingActivate(Jito)StakePoolWithdrawStake→StakingDeactivate(Jito)CreateAccount + NonceInitialize→WalletInitializationparseTransaction()unified API — returns aTransactionobject with.parse()for inspection and.addSignature()for signinglamportsPerSignatureis optional, defaults to 5000 (Solana protocol constant)tokenAccountRentExemptAmountis optional, adds ATA creation rent to fee when providedStakingAuthorizeInfoonExplainedTransaction— exposes staking authority change detailsTransactionTypeenum and all explain types exported for consumersConsumer usage
Test plan