MyGovernor3.sol 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  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 MyGovernor3 is
  9. Governor,
  10. GovernorTimelockControl,
  11. GovernorCompatibilityBravo,
  12. GovernorVotes,
  13. GovernorVotesQuorumFraction
  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 1; // 1 block
  21. }
  22. function votingPeriod() public pure override returns (uint256) {
  23. return 45818; // 1 week
  24. }
  25. function proposalThreshold() public pure override returns (uint256) {
  26. return 1000e18;
  27. }
  28. // The following functions are overrides required by Solidity.
  29. function quorum(
  30. uint256 blockNumber
  31. ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) {
  32. return super.quorum(blockNumber);
  33. }
  34. function state(
  35. uint256 proposalId
  36. ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) {
  37. return super.state(proposalId);
  38. }
  39. function propose(
  40. address[] memory targets,
  41. uint256[] memory values,
  42. bytes[] memory calldatas,
  43. string memory description
  44. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  45. return super.propose(targets, values, calldatas, description);
  46. }
  47. function cancel(
  48. address[] memory targets,
  49. uint256[] memory values,
  50. bytes[] memory calldatas,
  51. bytes32 descriptionHash
  52. ) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
  53. return super.cancel(targets, values, calldatas, descriptionHash);
  54. }
  55. function _execute(
  56. uint256 proposalId,
  57. address[] memory targets,
  58. uint256[] memory values,
  59. bytes[] memory calldatas,
  60. bytes32 descriptionHash
  61. ) internal override(Governor, GovernorTimelockControl) {
  62. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  63. }
  64. function _cancel(
  65. address[] memory targets,
  66. uint256[] memory values,
  67. bytes[] memory calldatas,
  68. bytes32 descriptionHash
  69. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  70. return super._cancel(targets, values, calldatas, descriptionHash);
  71. }
  72. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  73. return super._executor();
  74. }
  75. function supportsInterface(
  76. bytes4 interfaceId
  77. ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) {
  78. return super.supportsInterface(interfaceId);
  79. }
  80. }