Skip to content

Commit

Permalink
feat: add circuit breaker role to customtimelockcontroller
Browse files Browse the repository at this point in the history
  • Loading branch information
adu-web3 committed Sep 9, 2024
1 parent bf6f8c8 commit 3cb88fb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/utils/CustomTimelockController.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/governance/TimelockController.sol";

Check failure on line 4 in src/utils/CustomTimelockController.sol

View workflow job for this annotation

GitHub Actions / Foundry project

global import of path @openzeppelin/contracts/governance/TimelockController.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

interface IPausable {

function pause() external;
function unpause() external;

}

contract CustomTimelockController is TimelockController {

bytes32 public constant CIRCUIT_BREAKER_ROLE = keccak256("CIRCUIT_BREAKER_ROLE");

constructor(
uint256 minDelay,
address[] memory proposers,
address[] memory executors,
address[] memory circuitBreakers,
address admin
) TimelockController(minDelay, proposers, executors, admin) {
_setRoleAdmin(CIRCUIT_BREAKER_ROLE, TIMELOCK_ADMIN_ROLE);

// Grant CIRCUIT_BREAKER_ROLE to the specified circuit breakers
for (uint256 i = 0; i < circuitBreakers.length; i++) {
_setupRole(CIRCUIT_BREAKER_ROLE, circuitBreakers[i]);
}
}

function pause(address target) external onlyRole(CIRCUIT_BREAKER_ROLE) {
require(target != address(0), "CustomTimelockController: invalid target");
IPausable(target).pause();
}

}

0 comments on commit 3cb88fb

Please sign in to comment.