diff --git a/packages/apps-config/src/endpoints/index.spec.ts b/packages/apps-config/src/endpoints/index.spec.ts index 0b4bed1aac..51d735d5b3 100644 --- a/packages/apps-config/src/endpoints/index.spec.ts +++ b/packages/apps-config/src/endpoints/index.spec.ts @@ -10,7 +10,7 @@ interface Endpoint { value: string; } -const allEndpoints = createWsEndpoints((k: string, v?: string) => v || k); +const allEndpoints = createWsEndpoints((k: string, v?: string) => v || k, false, false); describe('WS urls are all valid', (): void => { allEndpoints @@ -33,10 +33,10 @@ describe('WS urls are all valid', (): void => { describe('urls are sorted', (): void => { let hasDevelopment = false; let lastHeader = ''; - const filtered = allEndpoints.filter(({ isHeader, isUnreachable, text }): boolean => { + const filtered = allEndpoints.filter(({ isHeader, text }): boolean => { hasDevelopment = hasDevelopment || (!!isHeader && text === 'Development'); - return !isUnreachable && !hasDevelopment; + return !hasDevelopment; }); filtered.forEach(({ isHeader, text }, index): void => { diff --git a/packages/apps-config/src/endpoints/index.ts b/packages/apps-config/src/endpoints/index.ts index 69a5b659fc..82ca4af0dd 100644 --- a/packages/apps-config/src/endpoints/index.ts +++ b/packages/apps-config/src/endpoints/index.ts @@ -12,7 +12,7 @@ import { createRococoRelay, createWestendRelay } from './testingRelays'; export { CUSTOM_ENDPOINT_KEY } from './development'; -export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOption[] { +export function createWsEndpoints (t: TFunction, firstOnly = false, withSort = true): LinkOption[] { return [ ...createCustom(t), { @@ -23,7 +23,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createPolkadotRelay(t, firstOnly), + ...createPolkadotRelay(t, firstOnly, withSort), { isDisabled: false, isHeader: true, @@ -31,7 +31,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createKusamaRelay(t, firstOnly), + ...createKusamaRelay(t, firstOnly, withSort), { isDisabled: false, isHeader: true, @@ -40,7 +40,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createWestendRelay(t, firstOnly), + ...createWestendRelay(t, firstOnly, withSort), { isDisabled: false, isHeader: true, @@ -48,7 +48,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createRococoRelay(t, firstOnly), + ...createRococoRelay(t, firstOnly, withSort), { isDisabled: false, isHeader: true, @@ -57,7 +57,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createProduction(t, firstOnly), + ...createProduction(t, firstOnly, withSort), { isDisabled: false, isHeader: true, @@ -65,7 +65,7 @@ export function createWsEndpoints (t: TFunction, firstOnly?: boolean): LinkOptio textBy: '', value: '' }, - ...createTesting(t, firstOnly), + ...createTesting(t, firstOnly, withSort), { isDevelopment: true, isDisabled: false, diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts index 3affb9f674..88eb7c266b 100644 --- a/packages/apps-config/src/endpoints/production.ts +++ b/packages/apps-config/src/endpoints/production.ts @@ -15,7 +15,7 @@ import { expandEndpoints } from './util'; // value: The actual hosted secure websocket endpoint // alphabetical based on chain name -export function createProduction (t: TFunction, firstOnly?: boolean): LinkOption[] { +export function createProduction (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { return expandEndpoints(t, [ { dnslink: 'centrifuge', @@ -193,5 +193,5 @@ export function createProduction (t: TFunction, firstOnly?: boolean): LinkOption DataHighway: 'wss://westlake.datahighway.com' } } - ], firstOnly); + ], firstOnly, withSort); } diff --git a/packages/apps-config/src/endpoints/productionRelayKusama.ts b/packages/apps-config/src/endpoints/productionRelayKusama.ts index 68b81c976d..2a5b9a397b 100644 --- a/packages/apps-config/src/endpoints/productionRelayKusama.ts +++ b/packages/apps-config/src/endpoints/productionRelayKusama.ts @@ -112,16 +112,6 @@ export function createKusama (t: TFunction): EndpointOption { Equilibrium: 'wss://gens-mainnet.equilibrium.io' } }, - { - info: 'heiko', - homepage: 'https://parallel.fi', - isUnreachable: true, - paraId: 2085, - text: t('rpc.kusama.heiko', 'Parallel Heiko', { ns: 'apps-config' }), - providers: { - Parallel: 'wss://heiko-rpc-0.parallel.fi' - } - }, { info: 'integritee', homepage: 'https://integritee.network', @@ -206,6 +196,16 @@ export function createKusama (t: TFunction): EndpointOption { 'Patract Elara': 'wss://pub.elara.patract.io/moonriver' } }, + { + info: 'heiko', + homepage: 'https://parallel.fi', + isUnreachable: true, + paraId: 2085, + text: t('rpc.kusama.heiko', 'Parallel Heiko', { ns: 'apps-config' }), + providers: { + Parallel: 'wss://heiko-rpc-0.parallel.fi' + } + }, { info: 'polkasmith', homepage: 'https://polkasmith.polkafoundry.com/', diff --git a/packages/apps-config/src/endpoints/productionRelays.ts b/packages/apps-config/src/endpoints/productionRelays.ts index 86387ac1ca..e6911ec851 100644 --- a/packages/apps-config/src/endpoints/productionRelays.ts +++ b/packages/apps-config/src/endpoints/productionRelays.ts @@ -8,10 +8,10 @@ import { createKusama } from './productionRelayKusama'; import { createPolkadot } from './productionRelayPolkadot'; import { expandEndpoints } from './util'; -export function createKusamaRelay (t: TFunction, firstOnly?: boolean): LinkOption[] { - return expandEndpoints(t, [createKusama(t)], firstOnly); +export function createKusamaRelay (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { + return expandEndpoints(t, [createKusama(t)], firstOnly, withSort); } -export function createPolkadotRelay (t: TFunction, firstOnly?: boolean): LinkOption[] { - return expandEndpoints(t, [createPolkadot(t)], firstOnly); +export function createPolkadotRelay (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { + return expandEndpoints(t, [createPolkadot(t)], firstOnly, withSort); } diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts index ea9dd36815..c219c4d5ad 100644 --- a/packages/apps-config/src/endpoints/testing.ts +++ b/packages/apps-config/src/endpoints/testing.ts @@ -14,7 +14,7 @@ import { expandEndpoints } from './util'; // text: The text to display on the dropdown // value: The actual hosted secure websocket endpoint -export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[] { +export function createTesting (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { return expandEndpoints(t, [ // alphabetical based on chain name, e.g. Amber, Arcadia, Beresheet, ... { @@ -461,5 +461,5 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[] ZERO: 'wss://alphaville.zero.io' } } - ], firstOnly); + ], firstOnly, withSort); } diff --git a/packages/apps-config/src/endpoints/testingRelays.ts b/packages/apps-config/src/endpoints/testingRelays.ts index 650753f67c..515d094711 100644 --- a/packages/apps-config/src/endpoints/testingRelays.ts +++ b/packages/apps-config/src/endpoints/testingRelays.ts @@ -8,10 +8,10 @@ import { createRococo } from './testingRelayRococo'; import { createWestend } from './testingRelayWestend'; import { expandEndpoints } from './util'; -export function createRococoRelay (t: TFunction, firstOnly?: boolean): LinkOption[] { - return expandEndpoints(t, [createRococo(t)], firstOnly); +export function createRococoRelay (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { + return expandEndpoints(t, [createRococo(t)], firstOnly, withSort); } -export function createWestendRelay (t: TFunction, firstOnly?: boolean): LinkOption[] { - return expandEndpoints(t, [createWestend(t)], firstOnly); +export function createWestendRelay (t: TFunction, firstOnly: boolean, withSort: boolean): LinkOption[] { + return expandEndpoints(t, [createWestend(t)], firstOnly, withSort); } diff --git a/packages/apps-config/src/endpoints/util.ts b/packages/apps-config/src/endpoints/util.ts index b763c9eadc..b790c94bac 100644 --- a/packages/apps-config/src/endpoints/util.ts +++ b/packages/apps-config/src/endpoints/util.ts @@ -33,7 +33,7 @@ export function expandLinked (input: LinkOption[]): LinkOption[] { }, []); } -export function expandEndpoint (t: TFunction, { dnslink, genesisHash, homepage, info, isChild, isDisabled, isUnreachable, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly?: boolean): LinkOption[] { +export function expandEndpoint (t: TFunction, { dnslink, genesisHash, homepage, info, isChild, isDisabled, isUnreachable, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly: boolean, withSort: boolean): LinkOption[] { const base = { genesisHash, homepage, @@ -64,11 +64,10 @@ export function expandEndpoint (t: TFunction, { dnslink, genesisHash, homepage, const last = result[result.length - 1]; const options: LinkOption[] = []; - linked - .sort(sortLinks) + (withSort ? linked.sort(sortLinks) : linked) .filter(({ paraId }) => paraId) .forEach((o) => - options.push(...expandEndpoint(t, o, firstOnly)) + options.push(...expandEndpoint(t, o, firstOnly, withSort)) ); last.isRelay = true; @@ -78,6 +77,8 @@ export function expandEndpoint (t: TFunction, { dnslink, genesisHash, homepage, return expandLinked(result); } -export function expandEndpoints (t: TFunction, input: EndpointOption[], firstOnly?: boolean): LinkOption[] { - return input.sort(sortLinks).reduce((result: LinkOption[], input) => result.concat(expandEndpoint(t, input, firstOnly)), []); +export function expandEndpoints (t: TFunction, input: EndpointOption[], firstOnly: boolean, withSort: boolean): LinkOption[] { + return (withSort ? input.sort(sortLinks) : input).reduce((result, input) => + result.concat(expandEndpoint(t, input, firstOnly, withSort)), [] + ); }