Skip to content

Commit

Permalink
Minor improvement on the copy address modal's search logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Dec 29, 2023
1 parent 3f743ec commit 920052b
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from "../../../../components/transition";
import { IChainInfoImpl } from "@keplr-wallet/stores";
import Color from "color";
import { DenomHelper } from "@keplr-wallet/common";

export const CopyAddressScene: FunctionComponent<{
close: () => void;
Expand Down Expand Up @@ -115,23 +116,34 @@ export const CopyAddressScene: FunctionComponent<{
return false;
}

const s = search.trim();
const s = search.trim().toLowerCase();
if (s.length === 0) {
return true;
}

if (address.chainInfo.chainId.includes(s)) {
if (address.chainInfo.chainId.toLowerCase().includes(s)) {
return true;
}
if (address.chainInfo.chainName.includes(s)) {
if (address.chainInfo.chainName.toLowerCase().includes(s)) {
return true;
}
const bech32Split = address.bech32Address.split("1");
if (bech32Split.length > 0) {
if (bech32Split[0].includes(s)) {
if (bech32Split[0].toLowerCase().includes(s)) {
return true;
}
}

for (const currency of address.chainInfo.currencies) {
if (
new DenomHelper(currency.coinMinimalDenom).type === "native" &&
!currency.coinMinimalDenom.startsWith("ibc/")
) {
if (currency.coinDenom.toLowerCase().includes(s)) {
return true;
}
}
}
})
.sort((a, b) => {
const aPriority = sortPriorities[a.chainInfo.chainIdentifier];
Expand Down

0 comments on commit 920052b

Please sign in to comment.