-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlacklistAdminRole.sol
More file actions
70 lines (57 loc) · 2.02 KB
/
BlacklistAdminRole.sol
File metadata and controls
70 lines (57 loc) · 2.02 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
pragma solidity 0.6.0;
import "./Roles.sol";
import "./Ownable.sol";
/** @title Contract managing the blacklist admin role */
contract BlacklistAdminRole is Ownable {
using Roles for Roles.Role;
event BlacklistAdminAdded(address indexed account);
event BlacklistAdminRemoved(address indexed account);
Roles.Role private blacklistAdmins;
constructor() internal {
_addBlacklistAdmin(msg.sender);
}
modifier onlyBlacklistAdmin() {
require(isBlacklistAdmin(msg.sender), "not blacklistAdmin");
_;
}
modifier requireBlacklistAdmin(address account) {
require(isBlacklistAdmin(account), "not blacklistAdmin");
_;
}
/**
* @dev Checks if account is blacklist admin
* @param account Account to check
* @return Boolean indicating if account is blacklist admin
*/
function isBlacklistAdmin(address account) public view returns (bool) {
return blacklistAdmins.has(account);
}
/**
* @dev Adds a blacklist admin account. Is only callable by owner.
* @param account Address to be added
*/
function addBlacklistAdmin(address account) public onlyOwner {
_addBlacklistAdmin(account);
}
/**
* @dev Removes a blacklist admin account. Is only callable by owner
* @param account Address to be removed
*/
function removeBlacklistAdmin(address account) public onlyOwner {
_removeBlacklistAdmin(account);
}
/** @dev Allows privilege holder to renounce their role */
function renounceBlacklistAdmin() public {
_removeBlacklistAdmin(msg.sender);
}
/** @dev Internal implementation of addBlacklistAdmin */
function _addBlacklistAdmin(address account) internal {
blacklistAdmins.add(account);
emit BlacklistAdminAdded(account);
}
/** @dev Internal implementation of removeBlacklistAdmin */
function _removeBlacklistAdmin(address account) internal {
blacklistAdmins.remove(account);
emit BlacklistAdminRemoved(account);
}
}