GovernorPreventLateHarness.sol 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 proposalProposer(uint256 proposalId) public view returns (address) {
  46. return _proposalProposer(proposalId);
  47. }
  48. function quorumReached(uint256 proposalId) public view returns (bool) {
  49. return _quorumReached(proposalId);
  50. }
  51. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  52. return _voteSucceeded(proposalId);
  53. }
  54. function isExecuted(uint256 proposalId) public view returns (bool) {
  55. return _isExecuted(proposalId);
  56. }
  57. function isCanceled(uint256 proposalId) public view returns (bool) {
  58. return _isCanceled(proposalId);
  59. }
  60. function isQueued(uint256 proposalId) public view returns (bool) {
  61. return _proposalQueueId(proposalId) != bytes32(0);
  62. }
  63. function governanceCallLength() public view returns (uint256) {
  64. return _governanceCallLength();
  65. }
  66. // Harness from GovernorPreventLateQuorum
  67. function getExtendedDeadline(uint256 proposalId) public view returns (uint64) {
  68. return _getExtendedDeadline(proposalId);
  69. }
  70. // Harness from GovernorCountingSimple
  71. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  72. (uint256 againstVotes,,) = proposalVotes(proposalId);
  73. return againstVotes;
  74. }
  75. function getForVotes(uint256 proposalId) public view returns (uint256) {
  76. (,uint256 forVotes,) = proposalVotes(proposalId);
  77. return forVotes;
  78. }
  79. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  80. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  81. return abstainVotes;
  82. }
  83. // The following functions are overrides required by Solidity added by OZ Wizard.
  84. function votingDelay() public pure override returns (uint256) {
  85. return 1; // 1 block
  86. }
  87. function votingPeriod() public pure override returns (uint256) {
  88. return 45818; // 1 week
  89. }
  90. function quorum(uint256 blockNumber)
  91. public
  92. view
  93. override(IGovernor, GovernorVotesQuorumFraction)
  94. returns (uint256)
  95. {
  96. return super.quorum(blockNumber);
  97. }
  98. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  99. return super.state(proposalId);
  100. }
  101. function proposalDeadline(uint256 proposalId) public view override(IGovernor, Governor, GovernorPreventLateQuorum) returns (uint256) {
  102. return super.proposalDeadline(proposalId);
  103. }
  104. function propose(
  105. address[] memory targets,
  106. uint256[] memory values,
  107. bytes[] memory calldatas,
  108. string memory description
  109. ) public override(Governor, IGovernor) returns (uint256) {
  110. return super.propose(targets, values, calldatas, description);
  111. }
  112. function _execute(
  113. uint256 proposalId,
  114. address[] memory targets,
  115. uint256[] memory values,
  116. bytes[] memory calldatas,
  117. bytes32 descriptionHash
  118. ) internal override(Governor, GovernorTimelockControl) {
  119. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  120. }
  121. function _cancel(
  122. address[] memory targets,
  123. uint256[] memory values,
  124. bytes[] memory calldatas,
  125. bytes32 descriptionHash
  126. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  127. return super._cancel(targets, values, calldatas, descriptionHash);
  128. }
  129. function _castVote(
  130. uint256 proposalId,
  131. address account,
  132. uint8 support,
  133. string memory reason,
  134. bytes memory params
  135. ) internal override(Governor, GovernorPreventLateQuorum) returns (uint256) {
  136. return super._castVote(proposalId, account, support, reason, params);
  137. }
  138. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  139. return super._executor();
  140. }
  141. function supportsInterface(bytes4 interfaceId)
  142. public
  143. view
  144. virtual
  145. override(Governor, GovernorTimelockControl)
  146. returns (bool)
  147. {
  148. return super.supportsInterface(interfaceId);
  149. }
  150. }