WizardFirstTry.sol 4.3 KB

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