MyGovernor.sol 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 _queueOperations(
  36. uint256 proposalId,
  37. address[] memory targets,
  38. uint256[] memory values,
  39. bytes[] memory calldatas,
  40. bytes32 descriptionHash
  41. ) internal override(Governor, GovernorTimelockControl) returns (uint48) {
  42. return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
  43. }
  44. function _executeOperations(
  45. uint256 proposalId,
  46. address[] memory targets,
  47. uint256[] memory values,
  48. bytes[] memory calldatas,
  49. bytes32 descriptionHash
  50. ) internal override(Governor, GovernorTimelockControl) {
  51. super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
  52. }
  53. function _cancel(
  54. address[] memory targets,
  55. uint256[] memory values,
  56. bytes[] memory calldatas,
  57. bytes32 descriptionHash
  58. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  59. return super._cancel(targets, values, calldatas, descriptionHash);
  60. }
  61. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  62. return super._executor();
  63. }
  64. }