Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix network selector #12641

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ exports[`Tokens Portfolio View should match the snapshot when portfolio view is
}
}
>
Ethereum Main Network
All Networks
</Text>
<SvgMock
color="#141618"
Expand Down
10 changes: 2 additions & 8 deletions app/selectors/networkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,9 @@ describe('networkSelectors', () => {
expect(selectNetworkClientId(mockState)).toBe('custom-network');
});

it('selectIsAllNetworks should return false if tokenNetworkFilter length does not match networkConfigurations length', () => {
it('selectIsAllNetworks should return false if tokenNetworkFilter length is greater than 1', () => {
const tokenNetworkFilter = { '0x1': 'true' };
expect(
selectIsAllNetworks.resultFunc(
mockState.engine.backgroundState.NetworkController
.networkConfigurationsByChainId,
tokenNetworkFilter,
),
).toBe(false);
expect(selectIsAllNetworks.resultFunc(tokenNetworkFilter)).toBe(false);
});

it('selectNetworkConfigurationByChainId should return the network configuration for a given chainId', () => {
Expand Down
10 changes: 6 additions & 4 deletions app/selectors/networkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ export const selectIsEIP1559Network = createSelector(
);

export const selectIsAllNetworks = createSelector(
selectNetworkConfigurations,
(state: RootState) => selectTokenNetworkFilter(state),
(networkConfigurations, tokenNetworkFilter) =>
Object.keys(tokenNetworkFilter).length ===
Object.keys(networkConfigurations).length,
(tokenNetworkFilter) => {
if (Object.keys(tokenNetworkFilter).length === 1) {
return false;
}
return true;
},
);

export const selectNetworkConfigurationByChainId = createSelector(
Expand Down
Loading