Skip to content

Commit 7718cf4

Browse files
committed
Add assetDisplayName as searchable field in wallet search
Include assetDisplayName from currencyInfo as a searchable field for wallet and create-wallet searches. This allows users to search by the asset's display name (e.g., 'Ethereum') in addition to other existing searchable fields.
1 parent 7befb89 commit 7718cf4

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/__tests__/scenes/__snapshots__/CreateWalletSelectCryptoScene.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
824824
data={
825825
[
826826
{
827+
"assetDisplayName": "Ethereum",
827828
"currencyCode": "ETH",
828829
"displayName": "Ethereum",
829830
"key": "create-wallet:ethereum-ethereum",

src/components/services/SortedWalletList.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export function searchWalletList(
285285

286286
// Grab wallet and token information:
287287
const { currencyCode, displayName } = token ?? wallet.currencyInfo
288-
const { chainDisplayName } = wallet.currencyInfo
288+
const { assetDisplayName, chainDisplayName } = wallet.currencyInfo
289289
const name = getWalletName(wallet)
290290

291291
const contractAddress = token?.networkLocation?.contractAddress ?? ''
@@ -295,6 +295,7 @@ export function searchWalletList(
295295
return (
296296
normalizeForSearch(currencyCode).includes(term) ||
297297
normalizeForSearch(displayName).includes(term) ||
298+
normalizeForSearch(assetDisplayName).includes(term) ||
298299
normalizeForSearch(chainDisplayName).includes(term) ||
299300
normalizeForSearch(name).includes(term) ||
300301
normalizeForSearch(contractAddress).includes(term)

src/selectors/getCreateWalletList.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface WalletCreateItem {
2525
walletType?: string
2626

2727
// Used for filtering
28+
assetDisplayName?: string
2829
networkLocation?: JsonObject
2930
}
3031

@@ -127,14 +128,15 @@ export const getCreateWalletList = (
127128
if (filterActivation && requiresActivation(pluginId)) continue
128129

129130
const currencyConfig = account.currencyConfig[pluginId]
130-
const { currencyCode, displayName, walletType } =
131+
const { assetDisplayName, currencyCode, displayName, walletType } =
131132
currencyConfig.currencyInfo
132133

133134
if (isAllowed(pluginId, null))
134135
if (!disableLegacy && segwitSpecialCases.has(pluginId)) {
135136
newWallets.push({
136137
type: 'create',
137138
key: `create-${walletType}-bip49-${pluginId}`,
139+
assetDisplayName,
138140
currencyCode,
139141
displayName: `${displayName} (Segwit)`,
140142
keyOptions: { format: 'bip49' },
@@ -145,6 +147,7 @@ export const getCreateWalletList = (
145147
newWallets.push({
146148
type: 'create',
147149
key: `create-${walletType}-bip44-${pluginId}`,
150+
assetDisplayName,
148151
currencyCode,
149152
displayName: `${displayName} (no Segwit)`,
150153
keyOptions: { format: 'bip44' },
@@ -156,6 +159,7 @@ export const getCreateWalletList = (
156159
newWallets.push({
157160
type: 'create',
158161
key: `create-${walletType}-${pluginId}`,
162+
assetDisplayName,
159163
currencyCode,
160164
displayName,
161165
keyOptions: {},
@@ -234,6 +238,7 @@ export const filterWalletCreateItemListBySearchText = (
234238
const out: WalletCreateItem[] = []
235239
for (const item of createWalletList) {
236240
const {
241+
assetDisplayName,
237242
currencyCode,
238243
displayName,
239244
networkLocation = {},
@@ -249,6 +254,13 @@ export const filterWalletCreateItemListBySearchText = (
249254
) {
250255
return true
251256
}
257+
// Search assetDisplayName for mainnet create items
258+
if (
259+
assetDisplayName != null &&
260+
normalizeForSearch(assetDisplayName).includes(term)
261+
) {
262+
return true
263+
}
252264
// Search pluginId for mainnet create items
253265
if (walletType != null && normalizeForSearch(pluginId).includes(term)) {
254266
return true

0 commit comments

Comments
 (0)