MyGovernor3.sol 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 state(uint256 proposalId)
  40. public
  41. view
  42. override(Governor, IGovernor, GovernorTimelockControl)
  43. returns (ProposalState)
  44. {
  45. return super.state(proposalId);
  46. }
  47. function propose(
  48. address[] memory targets,
  49. uint256[] memory values,
  50. bytes[] memory calldatas,
  51. string memory description
  52. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  53. return super.propose(targets, values, calldatas, description);
  54. }
  55. function _execute(
  56. uint256 proposalId,
  57. address[] memory targets,
  58. uint256[] memory values,
  59. bytes[] memory calldatas,
  60. bytes32 descriptionHash
  61. ) internal override(Governor, GovernorTimelockControl) {
  62. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  63. }
  64. function _cancel(
  65. address[] memory targets,
  66. uint256[] memory values,
  67. bytes[] memory calldatas,
  68. bytes32 descriptionHash
  69. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  70. return super._cancel(targets, values, calldatas, descriptionHash);
  71. }
  72. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  73. return super._executor();
  74. }
  75. function supportsInterface(bytes4 interfaceId)
  76. public
  77. view
  78. override(Governor, IERC165, GovernorTimelockControl)
  79. returns (bool)
  80. {
  81. return super.supportsInterface(interfaceId);
  82. }
  83. }