Skip to content

Commit

Permalink
feat: add onlyDelegateCall modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0dot committed Oct 11, 2024
1 parent 6cecd8f commit 6a8cfa7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/helpers/ExecutionInstallDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {ModuleInstallCommons} from "../libraries/ModuleInstallCommons.sol";
contract ExecutionInstallDelegate {
using LinkedListSetLib for LinkedListSet;

address internal immutable _THIS_ADDRESS;

error OnlyDelegateCall();
error NullModule();
error InterfaceNotSupported(address module);
error ModuleInstallCallbackFailed(address module, bytes revertReason);
Expand All @@ -31,13 +34,24 @@ contract ExecutionInstallDelegate {
error Erc4337FunctionNotAllowed(bytes4 selector);
error ExecutionHookAlreadySet(HookConfig hookConfig);

modifier onlyDelegateCall() {
if (address(this) == _THIS_ADDRESS) {
revert OnlyDelegateCall();
}
_;
}

constructor() {
_THIS_ADDRESS = address(this);
}

// External Functions

function installExecution(
address module,
ExecutionManifest calldata manifest,
bytes calldata moduleInstallData
) external {
) external onlyDelegateCall {
AccountStorage storage _storage = getAccountStorage();

if (module == address(0)) {
Expand Down Expand Up @@ -78,6 +92,7 @@ contract ExecutionInstallDelegate {

function uninstallExecution(address module, ExecutionManifest calldata manifest, bytes calldata uninstallData)
external
onlyDelegateCall
{
AccountStorage storage _storage = getAccountStorage();

Expand Down Expand Up @@ -120,7 +135,7 @@ contract ExecutionInstallDelegate {
bool skipRuntimeValidation,
bool allowGlobalValidation,
address module
) private {
) internal {
ExecutionData storage _executionData = getAccountStorage().executionData[selector];

if (_executionData.module != address(0)) {
Expand All @@ -147,15 +162,15 @@ contract ExecutionInstallDelegate {
_executionData.allowGlobalValidation = allowGlobalValidation;
}

function _removeExecutionFunction(bytes4 selector) private {
function _removeExecutionFunction(bytes4 selector) internal {
ExecutionData storage _executionData = getAccountStorage().executionData[selector];

_executionData.module = address(0);
_executionData.skipRuntimeValidation = false;
_executionData.allowGlobalValidation = false;
}

function _removeExecHooks(LinkedListSet storage hooks, HookConfig hookConfig) private {
function _removeExecHooks(LinkedListSet storage hooks, HookConfig hookConfig) internal {
// Todo: use predecessor
hooks.tryRemove(toSetValue(hookConfig));
}
Expand Down

0 comments on commit 6a8cfa7

Please sign in to comment.