mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-28 10:57:57 +00:00
Initial rebrand: @polkadot -> @pezkuwi (14 packages)
- Package namespace: @polkadot/* -> @pezkuwi/* - Repository: polkadot-js/common -> pezkuwichain/pezkuwi-common - Author: Pezkuwi Team <team@pezkuwichain.io> Core packages: - @pezkuwi/util (utilities) - @pezkuwi/util-crypto (crypto primitives) - @pezkuwi/keyring (account management) - @pezkuwi/networks (chain metadata) - @pezkuwi/hw-ledger (Ledger hardware wallet) - @pezkuwi/x-* (10 polyfill packages) Total: 14 packages Upstream: polkadot-js/common v14.0.1
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { ledgerApps } from '@pezkuwi/hw-ledger/defaults';
|
||||
import { isHex } from '@pezkuwi/util';
|
||||
|
||||
import { knownGenesis, knownLedger, knownTestnet } from './defaults/index.js';
|
||||
|
||||
describe('defaults', (): void => {
|
||||
const genesisKeys = Object.keys(knownGenesis);
|
||||
const ledgerKeys = Object.keys(knownLedger);
|
||||
|
||||
describe('genesis', (): void => {
|
||||
it('has hex values for all genesis chains', (): void => {
|
||||
expect(
|
||||
genesisKeys.filter((network) =>
|
||||
!knownGenesis[network].length ||
|
||||
knownGenesis[network].some((g) => !isHex(g, 256))
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has no entries for testnets', (): void => {
|
||||
expect(
|
||||
genesisKeys.filter((network) =>
|
||||
knownTestnet[network]
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has genesis for all Ledger chains', (): void => {
|
||||
expect(
|
||||
ledgerKeys.filter((network) =>
|
||||
!knownGenesis[network]
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ledger', (): void => {
|
||||
it('has entries for each of the apps (hwledger -> networks)', (): void => {
|
||||
expect(
|
||||
ledgerKeys.filter((network) =>
|
||||
!ledgerApps[network]
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has entries for each of the apps (networks -> hwledger)', (): void => {
|
||||
expect(
|
||||
Object.keys(ledgerApps).filter((network) =>
|
||||
!knownLedger[network]
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,210 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KnownGenesis } from '../types.js';
|
||||
|
||||
// In the case where the network was hard-spooned and multiple genesisHashes
|
||||
// are provided, it needs to be in reverse order, i.e. most-recent goes first,
|
||||
// oldest goes last. This make lookups for the current a simple genesisHash[0]
|
||||
// where the latest ios always the first entry (See Kusama as an example)
|
||||
//
|
||||
// IMPORTANT: Apart from the test relays, this list is limited to live parachains
|
||||
// and live production networks. It does not and should not contain any testnets,
|
||||
// either stand-alone or connected to test relays such as Westend/Rococo
|
||||
export const knownGenesis: KnownGenesis = {
|
||||
acala: [
|
||||
'0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c'
|
||||
],
|
||||
ajuna: [
|
||||
'0xe358eb1d11b31255a286c12e44fe6780b7edb171d657905a97e39f71d9c6c3ee'
|
||||
],
|
||||
'aleph-node': [
|
||||
'0x70255b4d28de0fc4e1a193d7e175ad1ccef431598211c55538f1018651a0344e'
|
||||
],
|
||||
astar: [
|
||||
'0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6'
|
||||
],
|
||||
basilisk: [
|
||||
'0xa85cfb9b9fd4d622a5b28289a02347af987d8f73fa3108450e2b4a11c1ce5755'
|
||||
],
|
||||
bifrost: [
|
||||
'0x262e1b2ad728475fd6fe88e62d34c200abe6fd693931ddad144059b1eb884e5b'
|
||||
],
|
||||
'bifrost-kusama': [
|
||||
'0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed'
|
||||
],
|
||||
bittensor: [
|
||||
'0x2f0555cc76fc2840a25a6ea3b9637146806f1f44b090c175ffde2a7e5ab36c03'
|
||||
],
|
||||
centrifuge: [
|
||||
'0xb3db41421702df9a7fcac62b53ffeac85f7853cc4e689e0b93aeb3db18c09d82',
|
||||
'0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5'
|
||||
],
|
||||
cere: [
|
||||
'0x81443836a9a24caaa23f1241897d1235717535711d1d3fe24eae4fdc942c092c'
|
||||
],
|
||||
composable: [
|
||||
'0xdaab8df776eb52ec604a5df5d388bb62a050a0aaec4556a64265b9d42755552d'
|
||||
],
|
||||
creditcoin3: [
|
||||
'0x4436a7d64e363df85e065a894721002a86643283f9707338bf195d360ba2ee71', // cc3 mainnet
|
||||
'0xfc4ec97a1c1f119c4353aecb4a17c7c0cf7b40d5d660143d8bad9117e9866572', // cc3 testnet/drynet
|
||||
'0xfc9df99a665f964aed6649f275055e54df5e3420489538ed31d7788f53d11ef6' // cc3 devnet
|
||||
],
|
||||
darwinia: [
|
||||
'0xe71578b37a7c799b0ab4ee87ffa6f059a6b98f71f06fb8c84a8d88013a548ad6'
|
||||
],
|
||||
dentnet: [
|
||||
'0x0313f6a011d128d22f996703cbab05162e2fdc9e031493314fe6db79979c5ca7'
|
||||
],
|
||||
'dock-mainnet': [
|
||||
'0x6bfe24dca2a3be10f22212678ac13a6446ec764103c0f3471c71609eac384aae',
|
||||
'0xf73467c6544aa68df2ee546b135f955c46b90fa627e9b5d7935f41061bb8a5a9'
|
||||
],
|
||||
edgeware: [
|
||||
'0x742a2ca70c2fda6cee4f8df98d64c4c670a052d9568058982dad9d5a7a135c5b'
|
||||
],
|
||||
encointer: [
|
||||
'0x7dd99936c1e9e6d1ce7d90eb6f33bea8393b4bf87677d675aa63c9cb3e8c5b5b'
|
||||
],
|
||||
enjin: [
|
||||
'0xd8761d3c88f26dc12875c00d3165f7d67243d56fc85b4cf19937601a7916e5a9'
|
||||
],
|
||||
equilibrium: [
|
||||
'0x6f1a800de3daff7f5e037ddf66ab22ce03ab91874debeddb1086f5f7dbd48925'
|
||||
],
|
||||
frequency: [
|
||||
'0x4a587bf17a404e3572747add7aab7bbe56e805a5479c6c436f07f36fcc8d3ae1'
|
||||
],
|
||||
genshiro: [
|
||||
'0x9b8cefc0eb5c568b527998bdd76c184e2b76ae561be76e4667072230217ea243'
|
||||
],
|
||||
hydradx: [
|
||||
'0xafdc188f45c71dacbaa0b62e16a91f726c7b8699a9748cdf715459de6b7f366d', // Hydration | HydraDX Parachain
|
||||
'0xd2a620c27ec5cbc5621ff9a522689895074f7cca0d08e7134a7804e1a3ba86fc', // Snakenet Gen3-1
|
||||
'0x10af6e84234477d84dc572bac0789813b254aa490767ed06fb9591191d1073f9', // Snakenet Gen3
|
||||
'0x3d75507dd46301767e601265791da1d9cb47b6ebc94e87347b635e5bf58bd047', // Snakenet Gen2
|
||||
'0x0ed32bfcab4a83517fac88f2aa7cbc2f88d3ab93be9a12b6188a036bf8a943c2' // Snakenet Gen1
|
||||
],
|
||||
integritee: [
|
||||
'0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da', // on Kusama
|
||||
'0xe13e7af377c64e83f95e0d70d5e5c3c01d697a84538776c5b9bbe0e7d7b6034c' // on Polkadot
|
||||
],
|
||||
'interlay-parachain': [
|
||||
'0xbf88efe70e9e0e916416e8bed61f2b45717f517d7f3523e33c7b001e5ffcbc72'
|
||||
],
|
||||
karura: [
|
||||
'0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b'
|
||||
],
|
||||
khala: [
|
||||
'0xd43540ba6d3eb4897c28a77d48cb5b729fea37603cbbfc7a86a73b72adb3be8d'
|
||||
],
|
||||
kulupu: [
|
||||
'0xf7a99d3cb92853d00d5275c971c132c074636256583fee53b3bbe60d7b8769ba'
|
||||
],
|
||||
kusama: [
|
||||
'0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe', // Kusama CC3,
|
||||
'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636', // Kusama CC2
|
||||
'0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf' // Kusama CC1
|
||||
],
|
||||
liberland: [
|
||||
'0x6bd89e052d67a45bb60a9a23e8581053d5e0d619f15cb9865946937e690c42d6'
|
||||
],
|
||||
matrixchain: [
|
||||
'0x3af4ff48ec76d2efc8476730f423ac07e25ad48f5f4c9dc39c778b164d808615'
|
||||
],
|
||||
mythos: [
|
||||
'0xf6ee56e9c5277df5b4ce6ae9983ee88f3cbed27d31beeb98f9f84f997a1ab0b9'
|
||||
],
|
||||
nodle: [
|
||||
'0x97da7ede98d7bad4e36b4d734b6055425a3be036da2a332ea5a7037656427a21'
|
||||
],
|
||||
origintrail: [
|
||||
'0xe7e0962324a3b86c83404dbea483f25fb5dab4c224791c81b756cfc948006174'
|
||||
],
|
||||
p3d: [
|
||||
'0x6c5894837ad89b6d92b114a2fb3eafa8fe3d26a54848e3447015442cd6ef4e66'
|
||||
],
|
||||
parallel: [
|
||||
'0xe61a41c53f5dcd0beb09df93b34402aada44cb05117b71059cce40a2723a4e97'
|
||||
],
|
||||
peaq: [
|
||||
'0xd2a5d385932d1f650dae03ef8e2748983779ee342c614f80854d32b8cd8fa48c'
|
||||
],
|
||||
pendulum: [
|
||||
'0x5d3c298622d5634ed019bf61ea4b71655030015bde9beb0d6a24743714462c86'
|
||||
],
|
||||
phala: [
|
||||
'0x1bb969d85965e4bb5a651abbedf21a54b6b31a21f66b5401cc3f1e286268d736'
|
||||
],
|
||||
picasso: [
|
||||
'0x6811a339673c9daa897944dcdac99c6e2939cc88245ed21951a0a3c9a2be75bc',
|
||||
'0xe8e7f0f4c4f5a00720b4821dbfddefea7490bcf0b19009961cc46957984e2c1c'
|
||||
],
|
||||
polimec: [
|
||||
'0x7eb9354488318e7549c722669dcbdcdc526f1fef1420e7944667212f3601fdbd'
|
||||
],
|
||||
polkadex: [
|
||||
'0x3920bcb4960a1eef5580cd5367ff3f430eef052774f78468852f7b9cb39f8a3c'
|
||||
],
|
||||
polkadot: [
|
||||
'0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3'
|
||||
],
|
||||
polymesh: [
|
||||
'0x6fbd74e5e1d0a61d52ccfe9d4adaed16dd3a7caa37c6bc4d0c2fa12e8b2f4063'
|
||||
],
|
||||
quartz: [
|
||||
'0xcd4d732201ebe5d6b014edda071c4203e16867305332301dc8d092044b28e554'
|
||||
],
|
||||
rococo: [
|
||||
'0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e',
|
||||
'0xaaf2cd1b74b5f726895921259421b534124726263982522174147046b8827897',
|
||||
'0x037f5f3c8e67b314062025fc886fcd6238ea25a4a9b45dce8d246815c9ebe770',
|
||||
'0xc196f81260cf1686172b47a79cf002120735d7cb0eb1474e8adce56618456fff',
|
||||
'0xf6e9983c37baf68846fedafe21e56718790e39fb1c582abc408b81bc7b208f9a',
|
||||
'0x5fce687da39305dfe682b117f0820b319348e8bb37eb16cf34acbf6a202de9d9',
|
||||
'0xe7c3d5edde7db964317cd9b51a3a059d7cd99f81bdbce14990047354334c9779',
|
||||
'0x1611e1dbf0405379b861e2e27daa90f480b2e6d3682414a80835a52e8cb8a215',
|
||||
'0x343442f12fa715489a8714e79a7b264ea88c0d5b8c66b684a7788a516032f6b9',
|
||||
'0x78bcd530c6b3a068bc17473cf5d2aff9c287102bed9af3ae3c41c33b9d6c6147',
|
||||
'0x47381ee0697153d64404fc578392c8fd5cba9073391908f46c888498415647bd',
|
||||
'0x19c0e4fa8ab75f5ac7865e0b8f74ff91eb9a100d336f423cd013a8befba40299'
|
||||
],
|
||||
sora: [
|
||||
'0x7e4e32d0feafd4f9c9414b0be86373f9a1efa904809b683453a9af6856d38ad5'
|
||||
],
|
||||
stafi: [
|
||||
'0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80'
|
||||
],
|
||||
statemine: [
|
||||
'0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a'
|
||||
],
|
||||
statemint: [
|
||||
'0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f'
|
||||
],
|
||||
subsocial: [
|
||||
'0x0bd72c1c305172e1275278aaeb3f161e02eccb7a819e63f62d47bd53a28189f8'
|
||||
],
|
||||
ternoa: [
|
||||
'0x6859c81ca95ef624c9dfe4dc6e3381c33e5d6509e35e147092bfbc780f777c4e'
|
||||
],
|
||||
unique: [
|
||||
'0x84322d9cddbf35088f1e54e9a85c967a41a56a4f43445768125e61af166c7d31'
|
||||
],
|
||||
vara: [
|
||||
'0xfe1b4c55fd4d668101126434206571a7838a8b6b93a6d1b95d607e78e6c53763'
|
||||
],
|
||||
vtb: [
|
||||
'0x286bc8414c7000ce1d6ee6a834e29a54c1784814b76243eb77ed0b2c5573c60f',
|
||||
'0x7483b89572fb2bd687c7b9a93b242d0b237f9aba463aba07ec24503931038aaa'
|
||||
],
|
||||
westend: [
|
||||
'0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e'
|
||||
],
|
||||
xxnetwork: [
|
||||
'0x50dd5d206917bf10502c68fb4d18a59fc8aa31586f4e8856b493e43544aa82aa'
|
||||
],
|
||||
zeitgeist: [
|
||||
'0x1bf2a2ecb4a868de66ea8610f2ce7c8c43706561b6476031315f6640fe38e060'
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KnownIcon } from '../types.js';
|
||||
|
||||
// these are icon overrides
|
||||
export const knownIcon: KnownIcon = {
|
||||
centrifuge: 'polkadot',
|
||||
kusama: 'polkadot',
|
||||
polkadot: 'polkadot',
|
||||
sora: 'polkadot',
|
||||
statemine: 'polkadot',
|
||||
statemint: 'polkadot',
|
||||
westmint: 'polkadot'
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { knownGenesis } from './genesis.js';
|
||||
export { knownIcon } from './icons.js';
|
||||
export { knownLedger } from './ledger.js';
|
||||
export { knownTestnet } from './testnets.js';
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KnownLedger } from '../types.js';
|
||||
|
||||
// These match up with the keys of the ledgerApps object in the @polkadot/hw-ledger/defaults.ts
|
||||
// and maps to the known slip44 (minus the `0x8` hard derivation flag)
|
||||
//
|
||||
// NOTE: Any network here needs to have a genesisHash attached in the ./genesis.ts config
|
||||
export const knownLedger: KnownLedger = {
|
||||
acala: 0x00000313,
|
||||
ajuna: 0x00000162,
|
||||
'aleph-node': 0x00000283,
|
||||
astar: 0x0000032a,
|
||||
bifrost: 0x00000314,
|
||||
'bifrost-kusama': 0x00000314,
|
||||
bittensor: 0x00000162,
|
||||
centrifuge: 0x000002eb,
|
||||
composable: 0x00000162,
|
||||
creditcoin3: 0x00000162,
|
||||
darwinia: 0x00000162,
|
||||
dentnet: 0x000002de,
|
||||
'dock-mainnet': 0x00000252,
|
||||
edgeware: 0x0000020b,
|
||||
encointer: 0x000001b2,
|
||||
enjin: 0x00000483,
|
||||
equilibrium: 0x05f5e0fd,
|
||||
frequency: 0x0000082b,
|
||||
genshiro: 0x05f5e0fc,
|
||||
hydradx: 0x00000162,
|
||||
integritee: 0x000007df,
|
||||
'interlay-parachain': 0x00000162,
|
||||
karura: 0x000002ae,
|
||||
khala: 0x000001b2,
|
||||
kusama: 0x000001b2,
|
||||
liberland: 0x000002ff,
|
||||
matrixchain: 0x00000483,
|
||||
mythos: 0x0000003c,
|
||||
nodle: 0x000003eb,
|
||||
origintrail: 0x00000162,
|
||||
parallel: 0x00000162,
|
||||
peaq: 0x00000d0a,
|
||||
pendulum: 0x00000162,
|
||||
phala: 0x00000162,
|
||||
picasso: 0x000001b2,
|
||||
polimec: 0x00000d10,
|
||||
polkadex: 0x0000031f,
|
||||
polkadot: 0x00000162,
|
||||
polymesh: 0x00000253,
|
||||
quartz: 0x00000277,
|
||||
sora: 0x00000269,
|
||||
stafi: 0x0000038b,
|
||||
statemine: 0x000001b2, // common-good on Kusama, shares derivation
|
||||
statemint: 0x00000162, // common-good on Polkadot, shares derivation
|
||||
ternoa: 0x00003e3,
|
||||
unique: 0x00000295,
|
||||
vara: 0x00001370,
|
||||
vtb: 0x000002b6,
|
||||
xxnetwork: 0x000007a3,
|
||||
zeitgeist: 0x00000162
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KnownTestnet } from '../types.js';
|
||||
|
||||
// testnets should not allow selection
|
||||
export const knownTestnet: KnownTestnet = {
|
||||
'': true, // this is the default non-network entry
|
||||
'cess-testnet': true,
|
||||
'dock-testnet': true,
|
||||
jupiter: true,
|
||||
'mathchain-testnet': true,
|
||||
p3dt: true,
|
||||
subspace_testnet: true,
|
||||
'zero-alphaville': true
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import type { SubstrateNetwork } from './types.js';
|
||||
|
||||
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults/index.js';
|
||||
import { allNetworks, availableNetworks, selectableNetworks } from './index.js';
|
||||
|
||||
describe('availableNetworks', (): void => {
|
||||
it('has the correct starting order', (): void => {
|
||||
expect(availableNetworks.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
|
||||
});
|
||||
|
||||
it('has a sorted list (first external, last external)', (): void => {
|
||||
expect(availableNetworks[3].displayName).toEqual('3DP network');
|
||||
expect(availableNetworks[availableNetworks.length - 1].displayName).toEqual('ZERO');
|
||||
});
|
||||
|
||||
it('has no ignored networks', (): void => {
|
||||
expect(availableNetworks.some(({ isIgnored }) => isIgnored)).toEqual(false);
|
||||
});
|
||||
|
||||
it('has no reserved networks', (): void => {
|
||||
expect(availableNetworks.some(({ prefix }) => prefix === 47)).toEqual(false);
|
||||
});
|
||||
|
||||
it('has allNetworks genesis information', (): void => {
|
||||
expect(
|
||||
Object.entries(knownGenesis).filter(([network, genesisHash]) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network &&
|
||||
genesisHash.some((g, index) => a.genesisHash[index] !== g)
|
||||
)
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has allNetworks ledger details', (): void => {
|
||||
expect(
|
||||
Object.entries(knownLedger).filter(([network, slip44]) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network && (
|
||||
a.slip44 !== slip44 ||
|
||||
!a.hasLedgerSupport ||
|
||||
!a.genesisHash.length
|
||||
)
|
||||
)
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has no testnets exposed', (): void => {
|
||||
expect(
|
||||
Object.keys(knownTestnet).filter((network) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network
|
||||
)
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has allNetworks icons, except for overrides', (): void => {
|
||||
expect(
|
||||
availableNetworks.filter(({ icon, network }) =>
|
||||
icon !== 'substrate' &&
|
||||
knownIcon[network] !== icon
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has all the correct fields', (): void => {
|
||||
expect(availableNetworks[0]).toEqual({
|
||||
decimals: [10],
|
||||
displayName: 'Polkadot Relay Chain',
|
||||
genesisHash: [
|
||||
'0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3'
|
||||
],
|
||||
hasLedgerSupport: true,
|
||||
icon: 'polkadot',
|
||||
isIgnored: false,
|
||||
isTestnet: false,
|
||||
network: 'polkadot',
|
||||
prefix: 0,
|
||||
slip44: 354,
|
||||
standardAccount: '*25519',
|
||||
symbols: ['DOT'],
|
||||
website: 'https://polkadot.network'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('allNetworks', (): void => {
|
||||
it('has no ss58 duplicates', (): void => {
|
||||
const dupes: SubstrateNetwork[] = [];
|
||||
const uniques: SubstrateNetwork[] = [];
|
||||
|
||||
allNetworks.forEach((a): void => {
|
||||
if (uniques.some((u) => u.prefix === a.prefix)) {
|
||||
dupes.push(a);
|
||||
} else {
|
||||
uniques.push(a);
|
||||
}
|
||||
});
|
||||
|
||||
expect(dupes).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectableNetworks', (): void => {
|
||||
it('has the correct starting order', (): void => {
|
||||
expect(selectableNetworks.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
|
||||
});
|
||||
|
||||
it('has a sorted list (first external, last external)', (): void => {
|
||||
expect(selectableNetworks[3].displayName).toEqual('3DP network');
|
||||
expect(selectableNetworks[selectableNetworks.length - 1].displayName).toEqual('Zeitgeist');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// TODO: This was removed, really cannot recall the reason...
|
||||
// ... put it back, but keep it removed
|
||||
// import './packageDetect.js';
|
||||
|
||||
export * from './interfaces.js';
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KnownSubstrate, Network, SubstrateNetwork } from './types.js';
|
||||
|
||||
import knownSubstrate from '@substrate/ss58-registry';
|
||||
|
||||
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults/index.js';
|
||||
|
||||
// These are known prefixes that are not sorted
|
||||
const UNSORTED = [0, 2, 42];
|
||||
const TESTNETS = ['testnet'];
|
||||
|
||||
function toExpanded (o: KnownSubstrate): SubstrateNetwork {
|
||||
const network = o.network || '';
|
||||
const nameParts = network.replace(/_/g, '-').split('-');
|
||||
const n = o as SubstrateNetwork;
|
||||
|
||||
// ledger additions
|
||||
n.slip44 = knownLedger[network];
|
||||
n.hasLedgerSupport = !!n.slip44;
|
||||
|
||||
// general items
|
||||
n.genesisHash = knownGenesis[network] || [];
|
||||
n.icon = knownIcon[network] || 'substrate';
|
||||
|
||||
// filtering
|
||||
n.isTestnet = !!knownTestnet[network] || TESTNETS.includes(nameParts[nameParts.length - 1]);
|
||||
n.isIgnored = n.isTestnet || (
|
||||
!(
|
||||
o.standardAccount &&
|
||||
o.decimals?.length &&
|
||||
o.symbols?.length
|
||||
) &&
|
||||
o.prefix !== 42
|
||||
);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
function filterSelectable ({ genesisHash, prefix }: Network): boolean {
|
||||
return !!genesisHash.length || prefix === 42;
|
||||
}
|
||||
|
||||
function filterAvailable (n: SubstrateNetwork): n is Network {
|
||||
return !n.isIgnored && !!n.network;
|
||||
}
|
||||
|
||||
function sortNetworks (a: Network, b: Network): number {
|
||||
const isUnSortedA = UNSORTED.includes(a.prefix);
|
||||
const isUnSortedB = UNSORTED.includes(b.prefix);
|
||||
|
||||
return isUnSortedA === isUnSortedB
|
||||
? isUnSortedA
|
||||
? 0
|
||||
: a.displayName.localeCompare(b.displayName)
|
||||
: isUnSortedA
|
||||
? -1
|
||||
: 1;
|
||||
}
|
||||
|
||||
// This is all the Substrate networks with our additional information
|
||||
export const allNetworks = knownSubstrate.map(toExpanded);
|
||||
|
||||
// The list of available/claimed prefixes
|
||||
// - no testnets
|
||||
// - we only include those where we have a standardAccount
|
||||
// - sort by name, however we keep 0, 2, 42 first in the list
|
||||
export const availableNetworks = allNetworks.filter(filterAvailable).sort(sortNetworks);
|
||||
|
||||
// A filtered list of those chains we have details about (genesisHashes)
|
||||
export const selectableNetworks = availableNetworks.filter(filterSelectable);
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@pezkuwi/util';
|
||||
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, []);
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/networks', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2017-2025 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import known from '@substrate/ss58-registry';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { stringify } from '@pezkuwi/util';
|
||||
|
||||
describe('@substrate/ss58-registry', (): void => {
|
||||
it('has known values', (): void => {
|
||||
const testUrl = new URL('../test/ss58registry.json', import.meta.url);
|
||||
const json = stringify(known, 2);
|
||||
|
||||
try {
|
||||
expect(
|
||||
JSON.parse(json)
|
||||
).toEqual(
|
||||
JSON.parse(
|
||||
fs.readFileSync(testUrl, 'utf-8')
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
if (process.env['GITHUB_REPOSITORY']) {
|
||||
console.error(json);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
fs.writeFileSync(testUrl, json, { flag: 'w' });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2017-2025 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { RegistryEntry } from '@substrate/ss58-registry';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
|
||||
export type Icon = 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||
|
||||
export type KnownIcon = Record<string, Icon>;
|
||||
|
||||
export type KnownLedger = Record<string, number>;
|
||||
|
||||
export type KnownGenesis = Record<string, HexString[]>;
|
||||
|
||||
export type KnownSubstrate = RegistryEntry;
|
||||
|
||||
export type KnownTestnet = Record<string, true>;
|
||||
|
||||
export interface SubstrateNetwork extends KnownSubstrate {
|
||||
/** The genesisHash for the chain */
|
||||
genesisHash: HexString[];
|
||||
/** Does the chain has support for Ledger devices */
|
||||
hasLedgerSupport: boolean;
|
||||
/** The IdentityIcon to use for the chain */
|
||||
icon: Icon;
|
||||
/** Flag set when we don't include this chain */
|
||||
isIgnored: boolean;
|
||||
/** Flag to indicate a testnet */
|
||||
isTestnet: boolean;
|
||||
/** The Ledger-specific/required slip44 for the chain */
|
||||
slip44?: number | null;
|
||||
}
|
||||
|
||||
export interface Network extends SubstrateNetwork {
|
||||
/** The network assigned to this chain */
|
||||
network: string;
|
||||
}
|
||||
|
||||
export interface Ss58Registry {
|
||||
registry: KnownSubstrate[];
|
||||
specification: string;
|
||||
schema: Record<keyof KnownSubstrate, string>;
|
||||
}
|
||||
Reference in New Issue
Block a user