MyGovernor.sol 2.9 KB

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