Skip to content

Commit

Permalink
Fix pre exec hook data in executeFromPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed committed Nov 30, 2023
1 parent 075bc7a commit 8ed1304
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract UpgradeableModularAccount is
modifier wrapNativeFunction() {
_doRuntimeValidationIfNotFromEP();

PostExecToRun[] memory postExecHooks = _doPreExecHooks(msg.sig);
PostExecToRun[] memory postExecHooks = _doPreExecHooks(msg.sig, msg.data);

_;

Expand Down Expand Up @@ -127,7 +127,7 @@ contract UpgradeableModularAccount is

PostExecToRun[] memory postExecHooks;
// Cache post-exec hooks in memory
postExecHooks = _doPreExecHooks(msg.sig);
postExecHooks = _doPreExecHooks(msg.sig, msg.data);

// execute the function, bubbling up any reverts
(bool execSuccess, bytes memory execReturnData) = execPlugin.call(msg.data);
Expand Down Expand Up @@ -197,7 +197,7 @@ contract UpgradeableModularAccount is
revert UnrecognizedFunction(selector);
}

PostExecToRun[] memory postExecHooks = _doPreExecHooks(selector);
PostExecToRun[] memory postExecHooks = _doPreExecHooks(selector, data);

(bool success, bytes memory returnData) = execFunctionPlugin.call(data);

Expand Down Expand Up @@ -256,7 +256,8 @@ contract UpgradeableModularAccount is
);

// Run any pre exec hooks for this selector
PostExecToRun[] memory postExecHooks = _doPreExecHooks(IPluginExecutor.executeFromPluginExternal.selector);
PostExecToRun[] memory postExecHooks =
_doPreExecHooks(IPluginExecutor.executeFromPluginExternal.selector, msg.data);

// Perform the external call
bytes memory returnData = _exec(target, value, data);
Expand Down Expand Up @@ -478,7 +479,10 @@ contract UpgradeableModularAccount is
}
}

function _doPreExecHooks(bytes4 selector) internal returns (PostExecToRun[] memory postHooksToRun) {
function _doPreExecHooks(bytes4 selector, bytes calldata data)
internal
returns (PostExecToRun[] memory postHooksToRun)
{
HookGroup storage hooks = getAccountStorage().selectorData[selector].executionHooks;

uint256 postExecHooksLength = 0;
Expand All @@ -500,7 +504,7 @@ contract UpgradeableModularAccount is

(address plugin, uint8 functionId) = preExecHook.unpack();
bytes memory preExecHookReturnData;
try IPlugin(plugin).preExecutionHook(functionId, msg.sender, msg.value, msg.data) returns (
try IPlugin(plugin).preExecutionHook(functionId, msg.sender, msg.value, data) returns (
bytes memory returnData
) {
preExecHookReturnData = returnData;
Expand Down

0 comments on commit 8ed1304

Please sign in to comment.