MyGovernor3Upgradeable.sol 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../governance/GovernorUpgradeable.sol";
  4. import "../../governance/compatibility/GovernorCompatibilityBravoUpgradeable.sol";
  5. import "../../governance/extensions/GovernorVotesUpgradeable.sol";
  6. import "../../governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol";
  7. import "../../governance/extensions/GovernorTimelockControlUpgradeable.sol";
  8. import "../../proxy/utils/Initializable.sol";
  9. contract MyGovernorUpgradeable is
  10. Initializable, GovernorUpgradeable,
  11. GovernorTimelockControlUpgradeable,
  12. GovernorCompatibilityBravoUpgradeable,
  13. GovernorVotesUpgradeable,
  14. GovernorVotesQuorumFractionUpgradeable
  15. {
  16. function __MyGovernor_init(IVotesUpgradeable _token, TimelockControllerUpgradeable _timelock) internal onlyInitializing {
  17. __EIP712_init_unchained("MyGovernor", version());
  18. __Governor_init_unchained("MyGovernor");
  19. __GovernorTimelockControl_init_unchained(_timelock);
  20. __GovernorVotes_init_unchained(_token);
  21. __GovernorVotesQuorumFraction_init_unchained(4);
  22. }
  23. function __MyGovernor_init_unchained(IVotesUpgradeable, TimelockControllerUpgradeable) internal onlyInitializing {}
  24. function votingDelay() public pure override returns (uint256) {
  25. return 1; // 1 block
  26. }
  27. function votingPeriod() public pure override returns (uint256) {
  28. return 45818; // 1 week
  29. }
  30. function proposalThreshold() public pure override returns (uint256) {
  31. return 1000e18;
  32. }
  33. // The following functions are overrides required by Solidity.
  34. function quorum(uint256 blockNumber)
  35. public
  36. view
  37. override(IGovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
  38. returns (uint256)
  39. {
  40. return super.quorum(blockNumber);
  41. }
  42. function getVotes(address account, uint256 blockNumber)
  43. public
  44. view
  45. override(IGovernorUpgradeable, GovernorVotesUpgradeable)
  46. returns (uint256)
  47. {
  48. return super.getVotes(account, blockNumber);
  49. }
  50. function state(uint256 proposalId)
  51. public
  52. view
  53. override(GovernorUpgradeable, IGovernorUpgradeable, GovernorTimelockControlUpgradeable)
  54. returns (ProposalState)
  55. {
  56. return super.state(proposalId);
  57. }
  58. function propose(
  59. address[] memory targets,
  60. uint256[] memory values,
  61. bytes[] memory calldatas,
  62. string memory description
  63. ) public override(GovernorUpgradeable, GovernorCompatibilityBravoUpgradeable, IGovernorUpgradeable) returns (uint256) {
  64. return super.propose(targets, values, calldatas, description);
  65. }
  66. function _execute(
  67. uint256 proposalId,
  68. address[] memory targets,
  69. uint256[] memory values,
  70. bytes[] memory calldatas,
  71. bytes32 descriptionHash
  72. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) {
  73. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  74. }
  75. function _cancel(
  76. address[] memory targets,
  77. uint256[] memory values,
  78. bytes[] memory calldatas,
  79. bytes32 descriptionHash
  80. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint256) {
  81. return super._cancel(targets, values, calldatas, descriptionHash);
  82. }
  83. function _executor() internal view override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (address) {
  84. return super._executor();
  85. }
  86. function supportsInterface(bytes4 interfaceId)
  87. public
  88. view
  89. override(GovernorUpgradeable, IERC165Upgradeable, GovernorTimelockControlUpgradeable)
  90. returns (bool)
  91. {
  92. return super.supportsInterface(interfaceId);
  93. }
  94. /**
  95. * This empty reserved space is put in place to allow future versions to add new
  96. * variables without shifting down storage in the inheritance chain.
  97. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  98. */
  99. uint256[50] private __gap;
  100. }