You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
730 B
39 lines
730 B
7 years ago
|
pragma solidity ^0.4.24;
|
||
7 years ago
|
|
||
|
|
||
|
/**
|
||
|
* @title Roles
|
||
|
* @dev Library for managing addresses assigned to a Role.
|
||
|
*/
|
||
|
library Roles {
|
||
7 years ago
|
struct Role {
|
||
|
mapping (address => bool) bearer;
|
||
|
}
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
7 years ago
|
* @dev give an account access to this role
|
||
7 years ago
|
*/
|
||
7 years ago
|
function add(Role storage _role, address _account) internal {
|
||
7 years ago
|
_role.bearer[_account] = true;
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
7 years ago
|
* @dev remove an account's access to this role
|
||
7 years ago
|
*/
|
||
7 years ago
|
function remove(Role storage _role, address _account) internal {
|
||
7 years ago
|
_role.bearer[_account] = false;
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
7 years ago
|
* @dev check if an account has this role
|
||
7 years ago
|
* @return bool
|
||
|
*/
|
||
7 years ago
|
function has(Role storage _role, address _account)
|
||
7 years ago
|
internal
|
||
7 years ago
|
view
|
||
7 years ago
|
returns (bool)
|
||
|
{
|
||
7 years ago
|
return _role.bearer[_account];
|
||
7 years ago
|
}
|
||
7 years ago
|
}
|