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"