MyGovernor2Upgradeable.sol 4.0 KB

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