Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit a5bea27

Browse files
authored
Allow nonceKey for simpleAccount preset (#111)
1 parent 900d815 commit a5bea27

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/preset/builder/simpleAccount.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class SimpleAccount extends UserOperationBuilder {
2323
private entryPoint: EntryPoint;
2424
private factory: SimpleAccountFactory;
2525
private initCode: string;
26+
private nonceKey: number;
2627
proxy: SimpleAccountImpl;
2728

2829
private constructor(
@@ -44,14 +45,15 @@ export class SimpleAccount extends UserOperationBuilder {
4445
this.provider
4546
);
4647
this.initCode = "0x";
48+
this.nonceKey = opts?.nonceKey || 0;
4749
this.proxy = SimpleAccount__factory.connect(
4850
ethers.constants.AddressZero,
4951
this.provider
5052
);
5153
}
5254

5355
private resolveAccount: UserOperationMiddlewareFn = async (ctx) => {
54-
ctx.op.nonce = await this.entryPoint.getNonce(ctx.op.sender, 0);
56+
ctx.op.nonce = await this.entryPoint.getNonce(ctx.op.sender, this.nonceKey);
5557
ctx.op.initCode = ctx.op.nonce.eq(0) ? this.initCode : "0x";
5658
};
5759

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface IPresetBuilderOpts {
107107
entryPoint?: string;
108108
factory?: string;
109109
salt?: BigNumberish;
110+
nonceKey?: number;
110111
paymasterMiddleware?: UserOperationMiddlewareFn;
111112
overrideBundlerRpc?: string;
112113
}

0 commit comments

Comments
 (0)