MyGovernor2Upgradeable.sol 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. __Context_init_unchained();
  20. __ERC165_init_unchained();
  21. __EIP712_init_unchained("MyGovernor", version());
  22. __IGovernor_init_unchained();
  23. __IGovernorTimelock_init_unchained();
  24. __Governor_init_unchained("MyGovernor");
  25. __GovernorTimelockControl_init_unchained(_timelock);
  26. __GovernorProposalThreshold_init_unchained();
  27. __GovernorVotes_init_unchained(_token);
  28. __GovernorVotesQuorumFraction_init_unchained(4);
  29. __GovernorCountingSimple_init_unchained();
  30. __MyGovernor2_init_unchained(_token, _timelock);
  31. }
  32. function __MyGovernor2_init_unchained(IVotesUpgradeable, TimelockControllerUpgradeable) internal onlyInitializing {}
  33. function votingDelay() public pure override returns (uint256) {
  34. return 1; // 1 block
  35. }
  36. function votingPeriod() public pure override returns (uint256) {
  37. return 45818; // 1 week
  38. }
  39. function proposalThreshold() public pure override returns (uint256) {
  40. return 1000e18;
  41. }
  42. // The following functions are overrides required by Solidity.
  43. function quorum(uint256 blockNumber)
  44. public
  45. view
  46. override(IGovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
  47. returns (uint256)
  48. {
  49. return super.quorum(blockNumber);
  50. }
  51. function getVotes(address account, uint256 blockNumber)
  52. public
  53. view
  54. override(IGovernorUpgradeable, GovernorVotesUpgradeable)
  55. returns (uint256)
  56. {
  57. return super.getVotes(account, blockNumber);
  58. }
  59. function state(uint256 proposalId) public view override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (ProposalState) {
  60. return super.state(proposalId);
  61. }
  62. function propose(
  63. address[] memory targets,
  64. uint256[] memory values,
  65. bytes[] memory calldatas,
  66. string memory description
  67. ) public override(GovernorUpgradeable, GovernorProposalThresholdUpgradeable, IGovernorUpgradeable) returns (uint256) {
  68. return super.propose(targets, values, calldatas, description);
  69. }
  70. function _execute(
  71. uint256 proposalId,
  72. address[] memory targets,
  73. uint256[] memory values,
  74. bytes[] memory calldatas,
  75. bytes32 descriptionHash
  76. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) {
  77. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  78. }
  79. function _cancel(
  80. address[] memory targets,
  81. uint256[] memory values,
  82. bytes[] memory calldatas,
  83. bytes32 descriptionHash
  84. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint256) {
  85. return super._cancel(targets, values, calldatas, descriptionHash);
  86. }
  87. function _executor() internal view override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (address) {
  88. return super._executor();
  89. }
  90. function supportsInterface(bytes4 interfaceId)
  91. public
  92. view
  93. override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
  94. returns (bool)
  95. {
  96. return super.supportsInterface(interfaceId);
  97. }
  98. uint256[50] private __gap;
  99. }