From 93a00c7451e725481f8bdf1a7519ac8e57d9bc00 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 27 Jun 2023 11:18:21 -0300 Subject: [PATCH] Added wider error deetection for JSON-RPC unsupported operation (#4162). --- src.ts/providers/provider-jsonrpc.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src.ts/providers/provider-jsonrpc.ts b/src.ts/providers/provider-jsonrpc.ts index 021910cf13..0ba83704b7 100644 --- a/src.ts/providers/provider-jsonrpc.ts +++ b/src.ts/providers/provider-jsonrpc.ts @@ -961,13 +961,20 @@ export abstract class JsonRpcApiProvider extends AbstractProvider { } } - if (message.match(/the method .* does not exist/i)) { + let unsupported = !!message.match(/the method .* does not exist/i); + if (!unsupported) { + if (error && (error).details && (error).details.startsWith("Unauthorized method:")) { + unsupported = true; + } + } + + if (unsupported) { return makeError("unsupported operation", "UNSUPPORTED_OPERATION", { - operation: payload.method, info: { error } + operation: payload.method, info: { error, payload } }); } - return makeError("could not coalesce error", "UNKNOWN_ERROR", { error }); + return makeError("could not coalesce error", "UNKNOWN_ERROR", { error, payload }); }