MyGovernor3.sol 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 MyGovernor 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(uint256 proposalId) public override(Governor, GovernorCompatibilityBravo, IGovernor) {
  48. super.cancel(proposalId);
  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. }