IAccessControl.sol 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. /**
  4. * @dev External interface of AccessControl declared to support ERC165 detection.
  5. */
  6. interface IAccessControl {
  7. /**
  8. * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
  9. *
  10. * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
  11. * {RoleAdminChanged} not being emitted signaling this.
  12. *
  13. * _Available since v3.1._
  14. */
  15. event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
  16. /**
  17. * @dev Emitted when `account` is granted `role`.
  18. *
  19. * `sender` is the account that originated the contract call, an admin role
  20. * bearer except when using {AccessControl-_setupRole}.
  21. */
  22. event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
  23. /**
  24. * @dev Emitted when `account` is revoked `role`.
  25. *
  26. * `sender` is the account that originated the contract call:
  27. * - if using `revokeRole`, it is the admin role bearer
  28. * - if using `renounceRole`, it is the role bearer (i.e. `account`)
  29. */
  30. event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
  31. /**
  32. * @dev Returns `true` if `account` has been granted `role`.
  33. */
  34. function hasRole(bytes32 role, address account) external view returns (bool);
  35. /**
  36. * @dev Returns the admin role that controls `role`. See {grantRole} and
  37. * {revokeRole}.
  38. *
  39. * To change a role's admin, use {AccessControl-_setRoleAdmin}.
  40. */
  41. function getRoleAdmin(bytes32 role) external view returns (bytes32);
  42. /**
  43. * @dev Grants `role` to `account`.
  44. *
  45. * If `account` had not been already granted `role`, emits a {RoleGranted}
  46. * event.
  47. *
  48. * Requirements:
  49. *
  50. * - the caller must have ``role``'s admin role.
  51. */
  52. function grantRole(bytes32 role, address account) external;
  53. /**
  54. * @dev Revokes `role` from `account`.
  55. *
  56. * If `account` had been granted `role`, emits a {RoleRevoked} event.
  57. *
  58. * Requirements:
  59. *
  60. * - the caller must have ``role``'s admin role.
  61. */
  62. function revokeRole(bytes32 role, address account) external;
  63. /**
  64. * @dev Revokes `role` from the calling account.
  65. *
  66. * Roles are often managed via {grantRole} and {revokeRole}: this function's
  67. * purpose is to provide a mechanism for accounts to lose their privileges
  68. * if they are compromised (such as when a trusted device is misplaced).
  69. *
  70. * If the calling account had been granted `role`, emits a {RoleRevoked}
  71. * event.
  72. *
  73. * Requirements:
  74. *
  75. * - the caller must be `account`.
  76. */
  77. function renounceRole(bytes32 role, address account) external;
  78. }