MyGovernor3.sol 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../governance/Governor.sol";
  4. import "../../governance/compatibility/GovernorCompatibilityBravo.sol";
  5. import "../../governance/extensions/GovernorVotes.sol";
  6. import "../../governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import "../../governance/extensions/GovernorTimelockControl.sol";
  8. contract MyGovernor is
  9. Governor,
  10. GovernorTimelockControl,
  11. GovernorCompatibilityBravo,
  12. GovernorVotes,
  13. GovernorVotesQuorumFraction
  14. {
  15. constructor(
  16. IVotes _token,
  17. TimelockController _timelock
  18. ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {}
  19. function votingDelay() public pure override returns (uint256) {
  20. return 1; // 1 block
  21. }
  22. function votingPeriod() public pure override returns (uint256) {
  23. return 45818; // 1 week
  24. }
  25. function proposalThreshold() public pure override returns (uint256) {
  26. return 1000e18;
  27. }
  28. // The following functions are overrides required by Solidity.
  29. function quorum(
  30. uint256 blockNumber
  31. ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) {
  32. return super.quorum(blockNumber);
  33. }
  34. function state(
  35. uint256 proposalId
  36. ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) {
  37. return super.state(proposalId);
  38. }
  39. function propose(
  40. address[] memory targets,
  41. uint256[] memory values,
  42. bytes[] memory calldatas,
  43. string memory description
  44. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  45. return super.propose(targets, values, calldatas, description);
  46. }
  47. function _execute(
  48. uint256 proposalId,
  49. address[] memory targets,
  50. uint256[] memory values,
  51. bytes[] memory calldatas,
  52. bytes32 descriptionHash
  53. ) internal override(Governor, GovernorTimelockControl) {
  54. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  55. }
  56. function _cancel(
  57. address[] memory targets,
  58. uint256[] memory values,
  59. bytes[] memory calldatas,
  60. bytes32 descriptionHash
  61. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  62. return super._cancel(targets, values, calldatas, descriptionHash);
  63. }
  64. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  65. return super._executor();
  66. }
  67. function supportsInterface(
  68. bytes4 interfaceId
  69. ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) {
  70. return super.supportsInterface(interfaceId);
  71. }
  72. }