Skip to content

Commit 03c2190

Browse files
committed
Fix Popular chain missing icons on dashboard (#4562)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR updates the `connect-wallet` component to include support for popular chains with metadata. ### Detailed summary - Added `useSupportedChainsRecord` import - Added `chainsRecord` state - Added `popularChainsWithMeta` state - Updated `chainSections` to use `popularChainsWithMeta` - Updated dependencies for `useMemo` in `chainSections` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 22e066c commit 03c2190

File tree

1 file changed

+11
-3
lines changed
  • apps/dashboard/src/@3rdweb-sdk/react/components/connect-wallet

1 file changed

+11
-3
lines changed

apps/dashboard/src/@3rdweb-sdk/react/components/connect-wallet/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { getSDKTheme } from "app/components/sdk-component-theme";
77
import { CustomChainRenderer } from "components/selects/CustomChainRenderer";
88
import { mapV4ChainToV5Chain } from "contexts/map-chains";
99
import { useTrack } from "hooks/analytics/useTrack";
10-
import { useSupportedChains } from "hooks/chains/configureChains";
10+
import {
11+
useSupportedChains,
12+
useSupportedChainsRecord,
13+
} from "hooks/chains/configureChains";
1114
import {
1215
useAddRecentlyUsedChainId,
1316
useRecentlyUsedChains,
@@ -37,12 +40,17 @@ export const CustomConnectWallet = (props: {
3740
// const setIsNetworkConfigModalOpen = useSetIsNetworkConfigModalOpen();
3841
const t = theme === "light" ? "light" : "dark";
3942
const allv4Chains = useSupportedChains();
43+
const chainsRecord = useSupportedChainsRecord();
4044
const favChainsQuery = useFavoriteChains();
4145
const setIsNetworkConfigModalOpen = useSetIsNetworkConfigModalOpen();
4246
const allChains = useMemo(() => {
4347
return allv4Chains.map(mapV4ChainToV5Chain);
4448
}, [allv4Chains]);
4549

50+
const popularChainsWithMeta = useMemo(() => {
51+
return popularChains.map((x) => chainsRecord[x.id] || x);
52+
}, [chainsRecord]);
53+
4654
const chainSections = useMemo(() => {
4755
return [
4856
{
@@ -51,14 +59,14 @@ export const CustomConnectWallet = (props: {
5159
},
5260
{
5361
label: "Popular",
54-
chains: popularChains,
62+
chains: popularChainsWithMeta.map(mapV4ChainToV5Chain),
5563
},
5664
{
5765
label: "Recent",
5866
chains: recentChainsv4.map(mapV4ChainToV5Chain),
5967
},
6068
];
61-
}, [recentChainsv4, favChainsQuery.data]);
69+
}, [recentChainsv4, favChainsQuery.data, popularChainsWithMeta]);
6270

6371
// ensures login status on pages that need it
6472
const { isLoading, isLoggedIn } = useLoggedInUser();

0 commit comments

Comments
 (0)