Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
bergeron committed Dec 10, 2024
1 parent 5a74331 commit e6a25a1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
5 changes: 5 additions & 0 deletions shared/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,11 @@ export const FEATURED_RPCS: AddNetworkFields[] = [
},
];

export const FEATURED_NETWORK_CHAIN_IDS = [
CHAIN_IDS.MAINNET,
...FEATURED_RPCS.map((rpc) => rpc.chainId),
];

export const infuraChainIdsTestNets: string[] = [
CHAIN_IDS.SEPOLIA,
CHAIN_IDS.HOLESKY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
import ImportControl from '../import-control';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../../../contexts/metametrics';
import { FEATURED_RPCS, TEST_CHAINS } from '../../../../../../shared/constants/network';
import {
FEATURED_NETWORK_CHAIN_IDS,
TEST_CHAINS,
} from '../../../../../../shared/constants/network';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
Expand Down Expand Up @@ -172,7 +175,10 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
className="asset-list-control-bar__button asset-list-control-bar__network_control"
onClick={toggleNetworkFilterPopover}
size={ButtonBaseSize.Sm}
disabled={isTestNetwork || !FEATURED_RPCS.some((rpc) => rpc.chainId === currentNetwork.chainId)}
disabled={
isTestNetwork ||
!FEATURED_NETWORK_CHAIN_IDS.includes(currentNetwork.chainId)
}
endIconName={IconName.ArrowDown}
backgroundColor={
isNetworkFilterPopoverOpen
Expand All @@ -186,7 +192,6 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
{allNetworksFilterShown
? currentNetwork?.nickname ?? t('currentNetwork')
: t('popularNetworks')}
{/* t('allNetworks')} */}
</ButtonBase>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {
variant={TextVariant.bodyMdMedium}
color={TextColor.textDefault}
>
{/* {t('allNetworks')} */}
{t('popularNetworks')}
</Text>
<Text
Expand Down
22 changes: 12 additions & 10 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
MOONBEAM_DISPLAY_NAME,
MOONRIVER_DISPLAY_NAME,
TEST_NETWORK_IDS,
FEATURED_RPCS,
FEATURED_NETWORK_CHAIN_IDS,
} from '../../shared/constants/network';
import {
WebHIDConnectedStatuses,
Expand Down Expand Up @@ -2345,10 +2345,10 @@ export const getAllChainsToPoll = createDeepEqualSelector(
return [currentChainId];
}

const featuredChainIds = FEATURED_RPCS.map((rpc) => rpc.chainId);

return Object.keys(networkConfigurations).filter(
(chainId) => chainId === currentChainId || featuredChainIds.includes(chainId),
(chainId) =>
chainId === currentChainId ||
FEATURED_NETWORK_CHAIN_IDS.includes(chainId),
);
},
);
Expand All @@ -2369,10 +2369,11 @@ export const getChainIdsToPoll = createDeepEqualSelector(
return [currentChainId];
}

const featuredChainIds = FEATURED_RPCS.map((rpc) => rpc.chainId);

return Object.keys(networkConfigurations).filter(
(chainId) => chainId === currentChainId || featuredChainIds.includes(chainId));
(chainId) =>
chainId === currentChainId ||
FEATURED_NETWORK_CHAIN_IDS.includes(chainId),
);
},
);

Expand All @@ -2397,11 +2398,12 @@ export const getNetworkClientIdsToPoll = createDeepEqualSelector(
];
}

const featuredChainIds = FEATURED_RPCS.map((rpc) => rpc.chainId);

return Object.entries(networkConfigurations).reduce(
(acc, [chainId, network]) => {
if (chainId === currentChainId || featuredChainIds.includes(chainId)) {
if (
chainId === currentChainId ||
FEATURED_NETWORK_CHAIN_IDS.includes(chainId)
) {
acc.push(
network.rpcEndpoints[network.defaultRpcEndpointIndex]
.networkClientId,
Expand Down

0 comments on commit e6a25a1

Please sign in to comment.