-
-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathCaveatEnforcer.sol
More file actions
47 lines (37 loc) · 1.84 KB
/
CaveatEnforcer.sol
File metadata and controls
47 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT AND Apache-2.0
pragma solidity 0.8.23;
import { ModeLib } from "@erc7579/lib/ModeLib.sol";
import { ICaveatEnforcer } from "../interfaces/ICaveatEnforcer.sol";
import { ModeCode } from "../utils/Types.sol";
import { CALLTYPE_SINGLE, CALLTYPE_BATCH } from "../utils/Constants.sol";
/**
* @title CaveatEnforcer
* @dev This abstract contract enforces caveats before and after the execution of an execution.
*/
abstract contract CaveatEnforcer is ICaveatEnforcer {
using ModeLib for ModeCode;
/// @inheritdoc ICaveatEnforcer
function beforeAllHook(bytes calldata, bytes calldata, ModeCode, bytes calldata, bytes32, address, address) public virtual { }
/// @inheritdoc ICaveatEnforcer
function beforeHook(bytes calldata, bytes calldata, ModeCode, bytes calldata, bytes32, address, address) public virtual { }
/// @inheritdoc ICaveatEnforcer
function afterHook(bytes calldata, bytes calldata, ModeCode, bytes calldata, bytes32, address, address) public virtual { }
/// @inheritdoc ICaveatEnforcer
function afterAllHook(bytes calldata, bytes calldata, ModeCode, bytes calldata, bytes32, address, address) public virtual { }
/// @inheritdoc ICaveatEnforcer
function _convertReadableTermsToCaveats(ReadableTerm[] memory _readableTerms) internal view virtual returns (Caveat[] memory) { }
/**
* @dev Require the function call to be in single execution mode
*/
modifier onlySingleExecutionMode(ModeCode _mode) {
require(ModeLib.getCallType(_mode) == CALLTYPE_SINGLE, "CaveatEnforcer:invalid-call-type");
_;
}
/**
* @dev Require the function call to be in batch execution mode
*/
modifier onlyBatchExecutionMode(ModeCode _mode) {
require(ModeLib.getCallType(_mode) == CALLTYPE_BATCH, "CaveatEnforcer:invalid-call-type");
_;
}
}