From 0e4cd8ef5615f4760d1474cb7665e85dea15fb93 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:31:05 +0000 Subject: [PATCH] remove override if not supported --- src/rpc/estimation/gasEstimationsV06.ts | 9 ++++++--- src/rpc/estimation/gasEstimationsV07.ts | 5 +++++ src/rpc/rpcHandler.ts | 5 ----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/rpc/estimation/gasEstimationsV06.ts b/src/rpc/estimation/gasEstimationsV06.ts index 5acb5d7f..19b87262 100644 --- a/src/rpc/estimation/gasEstimationsV06.ts +++ b/src/rpc/estimation/gasEstimationsV06.ts @@ -142,6 +142,11 @@ export class GasEstimatorV06 { } } + // Remove state override if not supported by network. + if (!this.config.balanceOverride) { + stateOverrides = undefined + } + try { await publicClient.request({ method: "eth_call", @@ -180,9 +185,7 @@ export class GasEstimatorV06 { } as const } - const cause = err.walk( - (err) => err instanceof RpcRequestError - ) + const cause = err.walk((err) => err instanceof RpcRequestError) const causeParseResult = z .union([ diff --git a/src/rpc/estimation/gasEstimationsV07.ts b/src/rpc/estimation/gasEstimationsV07.ts index 7b12ca4a..c89fb9eb 100644 --- a/src/rpc/estimation/gasEstimationsV07.ts +++ b/src/rpc/estimation/gasEstimationsV07.ts @@ -413,6 +413,11 @@ export class GasEstimatorV07 { args: [entryPoint, entryPointSimulationsCallData] }) + // Remove state override if not supported by network. + if (!this.config.balanceOverride) { + stateOverrides = undefined + } + const result = (await publicClient.request({ method: "eth_call", params: [ diff --git a/src/rpc/rpcHandler.ts b/src/rpc/rpcHandler.ts index e1b7ecc6..88d36cce 100644 --- a/src/rpc/rpcHandler.ts +++ b/src/rpc/rpcHandler.ts @@ -375,11 +375,6 @@ export class RpcHandler implements IRpcEndpoint { ): Promise { this.ensureEntryPointIsSupported(entryPoint) - // Remove state override if not supported by network. - if (!this.config.balanceOverride) { - stateOverrides = undefined - } - if (userOperation.maxFeePerGas === 0n) { throw new RpcError( "user operation max fee per gas must be larger than 0 during gas estimation"