IAccessControlDefaultAdminRules.sol 8.0 KB

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