feat(sdk-coin-polyx): add v8 metadata and base V8 builders#9139
feat(sdk-coin-polyx): add v8 metadata and base V8 builders#9139bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Conversation
Add Polymesh v8 chain resources and V8-prefixed transaction builder classes to support the Polymesh spec-version 8 migration. What changed: - src/resources/mainnetV8.ts, testnetV8.ts: new material files with specVersion 8000000 and txVersion 8 (metadata bytes identical to v7 placeholder, to be replaced once v8 chain launches). - src/resources/index.ts: re-export mainnetV8 and testnetV8. - src/lib/utils.ts: add getV8Material() helper, mirrors getMaterial(). - src/lib/v8TransferBuilder.ts: V8TransferBuilder — v8 material. - src/lib/v8HexTransferBuilder.ts: V8HexTransferBuilder — v8 material. - src/lib/v8RegisterDidWithCDDBuilder.ts: V8RegisterDidWithCDDBuilder. - src/lib/v8TokenTransferBuilder.ts: V8TokenTransferBuilder. - src/lib/v8HexTokenTransferBuilder.ts: V8HexTokenTransferBuilder. - src/lib/v8PreApproveAssetBuilder.ts: V8PreApproveAssetBuilder. - src/lib/transactionBuilderFactory.ts: six getV8*Builder() factory methods exposing the V8 builders through the standard factory. - src/lib/index.ts: export all six V8 builder classes. - src/lib/preApproveAssetBuilder.ts: remove stray console.log. - test/unit/transactionBuilder/v8*.ts: 25 unit tests verifying each V8 builder uses v8 material (specVersion/txVersion), that factory methods return the correct subclass, and that signed transactions encode the correct chain metadata in toJson() output. Why: Polymesh is upgrading its chain runtime from spec version 7 to version 8 (CECHO-1471 / Polymesh v8 Migration — BASE-2). Downstream services (HSM, wallet-platform, indexer) need dedicated V8 builder classes and factory methods so they can construct and sign v8 transactions independently of the existing v7 builders without breaking any in-flight v7 traffic. Ticket: CECHO-1471 Session-Id: d224e5fe-f47a-4f84-9e84-c680f3085842 Task-Id: b5392230-7ea0-47bb-be33-bee96e8ec7bb
b8d3688 to
4c98eee
Compare
|
@claude review |
|
Claude finished @nvrakesh06's task —— View job Code Review SummaryOverall Assessment: ✅ APPROVED - This is a well-structured, focused PR that cleanly implements Polymesh v8 support through a sensible pattern of inheritance-based V8 builders. Architecture & Design✅ Excellent separation of concerns: The PR uses a clean inheritance pattern where V8 builders are thin wrappers that swap in v8 material while inheriting all behavior from their v7 counterparts. ✅ Consistent naming convention: All V8 builders follow the ✅ Proper abstraction: The Implementation Quality✅ Minimal, focused changes: Each V8 builder is just ~15 lines and follows the exact same pattern: export class V8TransferBuilder extends TransferBuilder {
constructor(_coinConfig: Readonly<CoinConfig>) {
super(_coinConfig);
this.material(utils.getV8Material(_coinConfig.network.type));
}
}✅ Correct metadata structure: The v8 material files use:
✅ Clean factory integration: The 6 new factory methods in ✅ Proper exports: All V8 builders are correctly exported from Code Quality✅ Cleanup included: Removed stray ✅ Type safety: All builders maintain proper typing through inheritance. ✅ Documentation: Each V8 builder has clear JSDoc explaining its purpose and relationship to the base class. Test Coverage✅ Comprehensive testing: 25 new unit tests across 6 test files covering:
✅ Test quality: Tests properly verify the key requirement - that built transactions carry v8 specVersion/txVersion: should.deepEqual(txJson.specVersion, testnetV8Material.specVersion);
should.deepEqual(txJson.transactionVersion, testnetV8Material.txVersion);Migration Strategy✅ Zero-disruption approach: This design allows downstream services to migrate gradually:
Potential Improvements (Minor)
VerdictThis PR demonstrates excellent software engineering practices:
The inheritance-based approach is the right design choice here, avoiding code duplication while providing the needed v8 functionality. Ready to merge once v8 chain metadata becomes available. Job Run: View Logs |
What
src/resources/mainnetV8.tsandsrc/resources/testnetV8.ts: Polymesh v8 material withspecVersion: 8000000andtxVersion: 8(metadata bytes mirror v7 as a placeholder; will be replaced with actual v8 chain metadata once it is live).getV8Material()helper inutils.tsreturning the correct v8 material by network type.V8TransferBuilder—balances.transferWithMemoV8HexTransferBuilder—balances.transferWithMemowith hex memo encodingV8RegisterDidWithCDDBuilder—identity.cddRegisterDidWithCddV8TokenTransferBuilder—settlement.addAndAffirmWithMediatorsV8HexTokenTransferBuilder—settlement.addAndAffirmWithMediatorswith hex memoV8PreApproveAssetBuilder—asset.preApproveAssetgetV8*Builder()factory methods toTransactionBuilderFactory.src/lib/index.ts.console.logdebug artifact fromPreApproveAssetBuilder.Why
Polymesh is migrating its chain runtime from spec version 7 to version 8 (Polymesh v8 Migration, BASE-2). Downstream services (HSM, wallet-platform, indexer) need dedicated V8 builder classes and factory methods to construct and sign v8 transactions independently of the existing v7 builders — ensuring zero disruption to in-flight v7 traffic during the cutover period.
Test plan
tsc --noEmit— zero TypeScript errorsmocha --grep 'V8'— 25 new unit tests all passTicket: CECHO-1471