1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fixes to the Linea Goerli implementation (#18290)

* Ensure that NonInfuraDefaultNetworks are only selected in the dropdown if they are the currently selected network

* Ensure Linea Goerli network appears in network settings tab if added manually
This commit is contained in:
Dan J Miller 2023-03-23 09:07:28 -07:00 committed by GitHub
parent 048c3e3258
commit 270ff26561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 21 deletions

View File

@ -286,22 +286,20 @@ class NetworkDropdown extends Component {
} }
renderNonInfuraDefaultNetwork(networkConfigurations, network) { renderNonInfuraDefaultNetwork(networkConfigurations, network) {
const { const { provider, setActiveNetwork, upsertNetworkConfiguration } =
provider: { type: providerType }, this.props;
setActiveNetwork,
upsertNetworkConfiguration,
} = this.props;
const isCurrentRpcTarget = providerType === NETWORK_TYPES.RPC; const { chainId, ticker, blockExplorerUrl } = BUILT_IN_NETWORKS[network];
const networkName = NETWORK_TO_NAME_MAP[network];
const rpcUrl = CHAIN_ID_TO_RPC_URL_MAP[chainId];
const isCurrentRpcTarget =
provider.type === NETWORK_TYPES.RPC && rpcUrl === provider.rpcUrl;
return ( return (
<DropdownMenuItem <DropdownMenuItem
key={network} key={network}
closeMenu={this.props.hideNetworkDropdown} closeMenu={this.props.hideNetworkDropdown}
onClick={async () => { onClick={async () => {
const { chainId, ticker, blockExplorerUrl } =
BUILT_IN_NETWORKS[network];
const networkName = NETWORK_TO_NAME_MAP[network];
const networkConfiguration = pickBy( const networkConfiguration = pickBy(
networkConfigurations, networkConfigurations,
(config) => config.rpcUrl === CHAIN_ID_TO_RPC_URL_MAP[chainId], (config) => config.rpcUrl === CHAIN_ID_TO_RPC_URL_MAP[chainId],
@ -310,7 +308,6 @@ class NetworkDropdown extends Component {
let configurationId = null; let configurationId = null;
// eslint-disable-next-line no-extra-boolean-cast, no-implicit-coercion // eslint-disable-next-line no-extra-boolean-cast, no-implicit-coercion
if (!!networkConfiguration) { if (!!networkConfiguration) {
const rpcUrl = CHAIN_ID_TO_RPC_URL_MAP[chainId];
configurationId = await upsertNetworkConfiguration( configurationId = await upsertNetworkConfiguration(
{ {
rpcUrl, rpcUrl,
@ -346,7 +343,7 @@ class NetworkDropdown extends Component {
data-testid={`${network}-network-item`} data-testid={`${network}-network-item`}
style={{ style={{
color: color:
providerType === network provider.type === network
? 'var(--color-text-default)' ? 'var(--color-text-default)'
: 'var(--color-text-alternative)', : 'var(--color-text-alternative)',
}} }}

View File

@ -30,11 +30,13 @@ import NetworksTabContent from './networks-tab-content';
import NetworksForm from './networks-form'; import NetworksForm from './networks-form';
import NetworksFormSubheader from './networks-tab-subheader'; import NetworksFormSubheader from './networks-tab-subheader';
const defaultNetworks = defaultNetworksData.map((network) => ({ const defaultNetworks = defaultNetworksData
...network, .map((network) => ({
viewOnly: true, ...network,
isATestNetwork: TEST_CHAINS.includes(network.chainId), viewOnly: true,
})); isATestNetwork: TEST_CHAINS.includes(network.chainId),
}))
.filter((network) => network.chainId !== CHAIN_IDS.LINEA_TESTNET);
const NetworksTab = ({ addNewNetwork }) => { const NetworksTab = ({ addNewNetwork }) => {
const t = useI18nContext(); const t = useI18nContext();
@ -55,8 +57,8 @@ const NetworksTab = ({ addNewNetwork }) => {
getNetworksTabSelectedNetworkConfigurationId, getNetworksTabSelectedNetworkConfigurationId,
); );
const networkConfigurationsList = Object.entries(networkConfigurations) const networkConfigurationsList = Object.entries(networkConfigurations).map(
.map(([networkConfigurationId, networkConfiguration]) => { ([networkConfigurationId, networkConfiguration]) => {
return { return {
label: networkConfiguration.nickname, label: networkConfiguration.nickname,
iconColor: 'var(--color-icon-alternative)', iconColor: 'var(--color-icon-alternative)',
@ -68,8 +70,8 @@ const NetworksTab = ({ addNewNetwork }) => {
isATestNetwork: TEST_CHAINS.includes(networkConfiguration.chainId), isATestNetwork: TEST_CHAINS.includes(networkConfiguration.chainId),
networkConfigurationId, networkConfigurationId,
}; };
}) },
.filter((network) => network.chainId !== CHAIN_IDS.LINEA_TESTNET); );
let networksToRender = [...defaultNetworks, ...networkConfigurationsList]; let networksToRender = [...defaultNetworks, ...networkConfigurationsList];
if (!SHOULD_SHOW_LINEA_TESTNET_NETWORK) { if (!SHOULD_SHOW_LINEA_TESTNET_NETWORK) {