From 8bcd777d0b060267d19ae1c3d25a36ab99f6ea87 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 20 Nov 2024 18:46:57 -0600 Subject: [PATCH] fix: PortfolioView: Remove pausedChainIds from selector (#28552) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** After speaking with Infura, we no longer need this `pausedChainIds` property from the remote API. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28552?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. No manual testing, simply removing property and its tests ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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/selectors/selectors.js | 18 ++++-------------- ui/selectors/selectors.test.js | 26 -------------------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 7e4d04eeb3de..3c49befb6dd3 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -2240,30 +2240,23 @@ export const getAllEnabledNetworks = createDeepEqualSelector( ); export const getChainIdsToPoll = createDeepEqualSelector( - getPreferences, getNetworkConfigurationsByChainId, getCurrentChainId, - (preferences, networkConfigurations, currentChainId) => { - const { pausedChainIds = [] } = preferences; - + (networkConfigurations, currentChainId) => { if (!process.env.PORTFOLIO_VIEW) { return [currentChainId]; } return Object.keys(networkConfigurations).filter( - (chainId) => - !TEST_CHAINS.includes(chainId) && !pausedChainIds.includes(chainId), + (chainId) => !TEST_CHAINS.includes(chainId), ); }, ); export const getNetworkClientIdsToPoll = createDeepEqualSelector( - getPreferences, getNetworkConfigurationsByChainId, getCurrentChainId, - (preferences, networkConfigurations, currentChainId) => { - const { pausedChainIds = [] } = preferences; - + (networkConfigurations, currentChainId) => { if (!process.env.PORTFOLIO_VIEW) { const networkConfiguration = networkConfigurations[currentChainId]; return [ @@ -2275,10 +2268,7 @@ export const getNetworkClientIdsToPoll = createDeepEqualSelector( return Object.entries(networkConfigurations).reduce( (acc, [chainId, network]) => { - if ( - !TEST_CHAINS.includes(chainId) && - !pausedChainIds.includes(chainId) - ) { + if (!TEST_CHAINS.includes(chainId)) { acc.push( network.rpcEndpoints[network.defaultRpcEndpointIndex] .networkClientId, diff --git a/ui/selectors/selectors.test.js b/ui/selectors/selectors.test.js index 85180dec45f4..d3799885eaf6 100644 --- a/ui/selectors/selectors.test.js +++ b/ui/selectors/selectors.test.js @@ -873,7 +873,6 @@ describe('Selectors', () => { it('returns only non-test chain IDs', () => { const chainIds = selectors.getChainIdsToPoll({ metamask: { - preferences: { pausedChainIds: [] }, networkConfigurationsByChainId, selectedNetworkClientId: 'mainnet', }, @@ -884,18 +883,6 @@ describe('Selectors', () => { CHAIN_IDS.LINEA_MAINNET, ]); }); - - it('does not return paused chain IDs', () => { - const chainIds = selectors.getChainIdsToPoll({ - metamask: { - preferences: { pausedChainIds: [CHAIN_IDS.LINEA_MAINNET] }, - networkConfigurationsByChainId, - selectedNetworkClientId: 'mainnet', - }, - }); - expect(Object.values(chainIds)).toHaveLength(1); - expect(chainIds).toStrictEqual([CHAIN_IDS.MAINNET]); - }); }); describe('#getNetworkClientIdsToPoll', () => { @@ -933,7 +920,6 @@ describe('Selectors', () => { it('returns only non-test chain IDs', () => { const chainIds = selectors.getNetworkClientIdsToPoll({ metamask: { - preferences: { pausedChainIds: [] }, networkConfigurationsByChainId, selectedNetworkClientId: 'mainnet', }, @@ -941,18 +927,6 @@ describe('Selectors', () => { expect(Object.values(chainIds)).toHaveLength(2); expect(chainIds).toStrictEqual(['mainnet', 'linea-mainnet']); }); - - it('does not return paused chain IDs', () => { - const chainIds = selectors.getNetworkClientIdsToPoll({ - metamask: { - preferences: { pausedChainIds: [CHAIN_IDS.LINEA_MAINNET] }, - networkConfigurationsByChainId, - selectedNetworkClientId: 'mainnet', - }, - }); - expect(Object.values(chainIds)).toHaveLength(1); - expect(chainIds).toStrictEqual(['mainnet']); - }); }); describe('#isHardwareWallet', () => {