-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoles.sol
More file actions
43 lines (39 loc) · 969 Bytes
/
Roles.sol
File metadata and controls
43 lines (39 loc) · 969 Bytes
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
pragma solidity ^0.6.0;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles
{
struct Role
{
mapping (address => bool) bearer;
}
/**
* @dev give an account access to this role
*/
function add(Role storage role, address account) internal
{
require(account != address(0));
require(!has(role, account));
role.bearer[account] = true;
}
/**
* @dev remove an account's access to this role
*/
function remove(Role storage role, address account) internal
{
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}
/**
* @dev check if an account has this role
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool)
{
require(account != address(0));
return role.bearer[account];
}
}