GovernorPreventLateQuorumHarness.sol 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../munged/governance/extensions/GovernorPreventLateQuorum.sol";
  4. import "../munged/governance/Governor.sol";
  5. import "../munged/governance/extensions/GovernorCountingSimple.sol";
  6. import "../munged/governance/extensions/GovernorVotes.sol";
  7. import "../munged/governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../munged/governance/extensions/GovernorTimelockControl.sol";
  9. import "../munged/token/ERC20/extensions/ERC20Votes.sol";
  10. contract GovernorPreventLateQuorumHarness is Governor, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl, GovernorPreventLateQuorum {
  11. using SafeCast for uint256;
  12. using Timers for Timers.BlockNumber;
  13. constructor(IVotes _token, TimelockController _timelock, uint64 initialVoteExtension, uint256 quorumNumeratorValue)
  14. Governor("Harness")
  15. GovernorVotes(_token)
  16. GovernorVotesQuorumFraction(quorumNumeratorValue)
  17. GovernorTimelockControl(_timelock)
  18. GovernorPreventLateQuorum(initialVoteExtension)
  19. {}
  20. // variable added to check when _castVote is called
  21. uint256 public latestCastVoteCall;
  22. // Harness from GovernorPreventLateQuorum //
  23. function getVoteExtension() public view returns(uint64) {
  24. return _voteExtension;
  25. }
  26. function getExtendedDeadlineIsUnset(uint256 id) public view returns(bool) {
  27. return _extendedDeadlines[id].isUnset();
  28. }
  29. function getExtendedDeadline(uint256 id) public view returns(uint64) {
  30. return _extendedDeadlines[id].getDeadline();
  31. }
  32. // Harness from GovernorCountingSimple //
  33. function quorumReached(uint256 proposalId) public view returns(bool) {
  34. return _quorumReached(proposalId);
  35. }
  36. // Harness from Governor //
  37. function isExecuted(uint256 proposalId) public view returns (bool) {
  38. return _proposals[proposalId].executed;
  39. }
  40. function isCanceled(uint256 proposalId) public view returns (bool) {
  41. return _proposals[proposalId].canceled;
  42. }
  43. // The following functions are overrides required by Solidity added by Certora. //
  44. function proposalDeadline(uint256 proposalId) public view virtual override(Governor, GovernorPreventLateQuorum, IGovernor) returns (uint256) {
  45. return super.proposalDeadline(proposalId);
  46. }
  47. function _castVote(
  48. uint256 proposalId,
  49. address account,
  50. uint8 support,
  51. string memory reason,
  52. bytes memory params
  53. ) internal virtual override(Governor, GovernorPreventLateQuorum) returns (uint256) {
  54. latestCastVoteCall = block.number;
  55. return super._castVote(proposalId, account, support, reason, params);
  56. }
  57. function castVote(
  58. uint256 proposalId,
  59. address account,
  60. uint8 support,
  61. string memory reason,
  62. bytes memory params
  63. ) public returns(uint256) {
  64. return _castVote(proposalId, account, support, reason, params);
  65. }
  66. function lateQuorumVoteExtension() public view virtual override returns (uint64) {
  67. return super.lateQuorumVoteExtension();
  68. }
  69. function setLateQuorumVoteExtension(uint64 newVoteExtension) public virtual override onlyGovernance {
  70. super.setLateQuorumVoteExtension(newVoteExtension);
  71. }
  72. // The following functions are overrides required by Solidity added by OZ Wizard. //
  73. function votingDelay() public pure override returns (uint256) {
  74. return 1; // 1 block
  75. }
  76. function votingPeriod() public pure override returns (uint256) {
  77. return 45818; // 1 week
  78. }
  79. function quorum(uint256 blockNumber)
  80. public
  81. view
  82. override(IGovernor, GovernorVotesQuorumFraction)
  83. returns (uint256)
  84. {
  85. return super.quorum(blockNumber);
  86. }
  87. function state(uint256 proposalId)
  88. public
  89. view
  90. override(Governor, GovernorTimelockControl)
  91. returns (ProposalState)
  92. {
  93. return super.state(proposalId);
  94. }
  95. function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
  96. public
  97. override(Governor, IGovernor)
  98. returns (uint256)
  99. {
  100. return super.propose(targets, values, calldatas, description);
  101. }
  102. function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  103. internal
  104. override(Governor, GovernorTimelockControl)
  105. {
  106. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  107. }
  108. function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  109. internal
  110. override(Governor, GovernorTimelockControl)
  111. returns (uint256)
  112. {
  113. return super._cancel(targets, values, calldatas, descriptionHash);
  114. }
  115. function _executor()
  116. internal
  117. view
  118. override(Governor, GovernorTimelockControl)
  119. returns (address)
  120. {
  121. return super._executor();
  122. }
  123. function supportsInterface(bytes4 interfaceId)
  124. public
  125. view
  126. override(Governor, GovernorTimelockControl)
  127. returns (bool)
  128. {
  129. return super.supportsInterface(interfaceId);
  130. }
  131. }