Skip to content

Commit 9ba983e

Browse files
Merge pull request #327 from reown-com/fix/duplicated-wallets
fix: deduplicate wallets in all-wallets view
2 parents e6fa8a9 + bdc0388 commit 9ba983e

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

.changeset/shaggy-moose-tan.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@reown/appkit-scaffold-react-native': patch
3+
'@reown/appkit-ethers5-react-native': patch
4+
'@reown/appkit-common-react-native': patch
5+
'@reown/appkit-ethers-react-native': patch
6+
'@reown/appkit-wagmi-react-native': patch
7+
'@reown/appkit-core-react-native': patch
8+
'@reown/appkit-siwe-react-native': patch
9+
'@reown/appkit-ui-react-native': patch
10+
'@reown/appkit-auth-ethers-react-native': patch
11+
'@reown/appkit-auth-wagmi-react-native': patch
12+
'@reown/appkit-coinbase-ethers-react-native': patch
13+
'@reown/appkit-coinbase-wagmi-react-native': patch
14+
'@reown/appkit-scaffold-utils-react-native': patch
15+
'@reown/appkit-wallet-react-native': patch
16+
---
17+
18+
fix: deduplicate wallets in all wallet list

packages/scaffold/src/partials/w3m-all-wallets-list/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ export function AllWalletsList({ columns, itemWidth, onItemPress }: AllWalletsLi
3838
const preloadedWallets = installed.length + featured.length + recommended.length;
3939
const loadingItems = columns - ((100 + preloadedWallets) % columns);
4040

41-
const walletList = [
41+
const combinedWallets = [
4242
...(customWallets ?? []),
4343
...installed,
4444
...featured,
4545
...recommended,
46-
...wallets,
46+
...wallets
47+
];
48+
49+
// Deduplicate by wallet ID
50+
const uniqueWallets = Array.from(
51+
new Map(combinedWallets.map(wallet => [wallet?.id, wallet])).values()
52+
).filter(wallet => wallet?.id); // Filter out any undefined wallets
53+
54+
const walletList = [
55+
...uniqueWallets,
4756
...(pageLoading ? (Array.from({ length: loadingItems }) as WcWallet[]) : [])
4857
];
4958

@@ -132,7 +141,7 @@ export function AllWalletsList({ columns, itemWidth, onItemPress }: AllWalletsLi
132141
<Placeholder
133142
icon="warningCircle"
134143
iconColor="error-100"
135-
title="Oops, we couldnt load the wallets at the moment"
144+
title="Oops, we couldn't load the wallets at the moment"
136145
description={`This might be due to a temporary network issue.\nPlease try reloading to see if that helps.`}
137146
actionIcon="refresh"
138147
actionPress={initialFetch}

packages/scaffold/src/views/w3m-connect-view/components/all-wallet-list.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ export function AllWalletList({ itemStyle, onWalletPress, isWalletConnectEnabled
2323
const imageHeaders = ApiController._getApiHeaders();
2424
const RECENT_COUNT = recentWallets?.length && installed.length ? 1 : recentWallets?.length ?? 0;
2525

26-
const list = filterOutRecentWallets(
27-
recentWallets,
28-
[...installed, ...featured, ...recommended],
29-
RECENT_COUNT
30-
).slice(0, UiUtil.TOTAL_VISIBLE_WALLETS - RECENT_COUNT);
26+
const combinedWallets = [...installed, ...featured, ...recommended];
27+
28+
// Deduplicate by wallet ID
29+
const uniqueWallets = Array.from(
30+
new Map(combinedWallets.map(wallet => [wallet.id, wallet])).values()
31+
);
32+
33+
const list = filterOutRecentWallets(recentWallets, uniqueWallets, RECENT_COUNT).slice(
34+
0,
35+
UiUtil.TOTAL_VISIBLE_WALLETS - RECENT_COUNT
36+
);
3137

3238
if (!isWalletConnectEnabled || !list?.length) {
3339
return null;

0 commit comments

Comments
 (0)