From d5cedcc70a7668a8adaacf505d4cdf9509c35fe9 Mon Sep 17 00:00:00 2001 From: Jubal Mabaquiao Date: Thu, 14 Nov 2024 15:13:57 +0800 Subject: [PATCH] unique chain ids in chain list --- app/ts/components/ui-utils.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/ts/components/ui-utils.tsx b/app/ts/components/ui-utils.tsx index 49f3191e..6aceb2cb 100644 --- a/app/ts/components/ui-utils.tsx +++ b/app/ts/components/ui-utils.tsx @@ -177,5 +177,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 chainsMap = new Map() + for (const { chainId, name } of rpcEntries) { + if (chainsMap.has(chainId)) continue + chainsMap.set(chainId, { name, chainId }) + } + chainsMap.set('AllChains', { name: 'All Chains', chainId: 'AllChains' }) + return [...chainsMap.values()] }