-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathsupportedNetworks.ts
99 lines (83 loc) · 2.77 KB
/
supportedNetworks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { A } from '@mobily/ts-belt';
import { isTestnet } from '@suite-common/wallet-utils';
import {
networks,
AccountType,
Network,
NetworkSymbol,
getMainnets,
getTestnets,
} from '@suite-common/wallet-config';
export const orderedAccountTypes: AccountType[] = [
'normal',
'taproot',
'segwit',
'legacy',
'ledger',
];
const discoveryBlacklist: NetworkSymbol[] = ['sol', 'dsol', 'pol', 'bnb', 'op'];
// All supported coins for device discovery
export const networkSymbolsWhitelistMap = {
mainnet: [
'btc',
'eth',
'ltc',
'etc',
'ada',
'xrp',
'bch',
'btg',
'dash',
'dgb',
'doge',
'nmc',
'vtc',
'zec',
] as NetworkSymbol[],
testnet: ['test', 'regtest', 'tsep', 'thol', 'tada', 'txrp'] as NetworkSymbol[],
} as const satisfies Record<string, NetworkSymbol[]>;
// Blacklisting coins that are allowed inside `networkSymbolsWhitelistMap` so that we don't have to configs and just filter these out
const portfolioTrackerBlacklist = ['btg', 'dash', 'dgb', 'nmc', 'vtc'];
export const discoverySupportedNetworks = [
...networkSymbolsWhitelistMap.mainnet,
...networkSymbolsWhitelistMap.testnet,
];
export const orderedNetworkSymbols = Object.keys(networks) as NetworkSymbol[];
export const sortNetworks = (networksToSort: Network[]) =>
A.sort(networksToSort, (a, b) => {
const aOrder = orderedNetworkSymbols.indexOf(a.symbol);
const bOrder = orderedNetworkSymbols.indexOf(b.symbol);
return aOrder - bOrder;
});
export const filterTestnetNetworks = (
networkSymbols: NetworkSymbol[],
isTestnetEnabled: boolean,
) => {
if (isTestnetEnabled) return networkSymbols;
return networkSymbols.filter(networkSymbol => !isTestnet(networkSymbol));
};
export const filterBlacklistedNetworks = (
networksToFilter: Network[],
allowList: NetworkSymbol[],
) =>
networksToFilter.filter(
network =>
!discoveryBlacklist.includes(network.symbol) || allowList.includes(network.symbol),
);
export const portfolioTrackerMainnets = sortNetworks(
getMainnets()
.filter(network => networkSymbolsWhitelistMap.mainnet.includes(network.symbol))
.filter(network => !portfolioTrackerBlacklist.includes(network.symbol)),
).map(network => network.symbol);
const getPortfolioTrackerTestnets = () => {
return sortNetworks(
getTestnets().filter(network =>
networkSymbolsWhitelistMap.testnet.includes(network.symbol),
),
).map(network => network.symbol);
};
export const portfolioTrackerTestnets = getPortfolioTrackerTestnets();
export const portfolioTrackerSupportedNetworks = [
...portfolioTrackerMainnets,
...portfolioTrackerTestnets,
];