From 2cdaf71c4b0e28746f866dfd3425253f6f7ebf85 Mon Sep 17 00:00:00 2001 From: Jaco Date: Sat, 23 Oct 2021 11:34:53 +0200 Subject: [PATCH] Sync with paritytech/ss58-registry (#1138) * Sync with paritytech/ss58-registry * Since registry location * Adjust defaults with json location * Adjust * Adjust comments * prefix 42 --- .github/workflows/ss58-check.yml | 1 + CHANGELOG.md | 1 + packages/networks/scripts/fromSubstrate.mjs | 20 +++++-- packages/networks/src/crosscheck.spec.ts | 4 +- packages/networks/src/defaults.ts | 4 ++ packages/networks/src/interfaces.ts | 2 +- packages/networks/src/substrate.ts | 62 ++++++++++++++------- packages/networks/src/types.ts | 2 +- 8 files changed, 68 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ss58-check.yml b/.github/workflows/ss58-check.yml index 90cf6075f..100cc5fa1 100644 --- a/.github/workflows/ss58-check.yml +++ b/.github/workflows/ss58-check.yml @@ -13,6 +13,7 @@ jobs: CI_LOG: 123 run: | yarn install --immutable | grep -v 'YN0013' + yarn build yarn networks:crosscheck - name: issue diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d8b0912..f25f2a66f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes: - Update `xxhash*` to only use `Uint8Array` internally, no `Buffer` - Adjust `isAscii` to check against original string codepoints (when provided) +- Adjust networks to sync with `paritytech/ss58-registry` ## 7.5.1 Oct 16, 2021 diff --git a/packages/networks/scripts/fromSubstrate.mjs b/packages/networks/scripts/fromSubstrate.mjs index c5e3faa77..3f8ec3f6f 100644 --- a/packages/networks/scripts/fromSubstrate.mjs +++ b/packages/networks/scripts/fromSubstrate.mjs @@ -4,7 +4,11 @@ import fs from 'fs'; import fetch from 'node-fetch'; -const SUBSTRATE_REGISTRY = 'https://raw.githubusercontent.com/paritytech/substrate/master/ss58-registry.json'; +import { substrateRegistry } from '../build/defaults.js'; + +const substrateRegistryRepo = substrateRegistry + .replace('raw.githubusercontent.com', 'github.com') + .split('main')[0]; function outputField (k, v) { if (typeof v === 'string') { @@ -20,7 +24,7 @@ function outputField (k, v) { } async function getSubstrateRegistry () { - const original = await fetch(SUBSTRATE_REGISTRY); + const original = await fetch(substrateRegistry); const json = await original.json(); return json.registry @@ -39,11 +43,17 @@ getSubstrateRegistry() fs.writeFileSync('packages/networks/src/substrate.ts', `// Copyright 2017-2021 @polkadot/networks authors & contributors // SPDX-License-Identifier: Apache-2.0 +// // Auto-generated by yarn networks:sync (via scripts/fromSubstrate.mjs) // -// Do not edit, rather -// - make a PR to the upstream registry as per ${SUBSTRATE_REGISTRY} -// - yarn networks:sync +// This file should never be edited manually. Rather the process is as follow - +// +// - make a PR to the upstream registry found at ${substrateRegistryRepo} +// - ensure the PR gets merged +// - yarn networks:sync in this repo to sync +// +// Any manual changes to this file will make CI cron checks fail and will be +// lost when the registry is updated alongside the above sync. // import type { KnownSubstrate } from './types'; diff --git a/packages/networks/src/crosscheck.spec.ts b/packages/networks/src/crosscheck.spec.ts index 02fa231cf..a872c910c 100644 --- a/packages/networks/src/crosscheck.spec.ts +++ b/packages/networks/src/crosscheck.spec.ts @@ -8,10 +8,10 @@ import fs from 'fs'; import { stringify } from '@polkadot/util'; import { fetch } from '@polkadot/x-fetch'; +import { substrateRegistry } from './defaults'; import { allNetworks } from './'; const OUTPUT = './.github/ss58-check.md'; -const SUBSTRATE_REGISTRY = 'https://raw.githubusercontent.com/paritytech/substrate/master/ss58-registry.json'; function assertAndLog (check: boolean, error: string): void { if (!check) { @@ -28,7 +28,7 @@ describe('check latest Substrate ss58 registry', (): void => { let original: Ss58Registry; beforeAll(async (): Promise => { - original = (await (await fetch(SUBSTRATE_REGISTRY)).json()) as Ss58Registry; + original = (await (await fetch(substrateRegistry)).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 index 08438e964..69773da77 100644 --- a/packages/networks/src/defaults.ts +++ b/packages/networks/src/defaults.ts @@ -3,6 +3,8 @@ import type { KnownGenesis, KnownIcon, KnownLedger, KnownTestnet } from './types'; +export const substrateRegistry = 'https://raw.githubusercontent.com/paritytech/ss58-registry/main/ss58-registry.json'; + // 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 // last. This make lookups for the current a simple genesisHash[0] @@ -90,6 +92,8 @@ export const knownLedger: KnownLedger = { // 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, diff --git a/packages/networks/src/interfaces.ts b/packages/networks/src/interfaces.ts index e1fe05117..c2b98d7ea 100644 --- a/packages/networks/src/interfaces.ts +++ b/packages/networks/src/interfaces.ts @@ -18,7 +18,7 @@ export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => { n.genesisHash = knownGenesis[network] || []; n.icon = knownIcon[network] || 'substrate'; - n.isIgnored = !network || !!knownTestnet[network] || !o.standardAccount; + n.isIgnored = !!knownTestnet[network] || (!(o.standardAccount && o.decimals && o.symbols) && o.prefix !== 42); return n; }); diff --git a/packages/networks/src/substrate.ts b/packages/networks/src/substrate.ts index 2c72893bd..3b617f90f 100644 --- a/packages/networks/src/substrate.ts +++ b/packages/networks/src/substrate.ts @@ -1,11 +1,17 @@ // Copyright 2017-2021 @polkadot/networks authors & contributors // SPDX-License-Identifier: Apache-2.0 +// // Auto-generated by yarn networks:sync (via scripts/fromSubstrate.mjs) // -// Do not edit, rather -// - make a PR to the upstream registry as per https://raw.githubusercontent.com/paritytech/substrate/master/ss58-registry.json -// - yarn networks:sync +// This file should never be edited manually. Rather the process is as follow - +// +// - make a PR to the upstream registry found at https://github.com/paritytech/ss58-registry/ +// - ensure the PR gets merged +// - yarn networks:sync in this repo to sync +// +// Any manual changes to this file will make CI cron checks fail and will be +// lost when the registry is updated alongside the above sync. // import type { KnownSubstrate } from './types'; @@ -23,9 +29,9 @@ export const knownSubstrate: KnownSubstrate[] = [ { decimals: null, displayName: 'Bare 32-bit Schnorr/Ristretto (S/R 25519) public key.', - network: null, + network: 'BareSr25519', prefix: 1, - standardAccount: null, + standardAccount: 'Sr25519', symbols: null, website: null }, @@ -41,9 +47,9 @@ export const knownSubstrate: KnownSubstrate[] = [ { decimals: null, displayName: 'Bare 32-bit Ed25519 public key.', - network: null, + network: 'BareEd25519', prefix: 3, - standardAccount: null, + standardAccount: 'Ed25519', symbols: null, website: null }, @@ -387,14 +393,14 @@ export const knownSubstrate: KnownSubstrate[] = [ prefix: 42, standardAccount: '*25519', symbols: null, - website: 'https://docs.substrate.io/' + website: 'https://substrate.io/' }, { decimals: null, displayName: 'Bare 32-bit ECDSA SECP-256k1 public key.', - network: null, + network: 'BareSecp256k1', prefix: 43, - standardAccount: null, + standardAccount: 'secp256k1', symbols: null, website: null }, @@ -623,6 +629,15 @@ export const knownSubstrate: KnownSubstrate[] = [ symbols: ['NET'], website: 'https://social.network' }, + { + decimals: [15], + displayName: 'QUARTZ by UNIQUE', + network: 'quartz_mainnet', + prefix: 255, + standardAccount: '*25519', + symbols: ['QTZ'], + website: 'https://unique.network' + }, { decimals: [18], displayName: 'Moonbeam', @@ -641,15 +656,6 @@ export const knownSubstrate: KnownSubstrate[] = [ symbols: ['MOVR'], website: 'https://moonbeam.network' }, - { - decimals: [18], - displayName: 'Automata Mainnet', - network: 'automata', - prefix: 2349, - standardAccount: '*25519', - symbols: ['ATA'], - website: 'https://ata.network' - }, { decimals: [12], displayName: 'Basilisk', @@ -659,6 +665,24 @@ export const knownSubstrate: KnownSubstrate[] = [ symbols: ['BSX'], website: 'https://bsx.fi' }, + { + decimals: [12], + displayName: 'CESS Testnet', + network: 'cess-testnet', + prefix: 10042, + standardAccount: '*25519', + symbols: ['TCESS'], + website: 'https://cess.cloud' + }, + { + decimals: [12], + displayName: 'CESS', + network: 'cess', + prefix: 10043, + standardAccount: '*25519', + symbols: ['CESS'], + website: 'https://cess.cloud' + }, { decimals: [18], displayName: 'Automata ContextFree', diff --git a/packages/networks/src/types.ts b/packages/networks/src/types.ts index 775ad177d..96a248a44 100644 --- a/packages/networks/src/types.ts +++ b/packages/networks/src/types.ts @@ -8,7 +8,7 @@ export interface KnownSubstrate { displayName: string; network: string | null; prefix: number; - standardAccount: '*25519' | 'secp256k1' | null; + standardAccount: '*25519' | 'Ed25519' | 'Sr25519' | 'secp256k1' | null; symbols: string[] | null; website: string | null; }