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
59 changes: 27 additions & 32 deletions src/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IERC7579Modules.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down