@@ -47,11 +47,6 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
4747 using ExcessivelySafeCall for address ;
4848 using ECDSA for bytes32 ;
4949
50- /// @dev The slot in the transient storage to store the hooking flag.
51- // keccak256(abi.encode(uint256(keccak256(bytes("startale.modulemanager.hooking"))) - 1)) & ~bytes32(uint256(0xff))
52- bytes32 internal constant HOOKING_FLAG_TRANSIENT_STORAGE_SLOT =
53- 0x1085a7be7203eb252e321995729a7b29dd605712ca7b7b85cd33107663f41400 ;
54-
5550 /// @dev The default validator address.
5651 /// @notice To explicitly initialize the default validator, StartaleSmartAccount.execute(_DEFAULT_VALIDATOR.onInstall(...)) should be called.
5752 address internal immutable _DEFAULT_VALIDATOR;
@@ -75,16 +70,9 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
7570 /// @dev sender, msg.data and msg.value is passed to the hook to implement custom flows.
7671 modifier withHook () {
7772 address hook = _getHook ();
78- bool hooking;
79- assembly {
80- hooking := tload (HOOKING_FLAG_TRANSIENT_STORAGE_SLOT)
81- }
82- if (hook == address (0 ) || hooking) {
73+ if (hook == address (0 )) {
8374 _;
8475 } else {
85- assembly {
86- tstore (HOOKING_FLAG_TRANSIENT_STORAGE_SLOT, 1 )
87- }
8876 bytes memory hookData = IHook (hook).preCheck (msg .sender , msg .value , msg .data );
8977 _;
9078 IHook (hook).postCheck (hookData);
@@ -191,7 +179,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
191179 /// @dev This function goes through hook checks via withHook modifier.
192180 /// @dev No need to check that the module is already installed, as this check is done
193181 /// when trying to sstore the module in an appropriate SentinelList
194- function _installModule (uint256 moduleTypeId , address module , bytes calldata initData ) internal withHook {
182+ function _installModule (uint256 moduleTypeId , address module , bytes calldata initData ) internal {
195183 if (! _areSentinelListsInitialized ()) {
196184 _initSentinelLists ();
197185 }
@@ -218,7 +206,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
218206 /// @dev Installs a new validator module after checking if it matches the required module type.
219207 /// @param validator The address of the validator module to be installed.
220208 /// @param data Initialization data to configure the validator upon installation.
221- function _installValidator (address validator , bytes calldata data ) internal virtual {
209+ function _installValidator (address validator , bytes calldata data ) internal virtual withHook {
222210 if (! IValidator (validator).isModuleType (MODULE_TYPE_VALIDATOR)) revert MismatchModuleTypeId ();
223211 if (validator == _DEFAULT_VALIDATOR) {
224212 revert DefaultValidatorAlreadyInstalled ();
@@ -227,7 +215,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
227215 IValidator (validator).onInstall (data);
228216 }
229217
230- /// @dev Uninstalls a validator module /!\ ensuring the account retains at least one validator.
218+ /// @dev Uninstalls a validator module
231219 /// @param validator The address of the validator to be uninstalled.
232220 /// @param data De-initialization data to configure the validator upon uninstallation.
233221 function _uninstallValidator (address validator , bytes calldata data ) internal virtual {
@@ -246,7 +234,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
246234 /// @dev Installs a new executor module after checking if it matches the required module type.
247235 /// @param executor The address of the executor module to be installed.
248236 /// @param data Initialization data to configure the executor upon installation.
249- function _installExecutor (address executor , bytes calldata data ) internal virtual {
237+ function _installExecutor (address executor , bytes calldata data ) internal virtual withHook {
250238 if (! IExecutor (executor).isModuleType (MODULE_TYPE_EXECUTOR)) revert MismatchModuleTypeId ();
251239 _getAccountStorage ().executors.push (executor);
252240 IExecutor (executor).onInstall (data);
@@ -266,7 +254,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
266254 /// @dev Installs a hook module, ensuring no other hooks are installed before proceeding.
267255 /// @param hook The address of the hook to be installed.
268256 /// @param data Initialization data to configure the hook upon installation.
269- function _installHook (address hook , bytes calldata data ) internal virtual {
257+ function _installHook (address hook , bytes calldata data ) internal virtual withHook {
270258 if (! IHook (hook).isModuleType (MODULE_TYPE_HOOK)) revert MismatchModuleTypeId ();
271259 address currentHook = _getHook ();
272260 require (currentHook == address (0 ), HookAlreadyInstalled (currentHook));
@@ -297,7 +285,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
297285 /// @dev Installs a fallback handler for a given selector with initialization data.
298286 /// @param handler The address of the fallback handler to install.
299287 /// @param params The initialization parameters including the selector and call type.
300- function _installFallbackHandler (address handler , bytes calldata params ) internal virtual {
288+ function _installFallbackHandler (address handler , bytes calldata params ) internal virtual withHook {
301289 if (! IFallback (handler).isModuleType (MODULE_TYPE_FALLBACK)) revert MismatchModuleTypeId ();
302290 // Extract the function selector from the provided parameters.
303291 bytes4 selector = bytes4 (params[0 :4 ]);
@@ -350,7 +338,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManagerEventsAndEr
350338 uint256 preValidationHookType ,
351339 address preValidationHook ,
352340 bytes calldata data
353- ) internal virtual {
341+ ) internal virtual withHook {
354342 if (! IModule (preValidationHook).isModuleType (preValidationHookType)) revert MismatchModuleTypeId ();
355343 address currentPreValidationHook = _getPreValidationHook (preValidationHookType);
356344 if (currentPreValidationHook != address (0 )) revert PrevalidationHookAlreadyInstalled (currentPreValidationHook);
0 commit comments