diff --git a/app/ts/components/ui-utils.tsx b/app/ts/components/ui-utils.tsx index 49f3191e..6cb9e9fd 100644 --- a/app/ts/components/ui-utils.tsx +++ b/app/ts/components/ui-utils.tsx @@ -9,6 +9,7 @@ import { checksummedAddress } from '../utils/bigint.js' import { PopupOrTabId } from '../types/websiteAccessTypes.js' import { checkAndThrowRuntimeLastError, safeGetTab, safeGetWindow, updateTabIfExists, updateWindowIfExists } from '../utils/requests.js' import { ChainEntry, RpcEntries } from '../types/rpc.js' +import { CHAIN_NAMES } from '../utils/chainNames.js' function assertIsNode(e: EventTarget | null): asserts e is Node { if (!e || !('nodeType' in e)) { @@ -177,5 +178,11 @@ export const getAddressBookEntryOrAFiller = (addressMetaData: readonly AddressBo } export const rpcEntriesToChainEntriesWithAllChainsEntry = (rpcEntries: RpcEntries): readonly ChainEntry[] => { - return [ ...rpcEntries.map((rpcEntry) => ({ name: rpcEntry.name, chainId: rpcEntry.chainId })), { name: 'All Chains', chainId: 'AllChains' as const }] + const entries = rpcEntries.map(({ chainId }): [string, ChainEntry] => { + const chainIdString = chainId.toString() + return [chainIdString, { chainId, name: CHAIN_NAMES.get(chainIdString) || `Chain ID: ${ chainIdString }` }] + }) + const chainsMap = new Map(entries) + chainsMap.set('AllChains', { name: 'All Chains', chainId: 'AllChains' }) + return [...chainsMap.values()] }