Skip to content

Commit

Permalink
fix: linea network order in dropdown + remove feature toggle for linea (
Browse files Browse the repository at this point in the history
MetaMask#6072) (MetaMask#6109)

Co-authored-by: Victorien Gauch <[email protected]>
  • Loading branch information
Andepande and VGau authored Apr 3, 2023
1 parent 8aac1e0 commit 7a036b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
36 changes: 15 additions & 21 deletions app/components/UI/NetworkList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Networks, {
getDecimalChainId,
getNetworkImageSource,
isSafeChainId,
shouldShowZKEVM,
} from '../../../util/networks';
import { connect } from 'react-redux';
import Ionicons from 'react-native-vector-icons/Ionicons';
Expand Down Expand Up @@ -257,7 +256,10 @@ export class NetworkList extends PureComponent {

let rpc = frequentRpcList.find(({ rpcUrl }) => rpcUrl === rpcTarget);

if (!isLineaTestnetInFrequentRpcList) {
if (
!isLineaTestnetInFrequentRpcList &&
rpcTarget === new URL(LINEA_TESTNET_RPC_URL).href
) {
const url = new URLPARSE(LINEA_TESTNET_RPC_URL);
const decimalChainId = getDecimalChainId(NETWORKS_CHAIN_ID.LINEA_TESTNET);
PreferencesController.addToFrequentRpcList(
Expand Down Expand Up @@ -399,11 +401,11 @@ export class NetworkList extends PureComponent {
const { frequentRpcList, providerConfig } = this.props;
const colors = this.context.colors || mockTheme.colors;
let rpcList = frequentRpcList;
if (!shouldShowZKEVM) {
rpcList = frequentRpcList.filter(
({ chainId }) => chainId !== NETWORKS_CHAIN_ID.LINEA_TESTNET,
);
}

rpcList = frequentRpcList.filter(
({ chainId }) => chainId !== NETWORKS_CHAIN_ID.LINEA_TESTNET,
);

return rpcList.map(({ nickname, rpcUrl, chainId }, i) => {
const { name } = { name: nickname || rpcUrl, chainId, color: null };
const image = getNetworkImageSource({ chainId });
Expand Down Expand Up @@ -487,7 +489,7 @@ export class NetworkList extends PureComponent {
name,
image,
networkIndex,
rpcUrl,
rpcURL.href,
isCustomRpc,
);
};
Expand All @@ -505,12 +507,6 @@ export class NetworkList extends PureComponent {
};

render = () => {
const { frequentRpcList } = this.props;
const isLineaTestnetInFrequentRpcList =
frequentRpcList.findIndex(
(frequentRpc) =>
frequentRpc.chainId === NETWORKS_CHAIN_ID.LINEA_TESTNET,
) !== -1;
const styles = this.getStyles();
return (
<SafeAreaView
Expand All @@ -537,13 +533,11 @@ export class NetworkList extends PureComponent {
{this.renderMainnet()}
{this.renderRpcNetworks()}
{this.renderOtherNetworks()}
{shouldShowZKEVM &&
!isLineaTestnetInFrequentRpcList &&
this.renderNonInfuraNetwork(
NETWORKS_CHAIN_ID.LINEA_TESTNET,
LINEA_TESTNET_RPC_URL,
LINEA_TESTNET_NICKNAME,
)}
{this.renderNonInfuraNetwork(
NETWORKS_CHAIN_ID.LINEA_TESTNET,
LINEA_TESTNET_RPC_URL,
LINEA_TESTNET_NICKNAME,
)}
</ScrollView>
<View style={styles.footer}>
<StyledButton
Expand Down
3 changes: 1 addition & 2 deletions app/components/Views/Settings/NetworksSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Networks, {
getAllNetworks,
getNetworkImageSource,
isDefaultMainnet,
shouldShowZKEVM,
} from '../../../../util/networks';
import StyledButton from '../../../UI/StyledButton';
import Engine from '../../../../core/Engine';
Expand Down Expand Up @@ -433,7 +432,7 @@ class NetworksSettings extends PureComponent {
{strings('app_settings.test_network_name')}
</Text>
{this.renderOtherNetworks()}
{shouldShowZKEVM && this.renderNonInfuraNetworksView()}
{this.renderNonInfuraNetworksView()}
</>
)}
</ScrollView>
Expand Down
2 changes: 0 additions & 2 deletions app/util/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ const NetworkList = {

const NetworkListKeys = Object.keys(NetworkList);

export const shouldShowZKEVM = new Date().getTime() > Date.UTC(2023, 2, 28, 8);

export default NetworkList;

export const getAllNetworks = () =>
Expand Down

0 comments on commit 7a036b4

Please sign in to comment.