generated from ScopeLift/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assemble the v1 Governor w/ constructor test
- Loading branch information
Showing
4 changed files
with
143 additions
and
9 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
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 |
---|---|---|
@@ -1,4 +1,121 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.22; | ||
|
||
contract GuineaPigGovernor {} | ||
import { | ||
Governor, GovernorCountingFractional | ||
} from "flexible-voting/GovernorCountingFractional.sol"; | ||
import {IGovernor} from "@openzeppelin/contracts/governance/IGovernor.sol"; | ||
import {GovernorVotes} from "@openzeppelin/governance/extensions/GovernorVotes.sol"; | ||
import {GovernorTimelockControl} from | ||
"@openzeppelin/governance/extensions/GovernorTimelockControl.sol"; | ||
import {GovernorSettings} from "@openzeppelin/governance/extensions/GovernorSettings.sol"; | ||
import {IVotes} from "@openzeppelin/governance/utils/IVotes.sol"; | ||
// TODO: convert to interface? | ||
import {TimelockController} from "@openzeppelin/governance/TimelockController.sol"; | ||
|
||
contract GuineaPigGovernor is | ||
GovernorCountingFractional, | ||
GovernorVotes, | ||
GovernorTimelockControl, | ||
GovernorSettings | ||
{ | ||
/// @notice Human readable name of this Governor. | ||
string private constant GOVERNOR_NAME = "Guinea Pig DAO Governor v1"; | ||
|
||
constructor( | ||
IVotes _token, | ||
uint256 _initialVotingDelay, | ||
uint256 _initialVotingPeriod, | ||
uint256 _initialProposalThreshold, | ||
TimelockController _timelock | ||
) | ||
GovernorVotes(_token) | ||
GovernorSettings(_initialVotingDelay, _initialVotingPeriod, _initialProposalThreshold) | ||
GovernorTimelockControl(_timelock) | ||
Governor(GOVERNOR_NAME) | ||
{} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
virtual | ||
override(Governor, GovernorTimelockControl) | ||
returns (bool) | ||
{ | ||
return GovernorTimelockControl.supportsInterface(interfaceId); | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function castVoteWithReasonAndParamsBySig( | ||
uint256 proposalId, | ||
uint8 support, | ||
string calldata reason, | ||
bytes memory params, | ||
uint8 v, | ||
bytes32 r, | ||
bytes32 s | ||
) public override(Governor, GovernorCountingFractional, IGovernor) returns (uint256) { | ||
return GovernorCountingFractional.castVoteWithReasonAndParamsBySig( | ||
proposalId, support, reason, params, v, r, s | ||
); | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function proposalThreshold() | ||
public | ||
view | ||
virtual | ||
override(Governor, GovernorSettings) | ||
returns (uint256) | ||
{ | ||
return GovernorSettings.proposalThreshold(); | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function state(uint256 proposalId) | ||
public | ||
view | ||
virtual | ||
override(Governor, GovernorTimelockControl) | ||
returns (ProposalState) | ||
{ | ||
return GovernorTimelockControl.state(proposalId); | ||
} | ||
|
||
function quorum(uint256) public pure override returns (uint256) { | ||
return 1; // TODO: determine quorum rules | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function _execute( | ||
uint256 proposalId, | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) internal virtual override(Governor, GovernorTimelockControl) { | ||
return GovernorTimelockControl._execute(proposalId, targets, values, calldatas, descriptionHash); | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function _executor() | ||
internal | ||
view | ||
virtual | ||
override(Governor, GovernorTimelockControl) | ||
returns (address) | ||
{ | ||
return GovernorTimelockControl._executor(); | ||
} | ||
|
||
/// @dev We override this function to resolve ambiguity between inherited contracts. | ||
function _cancel( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) internal virtual override(Governor, GovernorTimelockControl) returns (uint256) { | ||
return GovernorTimelockControl._cancel(targets, values, calldatas, descriptionHash); | ||
} | ||
} |
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
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