Skip to content

Commit

Permalink
Add nonce key param on all wallets (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride authored Feb 8, 2024
1 parent fbbb381 commit 1d92797
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog
## [1.4.2] - 2024-01-26
## [1.5.1] - 2024-02-08
### Bug fixes
- Added `key` param on SimpleAccount and ZeroDev wallets

## [1.5.0] - 2024-01-26
### Breaking changes
- Refactored `estimate` method
- Added `key` in `estimate` method to include `key` of semi-abstracted nonce (https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etherspot/prime-sdk",
"version": "1.5.0",
"version": "1.5.1",
"description": "Etherspot Prime (Account Abstraction) SDK",
"keywords": [
"ether",
Expand Down
1 change: 0 additions & 1 deletion src/sdk/base/EtherspotWalletAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export class EtherspotWalletAPI extends BaseAccountAPI {
}

async getNonce(key = 0): Promise<BigNumber> {
console.log('checking nonce...');
if (await this.checkAccountPhantom()) {
return BigNumber.from(0);
}
Expand Down
6 changes: 2 additions & 4 deletions src/sdk/base/SimpleAccountWalletAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ export class SimpleAccountAPI extends BaseAccountAPI {
return this.accountAddress;
}

async getNonce(): Promise<BigNumber> {
console.log('checking nonce...');
async getNonce(key = 0): Promise<BigNumber> {
if (await this.checkAccountPhantom()) {
return BigNumber.from(0);
}
const accountContract = await this._getAccountContract();
return accountContract.getNonce();
return await this.nonceManager.getNonce(await this.getAccountAddress(), key);
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/sdk/base/ZeroDevWalletAPI.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BigNumber, BigNumberish, Contract, ethers } from 'ethers';
import {
EntryPoint__factory,
IEntryPoint__factory,
} from '../contracts';
import { arrayify, hexConcat } from 'ethers/lib/utils';
import { BaseApiParams, BaseAccountAPI } from './BaseAccountAPI';
Expand Down Expand Up @@ -117,13 +116,11 @@ export class ZeroDevWalletAPI extends BaseAccountAPI {
return this.accountAddress;
}

async getNonce(): Promise<BigNumber> {
console.log('checking nonce...');
async getNonce(key = 0): Promise<BigNumber> {
if (await this.checkAccountPhantom()) {
return BigNumber.from(0);
}
const entryPoint = IEntryPoint__factory.connect(this.entryPointAddress, this.provider);
return await entryPoint.getNonce(this.accountAddress, 0);
return await this.nonceManager.getNonce(await this.getAccountAddress(), key);
}

async signUserOpHash(userOpHash: string): Promise<string> {
Expand Down

0 comments on commit 1d92797

Please sign in to comment.