WizardControlFirstPriority.sol 4.6 KB

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