@kosu/gov-portal-helper v0.1.25-patch.1
Classes
Typedefs
Gov
Kind: global class
- Gov
- new Gov()
- instance
- .init()
- .currentProposals() ⇒ Map.<Proposal>
- .currentValidators() ⇒ Map.<Validator>
- .currentChallenges() ⇒ Map.<StoreChallenge>
- .weiToEther(wei) ⇒ string
- .etherToWei(ether) ⇒ string
- .commitVote(challengeId, value, amount) ⇒ Promise.<string>
- .hasCommittedVote(challengeId) ⇒ boolean
- .revealVote(challengeId) ⇒ Promise.<string>
- .hasRevealedVote(challengeId) ⇒ boolean
- .estimateFutureBlockTimestamp(blockNumber) ⇒ Promise.<number>
- .getPastBlockTimestamp(blockNumber) ⇒ Promise.<number>
- .getHistoricalChallenges() ⇒ Promise.<Array.<PastChallenge>>
- .getChallengeInfo(challengeId) ⇒ Promise.<ChallengeInfo>
- .currentBlockNumber() ⇒ number
- .getPastGovernanceActivity(address) ⇒ Promise.<Array.<PastGovernanceActivity>>
- static
new Gov()
gov.init()
Kind: instance method of Gov
gov.currentProposals() ⇒ Map.<Proposal>
Kind: instance method of Gov
Returns: Map.<Proposal> - a map where the key is the listing public key, and the value is a proposal object
Example
const proposals = gov.currentProposals();
gov.currentValidators() ⇒ Map.<Validator>
Kind: instance method of Gov
Returns: Map.<Validator> - a map where the key is the listing public key, and the value is a validator object
Example
const validators = gov.currentValidators();
gov.currentChallenges() ⇒ Map.<StoreChallenge>
Kind: instance method of Gov
Returns: Map.<StoreChallenge> - a map where the key is the listing public key, and the value is a challenge object
Example
const challenges = gov.currentChallenges();
gov.weiToEther(wei) ⇒ string
Kind: instance method of Gov
Returns: string - the same amount in ether, string used for precision
Param | Type | Description |
---|---|---|
wei | BigNumber | string | the token amount in wei to convert |
Example
gov.weiToEther("100000000000000000000"); // > "100"
gov.weiToEther(100000000000000000000); // > "100"
gov.etherToWei(ether) ⇒ string
Kind: instance method of Gov
Returns: string - the same amount in wei, string used for precision
Param | Type | Description |
---|---|---|
ether | BigNumber | string | the token amount to convert |
Example
gov.etherToWei(10); // > "10000000000000000000"
gov.etherToWei("1"); // > "1000000000000000000"
gov.commitVote(challengeId, value, amount) ⇒ Promise.<string>
Kind: instance method of Gov
Returns: Promise.<string> - the transaction hash of the commit tx
Param | Type | Description |
---|---|---|
challengeId | BigNumber | the pollId of the challenge, as a string |
value | string | the vote value, "1" to vote for the challenge, "0" to vote against |
amount | BigNumber | the number of tokens (in wei) to commit in the vote |
Example
// we are looking at challenge #13, and want to vote AGAINST it with 10 tokens
const pollId = new BigNumber(13);
const amount = new BigNumber(gov.etherToWei("10"));
const value = "0";
// will prompt for MetaMask signature
const commitVoteTxId = await gov.commitVote(pollId, value, amount);
// ... some time passes, we now want to reveal ...
// load vote from cookie and reveal
const revealTxId = await gov.revealVote(new BigNumber("13"));
// ... wait for Tx's to confirm or whatever, etc.
gov.hasCommittedVote(challengeId) ⇒ boolean
Kind: instance method of Gov
Returns: boolean - the boolean representing the presence of a commit vote
Param | Type | Description |
---|---|---|
challengeId | BigNumber | the challenge to check for a stored commit vote for |
gov.revealVote(challengeId) ⇒ Promise.<string>
Kind: instance method of Gov
Returns: Promise.<string> - the transaction hash of the reveal tx.
Param | Type | Description |
---|---|---|
challengeId | BigNumber | the challenge to reveal a stored vote for |
gov.hasRevealedVote(challengeId) ⇒ boolean
Kind: instance method of Gov
Returns: boolean - the boolean representing the presence of a reveal vote
Param | Type | Description |
---|---|---|
challengeId | BigNumber | the challenge to check for a stored reveal vote for |
gov.estimateFutureBlockTimestamp(blockNumber) ⇒ Promise.<number>
Kind: instance method of Gov
Returns: Promise.<number> - the block's estimated UNIX timestamp (in seconds)
Param | Type | Description |
---|---|---|
blockNumber | number | the block number to estimate the timestamp for |
Example
const block = 6102105;
const unixTs = gov.estimateFutureBlockTimestamp(block);
// use as a normal date object (multiply by 1000 to get ms)
const blockDate = new Date(ts * 1000);
gov.getPastBlockTimestamp(blockNumber) ⇒ Promise.<number>
Kind: instance method of Gov
Returns: Promise.<number> - the Unix timestamp of the specified blockNumber
Param | Type | Description |
---|---|---|
blockNumber | number | the block to get the unix timestamp for |
Example
await gov.getPastBlockTimestamp(515237); // > 1559346404
gov.getHistoricalChallenges() ⇒ Promise.<Array.<PastChallenge>>
Kind: instance method of Gov
Returns: Promise.<Array.<PastChallenge>> - all historical challenges.
gov.getChallengeInfo(challengeId) ⇒ Promise.<ChallengeInfo>
Kind: instance method of Gov
Returns: Promise.<ChallengeInfo> - the block numbers for this challenge
Param | Type | Description |
---|---|---|
challengeId | string | number | BigNumber | the ID of the challenge to query |
Example
const info = await gov.getChallengeInfo(new BigNumber(1));
const currentBlock = await gov.currentBlockNumber();
if (currentBlock < endCommitPeriod && currentBlock >= challengeStart) {
// in "commit" period; voters may submit votes
} else if (currentBlock >= endCommitPeriod && currentBlock <= challengeEnd) {
// in "reveal" period; voters may reveal votes
} else {
// challenge has ended (or issues with block numbers)
}
gov.currentBlockNumber() ⇒ number
Kind: instance method of Gov
Returns: number - The current (or most recent) Ethereum block height.
gov.getPastGovernanceActivity(address) ⇒ Promise.<Array.<PastGovernanceActivity>>
Kind: instance method of Gov
Returns: Promise.<Array.<PastGovernanceActivity>> - An array of snippets about past governance activity.
Param | Type | Description |
---|---|---|
address | string | Ethereum address of user to get past activity for. |
Gov.ZERO
Kind: static property of Gov
Gov.ONE
Kind: static property of Gov
Gov.ONE_HUNDRED
Kind: static property of Gov
Gov.BLOCKS_PER_DAY
Kind: static property of Gov
Validator
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
owner | string | the Ethereum address of the validator |
stakeSize | BigNumber | the staked balance (in wei) of the validator |
dailyReward | BigNumber | the approximate daily reward to the validator (in wei) |
confirmationUnix | number | the unix timestamp of the block the validator was confirmed in |
power | BigNumber | the validators approximate current vote power on the Kosu network |
details | string | arbitrary details provided by the validator when they applied |
Proposal
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
owner | string | the Ethereum address of the applicant |
stakeSize | BigNumber | the total stake the applicant is including with their proposal (in wei) |
dailyReward | BigNumber | the approximate daily reward (in wei) the applicant is requesting |
power | BigNumber | the estimated vote power the listing would receive if accepted right now |
details | string | arbitrary details provided by the applicant with their proposal |
acceptUnix | number | the approximate unix timestamp the listing will be accepted, if not challenged |
StoreChallenge
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
listingOwner | string | the Ethereum address of the owner of the challenged listing |
listingStake | BigNumber | the total stake of the challenged listing |
listingPower | BigNumber | the current vote power of the listing (if they are a validator) |
challenger | string | the Ethereum address of the challenger |
challengeId | BigNumber | the incremental ID of the current challenge |
challengerStake | BigNumber | the staked balance of the challenger |
challengeEndUnix | number | the estimated unix timestamp the challenge ends at |
challengeEnd | BigNumber | the block at which the challenge reveal period ends |
totalTokens | BigNumber | if finalized, the total number of tokens from participating voters |
winningTokens | BigNumber | if finalized, the number of tokens that voted on the winning side |
result | string | the final result of the challenge; "passed", "failed", or null if not finalized |
challengeType | string | the type of listing the challenge is against, either a "validator" or a "proposal" |
listingDetails | string | details provided by the listing holder |
challengeDetails | string | details provided by the challenger |
PastChallenge
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
balance | BigNumber | the number of tokens (in wei) staked in the challenge |
challengeEnd | BigNumber | the block the challenge ends at |
challenger | string | the Ethereum address of the challenger |
details | string | additional details provided by the challenger |
finalized | boolean | true if the challenge result is final, false if it is ongoing |
listingKey | string | the key that corresponds to the challenged listing |
listingSnapshot | ListingSnapshot | an object representing the state of the challenged listing at the time of challenge |
passed | boolean | true if the challenge was successful, false otherwise |
pollId | BigNumber | the incremental ID used to identify the poll |
voterTotal | BigNumber | the total number of tokens participating in the vote |
winningTokens | BigNumber | the total number of tokens voting for the winning option |
ListingSnapshot
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
applicationBlock | BigNumber | the block the listing application was submitted |
confirmationBlock | BigNumber | the block the listing was confirmed (0 if unconfirmed) |
currentChallenge | BigNumber | the ID of the current challenge against the listing |
details | string | arbitrary details provided by the listing applicant |
exitBlock | BigNumber | the block (if any) the listing exited at |
lastRewardBlock | BigNumber | the last block the listing owner claimed rewards for |
owner | string | the Ethereum address of the listing owner |
rewardRate | BigNumber | the number of tokens (in wei) rewarded to the listing per reward period |
stakedBalance | BigNumber | the number of tokens staked by the listing owner (in wei) |
status | number | the number representing the listing status (0: no listing, 1: proposal, 2: validator, 3: in-challenge, 4: exiting) |
tendermintPublicKey | string | the 32 byte Tendermint public key of the listing holder |
Vote
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | BigNumber | the challengeId the vote is for |
value | string | the vote value (should be "1" or "0" for challenge votes) |
salt | string | a secret string used to hash the vote; must use same salt in commit as reveal |
encoded | string | the encoded vote, as passed to the contract system |
commitTxHash | string | the transaction hash of the commit transaction |
revealTxHash | string | the transaction hash of the reveal transaction |
ChallengeInfo
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
challengeStart | number | the block at which the challenge was initiated, and when the commit period starts |
endCommitPeriod | number | the block the commit period ends, and the reveal period starts |
challengeEnd | number | the block the reveal period ends, and the challenge finalizes |
PastGovernanceActivity
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
type | string | Either "CHALLENGE_BY" for created challenges, "CHALLENGE_AGAINST" for challenges against a user, and "PROPOSAL" for created listings |
result | string | Either "PENDING" for active, "ACCEPTED" for successful listings and challenges, and "REJECTED" for failed challenges and applications |
actionable | boolean | Indicates if some on-chain action can be taken to change the governance activity state |
challengeId | number | If present, indicates the challenge ID associated with the activity |
listingPubKey | string | The public key of the listing (proposal or challenged proposal) |
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago