MyGovernor3Upgradeable.sol 4.1 KB

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