From 90cfc39762995967bbc1ec993f87b111ef53257d Mon Sep 17 00:00:00 2001 From: Paul Balaji <10051819+paulbalaji@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:11:35 +0100 Subject: [PATCH] fix: don't show unscraped chain in dropdown (#95) fix: don't show unscraped chain in dropdown --------- Signed-off-by: pbio <10051819+paulbalaji@users.noreply.github.com> --- src/components/search/SearchFilterBar.tsx | 12 ++++++++++-- src/consts/config.ts | 6 ++++++ src/features/chains/utils.ts | 7 +++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/search/SearchFilterBar.tsx b/src/components/search/SearchFilterBar.tsx index 5b3ab1a..c62b549 100644 --- a/src/components/search/SearchFilterBar.tsx +++ b/src/components/search/SearchFilterBar.tsx @@ -5,7 +5,12 @@ import { useMemo, useState } from 'react'; import { ChainMetadata } from '@hyperlane-xyz/sdk'; import { arrayToObject } from '@hyperlane-xyz/utils'; -import { getChainDisplayName, isEvmChain, isPiChain } from '../../features/chains/utils'; +import { + getChainDisplayName, + isEvmChain, + isPiChain, + isUnscrapedEvmChain, +} from '../../features/chains/utils'; import GearIcon from '../../images/icons/gear.svg'; import { useMultiProvider } from '../../store'; import { Color } from '../../styles/Color'; @@ -88,7 +93,10 @@ function ChainMultiSelector({ // Filtering to EVM is necessary to prevent errors until cosmos support is added // https://github.com/hyperlane-xyz/hyperlane-explorer/issues/61 const coreEvmChains = chains.filter( - (c) => isEvmChain(multiProvider, c.chainId) && !isPiChain(multiProvider, c.chainId), + (c) => + isEvmChain(multiProvider, c.chainId) && + !isPiChain(multiProvider, c.chainId) && + !isUnscrapedEvmChain(multiProvider, c.chainId), ); const mainnets = coreEvmChains.filter((c) => !c.isTestnet); const testnets = coreEvmChains.filter((c) => !!c.isTestnet); diff --git a/src/consts/config.ts b/src/consts/config.ts index 49a0344..f81c706 100644 --- a/src/consts/config.ts +++ b/src/consts/config.ts @@ -1,3 +1,5 @@ +import { CoreChain } from '@hyperlane-xyz/registry'; + const isDevMode = process?.env?.NODE_ENV === 'development'; const version = process?.env?.NEXT_PUBLIC_VERSION ?? null; const explorerApiKeys = JSON.parse(process?.env?.EXPLORER_API_KEYS || '{}'); @@ -15,3 +17,7 @@ export const config: Config = Object.freeze({ apiUrl: 'https://explorer4.hasura.app/v1/graphql', explorerApiKeys, }); + +// Based on https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/typescript/infra/config/environments/mainnet3/agent.ts +// Based on https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/typescript/infra/config/environments/testnet4/agent.ts +export const unscrapedEvmChains = [CoreChain.proteustestnet, CoreChain.sei, CoreChain.viction]; diff --git a/src/features/chains/utils.ts b/src/features/chains/utils.ts index 3ab30c7..e9c126e 100644 --- a/src/features/chains/utils.ts +++ b/src/features/chains/utils.ts @@ -2,6 +2,7 @@ import { CoreChain, CoreChains, IRegistry } from '@hyperlane-xyz/registry'; import { ChainMap, MultiProvider } from '@hyperlane-xyz/sdk'; import { ProtocolType, toTitleCase } from '@hyperlane-xyz/utils'; +import { unscrapedEvmChains } from '../../consts/config'; import { Environment } from '../../consts/environments'; import { ChainConfig } from './chainConfig'; @@ -43,3 +44,9 @@ export function isEvmChain(multiProvider: MultiProvider, chainIdOrName: number | const protocol = multiProvider.tryGetProtocol(chainIdOrName); return protocol === ProtocolType.Ethereum; } + +// TODO: Remove once we fetch CoreChains dynamically from the DB https://github.com/hyperlane-xyz/hyperlane-explorer/issues/74 +export function isUnscrapedEvmChain(multiProvider: MultiProvider, chainIdOrName: number | string) { + const chainName = multiProvider.tryGetChainName(chainIdOrName); + return chainName && unscrapedEvmChains.includes(chainName as CoreChain); +}