IAccessControlDefaultAdminRules.sol 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlDefaultAdminRules.sol)
  3. pragma solidity ^0.8.20;
  4. import {IAccessControl} from "../IAccessControl.sol";
  5. /**
  6. * @dev External interface of AccessControlDefaultAdminRules declared to support ERC-165 detection.
  7. */
  8. interface IAccessControlDefaultAdminRules is IAccessControl {
  9. /**
  10. * @dev The new default admin is not a valid default admin.
  11. */
  12. error AccessControlInvalidDefaultAdmin(address defaultAdmin);
  13. /**
  14. * @dev At least one of the following rules was violated:
  15. *
  16. * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself.
  17. * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time.
  18. * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps.
  19. */
  20. error AccessControlEnforcedDefaultAdminRules();
  21. /**
  22. * @dev The delay for transferring the default admin delay is enforced and
  23. * the operation must wait until `schedule`.
  24. *
  25. * NOTE: `schedule` can be 0 indicating there's no transfer scheduled.
  26. */
  27. error AccessControlEnforcedDefaultAdminDelay(uint48 schedule);
  28. /**
  29. * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next
  30. * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule`
  31. * passes.
  32. */
  33. event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);
  34. /**
  35. * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule.
  36. */
  37. event DefaultAdminTransferCanceled();
  38. /**
  39. * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next
  40. * delay to be applied between default admin transfer after `effectSchedule` has passed.
  41. */
  42. event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);
  43. /**
  44. * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass.
  45. */
  46. event DefaultAdminDelayChangeCanceled();
  47. /**
  48. * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder.
  49. */
  50. function defaultAdmin() external view returns (address);
  51. /**
  52. * @dev Returns a tuple of a `newAdmin` and an accept schedule.
  53. *
  54. * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role
  55. * by calling {acceptDefaultAdminTransfer}, completing the role transfer.
  56. *
  57. * A zero value only in `acceptSchedule` indicates no pending admin transfer.
  58. *
  59. * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced.
  60. */
  61. function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);
  62. /**
  63. * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started.
  64. *
  65. * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set
  66. * the acceptance schedule.
  67. *
  68. * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this
  69. * function returns the new delay. See {changeDefaultAdminDelay}.
  70. */
  71. function defaultAdminDelay() external view returns (uint48);
  72. /**
  73. * @dev Returns a tuple of `newDelay` and an effect schedule.
  74. *
  75. * After the `schedule` passes, the `newDelay` will get into effect immediately for every
  76. * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
  77. *
  78. * A zero value only in `effectSchedule` indicates no pending delay change.
  79. *
  80. * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay}
  81. * will be zero after the effect schedule.
  82. */
  83. function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);
  84. /**
  85. * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance
  86. * after the current timestamp plus a {defaultAdminDelay}.
  87. *
  88. * Requirements:
  89. *
  90. * - Only can be called by the current {defaultAdmin}.
  91. *
  92. * Emits a DefaultAdminRoleChangeStarted event.
  93. */
  94. function beginDefaultAdminTransfer(address newAdmin) external;
  95. /**
  96. * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
  97. *
  98. * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function.
  99. *
  100. * Requirements:
  101. *
  102. * - Only can be called by the current {defaultAdmin}.
  103. *
  104. * May emit a DefaultAdminTransferCanceled event.
  105. */
  106. function cancelDefaultAdminTransfer() external;
  107. /**
  108. * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
  109. *
  110. * After calling the function:
  111. *
  112. * - `DEFAULT_ADMIN_ROLE` should be granted to the caller.
  113. * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder.
  114. * - {pendingDefaultAdmin} should be reset to zero values.
  115. *
  116. * Requirements:
  117. *
  118. * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`.
  119. * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed.
  120. */
  121. function acceptDefaultAdminTransfer() external;
  122. /**
  123. * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting
  124. * into effect after the current timestamp plus a {defaultAdminDelay}.
  125. *
  126. * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this
  127. * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay}
  128. * set before calling.
  129. *
  130. * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then
  131. * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin}
  132. * complete transfer (including acceptance).
  133. *
  134. * The schedule is designed for two scenarios:
  135. *
  136. * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by
  137. * {defaultAdminDelayIncreaseWait}.
  138. * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`.
  139. *
  140. * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change.
  141. *
  142. * Requirements:
  143. *
  144. * - Only can be called by the current {defaultAdmin}.
  145. *
  146. * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.
  147. */
  148. function changeDefaultAdminDelay(uint48 newDelay) external;
  149. /**
  150. * @dev Cancels a scheduled {defaultAdminDelay} change.
  151. *
  152. * Requirements:
  153. *
  154. * - Only can be called by the current {defaultAdmin}.
  155. *
  156. * May emit a DefaultAdminDelayChangeCanceled event.
  157. */
  158. function rollbackDefaultAdminDelay() external;
  159. /**
  160. * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay})
  161. * to take effect. Default to 5 days.
  162. *
  163. * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with
  164. * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds)
  165. * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can
  166. * be overrode for a custom {defaultAdminDelay} increase scheduling.
  167. *
  168. * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise,
  169. * there's a risk of setting a high new delay that goes into effect almost immediately without the
  170. * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
  171. */
  172. function defaultAdminDelayIncreaseWait() external view returns (uint48);
  173. }