Skip to content

Commit 7aeb11b

Browse files
committed
fix: update nonce value for first txn
1 parent 7716f65 commit 7aeb11b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/contracts/modules/commons/ModuleAuthDynamic.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ constructor(address _factory, address _startupWalletImpl, address _immutableSign
7676
* For defensive validation, each extracted address is compared against IMMUTABLE_SIGNER_CONTRACT.
7777
* If a match is found, it is recorded.
7878
*
79-
* Special case: If this is the first transaction (nonce == 0) and the immutable signer contract
80-
* is one of the signers, the signature is automatically validated and approved without checking
81-
* the stored image hash. This allows the immutable signer to bootstrap the wallet on first use.
79+
* Special case: If this is the first transaction (nonce was 0, now 1 after increment) and the immutable
80+
* signer contract is one of the signers, the signature is automatically validated and approved without
81+
* checking the stored image hash. This allows the immutable signer to bootstrap the wallet on first use.
8282
*/
8383
function _signatureValidationWithUpdateCheck(
8484
bytes32 _hash,
@@ -145,9 +145,10 @@ constructor(address _factory, address _startupWalletImpl, address _immutableSign
145145
imageHash = keccak256(abi.encode(imageHash, addrWeight, addr));
146146
}
147147

148-
// Check if this is the first transaction (nonce == 0) and immutable signer contract is one of the signers
148+
// Check if this is the first transaction (nonce was 0 before increment) and immutable signer contract is one of the signers
149+
// Note: _validateNonce increments the nonce before _signatureValidation is called, so we check for 1, not 0
149150
uint256 currentNonce = uint256(ModuleStorage.readBytes32Map(NonceKey.NONCE_KEY, bytes32(uint256(0))));
150-
if (currentNonce == 0 && immutableSignerContractFound) {
151+
if (currentNonce == 1 && immutableSignerContractFound) {
151152
return (true, true, imageHash);
152153
}
153154

0 commit comments

Comments
 (0)