MyGovernor1Upgradeable.sol 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../governance/GovernorUpgradeable.sol";
  4. import "../../governance/extensions/GovernorCountingSimpleUpgradeable.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 MyGovernor1Upgradeable is
  10. Initializable, GovernorUpgradeable,
  11. GovernorTimelockControlUpgradeable,
  12. GovernorVotesUpgradeable,
  13. GovernorVotesQuorumFractionUpgradeable,
  14. GovernorCountingSimpleUpgradeable
  15. {
  16. function __MyGovernor1_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 __MyGovernor1_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. // The following functions are overrides required by Solidity.
  31. function quorum(uint256 blockNumber)
  32. public
  33. view
  34. override(IGovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
  35. returns (uint256)
  36. {
  37. return super.quorum(blockNumber);
  38. }
  39. function getVotes(address account, uint256 blockNumber)
  40. public
  41. view
  42. override(IGovernorUpgradeable, GovernorVotesUpgradeable)
  43. returns (uint256)
  44. {
  45. return super.getVotes(account, blockNumber);
  46. }
  47. function state(uint256 proposalId) public view override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (ProposalState) {
  48. return super.state(proposalId);
  49. }
  50. function propose(
  51. address[] memory targets,
  52. uint256[] memory values,
  53. bytes[] memory calldatas,
  54. string memory description
  55. ) public override(GovernorUpgradeable, IGovernorUpgradeable) returns (uint256) {
  56. return super.propose(targets, values, calldatas, description);
  57. }
  58. function _execute(
  59. uint256 proposalId,
  60. address[] memory targets,
  61. uint256[] memory values,
  62. bytes[] memory calldatas,
  63. bytes32 descriptionHash
  64. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) {
  65. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  66. }
  67. function _cancel(
  68. address[] memory targets,
  69. uint256[] memory values,
  70. bytes[] memory calldatas,
  71. bytes32 descriptionHash
  72. ) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint256) {
  73. return super._cancel(targets, values, calldatas, descriptionHash);
  74. }
  75. function _executor() internal view override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (address) {
  76. return super._executor();
  77. }
  78. function supportsInterface(bytes4 interfaceId)
  79. public
  80. view
  81. override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
  82. returns (bool)
  83. {
  84. return super.supportsInterface(interfaceId);
  85. }
  86. /**
  87. * This empty reserved space is put in place to allow future versions to add new
  88. * variables without shifting down storage in the inheritance chain.
  89. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  90. */
  91. uint256[50] private __gap;
  92. }