From fff960e85fc1ae2e97200448e68ec2f1473e0727 Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Mon, 5 Feb 2024 02:15:51 +0530 Subject: [PATCH] Added _acceptAdminOnTimelock() --- contracts/GovernorBravoDelegate.sol | 10 ++++++++++ contracts/GovernorBravoInterfaces.sol | 3 +++ contracts/Timelock.sol | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/contracts/GovernorBravoDelegate.sol b/contracts/GovernorBravoDelegate.sol index 93c085b..a3263ef 100644 --- a/contracts/GovernorBravoDelegate.sol +++ b/contracts/GovernorBravoDelegate.sol @@ -370,6 +370,16 @@ contract InstaGovernorBravoDelegate is GovernorBravoDelegateStorageV1, GovernorB emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); } + /** + * @notice Accepts transfer of admin rights on timelock contract. msg.sender must be admin of this contract + * @dev Admin function for pending admin to accept role and update admin on timelock contract + */ + function _acceptAdminOnTimelock() external { + // Check caller is pendingAdmin and pendingAdmin ≠ address(0) + require(msg.sender == admin && msg.sender != address(0), "GovernorBravo:_acceptAdmin: pending admin only"); + timelock.acceptAdmin(); + } + function getChainIdInternal() internal pure returns (uint) { uint chainId; diff --git a/contracts/GovernorBravoInterfaces.sol b/contracts/GovernorBravoInterfaces.sol index 4b9b337..af89a68 100644 --- a/contracts/GovernorBravoInterfaces.sol +++ b/contracts/GovernorBravoInterfaces.sol @@ -63,6 +63,9 @@ contract GovernorBravoEvents { /// @notice Emitted when pendingAdmin is accepted, which means admin is updated event NewAdmin(address oldAdmin, address newAdmin); + + /// @notice Emitted when pendingAdmin is accepted, which means timelock is updated + event NewTimelock(address oldTimelock, address newTimelock); } contract GovernorBravoDelegatorStorage { diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index 9771a39..ce48d30 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -19,7 +19,7 @@ contract InstaTimelockV2 { address public admin; address public pendingAdmin; - address pubic guardian; + address public guardian; uint public delay; mapping (bytes32 => bool) public queuedTransactions; @@ -27,7 +27,7 @@ contract InstaTimelockV2 { constructor(address admin_, uint delay_, address guardian_) { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); - require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); + require(delay_ <= MAXIMUM_DELAY, "Timelock::constructor: Delay must not exceed maximum delay."); admin = admin_; delay = delay_;