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