diff --git a/app/components/UI/Ramp/components/AccountSelector.tsx b/app/components/UI/Ramp/components/AccountSelector.tsx index 270a8e86a12..e50d8037ffa 100644 --- a/app/components/UI/Ramp/components/AccountSelector.tsx +++ b/app/components/UI/Ramp/components/AccountSelector.tsx @@ -35,7 +35,11 @@ const AccountSelector = () => { const selectedInternalAccount = useSelector(selectSelectedInternalAccount); const openAccountSelector = () => - navigation.navigate(...createAccountSelectorNavDetails()); + navigation.navigate( + ...createAccountSelectorNavDetails({ + disablePrivacyMode: true, + }), + ); return ( diff --git a/app/components/UI/WalletAccount/WalletAccount.test.tsx b/app/components/UI/WalletAccount/WalletAccount.test.tsx index d9a1de2c7d4..ef221e22c82 100644 --- a/app/components/UI/WalletAccount/WalletAccount.test.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.test.tsx @@ -9,7 +9,6 @@ import renderWithProvider, { DeepPartial, } from '../../../util/test/renderWithProvider'; import ClipboardManager from '../../../core/ClipboardManager'; -import { createAccountSelectorNavDetails } from '../../../components/Views/AccountSelector'; import { backgroundState } from '../../../util/test/initial-root-state'; import { Account } from '../../hooks/useAccounts'; import { @@ -134,19 +133,6 @@ describe('WalletAccount', () => { fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON)); expect(ClipboardManager.setString).toHaveBeenCalledTimes(1); }); - - it('should navigate to the account selector screen on account press', () => { - const { getByTestId } = renderWithProvider(, { - state: mockInitialState, - }); - - fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); - expect(mockNavigate).toHaveBeenCalledWith( - ...createAccountSelectorNavDetails({ - privacyMode: false, - }), - ); - }); it('displays the correct account name', () => { const { getByText } = renderWithProvider(, { state: mockInitialState, @@ -176,47 +162,4 @@ describe('WalletAccount', () => { expect(getByText(customAccountName)).toBeDefined(); }); }); - - it('should navigate to account selector with privacy mode disabled', () => { - const { getByTestId } = renderWithProvider(, { - state: mockInitialState, - }); - - fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); - expect(mockNavigate).toHaveBeenCalledWith( - ...createAccountSelectorNavDetails({ - privacyMode: false, - }), - ); - }); - - it('should navigate to account selector with privacy mode enabled', () => { - const stateWithPrivacyMode = { - ...mockInitialState, - engine: { - ...mockInitialState.engine, - backgroundState: { - ...mockInitialState.engine?.backgroundState, - PreferencesController: { - privacyMode: true, - }, - }, - }, - }; - - mockSelector.mockImplementation((callback) => - callback(stateWithPrivacyMode), - ); - - const { getByTestId } = renderWithProvider(, { - state: stateWithPrivacyMode, - }); - - fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); - expect(mockNavigate).toHaveBeenCalledWith( - ...createAccountSelectorNavDetails({ - privacyMode: true, - }), - ); - }); }); diff --git a/app/components/UI/WalletAccount/WalletAccount.tsx b/app/components/UI/WalletAccount/WalletAccount.tsx index 63cf33fccdd..e70fe2aad5b 100644 --- a/app/components/UI/WalletAccount/WalletAccount.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.tsx @@ -5,7 +5,6 @@ import { useNavigation } from '@react-navigation/native'; import { View } from 'react-native'; // External dependencies -import { selectPrivacyMode } from '../../../selectors/preferencesController'; import { IconName } from '../../../component-library/components/Icons/Icon'; import PickerAccount from '../../../component-library/components/Pickers/PickerAccount'; import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount'; @@ -38,7 +37,6 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { const yourAccountRef = useRef(null); const accountActionsRef = useRef(null); const selectedAccount = useSelector(selectSelectedInternalAccount); - const privacyMode = useSelector(selectPrivacyMode); const { ensName } = useEnsNameByAddress(selectedAccount?.address); const defaultName = selectedAccount?.metadata?.name; const accountName = useMemo( @@ -88,11 +86,7 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { tags: getTraceTags(store.getState()), op: TraceOperation.AccountList, }); - navigate( - ...createAccountSelectorNavDetails({ - privacyMode, - }), - ); + navigate(...createAccountSelectorNavDetails()); }} accountTypeLabel={ getLabelTextByAddress(selectedAccount?.address) || undefined diff --git a/app/components/Views/AccountSelector/AccountSelector.test.tsx b/app/components/Views/AccountSelector/AccountSelector.test.tsx index f306836197c..4b3ce05f837 100644 --- a/app/components/Views/AccountSelector/AccountSelector.test.tsx +++ b/app/components/Views/AccountSelector/AccountSelector.test.tsx @@ -59,6 +59,9 @@ const mockInitialState = { }, }, }, + PreferencesController: { + privacyMode: false, + }, }, }, accounts: { @@ -101,7 +104,7 @@ const mockRoute: AccountSelectorProps['route'] = { params: { onSelectAccount: jest.fn((address: string) => address), checkBalanceError: (balance: string) => balance, - privacyMode: false, + disablePrivacyMode: false, } as AccountSelectorParams, }; diff --git a/app/components/Views/AccountSelector/AccountSelector.tsx b/app/components/Views/AccountSelector/AccountSelector.tsx index 0565cb81bf0..a1c724e502f 100644 --- a/app/components/Views/AccountSelector/AccountSelector.tsx +++ b/app/components/Views/AccountSelector/AccountSelector.tsx @@ -25,6 +25,8 @@ import Button, { } from '../../../component-library/components/Buttons/Button'; import AddAccountActions from '../AddAccountActions'; import { AccountListBottomSheetSelectorsIDs } from '../../../../e2e/selectors/wallet/AccountListBottomSheet.selectors'; +import { selectPrivacyMode } from '../../../selectors/preferencesController'; + // Internal dependencies. import { AccountSelectorProps, @@ -40,13 +42,14 @@ import { TraceName, endTrace } from '../../../util/trace'; const AccountSelector = ({ route }: AccountSelectorProps) => { const dispatch = useDispatch(); const { trackEvent, createEventBuilder } = useMetrics(); - const { onSelectAccount, checkBalanceError, privacyMode } = + const { onSelectAccount, checkBalanceError, disablePrivacyMode } = route.params || {}; const { reloadAccounts } = useSelector((state: RootState) => state.accounts); // TODO: Replace "any" with type // eslint-disable-next-line @typescript-eslint/no-explicit-any const Engine = UntypedEngine as any; + const privacyMode = useSelector(selectPrivacyMode); const sheetRef = useRef(null); const { accounts, ensByAccountAddress } = useAccounts({ checkBalanceError, @@ -100,7 +103,7 @@ const AccountSelector = ({ route }: AccountSelectorProps) => { accounts={accounts} ensByAccountAddress={ensByAccountAddress} isRemoveAccountEnabled - privacyMode={privacyMode} + privacyMode={privacyMode && !disablePrivacyMode} testID={AccountListBottomSheetSelectorsIDs.ACCOUNT_LIST_ID} /> @@ -110,7 +113,9 @@ const AccountSelector = ({ route }: AccountSelectorProps) => { width={ButtonWidthTypes.Full} size={ButtonSize.Lg} onPress={() => setScreen(AccountSelectorScreens.AddAccountActions)} - testID={AccountListBottomSheetSelectorsIDs.ACCOUNT_LIST_ADD_BUTTON_ID} + testID={ + AccountListBottomSheetSelectorsIDs.ACCOUNT_LIST_ADD_BUTTON_ID + } /> @@ -121,6 +126,7 @@ const AccountSelector = ({ route }: AccountSelectorProps) => { ensByAccountAddress, onRemoveImportedAccount, privacyMode, + disablePrivacyMode, ], ); diff --git a/app/components/Views/AccountSelector/AccountSelector.types.ts b/app/components/Views/AccountSelector/AccountSelector.types.ts index 628d72b288d..7c61d309c3f 100644 --- a/app/components/Views/AccountSelector/AccountSelector.types.ts +++ b/app/components/Views/AccountSelector/AccountSelector.types.ts @@ -36,9 +36,9 @@ export interface AccountSelectorParams { */ checkBalanceError?: UseAccountsParams['checkBalanceError']; /** - * Optional boolean to indicate if privacy mode is enabled. + * Optional boolean to indicate if privacy mode is disabled. */ - privacyMode?: boolean; + disablePrivacyMode?: boolean; } /** diff --git a/app/components/Views/confirmations/SendFlow/AddressFrom/AddressFrom.tsx b/app/components/Views/confirmations/SendFlow/AddressFrom/AddressFrom.tsx index 8820d1ce2b5..bc9efc364d0 100644 --- a/app/components/Views/confirmations/SendFlow/AddressFrom/AddressFrom.tsx +++ b/app/components/Views/confirmations/SendFlow/AddressFrom/AddressFrom.tsx @@ -131,6 +131,7 @@ const SendFlowAddressFrom = ({ params: { isSelectOnly: true, onSelectAccount, + disablePrivacyMode: true, }, }); };