11import { BigNumberish , BytesLike , ethers } from "ethers" ;
22import { UserOperationEventEvent } from "./typechain/EntryPoint" ;
33
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+
414export interface IUserOperation {
515 sender : string ;
616 nonce : BigNumberish ;
@@ -15,55 +25,6 @@ export interface IUserOperation {
1525 signature : BytesLike ;
1626}
1727
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-
6728export type UserOperationMiddlewareFn = (
6829 context : IUserOperationMiddlewareCtx
6930) => Promise < void > ;
@@ -72,22 +33,12 @@ export interface IUserOperationMiddlewareCtx {
7233 op : IUserOperation ;
7334 entryPoint : string ;
7435 chainId : BigNumberish ;
36+ stateOverrides ?: StateOverrideSet ;
7537
7638 // A userOpHash is a unique hash of op + entryPoint + chainId.
7739 getUserOpHash : ( ) => string ;
7840}
7941
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-
9142export interface IClientOpts {
9243 entryPoint ?: string ;
9344 overrideBundlerRpc ?: string ;
@@ -96,6 +47,7 @@ export interface IClientOpts {
9647export interface ISendUserOperationOpts {
9748 dryRun ?: boolean ;
9849 onBuild ?: ( op : IUserOperation ) => Promise < any > | any ;
50+ stateOverrides ?: StateOverrideSet ;
9951}
10052
10153export interface ISendUserOperationResponse {
0 commit comments