-
Notifications
You must be signed in to change notification settings - Fork 2
feat(wasm-solana): add transaction parsing with BitGoJS compatibility #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8c77915 to
500aca4
Compare
OttoAllmendinger
left a comment
There was a problem hiding this 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
d0bc9ec to
05b7ad6
Compare
e689c41 to
b5cafec
Compare
93415f9 to
1a49cef
Compare
…ding 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
OttoAllmendinger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure all the amounts are bigint, the caller can convert them to string where necessary
| /** Raw instruction from WASM before post-processing */ | ||
| interface RawInstruction { | ||
| type: string; | ||
| fee?: string; // Fee comes as string from WASM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can make it bigint here anyway
| type: "TokenTransfer"; | ||
| fromAddress: string; | ||
| toAddress: string; | ||
| amount: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigint
| type: "StakingWithdraw"; | ||
| fromAddress: string; | ||
| stakingAddress: string; | ||
| amount: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigin
| type: "StakingActivate"; | ||
| fromAddress: string; | ||
| stakingAddress: string; | ||
| amount: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigint
| fromAddress: string; | ||
| nonceAddress: string; | ||
| authAddress: string; | ||
| amount: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigin
| export function parseTransaction(bytes: Uint8Array): ParsedTransaction { | ||
| const raw = ParserNamespace.parse_transaction(bytes) as RawParsedTransaction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's allow higher level types here as well so we don't always have to go through bytes
| export function parseTransaction(bytes: Uint8Array): ParsedTransaction { | |
| const raw = ParserNamespace.parse_transaction(bytes) as RawParsedTransaction; | |
| export function parseTransaction(bytes: Uint8Array | RawParsedTransaction): ParsedTransaction { | |
| const raw = ParserNamespace.parse_transaction(bytes) as RawParsedTransaction; |
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)
Instruction Decoding (src/instructions/)
High-Level Parser (src/parser.rs)
WASM Bindings (src/wasm/)
TypeScript Layer
Transaction Wrapper (js/transaction.ts)
Parser Types (js/parser.ts)
Exports (js/index.ts)
Tests
TICKET: BTC-2929