diff --git a/src/account/AccountStorage.sol b/src/account/AccountStorage.sol index c67d6f5e..85d5ca5c 100644 --- a/src/account/AccountStorage.sol +++ b/src/account/AccountStorage.sol @@ -21,12 +21,6 @@ struct PluginData { uint256 dependentCount; } -// Represents data associated with a plugin's permission to use `executeFromPlugin` -// to interact with another plugin installed on the account. -struct PermittedCallData { - bool callPermitted; -} - // Represents data associated with a plugin's permission to use `executeFromPluginExternal` // to interact with contracts and addresses external to the account and its plugins. struct PermittedExternalCallData { @@ -69,7 +63,7 @@ struct AccountStorage { // Execution functions and their associated functions mapping(bytes4 => SelectorData) selectorData; // bytes24 key = address(calling plugin) || bytes4(selector of execution function) - mapping(bytes24 => PermittedCallData) permittedCalls; + mapping(bytes24 => bool) callPermitted; // key = address(calling plugin) || target address mapping(IPlugin => mapping(address => PermittedExternalCallData)) permittedExternalCalls; // For ERC165 introspection diff --git a/src/account/PluginManagerInternals.sol b/src/account/PluginManagerInternals.sol index 3c4f9c1a..538c4ffc 100644 --- a/src/account/PluginManagerInternals.sol +++ b/src/account/PluginManagerInternals.sol @@ -136,23 +136,6 @@ abstract contract PluginManagerInternals is IPluginManager { _removeHooks(_selectorData.executionHooks, preExecHook, postExecHook); } - function _enableExecFromPlugin(bytes4 selector, address plugin, AccountStorage storage accountStorage) - internal - { - bytes24 key = getPermittedCallKey(plugin, selector); - - // If there are duplicates, this will just enable the flag again. This is not a problem, since the boolean - // will be set to false twice during uninstall, which is fine. - accountStorage.permittedCalls[key].callPermitted = true; - } - - function _disableExecFromPlugin(bytes4 selector, address plugin, AccountStorage storage accountStorage) - internal - { - bytes24 key = getPermittedCallKey(plugin, selector); - accountStorage.permittedCalls[key].callPermitted = false; - } - function _addHooks(HookGroup storage hooks, FunctionReference preExecHook, FunctionReference postExecHook) internal { @@ -306,7 +289,9 @@ abstract contract PluginManagerInternals is IPluginManager { // Add installed plugin and selectors this plugin can call length = manifest.permittedExecutionSelectors.length; for (uint256 i = 0; i < length;) { - _enableExecFromPlugin(manifest.permittedExecutionSelectors[i], plugin, _storage); + // If there are duplicates, this will just enable the flag again. This is not a problem, since the + // boolean will be set to false twice during uninstall, which is fine. + _storage.callPermitted[getPermittedCallKey(plugin, manifest.permittedExecutionSelectors[i])] = true; unchecked { ++i; @@ -619,7 +604,7 @@ abstract contract PluginManagerInternals is IPluginManager { length = manifest.permittedExecutionSelectors.length; for (uint256 i = 0; i < length;) { - _disableExecFromPlugin(manifest.permittedExecutionSelectors[i], plugin, _storage); + _storage.callPermitted[getPermittedCallKey(plugin, manifest.permittedExecutionSelectors[i])] = false; unchecked { ++i; diff --git a/src/account/UpgradeableModularAccount.sol b/src/account/UpgradeableModularAccount.sol index cb447eb2..950caeb5 100644 --- a/src/account/UpgradeableModularAccount.sol +++ b/src/account/UpgradeableModularAccount.sol @@ -183,7 +183,7 @@ contract UpgradeableModularAccount is AccountStorage storage _storage = getAccountStorage(); - if (!_storage.permittedCalls[execFromPluginKey].callPermitted) { + if (!_storage.callPermitted[execFromPluginKey]) { revert ExecFromPluginNotPermitted(callingPlugin, selector); }