GovernorPreventLateHarness.sol 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../patched/governance/Governor.sol";
  4. import "../patched/governance/extensions/GovernorCountingSimple.sol";
  5. import "../patched/governance/extensions/GovernorPreventLateQuorum.sol";
  6. import "../patched/governance/extensions/GovernorTimelockControl.sol";
  7. import "../patched/governance/extensions/GovernorVotes.sol";
  8. import "../patched/governance/extensions/GovernorVotesQuorumFraction.sol";
  9. import "../patched/token/ERC20/extensions/ERC20Votes.sol";
  10. contract GovernorPreventLateHarness is
  11. Governor,
  12. GovernorCountingSimple,
  13. GovernorPreventLateQuorum,
  14. GovernorTimelockControl,
  15. GovernorVotes,
  16. GovernorVotesQuorumFraction
  17. {
  18. constructor(IVotes _token, TimelockController _timelock, uint256 _quorumNumeratorValue, uint64 _initialVoteExtension)
  19. Governor("Harness")
  20. GovernorPreventLateQuorum(_initialVoteExtension)
  21. GovernorTimelockControl(_timelock)
  22. GovernorVotes(_token)
  23. GovernorVotesQuorumFraction(_quorumNumeratorValue)
  24. {}
  25. // Harness from Votes
  26. function token_getPastTotalSupply(uint256 blockNumber) public view returns(uint256) {
  27. return token.getPastTotalSupply(blockNumber);
  28. }
  29. function token_getPastVotes(address account, uint256 blockNumber) public view returns(uint256) {
  30. return token.getPastVotes(account, blockNumber);
  31. }
  32. function token_clock() public view returns (uint48) {
  33. return token.clock();
  34. }
  35. function token_CLOCK_MODE() public view returns (string memory) {
  36. return token.CLOCK_MODE();
  37. }
  38. // Harness from Governor
  39. function hashProposal(address[] memory targets,uint256[] memory values,bytes[] memory calldatas,string memory description) public pure returns (uint256) {
  40. return hashProposal(targets, values, calldatas, keccak256(bytes(description)));
  41. }
  42. function getExecutor() public view returns (address) {
  43. return _executor();
  44. }
  45. function quorumReached(uint256 proposalId) public view returns (bool) {
  46. return _quorumReached(proposalId);
  47. }
  48. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  49. return _voteSucceeded(proposalId);
  50. }
  51. function isExecuted(uint256 proposalId) public view returns (bool) {
  52. return _isExecuted(proposalId);
  53. }
  54. function isCanceled(uint256 proposalId) public view returns (bool) {
  55. return _isCanceled(proposalId);
  56. }
  57. function isQueued(uint256 proposalId) public view returns (bool) {
  58. return _proposalQueueId(proposalId) != bytes32(0);
  59. }
  60. function governanceCallLength() public view returns (uint256) {
  61. return _governanceCallLength();
  62. }
  63. // Harness from GovernorPreventLateQuorum
  64. function getExtendedDeadline(uint256 proposalId) public view returns (uint64) {
  65. return _getExtendedDeadline(proposalId);
  66. }
  67. // Harness from GovernorCountingSimple
  68. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  69. (uint256 againstVotes,,) = proposalVotes(proposalId);
  70. return againstVotes;
  71. }
  72. function getForVotes(uint256 proposalId) public view returns (uint256) {
  73. (,uint256 forVotes,) = proposalVotes(proposalId);
  74. return forVotes;
  75. }
  76. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  77. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  78. return abstainVotes;
  79. }
  80. // The following functions are overrides required by Solidity added by OZ Wizard.
  81. function votingDelay() public pure override returns (uint256) {
  82. return 1; // 1 block
  83. }
  84. function votingPeriod() public pure override returns (uint256) {
  85. return 45818; // 1 week
  86. }
  87. function quorum(uint256 blockNumber)
  88. public
  89. view
  90. override(IGovernor, GovernorVotesQuorumFraction)
  91. returns (uint256)
  92. {
  93. return super.quorum(blockNumber);
  94. }
  95. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  96. return super.state(proposalId);
  97. }
  98. function proposalDeadline(uint256 proposalId) public view override(IGovernor, Governor, GovernorPreventLateQuorum) returns (uint256) {
  99. return super.proposalDeadline(proposalId);
  100. }
  101. function propose(
  102. address[] memory targets,
  103. uint256[] memory values,
  104. bytes[] memory calldatas,
  105. string memory description
  106. ) public override(Governor, IGovernor) returns (uint256) {
  107. return super.propose(targets, values, calldatas, description);
  108. }
  109. function _execute(
  110. uint256 proposalId,
  111. address[] memory targets,
  112. uint256[] memory values,
  113. bytes[] memory calldatas,
  114. bytes32 descriptionHash
  115. ) internal override(Governor, GovernorTimelockControl) {
  116. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  117. }
  118. function _cancel(
  119. address[] memory targets,
  120. uint256[] memory values,
  121. bytes[] memory calldatas,
  122. bytes32 descriptionHash
  123. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  124. return super._cancel(targets, values, calldatas, descriptionHash);
  125. }
  126. function _castVote(
  127. uint256 proposalId,
  128. address account,
  129. uint8 support,
  130. string memory reason,
  131. bytes memory params
  132. ) internal override(Governor, GovernorPreventLateQuorum) returns (uint256) {
  133. return super._castVote(proposalId, account, support, reason, params);
  134. }
  135. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  136. return super._executor();
  137. }
  138. function supportsInterface(bytes4 interfaceId)
  139. public
  140. view
  141. virtual
  142. override(Governor, GovernorTimelockControl)
  143. returns (bool)
  144. {
  145. return super.supportsInterface(interfaceId);
  146. }
  147. }