Skip to content

Commit

Permalink
PortfolioView: Remove pausedChainIds from selector
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Nov 19, 2024
1 parent 39528b0 commit ff46ca1
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 @@ -2197,30 +2197,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 @@ -2232,10 +2225,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 ff46ca1

Please sign in to comment.