Skip to content

Commit

Permalink
Added wider error deetection for JSON-RPC unsupported operation (ethe…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent adc20fc commit 93a00c7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src.ts/providers/provider-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (<any>error).details && (<any>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 });
}


Expand Down

0 comments on commit 93a00c7

Please sign in to comment.