IAccessControl.sol 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.3.0) (access/IAccessControl.sol)
  3. pragma solidity ^0.8.20;
  4. /**
  5. * @dev External interface of AccessControl declared to support ERC-165 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 to signal this.
  23. */
  24. event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
  25. /**
  26. * @dev Emitted when `account` is granted `role`.
  27. *
  28. * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
  29. * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
  30. */
  31. event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
  32. /**
  33. * @dev Emitted when `account` is revoked `role`.
  34. *
  35. * `sender` is the account that originated the contract call:
  36. * - if using `revokeRole`, it is the admin role bearer
  37. * - if using `renounceRole`, it is the role bearer (i.e. `account`)
  38. */
  39. event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
  40. /**
  41. * @dev Returns `true` if `account` has been granted `role`.
  42. */
  43. function hasRole(bytes32 role, address account) external view returns (bool);
  44. /**
  45. * @dev Returns the admin role that controls `role`. See {grantRole} and
  46. * {revokeRole}.
  47. *
  48. * To change a role's admin, use {AccessControl-_setRoleAdmin}.
  49. */
  50. function getRoleAdmin(bytes32 role) external view returns (bytes32);
  51. /**
  52. * @dev Grants `role` to `account`.
  53. *
  54. * If `account` had not been already granted `role`, emits a {RoleGranted}
  55. * event.
  56. *
  57. * Requirements:
  58. *
  59. * - the caller must have ``role``'s admin role.
  60. */
  61. function grantRole(bytes32 role, address account) external;
  62. /**
  63. * @dev Revokes `role` from `account`.
  64. *
  65. * If `account` had been granted `role`, emits a {RoleRevoked} event.
  66. *
  67. * Requirements:
  68. *
  69. * - the caller must have ``role``'s admin role.
  70. */
  71. function revokeRole(bytes32 role, address account) external;
  72. /**
  73. * @dev Revokes `role` from the calling account.
  74. *
  75. * Roles are often managed via {grantRole} and {revokeRole}: this function's
  76. * purpose is to provide a mechanism for accounts to lose their privileges
  77. * if they are compromised (such as when a trusted device is misplaced).
  78. *
  79. * If the calling account had been granted `role`, emits a {RoleRevoked}
  80. * event.
  81. *
  82. * Requirements:
  83. *
  84. * - the caller must be `callerConfirmation`.
  85. */
  86. function renounceRole(bytes32 role, address callerConfirmation) external;
  87. }