Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions modules/statics/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ export interface DotNetwork extends AccountNetwork {
readonly txVersion: number;
}

export interface PolyxNetwork extends AccountNetwork {
readonly specName: SubstrateSpecNameType;
readonly genesisHash: string;
readonly specVersion: number;
readonly chainName: string;
readonly txVersion: number;
readonly v8SpecVersion: number;
readonly v8TxVersion: number;
}

export interface EthereumNetwork extends AccountNetwork {
// unique chain id used for replay-protecting transactions
readonly chainId: number;
Expand Down Expand Up @@ -2444,18 +2454,20 @@ class BaseChain extends Mainnet implements EthereumNetwork {
walletImplementationAddress = '0x92db2759d1dca129a0d9d46877f361be819184c4';
}

class Polymesh extends Mainnet implements AccountNetwork {
class Polymesh extends Mainnet implements PolyxNetwork {
name = 'Polymesh';
family = CoinFamily.POLYX;
explorerUrl = 'https://polymesh.subscan.io/extrinsic/';
specName = 'polymesh_mainnet';
specName = 'polymesh_mainnet' as SubstrateSpecNameType;
genesisHash = '0x6fbd74e5e1d0a61d52ccfe9d4adaed16dd3a7caa37c6bc4d0c2fa12e8b2f4063';
specVersion = 7002000;
chainName = 'Polymesh Mainnet';
txVersion = 7;
v8SpecVersion = 8000000;
v8TxVersion = 8;
}

class PolymeshTestnet extends Testnet implements AccountNetwork {
class PolymeshTestnet extends Testnet implements PolyxNetwork {
name = 'PolymeshTestnet';
family = CoinFamily.POLYX;
explorerUrl = 'https://polymesh-testnet.subscan.io/extrinsic/';
Expand All @@ -2464,6 +2476,8 @@ class PolymeshTestnet extends Testnet implements AccountNetwork {
specVersion = 7002000;
chainName = 'Polymesh Testnet';
txVersion = 7;
v8SpecVersion = 8000000;
v8TxVersion = 8;
Comment thread
nvrakesh06 marked this conversation as resolved.
}

class Vet extends Mainnet implements EthereumNetwork {
Expand Down
35 changes: 34 additions & 1 deletion modules/statics/test/unit/networks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import 'should';
import { AccountNetwork, BaseNetwork, DynamicNetwork, getNetwork, Networks, NetworkType } from '../../src/networks';
import {
AccountNetwork,
BaseNetwork,
DynamicNetwork,
getNetwork,
Networks,
NetworkType,
PolyxNetwork,
} from '../../src/networks';

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

describe('Polymesh (POLYX) v8 network fields', function () {
it('mainnet has v8SpecVersion and v8TxVersion', function () {
const network: PolyxNetwork = Networks.main.polyx as PolyxNetwork;
network.should.have.property('v8SpecVersion', 8000000);
network.should.have.property('v8TxVersion', 8);
network.should.have.property('specVersion', 7002000);
network.should.have.property('txVersion', 7);
});

it('testnet has v8SpecVersion and v8TxVersion', function () {
const network: PolyxNetwork = Networks.test.polyx as PolyxNetwork;
network.should.have.property('v8SpecVersion', 8000000);
network.should.have.property('v8TxVersion', 8);
network.should.have.property('specVersion', 7002000);
network.should.have.property('txVersion', 7);
});

it('PolyxNetwork interface has required fields', function () {
const network: PolyxNetwork = Networks.main.polyx as PolyxNetwork;
network.should.have.property('specName', 'polymesh_mainnet');
network.should.have.property('genesisHash');
network.should.have.property('chainName', 'Polymesh Mainnet');
});
});

describe('DynamicNetwork and getNetwork', function () {
it('DynamicNetwork should be an instance of BaseNetwork', function () {
const network = new DynamicNetwork({ name: 'TestDynNet', type: 'testnet', family: 'eth' });
Expand Down
Loading