Skip to content

feat(wasm-solana): return Transaction types from builder functions#121

Merged
lcovar merged 2 commits into
masterfrom
BTC-2988
Feb 2, 2026
Merged

feat(wasm-solana): return Transaction types from builder functions#121
lcovar merged 2 commits into
masterfrom
BTC-2988

Conversation

@lcovar
Copy link
Copy Markdown
Contributor

@lcovar lcovar commented Jan 29, 2026

Summary

  • Changed buildTransaction() to return Transaction instead of Uint8Array
  • Changed buildFromVersionedData() to return VersionedTransaction instead of Uint8Array
  • Added fromWasm() factory methods to Transaction and VersionedTransaction classes
  • Callers that need bytes can simply call .toBytes() on the result

This addresses feedback from PR #113 to return rich Transaction objects that can be inspected before serializing, which is more ergonomic.

Test plan

  • All 90 existing tests pass
  • Updated tests to use new return types

Changed buildTransaction() and buildFromVersionedData() to return
Transaction and VersionedTransaction objects instead of raw bytes.
This allows callers to inspect the transaction before serializing,
which is more ergonomic and matches the existing Transaction API.

Callers that need bytes can simply call .toBytes() on the result.
@lcovar lcovar requested a review from a team as a code owner January 29, 2026 19:19
Comment thread packages/wasm-solana/test/builder.ts Outdated
const txBytes = buildTransaction(intent);
const tx = buildTransaction(intent);
const txBytes = tx.toBytes();
const parsed = parseTransaction(txBytes);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not parse the tx directly instead of going through the byte representation here?

you can widen parseTransaction so that accepts both Transaction or bytes for convenience

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

smort

parseTransaction now accepts Uint8Array, Transaction, or VersionedTransaction
directly, avoiding the need for callers to explicitly call .toBytes() when
parsing a transaction that was just built.

Ticket: BTC-2988
@lcovar lcovar merged commit 41607f8 into master Feb 2, 2026
6 checks passed
@lcovar lcovar deleted the BTC-2988 branch February 2, 2026 18:43
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