MyGovernor1.sol 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../governance/Governor.sol";
  4. import "../../governance/extensions/GovernorCountingSimple.sol";
  5. import "../../governance/extensions/GovernorVotes.sol";
  6. import "../../governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import "../../governance/extensions/GovernorTimelockControl.sol";
  8. contract MyGovernor1 is
  9. Governor,
  10. GovernorTimelockControl,
  11. GovernorVotes,
  12. GovernorVotesQuorumFraction,
  13. GovernorCountingSimple
  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. // The following functions are overrides required by Solidity.
  26. function quorum(
  27. uint256 blockNumber
  28. ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) {
  29. return super.quorum(blockNumber);
  30. }
  31. function state(uint256 proposalId) public view override(Governor, 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, IGovernor) returns (uint256) {
  40. return super.propose(targets, values, calldatas, description);
  41. }
  42. function _execute(
  43. uint256 proposalId,
  44. address[] memory targets,
  45. uint256[] memory values,
  46. bytes[] memory calldatas,
  47. bytes32 descriptionHash
  48. ) internal override(Governor, GovernorTimelockControl) {
  49. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  50. }
  51. function _cancel(
  52. address[] memory targets,
  53. uint256[] memory values,
  54. bytes[] memory calldatas,
  55. bytes32 descriptionHash
  56. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  57. return super._cancel(targets, values, calldatas, descriptionHash);
  58. }
  59. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  60. return super._executor();
  61. }
  62. function supportsInterface(
  63. bytes4 interfaceId
  64. ) public view override(Governor, GovernorTimelockControl) returns (bool) {
  65. return super.supportsInterface(interfaceId);
  66. }
  67. }