{"author":"Digix Holdings","title":"Contract for all voting operations of DAO","fileName":"/contracts/interactive/DaoVoting.sol","name":"DaoVoting","abi":[{"constant":true,"inputs":[],"name":"resolver","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentQuarterIndex","outputs":[{"name":"_quarterIndex","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getAddressConfig","outputs":[{"name":"_configValue","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_index","type":"uint8"},{"name":"_vote","type":"bool"},{"name":"_salt","type":"bytes32"}],"name":"revealVoteOnProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"key","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_key","type":"bytes32"}],"name":"get_contract","outputs":[{"name":"_contract","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"currentTimeInQuarter","outputs":[{"name":"_currentT","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_index","type":"uint8"},{"name":"_commitHash","type":"bytes32"}],"name":"commitVoteOnProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_voteYes","type":"bool"}],"name":"voteOnDraft","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isMainPhase","outputs":[{"name":"_isMainPhase","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isLockingPhase","outputs":[{"name":"_isLockingPhase","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isParticipant","outputs":[{"name":"_is","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getBytesConfig","outputs":[{"name":"_configValue","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getUintConfig","outputs":[{"name":"_configValue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_commitHash","type":"bytes32"}],"name":"commitVoteOnSpecialProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isDaoNotReplaced","outputs":[{"name":"_isNotReplaced","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_vote","type":"bool"},{"name":"_salt","type":"bytes32"}],"name":"revealVoteOnSpecialProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ADDRESS","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"isProposalPaused","outputs":[{"name":"_isPausedOrStopped","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isModerator","outputs":[{"name":"_is","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}],"bin":false,"opcodes":false,"source":"pragma solidity ^0.4.24;\n\nimport \"openzeppelin-solidity/contracts/ownership/Claimable.sol\";\nimport \"../common/DaoCommon.sol\";\n\n\n/**\n@title Contract for all voting operations of DAO\n@author Digix Holdings\n*/\ncontract DaoVoting is DaoCommon, Claimable {\n\n    constructor(address _resolver) public {\n        require(init(CONTRACT_DAO_VOTING, _resolver));\n    }\n\n    \n    /**\n    @notice Function to vote on draft proposal (only Moderators can vote)\n    @param _proposalId ID of the proposal\n    @param _voteYes Boolean, true if voting for, false if voting against\n    */\n    function voteOnDraft(\n        bytes32 _proposalId,\n        bool _voteYes\n    )\n        public\n        ifDraftVotingPhase(_proposalId)\n    {\n        require(isMainPhase());\n        require(isModerator(msg.sender));\n        address _moderator = msg.sender;\n        uint256 _moderatorStake = daoStakeStorage().lockedDGDStake(_moderator);\n\n        uint256 _voteWeight;\n        (,_voteWeight) = daoStorage().readDraftVote(_proposalId, _moderator);\n\n        daoStorage().addDraftVote(_proposalId, _moderator, _voteYes, _moderatorStake);\n\n        if (_voteWeight == 0) { // just voted the first time\n            daoPointsStorage().addModeratorQuarterPoint(_moderator, getUintConfig(CONFIG_QUARTER_POINT_DRAFT_VOTE), currentQuarterIndex());\n        }\n    }\n\n    \n    /**\n    @notice Function to commit a vote on special proposal\n    @param _proposalId ID of the proposal\n    @param _commitHash Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes(random string)))\n    @return {\n      \"_success\": \"Boolean, true if vote was committed successfully\"\n    }\n    */\n    function commitVoteOnSpecialProposal(\n        bytes32 _proposalId,\n        bytes32 _commitHash\n    )\n        public\n        ifCommitPhaseSpecial(_proposalId)\n    {\n        require(isParticipant(msg.sender));\n        daoSpecialStorage().commitVote(_proposalId, _commitHash, msg.sender);\n    }\n\n    \n    /**\n    @notice Function to reveal a committed vote on special proposal\n    @dev The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called\n    @param _proposalId ID of the proposal\n    @param _vote Boolean, true if voted for, false if voted against\n    @param _salt Random bytes used to commit vote\n    */\n    function revealVoteOnSpecialProposal(\n        bytes32 _proposalId,\n        bool _vote,\n        bytes32 _salt\n    )\n        public\n        ifRevealPhaseSpecial(_proposalId)\n        hasNotRevealedSpecial(_proposalId)\n    {\n        require(isParticipant(msg.sender));\n        require(keccak256(abi.encodePacked(msg.sender, _vote, _salt)) == daoSpecialStorage().readComittedVote(_proposalId, msg.sender));\n        daoSpecialStorage().revealVote(_proposalId, msg.sender, _vote, daoStakeStorage().lockedDGDStake(msg.sender));\n        daoPointsStorage().addQuarterPoint(msg.sender, getUintConfig(CONFIG_QUARTER_POINT_VOTE), currentQuarterIndex());\n    }\n\n    \n    /**\n    @notice Function to commit a vote on proposal (Voting Round)\n    @param _proposalId ID of the proposal\n    @param _index Index of the Voting Round\n    @param _commitHash Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes32(random string)))\n    */\n    function commitVoteOnProposal(\n        bytes32 _proposalId,\n        uint8 _index,\n        bytes32 _commitHash\n    )\n        public\n        ifCommitPhase(_proposalId, _index)\n    {\n        require(isParticipant(msg.sender));\n        daoStorage().commitVote(_proposalId, _commitHash, msg.sender, _index);\n    }\n\n    \n    /**\n    @notice Function to reveal a committed vote on proposal (Voting Round)\n    @dev The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called\n    @param _proposalId ID of the proposal\n    @param _index Index of the Voting Round\n    @param _vote Boolean, true if voted for, false if voted against\n    @param _salt Random bytes used to commit vote\n    */\n    function revealVoteOnProposal(\n        bytes32 _proposalId,\n        uint8 _index,\n        bool _vote,\n        bytes32 _salt\n    )\n        public\n        ifRevealPhase(_proposalId, _index)\n        hasNotRevealed(_proposalId, _index)\n    {\n        require(isParticipant(msg.sender));\n        require(keccak256(abi.encodePacked(msg.sender, _vote, _salt)) == daoStorage().readComittedVote(_proposalId, _index, msg.sender));\n        daoStorage().revealVote(_proposalId, msg.sender, _vote, daoStakeStorage().lockedDGDStake(msg.sender), _index);\n        daoPointsStorage().addQuarterPoint(\n            msg.sender,\n            getUintConfig(_index == 0 ? CONFIG_QUARTER_POINT_VOTE : CONFIG_QUARTER_POINT_INTERIM_VOTE),\n            currentQuarterIndex()\n        );\n    }\n}\n","abiDocs":[{"constant":true,"inputs":[],"name":"resolver","payable":false,"stateMutability":"view","type":"function","signature":"resolver()","signatureHash":"04f3bcec"},{"constant":true,"inputs":[],"name":"currentQuarterIndex","outputs":[{"name":"_quarterIndex","type":"uint256","description":"the current quarter index"}],"payable":false,"stateMutability":"view","type":"function","details":"Quarter indexes starts from 1","return":"_quarterIndex the current quarter index","notice":"Get the current quarter index","signature":"currentQuarterIndex()","signatureHash":"0d7cc561"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getAddressConfig","payable":false,"stateMutability":"view","type":"function","signature":"getAddressConfig(bytes32)","signatureHash":"1d8ccd04"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_index","type":"uint8","description":"Index of the Voting Round"},{"name":"_vote","type":"bool","description":"Boolean, true if voted for, false if voted against"},{"name":"_salt","type":"bytes32","description":"Random bytes used to commit vote"}],"name":"revealVoteOnProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called","notice":"Function to reveal a committed vote on proposal (Voting Round)","signature":"revealVoteOnProposal(bytes32,uint8,bool,bytes32)","signatureHash":"2b051b50"},{"constant":true,"inputs":[],"name":"key","payable":false,"stateMutability":"view","type":"function","signature":"key()","signatureHash":"3943380c"},{"constant":true,"inputs":[{"name":"_key","type":"bytes32","description":"the resolver key to look up"}],"name":"get_contract","outputs":[{"name":"_contract","type":"address","description":"the address of the contract"}],"payable":false,"stateMutability":"view","type":"function","details":"Get the address of a contract","return":"_contract the address of the contract","signature":"get_contract(bytes32)","signatureHash":"3f83acff"},{"constant":false,"inputs":[],"name":"claimOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"Allows the pendingOwner address to finalize the transfer.","signature":"claimOwnership()","signatureHash":"4e71e0c8"},{"constant":true,"inputs":[],"name":"currentTimeInQuarter","outputs":[{"name":"_currentT","type":"uint256","description":"the current relative time in the quarter"}],"payable":false,"stateMutability":"view","type":"function","details":"For example: the currentTimeInQuarter of the first second of any quarter is 1","return":"_currentT the current relative time in the quarter","notice":"Get the current relative time in the quarter","signature":"currentTimeInQuarter()","signatureHash":"560a25ea"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_index","type":"uint8","description":"Index of the Voting Round"},{"name":"_commitHash","type":"bytes32","description":"Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes32(random string)))"}],"name":"commitVoteOnProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","notice":"Function to commit a vote on proposal (Voting Round)","signature":"commitVoteOnProposal(bytes32,uint8,bytes32)","signatureHash":"5e8254ea"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_voteYes","type":"bool","description":"Boolean, true if voting for, false if voting against"}],"name":"voteOnDraft","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","notice":"Function to vote on draft proposal (only Moderators can vote)","signature":"voteOnDraft(bytes32,bool)","signatureHash":"610af570"},{"constant":true,"inputs":[],"name":"isMainPhase","outputs":[{"name":"_isMainPhase","type":"bool","description":"true if it is in a main phase"}],"payable":false,"stateMutability":"view","type":"function","details":"The main phase is where all the governance activities could take plase. If the DAO is replaced, there can never be any more main phase.","return":"_isMainPhase true if it is in a main phase","notice":"Check if it is currently in a main phase.","signature":"isMainPhase()","signatureHash":"68533060"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"Allows the current owner to relinquish control of the contract.","notice":"Renouncing to ownership will leave the contract without an owner. It will not be possible to call the functions with the `onlyOwner` modifier anymore.","signature":"renounceOwnership()","signatureHash":"715018a6"},{"constant":true,"inputs":[],"name":"isLockingPhase","outputs":[{"name":"_isLockingPhase","type":"bool","description":"true if it is in the locking phase"}],"payable":false,"stateMutability":"view","type":"function","details":"No governance activities can happen in the locking phase. The locking phase is from t=0 to t=CONFIG_LOCKING_PHASE_DURATION-1","return":"_isLockingPhase true if it is in the locking phase","notice":"Check if it is currently in the locking phase","signature":"isLockingPhase()","signatureHash":"7d6fed80"},{"constant":true,"inputs":[],"name":"owner","payable":false,"stateMutability":"view","type":"function","signature":"owner()","signatureHash":"8da5cb5b"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isParticipant","payable":false,"stateMutability":"view","type":"function","notice":"Check if a user is a participant in the current quarter","signature":"isParticipant(address)","signatureHash":"929066f5"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getBytesConfig","payable":false,"stateMutability":"view","type":"function","signature":"getBytesConfig(bytes32)","signatureHash":"93ddad08"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getUintConfig","payable":false,"stateMutability":"view","type":"function","signature":"getUintConfig(bytes32)","signatureHash":"b1e2b9dd"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_commitHash","type":"bytes32","description":"Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes(random string)))"}],"name":"commitVoteOnSpecialProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","return":"{ \"_success\": \"Boolean, true if vote was committed successfully\" }","notice":"Function to commit a vote on special proposal","signature":"commitVoteOnSpecialProposal(bytes32,bytes32)","signatureHash":"be29783f"},{"constant":true,"inputs":[],"name":"isDaoNotReplaced","outputs":[{"name":"_isNotReplaced","type":"bool","description":"true if it is not replaced, false if it has already been replaced"}],"payable":false,"stateMutability":"view","type":"function","return":"_isNotReplaced true if it is not replaced, false if it has already been replaced","notice":"Check if the DAO contracts have been replaced by a new set of contracts","signature":"isDaoNotReplaced()","signatureHash":"d70d9358"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_vote","type":"bool","description":"Boolean, true if voted for, false if voted against"},{"name":"_salt","type":"bytes32","description":"Random bytes used to commit vote"}],"name":"revealVoteOnSpecialProposal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called","notice":"Function to reveal a committed vote on special proposal","signature":"revealVoteOnSpecialProposal(bytes32,bool,bytes32)","signatureHash":"d9db3c73"},{"constant":true,"inputs":[],"name":"CONTRACT_ADDRESS","payable":false,"stateMutability":"view","type":"function","signature":"CONTRACT_ADDRESS()","signatureHash":"db4ecbc1"},{"constant":true,"inputs":[],"name":"pendingOwner","payable":false,"stateMutability":"view","type":"function","signature":"pendingOwner()","signatureHash":"e30c3978"},{"constant":false,"inputs":[{"name":"newOwner","type":"address","description":"The address to transfer ownership to."}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"Allows the current owner to set the pendingOwner address.","signature":"transferOwnership(address)","signatureHash":"f2fde38b"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"isProposalPaused","outputs":[{"name":"_isPausedOrStopped","type":"bool","description":"true if the proposal is paused(or stopped)"}],"payable":false,"stateMutability":"view","type":"function","details":"If a proposal is paused/stopped (by the PRLs): proposer cannot call for voting, a current on-going voting round can still pass, but no funding can be withdrawn.A paused proposal can still be unpausedIf a proposal is stopped, this function also returns true","return":"_isPausedOrStopped true if the proposal is paused(or stopped)","notice":"Check if a proposal is currently paused/stopped","signature":"isProposalPaused(bytes32)","signatureHash":"f94f0f33"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isModerator","payable":false,"stateMutability":"view","type":"function","notice":"Check if a user is a moderator in the current quarter","signature":"isModerator(address)","signatureHash":"fa6f3936"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event","signature":"OwnershipRenounced(address)","signatureHash":"f8df3114"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event","signature":"OwnershipTransferred(address,address)","signatureHash":"8be0079c"}]}
