You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when NetworkController is instantiated with pre-existing
state that contains an invalid `selectedNetworkClientId` — that is, no
RPC endpoint exists which has the same network client ID — then it
throws an error. This was intentionally done to bring attention to
possible bugs in NetworkController, but this has the unfortunate side
effect of bricking users' wallets.
To fix this, we now correct an invalid `selectedNetworkClientId` to
point to the default RPC endpoint of the first network sorted by chain
ID (which in the vast majority of cases will be Mainnet). We still do
want to know about this, though, so we log the error in Sentry.
Copy file name to clipboardExpand all lines: packages/network-controller/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
- 429 responses now throw a "Rate Limiting" error
16
16
- Other 4xx responses now throw a generic HTTP client error
17
17
- Invalid JSON responses now throw a "Parse" error
18
+
- Rather than throwing an error, NetworkController now corrects an invalid initial `selectedNetworkClientId` to point to the default RPC endpoint of the first network sorted by chain ID ([#5851](https://github.com/MetaMask/core/pull/5851))
@@ -1054,14 +1066,44 @@ function validateNetworkControllerState(state: NetworkState) {
1054
1066
'NetworkController state has invalid `networkConfigurationsByChainId`: Every RPC endpoint across all network configurations must have a unique `networkClientId`',
`NetworkController state is invalid: \`selectedNetworkClientId\` '${state.selectedNetworkClientId}' does not refer to an RPC endpoint within a network configuration`,
1063
-
);
1064
-
}
1071
+
/**
1072
+
* Checks that the given initial NetworkController state is internally
1073
+
* consistent similar to `validateInitialState`, but if an anomaly is detected,
1074
+
* it does its best to correct the state and logs an error to Sentry.
1075
+
*
1076
+
* @param state - The NetworkController state to verify.
1077
+
* @param messenger - The NetworkController messenger.
`\`selectedNetworkClientId\` '${state.selectedNetworkClientId}' does not refer to an RPC endpoint within a network configuration; correcting to '${newSelectedNetworkClientId}'`,
0 commit comments