From cf7c7905053058d55f16fb47de65c3b4e5442cb7 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 10 May 2023 12:11:57 -0230 Subject: [PATCH] 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. --- .../controllers/network/network-controller.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/network/network-controller.ts b/app/scripts/controllers/network/network-controller.ts index b6fd4a503..4a79eaf1a 100644 --- a/app/scripts/controllers/network/network-controller.ts +++ b/app/scripts/controllers/network/network-controller.ts @@ -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 (