Skip to content

Commit 37c8882

Browse files
committed
fix: add toJsonFromWasm adapter and metadata-aware parsing fixes
- update wasm-dot tarball with parse-refactor changes: - Material.metadata is string (hex) matching Substrate RPC wire format - parseTransaction accepts DotTransaction only (not raw bytes/hex) - DotTransaction.fromHex/fromBytes accept material for metadata-aware signed extension parsing - explainTransaction removed from wasm-dot (now in BitGoJS) - simplify wasmParser.ts: pass material directly (no type conversion needed) - remove unused ParsedTransaction import BTC-0 TICKET: BTC-0
1 parent 590252c commit 37c8882

3 files changed

Lines changed: 343 additions & 28 deletions

File tree

modules/sdk-coin-dot/src/lib/transaction.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
} from './iface';
3939
import { getAddress, getDelegateAddress } from './iface_utils';
4040
import utils from './utils';
41-
import { explainDotTransaction } from './wasmParser';
41+
import { explainDotTransaction, toJsonFromWasm } from './wasmParser';
4242
import BigNumber from 'bignumber.js';
4343
import { Vec } from '@polkadot/types';
4444
import { PalletConstantMetadataV14 } from '@polkadot/types/interfaces';
@@ -162,6 +162,20 @@ export class Transaction extends BaseTransaction {
162162
if (!this._dotTransaction) {
163163
throw new InvalidTransactionError('Empty transaction');
164164
}
165+
166+
// WASM path for signed tdot transactions — validates WASM parsing against production.
167+
// Only for signed txs because toBroadcastFormat() returns the signed extrinsic (parseable).
168+
// Unsigned txs return a signing payload (different format), so they use the legacy path.
169+
if (this._coinConfig.name === 'tdot' && this._signedTransaction) {
170+
return toJsonFromWasm({
171+
txHex: this._signedTransaction,
172+
material: utils.getMaterial(this._coinConfig),
173+
senderAddress: this._sender,
174+
coinConfigName: this._coinConfig.name,
175+
referenceBlock: this._dotTransaction.blockHash,
176+
blockNumber: Number(this._dotTransaction.blockNumber),
177+
});
178+
}
165179
const decodedTx = decode(this._dotTransaction, {
166180
metadataRpc: this._dotTransaction.metadataRpc,
167181
registry: this._registry,

0 commit comments

Comments
 (0)