From 3fa28bf08aae23eca22618bfeccdf0b39f91179d Mon Sep 17 00:00:00 2001 From: Nick Gambino <35090461+gambinish@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:38:37 -0800 Subject: [PATCH] fix: Add optional chaining to currencyRates check for stability (#28753) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** https://github.com/MetaMask/metamask-extension/issues/28750 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28753?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28750 ## **Manual testing steps** Testing steps in issue. Behavior is inconsistent, hard to replicate consistently. ## **Screenshots/Recordings** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- ui/hooks/useTokenFiatAmount.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/hooks/useTokenFiatAmount.js b/ui/hooks/useTokenFiatAmount.js index 2728b2994781..486b8ba14fd6 100644 --- a/ui/hooks/useTokenFiatAmount.js +++ b/ui/hooks/useTokenFiatAmount.js @@ -67,8 +67,8 @@ export function useTokenFiatAmount( ); const tokenConversionRate = chainId - ? currencyRates[networkConfigurationsByChainId[chainId].nativeCurrency] - .conversionRate + ? currencyRates?.[networkConfigurationsByChainId[chainId]?.nativeCurrency] + ?.conversionRate : conversionRate; const currentCurrency = useSelector(getCurrentCurrency);