@@ -20,15 +20,14 @@ import (
20
20
// Client controls the end to end process of adding incoming UserOperations to the mempool. It also
21
21
// implements the required RPC methods as specified in EIP-4337.
22
22
type Client struct {
23
- mempool * mempool.Mempool
24
- chainID * big.Int
25
- supportedEntryPoints []common.Address
26
- userOpHandler modules.UserOpHandlerFunc
27
- logger logr.Logger
28
- getUserOpReceipt GetUserOpReceiptFunc
29
- getSimulateValidation GetSimulateValidationFunc
30
- getCallGasEstimate GetCallGasEstimateFunc
31
- getUserOpByHash GetUserOpByHashFunc
23
+ mempool * mempool.Mempool
24
+ chainID * big.Int
25
+ supportedEntryPoints []common.Address
26
+ userOpHandler modules.UserOpHandlerFunc
27
+ logger logr.Logger
28
+ getUserOpReceipt GetUserOpReceiptFunc
29
+ getGasEstimate GetGasEstimateFunc
30
+ getUserOpByHash GetUserOpByHashFunc
32
31
}
33
32
34
33
// New initializes a new ERC-4337 client which can be extended with modules for validating UserOperations
@@ -39,15 +38,14 @@ func New(
39
38
supportedEntryPoints []common.Address ,
40
39
) * Client {
41
40
return & Client {
42
- mempool : mempool ,
43
- chainID : chainID ,
44
- supportedEntryPoints : supportedEntryPoints ,
45
- userOpHandler : noop .UserOpHandler ,
46
- logger : logger .NewZeroLogr ().WithName ("client" ),
47
- getUserOpReceipt : getUserOpReceiptNoop (),
48
- getSimulateValidation : getSimulateValidationNoop (),
49
- getCallGasEstimate : getCallGasEstimateNoop (),
50
- getUserOpByHash : getUserOpByHashNoop (),
41
+ mempool : mempool ,
42
+ chainID : chainID ,
43
+ supportedEntryPoints : supportedEntryPoints ,
44
+ userOpHandler : noop .UserOpHandler ,
45
+ logger : logger .NewZeroLogr ().WithName ("client" ),
46
+ getUserOpReceipt : getUserOpReceiptNoop (),
47
+ getGasEstimate : getGasEstimateNoop (),
48
+ getUserOpByHash : getUserOpByHashNoop (),
51
49
}
52
50
}
53
51
@@ -77,16 +75,11 @@ func (i *Client) SetGetUserOpReceiptFunc(fn GetUserOpReceiptFunc) {
77
75
i .getUserOpReceipt = fn
78
76
}
79
77
80
- // SetGetSimulateValidationFunc defines a general function for fetching simulateValidation results given a
81
- // userOp and EntryPoint address. This function is called in *Client.EstimateUserOperationGas.
82
- func (i * Client ) SetGetSimulateValidationFunc (fn GetSimulateValidationFunc ) {
83
- i .getSimulateValidation = fn
84
- }
85
-
86
- // SetGetCallGasEstimateFunc defines a general function for fetching an estimate for callGasLimit given a
87
- // userOp and EntryPoint address. This function is called in *Client.EstimateUserOperationGas.
88
- func (i * Client ) SetGetCallGasEstimateFunc (fn GetCallGasEstimateFunc ) {
89
- i .getCallGasEstimate = fn
78
+ // SetGetGasEstimateFunc defines a general function for fetching an estimate for verificationGasLimit and
79
+ // callGasLimit given a userOp and EntryPoint address. This function is called in
80
+ // *Client.EstimateUserOperationGas.
81
+ func (i * Client ) SetGetGasEstimateFunc (fn GetGasEstimateFunc ) {
82
+ i .getGasEstimate = fn
90
83
}
91
84
92
85
// SetGetUserOpByHashFunc defines a general function for fetching a userOp given a userOpHash, EntryPoint
@@ -169,13 +162,7 @@ func (i *Client) EstimateUserOperationGas(op map[string]any, ep string) (*gas.Ga
169
162
hash := userOp .GetUserOpHash (epAddr , i .chainID )
170
163
l = l .WithValues ("userop_hash" , hash )
171
164
172
- sim , err := i .getSimulateValidation (epAddr , userOp )
173
- if err != nil {
174
- l .Error (err , "eth_estimateUserOperationGas error" )
175
- return nil , err
176
- }
177
-
178
- cg , err := i .getCallGasEstimate (epAddr , userOp )
165
+ vg , cg , err := i .getGasEstimate (epAddr , userOp )
179
166
if err != nil {
180
167
l .Error (err , "eth_estimateUserOperationGas error" )
181
168
return nil , err
@@ -184,7 +171,7 @@ func (i *Client) EstimateUserOperationGas(op map[string]any, ep string) (*gas.Ga
184
171
l .Info ("eth_estimateUserOperationGas ok" )
185
172
return & gas.GasEstimates {
186
173
PreVerificationGas : gas .NewDefaultOverhead ().CalcPreVerificationGas (userOp ),
187
- VerificationGas : sim . ReturnInfo . PreOpGas ,
174
+ VerificationGas : big . NewInt ( int64 ( vg )) ,
188
175
CallGasLimit : big .NewInt (int64 (cg )),
189
176
}, nil
190
177
}
0 commit comments