MyGovernor.sol 2.9 KB

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