IAccessControlDefaultAdminRules.sol 7.2 KB

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