WizardHarness1.sol 4.7 KB

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