Ensure only named networks are filtered (#875)

This commit is contained in:
Jaco Greeff
2021-02-08 10:07:57 +01:00
committed by GitHub
parent e2fa0ad11f
commit ff940e5d26
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
//
// Once the above is published as a package, the duplication here can be removed
import type { Network, NetworkFromSubstrate } from './types';
import type { Network, NetworkFromSubstrate, NetworkFromSubstrateNamed } from './types';
// These are known prefixes that are not sorted
const UNSORTED = [0, 2, 42];
@@ -446,7 +446,7 @@ const all: NetworkFromSubstrate[] = [
// - when no icon has been specified, default to substrate
// - sort by name, however we keep 0, 2, 42 first in the list
const available: Network[] = all
.filter((n) => !n.isIgnored)
.filter((n): n is NetworkFromSubstrateNamed => !n.isIgnored && !!n.network)
.map((n) => ({ ...n, genesisHash: n.genesisHash || [], icon: n.icon || 'substrate' }))
.sort((a, b) =>
UNSORTED.includes(a.prefix) && UNSORTED.includes(b.prefix)
+5 -1
View File
@@ -18,7 +18,11 @@ export interface NetworkFromSubstrate {
website: string | null;
}
export interface Network extends NetworkFromSubstrate {
export interface NetworkFromSubstrateNamed extends NetworkFromSubstrate {
network: string;
}
export interface Network extends NetworkFromSubstrateNamed {
genesisHash: string[];
icon: Icon;
}