MyGovernor2.sol 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../governance/Governor.sol";
  4. import "../../governance/extensions/GovernorProposalThreshold.sol";
  5. import "../../governance/extensions/GovernorCountingSimple.sol";
  6. import "../../governance/extensions/GovernorVotes.sol";
  7. import "../../governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../../governance/extensions/GovernorTimelockControl.sol";
  9. contract MyGovernor2 is
  10. Governor,
  11. GovernorTimelockControl,
  12. GovernorProposalThreshold,
  13. GovernorVotes,
  14. GovernorVotesQuorumFraction,
  15. GovernorCountingSimple
  16. {
  17. constructor(
  18. IVotes _token,
  19. TimelockController _timelock
  20. ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {}
  21. function votingDelay() public pure override returns (uint256) {
  22. return 1; // 1 block
  23. }
  24. function votingPeriod() public pure override returns (uint256) {
  25. return 45818; // 1 week
  26. }
  27. function proposalThreshold() public pure override returns (uint256) {
  28. return 1000e18;
  29. }
  30. // The following functions are overrides required by Solidity.
  31. function quorum(
  32. uint256 blockNumber
  33. ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) {
  34. return super.quorum(blockNumber);
  35. }
  36. function state(uint256 proposalId) public view override(Governor, 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, GovernorProposalThreshold, IGovernor) returns (uint256) {
  45. return super.propose(targets, values, calldatas, description);
  46. }
  47. function _execute(
  48. uint256 proposalId,
  49. address[] memory targets,
  50. uint256[] memory values,
  51. bytes[] memory calldatas,
  52. bytes32 descriptionHash
  53. ) internal override(Governor, GovernorTimelockControl) {
  54. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  55. }
  56. function _cancel(
  57. address[] memory targets,
  58. uint256[] memory values,
  59. bytes[] memory calldatas,
  60. bytes32 descriptionHash
  61. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  62. return super._cancel(targets, values, calldatas, descriptionHash);
  63. }
  64. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  65. return super._executor();
  66. }
  67. function supportsInterface(
  68. bytes4 interfaceId
  69. ) public view override(Governor, GovernorTimelockControl) returns (bool) {
  70. return super.supportsInterface(interfaceId);
  71. }
  72. }