Roles.sol 730 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. pragma solidity ^0.4.24;
  2. /**
  3. * @title Roles
  4. * @dev Library for managing addresses assigned to a Role.
  5. */
  6. library Roles {
  7. struct Role {
  8. mapping (address => bool) bearer;
  9. }
  10. /**
  11. * @dev give an account access to this role
  12. */
  13. function add(Role storage _role, address _account) internal {
  14. _role.bearer[_account] = true;
  15. }
  16. /**
  17. * @dev remove an account's access to this role
  18. */
  19. function remove(Role storage _role, address _account) internal {
  20. _role.bearer[_account] = false;
  21. }
  22. /**
  23. * @dev check if an account has this role
  24. * @return bool
  25. */
  26. function has(Role storage _role, address _account)
  27. internal
  28. view
  29. returns (bool)
  30. {
  31. return _role.bearer[_account];
  32. }
  33. }