generated from PaulRBerg/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTimelock.sol
More file actions
42 lines (36 loc) · 1.63 KB
/
Timelock.sol
File metadata and controls
42 lines (36 loc) · 1.63 KB
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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import { TimelockController } from "@openzeppelin/contracts/governance/TimelockController.sol";
/// @title Timelock
/// @notice A timelock contract with an immutable min delay
/// @author WalletConnect
contract Timelock is TimelockController {
/// @notice Thrown when an invalid delay is provided in the constructor
error InvalidDelay();
/// @notice Thrown when an invalid canceller is provided in the constructor
error InvalidCanceller();
/// @notice Thrown when an invalid proposer is provided in the constructor
error InvalidProposer();
/// @notice Thrown when an invalid executor is provided in the constructor
error InvalidExecutor();
/// @notice Initializes the Timelock contract
/// @dev Sets up the timelock with a specified delay and initial roles
/// @param delay The timelock delay in seconds (must be at least 3 days)
/// @param proposers Array of addresses that can propose new operations
/// @param executors Array of addresses that can execute operations
/// @param canceller Address of the canceller role
constructor(
uint256 delay,
address[] memory proposers,
address[] memory executors,
address canceller
)
TimelockController(delay, proposers, executors, address(0))
{
if (delay < 3 days || delay > 7 days) revert InvalidDelay();
if (canceller == address(0)) revert InvalidCanceller();
if (proposers.length == 0) revert InvalidProposer();
if (executors.length == 0) revert InvalidExecutor();
_grantRole(CANCELLER_ROLE, canceller);
}
}