-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathAdminRole.sol
38 lines (32 loc) · 1.02 KB
/
AdminRole.sol
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
pragma solidity 0.5.17;
import "../openzeppelin/Ownable.sol";
contract AdminRole is Ownable {
/// @dev user => flag whether user has admin role.
mapping(address => bool) public admins;
event AdminAdded(address admin);
event AdminRemoved(address admin);
/**
* @dev Throws if called by any account other than the owner or admin.
* or on our own overriding sovrynOwnable.
*/
modifier onlyAuthorized() {
require(isOwner() || admins[msg.sender], "unauthorized");
_;
}
/**
* @notice Add account to ACL.
* @param _admin The addresses of the account to grant permissions.
* */
function addAdmin(address _admin) public onlyOwner {
admins[_admin] = true;
emit AdminAdded(_admin);
}
/**
* @notice Remove account from ACL.
* @param _admin The addresses of the account to revoke permissions.
* */
function removeAdmin(address _admin) public onlyOwner {
admins[_admin] = false;
emit AdminRemoved(_admin);
}
}