Skip to content

Commit

Permalink
fix: PortfolioView: Remove pausedChainIds from selector (#28552)
Browse files Browse the repository at this point in the history
## **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**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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.
  • Loading branch information
darkwing authored Nov 21, 2024
1 parent bd2248d commit 8bcd777
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
18 changes: 4 additions & 14 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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,
Expand Down
26 changes: 0 additions & 26 deletions ui/selectors/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ describe('Selectors', () => {
it('returns only non-test chain IDs', () => {
const chainIds = selectors.getChainIdsToPoll({
metamask: {
preferences: { pausedChainIds: [] },
networkConfigurationsByChainId,
selectedNetworkClientId: 'mainnet',
},
Expand All @@ -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', () => {
Expand Down Expand Up @@ -933,26 +920,13 @@ describe('Selectors', () => {
it('returns only non-test chain IDs', () => {
const chainIds = selectors.getNetworkClientIdsToPoll({
metamask: {
preferences: { pausedChainIds: [] },
networkConfigurationsByChainId,
selectedNetworkClientId: 'mainnet',
},
});
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', () => {
Expand Down

0 comments on commit 8bcd777

Please sign in to comment.