Skip to content
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
27 changes: 20 additions & 7 deletions app/components/UI/Perps/hooks/usePerpsBalanceTokenFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { useIsPerpsBalanceSelected } from './useIsPerpsBalanceSelected';
import { usePerpsPaymentToken } from './usePerpsPaymentToken';
import Routes from '../../../../constants/navigation/Routes';
import { usePerpsTrading } from './usePerpsTrading';
import { useConfirmNavigation } from '../../../Views/confirmations/hooks/useConfirmNavigation';
import { useNavigation } from '@react-navigation/native';
import useApprovalRequest from '../../../Views/confirmations/hooks/useApprovalRequest';

/** URI for the perps balance token icon, shared with PerpsPayRow and pay-with modal. */
const resolvedPerpsIcon = Image.resolveAssetSource(perpsPayTokenIcon);
Expand All @@ -45,18 +46,30 @@ export function usePerpsBalanceTokenFilter(): (
const formatFiat = useFiatFormatter({ currency: 'usd' });

const { depositWithConfirmation } = usePerpsTrading();
const { navigateToConfirmation } = useConfirmNavigation();

const isPerpsDepositAndOrder = hasTransactionType(transactionMeta, [
TransactionType.perpsDepositAndOrder,
]);

const { onReject: handleReject } = useApprovalRequest();

const navigation = useNavigation();

const handlePerpsDepositPress = useCallback(() => {
navigateToConfirmation({ stack: Routes.PERPS.ROOT });
depositWithConfirmation().catch(() => {
// Deposit flow handles errors (e.g. user rejection).
});
}, [navigateToConfirmation, depositWithConfirmation]);
handleReject();
depositWithConfirmation()
.then(() => {
navigation.navigate(
Routes.FULL_SCREEN_CONFIRMATIONS.REDESIGNED_CONFIRMATIONS,
{
showPerpsHeader: true,
},
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded showPerpsHeader bypasses shared config constant

Low Severity

The showPerpsHeader value is hardcoded to true, but every other perps navigation path (PerpsOrderRedirect.tsx, usePerpsNavigation.ts) uses CONFIRMATION_HEADER_CONFIG.ShowPerpsHeaderForDepositAndTrade from the shared perpsConfig constants. Hardcoding the value here means this code path won't respect future changes to that configuration constant, creating an inconsistency across perps deposit/order flows.

Fix in Cursor Fix in Web

})
.catch(() => {
// Deposit flow handles errors (e.g. user rejection).
});
}, [navigation, depositWithConfirmation, handleReject]);
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

const { onPaymentTokenChange: onPerpsPaymentTokenChange } =
usePerpsPaymentToken();
Expand Down
Loading