WizardFirstTry.sol 4.3 KB

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