Added _acceptAdminOnTimelock()

This commit is contained in:
Thrilok kumar 2024-02-05 02:15:51 +05:30
parent 60bf8a6e0e
commit fff960e85f
3 changed files with 15 additions and 2 deletions

View File

@ -370,6 +370,16 @@ contract InstaGovernorBravoDelegate is GovernorBravoDelegateStorageV1, GovernorB
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); 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) { function getChainIdInternal() internal pure returns (uint) {
uint chainId; uint chainId;

View File

@ -63,6 +63,9 @@ contract GovernorBravoEvents {
/// @notice Emitted when pendingAdmin is accepted, which means admin is updated /// @notice Emitted when pendingAdmin is accepted, which means admin is updated
event NewAdmin(address oldAdmin, address newAdmin); 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 { contract GovernorBravoDelegatorStorage {

View File

@ -19,7 +19,7 @@ contract InstaTimelockV2 {
address public admin; address public admin;
address public pendingAdmin; address public pendingAdmin;
address pubic guardian; address public guardian;
uint public delay; uint public delay;
mapping (bytes32 => bool) public queuedTransactions; mapping (bytes32 => bool) public queuedTransactions;
@ -27,7 +27,7 @@ contract InstaTimelockV2 {
constructor(address admin_, uint delay_, address guardian_) { constructor(address admin_, uint delay_, address guardian_) {
require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); 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_; admin = admin_;
delay = delay_; delay = delay_;