diff --git a/src/Kernel.sol b/src/Kernel.sol index a3a4e4b..787dd47 100644 --- a/src/Kernel.sol +++ b/src/Kernel.sol @@ -181,42 +181,36 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager bytes memory result; if (address(config.hook) == address(0)) { revert InvalidSelector(); - } else { - // action installed - bytes memory context; - if ( - address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF - ) { - context = _doPreHook(config.hook, msg.value, msg.data); - } else if (address(config.hook) == 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF) { - // for selector manager, address(0) for the hook will default to type(address).max, - // and this will only allow entrypoints to interact - if (msg.sender != address(entrypoint)) { - revert InvalidCaller(); - } - } - // execute action - if (config.callType == CALLTYPE_SINGLE) { - (success, result) = ExecLib.doFallback2771Call(config.target); - } else if (config.callType == CALLTYPE_DELEGATECALL) { - (success, result) = ExecLib.executeDelegatecall(config.target, msg.data); - } else { - revert NotSupportedCallType(); - } - if ( - address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF - ) { - _doPostHook(config.hook, context); + } + // action installed + bytes memory context; + if (address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF) { + context = _doPreHook(config.hook, msg.value, msg.data); + } else if (address(config.hook) == 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF) { + // for selector manager, address(0) for the hook will default to type(address).max, + // and this will only allow entrypoints to interact + if (msg.sender != address(entrypoint)) { + revert InvalidCaller(); } } + // execute action + if (config.callType == CALLTYPE_SINGLE) { + (success, result) = ExecLib.doFallback2771Call(config.target); + } else if (config.callType == CALLTYPE_DELEGATECALL) { + (success, result) = ExecLib.executeDelegatecall(config.target, msg.data); + } else { + revert NotSupportedCallType(); + } if (!success) { assembly { revert(add(result, 0x20), mload(result)) } - } else { - assembly { - return(add(result, 0x20), mload(result)) - } + } + if (address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF) { + _doPostHook(config.hook, context); + } + assembly { + return(add(result, 0x20), mload(result)) } } @@ -289,10 +283,11 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager context = _doPreHook(hook, msg.value, userOp.callData[4:]); } (bool success, bytes memory ret) = ExecLib.executeDelegatecall(address(this), userOp.callData[4:]); + if (!success) { + revert ExecutionReverted(); + } if (address(hook) != address(1)) { _doPostHook(hook, context); - } else if (!success) { - revert ExecutionReverted(); } } diff --git a/src/interfaces/IERC7579Modules.sol b/src/interfaces/IERC7579Modules.sol index d07da1b..0f9d51b 100644 --- a/src/interfaces/IERC7579Modules.sol +++ b/src/interfaces/IERC7579Modules.sol @@ -44,7 +44,7 @@ interface IValidator is IModule { /** * @dev Validates a transaction on behalf of the account. - * This function is intended to be called by the MSA during the ERC-4337 validaton phase + * This function is intended to be called by the MSA during the ERC-4337 validation phase * Note: solely relying on bytes32 hash and signature is not sufficient for some * validation implementations (i.e. SessionKeys often need access to userOp.calldata) * @param userOp The user operation to be validated. The userOp MUST NOT contain any metadata.