Skip to content

Commit 59aaa22

Browse files
authored
Merge branch 'main' into harry/MMQA-1525
2 parents 8ca917e + 7362d38 commit 59aaa22

File tree

6 files changed

+402
-22
lines changed

6 files changed

+402
-22
lines changed

app/components/UI/SecurityTrust/Views/SecurityTrustScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const SecurityTrustScreen: React.FC = () => {
6363
const networkName = useNetworkName(params?.chainId as Hex);
6464

6565
// Get action handlers from hook (single source of truth)
66-
const { onBuy, goToSwaps, hasEligibleSwapTokens, networkModal } =
66+
const { onBuy, handleStickySwapPress, hasEligibleSwapTokens, networkModal } =
6767
useTokenActions({
6868
token: params,
6969
networkName,
@@ -619,7 +619,7 @@ const SecurityTrustScreen: React.FC = () => {
619619
token={params}
620620
securityData={securityData}
621621
onBuy={onBuy}
622-
goToSwaps={goToSwaps}
622+
onSwap={handleStickySwapPress}
623623
hasEligibleSwapTokens={hasEligibleSwapTokens}
624624
/>
625625
</View>

app/components/UI/TokenDetails/Views/TokenDetails.test.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jest.mock('../../Ramp/hooks/useTokenBuyability', () => ({
8080
}));
8181

8282
const mockGoToSwaps = jest.fn();
83+
const mockHandleStickySwapPress = jest.fn();
8384
const mockOnBuy = jest.fn();
8485
const mockUseTokenActions = jest.fn();
8586
jest.mock('../hooks/useTokenActions', () => ({
@@ -217,6 +218,7 @@ describe('TokenDetails', () => {
217218
goToSwaps: mockGoToSwaps,
218219
handleBuyPress: jest.fn(),
219220
handleSellPress: jest.fn(),
221+
handleStickySwapPress: mockHandleStickySwapPress,
220222
hasEligibleSwapTokens: true,
221223
networkModal: null,
222224
});
@@ -291,12 +293,7 @@ describe('TokenDetails', () => {
291293

292294
fireEvent.press(getByText('Swap'));
293295

294-
expect(mockGoToSwaps).toHaveBeenCalledWith(
295-
undefined,
296-
undefined,
297-
undefined,
298-
true,
299-
);
296+
expect(mockHandleStickySwapPress).toHaveBeenCalledTimes(1);
300297
});
301298

302299
it('shows only Swap when user has eligible tokens but token is not buyable', () => {
@@ -319,6 +316,7 @@ describe('TokenDetails', () => {
319316
goToSwaps: mockGoToSwaps,
320317
handleBuyPress: jest.fn(),
321318
handleSellPress: jest.fn(),
319+
handleStickySwapPress: mockHandleStickySwapPress,
322320
hasEligibleSwapTokens: false,
323321
networkModal: null,
324322
});

app/components/UI/TokenDetails/Views/TokenDetails.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,18 @@ const TokenDetails: React.FC<{
153153
///: END:ONLY_INCLUDE_IF
154154
} = useTokenBalance(token);
155155

156-
const { onBuy, onSend, onReceive, goToSwaps, hasEligibleSwapTokens } =
157-
useTokenActions({
158-
token,
159-
networkName,
160-
});
156+
const {
157+
onBuy,
158+
onSend,
159+
onReceive,
160+
goToSwaps,
161+
handleStickySwapPress,
162+
hasEligibleSwapTokens,
163+
} = useTokenActions({
164+
token,
165+
networkName,
166+
currentTokenBalance: balance,
167+
});
161168

162169
// Swaps view should always scroll to top when navigating from the token details view
163170
const goToSwapsFromDetails = useCallback(
@@ -306,7 +313,7 @@ const TokenDetails: React.FC<{
306313
token={token}
307314
securityData={securityData}
308315
onBuy={onBuy}
309-
goToSwaps={goToSwapsFromDetails}
316+
onSwap={handleStickySwapPress}
310317
hasEligibleSwapTokens={hasEligibleSwapTokens}
311318
/>
312319
)}

app/components/UI/TokenDetails/components/TokenDetailsStickyFooter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ interface TokenStickyFooterProps {
2323
securityData: TokenSecurityData | null | undefined;
2424
/** Action handlers from parent's useTokenActions hook */
2525
onBuy: () => void;
26-
goToSwaps: () => void;
26+
onSwap: () => void;
2727
hasEligibleSwapTokens: boolean;
2828
}
2929

3030
const TokenDetailsStickyFooter: React.FC<TokenStickyFooterProps> = ({
3131
token,
3232
securityData,
3333
onBuy,
34-
goToSwaps,
34+
onSwap,
3535
hasEligibleSwapTokens,
3636
}) => {
3737
const navigation = useNavigation();
@@ -139,7 +139,7 @@ const TokenDetailsStickyFooter: React.FC<TokenStickyFooterProps> = ({
139139
size: ButtonSize.Lg,
140140
onPress: () =>
141141
handleFooterAction(
142-
() => goToSwaps(),
142+
onSwap,
143143
strings('asset_overview.swap'),
144144
),
145145
},

0 commit comments

Comments
 (0)