|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +// OpenZeppelin Contracts v4.6.0 (governance/TimelockControllerWith46Migration.sol) |
| 3 | + |
| 4 | +pragma solidity ^0.8.0; |
| 5 | + |
| 6 | +import "./TimelockControllerUpgradeable.sol"; |
| 7 | +import "../proxy/utils/Initializable.sol"; |
| 8 | + |
| 9 | +/** |
| 10 | + * @dev Extension of the TimelockController that includes an additional |
| 11 | + * function to migrate from OpenZeppelin Upgradeable Contracts <4.6 to >=4.6. |
| 12 | + * |
| 13 | + * This migration is necessary to setup administration rights over the new |
| 14 | + * `CANCELLER_ROLE`. |
| 15 | + * |
| 16 | + * The migration is trustless and can be performed by anyone. |
| 17 | + * |
| 18 | + * _Available since v4.6._ |
| 19 | + */ |
| 20 | +contract TimelockControllerWith46MigrationUpgradeable is Initializable, TimelockControllerUpgradeable { |
| 21 | + function __TimelockControllerWith46Migration_init( |
| 22 | + uint256 minDelay, |
| 23 | + address[] memory proposers, |
| 24 | + address[] memory executors |
| 25 | + ) internal onlyInitializing { |
| 26 | + __TimelockController_init_unchained(minDelay, proposers, executors); |
| 27 | + } |
| 28 | + |
| 29 | + function __TimelockControllerWith46Migration_init_unchained( |
| 30 | + uint256, |
| 31 | + address[] memory, |
| 32 | + address[] memory |
| 33 | + ) internal onlyInitializing {} |
| 34 | + |
| 35 | + /** |
| 36 | + * @dev Migration function. Running it is necessary for upgradeable |
| 37 | + * instances that were initially setup with code <4.6 and that upgraded |
| 38 | + * to >=4.6. |
| 39 | + */ |
| 40 | + function migrateTo46() public virtual { |
| 41 | + require( |
| 42 | + getRoleAdmin(PROPOSER_ROLE) == TIMELOCK_ADMIN_ROLE && getRoleAdmin(CANCELLER_ROLE) == DEFAULT_ADMIN_ROLE, |
| 43 | + "TimelockController: already migrated" |
| 44 | + ); |
| 45 | + _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @dev This empty reserved space is put in place to allow future versions to add new |
| 50 | + * variables without shifting down storage in the inheritance chain. |
| 51 | + * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps |
| 52 | + */ |
| 53 | + uint256[50] private __gap; |
| 54 | +} |
0 commit comments