Skip to content

Commit 654ec64

Browse files
Update utils.ts
REVIEW REQUIRED. Removed hard-coded Token API networks, added what is hopefully an automatic fetch for Token API networks. PLEASE REVIEW THIS PR. It was implemented with advice from Claude. Not sure where these parameters are used, so I am unable to check if it works. Happy to let docs team make this update instead, but on the off chance this is correct feel free to merge.
1 parent b83b32c commit 654ec64

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

website/src/supportedNetworks/utils.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ export const MONO_ICON_NETWORKS = [
2525
'zksync-era-sepolia',
2626
]
2727

28-
// Networks with Token API support (TODO: remove once the registry has this information)
29-
export const TOKEN_API_NETWORKS = [
30-
'mainnet',
31-
'base',
32-
'bsc',
33-
'arbitrum-one',
34-
'matic',
35-
'optimism',
36-
'unichain',
37-
'avalanche',
38-
]
39-
4028
export const getIconVariant = (networkId: string): 'mono' | 'branded' => {
4129
return MONO_ICON_NETWORKS.includes(networkId) ? 'mono' : 'branded'
4230
}
@@ -60,6 +48,12 @@ export const getFirehoseSupportLevel = (network: Network) => {
6048
if (firehoseCount >= 2) return 'full'
6149
return 'basic'
6250
}
51+
export const getTokenApiSupportLevel = (network: Network) => {
52+
const tokenApiCount = network.services.tokenApi?.length || 0
53+
if (tokenApiCount === 0) return 'none'
54+
// Token API is currently defined as a binary yes/no, so we'll consider that as 'full' support
55+
return 'full'
56+
}
6357

6458
export async function getSupportedNetworks() {
6559
const registry = await NetworksRegistry.fromLatestVersion()
@@ -69,7 +63,7 @@ export async function getSupportedNetworks() {
6963
const subgraphs = Boolean(network.services.subgraphs?.length)
7064
const substreams = Boolean(network.services.substreams?.length)
7165
const firehose = Boolean(network.services.firehose?.length)
72-
const tokenApi = TOKEN_API_NETWORKS.includes(network.id)
66+
const tokenApi = Boolean(network.services.tokenApi?.length)
7367
if (!subgraphs && !substreams && !firehose && !tokenApi) {
7468
return []
7569
}
@@ -85,6 +79,7 @@ export async function getSupportedNetworks() {
8579
subgraphsSupportLevel: getSubgraphsSupportLevel(network),
8680
substreamsSupportLevel: getSubstreamsSupportLevel(network),
8781
firehoseSupportLevel: getFirehoseSupportLevel(network),
82+
tokenApiSupportLevel: getTokenApiSupportLevel(network),
8883
},
8984
]
9085
})

0 commit comments

Comments
 (0)