* Update to ganache-cli v6.1.0 and truffle v4.1.0 * Update to stable version of ganache-cli * fix: update event emission warning - Fix event emission warnings for solidity 4.21 after truffle has been updated to use this version * fix pr review comments * update to truffle v4.1.5 * update package-lock * add additional emit keywords * update solidity-coverage to 0.4.15 * update to solium 1.1.6 * fix MerkleProof coverage analysis by testing through wrapper * change version pragma to ^0.4.21 * fix solium linting errors
56 lines
975 B
Solidity
56 lines
975 B
Solidity
pragma solidity ^0.4.21;
|
|
|
|
|
|
/**
|
|
* @title Roles
|
|
* @author Francisco Giordano (@frangio)
|
|
* @dev Library for managing addresses assigned to a Role.
|
|
* See RBAC.sol for example usage.
|
|
*/
|
|
library Roles {
|
|
struct Role {
|
|
mapping (address => bool) bearer;
|
|
}
|
|
|
|
/**
|
|
* @dev give an address access to this role
|
|
*/
|
|
function add(Role storage role, address addr)
|
|
internal
|
|
{
|
|
role.bearer[addr] = true;
|
|
}
|
|
|
|
/**
|
|
* @dev remove an address' access to this role
|
|
*/
|
|
function remove(Role storage role, address addr)
|
|
internal
|
|
{
|
|
role.bearer[addr] = false;
|
|
}
|
|
|
|
/**
|
|
* @dev check if an address has this role
|
|
* // reverts
|
|
*/
|
|
function check(Role storage role, address addr)
|
|
view
|
|
internal
|
|
{
|
|
require(has(role, addr));
|
|
}
|
|
|
|
/**
|
|
* @dev check if an address has this role
|
|
* @return bool
|
|
*/
|
|
function has(Role storage role, address addr)
|
|
view
|
|
internal
|
|
returns (bool)
|
|
{
|
|
return role.bearer[addr];
|
|
}
|
|
}
|