From 49e31fcac8ec6fa83a68fad8b93764684abb2b66 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Fri, 6 Dec 2024 17:57:15 +0800 Subject: [PATCH 1/3] feat: Update token list sort rules --- .release/.changeset/eighty-clouds-jog.md | 5 ++++ .release/.changeset/pre.json | 1 + packages/canonical-bridge-widget/CHANGELOG.md | 6 ++++ packages/canonical-bridge-widget/package.json | 2 +- .../SelectModal/hooks/useTokenList.ts | 28 ++++--------------- 5 files changed, 18 insertions(+), 24 deletions(-) create mode 100644 .release/.changeset/eighty-clouds-jog.md diff --git a/.release/.changeset/eighty-clouds-jog.md b/.release/.changeset/eighty-clouds-jog.md new file mode 100644 index 00000000..d50b8e30 --- /dev/null +++ b/.release/.changeset/eighty-clouds-jog.md @@ -0,0 +1,5 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +--- + +Update token list sort rules diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json index a2f4fa95..21a91838 100644 --- a/.release/.changeset/pre.json +++ b/.release/.changeset/pre.json @@ -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" diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 37efd502..6289a2d4 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -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 diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index eb4ef0ed..d9b42cba 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -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, diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts index d8276d7d..41fe26b8 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts +++ b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts @@ -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; }, [ @@ -68,7 +51,6 @@ export function useTokenList(tokens: IBridgeToken[] = [], keyword?: string) { getTokenBalance, getTokenPrice, selectedToken?.address, - keyword, ]); return { data: sortedTokens, isLoading: isLoadingTokenBalances || isLoadingTokenPrices }; From 5f24b699f2554477b5a917d7597ed5207054798d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 6 Dec 2024 10:08:52 +0000 Subject: [PATCH 2/3] chore: Update versions --- .release/.changeset/eighty-clouds-jog.md | 5 ----- .release/.changeset/light-emus-switch.md | 5 ----- .release/.changeset/pre.json | 14 -------------- .release/.changeset/sharp-dryers-hear.md | 5 ----- .release/.changeset/slimy-crabs-know.md | 5 ----- packages/canonical-bridge-widget/CHANGELOG.md | 9 +++++++++ packages/canonical-bridge-widget/package.json | 2 +- 7 files changed, 10 insertions(+), 35 deletions(-) delete mode 100644 .release/.changeset/eighty-clouds-jog.md delete mode 100644 .release/.changeset/light-emus-switch.md delete mode 100644 .release/.changeset/pre.json delete mode 100644 .release/.changeset/sharp-dryers-hear.md delete mode 100644 .release/.changeset/slimy-crabs-know.md diff --git a/.release/.changeset/eighty-clouds-jog.md b/.release/.changeset/eighty-clouds-jog.md deleted file mode 100644 index d50b8e30..00000000 --- a/.release/.changeset/eighty-clouds-jog.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch ---- - -Update token list sort rules diff --git a/.release/.changeset/light-emus-switch.md b/.release/.changeset/light-emus-switch.md deleted file mode 100644 index a63eadc9..00000000 --- a/.release/.changeset/light-emus-switch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@bnb-chain/canonical-bridge-widget': patch ---- - -Show token address on `You Receive` diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json deleted file mode 100644 index 21a91838..00000000 --- a/.release/.changeset/pre.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "mode": "pre", - "tag": "alpha", - "initialVersions": { - "@bnb-chain/canonical-bridge-sdk": "0.4.2", - "@bnb-chain/canonical-bridge-widget": "0.5.7" - }, - "changesets": [ - "eighty-clouds-jog", - "light-emus-switch", - "sharp-dryers-hear", - "slimy-crabs-know" - ] -} diff --git a/.release/.changeset/sharp-dryers-hear.md b/.release/.changeset/sharp-dryers-hear.md deleted file mode 100644 index 4c231116..00000000 --- a/.release/.changeset/sharp-dryers-hear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch ---- - -Support searching token by address diff --git a/.release/.changeset/slimy-crabs-know.md b/.release/.changeset/slimy-crabs-know.md deleted file mode 100644 index d819d83e..00000000 --- a/.release/.changeset/slimy-crabs-know.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bnb-chain/canonical-bridge-widget": patch ---- - -Show token address on `You Receive` diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 6289a2d4..abb9c35b 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,14 @@ # @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 diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index d9b42cba..bc4e6ce7 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", - "version": "0.5.8-alpha.5", + "version": "0.5.8", "description": "canonical bridge widget", "author": "bnb-chain", "private": false, From 0c58bf277bb8cf15f3d579d084d92bec00ee212f Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 6 Dec 2024 22:41:37 +1000 Subject: [PATCH 3/3] fix: Fix chain id search issue --- .../aggregator/components/SelectModal/SourceNetworkModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/SourceNetworkModal.tsx b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/SourceNetworkModal.tsx index 8d30aac6..35fde603 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/SourceNetworkModal.tsx +++ b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/SourceNetworkModal.tsx @@ -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, });