From c36524a79d6e644e781513f474ffc76f38049037 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Tue, 17 Dec 2024 13:33:34 -0800 Subject: [PATCH 1/4] fix: We don't want to fallback to zero in all cases. In some cases undefined is the correct value, for instance when marketData doesn't exist --- ui/components/app/wallet-overview/coin-buttons.tsx | 1 + ui/pages/asset/components/asset-page.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index 2819e24cad0b..2995025e1456 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -332,6 +332,7 @@ const CoinButtons = ({ const setCorrectChain = useCallback(async () => { if (currentChainId !== chainId) { try { + throw new Error('test error'); const networkConfigurationId = networks[chainId]; await dispatch(setActiveNetworkWithError(networkConfigurationId)); await dispatch( diff --git a/ui/pages/asset/components/asset-page.tsx b/ui/pages/asset/components/asset-page.tsx index 79cf2510f015..398616555a2a 100644 --- a/ui/pages/asset/components/asset-page.tsx +++ b/ui/pages/asset/components/asset-page.tsx @@ -168,11 +168,11 @@ const AssetPage = ({ // Market and conversion rate data const baseCurrency = marketData[chainId]?.[address]?.currency; - const tokenMarketPrice = marketData[chainId]?.[address]?.price || 0; + const tokenMarketPrice = marketData[chainId]?.[address]?.price || undefined; const tokenExchangeRate = type === AssetType.native ? currencyRates[symbol]?.conversionRate - : currencyRates[baseCurrency]?.conversionRate || 0; + : currencyRates[baseCurrency]?.conversionRate || undefined; // Calculate fiat amount const tokenFiatAmount = @@ -284,7 +284,9 @@ const AssetPage = ({ chainId={chainId} symbol={symbol} image={image} - tokenFiatAmount={showFiat ? tokenFiatAmount : null} + tokenFiatAmount={ + showFiat && tokenMarketPrice ? tokenFiatAmount : null + } string={balance?.toString()} /> Date: Tue, 17 Dec 2024 13:47:32 -0800 Subject: [PATCH 2/4] fix: Update snapshots --- .../asset/components/__snapshots__/asset-page.test.tsx.snap | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap b/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap index dc3cf4c408de..c358336cff71 100644 --- a/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap +++ b/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap @@ -223,9 +223,7 @@ exports[`AssetPage should render a native asset 1`] = `

- $0.00 -

+ />
- $0.00 + $NaN

Date: Tue, 17 Dec 2024 14:39:56 -0800 Subject: [PATCH 3/4] fix: Cleanup --- ui/components/app/wallet-overview/coin-buttons.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index 2995025e1456..2819e24cad0b 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -332,7 +332,6 @@ const CoinButtons = ({ const setCorrectChain = useCallback(async () => { if (currentChainId !== chainId) { try { - throw new Error('test error'); const networkConfigurationId = networks[chainId]; await dispatch(setActiveNetworkWithError(networkConfigurationId)); await dispatch( From b2a79e5643476fe4200cbd7c69866354e4186b9c Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Tue, 17 Dec 2024 14:44:41 -0800 Subject: [PATCH 4/4] fix: NaN snapshot --- .../asset/components/__snapshots__/asset-page.test.tsx.snap | 2 +- ui/pages/asset/components/asset-page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap b/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap index c358336cff71..6a55226a42cb 100644 --- a/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap +++ b/ui/pages/asset/components/__snapshots__/asset-page.test.tsx.snap @@ -541,7 +541,7 @@ exports[`AssetPage should render an ERC20 asset without prices 1`] = ` class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--text-align-end mm-box--color-text-default" data-testid="multichain-token-list-item-secondary-value" > - $NaN + $0.00