Skip to content

refactor: move explain logic out of wasm-dot, accept metadata as hex string#182

Merged
lcovar merged 1 commit into
masterfrom
BTC-0.dot-parse-refactor
Feb 27, 2026
Merged

refactor: move explain logic out of wasm-dot, accept metadata as hex string#182
lcovar merged 1 commit into
masterfrom
BTC-0.dot-parse-refactor

Conversation

@lcovar

@lcovar lcovar commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove explainTransaction / explain.ts from wasm-dot — explain logic now lives in BitGoJS (sdk-coin-dot/wasmParser.ts)
  • narrow parseTransaction to accept only DotTransaction (not raw bytes/hex)
  • add fromHex and toBroadcastFormat to DotTransaction TS wrapper, remove toHex (callers use toBroadcastFormat or convert toBytes() output)
  • pass material at deserialization time so metadata-aware signed extension parsing can determine call_data boundaries correctly (needed for chains with non-standard extensions like Westend's AuthorizeCall / StorageWeightReclaim)
  • revert Material.metadata from Uint8Array back to string (0x-prefixed hex):
    • Substrate state_getMetadata RPC returns 0x-prefixed hex
    • metadata is stored and transported as hex through JSON APIs
    • forcing callers to convert to Uint8Array at every boundary adds friction with no benefit — the hex-to-bytes decode happens once, internally in Rust, right before SCALE decoding
    • Buffer.from('0x...', 'hex') silently returns an empty buffer when the input has a 0x prefix, making caller-side conversion error-prone
  • consolidate decode_metadata into a single pub(crate) function (was duplicated across parser.rs, builder/mod.rs, and transaction.rs)

Test plan

  • wasm-dot: 13 tests passing
  • BitGoJS sdk-coin-dot: 196 tests passing, 0 failing
  • cargo clippy, cargo fmt, eslint, prettier all clean

BTC-3093

@lcovar lcovar requested a review from a team as a code owner February 27, 2026 06:31
@lcovar lcovar force-pushed the BTC-0.dot-parse-refactor branch from 872b33a to ad2bf05 Compare February 27, 2026 06:40

@OttoAllmendinger OttoAllmendinger left a comment

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.

yeah the 0x prefixed hex strings are maybe a good exception for the no-hex rule worth documenting in the conventions

…string

- remove explainTransaction and explain.ts from wasm-dot (moved to BitGoJS)
- narrow parseTransaction to accept only DotTransaction (not raw bytes/hex)
- add fromHex, toHex, toBroadcastFormat to DotTransaction TS wrapper
- pass material at deserialization time (fromHex/fromBytes) so metadata-
  aware signed extension parsing can determine call_data boundaries
- revert Material.metadata from Uint8Array back to string (0x-prefixed hex)
  to match the Substrate RPC wire format and avoid forcing callers to convert
- consolidate decode_metadata into a single pub(crate) function in
  transaction.rs, remove duplicates from parser.rs and builder/mod.rs

BTC-3093
@lcovar lcovar force-pushed the BTC-0.dot-parse-refactor branch from ad2bf05 to 3ebe07d Compare February 27, 2026 10:28
@lcovar lcovar enabled auto-merge February 27, 2026 10:29
@lcovar lcovar merged commit 32010d5 into master Feb 27, 2026
12 checks passed
@lcovar lcovar deleted the BTC-0.dot-parse-refactor branch February 27, 2026 10:36
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