diff --git a/packages/hw-ledger/src/defaults.ts b/packages/hw-ledger/src/defaults.ts index 31e53d8ae..fe88aa43b 100644 --- a/packages/hw-ledger/src/defaults.ts +++ b/packages/hw-ledger/src/defaults.ts @@ -6,7 +6,7 @@ import type { SubstrateApp } from '@zondax/ledger-substrate'; import { newBifrostApp, newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newGenshiroApp, newKusamaApp, newNodleApp, newPolkadotApp, newPolymeshApp, newSoraApp, newStatemineApp } from '@zondax/ledger-substrate'; -// These match up with the keys of the knownLedger object in the @polkadot/networks/defaults.ts +// These match up with the keys of the knownLedger object in the @polkadot/networks/defaults/ledger.ts export const ledgerApps: Record SubstrateApp> = { bifrost: newBifrostApp, centrifuge: newCentrifugeApp, diff --git a/packages/networks/src/crosscheck.spec.ts b/packages/networks/src/crosscheck.spec.ts index fe7501377..d7da881c3 100644 --- a/packages/networks/src/crosscheck.spec.ts +++ b/packages/networks/src/crosscheck.spec.ts @@ -8,9 +8,9 @@ import fs from 'fs'; import { objectKeys, stringify } from '@polkadot/util'; import { fetch } from '@polkadot/x-fetch'; -import { substrateRegistry } from './defaults'; import { allNetworks } from './'; +const REGISTRY = 'https://raw.githubusercontent.com/paritytech/ss58-registry/main/ss58-registry.json'; const OUTPUT = './.github/ss58-check.md'; function assertAndLog (check: boolean, error: string): void { @@ -28,7 +28,7 @@ describe('check latest Substrate ss58 registry', (): void => { let original: Ss58Registry; beforeAll(async (): Promise => { - original = (await (await fetch(substrateRegistry)).json()) as Ss58Registry; + original = (await (await fetch(REGISTRY)).json()) as Ss58Registry; }); it('has the same number as the original', (): void => { diff --git a/packages/networks/src/defaults.ts b/packages/networks/src/defaults.ts deleted file mode 100644 index 3164bcca9..000000000 --- a/packages/networks/src/defaults.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017-2022 @polkadot/networks authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { KnownIcon, KnownLedger, KnownTestnet } from './types'; - -export { knownGenesis } from './genesis'; - -export const substrateRegistry = 'https://raw.githubusercontent.com/paritytech/ss58-registry/main/ss58-registry.json'; - -// these are icon overrides -export const knownIcon: KnownIcon = { - centrifuge: 'polkadot', - kusama: 'polkadot', - polkadot: 'polkadot', - sora: 'polkadot', - statemine: 'polkadot', - statemint: 'polkadot', - westmint: 'polkadot' -}; - -// 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 config above -export const knownLedger: KnownLedger = { - bifrost: 0x00000314, - centrifuge: 0x000002eb, - 'dock-mainnet': 0x00000252, - edgeware: 0x0000020b, - equilibrium: 0x05f5e0fd, - genshiro: 0x05f5e0fc, - kusama: 0x000001b2, - 'nodle-chain': 0x000003eb, - polkadot: 0x00000162, - polymesh: 0x00000253, - sora: 0x00000269, - statemine: 0x000001b2 // common-good on Kusama, shares derivation -}; - -// 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, - subspace_testnet: true, - 'zero-alphaville': true -}; diff --git a/packages/networks/src/genesis.ts b/packages/networks/src/defaults/genesis.ts similarity index 98% rename from packages/networks/src/genesis.ts rename to packages/networks/src/defaults/genesis.ts index 00cbccceb..40f926380 100644 --- a/packages/networks/src/genesis.ts +++ b/packages/networks/src/defaults/genesis.ts @@ -1,7 +1,7 @@ // Copyright 2017-2022 @polkadot/networks authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { KnownGenesis } from './types'; +import type { KnownGenesis } from '../types'; // NOTE: 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 first, oldest diff --git a/packages/networks/src/defaults/icons.ts b/packages/networks/src/defaults/icons.ts new file mode 100644 index 000000000..27520abe5 --- /dev/null +++ b/packages/networks/src/defaults/icons.ts @@ -0,0 +1,15 @@ +// Copyright 2017-2022 @polkadot/networks authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { KnownIcon } from '../types'; + +// these are icon overrides +export const knownIcon: KnownIcon = { + centrifuge: 'polkadot', + kusama: 'polkadot', + polkadot: 'polkadot', + sora: 'polkadot', + statemine: 'polkadot', + statemint: 'polkadot', + westmint: 'polkadot' +}; diff --git a/packages/networks/src/defaults/index.ts b/packages/networks/src/defaults/index.ts new file mode 100644 index 000000000..d2fc83f5c --- /dev/null +++ b/packages/networks/src/defaults/index.ts @@ -0,0 +1,7 @@ +// Copyright 2017-2022 @polkadot/networks authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export { knownGenesis } from './genesis'; +export { knownIcon } from './icons'; +export { knownLedger } from './ledger'; +export { knownTestnet } from './testnets'; diff --git a/packages/networks/src/defaults/ledger.ts b/packages/networks/src/defaults/ledger.ts new file mode 100644 index 000000000..9710f0be3 --- /dev/null +++ b/packages/networks/src/defaults/ledger.ts @@ -0,0 +1,23 @@ +// Copyright 2017-2022 @polkadot/networks authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { KnownLedger } from '../types'; + +// 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 = { + bifrost: 0x00000314, + centrifuge: 0x000002eb, + 'dock-mainnet': 0x00000252, + edgeware: 0x0000020b, + equilibrium: 0x05f5e0fd, + genshiro: 0x05f5e0fc, + kusama: 0x000001b2, + 'nodle-chain': 0x000003eb, + polkadot: 0x00000162, + polymesh: 0x00000253, + sora: 0x00000269, + statemine: 0x000001b2 // common-good on Kusama, shares derivation +}; diff --git a/packages/networks/src/defaults/testnets.ts b/packages/networks/src/defaults/testnets.ts new file mode 100644 index 000000000..bb73c8ad3 --- /dev/null +++ b/packages/networks/src/defaults/testnets.ts @@ -0,0 +1,15 @@ +// Copyright 2017-2022 @polkadot/networks authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { KnownTestnet } from '../types'; + +// 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, + subspace_testnet: true, + 'zero-alphaville': true +}; diff --git a/packages/networks/tsconfig.build.json b/packages/networks/tsconfig.build.json index 21275b5b4..1882db9fc 100644 --- a/packages/networks/tsconfig.build.json +++ b/packages/networks/tsconfig.build.json @@ -7,7 +7,7 @@ "rootDir": "./src" }, "include": [ - "**/src/*.ts", + "**/src/**/*.ts", "**/test/*.json" ], "references": [