Roles.sol 874 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. pragma solidity ^0.5.7;
  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(!has(role, account));
  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(has(role, account));
  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) internal view returns (bool) {
  29. require(account != address(0));
  30. return role.bearer[account];
  31. }
  32. }