Skip to content

Commit

Permalink
On fresh install, there was an error when the user wanted to change t…
Browse files Browse the repository at this point in the history
…o a custom rpc url of ethereum, because there was no other network configurations to override at that point
  • Loading branch information
tommasini committed May 23, 2024
1 parent c8d161e commit 9899331
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -630,22 +630,27 @@ class NetworkSettings extends PureComponent {
const isRPCDifferent = url.href !== prevRPCURL;
if ((editable || isCustomMainnet) && isRPCDifferent) {
// Only remove from frequent list if RPC URL is different.
const [prevNetworkConfigurationId] = Object.entries(
const foundNetworkConfiguration = Object.entries(
this.props.networkConfigurations,
).find(
([, networkConfiguration]) =>
networkConfiguration.rpcUrl === prevRPCURL,
);
NetworkController.removeNetworkConfiguration(
prevNetworkConfigurationId,
);

if (foundNetworkConfiguration) {
const [prevNetworkConfigurationId] = foundNetworkConfiguration;
NetworkController.removeNetworkConfiguration(
prevNetworkConfigurationId,
);
}
}

const analyticsParamsAdd = {
chain_id: this.getDecimalChainId(chainId),
source: 'Custom network form',
symbol: ticker,
};

metrics.trackEvent(MetaMetricsEvents.NETWORK_ADDED, analyticsParamsAdd);
this.props.showNetworkOnboardingAction({
networkUrl,
Expand Down

0 comments on commit 9899331

Please sign in to comment.