-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add circuit breaker role to customtimelockcontroller
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / Foundry project
|
||
|
||
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(); | ||
} | ||
|
||
} |