diff --git a/src/ui/App/App.tsx b/src/ui/App/App.tsx index 2a2d714e7..1e0f6cb38 100644 --- a/src/ui/App/App.tsx +++ b/src/ui/App/App.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import { AreaProvider } from 'react-area'; +import { AreaProvider, RenderArea } from 'react-area'; import { QueryClientProvider, useQuery } from '@tanstack/react-query'; import { HashRouter as Router, @@ -81,6 +81,7 @@ import { BackupPage } from '../pages/Backup/Backup'; import { ProgrammaticNavigationHelper } from '../shared/routing/ProgrammaticNavigationHelper'; import { Invite } from '../features/referral-program'; import { XpDrop } from '../features/xp-drop'; +import { HideBalancesFeature } from '../features/hide-balances/HideBalancesFeature'; import { RouteRestoration, registerPersistentRoute } from './RouteRestoration'; const isProd = process.env.NODE_ENV === 'production'; @@ -453,6 +454,7 @@ function GlobalKeyboardShortcuts() { openUrl(url, { windowType: 'tab' }); }} /> + ); } @@ -502,10 +504,12 @@ export function App({ initialView, inspect }: AppProps) { }> + + {inspect && !isProd ? ( ) : null} - {!isOnboardingView && !isPageLayout ? ( // Render above so that it doesn't flicker diff --git a/src/ui/components/HideBalance/BlurWithPixels.tsx b/src/ui/components/HideBalance/BlurWithPixels.tsx new file mode 100644 index 000000000..1a7e7b988 --- /dev/null +++ b/src/ui/components/HideBalance/BlurWithPixels.tsx @@ -0,0 +1,71 @@ +import React, { useMemo } from 'react'; + +interface BlurPixelsProps { + color?: 'neutral' | 'positive' | 'negative' | 'primary'; + // kind?: Kind; + height?: number; + pixelsProportion?: number; +} +interface BlurrableTextProps extends BlurPixelsProps { + children: React.ReactNode; +} + +function randomIntFromInterval(min: number, max: number) { + return Math.floor(Math.random() * (max - min + 1) + min); +} + +const getColorArray = (n: number, color: BlurrableTextProps['color']) => { + return [...Array(n * 2).keys()].map( + () => `var(--${color}-${randomIntFromInterval(1, 4) * 100})` + ); +}; + +export function BlurWithPixels({ + color = 'neutral', + // kind, + height, + pixelsProportion = 90, +}: BlurPixelsProps) { + const rowLength = useMemo(() => randomIntFromInterval(4, 6), []); + const pixelsColors = useMemo( + () => getColorArray(rowLength, color), + [color, rowLength] + ); + // const gridHeight = height || (kind ? textParams[kind][1] : '1em'); + const gridHeight = height || '1em'; + + return ( + + + {pixelsColors.map((color, index) => ( + + ))} + + + ); +} diff --git a/src/ui/components/HideBalance/HideBalance.tsx b/src/ui/components/HideBalance/HideBalance.tsx new file mode 100644 index 000000000..d312e01fb --- /dev/null +++ b/src/ui/components/HideBalance/HideBalance.tsx @@ -0,0 +1,85 @@ +import { useStore } from '@store-unit/react'; +import type BigNumber from 'bignumber.js'; +import React from 'react'; +import { + formatCurrencyToParts, + formatCurrencyValue, +} from 'src/shared/units/formatCurrencyValue'; +import { formatTokenValue } from 'src/shared/units/formatTokenValue'; +import { + HideBalanceMode, + hideBalancesStore, +} from 'src/ui/features/hide-balances/store'; +import { NeutralDecimals } from 'src/ui/ui-kit/NeutralDecimals'; +import { BlurWithPixels } from './BlurWithPixels'; + +function reduceValue(value: number, target = 50) { + do { + value = value / 10; + } while (Math.abs(value) > target); + return value; +} + +function shuffle(value: number) { + return value * Math.PI; +} + +function hideBalance( + value: number, + currency: string, + mode: HideBalanceMode +): number { + if (mode === HideBalanceMode.poorMode2) { + return value / 10; + } else if (mode === HideBalanceMode.poorMode3) { + return value / 100; + } else { + if (currency === 'btc') { + return shuffle(reduceValue(value, 0.001)); + } + return shuffle(reduceValue(value)); + } +} + +function isPoorMode(mode: HideBalanceMode) { + return ( + mode === hideBalancesStore.MODE.poorMode1 || + mode === hideBalancesStore.MODE.poorMode2 || + mode === hideBalancesStore.MODE.poorMode3 + ); +} + +export function HideBalance({ + value: originalValue, + children, + kind = 'currencyValue', + locale = 'en', + currency = 'usd', + symbol = '', +}: React.PropsWithChildren<{ + value: string | number | BigNumber; + locale?: string; + currency?: string; + kind?: 'NeutralDecimals' | 'currencyValue' | 'tokenValue'; + symbol?: string; +}>) { + const { mode } = useStore(hideBalancesStore); + if (mode === hideBalancesStore.MODE.default) { + return children; + } else if (isPoorMode(mode)) { + const fakeValue = hideBalance(Number(originalValue), currency, mode); + if (kind === 'NeutralDecimals') { + return ( + + ); + } else if (kind === 'currencyValue') { + return {formatCurrencyValue(fakeValue, locale, currency)}; + } else if (kind === 'tokenValue') { + return {formatTokenValue(fakeValue, symbol)}; + } + } else if (mode === hideBalancesStore.MODE.blurred) { + return ; + } +} diff --git a/src/ui/components/HideBalance/index.ts b/src/ui/components/HideBalance/index.ts new file mode 100644 index 000000000..ab223ad48 --- /dev/null +++ b/src/ui/components/HideBalance/index.ts @@ -0,0 +1 @@ +export { HideBalance } from './HideBalance'; diff --git a/src/ui/components/WalletDisplayName/WalletDisplayName.tsx b/src/ui/components/WalletDisplayName/WalletDisplayName.tsx index 8a3a8fe51..07668f558 100644 --- a/src/ui/components/WalletDisplayName/WalletDisplayName.tsx +++ b/src/ui/components/WalletDisplayName/WalletDisplayName.tsx @@ -1,24 +1,48 @@ +import { useStore } from '@store-unit/react'; import React from 'react'; import type { ExternallyOwnedAccount } from 'src/shared/types/ExternallyOwnedAccount'; +import { hideBalancesStore } from 'src/ui/features/hide-balances/store'; import { useProfileName } from 'src/ui/shared/useProfileName'; -export function WalletDisplayName({ - wallet, - padding, - maxCharacters, - render, -}: { +interface Props { wallet: ExternallyOwnedAccount; padding?: number; maxCharacters?: number; + tryEns?: boolean; render?: (data: ReturnType) => React.ReactNode; -}) { +} + +export function WalletDisplayNameBase({ + wallet, + padding, + maxCharacters, + tryEns = true, + render, +}: Props) { const data = useProfileName(wallet, { padding, maxCharacters, + enabled: tryEns, }); if (render) { return render(data); } return {data.value}; } + +const toFakeAddr = (address: string) => { + const shifted = + BigInt(address) - 99999999999999999999999999999999999999999999999n; + return `0x${shifted.toString(16)}`; +}; + +export function WalletDisplayName(props: Props) { + const { mode } = useStore(hideBalancesStore); + if (mode !== hideBalancesStore.MODE.default) { + const fakeAddr = toFakeAddr(props.wallet.address); + const wallet = { ...props.wallet, address: fakeAddr }; + return ; + } else { + return ; + } +} diff --git a/src/ui/features/hide-balances/HideBalancesFeature.tsx b/src/ui/features/hide-balances/HideBalancesFeature.tsx new file mode 100644 index 000000000..9bed60df8 --- /dev/null +++ b/src/ui/features/hide-balances/HideBalancesFeature.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Content } from 'react-area'; +import { KeyboardShortcut } from 'src/ui/components/KeyboardShortcut'; +import { hideBalancesStore } from './store'; + +export function HideBalancesFeature() { + return ( + <> + + { + hideBalancesStore.nextMode(); + }} + /> + { + hideBalancesStore.nextTemporary(); + }} + /> + + + ); +} diff --git a/src/ui/features/hide-balances/HideBalancesModeToggle.tsx b/src/ui/features/hide-balances/HideBalancesModeToggle.tsx new file mode 100644 index 000000000..d9398ddec --- /dev/null +++ b/src/ui/features/hide-balances/HideBalancesModeToggle.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { useStore } from '@store-unit/react'; +import EyeIcon from 'jsx:src/ui/assets/eye.svg'; +import { Button } from 'src/ui/ui-kit/Button'; +import { hideBalancesStore } from './store'; + +export function HideBalancesModeToggle() { + const { mode } = useStore(hideBalancesStore); + if (mode === hideBalancesStore.MODE.default) { + return null; + } + return ( + + ); +} diff --git a/src/ui/features/hide-balances/store.ts b/src/ui/features/hide-balances/store.ts new file mode 100644 index 000000000..f3b33c813 --- /dev/null +++ b/src/ui/features/hide-balances/store.ts @@ -0,0 +1,74 @@ +import { PersistentStore } from 'src/modules/persistent-store'; + +export enum HideBalanceMode { + default, + poorMode1, + poorMode2, + poorMode3, + blurred, +} + +const poorModeKinds = new Set([ + HideBalanceMode.poorMode1, + HideBalanceMode.poorMode2, + HideBalanceMode.poorMode3, +]); + +export function isPoorMode(mode: HideBalanceMode) { + return poorModeKinds.has(mode); +} + +interface State { + mode: HideBalanceMode; + poorModeKind: HideBalanceMode; +} + +class HideBalancesStore extends PersistentStore { + MODE = HideBalanceMode; + + nextMode() { + this.setState((state) => { + const nextMap = { + [HideBalanceMode.default]: state.poorModeKind, + [HideBalanceMode.poorMode1]: HideBalanceMode.blurred, + [HideBalanceMode.poorMode2]: HideBalanceMode.blurred, + [HideBalanceMode.poorMode3]: HideBalanceMode.blurred, + [HideBalanceMode.blurred]: HideBalanceMode.default, + }; + return { + ...state, + mode: nextMap[state.mode], + }; + }); + } + + nextTemporary() { + this.setState((state) => { + const nextMap = { + [HideBalanceMode.default]: HideBalanceMode.poorMode1, + [HideBalanceMode.poorMode1]: HideBalanceMode.poorMode2, + [HideBalanceMode.poorMode2]: HideBalanceMode.poorMode3, + [HideBalanceMode.poorMode3]: HideBalanceMode.default, + [HideBalanceMode.blurred]: HideBalanceMode.default, + }; + const mode = nextMap[state.mode]; + return { + mode, + poorModeKind: isPoorMode(mode) ? mode : state.poorModeKind, + }; + }); + } + + setMode(mode: HideBalanceMode) { + this.setState((state) => ({ + mode, + poorModeKind: isPoorMode(mode) ? mode : state.poorModeKind, + })); + } +} + +const KEY = 'hide-balances-v1'; +export const hideBalancesStore = new HideBalancesStore( + { mode: HideBalanceMode.default, poorModeKind: HideBalanceMode.poorMode1 }, + KEY +); diff --git a/src/ui/pages/History/ActionDetailedView/components/TransferInfo.tsx b/src/ui/pages/History/ActionDetailedView/components/TransferInfo.tsx index 9d0d56929..7fd902763 100644 --- a/src/ui/pages/History/ActionDetailedView/components/TransferInfo.tsx +++ b/src/ui/pages/History/ActionDetailedView/components/TransferInfo.tsx @@ -22,6 +22,7 @@ import { NetworkId } from 'src/modules/networks/NetworkId'; import * as helperStyles from 'src/ui/style/helpers.module.css'; import { AssetLink } from 'src/ui/components/AssetLink'; import { useCurrency } from 'src/modules/currency/useCurrency'; +import { HideBalance } from 'src/ui/components/HideBalance'; import { isUnlimitedApproval } from '../../isUnlimitedApproval'; type Direction = 'incoming' | 'outgoing'; @@ -165,7 +166,9 @@ function FungibleTransfer({ title={formatTokenValue(balance, fungible.symbol)} > {direction === 'incoming' ? '+' : minus} - {formatTokenValue(balance, '')} + + {formatTokenValue(balance, '')} + @@ -174,11 +177,18 @@ function FungibleTransfer({ detailText={ {almostEqual} - {formatCurrencyValue( - balance.times(transfer.price || 0), - 'en', - currency - )} + + {formatCurrencyValue( + balance.times(transfer.price || 0), + 'en', + currency + )} + } /> diff --git a/src/ui/pages/History/ActionItem/TransactionItemValue.tsx b/src/ui/pages/History/ActionItem/TransactionItemValue.tsx index 041350ae0..9f2cc6841 100644 --- a/src/ui/pages/History/ActionItem/TransactionItemValue.tsx +++ b/src/ui/pages/History/ActionItem/TransactionItemValue.tsx @@ -19,6 +19,7 @@ import { formatCurrencyValue } from 'src/shared/units/formatCurrencyValue'; import { AssetQuantity } from 'src/ui/components/AssetQuantity'; import { AssetLink } from 'src/ui/components/AssetLink'; import { NFTLink } from 'src/ui/components/NFTLink'; +import { HideBalance } from 'src/ui/components/HideBalance'; function getSign( decimaledValue?: number | BigNumber | string, @@ -74,7 +75,13 @@ function HistoryTokenValue({ title={commonQuantity?.toFixed()} > {commonQuantity ? ( - + + + ) : null} {withLink ? ( @@ -200,10 +207,15 @@ export function TransactionCurrencyValue({ chain, baseQuantity: transfer.quantity, }); - const value = formatCurrencyValue( - commonQuantity.times(transfer.price || 0), - 'en', - currency + const value = commonQuantity.times(transfer.price || 0); + return ( + + {formatCurrencyValue(value, 'en', currency)} + ); - return <>{value}; } diff --git a/src/ui/pages/Overview/NonFungibleTokens/NonFungibleTokens.tsx b/src/ui/pages/Overview/NonFungibleTokens/NonFungibleTokens.tsx index ba0e1302b..717144731 100644 --- a/src/ui/pages/Overview/NonFungibleTokens/NonFungibleTokens.tsx +++ b/src/ui/pages/Overview/NonFungibleTokens/NonFungibleTokens.tsx @@ -34,6 +34,7 @@ import { } from 'src/ui/DNA/components/DnaBanners'; import { useStore } from '@store-unit/react'; import { useCurrency } from 'src/modules/currency/useCurrency'; +import { HideBalance } from 'src/ui/components/HideBalance'; import { getNftEntityUrl } from '../../NonFungibleToken/getEntityUrl'; import { getGrownTabMaxHeight, offsetValues } from '../getTabsOffset'; import { NetworkBalance } from '../Positions/NetworkBalance'; @@ -133,9 +134,16 @@ function NFTItem({ {price ? ( - + + + ) : someHavePrice ? ( {NBSP} @@ -318,9 +326,16 @@ export function NonFungibleTokens({ onChange={onChainChange} value={ nftChainValue != null ? ( - + + + ) : null } /> diff --git a/src/ui/pages/Overview/Overview.tsx b/src/ui/pages/Overview/Overview.tsx index ad0ed34c5..027bd1170 100644 --- a/src/ui/pages/Overview/Overview.tsx +++ b/src/ui/pages/Overview/Overview.tsx @@ -68,6 +68,8 @@ import { FEATURE_LOYALTY_FLOW } from 'src/env/config'; import { useRemoteConfigValue } from 'src/modules/remote-config/useRemoteConfigValue'; import type { ExternallyOwnedAccount } from 'src/shared/types/ExternallyOwnedAccount'; import { emitter } from 'src/ui/shared/events'; +import { HideBalance } from 'src/ui/components/HideBalance'; +import { HideBalancesModeToggle } from 'src/ui/features/hide-balances/HideBalancesModeToggle'; import { HistoryList } from '../History/History'; import { SettingsLinkIcon } from '../Settings/SettingsLinkIcon'; import { WalletAvatar } from '../../components/WalletAvatar'; @@ -247,6 +249,7 @@ function CurrentAccountControls() { textToCopy={addressToCopy} tooltipContent="Address Copied" /> + @@ -584,13 +587,20 @@ function OverviewComponent() { {walletPortfolio?.totalValue != null ? ( - + + + ) : ( NBSP )} @@ -611,13 +621,27 @@ function OverviewComponent() { } > {`${sign}${change.formatted}`}{' '} - {walletPortfolio?.change24h.absolute - ? `(${formatCurrencyValue( - Math.abs(walletPortfolio.change24h.absolute), - 'en', - currency - )})` - : ''}{' '} + {walletPortfolio?.change24h.absolute ? ( + <> + {'('} + + + {formatCurrencyValue( + Math.abs(walletPortfolio.change24h.absolute), + 'en', + currency + )} + + + {')'} + + ) : ( + '' + )}{' '} Today ); diff --git a/src/ui/pages/Overview/Positions/Positions.tsx b/src/ui/pages/Overview/Positions/Positions.tsx index be3d0ea01..62bdae280 100644 --- a/src/ui/pages/Overview/Positions/Positions.tsx +++ b/src/ui/pages/Overview/Positions/Positions.tsx @@ -63,6 +63,7 @@ import { useWalletPortfolio } from 'src/modules/zerion-api/hooks/useWalletPortfo import type { WalletPortfolio } from 'src/modules/zerion-api/requests/wallet-get-portfolio'; import { usePositionsRefetchInterval } from 'src/ui/transactions/usePositionsRefetchInterval'; import { openHrefInTabIfSidepanel } from 'src/ui/shared/openInTabIfInSidepanel'; +import { HideBalance } from 'src/ui/components/HideBalance'; import { TAB_SELECTOR_HEIGHT, TAB_TOP_PADDING, @@ -234,14 +235,26 @@ function AddressPositionItem({ ) : position.quantity ? ( - {formatTokenValue( - getCommonQuantity({ + + {formatTokenValue( + getCommonQuantity({ + asset: position.asset, + chain, + baseQuantity: position.quantity, + }), + position.asset.symbol + )} + ) : null, ], @@ -255,7 +268,13 @@ function AddressPositionItem({ {position.value != null ? ( - {formatCurrencyValue(position.value, 'en', currency)} + + {formatCurrencyValue(position.value, 'en', currency)} + {position.asset.price?.relative_change_24h ? ( + {formatCurrencyValue(absoluteChange, 'en', currency)} + + {')'} ) : null} @@ -601,9 +628,16 @@ function PositionList({ - + + + ) : null} @@ -703,9 +737,16 @@ function MultiChainPositions({ onChange={onChainChange} value={ chainTotalValue ? ( - + + + ) : null } /> diff --git a/src/ui/pages/Settings/HideBalancesPage/HideBalancesPage.tsx b/src/ui/pages/Settings/HideBalancesPage/HideBalancesPage.tsx new file mode 100644 index 000000000..45518e33b --- /dev/null +++ b/src/ui/pages/Settings/HideBalancesPage/HideBalancesPage.tsx @@ -0,0 +1,175 @@ +import { useStore } from '@store-unit/react'; +import React from 'react'; +import CheckIcon from 'jsx:src/ui/assets/check.svg'; +import { useBackgroundKind } from 'src/ui/components/Background'; +import { NavigationTitle } from 'src/ui/components/NavigationTitle'; +import { PageColumn } from 'src/ui/components/PageColumn'; +import { PageTop } from 'src/ui/components/PageTop'; +import { hideBalancesStore } from 'src/ui/features/hide-balances/store'; +import { Frame } from 'src/ui/ui-kit/Frame'; +import { FrameListItemButton } from 'src/ui/ui-kit/FrameList'; +import { HStack } from 'src/ui/ui-kit/HStack'; +import { VStack } from 'src/ui/ui-kit/VStack'; +import { UIText } from 'src/ui/ui-kit/UIText'; +import { useWalletPortfolio } from 'src/modules/zerion-api/hooks/useWalletPortfolio'; +import { useCurrency } from 'src/modules/currency/useCurrency'; +import { useAddressParams } from 'src/ui/shared/user-address/useAddressParams'; +import { useHttpClientSource } from 'src/modules/zerion-api/hooks/useHttpClientSource'; +import { HideBalance } from 'src/ui/components/HideBalance'; +import { NeutralDecimals } from 'src/ui/ui-kit/NeutralDecimals'; +import { formatCurrencyToParts } from 'src/shared/units/formatCurrencyValue'; +import { Spacer } from 'src/ui/ui-kit/Spacer'; + +function TotalValue() { + const { currency } = useCurrency(); + const { params, ready } = useAddressParams(); + const { data } = useWalletPortfolio( + { addresses: [params.address], currency }, + { source: useHttpClientSource() }, + { enabled: ready, refetchInterval: 40000 } + ); + const walletPortfolio = data?.data; + if (walletPortfolio?.totalValue == null) { + return null; + } + return ( + + + + ); +} + +const sections = [ + { + title: 'Default', + mode: hideBalancesStore.MODE.default, + }, + { + title: 'Poor Mode', + sections: [ + { + title: 'Default Poor', + mode: hideBalancesStore.MODE.poorMode1, + }, + { + title: 'x10 Poor', + mode: hideBalancesStore.MODE.poorMode2, + }, + { + title: 'x100 Poor', + mode: hideBalancesStore.MODE.poorMode3, + }, + ], + }, + { + title: 'Blurred', + mode: hideBalancesStore.MODE.blurred, + }, +]; + +function Row({ + text, + checked, + onClick, + nested, +}: { + text: string; + checked: boolean; + onClick: null | (() => void); + nested: boolean; +}) { + const content = ( +
+ {text} + {checked ? ( + + ) : null} +
+ ); + if (onClick) { + return ( + + {content} + + ); + } else { + return
{content}
; + } +} + +export function HideBalancesPage() { + useBackgroundKind({ kind: 'white' }); + const { mode: currentMode } = useStore(hideBalancesStore); + // const goBack = useGoBack(); + + return ( + + + + + + + {sections.map((section) => { + return ( + + hideBalancesStore.setMode(section.mode) + : null + } + /> + {section.sections?.map((subSection) => ( + + hideBalancesStore.setMode(subSection.mode)} + /> + + ))} + + ); + })} + + + + + Example + + + + + + ); +} diff --git a/src/ui/pages/Settings/HideBalancesPage/index.ts b/src/ui/pages/Settings/HideBalancesPage/index.ts new file mode 100644 index 000000000..53da7e958 --- /dev/null +++ b/src/ui/pages/Settings/HideBalancesPage/index.ts @@ -0,0 +1 @@ +export { HideBalancesPage } from './HideBalancesPage'; diff --git a/src/ui/pages/Settings/Preferences.tsx b/src/ui/pages/Settings/Preferences.tsx index d965f7ef7..99e5a6eb8 100644 --- a/src/ui/pages/Settings/Preferences.tsx +++ b/src/ui/pages/Settings/Preferences.tsx @@ -20,6 +20,7 @@ import { VStack } from 'src/ui/ui-kit/VStack'; import CheckIcon from 'jsx:src/ui/assets/check.svg'; import { preferenceStore } from 'src/ui/features/appearance'; import { useGoBack } from 'src/ui/shared/navigation/useGoBack'; +import { HideBalancesPage } from './HideBalancesPage'; function CurrencyPage() { const { currency } = useCurrency(); @@ -86,24 +87,44 @@ function PreferencesMain() { - - - - - - Currency - - {CURRENCIES[currency].code.toUpperCase()} - - - - - - + + + + + + + Currency + + {CURRENCIES[currency].code.toUpperCase()} + + + + + + + + + + + + Hide Balances + + Shift+H + + + + + + + ); @@ -128,6 +149,14 @@ export function PreferencesPage() { } /> + + + + } + /> ); } diff --git a/src/ui/pages/WalletSelect/WalletList.tsx b/src/ui/pages/WalletSelect/WalletList.tsx index 7b4d1b237..1843161ad 100644 --- a/src/ui/pages/WalletSelect/WalletList.tsx +++ b/src/ui/pages/WalletSelect/WalletList.tsx @@ -22,6 +22,7 @@ import { CopyButton } from 'src/ui/components/CopyButton'; import { useCurrency } from 'src/modules/currency/useCurrency'; import { normalizeAddress } from 'src/shared/normalizeAddress'; import { VStack } from 'src/ui/ui-kit/VStack'; +import { HideBalance } from 'src/ui/components/HideBalance'; import * as styles from './styles.module.css'; function WalletListItem({ @@ -185,13 +186,20 @@ function WalletListItem({ render={(query) => ( {query.data ? ( - + + + ) : ( NBSP )} diff --git a/src/ui/pages/WalletSelect/WalletSelect.tsx b/src/ui/pages/WalletSelect/WalletSelect.tsx index 96365229d..a289e1ad1 100644 --- a/src/ui/pages/WalletSelect/WalletSelect.tsx +++ b/src/ui/pages/WalletSelect/WalletSelect.tsx @@ -33,6 +33,7 @@ import { getWalletParams } from 'src/ui/shared/requests/useWalletParams'; import { UnstyledAnchor } from 'src/ui/ui-kit/UnstyledAnchor'; import { useWalletsMetaByChunks } from 'src/ui/shared/requests/useWalletsMetaByChunks'; import { emitter } from 'src/ui/shared/events'; +import { HideBalance } from 'src/ui/components/HideBalance'; import * as styles from './styles.module.css'; import { WalletList } from './WalletList'; @@ -65,13 +66,20 @@ function PortfolioRow({ walletGroups }: { walletGroups: WalletGroup[] }) { {isLoading || !walletPortfolio ? ( ellipsis ) : ( - + + + )} } diff --git a/src/ui/shared/requests/PortfolioValue/ChainValue/ChainValue.tsx b/src/ui/shared/requests/PortfolioValue/ChainValue/ChainValue.tsx index 5449422cc..cd5d59796 100644 --- a/src/ui/shared/requests/PortfolioValue/ChainValue/ChainValue.tsx +++ b/src/ui/shared/requests/PortfolioValue/ChainValue/ChainValue.tsx @@ -1,8 +1,9 @@ -import type React from 'react'; +import React from 'react'; import type { Chain } from 'src/modules/networks/Chain'; import type { WalletPortfolio } from 'src/modules/zerion-api/requests/wallet-get-portfolio'; import { NetworkSelectValue } from 'src/modules/networks/NetworkSelectValue'; import { formatCurrencyValue } from 'src/shared/units/formatCurrencyValue'; +import { HideBalance } from 'src/ui/components/HideBalance'; export type ChainDistribution = Pick< WalletPortfolio, @@ -18,14 +19,16 @@ export function ChainValue({ chainDistribution: ChainDistribution | null; currency: string; }) { - const value = + const maybeValue = chain === NetworkSelectValue.All ? chainDistribution?.totalValue : chainDistribution?.positionsChainsDistribution[chain.toString()]; - return formatCurrencyValue( - value || 0, - 'en', - currency - ) as React.ReactNode as JSX.Element; + const value = maybeValue || 0; + + return ( + + {formatCurrencyValue(value, 'en', currency)} + + ); } diff --git a/src/ui/shared/useProfileName.ts b/src/ui/shared/useProfileName.ts index 0cfe0bce9..ac61b292c 100644 --- a/src/ui/shared/useProfileName.ts +++ b/src/ui/shared/useProfileName.ts @@ -27,12 +27,13 @@ export function useProfileName( { padding = 5, maxCharacters, - }: { padding?: number; maxCharacters?: number } = {} + enabled = true, + }: { padding?: number; maxCharacters?: number; enabled?: boolean } = {} ): { type: WalletNameType; value: string } { const { isLoading: isDomainLoading, data: domain } = useQuery({ queryKey: persistentQuery([lookupAddressNameKey, wallet.address]), queryFn: async () => lookupAddressName(wallet.address), - enabled: !wallet.name, + enabled: enabled && !wallet.name, suspense: false, refetchOnWindowFocus: false, refetchOnMount: false,