Skip to content

fix(ada): providing unsigned sweep support for WRW#8248

Open
dgm003 wants to merge 1 commit intomasterfrom
fix/ada-unsigned-sweep-CSHLD-134
Open

fix(ada): providing unsigned sweep support for WRW#8248
dgm003 wants to merge 1 commit intomasterfrom
fix/ada-unsigned-sweep-CSHLD-134

Conversation

@dgm003
Copy link
Contributor

@dgm003 dgm003 commented Mar 5, 2026

Ticket: CSHLD-134

Description

Extends the ADA unsigned sweep (cold wallet recovery) flow to correctly handle token-holding wallets.

Two gaps existed in the unsigned sweep path:

  1. 'explainTransaction()' stripped 'multiAssets' from outputs — token info was never surfaced in the parsed/explained view
  2. 'recover()' function unsigned path only used parsedTx.outputs[0], so token transactions with 2 outputs were broken

Changes:

  • transaction.ts: Added extractTokenTransfers() helper that converts CardanoWasm.MultiAsset into a flat '{ policyId, assetName, quantity }' array. Updated 'explainTransaction()' return type and output mapping to include 'tokenTransfers?' per output.
  • ada.ts: Fixed recover() unsigned sweep path to map over all 'parsedTx.outputs' instead of hardcoding only 'outputs[0]', with 'tokenTransfers' passed through.
  • ada.ts test: Added test for unsigned sweep with ADA+Token UTXOs — asserts 2 inputs, 2 outputs, correct token amounts, and tokenTransfers populated in explainTransaction().

Issue Number

CSHLD-134

Type of change

Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Ran npx mocha test file

  • All 160 existing unit tests pass
  • New unit test added: 'should recover ADA plus token UTXOs - token and ADA both appear in outputs (unsigned sweep)'
  • Validates 2 inputs (ADA UTXO + token UTXO), 2 outputs (token output with correct MultiAsset + ADA remainder), and 'tokenTransfers' in 'explainTransaction()'

@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch from 6269f8c to 2321317 Compare March 5, 2026 08:08
@dgm003 dgm003 marked this pull request as ready for review March 5, 2026 17:00
@dgm003 dgm003 requested a review from a team as a code owner March 5, 2026 17:00
@dgm003 dgm003 marked this pull request as draft March 5, 2026 17:01
@dgm003 dgm003 marked this pull request as ready for review March 18, 2026 09:43
@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch 2 times, most recently from 9a36a38 to bb7e4f5 Compare March 23, 2026 07:35
@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch from bb7e4f5 to 8035b13 Compare March 23, 2026 08:22
address: o.address,
valueString: o.amount,
coinName: walletCoin,
...(txOutputs[i]?.multiAssets && { assetList }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we checking for multiAssets and including the input assetList? We should be parsing the outputs.multiAssets and adding it here

const parsedTx = await this.parseTransaction({ txPrebuild: transactionPrebuild });
const walletCoin = this.getChain();
const output = (parsedTx.outputs as ITransactionRecipient)[0];
const txOutputs = unsignedTransaction.toJson().outputs;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to add the parsing logic for tokens in the explainTransaction itself?

@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch from 8035b13 to 8e74410 Compare March 23, 2026 08:59

private static parseMultiAssets(multiAssets: CardanoWasm.MultiAsset | Asset | undefined): Asset[] | undefined {
if (!multiAssets) return undefined;
if (!(multiAssets instanceof CardanoWasm.MultiAsset)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When will this if case be executed?

/** @inheritdoc */
explainTransaction(): {
outputs: { amount: string; address: string }[];
outputs: { amount: string; address: string; assetList?: Asset[] }[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we please use the same key name multiAssets after parsing as well just to be consistent

valueString: output.amount,
coinName: walletCoin,
value: new BigNumber(output.amount as string).toNumber(),
...(inputAssetList.length > 0 && { assetList: inputAssetList }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the key here as well

@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch from 8e74410 to f8fea96 Compare March 23, 2026 09:20
@dgm003 dgm003 requested a review from Ranjna-G March 23, 2026 09:21
@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch 2 times, most recently from 5e0aef9 to 946357c Compare March 23, 2026 09:47
@dgm003 dgm003 marked this pull request as draft March 23, 2026 10:05
@dgm003 dgm003 force-pushed the fix/ada-unsigned-sweep-CSHLD-134 branch from 946357c to 70c8834 Compare March 23, 2026 10:09
@dgm003 dgm003 marked this pull request as ready for review March 23, 2026 10:48
Copy link
Contributor

@Ranjna-G Ranjna-G left a comment

Choose a reason for hiding this comment

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

lgtm

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