GovernorBasicHarness.sol 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../contracts/governance/Governor.sol";
  4. import "../../contracts/governance/extensions/GovernorCountingSimple.sol";
  5. import "../../contracts/governance/extensions/GovernorVotes.sol";
  6. import "../../contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import "../../contracts/governance/extensions/GovernorTimelockCompound.sol";
  8. /*
  9. Wizard options:
  10. ERC20Votes
  11. TimelockCompound
  12. */
  13. contract GovernorBasicHarness is Governor, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockCompound {
  14. constructor(ERC20Votes _token, ICompoundTimelock _timelock, string memory name, uint256 quorumFraction)
  15. Governor(name)
  16. GovernorVotes(_token)
  17. GovernorVotesQuorumFraction(quorumFraction)
  18. GovernorTimelockCompound(_timelock)
  19. {}
  20. function isExecuted(uint256 proposalId) public view returns (bool) {
  21. return _proposals[proposalId].executed;
  22. }
  23. function isCanceled(uint256 proposalId) public view returns (bool) {
  24. return _proposals[proposalId].canceled;
  25. }
  26. uint256 _votingDelay;
  27. function votingDelay() public view override virtual returns (uint256) {
  28. return _votingDelay;
  29. }
  30. uint256 _votingPeriod;
  31. function votingPeriod() public view override virtual returns (uint256) {
  32. return _votingPeriod;
  33. }
  34. mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  35. function _castVote(
  36. uint256 proposalId,
  37. address account,
  38. uint8 support,
  39. string memory reason
  40. ) internal override virtual returns (uint256) {
  41. uint256 deltaWeight = super._castVote(proposalId, account, support, reason); //HARNESS
  42. ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  43. return deltaWeight;
  44. }
  45. function callPropose(address[] memory targets,
  46. uint256[] memory values,
  47. bytes[] memory calldatas) public virtual returns (uint256) {
  48. return super.propose(targets, values, calldatas, "");
  49. }
  50. /*
  51. mapping (address => mapping (uint256 => uint256)) _getVotes;
  52. function getVotesHarnness(address account, uint256 blockNumber) public {
  53. _getVotes[account][blockNumber] = getVotes(account, blockNumber);
  54. }
  55. */
  56. // The following functions are overrides required by Solidity.
  57. function quorum(uint256 blockNumber)
  58. public
  59. view
  60. override(IGovernor, GovernorVotesQuorumFraction)
  61. returns (uint256)
  62. {
  63. return super.quorum(blockNumber);
  64. }
  65. function getVotes(address account, uint256 blockNumber)
  66. public
  67. view
  68. override(IGovernor, GovernorVotes)
  69. returns (uint256)
  70. {
  71. return super.getVotes(account, blockNumber);
  72. }
  73. function state(uint256 proposalId)
  74. public
  75. view
  76. override(Governor, GovernorTimelockCompound)
  77. returns (ProposalState)
  78. {
  79. return super.state(proposalId);
  80. }
  81. function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
  82. public
  83. override(Governor, IGovernor)
  84. returns (uint256)
  85. {
  86. return super.propose(targets, values, calldatas, description);
  87. }
  88. function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  89. internal
  90. override(Governor, GovernorTimelockCompound)
  91. {
  92. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  93. }
  94. function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  95. internal
  96. override(Governor, GovernorTimelockCompound)
  97. returns (uint256)
  98. {
  99. return super._cancel(targets, values, calldatas, descriptionHash);
  100. }
  101. function _executor()
  102. internal
  103. view
  104. override(Governor, GovernorTimelockCompound)
  105. returns (address)
  106. {
  107. return super._executor();
  108. }
  109. function supportsInterface(bytes4 interfaceId)
  110. public
  111. view
  112. override(Governor, GovernorTimelockCompound)
  113. returns (bool)
  114. {
  115. return super.supportsInterface(interfaceId);
  116. }
  117. }