forked from graphprotocol/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSupportedNetworks.ts
34 lines (29 loc) · 1.19 KB
/
getSupportedNetworks.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
import { ChainProductStatus, SupportedNetworkMap } from '@edgeandnode/common'
const isNotNull = <T>(x: T | null): x is T => x !== null
export function getSupportedNetworks() {
return Array.from(SupportedNetworkMap.values()).flatMap((network) =>
Array.from(network.chains)
.map((chain) => {
if (!chain.graphCliName) {
return null
}
const supportedOnHosted = chain.productDeployStatus.hostedService === ChainProductStatus.ALLOWED
const supportedOnStudio = chain.studioHosted || chain.productDeployStatus.studio === ChainProductStatus.ALLOWED
const supportedOnNetwork = chain.networkPublishChainAllowStatusMap != null && !chain.testnet
if (!supportedOnHosted && !supportedOnStudio && !supportedOnNetwork) {
return null
}
return {
name: chain.name,
cliName: chain.graphCliName,
chainId: chain.chainId,
supportedOnHosted,
supportedOnStudio,
supportedOnNetwork,
substreams: chain.substreams,
isBeta: chain.graphCliName !== 'mainnet', // TODO: Include a `beta` property in `@edgeandnode/common`?
}
})
.filter(isNotNull),
)
}