1
1
import { BigNumberish , BytesLike , ethers } from "ethers" ;
2
2
import { UserOperationEventEvent } from "./typechain/EntryPoint" ;
3
3
4
+ export interface ISateOverrideAccount {
5
+ nonce : BigNumberish ;
6
+ code : BytesLike ;
7
+ balance : BigNumberish ;
8
+ state : Record < string , BytesLike > ;
9
+ stateDiff : Record < string , BytesLike > ;
10
+ }
11
+
12
+ export type StateOverrideSet = Record < string , Partial < ISateOverrideAccount > > ;
13
+
4
14
export interface IUserOperation {
5
15
sender : string ;
6
16
nonce : BigNumberish ;
@@ -15,55 +25,6 @@ export interface IUserOperation {
15
25
signature : BytesLike ;
16
26
}
17
27
18
- export interface IUserOperationBuilder {
19
- // get methods.
20
- getSender : ( ) => string ;
21
- getNonce : ( ) => BigNumberish ;
22
- getInitCode : ( ) => BytesLike ;
23
- getCallData : ( ) => BytesLike ;
24
- getCallGasLimit : ( ) => BigNumberish ;
25
- getVerificationGasLimit : ( ) => BigNumberish ;
26
- getPreVerificationGas : ( ) => BigNumberish ;
27
- getMaxFeePerGas : ( ) => BigNumberish ;
28
- getMaxPriorityFeePerGas : ( ) => BigNumberish ;
29
- getPaymasterAndData : ( ) => BytesLike ;
30
- getSignature : ( ) => BytesLike ;
31
- getOp : ( ) => IUserOperation ;
32
-
33
- // set methods.
34
- setSender : ( address : string ) => IUserOperationBuilder ;
35
- setNonce : ( nonce : BigNumberish ) => IUserOperationBuilder ;
36
- setInitCode : ( code : BytesLike ) => IUserOperationBuilder ;
37
- setCallData : ( data : BytesLike ) => IUserOperationBuilder ;
38
- setCallGasLimit : ( gas : BigNumberish ) => IUserOperationBuilder ;
39
- setVerificationGasLimit : ( gas : BigNumberish ) => IUserOperationBuilder ;
40
- setPreVerificationGas : ( gas : BigNumberish ) => IUserOperationBuilder ;
41
- setMaxFeePerGas : ( fee : BigNumberish ) => IUserOperationBuilder ;
42
- setMaxPriorityFeePerGas : ( fee : BigNumberish ) => IUserOperationBuilder ;
43
- setPaymasterAndData : ( data : BytesLike ) => IUserOperationBuilder ;
44
- setSignature : ( bytes : BytesLike ) => IUserOperationBuilder ;
45
- setPartial : ( partialOp : Partial < IUserOperation > ) => IUserOperationBuilder ;
46
-
47
- // Sets the default values that won't be wiped on reset.
48
- useDefaults : ( partialOp : Partial < IUserOperation > ) => IUserOperationBuilder ;
49
- resetDefaults : ( ) => IUserOperationBuilder ;
50
-
51
- // Some fields may require arbitrary logic to build an op.
52
- // Middleware functions allow you to set custom logic for building op fragments.
53
- useMiddleware : ( fn : UserOperationMiddlewareFn ) => IUserOperationBuilder ;
54
- resetMiddleware : ( ) => IUserOperationBuilder ;
55
-
56
- // This will construct a UserOperation that can be sent to a client.
57
- // It will run through your entire middleware stack in the process.
58
- buildOp : (
59
- entryPoint : string ,
60
- chainId : BigNumberish
61
- ) => Promise < IUserOperation > ;
62
-
63
- // Will reset all fields back to default value.
64
- resetOp : ( ) => IUserOperationBuilder ;
65
- }
66
-
67
28
export type UserOperationMiddlewareFn = (
68
29
context : IUserOperationMiddlewareCtx
69
30
) => Promise < void > ;
@@ -72,22 +33,12 @@ export interface IUserOperationMiddlewareCtx {
72
33
op : IUserOperation ;
73
34
entryPoint : string ;
74
35
chainId : BigNumberish ;
36
+ stateOverrides ?: StateOverrideSet ;
75
37
76
38
// A userOpHash is a unique hash of op + entryPoint + chainId.
77
39
getUserOpHash : ( ) => string ;
78
40
}
79
41
80
- export interface IClient {
81
- sendUserOperation : (
82
- builder : IUserOperationBuilder ,
83
- opts ?: ISendUserOperationOpts
84
- ) => Promise < ISendUserOperationResponse > ;
85
-
86
- buildUserOperation : (
87
- builder : IUserOperationBuilder
88
- ) => Promise < IUserOperation > ;
89
- }
90
-
91
42
export interface IClientOpts {
92
43
entryPoint ?: string ;
93
44
overrideBundlerRpc ?: string ;
@@ -96,6 +47,7 @@ export interface IClientOpts {
96
47
export interface ISendUserOperationOpts {
97
48
dryRun ?: boolean ;
98
49
onBuild ?: ( op : IUserOperation ) => Promise < any > | any ;
50
+ stateOverrides ?: StateOverrideSet ;
99
51
}
100
52
101
53
export interface ISendUserOperationResponse {
0 commit comments