WizardControlFirstPriority.sol 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../munged/governance/Governor.sol";
  4. import "../munged/governance/extensions/GovernorCountingSimple.sol";
  5. import "../munged/governance/extensions/GovernorVotes.sol";
  6. import "../munged/governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import "../munged/governance/extensions/GovernorTimelockControl.sol";
  8. import "../munged/governance/extensions/GovernorProposalThreshold.sol";
  9. import "../munged/token/ERC20/extensions/ERC20Votes.sol";
  10. /*
  11. Wizard options:
  12. ProposalThreshhold = 10
  13. ERC20Votes
  14. TimelockController
  15. */
  16. contract WizardControlFirstPriority is Governor, GovernorProposalThreshold, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl {
  17. constructor(ERC20Votes _token, TimelockController _timelock, string memory name, uint256 quorumFraction)
  18. Governor(name)
  19. GovernorVotes(_token)
  20. GovernorVotesQuorumFraction(quorumFraction)
  21. GovernorTimelockControl(_timelock)
  22. {}
  23. //HARNESS
  24. function isExecuted(uint256 proposalId) public view returns (bool) {
  25. return _proposals[proposalId].executed;
  26. }
  27. function isCanceled(uint256 proposalId) public view returns (bool) {
  28. return _proposals[proposalId].canceled;
  29. }
  30. uint256 _votingDelay;
  31. uint256 _votingPeriod;
  32. uint256 _proposalThreshold;
  33. mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  34. function _castVote(
  35. uint256 proposalId,
  36. address account,
  37. uint8 support,
  38. string memory reason
  39. ) internal override virtual returns (uint256) {
  40. uint256 deltaWeight = super._castVote(proposalId, account, support, reason); //HARNESS
  41. ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  42. return deltaWeight;
  43. }
  44. function snapshot(uint256 proposalId) public view returns (uint64) {
  45. return _proposals[proposalId].voteStart._deadline;
  46. }
  47. function getExecutor() public view returns (address){
  48. return _executor();
  49. }
  50. // original code, harnessed
  51. function votingDelay() public view override returns (uint256) { // HARNESS: pure -> view
  52. return _votingDelay; // HARNESS: parametric
  53. }
  54. function votingPeriod() public view override returns (uint256) { // HARNESS: pure -> view
  55. return _votingPeriod; // HARNESS: parametric
  56. }
  57. function proposalThreshold() public view override returns (uint256) { // HARNESS: pure -> view
  58. return _proposalThreshold; // HARNESS: parametric
  59. }
  60. // original code, not harnessed
  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. }