From b645781c55affcb9f46ffd21cd3abc13dac829e4 Mon Sep 17 00:00:00 2001 From: nikhil kumar Date: Sun, 7 Jul 2024 13:31:46 +0530 Subject: [PATCH] enhancement: contract based binary search for call gas limit estimate --- packages/executor/src/interfaces.ts | 5 + packages/executor/src/modules/eth.ts | 14 +- .../services/EntryPointService/constants.ts | 2 + .../utils/decodeRevertReason.ts | 17 + .../EntryPointService/versions/0.0.7.ts | 41 ++- .../src/services/UserOpValidation/service.ts | 3 +- .../UserOpValidation/validators/estimation.ts | 21 +- .../EPv7/core/CallGasEstimationProxy.ts | 250 +++++++++++++ .../core/CallGasEstimationProxy__factory.ts | 337 ++++++++++++++++++ .../contracts/EPv7/factories/core/index.ts | 1 + 10 files changed, 668 insertions(+), 23 deletions(-) create mode 100644 packages/types/src/contracts/EPv7/core/CallGasEstimationProxy.ts create mode 100644 packages/types/src/contracts/EPv7/factories/core/CallGasEstimationProxy__factory.ts diff --git a/packages/executor/src/interfaces.ts b/packages/executor/src/interfaces.ts index 150ea97b..0ce73f4d 100644 --- a/packages/executor/src/interfaces.ts +++ b/packages/executor/src/interfaces.ts @@ -253,3 +253,8 @@ export interface KnownEntities { accounts: string[]; otherEntities: string[]; } + +export interface ExecutionResultAndCallGasLimit { + returnInfo: ExecutionResult; + callGasLimit: BigNumber; +} diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index e6b46d6d..e5b76b07 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -177,7 +177,7 @@ export class Eth { userOp.signature = ECDSA_DUMMY_SIGNATURE; } - const returnInfo = await this.userOpValidationService.validateForEstimation( + let {returnInfo, callGasLimit} = await this.userOpValidationService.validateForEstimation( userOp, entryPoint ); @@ -194,12 +194,12 @@ export class Eth { // calculate callGasLimit based on paid fee const { cglMarkup } = this.config; - const totalGas: BigNumber = BigNumber.from(paid).div(userOp.maxFeePerGas); - let callGasLimit = totalGas - .sub(preOpGas) - .mul(10000 + this.config.cglMarkupPercent) - .div(10000) // % markup - .add(cglMarkup || 0); + // const totalGas: BigNumber = BigNumber.from(paid).div(userOp.maxFeePerGas); + // let callGasLimit = totalGas + // .sub(preOpGas) + // .mul(10000 + this.config.cglMarkupPercent) + // .div(10000) // % markup + // .add(cglMarkup || 0); if (callGasLimit.lt(cglMarkup)) { callGasLimit = BigNumber.from(cglMarkup); diff --git a/packages/executor/src/services/EntryPointService/constants.ts b/packages/executor/src/services/EntryPointService/constants.ts index 027c7163..eba48178 100644 --- a/packages/executor/src/services/EntryPointService/constants.ts +++ b/packages/executor/src/services/EntryPointService/constants.ts @@ -7,3 +7,5 @@ export const DefaultGasOverheads = { bundleSize: 1, sigSize: 65, }; + +export const IMPLEMENTATION_ADDRESS_MARKER = "0xA13dB4eCfbce0586E57D1AeE224FbE64706E8cd3"; diff --git a/packages/executor/src/services/EntryPointService/utils/decodeRevertReason.ts b/packages/executor/src/services/EntryPointService/utils/decodeRevertReason.ts index 2fbd5092..e7204a60 100644 --- a/packages/executor/src/services/EntryPointService/utils/decodeRevertReason.ts +++ b/packages/executor/src/services/EntryPointService/utils/decodeRevertReason.ts @@ -63,6 +63,23 @@ export function decodeRevertReason( } } +export function decodeTargetData(data: string) { + try { + const methodSig = data.slice(0, 10); + const dataParams = "0x" + data.slice(10); + if(methodSig === "0x8c83589a") { + const res = ethers.utils.defaultAbiCoder.decode( + ["uint256", "uint256"], + dataParams + ); + return res; + } + throw Error("Error decoding target data"); + } catch (error) { + throw error; + } +} + // not sure why ethers fail to decode revert reasons, not even "Error()" (and obviously, not custom errors) export function rethrowWithRevertReason(e: Error): never { throw new Error(decodeRevertReason(e, false) as any); diff --git a/packages/executor/src/services/EntryPointService/versions/0.0.7.ts b/packages/executor/src/services/EntryPointService/versions/0.0.7.ts index 057d2630..3028a118 100644 --- a/packages/executor/src/services/EntryPointService/versions/0.0.7.ts +++ b/packages/executor/src/services/EntryPointService/versions/0.0.7.ts @@ -35,13 +35,21 @@ import { StakeInfo, UserOpValidationResult, } from "../../../interfaces"; -import { DefaultGasOverheads } from "../constants"; +import { DefaultGasOverheads, IMPLEMENTATION_ADDRESS_MARKER } from "../constants"; import { StateOverrides } from "../interfaces"; -import { decodeRevertReason } from "../utils/decodeRevertReason"; +import { decodeRevertReason, decodeTargetData } from "../utils/decodeRevertReason"; import { getUserOpGasLimit } from "../../BundlingService/utils"; import { IEntryPointService } from "./base"; +import { + CallGasEstimationProxy__factory, + _deployedBytecode as _callGasEstimationProxyDeployedBytecode +} from "@skandha/types/lib/contracts/EPv7/factories/core/CallGasEstimationProxy__factory"; +import { + CallGasEstimationProxy +} from "@skandha/types/lib/contracts/EPv7/core/CallGasEstimationProxy"; const entryPointSimulations = IEntryPointSimulations__factory.createInterface(); +const callGasEstimateProxy = CallGasEstimationProxy__factory.createInterface(); export class EntryPointV7Service implements IEntryPointService { contract: EntryPoint; @@ -70,11 +78,22 @@ export class EntryPointV7Service implements IEntryPointService { this.networkConfig.estimationGasLimit ) : undefined; + + const estimateCallGasArgs: CallGasEstimationProxy.EstimateCallGasArgsStruct = { + userOp: packUserOp(userOp), + isContinuation: true, + maxGas: "100000", + minGas: "21000", + rounding: "2" + } - const [data, stateOverrides] = this.encodeSimulateHandleOp( + const [data] = this.encodeSimulateHandleOp( userOp, - AddressZero, - BytesZero + this.address, + callGasEstimateProxy.encodeFunctionData( + "estimateCallGas", + [estimateCallGasArgs] + ) ); const tx: providers.TransactionRequest = { @@ -83,6 +102,15 @@ export class EntryPointV7Service implements IEntryPointService { gasLimit, }; + const stateOverrides: StateOverrides = { + [this.address]: { + code: _callGasEstimationProxyDeployedBytecode + }, + [IMPLEMENTATION_ADDRESS_MARKER]: { + code: _deployedBytecode + } + } + try { const simulationResult = await this.provider.send("eth_call", [ tx, @@ -93,7 +121,8 @@ export class EntryPointV7Service implements IEntryPointService { "simulateHandleOp", simulationResult ); - return res[0]; + const [callGasLimit] = decodeTargetData(res[0].targetResult); + return {returnInfo: res[0], callGasLimit: callGasLimit}; } catch (error: any) { console.log(error); const err = decodeRevertReason(error); diff --git a/packages/executor/src/services/UserOpValidation/service.ts b/packages/executor/src/services/UserOpValidation/service.ts index 9a4ea9c9..eded386b 100644 --- a/packages/executor/src/services/UserOpValidation/service.ts +++ b/packages/executor/src/services/UserOpValidation/service.ts @@ -6,6 +6,7 @@ import { UserOperation } from "@skandha/types/lib/contracts/UserOperation"; import { Config } from "../../config"; import { ExecutionResult, + ExecutionResultAndCallGasLimit, NetworkConfig, UserOpValidationResult, } from "../../interfaces"; @@ -62,7 +63,7 @@ export class UserOpValidationService { async validateForEstimation( userOp: UserOperation, entryPoint: string - ): Promise { + ): Promise { return await this.estimationService.estimateUserOp(userOp, entryPoint); } diff --git a/packages/executor/src/services/UserOpValidation/validators/estimation.ts b/packages/executor/src/services/UserOpValidation/validators/estimation.ts index 2d712278..d279e4dc 100644 --- a/packages/executor/src/services/UserOpValidation/validators/estimation.ts +++ b/packages/executor/src/services/UserOpValidation/validators/estimation.ts @@ -1,7 +1,7 @@ import { providers } from "ethers"; import { Logger } from "@skandha/types/lib"; import { UserOperation } from "@skandha/types/lib/contracts/UserOperation"; -import { ExecutionResult } from "../../../interfaces"; +import { ExecutionResultAndCallGasLimit } from "../../../interfaces"; import { EntryPointService } from "../../EntryPointService"; import { mergeValidationDataValues } from "../../EntryPointService/utils"; @@ -15,8 +15,8 @@ export class EstimationService { async estimateUserOp( userOp: UserOperation, entryPoint: string - ): Promise { - const returnInfo = await this.entryPointService.simulateHandleOp( + ): Promise { + const { returnInfo, callGasLimit } = await this.entryPointService.simulateHandleOp( entryPoint, userOp ); @@ -25,12 +25,15 @@ export class EstimationService { returnInfo.paymasterValidationData ); return { - preOpGas: returnInfo.preOpGas, - paid: returnInfo.paid, - validAfter: validAfter, - validUntil: validUntil, - targetSuccess: returnInfo.targetSuccess, - targetResult: returnInfo.targetResult, + returnInfo: { + preOpGas: returnInfo.preOpGas, + paid: returnInfo.paid, + validAfter: validAfter, + validUntil: validUntil, + targetSuccess: returnInfo.targetSuccess, + targetResult: returnInfo.targetResult, + }, + callGasLimit }; } } diff --git a/packages/types/src/contracts/EPv7/core/CallGasEstimationProxy.ts b/packages/types/src/contracts/EPv7/core/CallGasEstimationProxy.ts new file mode 100644 index 00000000..8f89d651 --- /dev/null +++ b/packages/types/src/contracts/EPv7/core/CallGasEstimationProxy.ts @@ -0,0 +1,250 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { FunctionFragment, Result } from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, + PromiseOrValue, +} from "../../common"; + +export type PackedUserOperationStruct = { + sender: PromiseOrValue; + nonce: PromiseOrValue; + initCode: PromiseOrValue; + callData: PromiseOrValue; + accountGasLimits: PromiseOrValue; + preVerificationGas: PromiseOrValue; + gasFees: PromiseOrValue; + paymasterAndData: PromiseOrValue; + signature: PromiseOrValue; +}; + +export type PackedUserOperationStructOutput = [ + string, + BigNumber, + string, + string, + string, + BigNumber, + string, + string, + string +] & { + sender: string; + nonce: BigNumber; + initCode: string; + callData: string; + accountGasLimits: string; + preVerificationGas: BigNumber; + gasFees: string; + paymasterAndData: string; + signature: string; +}; + +export declare namespace CallGasEstimationProxy { + export type EstimateCallGasArgsStruct = { + userOp: PackedUserOperationStruct; + minGas: PromiseOrValue; + maxGas: PromiseOrValue; + rounding: PromiseOrValue; + isContinuation: PromiseOrValue; + }; + + export type EstimateCallGasArgsStructOutput = [ + PackedUserOperationStructOutput, + BigNumber, + BigNumber, + BigNumber, + boolean + ] & { + userOp: PackedUserOperationStructOutput; + minGas: BigNumber; + maxGas: BigNumber; + rounding: BigNumber; + isContinuation: boolean; + }; +} + +export interface CallGasEstimationProxyInterface extends utils.Interface { + functions: { + "_innerCall(address,bytes,uint256)": FunctionFragment; + "estimateCallGas(((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),uint256,uint256,uint256,bool))": FunctionFragment; + "testCallGas((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),uint256)": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: "_innerCall" | "estimateCallGas" | "testCallGas" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "_innerCall", + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue + ] + ): string; + encodeFunctionData( + functionFragment: "estimateCallGas", + values: [CallGasEstimationProxy.EstimateCallGasArgsStruct] + ): string; + encodeFunctionData( + functionFragment: "testCallGas", + values: [PackedUserOperationStruct, PromiseOrValue] + ): string; + + decodeFunctionResult(functionFragment: "_innerCall", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "estimateCallGas", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "testCallGas", + data: BytesLike + ): Result; + + events: {}; +} + +export interface CallGasEstimationProxy extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: CallGasEstimationProxyInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + _innerCall( + sender: PromiseOrValue, + callData: PromiseOrValue, + gas: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + estimateCallGas( + args: CallGasEstimationProxy.EstimateCallGasArgsStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + testCallGas( + userOp: PackedUserOperationStruct, + callGasLimit: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; + + _innerCall( + sender: PromiseOrValue, + callData: PromiseOrValue, + gas: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + estimateCallGas( + args: CallGasEstimationProxy.EstimateCallGasArgsStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + testCallGas( + userOp: PackedUserOperationStruct, + callGasLimit: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + callStatic: { + _innerCall( + sender: PromiseOrValue, + callData: PromiseOrValue, + gas: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + estimateCallGas( + args: CallGasEstimationProxy.EstimateCallGasArgsStruct, + overrides?: CallOverrides + ): Promise; + + testCallGas( + userOp: PackedUserOperationStruct, + callGasLimit: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + }; + + filters: {}; + + estimateGas: { + _innerCall( + sender: PromiseOrValue, + callData: PromiseOrValue, + gas: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + estimateCallGas( + args: CallGasEstimationProxy.EstimateCallGasArgsStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + testCallGas( + userOp: PackedUserOperationStruct, + callGasLimit: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; + + populateTransaction: { + _innerCall( + sender: PromiseOrValue, + callData: PromiseOrValue, + gas: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + estimateCallGas( + args: CallGasEstimationProxy.EstimateCallGasArgsStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + testCallGas( + userOp: PackedUserOperationStruct, + callGasLimit: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; +} diff --git a/packages/types/src/contracts/EPv7/factories/core/CallGasEstimationProxy__factory.ts b/packages/types/src/contracts/EPv7/factories/core/CallGasEstimationProxy__factory.ts new file mode 100644 index 00000000..7d9325d5 --- /dev/null +++ b/packages/types/src/contracts/EPv7/factories/core/CallGasEstimationProxy__factory.ts @@ -0,0 +1,337 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers"; +import type { Provider, TransactionRequest } from "@ethersproject/providers"; +import type { PromiseOrValue } from "../../../common"; +import type { + CallGasEstimationProxy, + CallGasEstimationProxyInterface, +} from "../../core/CallGasEstimationProxy"; + +const _abi = [ + { + inputs: [ + { + internalType: "uint256", + name: "minGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "numRounds", + type: "uint256", + }, + ], + name: "EstimateCallGasContinuation", + type: "error", + }, + { + inputs: [ + { + internalType: "uint256", + name: "gasEstimate", + type: "uint256", + }, + { + internalType: "uint256", + name: "numRounds", + type: "uint256", + }, + ], + name: "EstimateCallGasResult", + type: "error", + }, + { + inputs: [ + { + internalType: "bytes", + name: "revertData", + type: "bytes", + }, + ], + name: "EstimateCallGasRevertAtMax", + type: "error", + }, + { + inputs: [ + { + internalType: "bool", + name: "success", + type: "bool", + }, + { + internalType: "uint256", + name: "gasUsed", + type: "uint256", + }, + { + internalType: "bytes", + name: "revertData", + type: "bytes", + }, + ], + name: "TestCallGasResult", + type: "error", + }, + { + inputs: [ + { + internalType: "bool", + name: "success", + type: "bool", + }, + { + internalType: "uint256", + name: "gasUsed", + type: "uint256", + }, + { + internalType: "bytes", + name: "revertData", + type: "bytes", + }, + ], + name: "_InnerCallResult", + type: "error", + }, + { + stateMutability: "payable", + type: "fallback", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "uint256", + name: "gas", + type: "uint256", + }, + ], + name: "_innerCall", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "bytes", + name: "initCode", + type: "bytes", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "bytes32", + name: "accountGasLimits", + type: "bytes32", + }, + { + internalType: "uint256", + name: "preVerificationGas", + type: "uint256", + }, + { + internalType: "bytes32", + name: "gasFees", + type: "bytes32", + }, + { + internalType: "bytes", + name: "paymasterAndData", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + ], + internalType: "struct PackedUserOperation", + name: "userOp", + type: "tuple", + }, + { + internalType: "uint256", + name: "minGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "rounding", + type: "uint256", + }, + { + internalType: "bool", + name: "isContinuation", + type: "bool", + }, + ], + internalType: "struct CallGasEstimationProxy.EstimateCallGasArgs", + name: "args", + type: "tuple", + }, + ], + name: "estimateCallGas", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "bytes", + name: "initCode", + type: "bytes", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "bytes32", + name: "accountGasLimits", + type: "bytes32", + }, + { + internalType: "uint256", + name: "preVerificationGas", + type: "uint256", + }, + { + internalType: "bytes32", + name: "gasFees", + type: "bytes32", + }, + { + internalType: "bytes", + name: "paymasterAndData", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + ], + internalType: "struct PackedUserOperation", + name: "userOp", + type: "tuple", + }, + { + internalType: "uint256", + name: "callGasLimit", + type: "uint256", + }, + ], + name: "testCallGas", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const _bytecode = + "0x608060405234801561000f575f80fd5b50610d638061001d5f395ff3fe608060405260043610610033575f3560e01c806308c4a1f51461003d5780631533a8c31461005c5780637a65051b1461007b575b61003b61009a565b005b348015610048575f80fd5b5061003b61005736600461075f565b6100b9565b348015610067575f80fd5b5061003b6100763660046107b1565b6102be565b348015610086575f80fd5b5061003b610095366004610833565b61036e565b6100b773a13db4ecfbce0586e57d1aee224fbe64706e8cd36103ad565b565b3330146100c4575f80fd5b5f6100d76060830135602084013561088e565b90505f6100ec604084013560608501356103cb565b9050805f806101036100fe87806108ad565b61041b565b905061011560a08701608088016108dc565b610187575f80806101346101298a806108ad565b858b6040013561052b565b925092509250826101635780604051632cf919e960e11b815260040161015a9190610944565b60405180910390fd5b6060890135610173836002610956565b61017d919061088e565b9450505050610195565b6101928585856106d4565b91505b5f5b846101a387600161096d565b101561027e57806101b381610980565b91505f90506101c6606089013585610956565b90506101d18161071c565b610222575f6101e460608a013589610956565b90505f6101f560608b013589610956565b604051631167ca7360e11b815260048101849052602481018290526044810186905290915060640161015a565b5f806102386102318b806108ad565b868561052b565b509150915081156102655761025b6102548260608d01356103cb565b889061074a565b9650859750610269565b8598505b6102748989896106d4565b9550505050610197565b61029a61028f606089013587610956565b60408901359061074a565b604051634641ac4d60e11b815260048101919091526024810182905260440161015a565b5f5a90505f80866001600160a01b03168487876040516102df929190610998565b5f604051808303815f8787f1925050503d805f8114610319576040519150601f19603f3d011682016040523d82523d5f602084013e61031e565b606091505b50915091505f5a61032f90856109a7565b90505f8361033d578261034d565b60405180602001604052805f8152505b905083828260405163f9bb41fb60e01b815260040161015a939291906109ba565b5f6103788361041b565b90505f805f61038886858761052b565b925092509250828282604051636ce2512b60e11b815260040161015a939291906109ba565b365f80375f80365f845af43d5f803e8080156103c7573d5ff35b3d5ffd5b5f815f036103e4576103dd828461088e565b9050610415565b821561041057816103f66001856109a7565b610400919061088e565b61040b90600161096d565b610412565b5f5b90505b92915050565b5f805f306001600160a01b03166322cdde4c60e01b856040516024016104419190610b32565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b031990941693909317909252905161047f9190610b44565b5f604051808303815f865af19150503d805f81146104b8576040519150601f19603f3d011682016040523d82523d5f602084013e6104bd565b606091505b50915091508161050f5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c20746f20676574557365724f7048617368206661696c656400000000604482015260640161015a565b808060200190518101906105239190610b55565b949350505050565b5f806060368261053d88840189610b6c565b915091505f81600381111561055157833591505b5060606372288ed160e01b6001600160e01b03198316016105b057898960405160240161057f929190610baf565b60408051601f198184030181529190526020810180516001600160e01b0316638dd7712f60e01b17905290506105e9565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152509293505050505b30631533a8c36105fc60208d018d610bd0565b838b6040518463ffffffff1660e01b815260040161061c93929190610be9565b5f604051808303815f87803b158015610633575f80fd5b505af1925050508015610644575060015b6106c3573d808015610671576040519150601f19603f3d011682016040523d82523d5f602084013e610676565b606091505b5063f9bb41fb60e01b61068882610c1c565b6001600160e01b0319161461069b575f80fd5b600481019050808060200190518101906106b59190610c67565b919950975095506106c79050565b5f80fd5b5050505093509350939050565b5f8060026106e2858761096d565b6106ec919061088e565b90508483116106fc579050610715565b61071161070a846002610956565b829061074a565b9150505b9392505050565b5f5a610f8161072d84611000610956565b610737919061088e565b6107439061c35061096d565b1092915050565b5f8183106107585781610412565b5090919050565b5f6020828403121561076f575f80fd5b813567ffffffffffffffff811115610785575f80fd5b820160a08185031215610715575f80fd5b80356001600160a01b03811681146107ac575f80fd5b919050565b5f805f80606085870312156107c4575f80fd5b6107cd85610796565b9350602085013567ffffffffffffffff808211156107e9575f80fd5b818701915087601f8301126107fc575f80fd5b81358181111561080a575f80fd5b88602082850101111561081b575f80fd5b95986020929092019750949560400135945092505050565b5f8060408385031215610844575f80fd5b823567ffffffffffffffff81111561085a575f80fd5b8301610120818603121561086c575f80fd5b946020939093013593505050565b634e487b7160e01b5f52601160045260245ffd5b5f826108a857634e487b7160e01b5f52601260045260245ffd5b500490565b5f823561011e198336030181126108c2575f80fd5b9190910192915050565b80151581146108d9575f80fd5b50565b5f602082840312156108ec575f80fd5b8135610715816108cc565b5f5b838110156109115781810151838201526020016108f9565b50505f910152565b5f81518084526109308160208601602086016108f7565b601f01601f19169290920160200192915050565b602081525f6104126020830184610919565b80820281158282048414176104155761041561087a565b808201808211156104155761041561087a565b5f600182016109915761099161087a565b5060010190565b818382375f9101908152919050565b818103818111156104155761041561087a565b8315158152826020820152606060408201525f6109da6060830184610919565b95945050505050565b5f808335601e198436030181126109f8575f80fd5b830160208101925035905067ffffffffffffffff811115610a17575f80fd5b803603821315610a25575f80fd5b9250929050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b5f610120610a7284610a6585610796565b6001600160a01b03169052565b60208301356020850152610a8960408401846109e3565b826040870152610a9c8387018284610a2c565b92505050610aad60608401846109e3565b8583036060870152610ac0838284610a2c565b925050506080830135608085015260a083013560a085015260c083013560c0850152610aef60e08401846109e3565b85830360e0870152610b02838284610a2c565b92505050610100610b15818501856109e3565b86840383880152610b27848284610a2c565b979650505050505050565b602081525f6104126020830184610a54565b5f82516108c28184602087016108f7565b5f60208284031215610b65575f80fd5b5051919050565b5f808335601e19843603018112610b81575f80fd5b83018035915067ffffffffffffffff821115610b9b575f80fd5b602001915036819003821315610a25575f80fd5b604081525f610bc16040830185610a54565b90508260208301529392505050565b5f60208284031215610be0575f80fd5b61041282610796565b6001600160a01b03841681526060602082018190525f90610c0c90830185610919565b9050826040830152949350505050565b805160208201516001600160e01b03198082169291906004831015610c4b5780818460040360031b1b83161693505b505050919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215610c79575f80fd5b8351610c84816108cc565b60208501516040860151919450925067ffffffffffffffff80821115610ca8575f80fd5b818601915086601f830112610cbb575f80fd5b815181811115610ccd57610ccd610c53565b604051601f8201601f19908116603f01168101908382118183101715610cf557610cf5610c53565b81604052828152896020848701011115610d0d575f80fd5b610d1e8360208301602088016108f7565b8095505050505050925092509256fea2646970667358221220beed3acca0e128dd5c8307965b3bac43ff9675975c28ef36a745c5b95a2e66c864736f6c63430008180033"; +export const _deployedBytecode = +"0x608060405260043610610033575f3560e01c806308c4a1f51461003d5780631533a8c31461005c5780637a65051b1461007b575b61003b61009a565b005b348015610048575f80fd5b5061003b61005736600461075f565b6100b9565b348015610067575f80fd5b5061003b6100763660046107b1565b6102be565b348015610086575f80fd5b5061003b610095366004610833565b61036e565b6100b773a13db4ecfbce0586e57d1aee224fbe64706e8cd36103ad565b565b3330146100c4575f80fd5b5f6100d76060830135602084013561088e565b90505f6100ec604084013560608501356103cb565b9050805f806101036100fe87806108ad565b61041b565b905061011560a08701608088016108dc565b610187575f80806101346101298a806108ad565b858b6040013561052b565b925092509250826101635780604051632cf919e960e11b815260040161015a9190610944565b60405180910390fd5b6060890135610173836002610956565b61017d919061088e565b9450505050610195565b6101928585856106d4565b91505b5f5b846101a387600161096d565b101561027e57806101b381610980565b91505f90506101c6606089013585610956565b90506101d18161071c565b610222575f6101e460608a013589610956565b90505f6101f560608b013589610956565b604051631167ca7360e11b815260048101849052602481018290526044810186905290915060640161015a565b5f806102386102318b806108ad565b868561052b565b509150915081156102655761025b6102548260608d01356103cb565b889061074a565b9650859750610269565b8598505b6102748989896106d4565b9550505050610197565b61029a61028f606089013587610956565b60408901359061074a565b604051634641ac4d60e11b815260048101919091526024810182905260440161015a565b5f5a90505f80866001600160a01b03168487876040516102df929190610998565b5f604051808303815f8787f1925050503d805f8114610319576040519150601f19603f3d011682016040523d82523d5f602084013e61031e565b606091505b50915091505f5a61032f90856109a7565b90505f8361033d578261034d565b60405180602001604052805f8152505b905083828260405163f9bb41fb60e01b815260040161015a939291906109ba565b5f6103788361041b565b90505f805f61038886858761052b565b925092509250828282604051636ce2512b60e11b815260040161015a939291906109ba565b365f80375f80365f845af43d5f803e8080156103c7573d5ff35b3d5ffd5b5f815f036103e4576103dd828461088e565b9050610415565b821561041057816103f66001856109a7565b610400919061088e565b61040b90600161096d565b610412565b5f5b90505b92915050565b5f805f306001600160a01b03166322cdde4c60e01b856040516024016104419190610b32565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b031990941693909317909252905161047f9190610b44565b5f604051808303815f865af19150503d805f81146104b8576040519150601f19603f3d011682016040523d82523d5f602084013e6104bd565b606091505b50915091508161050f5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c20746f20676574557365724f7048617368206661696c656400000000604482015260640161015a565b808060200190518101906105239190610b55565b949350505050565b5f806060368261053d88840189610b6c565b915091505f81600381111561055157833591505b5060606372288ed160e01b6001600160e01b03198316016105b057898960405160240161057f929190610baf565b60408051601f198184030181529190526020810180516001600160e01b0316638dd7712f60e01b17905290506105e9565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152509293505050505b30631533a8c36105fc60208d018d610bd0565b838b6040518463ffffffff1660e01b815260040161061c93929190610be9565b5f604051808303815f87803b158015610633575f80fd5b505af1925050508015610644575060015b6106c3573d808015610671576040519150601f19603f3d011682016040523d82523d5f602084013e610676565b606091505b5063f9bb41fb60e01b61068882610c1c565b6001600160e01b0319161461069b575f80fd5b600481019050808060200190518101906106b59190610c67565b919950975095506106c79050565b5f80fd5b5050505093509350939050565b5f8060026106e2858761096d565b6106ec919061088e565b90508483116106fc579050610715565b61071161070a846002610956565b829061074a565b9150505b9392505050565b5f5a610f8161072d84611000610956565b610737919061088e565b6107439061c35061096d565b1092915050565b5f8183106107585781610412565b5090919050565b5f6020828403121561076f575f80fd5b813567ffffffffffffffff811115610785575f80fd5b820160a08185031215610715575f80fd5b80356001600160a01b03811681146107ac575f80fd5b919050565b5f805f80606085870312156107c4575f80fd5b6107cd85610796565b9350602085013567ffffffffffffffff808211156107e9575f80fd5b818701915087601f8301126107fc575f80fd5b81358181111561080a575f80fd5b88602082850101111561081b575f80fd5b95986020929092019750949560400135945092505050565b5f8060408385031215610844575f80fd5b823567ffffffffffffffff81111561085a575f80fd5b8301610120818603121561086c575f80fd5b946020939093013593505050565b634e487b7160e01b5f52601160045260245ffd5b5f826108a857634e487b7160e01b5f52601260045260245ffd5b500490565b5f823561011e198336030181126108c2575f80fd5b9190910192915050565b80151581146108d9575f80fd5b50565b5f602082840312156108ec575f80fd5b8135610715816108cc565b5f5b838110156109115781810151838201526020016108f9565b50505f910152565b5f81518084526109308160208601602086016108f7565b601f01601f19169290920160200192915050565b602081525f6104126020830184610919565b80820281158282048414176104155761041561087a565b808201808211156104155761041561087a565b5f600182016109915761099161087a565b5060010190565b818382375f9101908152919050565b818103818111156104155761041561087a565b8315158152826020820152606060408201525f6109da6060830184610919565b95945050505050565b5f808335601e198436030181126109f8575f80fd5b830160208101925035905067ffffffffffffffff811115610a17575f80fd5b803603821315610a25575f80fd5b9250929050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b5f610120610a7284610a6585610796565b6001600160a01b03169052565b60208301356020850152610a8960408401846109e3565b826040870152610a9c8387018284610a2c565b92505050610aad60608401846109e3565b8583036060870152610ac0838284610a2c565b925050506080830135608085015260a083013560a085015260c083013560c0850152610aef60e08401846109e3565b85830360e0870152610b02838284610a2c565b92505050610100610b15818501856109e3565b86840383880152610b27848284610a2c565b979650505050505050565b602081525f6104126020830184610a54565b5f82516108c28184602087016108f7565b5f60208284031215610b65575f80fd5b5051919050565b5f808335601e19843603018112610b81575f80fd5b83018035915067ffffffffffffffff821115610b9b575f80fd5b602001915036819003821315610a25575f80fd5b604081525f610bc16040830185610a54565b90508260208301529392505050565b5f60208284031215610be0575f80fd5b61041282610796565b6001600160a01b03841681526060602082018190525f90610c0c90830185610919565b9050826040830152949350505050565b805160208201516001600160e01b03198082169291906004831015610c4b5780818460040360031b1b83161693505b505050919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215610c79575f80fd5b8351610c84816108cc565b60208501516040860151919450925067ffffffffffffffff80821115610ca8575f80fd5b818601915086601f830112610cbb575f80fd5b815181811115610ccd57610ccd610c53565b604051601f8201601f19908116603f01168101908382118183101715610cf557610cf5610c53565b81604052828152896020848701011115610d0d575f80fd5b610d1e8360208301602088016108f7565b8095505050505050925092509256fea2646970667358221220beed3acca0e128dd5c8307965b3bac43ff9675975c28ef36a745c5b95a2e66c864736f6c63430008180033"; +type CallGasEstimationProxyConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: CallGasEstimationProxyConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class CallGasEstimationProxy__factory extends ContractFactory { + constructor(...args: CallGasEstimationProxyConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override deploy( + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise { + return super.deploy(overrides || {}) as Promise; + } + override getDeployTransaction( + overrides?: Overrides & { from?: PromiseOrValue } + ): TransactionRequest { + return super.getDeployTransaction(overrides || {}); + } + override attach(address: string): CallGasEstimationProxy { + return super.attach(address) as CallGasEstimationProxy; + } + override connect(signer: Signer): CallGasEstimationProxy__factory { + return super.connect(signer) as CallGasEstimationProxy__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): CallGasEstimationProxyInterface { + return new utils.Interface(_abi) as CallGasEstimationProxyInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): CallGasEstimationProxy { + return new Contract( + address, + _abi, + signerOrProvider + ) as CallGasEstimationProxy; + } +} diff --git a/packages/types/src/contracts/EPv7/factories/core/index.ts b/packages/types/src/contracts/EPv7/factories/core/index.ts index 3439cc50..aa046300 100644 --- a/packages/types/src/contracts/EPv7/factories/core/index.ts +++ b/packages/types/src/contracts/EPv7/factories/core/index.ts @@ -9,3 +9,4 @@ export { NonceManager__factory } from "./NonceManager__factory"; export { SenderCreator__factory } from "./SenderCreator__factory"; export { StakeManager__factory } from "./StakeManager__factory"; export { UserOperationLib__factory } from "./UserOperationLib__factory"; +export { CallGasEstimationProxy__factory } from "./CallGasEstimationProxy__factory";