@@ -14,7 +14,10 @@ import { IGovernor } from "./IGovernor.sol";
1414
1515/// @title Governor
1616/// @author Rohan Kulkarni
17- /// @notice DAO proposal manager and transaction scheduler
17+ /// @notice A DAO's proposal manager and transaction scheduler
18+ /// Modified from:
19+ /// - OpenZeppelin Contracts v4.7.3 (governance/extensions/GovernorTimelockControl.sol)
20+ /// - NounsDAOLogicV1.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.
1821contract Governor is IGovernor , UUPS , Ownable , EIP712 , GovernorStorageV1 {
1922 /// ///
2023 /// CONSTANTS ///
@@ -34,7 +37,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
3437 /// CONSTRUCTOR ///
3538 /// ///
3639
37- /// @param _manager The address of the contract upgrade manager
40+ /// @param _manager The contract upgrade manager address
3841 constructor (address _manager ) payable initializer {
3942 manager = IManager (_manager);
4043 }
@@ -76,10 +79,10 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
7679 settings.proposalThresholdBps = SafeCast.toUint16 (_proposalThresholdBps);
7780 settings.quorumThresholdBps = SafeCast.toUint16 (_quorumThresholdBps);
7881
79- // Initialize support for off-chain voting
82+ // Initialize EIP-712 support
8083 __EIP712_init (string .concat (settings.token.symbol (), " GOV " ), "1 " );
8184
82- // Grant ownership of the contract to the treasury
85+ // Grant ownership to the treasury
8386 __Ownable_init (_treasury);
8487 }
8588
@@ -135,7 +138,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
135138 if (numTargets != _values.length ) revert PROPOSAL_LENGTH_MISMATCH ();
136139 if (numTargets != _calldatas.length ) revert PROPOSAL_LENGTH_MISMATCH ();
137140
138- // Compute the hash of the description
141+ // Compute the description hash
139142 bytes32 descriptionHash = keccak256 (bytes (_description));
140143
141144 // Compute the proposal id
@@ -144,7 +147,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
144147 // Get the pointer to store the proposal
145148 Proposal storage proposal = proposals[proposalId];
146149
147- // Ensure a proposal with the same id doesn't already exist
150+ // Ensure the proposal doesn't already exist
148151 if (proposal.voteStart != 0 ) revert PROPOSAL_EXISTS (proposalId);
149152
150153 // Used to store the snapshot and deadline
@@ -161,7 +164,6 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
161164 // Store the proposal data
162165 proposal.voteStart = uint32 (snapshot);
163166 proposal.voteEnd = uint32 (deadline);
164-
165167 proposal.proposalThreshold = uint32 (currentProposalThreshold);
166168 proposal.quorumVotes = uint32 (quorum ());
167169 proposal.proposer = msg .sender ;
@@ -218,9 +220,9 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
218220 // Used to store the signed digest
219221 bytes32 digest;
220222
221- // Cannot realistically overflow voter nonces
223+ // Cannot realistically overflow
222224 unchecked {
223- // Compute the encoded message
225+ // Compute the message
224226 digest = keccak256 (
225227 abi.encodePacked (
226228 "\x19\x01 " ,
@@ -230,11 +232,11 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
230232 );
231233 }
232234
233- // Recover the signer of the message
235+ // Recover the message signer
234236 address recoveredAddress = ecrecover (digest, _v, _r, _s);
235237
236238 // Ensure the recovered signer is the given voter
237- if (recoveredAddress == address (0 ) || recoveredAddress != _voter) revert INVALID_SIGNER ();
239+ if (recoveredAddress == address (0 ) || recoveredAddress != _voter) revert INVALID_SIGNATURE ();
238240
239241 return _castVote (_proposalId, _voter, _support, "" );
240242 }
@@ -249,7 +251,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
249251 uint256 _support ,
250252 string memory _reason
251253 ) internal returns (uint256 ) {
252- // Ensure voting for the proposal is active
254+ // Ensure voting is active
253255 if (state (_proposalId) != ProposalState.Active) revert VOTING_NOT_STARTED ();
254256
255257 // Ensure the voter hasn't already voted
@@ -304,8 +306,8 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
304306 // Ensure the proposal has succeeded
305307 if (state (_proposalId) != ProposalState.Succeeded) revert PROPOSAL_UNSUCCESSFUL ();
306308
307- // Schedule the proposal for execution and get the timestamp that it'll be valid to execute
308- eta = settings.treasury.schedule (_proposalId);
309+ // Schedule the proposal for execution
310+ eta = settings.treasury.queue (_proposalId);
309311
310312 emit ProposalQueued (_proposalId, eta);
311313 }
@@ -320,9 +322,9 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
320322 /// @param _calldatas The calldata of each call
321323 /// @param _descriptionHash The hash of the description
322324 function execute (
323- address [] memory _targets ,
324- uint256 [] memory _values ,
325- bytes [] memory _calldatas ,
325+ address [] calldata _targets ,
326+ uint256 [] calldata _values ,
327+ bytes [] calldata _calldatas ,
326328 bytes32 _descriptionHash
327329 ) external payable returns (bytes32 ) {
328330 // Get the proposal id
@@ -334,7 +336,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
334336 // Mark the proposal as executed
335337 proposals[proposalId].executed = true ;
336338
337- // Call the treasury to execute the proposal
339+ // Execute the proposal
338340 settings.treasury.execute { value: msg .value }(_targets, _values, _calldatas, _descriptionHash);
339341
340342 emit ProposalExecuted (proposalId);
@@ -518,12 +520,12 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
518520 /// GOVERNOR SETTINGS ///
519521 /// ///
520522
521- /// @notice The minimum basis points of the total token supply required to submit a proposal
523+ /// @notice The basis points of the token supply required to create a proposal
522524 function proposalThresholdBps () external view returns (uint256 ) {
523525 return settings.proposalThresholdBps;
524526 }
525527
526- /// @notice The minimum basis points of the total token supply required to reach quorum
528+ /// @notice The basis points of the token supply required to reach quorum
527529 function quorumThresholdBps () external view returns (uint256 ) {
528530 return settings.quorumThresholdBps;
529531 }
@@ -548,7 +550,7 @@ contract Governor is IGovernor, UUPS, Ownable, EIP712, GovernorStorageV1 {
548550 return address (settings.token);
549551 }
550552
551- /// @notice The address of the transaction executor and treasury
553+ /// @notice The address of the treasury
552554 function treasury () external view returns (address ) {
553555 return address (settings.treasury);
554556 }
0 commit comments