Skip to content

fix(sdk-coin-polyx, abstract-substrate): fix withdrawal local validation after chain upgrade#9207

Merged
nvrakesh06 merged 1 commit into
masterfrom
nvrakeshreddy/cecho-1471-fix-v8-transfer-routing
Jul 9, 2026
Merged

fix(sdk-coin-polyx, abstract-substrate): fix withdrawal local validation after chain upgrade#9207
nvrakesh06 merged 1 commit into
masterfrom
nvrakeshreddy/cecho-1471-fix-v8-transfer-routing

Conversation

@nvrakesh06

@nvrakesh06 nvrakesh06 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Root cause: After a Polymesh chain upgrade, pallet indices shift in the live chain metadata. The client-side SDK uses hardcoded metadata (both v7 and v8 SDK versions map pallet 0x28 to Treasury), while the server builds transactions against live RPC metadata (where 0x28 is now Balances). This causes verifyTransaction to misread balances.transferWithMemo as treasury.disbursement and fail.
  • Why wallet creation works but withdrawals fail: Wallet creation (RegisterDidWithCDD) runs entirely server-side — the server uses live RPC material for both build and decode, so it always matches. Withdrawals go through Wallet.prebuildAndSignTransaction in the browser, which calls verifyTransaction locally with the hardcoded SDK material.
  • Fix 1 (abstract-substrate): verifyTransaction now reads txPrebuild.coinSpecific.material (the live chain material the server embeds during prebuild) and passes it to the factory before .from(txHex). This gives the factory the correct pallet mapping for the current chain spec.
  • Fix 2 (sdk-coin-polyx): tryGetV8Builder now routes v8-encoded non-staking transactions (transferWithMemo, addAndAffirmWithMediators, registerDid, preApproveAsset) to their v8 builders. Defense-in-depth for cases where coinSpecific.material is absent or stale.

Root Cause Detail

Server builds txHex with live chain material → Balances at pallet 0x28
Client decodes txHex with hardcoded SDK v7/v8 material → pallet 0x28 = Treasury
→ treasury.disbursement decode fails: Vec length 1055031096 exceeds 524288

Test plan

  • Unit test: verifyTransaction with a txHex whose pallet index only resolves correctly with the material in coinSpecific.material
  • Unit test: tryGetV8Builder routes transferWithMemo to V8TransferBuilder
  • Manual: tpolyx withdrawal end-to-end confirms local validation passes

Linear: CECHO-1471

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

CECHO-1471

@nvrakesh06 nvrakesh06 force-pushed the nvrakeshreddy/cecho-1471-fix-v8-transfer-routing branch from 49a09c9 to 6902983 Compare July 8, 2026 15:29
@nvrakesh06 nvrakesh06 changed the title fix(sdk-coin-polyx): route v8 transfer txns in tryGetV8Builder fix(sdk-coin-polyx, abstract-substrate): fix withdrawal local validation after chain upgrade Jul 8, 2026
@nvrakesh06 nvrakesh06 requested a review from Copilot July 8, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Polymesh (POLYX) client-side transaction validation failures after a chain upgrade by ensuring transaction decoding uses the correct chain metadata, and by improving v8 transaction builder routing as a fallback.

Changes:

  • Update abstract-substrate verifyTransaction to prefer txPrebuild.coinSpecific.material (live chain material embedded by the server) for decoding before calling .from(txHex).
  • Extend sdk-coin-polyx tryGetV8Builder to route additional non-staking v8 transactions (e.g., transferWithMemo, registerDid, preApproveAsset, addAndAffirmWithMediators) to v8 builders.
  • Add unit tests covering v8 builder routing and verifyTransaction behavior when coinSpecific.material is provided.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
modules/sdk-coin-polyx/test/unit/transactionBuilder/transactionBuilderFactory.ts Adds unit tests to assert v8 transferWithMemo transactions route to the correct v8 builders via fallback.
modules/sdk-coin-polyx/test/unit/polyx.ts Adds unit tests verifying verifyTransaction succeeds/fails correctly for v8 transfers when coinSpecific.material is provided.
modules/sdk-coin-polyx/src/lib/transactionBuilderFactory.ts Expands v8 fallback routing to cover additional non-staking transaction types and memo-encoding variants.
modules/abstract-substrate/src/abstractSubstrateCoin.ts Uses embedded live-chain material (when present) to decode transactions correctly during local validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When the server builds a transfer tx against v8 chain metadata, the
client-side v7 decode fails (call indices shifted) and falls through to
tryGetV8Builder. Route transferWithMemo, addAndAffirmWithMediators,
registerDid/WithCDD, and preApproveAsset to their v8 builders.

Pass coinSpecific.material from txPrebuild to the transaction builder
factory before from() so local validation uses live-chain pallet/call
mapping instead of stale hardcoded metadata.

Add unit tests for v8 transfer routing and material propagation.

Ticket: CECHO-1471
Co-authored-by: Cursor <cursoragent@cursor.com>
@nvrakesh06 nvrakesh06 force-pushed the nvrakeshreddy/cecho-1471-fix-v8-transfer-routing branch from b89e1f4 to 36d878b Compare July 8, 2026 16:12
@nvrakesh06 nvrakesh06 marked this pull request as ready for review July 9, 2026 05:39
@nvrakesh06 nvrakesh06 requested a review from a team as a code owner July 9, 2026 05:39
@nvrakesh06 nvrakesh06 merged commit b6734cb into master Jul 9, 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.

3 participants