-
Notifications
You must be signed in to change notification settings - Fork 121
/
supportedNetworks.tsx
99 lines (89 loc) · 3.7 KB
/
supportedNetworks.tsx
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 { CodeInline, Table } from '@graphprotocol/nextra-theme'
import type { ExecutionResult } from 'graphql'
import { ChainProductStatus, SupportedNetworkMap } from '@edgeandnode/common'
import { execute, SupportedNetworksDocument, type SupportedNetworksQuery } from '@/.graphclient'
import { useI18n } from '@/i18n'
export async function getSupportedNetworks() {
// Get the IDs of the networks that are fully supported (as opposed to supported only by the upgrade indexer) using the EBO subgraph
const supportedNetworksQueryResult: ExecutionResult<SupportedNetworksQuery> = await execute(SupportedNetworksDocument)
const fullySupportedNetworkIds = (supportedNetworksQueryResult.data?.networks ?? []).map((network) => network.id)
// Fallback in case the GraphQL query fails (last updated 2024-06-04)
if (fullySupportedNetworkIds.length === 0) {
fullySupportedNetworkIds.push(
'eip155:1',
'eip155:100',
'eip155:137',
'eip155:250',
'eip155:42161',
'eip155:42220',
'eip155:43114',
'eip155:10',
)
}
return Array.from(SupportedNetworkMap.values()).flatMap((network) =>
Array.from(network.chains)
.map((chain) => {
const supportedOnHostedService = chain.productDeployStatus.hostedService === ChainProductStatus.ALLOWED
const supportedOnStudio = chain.productDeployStatus.studio === ChainProductStatus.ALLOWED
const integrationType = ['evm', 'near', 'cosmos', 'osmosis', 'ar'].includes(chain.network)
? chain.network
: 'substreams'
if (
!chain.graphCliName ||
(!supportedOnStudio && !supportedOnHostedService && integrationType !== 'substreams')
) {
return null as never // `as never` to work around the `.filter(Boolean)` below not narrowing the type
}
const fullySupportedOnNetwork =
network.id === 'evm' && fullySupportedNetworkIds.includes(`eip155:${chain.chainId}`)
return {
uid: chain.uid,
name: chain.name,
cliName: chain.graphCliName,
chainId: chain.chainId,
testnet: chain.testnet,
supportedOnHostedService,
supportedOnStudio,
fullySupportedOnNetwork,
substreams: chain.substreams ?? [],
integrationType,
}
})
.filter(Boolean),
)
}
export function SupportedNetworksTable({ networks }: { networks: Awaited<ReturnType<typeof getSupportedNetworks>> }) {
const { t } = useI18n()
return (
<Table>
<tbody>
<tr>
<th>{t('supportedNetworks.network')}</th>
<th>{t('supportedNetworks.cliName')}</th>
<th align="center">{t('supportedNetworks.integrationType')}**</th>
<th align="center">{t('supportedNetworks.hostedService')}</th>
<th align="center">{t('supportedNetworks.subgraphStudio')}</th>
<th align="center">{t('supportedNetworks.decentralizedNetwork')}</th>
</tr>
{networks.map((network) => (
<tr key={network.cliName}>
<td>{network.name}</td>
<td>
<CodeInline>{network.cliName}</CodeInline>
</td>
<td align="center">{network.integrationType}</td>
<td align="center">{network.supportedOnHostedService ? '✓' : null}</td>
<td align="center">
{network.supportedOnStudio ? '✓' : null}
{network.substreams.includes('studio') ? <sup>†</sup> : null}
</td>
<td align="center">
{network.fullySupportedOnNetwork ? '✓' : null}
{!network.fullySupportedOnNetwork && network.supportedOnStudio ? '*' : null}
</td>
</tr>
))}
</tbody>
</Table>
)
}