Skip to content

Commit 70c4879

Browse files
committed
refactor: array to map
1 parent 2fccaef commit 70c4879

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

ui/components/multichain-accounts/multichain-address-rows-hovered-list/multichain-address-rows-hovered-list.test.tsx renamed to ui/components/multichain-accounts/multichain-address-rows-hovered-list/multichain-hovered-address-rows-hovered-list.test.tsx

File renamed without changes.

ui/components/multichain-accounts/multichain-address-rows-hovered-list/multichain-hovered-address-rows-hovered-list.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import { MULTICHAIN_ACCOUNT_ADDRESS_LIST_PAGE_ROUTE } from '../../../helpers/con
2424
import { MultichainAggregatedAddressListRow } from './multichain-aggregated-list-row';
2525

2626
// Priority networks that should appear first (using CAIP chain IDs)
27-
const PRIORITY_CHAIN_IDS: CaipChainId[] = [
28-
'eip155:1' as CaipChainId, // Ethereum mainnet
29-
'bip122:000000000019d6689c085ae165831e93' as CaipChainId, // Bitcoin mainnet
30-
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' as CaipChainId, // Solana mainnet
31-
'tron:0x2b6653dc' as CaipChainId, // Tron mainnet
32-
];
27+
const PRIORITY_CHAIN_IDS = new Map<CaipChainId, number>([
28+
['eip155:1' as CaipChainId, 0], // Ethereum mainnet
29+
['bip122:000000000019d6689c085ae165831e93' as CaipChainId, 1], // Bitcoin mainnet
30+
['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' as CaipChainId, 2], // Solana mainnet
31+
['tron:0x2b6653dc' as CaipChainId, 3], // Tron mainnet
32+
]);
3333

3434
export type MultichainAddressRowsListProps = {
3535
/**
@@ -108,9 +108,16 @@ export const MultichainHoveredAddressRowsList = ({
108108

109109
groupedItems.forEach((item) => {
110110
// Check if any of the scopes are in priority list
111-
const priorityIndex = PRIORITY_CHAIN_IDS.findIndex((chainId) =>
112-
item.scopes.includes(chainId),
113-
);
111+
let priorityIndex = -1;
112+
113+
// Check each scope for priority chain membership
114+
for (const scope of item.scopes) {
115+
const index = PRIORITY_CHAIN_IDS.get(scope);
116+
if (index !== undefined) {
117+
priorityIndex = index;
118+
break;
119+
}
120+
}
114121

115122
if (priorityIndex > -1) {
116123
// Store with priority index for proper ordering

0 commit comments

Comments
 (0)