MyGovernor.sol 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {IGovernor, Governor} from "../../../governance/Governor.sol";
  4. import {GovernorCountingSimple} from "../../../governance/extensions/GovernorCountingSimple.sol";
  5. import {GovernorVotes} from "../../../governance/extensions/GovernorVotes.sol";
  6. import {GovernorVotesQuorumFraction} from "../../../governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import {GovernorTimelockControl} from "../../../governance/extensions/GovernorTimelockControl.sol";
  8. import {TimelockController} from "../../../governance/TimelockController.sol";
  9. import {IVotes} from "../../../governance/utils/IVotes.sol";
  10. import {IERC165} from "../../../interfaces/IERC165.sol";
  11. contract MyGovernor is
  12. Governor,
  13. GovernorCountingSimple,
  14. GovernorVotes,
  15. GovernorVotesQuorumFraction,
  16. GovernorTimelockControl
  17. {
  18. constructor(
  19. IVotes _token,
  20. TimelockController _timelock
  21. ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {}
  22. function votingDelay() public pure override returns (uint256) {
  23. return 7200; // 1 day
  24. }
  25. function votingPeriod() public pure override returns (uint256) {
  26. return 50400; // 1 week
  27. }
  28. function proposalThreshold() public pure override returns (uint256) {
  29. return 0;
  30. }
  31. // The functions below are overrides required by Solidity.
  32. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  33. return super.state(proposalId);
  34. }
  35. function proposalNeedsQueuing(
  36. uint256 proposalId
  37. ) public view virtual override(Governor, GovernorTimelockControl) returns (bool) {
  38. return super.proposalNeedsQueuing(proposalId);
  39. }
  40. function _queueOperations(
  41. uint256 proposalId,
  42. address[] memory targets,
  43. uint256[] memory values,
  44. bytes[] memory calldatas,
  45. bytes32 descriptionHash
  46. ) internal override(Governor, GovernorTimelockControl) returns (uint48) {
  47. return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
  48. }
  49. function _executeOperations(
  50. uint256 proposalId,
  51. address[] memory targets,
  52. uint256[] memory values,
  53. bytes[] memory calldatas,
  54. bytes32 descriptionHash
  55. ) internal override(Governor, GovernorTimelockControl) {
  56. super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
  57. }
  58. function _cancel(
  59. address[] memory targets,
  60. uint256[] memory values,
  61. bytes[] memory calldatas,
  62. bytes32 descriptionHash
  63. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  64. return super._cancel(targets, values, calldatas, descriptionHash);
  65. }
  66. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  67. return super._executor();
  68. }
  69. }