WizardFirstTry.sol 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../../contracts/governance/Governor.sol";
  4. import "../../contracts/governance/extensions/GovernorCountingSimple.sol";
  5. import "../../contracts/governance/extensions/GovernorVotes.sol";
  6. import "../../contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
  7. import "../../contracts/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. // The following functions are overrides required by Solidity.
  54. function quorum(uint256 blockNumber)
  55. public
  56. view
  57. override(IGovernor, GovernorVotesQuorumFraction)
  58. returns (uint256)
  59. {
  60. return super.quorum(blockNumber);
  61. }
  62. function getVotes(address account, uint256 blockNumber)
  63. public
  64. view
  65. override(IGovernor, GovernorVotes)
  66. returns (uint256)
  67. {
  68. return super.getVotes(account, blockNumber);
  69. }
  70. function state(uint256 proposalId)
  71. public
  72. view
  73. override(Governor, GovernorTimelockCompound)
  74. returns (ProposalState)
  75. {
  76. return super.state(proposalId);
  77. }
  78. function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
  79. public
  80. override(Governor, IGovernor)
  81. returns (uint256)
  82. {
  83. return super.propose(targets, values, calldatas, description);
  84. }
  85. function _execute(uint256 proposalId, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  86. internal
  87. override(Governor, GovernorTimelockCompound)
  88. {
  89. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  90. }
  91. function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
  92. internal
  93. override(Governor, GovernorTimelockCompound)
  94. returns (uint256)
  95. {
  96. return super._cancel(targets, values, calldatas, descriptionHash);
  97. }
  98. function _executor()
  99. internal
  100. view
  101. override(Governor, GovernorTimelockCompound)
  102. returns (address)
  103. {
  104. return super._executor();
  105. }
  106. function supportsInterface(bytes4 interfaceId)
  107. public
  108. view
  109. override(Governor, GovernorTimelockCompound)
  110. returns (bool)
  111. {
  112. return super.supportsInterface(interfaceId);
  113. }
  114. }