Skip to content

Commit c8c7a3f

Browse files
committed
update hooks for isswap on prepare bridge page
1 parent d68ca52 commit c8c7a3f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

ui/pages/bridge/hooks/useDestinationAccount.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ import {
55
getSelectedEvmInternalAccount,
66
getSelectedInternalAccount,
77
} from '../../../selectors';
8-
import { getToChain, getFromChain } from '../../../ducks/bridge/selectors';
8+
import { getToChain } from '../../../ducks/bridge/selectors';
99
import { getLastSelectedSolanaAccount } from '../../../selectors/multichain';
1010
import type { DestinationAccount } from '../prepare/types';
1111

12-
export const useDestinationAccount = () => {
12+
export const useDestinationAccount = (isSwap: boolean) => {
1313
const [selectedDestinationAccount, setSelectedDestinationAccount] =
1414
useState<DestinationAccount | null>(null);
1515

1616
const selectedEvmAccount = useSelector(getSelectedEvmInternalAccount);
1717
const selectedSolanaAccount = useSelector(getLastSelectedSolanaAccount);
1818
const currentlySelectedAccount = useSelector(getSelectedInternalAccount);
1919

20-
const fromChain = useSelector(getFromChain);
2120
const toChain = useSelector(getToChain);
2221
const isDestinationSolana = toChain && isSolanaChainId(toChain.chainId);
2322

@@ -29,9 +28,8 @@ export const useDestinationAccount = () => {
2928
return;
3029
}
3130

32-
// Check if it's a swap (same chain)
33-
const isSwap = fromChain?.chainId === toChain?.chainId;
34-
31+
// Use isSwap parameter to determine behavior
32+
// This preserves legacy behavior when unified UI is disabled
3533
if (isSwap) {
3634
// For swaps, always use the currently selected account
3735
setSelectedDestinationAccount(currentlySelectedAccount);
@@ -46,8 +44,8 @@ export const useDestinationAccount = () => {
4644
selectedSolanaAccount,
4745
selectedEvmAccount,
4846
toChain,
49-
fromChain,
5047
currentlySelectedAccount,
48+
isSwap,
5149
]);
5250

5351
return { selectedDestinationAccount, setSelectedDestinationAccount };

ui/pages/bridge/prepare/prepare-bridge-page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ const PrepareBridgePage = () => {
150150
getIsUnifiedUIEnabled(state, fromChain?.chainId),
151151
);
152152

153-
// Determine if this is a swap based on unified UI setting
154-
const isSwap = isUnifiedUIEnabled
155-
? useSelector(getIsSwap) // Use quote request params when unified
156-
: useIsMultichainSwap(); // Use URL params for legacy behavior
153+
// Check the two types of swaps
154+
const isSwapFromQuote = useSelector(getIsSwap);
155+
const isSwapFromUrl = useIsMultichainSwap();
156+
157+
// Use the appropriate value based on unified UI setting
158+
const isSwap = isUnifiedUIEnabled ? isSwapFromQuote : isSwapFromUrl;
157159

158160
const fromToken = useSelector(getFromToken);
159161
const fromTokens = useSelector(getTokenList) as TokenListMap;
@@ -243,7 +245,7 @@ const PrepareBridgePage = () => {
243245
const { tokenAlert } = useTokenAlerts();
244246
const srcTokenBalance = useLatestBalance(fromToken);
245247
const { selectedDestinationAccount, setSelectedDestinationAccount } =
246-
useDestinationAccount();
248+
useDestinationAccount(isSwap);
247249

248250
const {
249251
filteredTokenListGenerator: toTokenListGenerator,

0 commit comments

Comments
 (0)