-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBlacklist.sol
More file actions
58 lines (49 loc) · 1.75 KB
/
Copy pathBlacklist.sol
File metadata and controls
58 lines (49 loc) · 1.75 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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import {Errors} from "./libraries/Errors.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IBlacklist} from "./interfaces/IBlacklist.sol";
import {Roles} from "./libraries/Roles.sol";
contract Blacklist is IBlacklist {
IAccessControl public immutable override accessController;
mapping(address => bool) private _blacklisted;
/**
* @dev Throws if called by any account other than the blacklister
*/
modifier onlyBlacklister() {
if (!accessController.hasRole(Roles.MCAG_BLACKLIST_ROLE, msg.sender)) {
revert Errors.BLACKLIST_CALLER_IS_NOT_BLACKLISTER();
}
_;
}
constructor(IAccessControl _accessController) {
if (address(_accessController) == address(0)) {
revert Errors.CANNOT_SET_TO_ADDRESS_ZERO();
}
accessController = _accessController;
emit AccessControllerSet(address(_accessController));
}
/**
* @dev Adds account to blacklist
* @param account The address to blacklist
*/
function blacklist(address account) external override onlyBlacklister {
_blacklisted[account] = true;
emit Blacklisted(account);
}
/**
* @dev Removes account from blacklist
* @param account The address to remove from the blacklist
*/
function unBlacklist(address account) external override onlyBlacklister {
_blacklisted[account] = false;
emit UnBlacklisted(account);
}
/**
* @dev Checks if account is blacklisted
* @param account The address to check
*/
function isBlacklisted(address account) external view override returns (bool) {
return _blacklisted[account];
}
}