Skip to content

Commit

Permalink
feat: Update token list sort rules
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Dec 6, 2024
1 parent 34d21ec commit 49e31fc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .release/.changeset/eighty-clouds-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/canonical-bridge-widget": patch
---

Update token list sort rules
1 change: 1 addition & 0 deletions .release/.changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@bnb-chain/canonical-bridge-widget": "0.5.7"
},
"changesets": [
"eighty-clouds-jog",
"light-emus-switch",
"sharp-dryers-hear",
"slimy-crabs-know"
Expand Down
6 changes: 6 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @bnb-chain/canonical-bridge-widget

## 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-alpha.5",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
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 49e31fc

Please sign in to comment.