MyGovernor3.sol 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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(IVotes _token, TimelockController _timelock)
  16. Governor("MyGovernor")
  17. GovernorVotes(_token)
  18. GovernorVotesQuorumFraction(4)
  19. GovernorTimelockControl(_timelock)
  20. {}
  21. function votingDelay() public pure override returns (uint256) {
  22. return 1; // 1 block
  23. }
  24. function votingPeriod() public pure override returns (uint256) {
  25. return 45818; // 1 week
  26. }
  27. function proposalThreshold() public pure override returns (uint256) {
  28. return 1000e18;
  29. }
  30. // The following functions are overrides required by Solidity.
  31. function quorum(uint256 blockNumber)
  32. public
  33. view
  34. override(IGovernor, GovernorVotesQuorumFraction)
  35. returns (uint256)
  36. {
  37. return super.quorum(blockNumber);
  38. }
  39. function getVotes(address account, uint256 blockNumber)
  40. public
  41. view
  42. override(IGovernor, GovernorVotes)
  43. returns (uint256)
  44. {
  45. return super.getVotes(account, blockNumber);
  46. }
  47. function state(uint256 proposalId)
  48. public
  49. view
  50. override(Governor, IGovernor, GovernorTimelockControl)
  51. returns (ProposalState)
  52. {
  53. return super.state(proposalId);
  54. }
  55. function propose(
  56. address[] memory targets,
  57. uint256[] memory values,
  58. bytes[] memory calldatas,
  59. string memory description
  60. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  61. return super.propose(targets, values, calldatas, description);
  62. }
  63. function _execute(
  64. uint256 proposalId,
  65. address[] memory targets,
  66. uint256[] memory values,
  67. bytes[] memory calldatas,
  68. bytes32 descriptionHash
  69. ) internal override(Governor, GovernorTimelockControl) {
  70. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  71. }
  72. function _cancel(
  73. address[] memory targets,
  74. uint256[] memory values,
  75. bytes[] memory calldatas,
  76. bytes32 descriptionHash
  77. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  78. return super._cancel(targets, values, calldatas, descriptionHash);
  79. }
  80. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  81. return super._executor();
  82. }
  83. function supportsInterface(bytes4 interfaceId)
  84. public
  85. view
  86. override(Governor, IERC165, GovernorTimelockControl)
  87. returns (bool)
  88. {
  89. return super.supportsInterface(interfaceId);
  90. }
  91. }