Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bug 28347 - Privacy mode tweaks (#28367) #28372

Merged
merged 1 commit into from
Nov 8, 2024
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
5 changes: 3 additions & 2 deletions ui/components/app/assets/token-cell/token-cell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { getTokenList, getPreferences } from '../../../../selectors';
import { getTokenList } from '../../../../selectors';
import { useTokenFiatAmount } from '../../../../hooks/useTokenFiatAmount';
import { TokenListItem } from '../../../multichain';
import { isEqualCaseInsensitive } from '../../../../../shared/modules/string-utils';
Expand All @@ -12,6 +12,7 @@ type TokenCellProps = {
symbol: string;
string?: string;
image: string;
privacyMode?: boolean;
onClick?: (arg: string) => void;
};

Expand All @@ -20,10 +21,10 @@ export default function TokenCell({
image,
symbol,
string,
privacyMode = false,
onClick,
}: TokenCellProps) {
const tokenList = useSelector(getTokenList);
const { privacyMode } = useSelector(getPreferences);
const tokenData = Object.values(tokenList).find(
(token) =>
isEqualCaseInsensitive(token.symbol, symbol) &&
Expand Down
4 changes: 3 additions & 1 deletion ui/components/app/assets/token-list/token-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default function TokenList({
nativeToken,
}: TokenListProps) {
const t = useI18nContext();
const { tokenSortConfig, tokenNetworkFilter } = useSelector(getPreferences);
const { tokenSortConfig, tokenNetworkFilter, privacyMode } =
useSelector(getPreferences);
const selectedAccount = useSelector(getSelectedAccount);
const conversionRate = useSelector(getConversionRate);
const nativeTokenWithBalance = useNativeTokenBalance();
Expand Down Expand Up @@ -88,6 +89,7 @@ export default function TokenList({
<TokenCell
key={`${tokenData.symbol}-${tokenData.address}`}
{...tokenData}
privacyMode={privacyMode}
onClick={onTokenClick}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type UserPrefrencedCurrencyDisplayProps = OverridingUnion<
showCurrencySuffix?: boolean;
shouldCheckShowNativeToken?: boolean;
isAggregatedFiatOverviewBalance?: boolean;
privacyMode?: boolean;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function UserPreferencedCurrencyDisplay({
showNative,
showCurrencySuffix,
shouldCheckShowNativeToken,
privacyMode = false,
...restProps
}) {
// NOTE: When displaying currencies, we need the actual account to detect whether we're in a
Expand Down Expand Up @@ -83,6 +84,7 @@ export default function UserPreferencedCurrencyDisplay({
numberOfDecimals={numberOfDecimals}
prefixComponent={prefixComponent}
suffix={showCurrencySuffix && !showEthLogo && currency}
privacyMode={privacyMode}
/>
);
}
Expand Down Expand Up @@ -126,6 +128,7 @@ const UserPreferencedCurrencyDisplayPropTypes = {
textProps: PropTypes.object,
suffixProps: PropTypes.object,
shouldCheckShowNativeToken: PropTypes.bool,
privacyMode: PropTypes.bool,
};

UserPreferencedCurrencyDisplay.propTypes =
Expand Down
6 changes: 3 additions & 3 deletions ui/components/app/wallet-overview/coin-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export const CoinOverview = ({

const shouldShowPopover = useSelector(getShouldShowAggregatedBalancePopover);
const isTestnet = useSelector(getIsTestnet);
const { showFiatInTestnets, privacyMode } = useSelector(getPreferences);
const { showFiatInTestnets, privacyMode, showNativeTokenAsMainBalance } =
useSelector(getPreferences);

const selectedAccount = useSelector(getSelectedAccount);
const shouldHideZeroBalanceTokens = useSelector(
Expand All @@ -143,8 +144,6 @@ export const CoinOverview = ({
shouldHideZeroBalanceTokens,
);

const { showNativeTokenAsMainBalance } = useSelector(getPreferences);

const isEvm = useSelector(getMultichainIsEvm);
const isNotAggregatedFiatBalance =
showNativeTokenAsMainBalance || isTestnet || !isEvm;
Expand Down Expand Up @@ -281,6 +280,7 @@ export const CoinOverview = ({
isAggregatedFiatOverviewBalance={
!showNativeTokenAsMainBalance && !isTestnet
}
privacyMode={privacyMode}
/>
<ButtonIcon
color={IconColor.iconAlternative}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const AccountListItem = ({
startAccessory,
onActionClick,
shouldScrollToWhenSelected = true,
privacyMode = false,
}) => {
const t = useI18nContext();
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
Expand Down Expand Up @@ -313,6 +314,7 @@ const AccountListItem = ({
type={PRIMARY}
showFiat={showFiat}
data-testid="first-currency-display"
privacyMode={privacyMode}
/>
</Text>
</Box>
Expand Down Expand Up @@ -360,6 +362,7 @@ const AccountListItem = ({
type={SECONDARY}
showNative
data-testid="second-currency-display"
privacyMode={privacyMode}
/>
</Text>
</Box>
Expand Down Expand Up @@ -507,6 +510,10 @@ AccountListItem.propTypes = {
* Determines if list item should be scrolled to when selected
*/
shouldScrollToWhenSelected: PropTypes.bool,
/**
* Determines if list balance should be obfuscated
*/
privacyMode: PropTypes.bool,
};

AccountListItem.displayName = 'AccountListItem';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ export const mergeAccounts = (

type AccountListMenuProps = {
onClose: () => void;
privacyMode?: boolean;
showAccountCreation?: boolean;
accountListItemProps?: object;
allowedAccountTypes?: KeyringAccountType[];
};

export const AccountListMenu = ({
onClose,
privacyMode = false,
showAccountCreation = true,
accountListItemProps,
allowedAccountTypes = [
Expand Down Expand Up @@ -644,6 +646,7 @@ export const AccountListMenu = ({
isHidden={Boolean(account.hidden)}
currentTabOrigin={currentTabOrigin}
isActive={Boolean(account.active)}
privacyMode={privacyMode}
{...accountListItemProps}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay';
import { EtherDenomination } from '../../../../shared/constants/common';
import { getPreferences } from '../../../selectors';
import { SensitiveText, Box } from '../../component-library';
import {
AlignItems,
Expand Down Expand Up @@ -35,9 +33,9 @@ export default function CurrencyDisplay({
textProps = {},
suffixProps = {},
isAggregatedFiatOverviewBalance = false,
privacyMode = false,
...props
}) {
const { privacyMode } = useSelector(getPreferences);
const [title, parts] = useCurrencyDisplay(value, {
account,
displayValue,
Expand Down Expand Up @@ -125,6 +123,7 @@ const CurrencyDisplayPropTypes = {
textProps: PropTypes.object,
suffixProps: PropTypes.object,
isAggregatedFiatOverviewBalance: PropTypes.bool,
privacyMode: PropTypes.bool,
};

CurrencyDisplay.propTypes = CurrencyDisplayPropTypes;
7 changes: 6 additions & 1 deletion ui/pages/routes/routes.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default class Routes extends Component {
history: PropTypes.object,
location: PropTypes.object,
autoLockTimeLimit: PropTypes.number,
privacyMode: PropTypes.bool,
pageChanged: PropTypes.func.isRequired,
browserEnvironmentOs: PropTypes.string,
browserEnvironmentBrowser: PropTypes.string,
Expand Down Expand Up @@ -417,6 +418,7 @@ export default class Routes extends Component {
switchedNetworkDetails,
clearSwitchedNetworkDetails,
clearEditedNetwork,
privacyMode,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
isShowKeyringSnapRemovalResultModal,
hideShowKeyringSnapRemovalResultModal,
Expand Down Expand Up @@ -494,7 +496,10 @@ export default class Routes extends Component {
///: END:ONLY_INCLUDE_IF
}
{isAccountMenuOpen ? (
<AccountListMenu onClose={() => toggleAccountMenu()} />
<AccountListMenu
onClose={() => toggleAccountMenu()}
privacyMode={privacyMode}
/>
) : null}
{isNetworkMenuOpen ? (
<NetworkListMenu
Expand Down
3 changes: 2 additions & 1 deletion ui/pages/routes/routes.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Routes from './routes.component';
function mapStateToProps(state) {
const { activeTab, appState } = state;
const { alertOpen, alertMessage, isLoading, loadingMessage } = appState;
const { autoLockTimeLimit = DEFAULT_AUTO_LOCK_TIME_LIMIT } =
const { autoLockTimeLimit = DEFAULT_AUTO_LOCK_TIME_LIMIT, privacyMode } =
getPreferences(state);
const { completedOnboarding } = state.metamask;

Expand All @@ -81,6 +81,7 @@ function mapStateToProps(state) {
isNetworkLoading: isNetworkLoading(state),
currentCurrency: state.metamask.currentCurrency,
autoLockTimeLimit,
privacyMode,
browserEnvironmentOs: state.metamask.browserEnvironment?.os,
browserEnvironmentContainter: state.metamask.browserEnvironment?.browser,
providerId: getNetworkIdentifier(state),
Expand Down