diff --git a/.eslintrc.js b/.eslintrc.js index 8eeba3634d59..58e930e1a567 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -82,7 +82,7 @@ const utilNumberImportBurndownFiles = [ 'app/components/UI/Ramp/Aggregator/hooks/useHandleSuccessfulOrder.ts', 'app/components/UI/Ramp/Aggregator/hooks/useIntentAmount.ts', 'app/components/UI/Ramp/Aggregator/utils/index.ts', - 'app/components/UI/Ramp/Deposit/utils/index.ts', + 'app/components/UI/Ramp/utils/depositUtils.ts', 'app/components/UI/Ramp/utils/getOrderAmount.ts', 'app/components/UI/Ramp/utils/v2OrderToast.ts', 'app/components/UI/Stake/components/StakingBalance/StakingBanners/ClaimBanner/ClaimBanner.tsx', diff --git a/app/components/Nav/Main/MainNavigator.js b/app/components/Nav/Main/MainNavigator.js index c63f24086482..3036be9643d2 100644 --- a/app/components/Nav/Main/MainNavigator.js +++ b/app/components/Nav/Main/MainNavigator.js @@ -77,13 +77,12 @@ import RampActivationKeyForm from '../../UI/Ramp/Aggregator/Views/Settings/Activ import RampHeadlessPlayground from '../../UI/Ramp/Views/HeadlessPlayground'; import TokenListRoutes from '../../UI/Ramp/routes'; -import DepositRoutes from '../../UI/Ramp/Deposit/routes'; import V2BankDetails from '../../UI/Ramp/Views/NativeFlow/BankDetails'; import { colors as importedColors } from '../../../styles/common'; import OrderDetails from '../../UI/Ramp/Aggregator/Views/OrderDetails'; import RampsOrderDetails from '../../UI/Ramp/Views/OrderDetails'; -import DepositOrderDetails from '../../UI/Ramp/Deposit/Views/DepositOrderDetails/DepositOrderDetails'; +import DepositOrderDetails from '../../UI/Ramp/Views/OrderDetails/DepositOrderDetails/DepositOrderDetails'; import ProcessingInfoModal from '../../UI/Ramp/Views/Modals/ProcessingInfoModal/ProcessingInfoModal'; import SendTransaction from '../../UI/Ramp/Aggregator/Views/SendTransaction'; import TabBar from '../../../component-library/components/Navigation/TabBar'; @@ -1179,7 +1178,6 @@ const MainNavigator = () => { > {() => } - { expect(rampSellScreen).toBeDefined(); }); - it('includes Deposit route', () => { - const container = renderWithProvider(, { - state: initialRootState, - }); - - const screenProps = getScreenProps(container); - const depositScreen = screenProps?.find( - (screen) => screen?.name === Routes.DEPOSIT.ID, - ); - - expect(depositScreen).toBeDefined(); - }); - it('includes Settings view route', () => { const container = renderWithProvider(, { state: initialRootState, diff --git a/app/components/Nav/Main/index.test.tsx b/app/components/Nav/Main/index.test.tsx index 7e858613f956..e2f71a485582 100644 --- a/app/components/Nav/Main/index.test.tsx +++ b/app/components/Nav/Main/index.test.tsx @@ -8,21 +8,12 @@ import initialRootState from '../../../util/test/initial-root-state'; const mockReact = React; const mockView = View; -// Mock Ramp SDK dependencies to prevent SdkEnvironment.Production errors +// Mock Ramp shell to avoid deep dependency graph in Main mount test jest.mock('../../../components/UI/Ramp', () => ({ __esModule: true, default: () => mockReact.createElement('RampOrdersMock'), })); -jest.mock('../../../components/UI/Ramp/Deposit/sdk', () => ({ - DepositSDKProvider: ({ children }: { children: React.ReactNode }) => children, - DepositSDKContext: { - Provider: ({ children }: { children: React.ReactNode }) => children, - }, -})); - -jest.mock('../../../components/UI/Ramp/Deposit/orderProcessor', () => ({})); - jest.mock('react-native-device-info', () => ({ getVersion: jest.fn(() => '0.0.0'), getBuildNumber: jest.fn(() => '0'), @@ -109,22 +100,6 @@ jest.mock('../../../util/transaction-controller', () => ({ stopIncomingTransactionPolling: jest.fn(), })); -jest.mock('@consensys/native-ramps-sdk', () => ({ - SdkEnvironment: { - Production: 'production', - Staging: 'staging', - }, - Context: { - MobileIOS: 'mobile-ios', - MobileAndroid: 'mobile-android', - }, - DepositPaymentMethodDuration: { - instant: 'instant', - oneToTwoDays: '1_to_2_days', - }, - NativeRampsSdk: jest.fn(), -})); - describe('Main', () => { beforeEach(() => { jest.clearAllMocks(); diff --git a/app/components/UI/BalanceEmptyState/BalanceEmptyState.test.tsx b/app/components/UI/BalanceEmptyState/BalanceEmptyState.test.tsx index 61c977066054..61bcce0f0feb 100644 --- a/app/components/UI/BalanceEmptyState/BalanceEmptyState.test.tsx +++ b/app/components/UI/BalanceEmptyState/BalanceEmptyState.test.tsx @@ -25,12 +25,6 @@ jest.mock('../Ramp/hooks/useRampsButtonClickData', () => ({ useRampsButtonClickData: jest.fn(() => mockButtonClickData), })); -const mockUseRampsUnifiedV2Enabled = jest.fn(); -jest.mock('../Ramp/hooks/useRampsUnifiedV2Enabled', () => ({ - __esModule: true, - default: () => mockUseRampsUnifiedV2Enabled(), -})); - const mockTrackEvent = jest.fn(); const mockCreateEventBuilder = jest.fn(); const mockEventBuilder = { @@ -54,7 +48,6 @@ describe('BalanceEmptyState', () => { createEventBuilder: mockCreateEventBuilder, }), ); - mockUseRampsUnifiedV2Enabled.mockReturnValue(false); }); const renderComponent = (props: Partial = {}) => @@ -92,32 +85,7 @@ describe('BalanceEmptyState', () => { expect(mockGoToBuy).toHaveBeenCalled(); }); - it('tracks RAMPS_BUTTON_CLICKED event with ramp_type BUY when unified V2 is disabled', () => { - mockUseRampsUnifiedV2Enabled.mockReturnValue(false); - const { getByTestId } = renderComponent(); - const actionButton = getByTestId('balance-empty-state-action-button'); - - fireEvent.press(actionButton); - - expect(mockCreateEventBuilder).toHaveBeenCalledWith( - MetaMetricsEvents.RAMPS_BUTTON_CLICKED, - ); - expect(mockEventBuilder.addProperties).toHaveBeenCalledWith( - expect.objectContaining({ - button_text: 'Add funds', - location: 'BalanceEmptyState', - chain_id_destination: 1, - ramp_type: 'BUY', - is_authenticated: false, - preferred_provider: undefined, - order_count: 0, - }), - ); - expect(mockTrackEvent).toHaveBeenCalled(); - }); - - it('tracks RAMPS_BUTTON_CLICKED event with ramp_type UNIFIED_BUY_2 when unified V2 is enabled', () => { - mockUseRampsUnifiedV2Enabled.mockReturnValue(true); + it('tracks RAMPS_BUTTON_CLICKED event with ramp_type UNIFIED_BUY_2', () => { const { getByTestId } = renderComponent(); const actionButton = getByTestId('balance-empty-state-action-button'); diff --git a/app/components/UI/BalanceEmptyState/BalanceEmptyState.tsx b/app/components/UI/BalanceEmptyState/BalanceEmptyState.tsx index 1de04443b3c5..efc880580f66 100644 --- a/app/components/UI/BalanceEmptyState/BalanceEmptyState.tsx +++ b/app/components/UI/BalanceEmptyState/BalanceEmptyState.tsx @@ -26,7 +26,6 @@ import { BalanceEmptyStateProps } from './BalanceEmptyState.types'; import bankTransferImage from '../../../images/bank-transfer.png'; import { getDetectedGeolocation } from '../../../reducers/fiatOrders'; import { useRampsButtonClickData } from '../Ramp/hooks/useRampsButtonClickData'; -import useRampsUnifiedV2Enabled from '../Ramp/hooks/useRampsUnifiedV2Enabled'; /** * BalanceEmptyState smart component displays an empty state for wallet balance @@ -42,7 +41,6 @@ const BalanceEmptyState: React.FC = ({ const rampGeodetectedRegion = useSelector(getDetectedGeolocation); const { goToBuy } = useRampNavigation(); const buttonClickData = useRampsButtonClickData(); - const isV2UnifiedEnabled = useRampsUnifiedV2Enabled(); const handleAction = () => { goToBuy(); @@ -53,7 +51,7 @@ const BalanceEmptyState: React.FC = ({ button_text: 'Add funds', location: 'BalanceEmptyState', chain_id_destination: getDecimalChainId(chainId), - ramp_type: isV2UnifiedEnabled ? 'UNIFIED_BUY_2' : 'BUY', + ramp_type: 'UNIFIED_BUY_2', region: rampGeodetectedRegion, is_authenticated: buttonClickData.is_authenticated, preferred_provider: buttonClickData.preferred_provider, diff --git a/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.test.tsx b/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.test.tsx index 39d373549f8d..8fb6fa0c5164 100644 --- a/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.test.tsx +++ b/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { fireEvent } from '@testing-library/react-native'; import AddFundsBottomSheet from './AddFundsBottomSheet'; import { useOpenSwaps } from '../../hooks/useOpenSwaps'; -import useDepositEnabled from '../../../Ramp/Deposit/hooks/useDepositEnabled'; +import useDepositEnabled from '../../../Ramp/hooks/useDepositEnabled'; import { isBridgeAllowed } from '../../../Bridge/utils'; import { MetaMetricsEvents } from '../../../../../core/Analytics'; import { useAnalytics } from '../../../../hooks/useAnalytics/useAnalytics'; @@ -12,7 +12,6 @@ import { CardFundingToken, FundingStatus } from '../../types'; import { renderScreen } from '../../../../../util/test/renderWithProvider'; import { backgroundState } from '../../../../../util/test/initial-root-state'; import { useRampNavigation } from '../../../Ramp/hooks/useRampNavigation'; -import useRampsUnifiedV2Enabled from '../../../Ramp/hooks/useRampsUnifiedV2Enabled'; import { CardHomeSelectors } from '../../Views/CardHome/CardHome.testIds'; import { RampsButtonClickData } from '../../../Ramp/hooks/useRampsButtonClickData'; @@ -21,7 +20,6 @@ const mockUseParams = jest.fn(); const mockGoBack = jest.fn(); const mockNavigate = jest.fn(); const mockGoToBuy = jest.fn(); -const mockGoToDeposit = jest.fn(); // Mock dependencies jest.mock('../../../Ramp/hooks/useRampNavigation'); @@ -29,7 +27,7 @@ jest.mock('../../hooks/useOpenSwaps', () => ({ useOpenSwaps: jest.fn(), })); -jest.mock('../../../Ramp/Deposit/hooks/useDepositEnabled', () => ({ +jest.mock('../../../Ramp/hooks/useDepositEnabled', () => ({ __esModule: true, default: jest.fn(), })); @@ -85,8 +83,6 @@ jest.mock('../../../Ramp/hooks/useRampsButtonClickData', () => ({ useRampsButtonClickData: jest.fn(() => mockButtonClickData), })); -jest.mock('../../../Ramp/hooks/useRampsUnifiedV2Enabled'); - jest.mock('@react-navigation/native', () => ({ ...jest.requireActual('@react-navigation/native'), useNavigation: () => ({ @@ -150,13 +146,8 @@ describe('AddFundsBottomSheet', () => { (useRampNavigation as jest.Mock).mockReturnValue({ goToBuy: mockGoToBuy, - goToDeposit: mockGoToDeposit, }); - // Default V2 enabled — the whole point of this migration is UB2 routing. - // Individual tests override to false where they need to assert V1 fallback. - (useRampsUnifiedV2Enabled as jest.Mock).mockReturnValue(true); - (useDepositEnabled as jest.Mock).mockReturnValue({ isDepositEnabled: true, }); @@ -257,20 +248,6 @@ describe('AddFundsBottomSheet', () => { }); }); - it('tags analytics with ramp_type DEPOSIT when the UB2 feature flag is disabled', () => { - (useRampsUnifiedV2Enabled as jest.Mock).mockReturnValue(false); - - const { getByText } = setupComponent(); - - fireEvent.press(getByText('Fund with cash')); - - expect(mockEventBuilder.addProperties).toHaveBeenCalledWith( - expect.objectContaining({ - ramp_type: 'DEPOSIT', - }), - ); - }); - it('handles swap option press correctly', () => { const { getByText } = setupComponent(); @@ -354,16 +331,6 @@ describe('AddFundsBottomSheet', () => { }); }); - it('does NOT call the deprecated goToDeposit (UB1) when Fund with cash is pressed', () => { - // Regression guard: this entry point was migrated off goToDeposit (UB1) - // to goToBuy (UB2-aware). If someone reverts that, this test goes red. - const { getByText } = setupComponent(); - - fireEvent.press(getByText('Fund with cash')); - - expect(mockGoToDeposit).not.toHaveBeenCalled(); - }); - it('falls back to goToBuy() with no intent when the priority token has no address', () => { // No assetId → useRampNavigation routes UB2 to TokenSelection // (see useRampNavigation.ts, 'V2: If no assetId and V2 is enabled'). diff --git a/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.tsx b/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.tsx index 3cdf9d303a7c..aedb075d34de 100644 --- a/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.tsx +++ b/app/components/UI/Card/components/AddFundsBottomSheet/AddFundsBottomSheet.tsx @@ -23,7 +23,7 @@ import { View } from 'react-native'; import { CardFundingToken } from '../../types'; import AppConstants from '../../../../../core/AppConstants'; import { isBridgeAllowed } from '../../../Bridge/utils'; -import useDepositEnabled from '../../../Ramp/Deposit/hooks/useDepositEnabled'; +import useDepositEnabled from '../../../Ramp/hooks/useDepositEnabled'; import { getDecimalChainId } from '../../../../../util/networks'; import { trace, TraceName } from '../../../../../util/trace'; import { useOpenSwaps } from '../../hooks/useOpenSwaps'; @@ -35,7 +35,6 @@ import { useRampNavigation } from '../../../Ramp/hooks/useRampNavigation'; import { safeFormatChainIdToHex } from '../../util/safeFormatChainIdToHex'; import { getDetectedGeolocation } from '../../../../../reducers/fiatOrders'; import { useRampsButtonClickData } from '../../../Ramp/hooks/useRampsButtonClickData'; -import useRampsUnifiedV2Enabled from '../../../Ramp/hooks/useRampsUnifiedV2Enabled'; import { createNavigationDetails, useParams, @@ -67,7 +66,6 @@ const AddFundsBottomSheet: React.FC = () => { const rampGeodetectedRegion = useSelector(getDetectedGeolocation); const { goToBuy } = useRampNavigation(); const buttonClickData = useRampsButtonClickData(); - const isV2UnifiedEnabled = useRampsUnifiedV2Enabled(); const closeBottomSheetAndNavigate = useCallback( (navigateFunc: () => void) => { @@ -104,7 +102,7 @@ const AddFundsBottomSheet: React.FC = () => { button_text: 'Fund with cash', location: 'CardHome', chain_id_destination: getDecimalChainId(priorityToken?.caipChainId), - ramp_type: isV2UnifiedEnabled ? 'UNIFIED_BUY_2' : 'DEPOSIT', + ramp_type: 'UNIFIED_BUY_2', region: rampGeodetectedRegion, is_authenticated: buttonClickData.is_authenticated, preferred_provider: buttonClickData.preferred_provider, @@ -124,7 +122,6 @@ const AddFundsBottomSheet: React.FC = () => { createEventBuilder, priorityToken, buttonClickData, - isV2UnifiedEnabled, ]); const options = [ diff --git a/app/components/UI/Card/components/Onboarding/PersonalDetails.test.tsx b/app/components/UI/Card/components/Onboarding/PersonalDetails.test.tsx index c8f3b76ba100..de3dfb73ef14 100644 --- a/app/components/UI/Card/components/Onboarding/PersonalDetails.test.tsx +++ b/app/components/UI/Card/components/Onboarding/PersonalDetails.test.tsx @@ -227,7 +227,7 @@ jest.mock('../../../../../component-library/components/Buttons/Button', () => { }; }); -jest.mock('../../../Ramp/Deposit/components/DepositDateField', () => { +jest.mock('../../../Ramp/components/DepositDateField', () => { const React = jest.requireActual('react'); const { TextInput } = jest.requireActual('react-native'); diff --git a/app/components/UI/Card/components/Onboarding/PersonalDetails.tsx b/app/components/UI/Card/components/Onboarding/PersonalDetails.tsx index b9303d7f7c30..63b7f46be08b 100644 --- a/app/components/UI/Card/components/Onboarding/PersonalDetails.tsx +++ b/app/components/UI/Card/components/Onboarding/PersonalDetails.tsx @@ -14,7 +14,7 @@ import Routes from '../../../../../constants/navigation/Routes'; import { strings } from '../../../../../../locales/i18n'; import OnboardingStep from './OnboardingStep'; import SelectField from './SelectField'; -import DepositDateField from '../../../Ramp/Deposit/components/DepositDateField'; +import DepositDateField from '../../../Ramp/components/DepositDateField'; import { resetOnboardingState, selectOnboardingId, diff --git a/app/components/UI/Card/components/Onboarding/SignUp.test.tsx b/app/components/UI/Card/components/Onboarding/SignUp.test.tsx index 77a43b028e6f..5c7a688e4e3c 100644 --- a/app/components/UI/Card/components/Onboarding/SignUp.test.tsx +++ b/app/components/UI/Card/components/Onboarding/SignUp.test.tsx @@ -5,7 +5,7 @@ import { configureStore } from '@reduxjs/toolkit'; import { useNavigation } from '@react-navigation/native'; import useEmailVerificationSend from '../../hooks/useEmailVerificationSend'; import { useDebouncedValue } from '../../../../hooks/useDebouncedValue'; -import { validateEmail } from '../../../Ramp/Deposit/utils'; +import { validateEmail } from '../../../Ramp/utils/depositUtils'; import { validatePassword } from '../../util/validatePassword'; import SignUp from './SignUp'; import Routes from '../../../../../constants/navigation/Routes'; @@ -57,7 +57,7 @@ jest.mock('../../hooks/useRegions', () => ({ jest.mock('../../../../hooks/useDebouncedValue'); // Mock utility functions -jest.mock('../../../Ramp/Deposit/utils'); +jest.mock('../../../Ramp/utils/depositUtils'); jest.mock('../../util/validatePassword'); // Mock Engine diff --git a/app/components/UI/Card/components/Onboarding/SignUp.tsx b/app/components/UI/Card/components/Onboarding/SignUp.tsx index 089bcfca1be7..b7f675733669 100644 --- a/app/components/UI/Card/components/Onboarding/SignUp.tsx +++ b/app/components/UI/Card/components/Onboarding/SignUp.tsx @@ -23,7 +23,7 @@ import TextField from '../../../../../component-library/components/Form/TextFiel import Routes from '../../../../../constants/navigation/Routes'; import { strings } from '../../../../../../locales/i18n'; import OnboardingStep from './OnboardingStep'; -import { validateEmail } from '../../../Ramp/Deposit/utils'; +import { validateEmail } from '../../../Ramp/utils/depositUtils'; import { useDebouncedValue } from '../../../../hooks/useDebouncedValue'; import useEmailVerificationSend from '../../hooks/useEmailVerificationSend'; import useRegions from '../../hooks/useRegions'; diff --git a/app/components/UI/Card/hooks/useAssetBalances.test.ts b/app/components/UI/Card/hooks/useAssetBalances.test.ts index b6dfac5a6572..3c91ed964132 100644 --- a/app/components/UI/Card/hooks/useAssetBalances.test.ts +++ b/app/components/UI/Card/hooks/useAssetBalances.test.ts @@ -56,7 +56,7 @@ jest.mock('../../../../core/Engine', () => ({ jest.mock('@metamask/bridge-controller', () => ({ isSolanaChainId: jest.fn((chainId: string) => chainId.startsWith('solana:')), })); -jest.mock('../../Ramp/Deposit/constants/networks', () => ({ +jest.mock('../../Ramp/constants/networks', () => ({ SOLANA_MAINNET: { chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', }, diff --git a/app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.test.tsx b/app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.test.tsx index 09c5fa1ff89f..e0a537e153ad 100644 --- a/app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.test.tsx +++ b/app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.test.tsx @@ -222,7 +222,6 @@ describe('EarnMusdConversionEducationView', () => { goToBuy: jest.fn(), goToAggregator: mockGoToAggregator, goToSell: jest.fn(), - goToDeposit: jest.fn(), }); mockSelectMoneyHubEnabledFlag.mockReturnValue(false); @@ -505,7 +504,6 @@ describe('EarnMusdConversionEducationView', () => { goToBuy: mockGoToBuy, goToAggregator: mockGoToAggregator, goToSell: jest.fn(), - goToDeposit: jest.fn(), }); mockUseMusdConversionFlowData.mockReturnValue({ diff --git a/app/components/UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.test.tsx b/app/components/UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.test.tsx index e5dd56d6f616..e33123dbdab8 100644 --- a/app/components/UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.test.tsx +++ b/app/components/UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.test.tsx @@ -94,7 +94,6 @@ describe('MusdConversionAssetListCta', () => { goToBuy: mockGoToBuy, goToAggregator: jest.fn(), goToSell: jest.fn(), - goToDeposit: jest.fn(), }); ( diff --git a/app/components/UI/Earn/hooks/useMusdCtaVisibility.test.ts b/app/components/UI/Earn/hooks/useMusdCtaVisibility.test.ts index eccb0df298ce..d87f975eeb50 100644 --- a/app/components/UI/Earn/hooks/useMusdCtaVisibility.test.ts +++ b/app/components/UI/Earn/hooks/useMusdCtaVisibility.test.ts @@ -10,9 +10,8 @@ import { useMusdConversionTokens } from './useMusdConversionTokens'; import { useMusdConversionEligibility } from './useMusdConversionEligibility'; import { useCurrentNetworkInfo } from '../../../hooks/useCurrentNetworkInfo'; import { useNetworksByCustomNamespace } from '../../../hooks/useNetworksByNamespace/useNetworksByNamespace'; -import { useRampTokens, RampsToken } from '../../Ramp/hooks/useRampTokens'; +import { RampsToken } from '../../Ramp/hooks/useRampTokens'; import useRampsTokens from '../../Ramp/hooks/useRampsTokens'; -import useRampsUnifiedV2Enabled from '../../Ramp/hooks/useRampsUnifiedV2Enabled'; import { MUSD_TOKEN_ASSET_ID_BY_CHAIN } from '../constants/musd'; import { createMockToken } from '../../Stake/testUtils'; import { @@ -36,9 +35,7 @@ jest.mock('./useMusdConversionTokens'); jest.mock('./useMusdConversionEligibility'); jest.mock('../../../hooks/useCurrentNetworkInfo'); jest.mock('../../../hooks/useNetworksByNamespace/useNetworksByNamespace'); -jest.mock('../../Ramp/hooks/useRampTokens'); jest.mock('../../Ramp/hooks/useRampsTokens'); -jest.mock('../../Ramp/hooks/useRampsUnifiedV2Enabled'); jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux'), useSelector: jest.fn(), @@ -66,16 +63,9 @@ const mockUseNetworksByCustomNamespace = useNetworksByCustomNamespace as jest.MockedFunction< typeof useNetworksByCustomNamespace >; -const mockUseRampTokens = useRampTokens as jest.MockedFunction< - typeof useRampTokens ->; const mockUseRampsTokens = useRampsTokens as jest.MockedFunction< typeof useRampsTokens >; -const mockUseRampsUnifiedV2Enabled = - useRampsUnifiedV2Enabled as jest.MockedFunction< - typeof useRampsUnifiedV2Enabled - >; const mockUseMusdConversionTokens = useMusdConversionTokens as jest.MockedFunction< typeof useMusdConversionTokens @@ -142,7 +132,7 @@ describe('useMusdCtaVisibility', () => { }; const defaultRampTokens = { - topTokens: null, + topTokens: [], allTokens: [ createMusdRampToken(CHAIN_IDS.MAINNET), createMusdRampToken(CHAIN_IDS.LINEA_MAINNET), @@ -220,15 +210,16 @@ describe('useMusdCtaVisibility', () => { mockUseNetworksByCustomNamespace.mockReturnValue( defaultNetworksByNamespace, ); - mockUseRampsUnifiedV2Enabled.mockReturnValue(false); mockUseRampsTokens.mockReturnValue({ - tokens: null, + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: defaultRampTokens.allTokens ?? [], + }, selectedToken: null, setSelectedToken: jest.fn(), - isLoading: false, - error: null, + isLoading: defaultRampTokens.isLoading, + error: defaultRampTokens.error, }); - mockUseRampTokens.mockReturnValue(defaultRampTokens); mockUseMusdConversionTokens.mockReturnValue({ tokens: [], filterAllowedTokens: jest.fn(), @@ -391,9 +382,12 @@ describe('useMusdCtaVisibility', () => { }); it('returns shouldShowCta false when MUSD is not buyable on any chain', () => { - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [], + mockUseRampsTokens.mockReturnValue({ + tokens: { topTokens: defaultRampTokens.topTokens, allTokens: [] }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); @@ -488,12 +482,18 @@ describe('useMusdCtaVisibility', () => { }); it('returns shouldShowCta false when MUSD not buyable in region for mainnet', () => { - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [ - createMusdRampToken(CHAIN_IDS.MAINNET, false), // tokenSupported = false - createMusdRampToken(CHAIN_IDS.LINEA_MAINNET), - ], + mockUseRampsTokens.mockReturnValue({ + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: [ + createMusdRampToken(CHAIN_IDS.MAINNET, false), // tokenSupported = false + createMusdRampToken(CHAIN_IDS.LINEA_MAINNET), + ], + }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); @@ -506,12 +506,18 @@ describe('useMusdCtaVisibility', () => { }); it('returns shouldShowCta false when MUSD not buyable anywhere', () => { - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [ - createMusdRampToken(CHAIN_IDS.MAINNET, false), - createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, false), - ], + mockUseRampsTokens.mockReturnValue({ + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: [ + createMusdRampToken(CHAIN_IDS.MAINNET, false), + createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, false), + ], + }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); @@ -555,12 +561,18 @@ describe('useMusdCtaVisibility', () => { }); it('returns shouldShowCta false when MUSD not buyable in region for Linea', () => { - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [ - createMusdRampToken(CHAIN_IDS.MAINNET), - createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, false), // tokenSupported = false - ], + mockUseRampsTokens.mockReturnValue({ + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: [ + createMusdRampToken(CHAIN_IDS.MAINNET), + createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, false), // tokenSupported = false + ], + }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); @@ -737,12 +749,18 @@ describe('useMusdCtaVisibility', () => { }); // Selected chain is not buyable on Ramp (no supported token route). - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [ - createMusdRampToken(CHAIN_IDS.MAINNET, false), // not buyable on selected chain - createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, true), // buyable elsewhere - ], + mockUseRampsTokens.mockReturnValue({ + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: [ + createMusdRampToken(CHAIN_IDS.MAINNET, false), // not buyable on selected chain + createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, true), // buyable elsewhere + ], + }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); mockUseMusdBalance.mockReturnValue(createMusdBalanceMockReturn()); @@ -905,9 +923,12 @@ describe('useMusdCtaVisibility', () => { ...defaultNetworksByNamespace, areAllNetworksSelected: true, }); - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: null, + mockUseRampsTokens.mockReturnValue({ + tokens: null, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: true, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); @@ -928,12 +949,18 @@ describe('useMusdCtaVisibility', () => { ...defaultNetworksByNamespace, areAllNetworksSelected: true, }); - mockUseRampTokens.mockReturnValue({ - ...defaultRampTokens, - allTokens: [ - createMusdRampToken(CHAIN_IDS.MAINNET, false), // not buyable - createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, true), // buyable - ], + mockUseRampsTokens.mockReturnValue({ + tokens: { + topTokens: defaultRampTokens.topTokens, + allTokens: [ + createMusdRampToken(CHAIN_IDS.MAINNET, false), // not buyable + createMusdRampToken(CHAIN_IDS.LINEA_MAINNET, true), // buyable + ], + }, + selectedToken: null, + setSelectedToken: jest.fn(), + isLoading: false, + error: null, }); const { result } = renderHook(() => useMusdCtaVisibility()); diff --git a/app/components/UI/FundActionMenu/FundActionMenu.test.tsx b/app/components/UI/FundActionMenu/FundActionMenu.test.tsx index 57d4ad7ac98c..d92500630c28 100644 --- a/app/components/UI/FundActionMenu/FundActionMenu.test.tsx +++ b/app/components/UI/FundActionMenu/FundActionMenu.test.tsx @@ -11,7 +11,6 @@ import { WalletActionsBottomSheetSelectorsIDs } from '../../Views/WalletActions/ // Internal dependencies. import { useAnalytics } from '../../hooks/useAnalytics/useAnalytics'; import { createMockUseAnalyticsHook } from '../../../util/test/analyticsMock'; -import useRampsUnifiedV2Enabled from '../Ramp/hooks/useRampsUnifiedV2Enabled'; import { useRampNavigation } from '../Ramp/hooks/useRampNavigation'; import FundActionMenu from './FundActionMenu'; import { RampsButtonClickData } from '../Ramp/hooks/useRampsButtonClickData'; @@ -24,7 +23,6 @@ jest.mock('react-redux', () => ({ connect: jest.fn(() => (component: React.ComponentType) => component), })); jest.mock('../../hooks/useAnalytics/useAnalytics'); -jest.mock('../Ramp/hooks/useRampsUnifiedV2Enabled'); jest.mock('../Ramp/hooks/useRampNavigation'); jest.mock('../../../util/trace'); jest.mock('../../../util/networks', () => ({ @@ -55,10 +53,6 @@ const mockUseNavigation = useNavigation as jest.MockedFunction< const mockUseRoute = useRoute as jest.MockedFunction; const mockUseSelector = useSelector as jest.MockedFunction; const mockUseAnalytics = jest.mocked(useAnalytics); -const mockUseRampsUnifiedV2Enabled = - useRampsUnifiedV2Enabled as jest.MockedFunction< - typeof useRampsUnifiedV2Enabled - >; const mockUseRampNavigation = useRampNavigation as jest.MockedFunction< typeof useRampNavigation >; @@ -72,7 +66,6 @@ describe('FundActionMenu', () => { const mockGoToBuy = jest.fn(); const mockGoToAggregator = jest.fn(); const mockGoToSell = jest.fn(); - const mockGoToDeposit = jest.fn(); const mockTrackEvent = jest.fn(); const mockCreateEventBuilder = jest.fn(); const mockBuild = jest.fn(); @@ -115,12 +108,10 @@ describe('FundActionMenu', () => { }), ); - mockUseRampsUnifiedV2Enabled.mockReturnValue(false); mockUseRampNavigation.mockReturnValue({ goToBuy: mockGoToBuy, goToAggregator: mockGoToAggregator, goToSell: mockGoToSell, - goToDeposit: mockGoToDeposit, }); getDecimalChainId.mockReturnValue(1); createBuyNavigationDetails.mockReturnValue(['BuyScreen', {}] as never); @@ -327,7 +318,7 @@ describe('FundActionMenu', () => { button_text: 'Buy', location: 'FundActionMenu', chain_id_destination: 1, - ramp_type: 'BUY', + ramp_type: 'UNIFIED_BUY_2', region: undefined, is_authenticated: false, preferred_provider: undefined, @@ -337,24 +328,6 @@ describe('FundActionMenu', () => { }); }); - it('sets ramp_type to UNIFIED_BUY_2 when unified V2 is enabled', async () => { - mockUseRampsUnifiedV2Enabled.mockReturnValue(true); - - const { getByTestId } = render(); - - fireEvent.press( - getByTestId(WalletActionsBottomSheetSelectorsIDs.BUY_UNIFIED_BUTTON), - ); - - await waitFor(() => { - expect(mockAddProperties).toHaveBeenCalledWith( - expect.objectContaining({ - ramp_type: 'UNIFIED_BUY_2', - }), - ); - }); - }); - it('does not track buy analytics when custom onBuy function is used', async () => { const customOnBuy = jest.fn(); mockUseRoute.mockReturnValue({ @@ -393,7 +366,7 @@ describe('FundActionMenu', () => { button_text: 'Buy', location: 'FundActionMenu', chain_id_destination: 137, - ramp_type: 'BUY', + ramp_type: 'UNIFIED_BUY_2', region: undefined, is_authenticated: false, preferred_provider: undefined, diff --git a/app/components/UI/FundActionMenu/FundActionMenu.tsx b/app/components/UI/FundActionMenu/FundActionMenu.tsx index 20ca5c58abba..6fbc204bc804 100644 --- a/app/components/UI/FundActionMenu/FundActionMenu.tsx +++ b/app/components/UI/FundActionMenu/FundActionMenu.tsx @@ -30,7 +30,6 @@ import type { ActionConfig, } from './FundActionMenu.types'; import { getDetectedGeolocation } from '../../../reducers/fiatOrders'; -import useRampsUnifiedV2Enabled from '../Ramp/hooks/useRampsUnifiedV2Enabled'; import { useRampsButtonClickData } from '../Ramp/hooks/useRampsButtonClickData'; import { useElevatedSurface } from '../../../util/theme/themeUtils'; @@ -48,7 +47,6 @@ const FundActionMenu = () => { const { trackEvent, createEventBuilder } = useAnalytics(); const canSignTransactions = useSelector(selectCanSignTransactions); const rampGeodetectedRegion = useSelector(getDetectedGeolocation); - const isV2UnifiedEnabled = useRampsUnifiedV2Enabled(); const { goToBuy, goToSell } = useRampNavigation(); const rampsButtonClickData = useRampsButtonClickData(); @@ -115,7 +113,7 @@ const FundActionMenu = () => { button_text: 'Buy', location: 'FundActionMenu', chain_id_destination: getChainIdForAsset(), - ramp_type: isV2UnifiedEnabled ? 'UNIFIED_BUY_2' : 'BUY', + ramp_type: 'UNIFIED_BUY_2', region: rampGeodetectedRegion, is_authenticated: rampsButtonClickData.is_authenticated, preferred_provider: rampsButtonClickData.preferred_provider, @@ -156,7 +154,6 @@ const FundActionMenu = () => { }, ] as ActionConfig[], [ - isV2UnifiedEnabled, rampGeodetectedRegion, getChainIdForAsset, canSignTransactions, diff --git a/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.test.tsx b/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.test.tsx index 218f5e4fa0e5..2a315b4f617a 100644 --- a/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.test.tsx +++ b/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.test.tsx @@ -36,9 +36,8 @@ jest.mock('react-native-modal', () => { ) : null; }); -// Mock @consensys/native-ramps-sdk to provide missing enum -jest.mock('@consensys/native-ramps-sdk', () => ({ - ...jest.requireActual('@consensys/native-ramps-sdk'), +jest.mock('../../../Ramp/types/legacyDeposit', () => ({ + ...jest.requireActual('../../../Ramp/types/legacyDeposit'), DepositPaymentMethodDuration: { instant: 'instant', oneToTwoDays: 'oneToTwoDays', diff --git a/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.test.tsx b/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.test.tsx index 13f0e989e964..ea456bb9efdf 100644 --- a/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.test.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.test.tsx @@ -10,23 +10,10 @@ import { import { backgroundState } from '../../../../../../../util/test/initial-root-state'; import Routes from '../../../../../../../constants/navigation/Routes'; import { RampSDK } from '../../../sdk'; -import { RampsButtonClickData } from '../../../../hooks/useRampsButtonClickData'; - -const mockButtonClickData: RampsButtonClickData = { - is_authenticated: false, - preferred_provider: undefined, - order_count: 0, -}; - -jest.mock('../../../../hooks/useRampsButtonClickData', () => ({ - useRampsButtonClickData: jest.fn(() => mockButtonClickData), -})); const mockNavigate = jest.fn(); const mockGoBack = jest.fn(); const mockDangerouslyGetParent = jest.fn(); -const mockGoToDeposit = jest.fn(); -const mockTrackEvent = jest.fn(); jest.mock('@react-navigation/native', () => { const actualReactNavigation = jest.requireActual('@react-navigation/native'); @@ -41,12 +28,6 @@ jest.mock('@react-navigation/native', () => { }; }); -jest.mock('../../../../hooks/useAnalytics', () => () => mockTrackEvent); - -jest.mock('../../../../hooks/useRampNavigation', () => ({ - useRampNavigation: jest.fn(() => ({ goToDeposit: mockGoToDeposit })), -})); - const mockUseRampSDKValues: DeepPartial = { selectedRegion: { id: 'us' }, }; @@ -94,13 +75,6 @@ describe('SettingsModal', () => { expect(getByText('View order history')).toBeTruthy(); }); - it('displays more ways to buy menu item', () => { - const { getByText } = render(); - - expect(getByText('More ways to buy')).toBeTruthy(); - expect(getByText('Switch to the new version')).toBeTruthy(); - }); - it('navigates to transactions view when view order history is pressed', () => { const { getByText } = render(); const viewOrderHistoryButton = getByText('View order history'); @@ -115,32 +89,6 @@ describe('SettingsModal', () => { }); }); - it('navigates to deposit when more ways to buy is pressed', () => { - const { getByText } = render(); - const moreWaysToBuyButton = getByText('More ways to buy'); - - fireEvent.press(moreWaysToBuyButton); - - expect(mockDangerouslyGetParent).toHaveBeenCalled(); - expect(mockGoToDeposit).toHaveBeenCalled(); - }); - - it('navigates back through parent navigation when deposit is pressed', () => { - const mockParentGoBack = jest.fn(); - mockDangerouslyGetParent.mockReturnValue({ - getParent: jest.fn().mockReturnValue({ - goBack: mockParentGoBack, - }), - }); - - const { getByText } = render(); - const moreWaysToBuyButton = getByText('More ways to buy'); - - fireEvent.press(moreWaysToBuyButton); - - expect(mockParentGoBack).toHaveBeenCalled(); - }); - describe('bottom sheet behavior', () => { it('renders bottom sheet with settings content', () => { const { getByText } = render(); @@ -155,12 +103,6 @@ describe('SettingsModal', () => { expect(getByText('View order history')).toBeTruthy(); }); - - it('renders add icon for more ways to buy', () => { - const { getByText } = render(); - - expect(getByText('More ways to buy')).toBeTruthy(); - }); }); describe('callback functions', () => { @@ -170,21 +112,5 @@ describe('SettingsModal', () => { expect(mockNavigate).not.toHaveBeenCalled(); expect(mockDangerouslyGetParent).not.toHaveBeenCalled(); }); - - it('tracks event when deposit is pressed', () => { - const { getByText } = render(); - const moreWaysToBuyButton = getByText('More ways to buy'); - - fireEvent.press(moreWaysToBuyButton); - - expect(mockTrackEvent).toHaveBeenCalledWith('RAMPS_BUTTON_CLICKED', { - location: 'Buy Settings Modal', - ramp_type: 'DEPOSIT', - region: 'us', - is_authenticated: false, - preferred_provider: undefined, - order_count: 0, - }); - }); }); }); diff --git a/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.tsx b/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.tsx index 8dc3ce37a52c..6b38fbc5be97 100644 --- a/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/Modals/Settings/SettingsModal.tsx @@ -9,10 +9,6 @@ import { IconName } from '@metamask/design-system-react-native'; import Routes from '../../../../../../../constants/navigation/Routes'; import { createNavigationDetails } from '../../../../../../../util/navigation/navUtils'; import MenuItem from '../../../../components/MenuItem'; -import { useRampNavigation } from '../../../../hooks/useRampNavigation'; -import useAnalytics from '../../../../hooks/useAnalytics'; -import { useRampSDK } from '../../../sdk'; -import { useRampsButtonClickData } from '../../../../hooks/useRampsButtonClickData'; export const createBuySettingsModalNavigationDetails = createNavigationDetails( Routes.RAMP.MODALS.ID, @@ -22,11 +18,6 @@ export const createBuySettingsModalNavigationDetails = createNavigationDetails( function SettingsModal() { const sheetRef = useRef(null); const navigation = useNavigation(); - const { goToDeposit } = useRampNavigation(); - const { selectedRegion } = useRampSDK(); - - const trackEvent = useAnalytics(); - const buttonClickData = useRampsButtonClickData(); const handleNavigateToOrderHistory = useCallback(() => { sheetRef.current?.onCloseBottomSheet(); @@ -38,26 +29,6 @@ function SettingsModal() { }); }, [navigation]); - const handleDepositPress = useCallback(() => { - trackEvent('RAMPS_BUTTON_CLICKED', { - location: 'Buy Settings Modal', - ramp_type: 'DEPOSIT', - region: selectedRegion?.id as string, - is_authenticated: buttonClickData.is_authenticated, - preferred_provider: buttonClickData.preferred_provider, - order_count: buttonClickData.order_count, - }); - sheetRef.current?.onCloseBottomSheet(); - navigation.getParent()?.getParent()?.goBack(); - goToDeposit(); - }, [ - navigation, - goToDeposit, - selectedRegion?.id, - trackEvent, - buttonClickData, - ]); - const handleClosePress = useCallback(() => { sheetRef.current?.onCloseBottomSheet(); }, []); @@ -72,16 +43,6 @@ function SettingsModal() { title={strings('deposit.configuration_modal.view_order_history')} onPress={handleNavigateToOrderHistory} /> - ); } diff --git a/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.test.tsx b/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.test.tsx index 80d3dd9df08b..201cd09fe479 100644 --- a/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.test.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.test.tsx @@ -4,7 +4,7 @@ import { FIAT_ORDER_PROVIDERS, FIAT_ORDER_STATES, } from '../../../../../../constants/on-ramp'; -import { DepositOrderType } from '@consensys/native-ramps-sdk'; +import { DepositOrderType } from '../../../types/legacyDeposit'; import renderWithProvider, { DeepPartial, } from '../../../../../../util/test/renderWithProvider'; @@ -14,10 +14,7 @@ import { fireEvent, screen } from '@testing-library/react-native'; import { createMockInternalAccount } from '../../../../../../util/test/accountsControllerTestUtils'; import { mockNetworkState } from '../../../../../../util/test/network'; import { CHAIN_IDS } from '@metamask/transaction-controller'; -import { - MOCK_USDC_TOKEN, - MOCK_USDT_TOKEN, -} from '../../../Deposit/testUtils/constants'; +import { MOCK_USDC_TOKEN, MOCK_USDT_TOKEN } from '../../../testUtils/constants'; import { AccountGroupType } from '@metamask/account-api'; const MOCK_ADDRESS = '0xe64dD0AB5ad7e8C5F2bf6Ce75C34e187af8b920A'; @@ -222,7 +219,7 @@ function render(Component: React.ReactElement, orders = testOrders) { } const mockNavigate = jest.fn(); -const mockGoToDeposit = jest.fn(); +const mockGoToBuy = jest.fn(); jest.mock('@react-navigation/native', () => { const actualReactNavigation = jest.requireActual('@react-navigation/native'); @@ -235,13 +232,13 @@ jest.mock('@react-navigation/native', () => { }); jest.mock('../../../hooks/useRampNavigation', () => ({ - useRampNavigation: jest.fn(() => ({ goToDeposit: mockGoToDeposit })), + useRampNavigation: jest.fn(() => ({ goToBuy: mockGoToBuy })), })); describe('OrdersList', () => { beforeEach(() => { mockNavigate.mockClear(); - mockGoToDeposit.mockClear(); + mockGoToBuy.mockClear(); }); it('renders correctly', () => { @@ -335,12 +332,12 @@ describe('OrdersList', () => { }); }); - it('navigates to deposit flow when pressing created deposit order item', () => { + it('navigates to buy flow when pressing created deposit order item', () => { render(); fireEvent.press(screen.getByRole('button', { name: 'Purchased' })); fireEvent.press(screen.getByRole('button', { name: /Purchased USDT/ })); - expect(mockGoToDeposit).toHaveBeenCalledWith(); + expect(mockGoToBuy).toHaveBeenCalledWith(); }); }); diff --git a/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.tsx b/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.tsx index 71ba29c81b19..5bea4b619af4 100644 --- a/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.tsx @@ -7,7 +7,7 @@ import { OrderOrderTypeEnum } from '@consensys/on-ramp-sdk/dist/API'; import { createOrderDetailsNavDetails } from '../OrderDetails/OrderDetails'; import { createRampsOrderDetailsNavDetails } from '../../../Views/OrderDetails'; -import { createDepositOrderDetailsNavDetails } from '../../../Deposit/Views/DepositOrderDetails/DepositOrderDetails'; +import { createDepositOrderDetailsNavDetails } from '../../../Views/OrderDetails/DepositOrderDetails/DepositOrderDetails'; import { useRampNavigation } from '../../../hooks/useRampNavigation'; import createStyles from './OrdersList.styles'; import { TabEmptyState } from '../../../../../../component-library/components-temp/TabEmptyState'; @@ -181,7 +181,7 @@ function OrdersList() { const allLegacyOrders = useSelector(getOrders); const { orders: v2Orders } = useRampsOrders(); const [currentFilter, setCurrentFilter] = useState('ALL'); - const { goToDeposit } = useRampNavigation(); + const { goToBuy } = useRampNavigation(); const tw = useTailwind(); const displayOrders = useMemo( @@ -237,7 +237,7 @@ function OrdersList() { order?.state === FIAT_ORDER_STATES.CREATED && order?.provider === FIAT_ORDER_PROVIDERS.DEPOSIT ) { - goToDeposit(); + goToBuy(); } else if (order?.provider === FIAT_ORDER_PROVIDERS.DEPOSIT) { navigation.navigate( ...createDepositOrderDetailsNavDetails({ @@ -248,12 +248,7 @@ function OrdersList() { handleNavigateToAggregatorTxDetails(orderId); } }, - [ - allLegacyOrders, - goToDeposit, - handleNavigateToAggregatorTxDetails, - navigation, - ], + [allLegacyOrders, goToBuy, handleNavigateToAggregatorTxDetails, navigation], ); const handleItemPress = useCallback( diff --git a/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.test.tsx b/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.test.tsx index 920b549ecf44..22b41aecdb97 100644 --- a/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.test.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.test.tsx @@ -47,12 +47,6 @@ jest.mock('@react-navigation/native', () => { }; }); -jest.mock('../../../utils/withRampAndDepositSDK', () => - jest.fn((Component) => (props: Record) => ( - - )), -); - const mockedActivationKeys: ActivationKey[] = [ { key: 'testKey1', @@ -176,12 +170,6 @@ jest.mock('../../sdk', () => ({ withRampSDK: jest.fn().mockImplementation((Component) => Component), })); -let mockUseRampsUnifiedV2EnabledValue = true; - -jest.mock('../../../hooks/useRampsUnifiedV2Enabled', () => - jest.fn(() => mockUseRampsUnifiedV2EnabledValue), -); - describe('Settings', () => { afterEach(() => { jest.clearAllMocks(); @@ -197,7 +185,6 @@ describe('Settings', () => { mockUseRampsControllerValues = { ...mockUseRampsControllerInitialValues, }; - mockUseRampsUnifiedV2EnabledValue = true; }); it('renders correctly', () => { @@ -231,89 +218,53 @@ describe('Settings', () => { }); describe('Region', () => { - describe('V2 enabled', () => { - beforeEach(() => { - mockUseRampsUnifiedV2EnabledValue = true; - }); - - it('renders correctly when region is set', () => { - render(Settings); - expect( - screen.getByRole('button', { name: 'Change region' }), - ).toBeOnTheScreen(); - }); - - it('renders correctly when region is not set', () => { - mockUseRampsControllerValues = { - ...mockUseRampsControllerInitialValues, - userRegion: null, - }; - render(Settings); - expect( - screen.getByRole('button', { name: 'Change region' }), - ).toBeOnTheScreen(); - }); - - it('renders correctly when region has state', () => { - mockUseRampsControllerValues = { - ...mockUseRampsControllerInitialValues, - userRegion: createMockUserRegion('eu-fr'), - }; - render(Settings); - expect(screen.getByText('FR')).toBeOnTheScreen(); - }); - - it('renders correctly when region is country only (no state)', () => { - mockUseRampsControllerValues = { - ...mockUseRampsControllerInitialValues, - userRegion: createMockUserRegion('fr'), - }; - render(Settings); - expect( - screen.getByRole('button', { name: 'Change region' }), - ).toBeOnTheScreen(); - }); - - it('navigates to region selector when change region button is pressed', () => { - render(Settings); - const changeRegionButton = screen.getByRole('button', { - name: 'Change region', - }); - fireEvent.press(changeRegionButton); - expect(mockNavigate).toHaveBeenCalledWith( - Routes.SETTINGS.REGION_SELECTOR, - ); - }); + it('renders correctly when region is set', () => { + render(Settings); + expect( + screen.getByRole('button', { name: 'Change region' }), + ).toBeOnTheScreen(); }); - describe('V2 disabled (Original)', () => { - beforeEach(() => { - mockUseRampsUnifiedV2EnabledValue = false; - }); + it('renders correctly when region is not set', () => { + mockUseRampsControllerValues = { + ...mockUseRampsControllerInitialValues, + userRegion: null, + }; + render(Settings); + expect( + screen.getByRole('button', { name: 'Change region' }), + ).toBeOnTheScreen(); + }); - it('renders correctly when region is set', () => { - render(Settings); - expect( - screen.getByRole('button', { name: 'Reset region' }), - ).toBeOnTheScreen(); - }); + it('renders correctly when region has state', () => { + mockUseRampsControllerValues = { + ...mockUseRampsControllerInitialValues, + userRegion: createMockUserRegion('eu-fr'), + }; + render(Settings); + expect(screen.getByText('FR')).toBeOnTheScreen(); + }); - it('renders correctly when region is not set', () => { - mockUseRampSDKValues = { - ...mockuseRampSDKInitialValues, - selectedRegion: null, - }; - expect(() => render(Settings)).not.toThrow(); - }); + it('renders correctly when region is country only (no state)', () => { + mockUseRampsControllerValues = { + ...mockUseRampsControllerInitialValues, + userRegion: createMockUserRegion('fr'), + }; + render(Settings); + expect( + screen.getByRole('button', { name: 'Change region' }), + ).toBeOnTheScreen(); + }); - it('calls reset region when reset button is pressed', () => { - render(Settings); - const resetRegionButton = screen.getByRole('button', { - name: 'Reset region', - }); - fireEvent.press(resetRegionButton); - expect(mockSetSelectedRegion).toHaveBeenCalledWith(null); + it('navigates to region selector when change region button is pressed', () => { + render(Settings); + const changeRegionButton = screen.getByRole('button', { + name: 'Change region', }); + fireEvent.press(changeRegionButton); + expect(mockNavigate).toHaveBeenCalledWith( + Routes.SETTINGS.REGION_SELECTOR, + ); }); }); diff --git a/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.tsx b/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.tsx index b3ae0c686b12..3547d9388794 100644 --- a/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.tsx +++ b/app/components/UI/Ramp/Aggregator/Views/Settings/Settings.tsx @@ -5,7 +5,6 @@ import { useNavigation } from '@react-navigation/native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useRampSDK, withRampSDK } from '../../sdk'; -import useRampsUnifiedV2Enabled from '../../../hooks/useRampsUnifiedV2Enabled'; import useRampsController from '../../../hooks/useRampsController'; import ScreenLayout from '../../components/ScreenLayout'; import Row from '../../components/Row'; @@ -35,8 +34,7 @@ export const RAMP_SETTINGS_HEADLESS_PLAYGROUND_BUTTON_TEST_ID = function Settings() { const navigation = useNavigation(); - const { isInternalBuild, selectedRegion, setSelectedRegion } = useRampSDK(); - const isRampsUnifiedV2Enabled = useRampsUnifiedV2Enabled(); + const { isInternalBuild } = useRampSDK(); const trackEvent = useAnalytics(); const { userRegion } = useRampsController(); const style = styles(); @@ -45,13 +43,6 @@ function Settings() { navigation.goBack(); }, [navigation]); - const handleResetRegion = useCallback(() => { - trackEvent('RAMP_REGION_RESET', { - location: 'Settings Screen', - }); - setSelectedRegion(null); - }, [setSelectedRegion, trackEvent]); - const handleChangeRegion = useCallback(() => { navigation.navigate(Routes.SETTINGS.REGION_SELECTOR); }, [navigation]); @@ -75,67 +66,31 @@ function Settings() { - {isRampsUnifiedV2Enabled ? ( - - - {strings('app_settings.fiat_on_ramp.current_region')} - - - - - {userRegion?.country?.flag || '🏳️'} - - - - {userRegion?.state?.name || - userRegion?.country?.name || - strings( - 'app_settings.fiat_on_ramp.no_region_selected', - )} - - - -