import { EthApi } from "@joincivil/ethapi"; import { Bytes32, EthAddress, PollData, BigNumber, DecodedLogEntryEvent } from "@joincivil/typescript-types"; import { Observable } from "rxjs"; import { TwoStepEthTransaction } from "../../types"; import { BaseWrapper } from "../basewrapper"; import { CivilPLCRVotingContract, CivilPLCRVoting } from "../generated/wrappers/civil_p_l_c_r_voting"; /** * Voting allows user to interface with polls, either from the * Parameterizer or the Registry */ export declare class Voting extends BaseWrapper { static singleton(ethApi: EthApi): Promise; static atUntrusted(web3wrapper: EthApi, address: EthAddress): Promise; private constructor(); /** * Event Streams */ /** * An unending stream of all IDs of active Polls * @param fromBlock Starting block in history for events concerning new polls * Set to "latest" for only new events * @returns currently active polls (by id) */ activePolls(fromBlock?: number, toBlock?: number): Observable; /** * An unending stream of all pollIDs of polls the user has committed votes on * @param fromBlock Starting block in history for events concerning new polls * Set to "latest" for only new events * @param user the user to check */ votesCommitted(fromBlock?: number, user?: EthAddress, toBlock?: number): Observable; /** * An unending stream of all pollIDs of polls the user has revealed votes on * @param fromBlock Starting block in history for events concerning new polls * Set to "latest" for only new events * @param user the user to check */ votesRevealed(fromBlock?: number, user?: EthAddress, toBlock?: number): Observable; /** * An unending stream of all pollIDs of polls the user has rescued votes on * @param fromBlock Starting block in history for events concerning new polls * Set to "latest" for only new events * @param user the user to check */ votesRescued(fromBlock?: number, user?: EthAddress, toBlock?: number): Observable; balanceUpdate(fromBlock: number | undefined, user: EthAddress): Observable; /** * Contract Transactions */ /** * Withdraw tokens from voting contract (thus withdrawing voting rights) * @param numTokens number of tokens to withdraw from voting contract */ withdrawVotingRights(numTokens: BigNumber): Promise; /** * Deposits tokens into voting contract (thus requesting voting rights) * @param numTokens number of tokens to deposit into voting contract */ requestVotingRights(numTokens: BigNumber): Promise; /** * Checks whether or not a user can rescue tokens from a poll by trying to estimate gas cost of the transaction. * If estimate succeeds, it should be true. If the estimate fails, it means the transaction would result in an EVM * exception and should be false. * @param user user to check * @param pollID poll to check */ canRescueTokens(user: EthAddress, pollID: BigNumber): Promise; /** * Unlocks tokens from unrevealed vote where poll has ended * @param pollID ID of poll to unlock unrevealed vote of */ rescueTokens(pollID: BigNumber): Promise; /** * Unlocks tokens from unrevealed vote from multiple polls that have ended * @param pollIDs List of IDs of polls to unlock unrevealed vote of */ rescueTokensInMultiplePolls(pollIDs: BigNumber[]): Promise; /** * Commits user's votes for poll * @param pollID ID of poll to commit votes to * @param secretHash keccak256 hash of voter's choice and salt (tightly packed in this order) * @param numTokens How many tokens to be committed to poll * @param prevPollID ID of poll that the user has committed the maximum * number of tokens to (less than or equal to numTokens) */ commitVote(pollID: BigNumber, secretHash: Bytes32, numTokens: BigNumber, prevPollID: BigNumber): Promise; /** * Reveals user's vote for specified poll * @param pollID ID of poll to reveal votes in * @param voteOption Vote choice used to generate commitHash for poll * @param salt Secret number used to generate commitHash for poll */ revealVote(pollID: BigNumber, voteOption: BigNumber, salt: BigNumber): Promise; getRevealedVote(pollID: BigNumber, voter: EthAddress): Promise; isVoterWinner(pollID: BigNumber, voter: EthAddress): Promise; getRevealedVoteEvent(pollID: BigNumber, voter: EthAddress): Promise | undefined>; /** * Contract Getters */ /** * Gets number of tokens held as voting rights by the Voting contract * Voting contract may hold more tokens than can be withdrawn if some tokens * are currently locked in a vote * @param tokenOwner Address of token owner to check voting rights of */ getNumVotingRights(tokenOwner?: EthAddress): Promise; /** * Has a vote been revealed for given voter in specified poll? * @param voterAddress voter to check vote status of * @param pollID ID of poll to check */ hasVoteBeenRevealed(pollID: BigNumber, voter?: EthAddress): Promise; /** * Is this poll in reveal period? * @param pollID ID of poll to check */ isRevealPeriodActive(pollID: BigNumber): Promise; /** * Is this poll in commit period? * @param pollID ID of poll to check */ isCommitPeriodActive(pollID: BigNumber): Promise; didCommitVote(user: EthAddress, pollID: BigNumber): Promise; didRevealVote(user: EthAddress, pollID: BigNumber): Promise; /** * Has this poll ended? * @param pollID ID of poll to check */ hasPollEnded(pollID: BigNumber): Promise; /** * Gets total number of tokens from winning side of poll * @param pollID ID of poll to check */ getTotalTokensForWinners(pollID: BigNumber): Promise; /** * Returns number of tokens this user committed & revealed for given poll * @param voterAddress address of voter to check * @param pollID ID of poll to check * @param salt Salt used by voter for this poll */ getNumPassingTokens(pollID: BigNumber, salt: BigNumber, voter: EthAddress): Promise; getNumLosingTokens(pollID: BigNumber, salt: BigNumber, voter: EthAddress): Promise; getNumTokens(pollID: BigNumber, voter: EthAddress): Promise; /** * Did this poll pass? * @param pollID ID of poll to check */ isPollPassed(pollID: BigNumber): Promise; /** * Gets the pollID of the poll with most tokens less than tokens specified. * This is used to insert the new pollID in the correct position of list. * @param tokens number of tokens being committed this vote * @param account account to check pollID for */ getPrevPollID(tokens: BigNumber, pollID: BigNumber, account?: EthAddress): Promise; getPoll(pollID: BigNumber): Promise; }