fix(sdk-coin-polyx): route v8 batchAll(bond,nominate) parse to v8 builder#9220
Conversation
d0a1c15 to
4c9ff96
Compare
|
@claude review |
|
Claude finished @abhijit0943's task —— View job Code Review for PR #9220 ✅Reviewing the fix for v8 batchAll(bond,nominate) routing in POLYX SDK. Todo List:
Code Review Analysis✅ Overall Assessment: LGTM - Well-designed fixThe PR addresses a specific routing bug where v8 📝 Core Changes Review1. Factory Logic Enhancement ( const bondArgs = args.calls[0].args as { controller?: unknown };
if (bondArgs.controller === undefined) {
return this.getV8BatchStakingBuilder();
}✅ Strengths:
✅ Type Safety: The type assertion 🧪 Test Coverage Review2. v7 Regression Test ( it('factory.from routes a v7 bond+nominate transaction to BatchStakingBuilder (SI-981 regression)', ...)✅ Good coverage: Ensures v7 transactions with controller still route to the correct v7 builder 3. v8 Routing Test ( it('factory.from routes to V8BatchStakingBuilder on the v8 decode-success path (SI-981)', ...)✅ Reproduces the bug: Test directly addresses the original staging incident with v8 material 🔍 Technical AnalysisProblem Understanding:
Solution Approach:
|
…lder On the decode-success path, TransactionBuilderFactory.getBuilder() routed every batchAll([bond, nominate]) to the v7 BatchStakingBuilder. When the transaction is decoded against v8 material the bond call carries no `controller` (v8 changed bond(controller, value, payee) → bond(value, payee)), so v7 validateBondArgs crashed reading `args.controller.id`. Inspect the decoded bond args: route to V8BatchStakingBuilder when no controller is present, and keep v7 bond+nominate on BatchStakingBuilder. TICKET: SI-981
4c9ff96 to
c22ca5c
Compare
What
TransactionBuilderFactory.getBuilder()routed everybatchAll([bond, nominate])to the v7BatchStakingBuilderon the decode-success path. When the transaction is decoded against v8 material, the bond call carries nocontroller(v8 changedbond(controller, value, payee)→bond(value, payee)), so v7validateBondArgscrashed withCannot read properties of undefined (reading 'id')while accessingargs.controller.id.Why
tryGetV8Builder()only runs when v7decode()throws. Unlike v8 transfers (whose shifted call indices make v7 decode fail), v8 stakingbatchAllcan decode without throwing, so the v8 fallback never fired and the tx was misrouted — breaking POLYX v8 stake dry-runs on staging.How
In the
batchAll([bond, nominate])branch, inspect the decoded bond args: route toV8BatchStakingBuilderwhen nocontrolleris present, and keep v7 bond+nominate onBatchStakingBuilder. Scoped to the factory only — no builder implementation changes.Testing
factory.from()on a v8batchAll([bond, nominate])returnsV8BatchStakingBuilderinstead of crashing.BatchStakingBuilder.yarn tsc, lint, and the polyx staking test files pass.Linked to SI-981.