Skip to content

Commit

Permalink
module events
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jul 23, 2024
1 parent d6b7580 commit bc4524a
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 9 deletions.
4 changes: 0 additions & 4 deletions contracts/abstraction/account/ERC7579Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ abstract contract ERC7579Account is
if (moduleTypeId != MODULE_TYPE_SIGNER && !IERC7579Module(module).isModuleType(moduleTypeId))
revert MismatchModuleTypeId(moduleTypeId, module);
_installModule(moduleTypeId, module, initData);
/// TODO: silent unreachable and re-enable this event
// emit ModuleInstalled(moduleTypeId, module);
}

/// @inheritdoc IERC7579ModuleConfig
Expand All @@ -193,8 +191,6 @@ abstract contract ERC7579Account is
bytes calldata deInitData
) public virtual onlyEntryPointOrSelf {
_uninstallModule(moduleTypeId, module, deInitData);
/// TODO: silent unreachable and re-enable this event
// emit ModuleUninstalled(moduleTypeId, module);
}

/// @inheritdoc IERC7579ModuleConfig
Expand Down
8 changes: 7 additions & 1 deletion contracts/abstraction/account/modules/AccountEIP7702.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import {AccountValidateECDSA} from "./validation/AccountValidateECDSA.sol";
import {ERC4337Utils} from "../../utils/ERC4337Utils.sol";
import {PackedUserOperation} from "../../../interfaces/IERC4337.sol";

/**
* @dev Extension of AccountValidateECDSA that grants access to the private key which address matches the one of this
* Account. In the case of an account instanciated at the address of an EOA using EIP-7702, using this module will

Check failure on line 11 in contracts/abstraction/account/modules/AccountEIP7702.sol

View workflow job for this annotation

GitHub Actions / codespell

instanciated ==> instantiated
* allow the EOA's private key to control the account.
*/
abstract contract Account7702 is AccountValidateECDSA {
/// @inheritdoc AccountValidateECDSA
function _isSigner(address signer) internal view virtual override returns (bool) {
return signer == address(this);
return signer == address(this) || super._isSigner(signer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abstract contract ERC7579AccountModuleExecutor is ERC7579Account {
if (moduleTypeId == MODULE_TYPE_EXECUTOR) {
if (!_executors.add(module)) revert ModuleAlreadyInstalled(moduleTypeId, module);
IERC7579Module(module).onInstall(initData);
emit ModuleInstalled(moduleTypeId, module);
} else {
super._installModule(moduleTypeId, module, initData);
}
Expand All @@ -49,6 +50,7 @@ abstract contract ERC7579AccountModuleExecutor is ERC7579Account {
if (moduleTypeId == MODULE_TYPE_EXECUTOR) {
if (!_executors.remove(module)) revert ModuleNotInstalled(moduleTypeId, module);
IERC7579Module(module).onUninstall(deInitData);
emit ModuleUninstalled(moduleTypeId, module);
} else {
super._uninstallModule(moduleTypeId, module, deInitData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ abstract contract ERC7579AccountModuleFallback is ERC7579Account {
_fallbacks[selector] = module;

IERC7579Module(module).onInstall(initData[4:]);
emit ModuleInstalled(moduleTypeId, module);
} else {
super._installModule(moduleTypeId, module, initData);
}
Expand All @@ -59,6 +60,7 @@ abstract contract ERC7579AccountModuleFallback is ERC7579Account {
delete _fallbacks[selector];

IERC7579Module(module).onUninstall(deInitData[4:]);
emit ModuleUninstalled(moduleTypeId, module);
} else {
super._uninstallModule(moduleTypeId, module, deInitData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ abstract contract ERC7579AccountModuleHook is ERC7579Account {
if (_hook != address(0)) revert ModuleNotInstalled(moduleTypeId, _hook);
_hook = module;
IERC7579Module(module).onInstall(initData);
emit ModuleInstalled(moduleTypeId, module);
} else {
super._installModule(moduleTypeId, module, initData);
}
Expand All @@ -58,6 +59,7 @@ abstract contract ERC7579AccountModuleHook is ERC7579Account {
if (_hook != module) revert ModuleAlreadyInstalled(moduleTypeId, module);
delete _hook;
IERC7579Module(module).onUninstall(deInitData);
emit ModuleUninstalled(moduleTypeId, module);
} else {
super._uninstallModule(moduleTypeId, module, deInitData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abstract contract ERC7579AccountModuleSigner is ERC7579Account {
if (!_signers.add(module)) revert ModuleAlreadyInstalled(moduleTypeId, module);
// Do not install signers
// IERC7579Module(module).onInstall(initData);
emit ModuleInstalled(moduleTypeId, module);
} else {
super._installModule(moduleTypeId, module, initData);
}
Expand All @@ -50,6 +51,7 @@ abstract contract ERC7579AccountModuleSigner is ERC7579Account {
if (!_signers.remove(module)) revert ModuleNotInstalled(moduleTypeId, module);
// Do not uninstall signers
// IERC7579Module(module).onUninstall(deInitData);
emit ModuleUninstalled(moduleTypeId, module);
} else {
super._uninstallModule(moduleTypeId, module, deInitData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ abstract contract ERC7579AccountModuleValidator is ERC7579Account {
if (moduleTypeId == MODULE_TYPE_VALIDATOR) {
if (!_validators.add(module)) revert ModuleAlreadyInstalled(moduleTypeId, module);
IERC7579Module(module).onInstall(initData);
emit ModuleInstalled(moduleTypeId, module);
} else {
super._installModule(moduleTypeId, module, initData);
}
Expand All @@ -48,6 +49,7 @@ abstract contract ERC7579AccountModuleValidator is ERC7579Account {
if (moduleTypeId == MODULE_TYPE_VALIDATOR) {
if (!_validators.remove(module)) revert ModuleNotInstalled(moduleTypeId, module);
IERC7579Module(module).onUninstall(deInitData);
emit ModuleUninstalled(moduleTypeId, module);
} else {
super._uninstallModule(moduleTypeId, module, deInitData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ import {AccountValidateECDSA} from "./validation/AccountValidateECDSA.sol";
import {AccountValidateERC7579} from "./validation/AccountValidateERC7579.sol";

abstract contract ERC7579AccountMultisig is ERC7579Account, AccountValidateECDSA, AccountValidateERC7579 {
/// @dev Number of distinct signers/validators required for a userOperation to be valid
function requiredSignatures() public view virtual returns (uint256);

/// @inheritdoc AccountValidateECDSA
function _isSigner(address signer) internal view virtual override returns (bool) {
return isModuleInstalled(MODULE_TYPE_SIGNER, signer, _zeroBytesCalldata());
return isModuleInstalled(MODULE_TYPE_SIGNER, signer, _zeroBytesCalldata()) || super._isSigner(signer);
}

/// @inheritdoc AccountValidateERC7579
function _isValidator(address module) internal view virtual override returns (bool) {
return isModuleInstalled(MODULE_TYPE_VALIDATOR, module, _zeroBytesCalldata());
return isModuleInstalled(MODULE_TYPE_VALIDATOR, module, _zeroBytesCalldata()) || super._isValidator(module);
}

/// @inheritdoc Account
function _validateUserOp(
PackedUserOperation calldata userOp,
bytes32 userOpHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ import {MessageHashUtils} from "../../../../utils/cryptography/MessageHashUtils.
import {PackedUserOperation} from "../../../../interfaces/IERC4337.sol";

abstract contract AccountValidateECDSA is Account {
function _isSigner(address) internal view virtual returns (bool);
/**
* @dev Hook used to verify the validity of recovered signers.
*
* Must be implemented by some access control management system to validate which EOA is authorised to sign user
* operations for this account.
*/
function _isSigner(address) internal view virtual returns (bool) {
return false;
}

/// @inheritdoc Account
function _validateUserOp(
PackedUserOperation calldata /*userOp*/,
bytes32 userOpHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ import {PackedUserOperation} from "../../../../interfaces/IERC4337.sol";
import {IERC7579Validator} from "../../../../interfaces/IERC7579Module.sol";

abstract contract AccountValidateERC7579 is Account {
function _isValidator(address) internal view virtual returns (bool);
/**
* @dev Hook used to verify the validity of validator used.
*
* Must be implemented by some access control management system to validate which validator is authorised to sign
* user operations for this account.
*/
function _isValidator(address) internal view virtual returns (bool) {
return false;
}

/// @inheritdoc Account
function _validateUserOp(
PackedUserOperation calldata userOp,
bytes32 userOpHash,
Expand Down

0 comments on commit bc4524a

Please sign in to comment.