WizardFirstTry.sol 4.3 KB

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