2
2
pragma solidity 0.8.26 ;
3
3
4
4
import {Address} from "@openzeppelin/contracts/utils/Address.sol " ;
5
+
6
+ import {Durations} from "../types/Duration.sol " ;
7
+ import {Timestamp} from "../types/Timestamp.sol " ;
8
+
9
+ import {IEmergencyProtectedTimelock} from "../interfaces/IEmergencyProtectedTimelock.sol " ;
10
+
5
11
import {HashConsensus} from "./HashConsensus.sol " ;
6
12
import {ProposalsList} from "./ProposalsList.sol " ;
7
- import {ITimelock} from "../interfaces/ITimelock.sol " ;
8
- import {Timestamp} from "../types/Timestamp.sol " ;
9
- import {Durations} from "../types/Duration.sol " ;
10
13
11
14
enum ProposalType {
12
15
EmergencyExecute,
@@ -17,14 +20,16 @@ enum ProposalType {
17
20
/// @notice This contract allows a committee to vote on and execute emergency proposals
18
21
/// @dev Inherits from HashConsensus for voting mechanisms and ProposalsList for proposal management
19
22
contract EmergencyExecutionCommittee is HashConsensus , ProposalsList {
23
+ error ProposalDoesNotExist (uint256 proposalId );
24
+
20
25
address public immutable EMERGENCY_PROTECTED_TIMELOCK;
21
26
22
27
constructor (
23
28
address owner ,
24
29
address [] memory committeeMembers ,
25
30
uint256 executionQuorum ,
26
31
address emergencyProtectedTimelock
27
- ) HashConsensus (owner, Durations.from ( 0 ) ) {
32
+ ) HashConsensus (owner, Durations.ZERO ) {
28
33
EMERGENCY_PROTECTED_TIMELOCK = emergencyProtectedTimelock;
29
34
30
35
_addMembers (committeeMembers, executionQuorum);
@@ -37,11 +42,12 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList {
37
42
/// @notice Votes on an emergency execution proposal
38
43
/// @dev Only callable by committee members
39
44
/// @param proposalId The ID of the proposal to vote on
40
- /// @param _supports Indicates whether the member supports the proposal execution
41
- function voteEmergencyExecute (uint256 proposalId , bool _supports ) public {
45
+ /// @param _support Indicates whether the member supports the proposal execution
46
+ function voteEmergencyExecute (uint256 proposalId , bool _support ) public {
42
47
_checkCallerIsMember ();
48
+ _checkProposalExists (proposalId);
43
49
(bytes memory proposalData , bytes32 key ) = _encodeEmergencyExecute (proposalId);
44
- _vote (key, _supports );
50
+ _vote (key, _support );
45
51
_pushProposal (key, uint256 (ProposalType.EmergencyExecute), proposalData);
46
52
}
47
53
@@ -66,10 +72,22 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList {
66
72
(, bytes32 key ) = _encodeEmergencyExecute (proposalId);
67
73
_markUsed (key);
68
74
Address.functionCall (
69
- EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector (ITimelock.emergencyExecute.selector , proposalId)
75
+ EMERGENCY_PROTECTED_TIMELOCK,
76
+ abi.encodeWithSelector (IEmergencyProtectedTimelock.emergencyExecute.selector , proposalId)
70
77
);
71
78
}
72
79
80
+ /// @notice Checks if a proposal exists
81
+ /// @param proposalId The ID of the proposal to check
82
+ function _checkProposalExists (uint256 proposalId ) internal view {
83
+ if (
84
+ proposalId == 0
85
+ || proposalId > IEmergencyProtectedTimelock (EMERGENCY_PROTECTED_TIMELOCK).getProposalsCount ()
86
+ ) {
87
+ revert ProposalDoesNotExist (proposalId);
88
+ }
89
+ }
90
+
73
91
/// @dev Encodes the proposal data and generates the proposal key for an emergency execution
74
92
/// @param proposalId The ID of the proposal to encode
75
93
/// @return proposalData The encoded proposal data
@@ -114,7 +132,9 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList {
114
132
function executeEmergencyReset () external {
115
133
bytes32 proposalKey = _encodeEmergencyResetProposalKey ();
116
134
_markUsed (proposalKey);
117
- Address.functionCall (EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector (ITimelock.emergencyReset.selector ));
135
+ Address.functionCall (
136
+ EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector (IEmergencyProtectedTimelock.emergencyReset.selector )
137
+ );
118
138
}
119
139
120
140
/// @notice Encodes the proposal key for an emergency reset
0 commit comments