From fc4ec6616193c6106e795996f3a929fae9bfa890 Mon Sep 17 00:00:00 2001 From: Andreas Petersson Date: Tue, 17 Sep 2024 03:18:03 +0200 Subject: [PATCH] fixed provider-jsonrpc.ts strict compile fixes (and possible wrong error handling on network_error) The original condition used "NETWORK_ERROR" || isError(error, "UNSUPPORTED_OPERATION") which is always truthy due to the way the logical OR operator (||) is evaluated. This caused the if statement to not function as intended, potentially resulting in unexpected rejections during transaction handling. --- src.ts/providers/provider-jsonrpc.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src.ts/providers/provider-jsonrpc.ts b/src.ts/providers/provider-jsonrpc.ts index fb993249ae..e1880fb4f6 100644 --- a/src.ts/providers/provider-jsonrpc.ts +++ b/src.ts/providers/provider-jsonrpc.ts @@ -382,15 +382,16 @@ export class JsonRpcSigner extends AbstractSigner { // If the network changed: calling again will also fail // If unsupported: likely destroyed if (isError(error, "CANCELLED") || isError(error, "BAD_DATA") || - isError(error, "NETWORK_ERROR" || isError(error, "UNSUPPORTED_OPERATION"))) { - + isError(error, "NETWORK_ERROR") || isError(error, "UNSUPPORTED_OPERATION")) { + if (error.info == null) { error.info = { }; } error.info.sendTransactionHash = hash; - + reject(error); return; } + // Stop-gap for misbehaving backends; see #4513 if (isError(error, "INVALID_ARGUMENT")) { invalids++;