MyGovernor.sol 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. import {IGovernor, Governor} from "../../../governance/Governor.sol";
  4. import {GovernorCompatibilityBravo} from "../../../governance/compatibility/GovernorCompatibilityBravo.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. GovernorCompatibilityBravo,
  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(
  33. uint256 proposalId
  34. ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) {
  35. return super.state(proposalId);
  36. }
  37. function propose(
  38. address[] memory targets,
  39. uint256[] memory values,
  40. bytes[] memory calldatas,
  41. string memory description
  42. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  43. return super.propose(targets, values, calldatas, description);
  44. }
  45. function cancel(
  46. address[] memory targets,
  47. uint256[] memory values,
  48. bytes[] memory calldatas,
  49. bytes32 descriptionHash
  50. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  51. return super.cancel(targets, values, calldatas, descriptionHash);
  52. }
  53. function _execute(
  54. uint256 proposalId,
  55. address[] memory targets,
  56. uint256[] memory values,
  57. bytes[] memory calldatas,
  58. bytes32 descriptionHash
  59. ) internal override(Governor, GovernorTimelockControl) {
  60. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  61. }
  62. function _cancel(
  63. address[] memory targets,
  64. uint256[] memory values,
  65. bytes[] memory calldatas,
  66. bytes32 descriptionHash
  67. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  68. return super._cancel(targets, values, calldatas, descriptionHash);
  69. }
  70. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  71. return super._executor();
  72. }
  73. function supportsInterface(
  74. bytes4 interfaceId
  75. ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) {
  76. return super.supportsInterface(interfaceId);
  77. }
  78. }