From 9b99609a9c033f614a3e2d169dcddfb560d48fbf Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Fri, 15 Nov 2024 15:09:19 -0800 Subject: [PATCH 1/2] use feature flag --- ui/hooks/useTokenDetectionPolling.ts | 8 +++++++- ui/hooks/useTokenRatesPolling.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ui/hooks/useTokenDetectionPolling.ts b/ui/hooks/useTokenDetectionPolling.ts index 790384e21cbf..d2e08d01892d 100644 --- a/ui/hooks/useTokenDetectionPolling.ts +++ b/ui/hooks/useTokenDetectionPolling.ts @@ -1,5 +1,6 @@ import { useSelector } from 'react-redux'; import { + getCurrentChainId, getNetworkConfigurationsByChainId, getUseTokenDetection, } from '../selectors'; @@ -17,14 +18,19 @@ const useTokenDetectionPolling = () => { const useTokenDetection = useSelector(getUseTokenDetection); const completedOnboarding = useSelector(getCompletedOnboarding); const isUnlocked = useSelector(getIsUnlocked); + const currentChainId = useSelector(getCurrentChainId); const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); const enabled = completedOnboarding && isUnlocked && useTokenDetection; + const chainIds = process.env.PORTFOLIO_VIEW + ? Object.keys(networkConfigurations) + : [currentChainId]; + useMultiPolling({ startPolling: tokenDetectionStartPolling, stopPollingByPollingToken: tokenDetectionStopPollingByPollingToken, - input: enabled ? [Object.keys(networkConfigurations)] : [], + input: enabled ? [chainIds] : [], }); return {}; diff --git a/ui/hooks/useTokenRatesPolling.ts b/ui/hooks/useTokenRatesPolling.ts index a740a426e36c..37864ec89b82 100644 --- a/ui/hooks/useTokenRatesPolling.ts +++ b/ui/hooks/useTokenRatesPolling.ts @@ -1,5 +1,6 @@ import { useSelector } from 'react-redux'; import { + getCurrentChainId, getMarketData, getNetworkConfigurationsByChainId, getTokenExchangeRates, @@ -16,10 +17,11 @@ import { } from '../ducks/metamask/metamask'; import useMultiPolling from './useMultiPolling'; -const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => { +const useTokenRatesPolling = () => { // Selectors to determine polling input const completedOnboarding = useSelector(getCompletedOnboarding); const isUnlocked = useSelector(getIsUnlocked); + const currentChainId = useSelector(getCurrentChainId); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); @@ -30,10 +32,14 @@ const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => { const enabled = completedOnboarding && isUnlocked && useCurrencyRateCheck; + const chainIds = process.env.PORTFOLIO_VIEW + ? Object.keys(networkConfigurations) + : [currentChainId]; + useMultiPolling({ startPolling: tokenRatesStartPolling, stopPollingByPollingToken: tokenRatesStopPollingByPollingToken, - input: enabled ? chainIds ?? Object.keys(networkConfigurations) : [], + input: enabled ? chainIds : [], }); return { From a60bb7d89500b74cb25afe858984d78474a29c6c Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Wed, 20 Nov 2024 11:01:06 -0800 Subject: [PATCH 2/2] fix e2e test --- .../privacy/onboarding-token-price-call-privacy.spec.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts b/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts index a599d96fd5d4..f565c0bb354e 100644 --- a/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts +++ b/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts @@ -21,13 +21,6 @@ async function mockTokenPriceApi( statusCode: 200, json: {}, })), - // linea - await mockServer - .forGet('https://price.api.cx.metamask.io/v2/chains/59144/spot-prices') - .thenCallback(() => ({ - statusCode: 200, - json: {}, - })), ]; }