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
Changes from 1 commit
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
Next Next commit
fix: Fix the issue of to token cannot be selected after exchange chain
wenty22 committed Jan 22, 2025
commit 213ee2ca50d0b7ddd4f1c95fbd5507dc83f62718
Original file line number Diff line number Diff line change
@@ -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;
}

Original file line number Diff line number Diff line change
@@ -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) {
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ export function BridgeRoutes() {
dispatch,
bridgeConfig.http.refetchingInterval,
isManuallyReload,
toToken,
]);

if (isBase) {
Original file line number Diff line number Diff line change
@@ -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) {
Original file line number Diff line number Diff line change
@@ -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));
Original file line number Diff line number Diff line change
@@ -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,
],
);