Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const useSwapBridgeNavigation = ({
bridgeViewMode: BridgeViewMode,
sourceTokenOverride?: BridgeToken,
destTokenOverride?: BridgeToken,
buttonLabel?: string,
) => {
// Use tokenOverride if provided, otherwise fall back to tokenBase
const effectiveSourceTokenBase = sourceTokenOverride ?? sourceTokenBase;
Expand Down Expand Up @@ -283,7 +284,7 @@ export const useSwapBridgeNavigation = ({
...(isFromNavbar
? {}
: { action_position: ActionPosition.SECOND_POSITION }),
button_label: strings('asset_overview.swap'),
button_label: buttonLabel ?? strings('asset_overview.swap'),
location: isFromNavbar
? ActionLocation.NAVBAR
: ActionLocation.ASSET_DETAILS,
Expand Down Expand Up @@ -328,11 +329,16 @@ export const useSwapBridgeNavigation = ({
const { networkModal } = useAddNetwork();

const goToSwaps = useCallback(
(tokenOverride?: BridgeToken, destTokenOverride?: BridgeToken) => {
(
tokenOverride?: BridgeToken,
destTokenOverride?: BridgeToken,
buttonLabel?: string,
) => {
goToNativeBridge(
BridgeViewMode.Unified,
tokenOverride,
destTokenOverride,
buttonLabel,
);
},
[goToNativeBridge],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ describe('useTokenActions', () => {
chainId: defaultToken.chainId,
symbol: defaultToken.symbol,
}),
'Buy',
);
expect(mockGoToBuy).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -692,6 +693,7 @@ describe('useTokenActions', () => {
expect.objectContaining({
address: defaultToken.address,
}),
'Buy',
);
});

Expand Down Expand Up @@ -743,6 +745,7 @@ describe('useTokenActions', () => {
chainId: '0x1',
symbol: 'ETH',
}),
'Buy',
);
expect(mockGoToBuy).not.toHaveBeenCalled();
});
Expand All @@ -767,6 +770,7 @@ describe('useTokenActions', () => {
symbol: defaultToken.symbol,
}),
undefined,
'Sell',
);
});
});
Expand Down
12 changes: 10 additions & 2 deletions app/components/UI/TokenDetails/hooks/useTokenActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,11 @@ export const useTokenActions = ({
}

if (!goToSwaps) return;
goToSwaps(buySourceToken, currentTokenAsBridgeToken);
goToSwaps(
buySourceToken,
currentTokenAsBridgeToken,
strings('asset_overview.buy_button'),
);
}, [
goToSwaps,
goToBuy,
Expand All @@ -450,7 +454,11 @@ export const useTokenActions = ({
// Sell: current token as source, let swap UI compute default dest
const handleSellPress = useCallback(() => {
if (!goToSwaps) return;
goToSwaps(currentTokenAsBridgeToken, undefined);
goToSwaps(
currentTokenAsBridgeToken,
undefined,
strings('asset_overview.sell_button'),
);
}, [goToSwaps, currentTokenAsBridgeToken]);

return {
Expand Down
Loading