GovernorHarness.sol 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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/GovernorTimelockControl.sol";
  6. import "../patched/governance/extensions/GovernorVotes.sol";
  7. import "../patched/governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../patched/token/ERC20/extensions/ERC20Votes.sol";
  9. contract GovernorHarness is
  10. Governor,
  11. GovernorCountingSimple,
  12. GovernorTimelockControl,
  13. GovernorVotes,
  14. GovernorVotesQuorumFraction
  15. {
  16. constructor(IVotes _token, TimelockController _timelock, uint256 _quorumNumeratorValue)
  17. Governor("Harness")
  18. GovernorTimelockControl(_timelock)
  19. GovernorVotes(_token)
  20. GovernorVotesQuorumFraction(_quorumNumeratorValue)
  21. {}
  22. // Harness from Votes
  23. function token_getPastTotalSupply(uint256 blockNumber) public view returns(uint256) {
  24. return token.getPastTotalSupply(blockNumber);
  25. }
  26. function token_getPastVotes(address account, uint256 blockNumber) public view returns(uint256) {
  27. return token.getPastVotes(account, blockNumber);
  28. }
  29. function token_clock() public view returns (uint48) {
  30. return token.clock();
  31. }
  32. function token_CLOCK_MODE() public view returns (string memory) {
  33. return token.CLOCK_MODE();
  34. }
  35. // Harness from Governor
  36. function hashProposal(address[] memory targets,uint256[] memory values,bytes[] memory calldatas,string memory description) public pure returns (uint256) {
  37. return hashProposal(targets, values, calldatas, keccak256(bytes(description)));
  38. }
  39. function getExecutor() public view returns (address) {
  40. return _executor();
  41. }
  42. function proposalProposer(uint256 proposalId) public view returns (address) {
  43. return _proposalProposer(proposalId);
  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 GovernorCountingSimple
  64. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  65. (uint256 againstVotes,,) = proposalVotes(proposalId);
  66. return againstVotes;
  67. }
  68. function getForVotes(uint256 proposalId) public view returns (uint256) {
  69. (,uint256 forVotes,) = proposalVotes(proposalId);
  70. return forVotes;
  71. }
  72. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  73. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  74. return abstainVotes;
  75. }
  76. // The following functions are overrides required by Solidity added by OZ Wizard.
  77. function votingDelay() public pure override returns (uint256) {
  78. return 1; // 1 block
  79. }
  80. function votingPeriod() public pure override returns (uint256) {
  81. return 45818; // 1 week
  82. }
  83. function quorum(uint256 blockNumber)
  84. public
  85. view
  86. override(IGovernor, GovernorVotesQuorumFraction)
  87. returns (uint256)
  88. {
  89. return super.quorum(blockNumber);
  90. }
  91. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  92. return super.state(proposalId);
  93. }
  94. function propose(
  95. address[] memory targets,
  96. uint256[] memory values,
  97. bytes[] memory calldatas,
  98. string memory description
  99. ) public override(Governor, IGovernor) returns (uint256) {
  100. return super.propose(targets, values, calldatas, description);
  101. }
  102. function _execute(
  103. uint256 proposalId,
  104. address[] memory targets,
  105. uint256[] memory values,
  106. bytes[] memory calldatas,
  107. bytes32 descriptionHash
  108. ) internal override(Governor, GovernorTimelockControl) {
  109. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  110. }
  111. function _cancel(
  112. address[] memory targets,
  113. uint256[] memory values,
  114. bytes[] memory calldatas,
  115. bytes32 descriptionHash
  116. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  117. return super._cancel(targets, values, calldatas, descriptionHash);
  118. }
  119. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  120. return super._executor();
  121. }
  122. function supportsInterface(bytes4 interfaceId)
  123. public
  124. view
  125. override(Governor, GovernorTimelockControl)
  126. returns (bool)
  127. {
  128. return super.supportsInterface(interfaceId);
  129. }
  130. }