Ensure isUnreachable is sorted alongside (#6037)

This commit is contained in:
Jaco 2021-08-31 09:47:19 +03:00 committed by GitHub
parent 90472172e3
commit 93c9e38f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 38 deletions

View File

@ -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 => {

View File

@ -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,

View File

@ -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);
}

View File

@ -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/',

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<LinkOption[]>((result, input) =>
result.concat(expandEndpoint(t, input, firstOnly, withSort)), []
);
}