Skip to content

feat: add @bitgo/wasm-ton package#235

Open
lcovar wants to merge 1 commit intomasterfrom
wasm-ton
Open

feat: add @bitgo/wasm-ton package#235
lcovar wants to merge 1 commit intomasterfrom
wasm-ton

Conversation

@lcovar
Copy link
Copy Markdown
Contributor

@lcovar lcovar commented Mar 27, 2026

Summary

  • New @bitgo/wasm-ton WASM package for offline TON transaction building, parsing, and signing support
  • Built on toner (tlb-ton 0.7.3) Rust crate, compiles to wasm32-unknown-unknown
  • Supports all TON transaction types: transfer, token transfer (jetton), staking (TonWhales, SingleNominator, MultiNominator), vesting, consolidation, fillNonce
  • Two-layer architecture: core Rust logic in src/, thin #[wasm_bindgen] wrappers in src/wasm/, TypeScript wrappers in js/
  • No signing in WASM, only signablePayload() and addSignature() for TSS integration
  • 32 TypeScript tests covering address, transaction, and builder flows
  • private: true in package.json until npm package is created by velocity team

Ticket: BTC-3212

Copy link
Copy Markdown
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 get rid of the enums

not super happy about the base conversion bloat but so far it's not out of control

@lcovar lcovar force-pushed the wasm-ton branch 6 times, most recently from deb8e6e to 7d326d0 Compare March 27, 2026 18:08
@lcovar lcovar requested a review from OttoAllmendinger March 30, 2026 17:41
@lcovar lcovar marked this pull request as ready for review March 30, 2026 22:02
@lcovar lcovar requested a review from a team as a code owner March 30, 2026 22:02
Comment on lines +81 to +86
/**
* Convenience function to create a Transaction from bytes.
*/
export function transactionFromBytes(bytes: Uint8Array): Transaction {
return Transaction.fromBytes(bytes);
}
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.

not that much more convenient

Rust/WASM package for TON (The Open Network) transaction building,
parsing, and signing. Uses toner v0.7.3 (pure Rust TON SDK) compiled
to wasm32-unknown-unknown.

Supports all wallet-platform intent types:
- payment (native TON + jetton token transfers)
- fillNonce (nonce hole filling via self-send)
- consolidate (native + token, 7-day expiry)
- delegate (TonWhales, SingleNominator, MultiNominator)
- undelegate (TonWhales, SingleNominator, MultiNominator)
- vesting contract variants for Whales deposit/withdraw

Architecture follows wasm-solana/wasm-dot patterns:
- Two-layer rule: core Rust logic in src/, thin WASM bindings in src/wasm/
- TypeScript wrappers in js/ with bigint for all monetary amounts
- Transaction signing via signablePayload() + addSignature()
- Standalone parseTransaction() for all 7 transaction shapes
- Intent-based buildTransaction() with BuildContext for offline building

32 TypeScript tests + Rust unit tests.

BTC-3211
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