WizardHarness1.sol 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. // original code
  62. function votingDelay() public view override returns (uint256) { // HARNESS: pure -> view
  63. return _votingDelay; // HARNESS: parametric
  64. }
  65. function votingPeriod() public view override returns (uint256) { // HARNESS: pure -> view
  66. return _votingPeriod; // HARNESS: parametric
  67. }
  68. function proposalThreshold() public view override returns (uint256) { // HARNESS: pure -> view
  69. return _proposalThreshold; // HARNESS: parametric
  70. }
  71. // The following functions are overrides required by Solidity.
  72. function quorum(uint256 blockNumber)
  73. public
  74. view
  75. override(IGovernor, GovernorVotesQuorumFraction)
  76. returns (uint256)
  77. {
  78. return super.quorum(blockNumber);
  79. }
  80. function getVotes(address account, uint256 blockNumber)
  81. public
  82. view
  83. override(IGovernor, GovernorVotes)
  84. returns (uint256)
  85. {
  86. return super.getVotes(account, blockNumber);
  87. }
  88. function state(uint256 proposalId)
  89. public
  90. view
  91. override(Governor, GovernorTimelockControl)
  92. returns (ProposalState)
  93. {
  94. return super.state(proposalId);
  95. }
  96. function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
  97. public
  98. override(Governor, GovernorProposalThreshold, IGovernor)
  99. returns (uint256)
  100. {
  101. return super.propose(targets, values, calldatas, description);
  102. }
  103. function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  104. internal
  105. override(Governor, GovernorTimelockControl)
  106. {
  107. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  108. }
  109. function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  110. internal
  111. override(Governor, GovernorTimelockControl)
  112. returns (uint256)
  113. {
  114. return super._cancel(targets, values, calldatas, descriptionHash);
  115. }
  116. function _executor()
  117. internal
  118. view
  119. override(Governor, GovernorTimelockControl)
  120. returns (address)
  121. {
  122. return super._executor();
  123. }
  124. function supportsInterface(bytes4 interfaceId)
  125. public
  126. view
  127. override(Governor, GovernorTimelockControl)
  128. returns (bool)
  129. {
  130. return super.supportsInterface(interfaceId);
  131. }
  132. }