Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions src/MSAAdvanced.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyEntryPointOrSelf
withHook
{
(address hook, bytes memory hookData) = _preCheck();
(CallType callType, ExecType execType,,) = mode.decode();

// check if calltype is batch or single
Expand Down Expand Up @@ -68,9 +68,6 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
} else {
revert UnsupportedCallType(callType);
}

// TODO: add correct data
_postCheck(hook, hookData, true, new bytes(0));
}

/**
Expand All @@ -87,11 +84,11 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyExecutorModule
withHook
returns (
bytes[] memory returnData // TODO returnData is not used
)
{
(address hook, bytes memory hookData) = _preCheck();
(CallType callType, ExecType execType,,) = mode.decode();

// check if calltype is batch or single
Expand Down Expand Up @@ -130,9 +127,6 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
} else {
revert UnsupportedCallType(callType);
}

// TODO: add correct data
_postCheck(hook, hookData, true, new bytes(0));
}

/**
Expand Down Expand Up @@ -167,18 +161,14 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyEntryPointOrSelf
withHook
{
(address hook, bytes memory hookData) = _preCheck();

if (moduleTypeId == MODULE_TYPE_VALIDATOR) _installValidator(module, initData);
else if (moduleTypeId == MODULE_TYPE_EXECUTOR) _installExecutor(module, initData);
else if (moduleTypeId == MODULE_TYPE_FALLBACK) _installFallbackHandler(module, initData);
else if (moduleTypeId == MODULE_TYPE_HOOK) _installHook(module, initData);
else revert UnsupportedModuleType(moduleTypeId);
emit ModuleInstalled(moduleTypeId, module);

// TODO: add correct data
_postCheck(hook, hookData, true, new bytes(0));
}

/**
Expand All @@ -192,9 +182,8 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyEntryPointOrSelf
withHook
{
(address hook, bytes memory hookData) = _preCheck();

if (moduleTypeId == MODULE_TYPE_VALIDATOR) {
_uninstallValidator(module, deInitData);
} else if (moduleTypeId == MODULE_TYPE_EXECUTOR) {
Expand All @@ -207,9 +196,6 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
revert UnsupportedModuleType(moduleTypeId);
}
emit ModuleUninstalled(moduleTypeId, module);

// TODO: add correct data
_postCheck(hook, hookData, true, new bytes(0));
}

/**
Expand Down
26 changes: 8 additions & 18 deletions src/core/HookManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,14 @@ abstract contract HookManager {
error HookPostCheckFailed();
error HookAlreadyInstalled(address currentHook);

function _preCheck() internal returns (address hook, bytes memory hookData) {
hook = _getHook();
if (hook != address(0)) {
hookData = IHook(hook).preCheck(msg.sender, msg.value, msg.data);
return (hook, hookData);
}
}

function _postCheck(
address hook,
bytes memory hookData,
bool executionSuccess,
bytes memory executionReturnValue
)
internal
{
if (hook != address(0)) {
IHook(hook).postCheck(hookData, executionSuccess, executionReturnValue);
modifier withHook() {
address hook = _getHook();
if (hook == address(0)) {
_;
} else {
bytes memory hookData = IHook(hook).preCheck(msg.sender, msg.value, msg.data);
_;
IHook(hook).postCheck(hookData);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/interfaces/IERC7579Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.21;

import { CallType, ExecType, ModeCode } from "../lib/ModeLib.sol";
import { PackedUserOperation } from "account-abstraction/interfaces/IAccount.sol";

struct Execution {
address target;
Expand Down
7 changes: 1 addition & 6 deletions src/interfaces/IERC7579Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ interface IHook is IModule {
external
returns (bytes memory hookData);

function postCheck(
bytes calldata hookData,
bool executionSuccess,
bytes calldata executionReturnValue
)
external;
function postCheck(bytes calldata hookData) external;
}

interface IFallback is IModule { }
8 changes: 1 addition & 7 deletions test/mocks/MockHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ contract MockHook is IHook {
external
returns (bytes memory hookData)
{ }
function postCheck(
bytes calldata hookData,
bool executionSuccess,
bytes calldata executionReturnValue
)
external
{ }
function postCheck(bytes calldata hookData) external { }

function isModuleType(uint256 moduleTypeId) external view returns (bool) {
return moduleTypeId == MODULE_TYPE_HOOK;
Expand Down