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>
pull/97/head
Paul Balaji 4 months ago committed by GitHub
parent 8c8c1c8550
commit 90cfc39762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      src/components/search/SearchFilterBar.tsx
  2. 6
      src/consts/config.ts
  3. 7
      src/features/chains/utils.ts

@ -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);

@ -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];

@ -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);
}

Loading…
Cancel
Save