IAccessControl.sol 3.2 KB

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