Skip to content

Commit 227c32c

Browse files
ernestognwAmxx
andauthored
Add signature argument to internal _validateUserOp in Account.sol (#5976)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
1 parent 45558b8 commit 227c32c

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
- `SignerERC7702` is renamed as `SignerEIP7702`. Imports and inheritance must be updated to that new name and path. Behavior is unmodified.
1212
- `ERC721Holder`, `ERC1155Holder`, `ReentrancyGuard` and `ReentrancyGuardTransient` are flagged as stateless and are no longer transpiled. Developers using their upgradeable variants from `@openzeppelin/contracts-upgradeable` must update their imports to use the equivalent version available in `@openzeppelin/contracts`.
1313
- Update minimum pragma to 0.8.24 in `Votes`, `VotesExtended`, `ERC20Votes`, `Strings`, `ERC1155URIStorage`, `MessageHashUtils`, `ERC721URIStorage`, `ERC721Votes`, `ERC721Wrapper`, `ERC721Burnable`, `ERC721Consecutive`, `ERC721Enumerable`, `ERC721Pausable`, `ERC721Royalty`, `ERC721Wrapper`, `EIP712`, `ERC4626` and `ERC7739`. ([#5726](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5726))
14-
- `AccountERC7579`: Installing and uninstalling fallback modules now require the corresponding `initData` and `deInitData` arguments to be at least 4 bytes long (matching the selector to which the fallback module is registered). It now reverts with `ERC7579CannotDecodeFallbackData` instead of treating the missing bytes as `0x00`.
14+
- `Account`: Add `signature` argument to the internal `_validateUserOp` function for custom signature handling logic. Developers overriding it must now provide the signature from the user operation (i.e. `userOp.signature`) to keep compatibility. ([#5976](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5976))
15+
- `AccountERC7579`: Installing and uninstalling fallback modules now require the corresponding `initData` and `deInitData` arguments to be at least 4 bytes long (matching the selector to which the fallback module is registered). It now reverts with `ERC7579CannotDecodeFallbackData` instead of treating the missing bytes as `0x00`. ([#5974](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5974))
1516

1617
### Deprecation
1718

contracts/account/Account.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ abstract contract Account is AbstractSigner, IAccount {
7575
bytes32 userOpHash,
7676
uint256 missingAccountFunds
7777
) public virtual onlyEntryPoint returns (uint256) {
78-
uint256 validationData = _validateUserOp(userOp, userOpHash);
78+
uint256 validationData = _validateUserOp(userOp, userOpHash, userOp.signature);
7979
_payPrefund(missingAccountFunds);
8080
return validationData;
8181
}
@@ -84,15 +84,21 @@ abstract contract Account is AbstractSigner, IAccount {
8484
* @dev Returns the validationData for a given user operation. By default, this checks the signature of the
8585
* signable hash (produced by {_signableUserOpHash}) using the abstract signer ({AbstractSigner-_rawSignatureValidation}).
8686
*
87+
* The `signature` parameter is taken directly from the user operation's `signature` field.
88+
* This design enables derived contracts to implement custom signature handling logic,
89+
* such as embedding additional data within the signature and processing it by overriding this function
90+
* and optionally invoking `super`.
91+
*
8792
* NOTE: The userOpHash is assumed to be correct. Calling this function with a userOpHash that does not match the
8893
* userOp will result in undefined behavior.
8994
*/
9095
function _validateUserOp(
9196
PackedUserOperation calldata userOp,
92-
bytes32 userOpHash
97+
bytes32 userOpHash,
98+
bytes calldata signature
9399
) internal virtual returns (uint256) {
94100
return
95-
_rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), userOp.signature)
101+
_rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), signature)
96102
? ERC4337Utils.SIG_VALIDATION_SUCCESS
97103
: ERC4337Utils.SIG_VALIDATION_FAILED;
98104
}

contracts/account/extensions/draft-AccountERC7579.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,14 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75
210210
*/
211211
function _validateUserOp(
212212
PackedUserOperation calldata userOp,
213-
bytes32 userOpHash
213+
bytes32 userOpHash,
214+
bytes calldata signature
214215
) internal virtual override returns (uint256) {
215216
address module = _extractUserOpValidator(userOp);
216217
return
217218
isModuleInstalled(MODULE_TYPE_VALIDATOR, module, Calldata.emptyBytes())
218219
? IERC7579Validator(module).validateUserOp(userOp, _signableUserOpHash(userOp, userOpHash))
219-
: super._validateUserOp(userOp, userOpHash);
220+
: super._validateUserOp(userOp, userOpHash, signature);
220221
}
221222

222223
/**

contracts/mocks/account/AccountMock.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ abstract contract AccountERC7702WithModulesMock is
102102
{
103103
function _validateUserOp(
104104
PackedUserOperation calldata userOp,
105-
bytes32 userOpHash
105+
bytes32 userOpHash,
106+
bytes calldata signature
106107
) internal virtual override(Account, AccountERC7579) returns (uint256) {
107-
return super._validateUserOp(userOp, userOpHash);
108+
return super._validateUserOp(userOp, userOpHash, signature);
108109
}
109110

110111
/// @dev Resolve implementation of ERC-1271 by both ERC7739 and AccountERC7579 to support both schemes.

0 commit comments

Comments
 (0)