|
| 1 | +/* |
| 2 | + This file is part of The Colony Network. |
| 3 | +
|
| 4 | + The Colony Network is free software: you can redistribute it and/or modify |
| 5 | + it under the terms of the GNU General external License as published by |
| 6 | + the Free Software Foundation, either version 3 of the License, or |
| 7 | + (at your option) any later version. |
| 8 | +
|
| 9 | + The Colony Network is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU General external License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU General external License |
| 15 | + along with The Colony Network. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +*/ |
| 17 | + |
| 18 | +pragma solidity 0.7.3; |
| 19 | +pragma experimental ABIEncoderV2; |
| 20 | + |
| 21 | +// import "./../colonyNetwork/IColonyNetwork.sol"; |
| 22 | +// import "./../colony/ColonyRoles.sol"; |
| 23 | +import "./../../common/IBasicMetaTransaction.sol"; |
| 24 | +import "./../IColonyExtension.sol"; |
| 25 | +import "./VotingReputationDataTypes.sol"; |
| 26 | +// import "./../patriciaTree/PatriciaTreeProofs.sol"; |
| 27 | +// import "./../tokenLocking/ITokenLocking.sol"; |
| 28 | +// import "./ColonyExtension.sol"; |
| 29 | + |
| 30 | + |
| 31 | +interface IVotingReputation is IBasicMetaTransaction, IColonyExtension, VotingReputationDataTypes { |
| 32 | + |
| 33 | + // function getMetatransactionNonce(address userAddress) override external view returns (uint256 nonce); |
| 34 | + |
| 35 | + |
| 36 | + /// @notice Initialise the extension |
| 37 | + /// @param _totalStakeFraction The fraction of the domain's reputation we need to stake |
| 38 | + /// @param _userMinStakeFraction The minimum per-user stake as fraction of total stake |
| 39 | + /// @param _maxVoteFraction The fraction of the domain's reputation which must submit for quick-end |
| 40 | + /// @param _voterRewardFraction The fraction of the total stake paid out to voters as rewards |
| 41 | + /// @param _stakePeriod The length of the staking period in seconds |
| 42 | + /// @param _submitPeriod The length of the submit period in seconds |
| 43 | + /// @param _revealPeriod The length of the reveal period in seconds |
| 44 | + /// @param _escalationPeriod The length of the escalation period in seconds |
| 45 | + function initialise( |
| 46 | + uint256 _totalStakeFraction, |
| 47 | + uint256 _voterRewardFraction, |
| 48 | + uint256 _userMinStakeFraction, |
| 49 | + uint256 _maxVoteFraction, |
| 50 | + uint256 _stakePeriod, |
| 51 | + uint256 _submitPeriod, |
| 52 | + uint256 _revealPeriod, |
| 53 | + uint256 _escalationPeriod |
| 54 | + ) |
| 55 | + external; |
| 56 | + |
| 57 | + // // Data structures |
| 58 | + |
| 59 | + // external functions (interface) |
| 60 | + |
| 61 | + /// @notice Create a motion |
| 62 | + /// @param _domainId The domain where we vote on the motion |
| 63 | + /// @param _childSkillIndex The childSkillIndex pointing to the domain of the action |
| 64 | + /// @param _altTarget The contract to which we send the action (0x0 for the colony) |
| 65 | + /// @param _action A bytes array encoding a function call |
| 66 | + /// @param _key Reputation tree key for the root domain |
| 67 | + /// @param _value Reputation tree value for the root domain |
| 68 | + /// @param _branchMask The branchmask of the proof |
| 69 | + /// @param _siblings The siblings of the proof |
| 70 | + function createMotion( |
| 71 | + uint256 _domainId, |
| 72 | + uint256 _childSkillIndex, |
| 73 | + address _altTarget, |
| 74 | + bytes memory _action, |
| 75 | + bytes memory _key, |
| 76 | + bytes memory _value, |
| 77 | + uint256 _branchMask, |
| 78 | + bytes32[] memory _siblings |
| 79 | + ) |
| 80 | + external; |
| 81 | + |
| 82 | + /// @notice Create a motion in the root domain (DEPRECATED) |
| 83 | + /// @param _altTarget The contract to which we send the action (0x0 for the colony) |
| 84 | + /// @param _action A bytes array encoding a function call |
| 85 | + /// @param _key Reputation tree key for the root domain |
| 86 | + /// @param _value Reputation tree value for the root domain |
| 87 | + /// @param _branchMask The branchmask of the proof |
| 88 | + /// @param _siblings The siblings of the proof |
| 89 | + function createRootMotion( |
| 90 | + address _altTarget, |
| 91 | + bytes memory _action, |
| 92 | + bytes memory _key, |
| 93 | + bytes memory _value, |
| 94 | + uint256 _branchMask, |
| 95 | + bytes32[] memory _siblings |
| 96 | + ) |
| 97 | + external; |
| 98 | + |
| 99 | + /// @notice Create a motion in any domain (DEPRECATED) |
| 100 | + /// @param _domainId The domain where we vote on the motion |
| 101 | + /// @param _childSkillIndex The childSkillIndex pointing to the domain of the action |
| 102 | + /// @param _action A bytes array encoding a function call |
| 103 | + /// @param _key Reputation tree key for the domain |
| 104 | + /// @param _value Reputation tree value for the domain |
| 105 | + /// @param _branchMask The branchmask of the proof |
| 106 | + /// @param _siblings The siblings of the proof |
| 107 | + function createDomainMotion( |
| 108 | + uint256 _domainId, |
| 109 | + uint256 _childSkillIndex, |
| 110 | + bytes memory _action, |
| 111 | + bytes memory _key, |
| 112 | + bytes memory _value, |
| 113 | + uint256 _branchMask, |
| 114 | + bytes32[] memory _siblings |
| 115 | + ) |
| 116 | + external; |
| 117 | + |
| 118 | + /// @notice Stake on a motion |
| 119 | + /// @param _motionId The id of the motion |
| 120 | + /// @param _permissionDomainId The domain where the extension has the arbitration permission |
| 121 | + /// @param _childSkillIndex For the domain in which the motion is occurring |
| 122 | + /// @param _vote The side being supported (0 = NAY, 1 = YAY) |
| 123 | + /// @param _amount The amount of tokens being staked |
| 124 | + /// @param _key Reputation tree key for the staker/domain |
| 125 | + /// @param _value Reputation tree value for the staker/domain |
| 126 | + /// @param _branchMask The branchmask of the proof |
| 127 | + /// @param _siblings The siblings of the proof |
| 128 | + function stakeMotion( |
| 129 | + uint256 _motionId, |
| 130 | + uint256 _permissionDomainId, |
| 131 | + uint256 _childSkillIndex, |
| 132 | + uint256 _vote, |
| 133 | + uint256 _amount, |
| 134 | + bytes memory _key, |
| 135 | + bytes memory _value, |
| 136 | + uint256 _branchMask, |
| 137 | + bytes32[] memory _siblings |
| 138 | + ) |
| 139 | + external; |
| 140 | + |
| 141 | + /// @notice Submit a vote secret for a motion |
| 142 | + /// @param _motionId The id of the motion |
| 143 | + /// @param _voteSecret The hashed vote secret |
| 144 | + /// @param _key Reputation tree key for the staker/domain |
| 145 | + /// @param _value Reputation tree value for the staker/domain |
| 146 | + /// @param _branchMask The branchmask of the proof |
| 147 | + /// @param _siblings The siblings of the proof |
| 148 | + function submitVote( |
| 149 | + uint256 _motionId, |
| 150 | + bytes32 _voteSecret, |
| 151 | + bytes memory _key, |
| 152 | + bytes memory _value, |
| 153 | + uint256 _branchMask, |
| 154 | + bytes32[] memory _siblings |
| 155 | + ) |
| 156 | + external; |
| 157 | + |
| 158 | + /// @notice Reveal a vote secret for a motion |
| 159 | + /// @param _motionId The id of the motion |
| 160 | + /// @param _salt The salt used to hash the vote |
| 161 | + /// @param _vote The side being supported (0 = NAY, 1 = YAY) |
| 162 | + /// @param _key Reputation tree key for the staker/domain |
| 163 | + /// @param _value Reputation tree value for the staker/domain |
| 164 | + /// @param _branchMask The branchmask of the proof |
| 165 | + /// @param _siblings The siblings of the proof |
| 166 | + function revealVote( |
| 167 | + uint256 _motionId, |
| 168 | + bytes32 _salt, |
| 169 | + uint256 _vote, |
| 170 | + bytes memory _key, |
| 171 | + bytes memory _value, |
| 172 | + uint256 _branchMask, |
| 173 | + bytes32[] memory _siblings |
| 174 | + ) |
| 175 | + external; |
| 176 | + |
| 177 | + /// @notice Escalate a motion to a higher domain |
| 178 | + /// @param _motionId The id of the motion |
| 179 | + /// @param _newDomainId The desired domain of escalation |
| 180 | + /// @param _childSkillIndex For the current domain, relative to the escalated domain |
| 181 | + /// @param _key Reputation tree key for the new domain |
| 182 | + /// @param _value Reputation tree value for the new domain |
| 183 | + /// @param _branchMask The branchmask of the proof |
| 184 | + /// @param _siblings The siblings of the proof |
| 185 | + function escalateMotion( |
| 186 | + uint256 _motionId, |
| 187 | + uint256 _newDomainId, |
| 188 | + uint256 _childSkillIndex, |
| 189 | + bytes memory _key, |
| 190 | + bytes memory _value, |
| 191 | + uint256 _branchMask, |
| 192 | + bytes32[] memory _siblings |
| 193 | + ) |
| 194 | + external; |
| 195 | + |
| 196 | + function finalizeMotion(uint256 _motionId) external; |
| 197 | + |
| 198 | + |
| 199 | + /// @notice Return whether a motion, assuming it's in the finalizable state, |
| 200 | + // is allowed to finalize without the call executing successfully. |
| 201 | + /// @param _motionId The id of the motion |
| 202 | + /// @dev We are only expecting this to be called from finalize motion in the contracts. |
| 203 | + /// It is marked as external only so that the frontend can use it. |
| 204 | + function failingExecutionAllowed(uint256 _motionId) external view returns (bool); |
| 205 | + |
| 206 | + /// @notice Claim the staker's reward |
| 207 | + /// @param _motionId The id of the motion |
| 208 | + /// @param _permissionDomainId The domain where the extension has the arbitration permission |
| 209 | + /// @param _childSkillIndex For the domain in which the motion is occurring |
| 210 | + /// @param _staker The staker whose reward is being claimed |
| 211 | + /// @param _vote The side being supported (0 = NAY, 1 = YAY) |
| 212 | + function claimReward( |
| 213 | + uint256 _motionId, |
| 214 | + uint256 _permissionDomainId, |
| 215 | + uint256 _childSkillIndex, |
| 216 | + address _staker, |
| 217 | + uint256 _vote |
| 218 | + ) |
| 219 | + external; |
| 220 | + |
| 221 | + // external view functions |
| 222 | + |
| 223 | + /// @notice Get the total stake fraction |
| 224 | + /// @return The total stake fraction |
| 225 | + function getTotalStakeFraction() external view returns (uint256); |
| 226 | + |
| 227 | + /// @notice Get the voter reward fraction |
| 228 | + /// @return The voter reward fraction |
| 229 | + function getVoterRewardFraction() external view returns (uint256) ; |
| 230 | + |
| 231 | + /// @notice Get the user min stake fraction |
| 232 | + /// @return The user min stake fraction |
| 233 | + function getUserMinStakeFraction() external view returns (uint256) ; |
| 234 | + |
| 235 | + /// @notice Get the max vote fraction |
| 236 | + /// @return The max vote fraction |
| 237 | + function getMaxVoteFraction() external view returns (uint256); |
| 238 | + |
| 239 | + /// @notice Get the stake period |
| 240 | + /// @return The stake period |
| 241 | + function getStakePeriod() external view returns (uint256); |
| 242 | + |
| 243 | + /// @notice Get the submit period |
| 244 | + /// @return The submit period |
| 245 | + function getSubmitPeriod() external view returns (uint256); |
| 246 | + |
| 247 | + /// @notice Get the reveal period |
| 248 | + /// @return The reveal period |
| 249 | + function getRevealPeriod() external view returns (uint256); |
| 250 | + |
| 251 | + /// @notice Get the escalation period |
| 252 | + /// @return The escalation period |
| 253 | + function getEscalationPeriod() external view returns (uint256); |
| 254 | + |
| 255 | + |
| 256 | + /// @notice Get the total motion count |
| 257 | + /// @return The total motion count |
| 258 | + function getMotionCount() external view returns (uint256) ; |
| 259 | + |
| 260 | + /// @notice Get the data for a single motion |
| 261 | + /// @param _motionId The id of the motion |
| 262 | + /// @return motion The motion struct |
| 263 | + function getMotion(uint256 _motionId) external view returns (Motion memory motion); |
| 264 | + |
| 265 | + /// @notice Get a user's stake on a motion |
| 266 | + /// @param _motionId The id of the motion |
| 267 | + /// @param _staker The staker address |
| 268 | + /// @param _vote The side being supported (0 = NAY, 1 = YAY) |
| 269 | + /// @return The user's stake |
| 270 | + function getStake(uint256 _motionId, address _staker, uint256 _vote) external view returns (uint256); |
| 271 | + |
| 272 | + /// @notice Get the number of ongoing motions for a single expenditure / expenditure slot |
| 273 | + /// @param _structHash The hash of the expenditureId or expenditureId*expenditureSlot |
| 274 | + /// @return The number of ongoing motions |
| 275 | + function getExpenditureMotionCount(bytes32 _structHash) external view returns (uint256); |
| 276 | + |
| 277 | + /// @notice Get the largest past vote on a single expenditure variable |
| 278 | + /// @param _actionHash The hash of the particular expenditure action |
| 279 | + /// @return The largest past vote on this variable |
| 280 | + function getExpenditurePastVote(bytes32 _actionHash) external view returns (uint256); |
| 281 | + |
| 282 | + /// @notice Get the current state of the motion |
| 283 | + /// @return The current motion state |
| 284 | + function getMotionState(uint256 _motionId) external view returns (MotionState) ; |
| 285 | + |
| 286 | + /// @notice Get the voter reward |
| 287 | + /// NB This function will only return a meaningful value if in the reveal state. |
| 288 | + /// Prior to the reveal state, getVoterRewardRange should be used. |
| 289 | + /// @param _motionId The id of the motion |
| 290 | + /// @param _voterRep The reputation the voter has in the domain |
| 291 | + /// @return The voter reward |
| 292 | + function getVoterReward(uint256 _motionId, uint256 _voterRep) external view returns (uint256) ; |
| 293 | + |
| 294 | + /// @notice Get the range of potential rewards for a voter on a specific motion, intended to be |
| 295 | + /// used when the motion is in the reveal state. |
| 296 | + /// Once a motion is in the reveal state the reward is known, and getVoterRewardRange should be used. |
| 297 | + /// @param _motionId The id of the motion |
| 298 | + /// @param _voterRep The reputation the voter has in the domain |
| 299 | + /// @param _voterAddress The address the user will be voting as |
| 300 | + /// @return The voter reward |
| 301 | + function getVoterRewardRange(uint256 _motionId, uint256 _voterRep, address _voterAddress) external view returns (uint256, uint256) ; |
| 302 | + /// @notice Get the staker reward |
| 303 | + /// @param _motionId The id of the motion |
| 304 | + /// @param _staker The staker's address |
| 305 | + /// @param _vote The vote (0 = NAY, 1 = YAY) |
| 306 | + /// @return The staker reward and the reputation penalty (if any) |
| 307 | + function getStakerReward(uint256 _motionId, address _staker, uint256 _vote) external view returns (uint256, uint256); |
| 308 | + |
| 309 | + function createClaimDelayAction(bytes memory action, uint256 value) |
| 310 | + external |
| 311 | + returns (bytes memory); |
| 312 | + |
| 313 | + function claimMisalignedReward( |
| 314 | + uint256 _motionId, |
| 315 | + uint256 _permissionDomainId, |
| 316 | + uint256 _childSkillIndex, |
| 317 | + address _staker, |
| 318 | + uint256 _vote |
| 319 | + ) |
| 320 | + external; |
| 321 | +} |
0 commit comments