WizardHarness1.sol 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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/GovernorTimelockControl.sol";
  8. import "../../contracts/governance/extensions/GovernorProposalThreshold.sol";
  9. /*
  10. Wizard options:
  11. ProposalThreshhold = 10
  12. ERC20Votes
  13. TimelockCOntroller
  14. */
  15. contract WizardHarness1 is Governor, GovernorProposalThreshold, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl {
  16. constructor(ERC20Votes _token, TimelockController _timelock, string memory name, uint256 quorumFraction)
  17. Governor(name)
  18. GovernorVotes(_token)
  19. GovernorVotesQuorumFraction(quorumFraction)
  20. GovernorTimelockControl(_timelock)
  21. {}
  22. //HARNESS
  23. function isExecuted(uint256 proposalId) public view returns (bool) {
  24. return _proposals[proposalId].executed;
  25. }
  26. function isCanceled(uint256 proposalId) public view returns (bool) {
  27. return _proposals[proposalId].canceled;
  28. }
  29. uint256 _votingDelay;
  30. uint256 _votingPeriod;
  31. uint256 _proposalThreshold;
  32. mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  33. function _castVote(
  34. uint256 proposalId,
  35. address account,
  36. uint8 support,
  37. string memory reason
  38. ) internal override virtual returns (uint256) {
  39. uint256 deltaWeight = super._castVote(proposalId, account, support, reason); //HARNESS
  40. ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  41. return deltaWeight;
  42. }
  43. function callPropose(address[] memory targets,
  44. uint256[] memory values,
  45. bytes[] memory calldatas) public virtual returns (uint256) {
  46. return super.propose(targets, values, calldatas, "");
  47. }
  48. function snapshot(uint256 proposalId) public view returns (uint64) {
  49. return _proposals[proposalId].voteStart._deadline;
  50. }
  51. // Harness of castVoteWithReason to be able to impose requirement on the proposal ID.
  52. uint256 public _pId_Harness;
  53. function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
  54. public
  55. override(IGovernor, Governor)
  56. returns (uint256)
  57. {
  58. require(proposalId == _pId_Harness);
  59. return super.castVoteWithReason(proposalId, support, reason);
  60. }
  61. function getExecutor() public returns (address){
  62. return _executor();
  63. }
  64. // original code
  65. function votingDelay() public view override returns (uint256) { // HARNESS: pure -> view
  66. return _votingDelay; // HARNESS: parametric
  67. }
  68. function votingPeriod() public view override returns (uint256) { // HARNESS: pure -> view
  69. return _votingPeriod; // HARNESS: parametric
  70. }
  71. function proposalThreshold() public view override returns (uint256) { // HARNESS: pure -> view
  72. return _proposalThreshold; // HARNESS: parametric
  73. }
  74. // The following functions are overrides required by Solidity.
  75. function quorum(uint256 blockNumber)
  76. public
  77. view
  78. override(IGovernor, GovernorVotesQuorumFraction)
  79. returns (uint256)
  80. {
  81. return super.quorum(blockNumber);
  82. }
  83. function getVotes(address account, uint256 blockNumber)
  84. public
  85. view
  86. override(IGovernor, GovernorVotes)
  87. returns (uint256)
  88. {
  89. return super.getVotes(account, blockNumber);
  90. }
  91. function state(uint256 proposalId)
  92. public
  93. view
  94. override(Governor, GovernorTimelockControl)
  95. returns (ProposalState)
  96. {
  97. return super.state(proposalId);
  98. }
  99. function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
  100. public
  101. override(Governor, GovernorProposalThreshold, IGovernor)
  102. returns (uint256)
  103. {
  104. return super.propose(targets, values, calldatas, description);
  105. }
  106. function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  107. internal
  108. override(Governor, GovernorTimelockControl)
  109. {
  110. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  111. }
  112. function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  113. internal
  114. override(Governor, GovernorTimelockControl)
  115. returns (uint256)
  116. {
  117. return super._cancel(targets, values, calldatas, descriptionHash);
  118. }
  119. function _executor()
  120. internal
  121. view
  122. override(Governor, GovernorTimelockControl)
  123. returns (address)
  124. {
  125. return super._executor();
  126. }
  127. function supportsInterface(bytes4 interfaceId)
  128. public
  129. view
  130. override(Governor, GovernorTimelockControl)
  131. returns (bool)
  132. {
  133. return super.supportsInterface(interfaceId);
  134. }
  135. }