Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix the issue of to token cannot be selected after exchange chain #297

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .release/.changeset/brown-suits-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bnb-chain/canonical-bridge-widget": patch
"@bnb-chain/canonical-bridge-sdk": patch
---

Fix the issue of to token cannot be selected after exchange chain
1 change: 1 addition & 0 deletions .release/.changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"changesets": [
"blue-goats-shave",
"brown-suits-matter",
"curvy-dingos-end",
"thick-donkeys-kneel"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,19 @@ export class BridgeProcessor extends WorkerHost {
return false;
}

let key: string | undefined;
const isNative = isNativeToken(tokenAddress, chainInfo.chainType);
const key = isNative ? `${chainId}` : `${chainId}:${tokenAddress}`;
if (isNative) {
key = `${chainId}`;
} else {
if (chainInfo.chainType === 'evm') {
key = `${chainId}:${tokenAddress.toLowerCase()}`;
} else {
key = `${chainId}:${tokenAddress}`;
}
}
const price = cmcPrices[key] ?? llamaPrices[key];

return !!price;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/canonical-bridge-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @bnb-chain/canonical-bridge-sdk

## 0.5.0-alpha.10

### Patch Changes

- Fix the issue of to token cannot be selected after exchange chain

## 0.5.0-alpha.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-sdk",
"version": "0.5.0-alpha.9",
"version": "0.5.0-alpha.10",
"description": "canonical bridge sdk",
"author": "bnb-chain",
"private": false,
Expand Down
8 changes: 8 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @bnb-chain/canonical-bridge-widget

## 0.6.0-alpha.15

### Patch Changes

- Fix the issue of to token cannot be selected after exchange chain
- Updated dependencies
- @bnb-chain/[email protected]

## 0.6.0-alpha.14

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions 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.6.0-alpha.14",
"version": "0.6.0-alpha.15",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
Expand Down Expand Up @@ -46,7 +46,7 @@
"@solana/web3.js": "^1",
"tronweb": "^6",
"@tronweb3/tronwallet-adapter-react-hooks": "^1",
"@bnb-chain/canonical-bridge-sdk": "^0.5.0-alpha.9"
"@bnb-chain/canonical-bridge-sdk": "^0.5.0-alpha.10"
},
"devDependencies": {
"@bnb-chain/canonical-bridge-sdk": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export function useSelection() {
// eslint-disable-next-line no-console
console.log('[aggregator]', `has multiple toTokens (${toTokens.length})`);
dispatch(setToTokens(toTokens));
dispatch(setToToken(undefined));
} else {
dispatch(setToTokens([]));
dispatch(setToToken(undefined));
}

if (toTokens.length === 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function BridgeRoutes() {
dispatch,
bridgeConfig.http.refetchingInterval,
isManuallyReload,
toToken,
]);

if (isBase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const ReceiveInfo = ({ onOpen }: ReceiveInfoProps) => {
const debouncedSendValue = useDebounce(sendValue, DEBOUNCE_DELAY);

useEffect(() => {
if (!isBase || !toToken) return;
if (!isBase || !toToken || !sendValue) return;

// On mobile
if (sendValue === debouncedSendValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function TransferOverview(props: TransferOverviewProps) {
const toToken = useAppSelector((state) => state.transfer.toToken);

useEffect(() => {
if (isBase || !toToken) return;
if (isBase || !toToken || !sendValue) return;

if (sendValue === debouncedSendValue) {
dispatch(setTransferActionInfo(undefined));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,27 +503,24 @@ export const useLoadingBridgeFees = () => {
fromChain,
toChain,
debouncedSendValue,
toToken,
bridgeSDK,
address,
publicClient,
toToken?.layerZero?.raw?.endpointID,
toToken?.stargate?.raw?.endpointID,
toToken?.meson?.raw?.id,
toToken?.deBridge?.raw?.address,
max_slippage,
tronAddress,
deBridgeAccessToken,
deBridgeReferralCode,
solanaAddress,
isSolanaAvailableToAccount,
feeReloadMaxTime,
onOpenFeeTimeoutModal,
formatMessage,
getToDecimals,
isWalletCompatible,
nativeToken,
preSelectRoute,
onOpenFailedGetQuoteModal,
onOpenFeeTimeoutModal,
feeReloadMaxTime,
preSelectRoute,
],
);

Expand Down
Loading