-
Notifications
You must be signed in to change notification settings - Fork 324
/
PolygonZkEVMTimelock.sol
47 lines (43 loc) · 1.79 KB
/
PolygonZkEVMTimelock.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "@openzeppelin/contracts/governance/TimelockController.sol";
import "./PolygonZkEVM.sol";
/**
* @dev Contract module which acts as a timelocked controller.
* This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied.
* If emergency mode of the zkevm contract system is active, this timelock have no delay.
*/
contract PolygonZkEVMTimelock is TimelockController {
// Polygon ZK-EVM address. Will be used to check if it's on emergency state.
PolygonZkEVM public immutable polygonZkEVM;
/**
* @notice Constructor of timelock
* @param minDelay initial minimum delay for operations
* @param proposers accounts to be granted proposer and canceller roles
* @param executors accounts to be granted executor role
* @param admin optional account to be granted admin role; disable with zero address
* @param _polygonZkEVM polygonZkEVM address
**/
constructor(
uint256 minDelay,
address[] memory proposers,
address[] memory executors,
address admin,
PolygonZkEVM _polygonZkEVM
) TimelockController(minDelay, proposers, executors, admin) {
polygonZkEVM = _polygonZkEVM;
}
/**
* @dev Returns the minimum delay for an operation to become valid.
*
* This value can be changed by executing an operation that calls `updateDelay`.
* If Polygon ZK-EVM is on emergency state the minDelay will be 0 instead.
*/
function getMinDelay() public view override returns (uint256 duration) {
if (address(polygonZkEVM) != address(0) && polygonZkEVM.isEmergencyState()) {
return 0;
} else {
return super.getMinDelay();
}
}
}