diff --git a/src/rpc/estimation/gasEstimationHandler.ts b/src/rpc/estimation/gasEstimationHandler.ts index cd87753d..f42c87a9 100644 --- a/src/rpc/estimation/gasEstimationHandler.ts +++ b/src/rpc/estimation/gasEstimationHandler.ts @@ -1,4 +1,4 @@ -import type { UserOperation } from "@alto/types" +import type { ChainType, UserOperation } from "@alto/types" import type { StateOverrides, UserOperationV07 } from "@alto/types" import type { Hex } from "viem" import type { SimulateHandleOpResult } from "./types" @@ -56,6 +56,7 @@ export class GasEstimationHandler { chainId: number, blockTagSupport: boolean, utilityWalletAddress: Address, + chainType: ChainType, entryPointSimulationsAddress?: Address, fixedGasLimitForEstimation?: bigint ) { @@ -74,6 +75,7 @@ export class GasEstimationHandler { entryPointSimulationsAddress, blockTagSupport, utilityWalletAddress, + chainType, fixedGasLimitForEstimation ) } diff --git a/src/rpc/estimation/gasEstimationsV07.ts b/src/rpc/estimation/gasEstimationsV07.ts index b0893b4a..09feb505 100644 --- a/src/rpc/estimation/gasEstimationsV07.ts +++ b/src/rpc/estimation/gasEstimationsV07.ts @@ -22,7 +22,8 @@ import { ValidationErrors, ExecutionErrors, targetCallResultSchema, - RpcError + RpcError, + ChainType } from "@alto/types" import { getUserOperationHash, toPackedUserOperation } from "@alto/utils" import { @@ -40,6 +41,7 @@ export class GasEstimatorV07 { blockTagSupport: boolean utilityWalletAddress: Address fixedGasLimitForEstimation?: bigint + chainType: ChainType constructor( binarySearchToleranceDelta: bigint, @@ -49,6 +51,7 @@ export class GasEstimatorV07 { entryPointSimulationsAddress: Address | undefined, blockTagSupport: boolean, utilityWalletAddress: Address, + chainType: ChainType, fixedGasLimitForEstimation?: bigint ) { this.binarySearchToleranceDelta = binarySearchToleranceDelta @@ -58,6 +61,7 @@ export class GasEstimatorV07 { this.entryPointSimulationsAddress = entryPointSimulationsAddress this.blockTagSupport = blockTagSupport this.utilityWalletAddress = utilityWalletAddress + this.chainType = chainType this.fixedGasLimitForEstimation = fixedGasLimitForEstimation } @@ -302,14 +306,35 @@ export class GasEstimatorV07 { queuedUserOperations }) - let cause = await this.callPimlicoEntryPointSimulations({ - entryPoint, - entryPointSimulationsCallData: [ - simulateHandleOpLast, - simulateCallData - ], - stateOverrides - }) + let cause + + if (this.chainType === "hedera") { + // due to Hedera specific restrictions, we can't combine these two calls. + const [simulateHandleOpLastCause, simulateCallDataCause] = + await Promise.all([ + this.callPimlicoEntryPointSimulations({ + entryPoint, + entryPointSimulationsCallData: [simulateHandleOpLast], + stateOverrides + }), + this.callPimlicoEntryPointSimulations({ + entryPoint, + entryPointSimulationsCallData: [simulateCallData], + stateOverrides + }) + ]) + + cause = [simulateHandleOpLastCause[0], simulateCallDataCause[0]] + } else { + cause = await this.callPimlicoEntryPointSimulations({ + entryPoint, + entryPointSimulationsCallData: [ + simulateHandleOpLast, + simulateCallData + ], + stateOverrides + }) + } cause = cause.map((data: Hex) => { const decodedDelegateAndError = decodeErrorResult({ diff --git a/src/rpc/rpcHandler.ts b/src/rpc/rpcHandler.ts index 52e4c276..aaac17ba 100644 --- a/src/rpc/rpcHandler.ts +++ b/src/rpc/rpcHandler.ts @@ -82,7 +82,7 @@ import { slice, toFunctionSelector } from "viem" -import { base, baseSepolia, optimism } from "viem/chains" +import { base, baseSepolia, hedera, optimism } from "viem/chains" import type { NonceQueuer } from "./nonceQueuer" export interface IRpcEndpoint { @@ -423,6 +423,12 @@ export class RpcHandler implements IRpcEndpoint { userOperation.verificationGasLimit = 5_000_000n } + if (this.chainId === hedera.id) { + // The eth_call gasLimit is set to 12_500_000 on Hedera. + userOperation.verificationGasLimit = 5_000_000n + userOperation.callGasLimit = 4_500_000n + } + if (isVersion07(userOperation)) { userOperation.paymasterPostOpGasLimit = 2_000_000n userOperation.paymasterVerificationGasLimit = 5_000_000n diff --git a/src/rpc/validation/UnsafeValidator.ts b/src/rpc/validation/UnsafeValidator.ts index 672de353..375d3ac1 100644 --- a/src/rpc/validation/UnsafeValidator.ts +++ b/src/rpc/validation/UnsafeValidator.ts @@ -96,6 +96,7 @@ export class UnsafeValidator implements InterfaceValidator { publicClient.chain.id, blockTagSupport, utilityWalletAddress, + chainType, entryPointSimulationsAddress, fixedGasLimitForEstimation )