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

Only recognize "blocked" status for built-in networks (#19069)

The detection of the Infura "blocked" status has been updated to apply
only to built-in networks. The message we show to users in this state
is meant only for Infura; we don't want to show it for third-party RPC
APIs that happen to use the same error response.

This brings the network controller further in alignment with the core
network controller.

This isn't tested, but it was found in the course of porting unit tests
from core to extension. It will be covered by these tests, which will
be added in the next PR.
This commit is contained in:
Mark Stacey 2023-05-10 12:11:57 -02:30 committed by GitHub
parent 46c2f1cc56
commit cf7c790505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -623,12 +623,14 @@ export class NetworkController extends EventEmitter {
supportsEIP1559 = results[1];
networkStatus = NetworkStatus.Available;
} catch (error) {
if (isErrorWithCode(error) && isErrorWithMessage(error)) {
if (isErrorWithCode(error)) {
let responseBody;
try {
responseBody = JSON.parse(error.message);
} catch {
// error.message must not be JSON
if (isInfura && isErrorWithMessage(error)) {
try {
responseBody = JSON.parse(error.message);
} catch {
// error.message must not be JSON
}
}
if (