-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathEnforcementModule.sol
More file actions
93 lines (81 loc) · 3.44 KB
/
EnforcementModule.sol
File metadata and controls
93 lines (81 loc) · 3.44 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
/* ==== Module === */
import {EnforcementModuleInternal} from "../../internal/EnforcementModuleInternal.sol";
import {IERC3643Enforcement, IERC3643EnforcementEvent} from "../../../interfaces/tokenization/IERC3643Partial.sol";
/*
/**
* @title Enforcement module.
* @dev
*
* Allows the issuer to freeze transfers from a given address
*/
abstract contract EnforcementModule is
EnforcementModuleInternal,
IERC3643Enforcement,
IERC3643EnforcementEvent
{
/* ============ State Variables ============ */
bytes32 public constant ENFORCER_ROLE = keccak256("ENFORCER_ROLE");
/* ============ Modifier ============ */
/// @dev Modifier to restrict access to the burner functions
modifier onlyEnforcer() {
_authorizeFreeze();
_;
}
/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/* ============ State restricted functions ============ */
/**
* @inheritdoc IERC3643Enforcement
* @custom:access-control
* - the caller must have the `ENFORCER_ROLE`.
*/
function setAddressFrozen(address account, bool freeze) public virtual override(IERC3643Enforcement) onlyEnforcer{
_addAddressToTheList(account, freeze, "");
}
/**
* @notice Sets the frozen status of a specific account.
* @dev
* Extend ERC-3643 functions `setAddressFrozen` with a supplementary `data` parameter
* - Freezing an account prevents it from transferring or receiving tokens depending on enforcement logic.
* - Emits an `AddressFrozen` event.
* @param account The address whose frozen status is being updated.
* @param freeze Set to `true` to freeze the account, or `false` to unfreeze it.
* @param data Optional metadata providing context or justification for the action (e.g. compliance reason).
* @custom:access-control
* - the caller must have the `ENFORCER_ROLE`.
*/
function setAddressFrozen(
address account, bool freeze, bytes calldata data
) public virtual onlyEnforcer {
_addAddressToTheList(account, freeze, data);
}
/**
* @inheritdoc IERC3643Enforcement
* @custom:access-control
* - the caller must have the `ENFORCER_ROLE`.
*/
function batchSetAddressFrozen(
address[] calldata accounts, bool[] calldata freezes
) public virtual override(IERC3643Enforcement) onlyEnforcer {
_addAddressesToTheList(accounts, freezes, "");
}
/* ============ View functions ============ */
/**
* @inheritdoc IERC3643Enforcement
*/
function isFrozen(address account) public override(IERC3643Enforcement) view virtual returns (bool isFrozen_) {
return _addressIsListed(account);
}
/*//////////////////////////////////////////////////////////////
INTERNAL/PRIVATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
function _addAddressToTheList(EnforcementModuleInternalStorage storage $,address account, bool freeze, bytes memory data) internal override(EnforcementModuleInternal){
EnforcementModuleInternal._addAddressToTheList($, account, freeze, data);
emit AddressFrozen(account, freeze, _msgSender(), data);
}
/* ============ Access Control ============ */
function _authorizeFreeze() internal virtual;
}