Skip to content

Commit

Permalink
Merge pull request #175 from bnb-chain/hotfix/ChainSearch
Browse files Browse the repository at this point in the history
Hotfix/chain search
  • Loading branch information
Halibao-Lala authored Dec 6, 2024
2 parents 54cf211 + 0c58bf2 commit 741b022
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 53 deletions.
5 changes: 0 additions & 5 deletions .release/.changeset/light-emus-switch.md

This file was deleted.

13 changes: 0 additions & 13 deletions .release/.changeset/pre.json

This file was deleted.

5 changes: 0 additions & 5 deletions .release/.changeset/sharp-dryers-hear.md

This file was deleted.

5 changes: 0 additions & 5 deletions .release/.changeset/slimy-crabs-know.md

This file was deleted.

15 changes: 15 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @bnb-chain/canonical-bridge-widget

## 0.5.8

### Patch Changes

- 49e31fc: Update token list sort rules
- f86dcd0: Show token address on `You Receive`
- f86dcd0: Support searching token by address
- f86dcd0: Show token address on `You Receive`

## 0.5.8-alpha.5

### Patch Changes

- Update token list sort rules

## 0.5.8-alpha.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-widget",
"version": "0.5.8-alpha.4",
"version": "0.5.8",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function SourceNetworkModal(props: SourceNetworkModalProps) {
});

const { isNoResult, result, onSearch } = useSearch({
filter: (item, keyword) => item.name.toLowerCase().includes(keyword),
filter: (item, keyword) => item.name.toLowerCase().includes(keyword.toLowerCase()),
sorter: (a) => (fromChain?.id === a.id ? -1 : 0),
data: fromChains,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,11 @@ export function useTokenList(tokens: IBridgeToken[] = [], keyword?: string) {
const sortedTokens = sortTokens({
tokens: tmpTokens,
orders: transferConfig.order?.tokens,
})
.sort((a, b) => {
if (keyword) {
const isA = isChainOrTokenCompatible(a);
const isB = isChainOrTokenCompatible(b);
const findA = a.displaySymbol?.toLowerCase()?.includes(keyword?.toLowerCase());
const findB = b.displaySymbol?.toLowerCase()?.includes(keyword?.toLowerCase());

if (findA && isA) {
return -1;
}
if (findB && isB) {
return 1;
}
}
return 0;
})
.sort((a) => {
return isSameAddress(a.address, selectedToken?.address) && isChainOrTokenCompatible(a)
? -1
: 0;
});
}).sort((a) => {
return isSameAddress(a.address, selectedToken?.address) && isChainOrTokenCompatible(a)
? -1
: 0;
});

return sortedTokens;
}, [
Expand All @@ -68,7 +51,6 @@ export function useTokenList(tokens: IBridgeToken[] = [], keyword?: string) {
getTokenBalance,
getTokenPrice,
selectedToken?.address,
keyword,
]);

return { data: sortedTokens, isLoading: isLoadingTokenBalances || isLoadingTokenPrices };
Expand Down

0 comments on commit 741b022

Please sign in to comment.