{"author":"Digix Holdings","title":"Contract to claim voting results","fileName":"/contracts/interactive/DaoSpecialVotingClaims.sol","name":"DaoSpecialVotingClaims","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":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":"_operations","type":"uint256"}],"name":"claimSpecialProposalVotingResult","outputs":[{"name":"_passed","type":"bool"}],"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":true,"inputs":[],"name":"isDaoNotReplaced","outputs":[{"name":"_isNotReplaced","type":"bool"}],"payable":false,"stateMutability":"view","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\";\nimport \"../service/DaoCalculatorService.sol\";\nimport \"./DaoFundingManager.sol\";\nimport \"./DaoRewardsManager.sol\";\nimport \"../lib/DaoIntermediateStructs.sol\";\nimport \"../lib/DaoStructs.sol\";\n\n\n/**\n@title Contract to claim voting results\n@author Digix Holdings\n*/\ncontract DaoSpecialVotingClaims is DaoCommon, Claimable {\n    using DaoIntermediateStructs for DaoIntermediateStructs.VotingCount;\n    using DaoStructs for DaoStructs.IntermediateResults;\n\n    function daoCalculatorService()\n        internal\n        constant\n        returns (DaoCalculatorService _contract)\n    {\n        _contract = DaoCalculatorService(get_contract(CONTRACT_SERVICE_DAO_CALCULATOR));\n    }\n\n    function daoFundingManager()\n        internal\n        constant\n        returns (DaoFundingManager _contract)\n    {\n        _contract = DaoFundingManager(get_contract(CONTRACT_DAO_FUNDING_MANAGER));\n    }\n\n    function daoRewardsManager()\n        internal\n        constant\n        returns (DaoRewardsManager _contract)\n    {\n        _contract = DaoRewardsManager(get_contract(CONTRACT_DAO_REWARDS_MANAGER));\n    }\n\n    constructor(address _resolver) public {\n        require(init(CONTRACT_DAO_SPECIAL_VOTING_CLAIMS, _resolver));\n    }\n\n    \n    /**\n    @notice Function to claim the voting result on special proposal\n    @param _proposalId ID of the special proposal\n    @return {\n      \"_passed\": \"Boolean, true if voting passed, throw if failed, returns false if passed deadline\"\n    }\n    */\n    function claimSpecialProposalVotingResult(bytes32 _proposalId, uint256 _operations)\n        public\n        ifNotClaimedSpecial(_proposalId)\n        ifAfterRevealPhaseSpecial(_proposalId)\n        returns (bool _passed)\n    {\n        require(isMainPhase());\n        if (now > daoSpecialStorage().readVotingTime(_proposalId)\n                    .add(getUintConfig(CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL))\n                    .add(getUintConfig(CONFIG_VOTE_CLAIMING_DEADLINE))) {\n            daoSpecialStorage().setPass(_proposalId, false);\n            return false;\n        }\n        require(msg.sender == daoSpecialStorage().readProposalProposer(_proposalId));\n\n        DaoStructs.IntermediateResults memory _currentResults;\n        (\n            _currentResults.countedUntil,\n            _currentResults.currentForCount,\n            _currentResults.currentAgainstCount,\n        ) = intermediateResultsStorage().getIntermediateResults(_proposalId);\n\n        address[] memory _voters;\n        if (_currentResults.countedUntil == EMPTY_ADDRESS) {\n            _voters = daoListingService().listParticipants(\n                _operations,\n                true\n            );\n        } else {\n            _voters = daoListingService().listParticipantsFrom(\n                _currentResults.countedUntil,\n                _operations,\n                true\n            );\n        }\n\n        address _lastVoter = _voters[_voters.length - 1];\n\n        DaoIntermediateStructs.VotingCount memory _voteCount;\n        (_voteCount.forCount, _voteCount.againstCount) = daoSpecialStorage().readVotingCount(_proposalId, _voters);\n\n        _currentResults.countedUntil = _lastVoter;\n        _currentResults.currentForCount = _currentResults.currentForCount.add(_voteCount.forCount);\n        _currentResults.currentAgainstCount = _currentResults.currentAgainstCount.add(_voteCount.againstCount);\n\n        if (_lastVoter == daoStakeStorage().readLastParticipant()) {\n            // this is already the last transaction, we have counted all the votes\n\n            if (\n                (_currentResults.currentForCount.add(_currentResults.currentAgainstCount) > daoCalculatorService().minimumVotingQuorumForSpecial()) &&\n                (daoCalculatorService().votingQuotaForSpecialPass(_currentResults.currentForCount, _currentResults.currentAgainstCount))\n            ) {\n                _passed = true;\n                setConfigs(_proposalId);\n            }\n            daoSpecialStorage().setPass(_proposalId, _passed);\n            daoSpecialStorage().setVotingClaim(_proposalId, true);\n        } else {\n            intermediateResultsStorage().setIntermediateResults(\n                _proposalId,\n                _currentResults.countedUntil,\n                _currentResults.currentForCount,\n                _currentResults.currentAgainstCount,\n                0\n            );\n        }\n    }\n\n    \n    function setConfigs(bytes32 _proposalId)\n        private\n    {\n        uint256[] memory _uintConfigs;\n        address[] memory _addressConfigs;\n        bytes32[] memory _bytesConfigs;\n        (\n            _uintConfigs,\n            _addressConfigs,\n            _bytesConfigs\n        ) = daoSpecialStorage().readConfigs(_proposalId);\n        daoConfigsStorage().updateUintConfigs(_uintConfigs);\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":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 special proposal"},{"name":"_operations","type":"uint256"}],"name":"claimSpecialProposalVotingResult","outputs":[{"name":"_passed","type":"bool","description":"Boolean, true if voting passed, throw if failed, returns false if passed deadline"}],"payable":false,"stateMutability":"nonpayable","type":"function","return":"{ \"_passed\": \"Boolean, true if voting passed, throw if failed, returns false if passed deadline\" }","notice":"Function to claim the voting result on special proposal","signature":"claimSpecialProposalVotingResult(bytes32,uint256)","signatureHash":"5932470b"},{"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":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":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"}]}
