Roles.sol 826 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. require(account != address(0));
  15. role.bearer[account] = true;
  16. }
  17. /**
  18. * @dev remove an account's access to this role
  19. */
  20. function remove(Role storage role, address account) internal {
  21. require(account != address(0));
  22. role.bearer[account] = false;
  23. }
  24. /**
  25. * @dev check if an account has this role
  26. * @return bool
  27. */
  28. function has(Role storage role, address account)
  29. internal
  30. view
  31. returns (bool)
  32. {
  33. require(account != address(0));
  34. return role.bearer[account];
  35. }
  36. }