MyGovernor2.sol 2.8 KB

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