Skip to content

Commit

Permalink
unique chain ids in chain list
Browse files Browse the repository at this point in the history
  • Loading branch information
jubalm committed Nov 14, 2024
1 parent 90e2daf commit d5cedcc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/ts/components/ui-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<bigint | string, ChainEntry>()
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()]
}

0 comments on commit d5cedcc

Please sign in to comment.