stackup-wallet / userop.js

A simple JS library for building ERC-4337 UserOperations.
MIT License
113 stars 32 forks source link

Fix nonce 0 creation assumption #95

Closed nalinbhardwaj closed 10 months ago

nalinbhardwaj commented 11 months ago

Currently the gasLimit estimation preset assumes that Nonce 0 includes the deployment of the account. This assumption is fine for SimpleAccount.sol, but is not the ERC-4337 specified way to detect this case, particularly as nonces may be interpreted in different ways by account contracts. This causes the preset to crash when used with accounts with such non-standard nonces/deployment procedure (example, Daimo).

ERC-4337 specifies that the account should only be created if initCode is non-empty, this commit makes the gas estimation match this behaviour.

image

I've tested this PR with Daimo accounts as well as the Quickstart examples in Stackup docs.

nalinbhardwaj commented 10 months ago

Closing because looks like this got fixed in https://github.com/stackup-wallet/userop.js/commit/ef1a5fc368fd84422ee35a240b99aabae76c83e8