Skip to content

fix(sdk-coin-polyx): route v8 token transfers with dropped sender.did to v8 builder#9309

Merged
nvrakesh06 merged 1 commit into
masterfrom
nvrakeshreddy/polyx-v8-token-withdrawal-routing
Jul 21, 2026
Merged

fix(sdk-coin-polyx): route v8 token transfers with dropped sender.did to v8 builder#9309
nvrakesh06 merged 1 commit into
masterfrom
nvrakeshreddy/polyx-v8-token-withdrawal-routing

Conversation

@nvrakesh06

Copy link
Copy Markdown
Contributor

Description

Fixes token withdrawals (Polymesh settlement.addAndAffirmWithMediators) failing on the v7/v8 chain migration with:

Invalid transaction: "legs[0].fungible.sender.did" is required

TransactionBuilderFactory.getBuilder() decodes the raw tx against v7 metadata first and only retries against v8 material if that decode throws. v8 wraps leg sender/receiver in an AssetHolder enum ({ portfolio: { did, kind } }) instead of the bare v7 { did, kind }, but the call index for addAndAffirmWithMediators is unchanged between v7/v8 — so decoding a v8-encoded token transfer with v7 metadata does not throw, it just silently produces a decoded transaction missing legs[0].fungible.sender.did. The factory then proceeds with the v7 TokenTransferBuilder, whose schema requires that field directly, and validateDecodedTransaction rejects the transaction during wallet-platform's build-time round-trip re-parse of the withdrawal.

Native transfers (transferWithMemo) are unaffected because that call's v7/v8 arg shape didn't change.

Fix

On the v7 decode-success path for AddAndAffirmWithMediators, detect a missing legs[0].fungible.sender.did and retry via the existing tryGetV8Builder() (which already correctly routes to V8TokenTransferBuilder/V8HexTokenTransferBuilder) before falling through to the v7 builder.

Issue Number

TICKET: CECHO-1471

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • npx tsc --noEmit in modules/sdk-coin-polyx — clean
  • npx mocha test/unit/transactionBuilder/*TokenTransfer* — 31 passing
  • npx mocha test/unit/transactionBuilder/transactionBuilderFactory.ts — 248 passing, 2 pending
  • Root-caused against live staging logs (Loki/wallet-platform) reproducing the exact sender.did failure for a TPOLYX:NVBITGOT withdrawal on testnet Polymesh v8.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My code compiles correctly for both Node and Browser environments
  • My commits follow Conventional Commits
  • The ticket was included in the commit message as a reference
  • I have added tests that prove my fix is effective — TODO before merge: add a regression test to transactionBuilderFactory.ts's suite covering "v7 decode succeeds but sender.did missing → routes to v8 builder"
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

Retry v8 decoding when v7 metadata silently drops sender.did, then route
the transaction to V8TokenTransferBuilder. Add regression and signed and
unsigned round-trip coverage.

TICKET: CECHO-1471
Co-authored-by: Cursor <cursoragent@cursor.com>
@nvrakesh06
nvrakesh06 force-pushed the nvrakeshreddy/polyx-v8-token-withdrawal-routing branch from 6875967 to 57fd25f Compare July 21, 2026 11:49
@nvrakesh06
nvrakesh06 marked this pull request as ready for review July 21, 2026 12:17
@nvrakesh06
nvrakesh06 requested a review from a team as a code owner July 21, 2026 12:17
@nvrakesh06
nvrakesh06 merged commit 86a3943 into master Jul 21, 2026
25 checks passed
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