@@ -9,20 +9,27 @@ import {AccountERC7579} from "./AccountERC7579.sol";
9
9
/**
10
10
* @dev Extension of {AccountERC7579} with support for a single hook module (type 4).
11
11
*
12
- * If installed, this extension will call the hook module's {IERC7579Hook-preCheck} before
13
- * executing any operation with {_execute} (including {execute} and {executeFromExecutor} by
14
- * default) and {IERC7579Hook-postCheck} thereafter.
12
+ * If installed, this extension will call the hook module's {IERC7579Hook-preCheck} before executing any operation
13
+ * with {_execute} (including {execute} and {executeFromExecutor} by default) and {IERC7579Hook-postCheck} thereafter.
14
+ *
15
+ * NOTE: Hook modules break the check-effect-interaction pattern. In particular, the {IERC7579Hook-preCheck} hook can
16
+ * lead to potentially dangerous reentrancy. Using the `withHook()` modifier is safe if no effect is performed
17
+ * before the preHook or after the postHook. That is the case on all functions here, but it may not be the case if
18
+ * functions that have this modifier are overridden. Developers should be extremely careful when implementing hook
19
+ * modules or further overriding functions that involve hooks.
15
20
*/
16
21
abstract contract AccountERC7579Hooked is AccountERC7579 {
17
22
address private _hook;
18
23
19
24
/**
20
- * @dev Calls {IERC7579Hook-preCheck} before executing the modified
21
- * function and {IERC7579Hook-postCheck} thereafter.
25
+ * @dev Calls {IERC7579Hook-preCheck} before executing the modified function and {IERC7579Hook-postCheck}
26
+ * thereafter.
22
27
*/
23
28
modifier withHook () {
24
29
address hook_ = hook ();
25
30
bytes memory hookData;
31
+
32
+ // slither-disable-next-line reentrancy-no-eth
26
33
if (hook_ != address (0 )) hookData = IERC7579Hook (hook_).preCheck (msg .sender , msg .value , msg .data );
27
34
_;
28
35
if (hook_ != address (0 )) IERC7579Hook (hook_).postCheck (hookData);
@@ -50,7 +57,6 @@ abstract contract AccountERC7579Hooked is AccountERC7579 {
50
57
}
51
58
52
59
/// @dev Installs a module with support for hook modules. See {AccountERC7579-_installModule}
53
- /// TODO: withHook? based on what value?
54
60
function _installModule (
55
61
uint256 moduleTypeId ,
56
62
address module ,
@@ -64,7 +70,6 @@ abstract contract AccountERC7579Hooked is AccountERC7579 {
64
70
}
65
71
66
72
/// @dev Uninstalls a module with support for hook modules. See {AccountERC7579-_uninstallModule}
67
- /// TODO: withHook? based on what value?
68
73
function _uninstallModule (
69
74
uint256 moduleTypeId ,
70
75
address module ,
0 commit comments