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 }); }