Skip to content

Commit d95dde3

Browse files
committed
feat(statics): add PolyxNetwork interface with v8SpecVersion and v8TxVersion
Polymesh runtime v8 is live on testnet. This commit adds the infrastructure prerequisite fields to support the v8 migration: - Introduce PolyxNetwork interface extending AccountNetwork with Polymesh-specific fields: specName, genesisHash, specVersion, chainName, txVersion, v8SpecVersion, and v8TxVersion. - Update Polymesh (mainnet) and PolymeshTestnet classes to implement PolyxNetwork instead of plain AccountNetwork. - Set v8SpecVersion = 8000000 and v8TxVersion = 8 on both network classes to reflect the Polymesh v8 runtime version. - Add unit tests verifying v8 fields on both mainnet and testnet network instances. These fields are required by BASE-2 (v8 metadata/builders) and downstream services (indexer, wallet-platform, HSM parsing) that need to gate logic on the runtime version. Ticket: CECHO-1470 Session-Id: 45130683-1dd5-4330-af56-4edc9845062a Task-Id: 64b6fe5d-9398-4f7c-9331-e87d098b8d9e
1 parent 99f90f8 commit d95dde3

2 files changed

Lines changed: 51 additions & 4 deletions

File tree

modules/statics/src/networks.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ export interface DotNetwork extends AccountNetwork {
160160
readonly txVersion: number;
161161
}
162162

163+
export interface PolyxNetwork extends AccountNetwork {
164+
readonly specName: SubstrateSpecNameType;
165+
readonly genesisHash: string;
166+
readonly specVersion: number;
167+
readonly chainName: string;
168+
readonly txVersion: number;
169+
readonly v8SpecVersion: number;
170+
readonly v8TxVersion: number;
171+
}
172+
163173
export interface EthereumNetwork extends AccountNetwork {
164174
// unique chain id used for replay-protecting transactions
165175
readonly chainId: number;
@@ -2444,18 +2454,20 @@ class BaseChain extends Mainnet implements EthereumNetwork {
24442454
walletImplementationAddress = '0x92db2759d1dca129a0d9d46877f361be819184c4';
24452455
}
24462456

2447-
class Polymesh extends Mainnet implements AccountNetwork {
2457+
class Polymesh extends Mainnet implements PolyxNetwork {
24482458
name = 'Polymesh';
24492459
family = CoinFamily.POLYX;
24502460
explorerUrl = 'https://polymesh.subscan.io/extrinsic/';
2451-
specName = 'polymesh_mainnet';
2461+
specName = 'polymesh_mainnet' as SubstrateSpecNameType;
24522462
genesisHash = '0x6fbd74e5e1d0a61d52ccfe9d4adaed16dd3a7caa37c6bc4d0c2fa12e8b2f4063';
24532463
specVersion = 7002000;
24542464
chainName = 'Polymesh Mainnet';
24552465
txVersion = 7;
2466+
v8SpecVersion = 8000000;
2467+
v8TxVersion = 8;
24562468
}
24572469

2458-
class PolymeshTestnet extends Testnet implements AccountNetwork {
2470+
class PolymeshTestnet extends Testnet implements PolyxNetwork {
24592471
name = 'PolymeshTestnet';
24602472
family = CoinFamily.POLYX;
24612473
explorerUrl = 'https://polymesh-testnet.subscan.io/extrinsic/';
@@ -2464,6 +2476,8 @@ class PolymeshTestnet extends Testnet implements AccountNetwork {
24642476
specVersion = 7002000;
24652477
chainName = 'Polymesh Testnet';
24662478
txVersion = 7;
2479+
v8SpecVersion = 8000000;
2480+
v8TxVersion = 8;
24672481
}
24682482

24692483
class Vet extends Mainnet implements EthereumNetwork {

modules/statics/test/unit/networks.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import 'should';
2-
import { AccountNetwork, BaseNetwork, DynamicNetwork, getNetwork, Networks, NetworkType } from '../../src/networks';
2+
import {
3+
AccountNetwork,
4+
BaseNetwork,
5+
DynamicNetwork,
6+
getNetwork,
7+
Networks,
8+
NetworkType,
9+
PolyxNetwork,
10+
} from '../../src/networks';
311

412
Object.entries(Networks).forEach(([category, networks]) => {
513
Object.entries(networks).forEach(([networkName, network]) => {
@@ -131,6 +139,31 @@ describe('Cosmos-family addressPrefix', function () {
131139
}
132140
});
133141

142+
describe('Polymesh (POLYX) v8 network fields', function () {
143+
it('mainnet has v8SpecVersion and v8TxVersion', function () {
144+
const network = Networks.main.polyx as unknown as PolyxNetwork;
145+
network.should.have.property('v8SpecVersion', 8000000);
146+
network.should.have.property('v8TxVersion', 8);
147+
network.should.have.property('specVersion', 7002000);
148+
network.should.have.property('txVersion', 7);
149+
});
150+
151+
it('testnet has v8SpecVersion and v8TxVersion', function () {
152+
const network = Networks.test.polyx as unknown as PolyxNetwork;
153+
network.should.have.property('v8SpecVersion', 8000000);
154+
network.should.have.property('v8TxVersion', 8);
155+
network.should.have.property('specVersion', 7002000);
156+
network.should.have.property('txVersion', 7);
157+
});
158+
159+
it('PolyxNetwork interface has required fields', function () {
160+
const network = Networks.main.polyx as unknown as PolyxNetwork;
161+
network.should.have.property('specName', 'polymesh_mainnet');
162+
network.should.have.property('genesisHash');
163+
network.should.have.property('chainName', 'Polymesh Mainnet');
164+
});
165+
});
166+
134167
describe('DynamicNetwork and getNetwork', function () {
135168
it('DynamicNetwork should be an instance of BaseNetwork', function () {
136169
const network = new DynamicNetwork({ name: 'TestDynNet', type: 'testnet', family: 'eth' });

0 commit comments

Comments
 (0)