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.
36 lines
982 B
36 lines
982 B
pragma solidity ^0.5.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(!has(role, account), "Roles: account already has role");
|
|
role.bearer[account] = true;
|
|
}
|
|
|
|
/**
|
|
* @dev Remove an account's access to this role.
|
|
*/
|
|
function remove(Role storage role, address account) internal {
|
|
require(has(role, account), "Roles: account does not have role");
|
|
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), "Roles: account is the zero address");
|
|
return role.bearer[account];
|
|
}
|
|
}
|
|
|