0.1.25-patch.1 • Published 5 years ago

@kosu/gov-portal-helper v0.1.25-patch.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Classes

Typedefs

Gov

Kind: global class

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

ParamTypeDescription
weiBigNumber | stringthe 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

ParamTypeDescription
etherBigNumber | stringthe 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

ParamTypeDescription
challengeIdBigNumberthe pollId of the challenge, as a string
valuestringthe vote value, "1" to vote for the challenge, "0" to vote against
amountBigNumberthe 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

ParamTypeDescription
challengeIdBigNumberthe 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.

ParamTypeDescription
challengeIdBigNumberthe 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

ParamTypeDescription
challengeIdBigNumberthe 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)

ParamTypeDescription
blockNumbernumberthe 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

ParamTypeDescription
blockNumbernumberthe 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

ParamTypeDescription
challengeIdstring | number | BigNumberthe 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.

ParamTypeDescription
addressstringEthereum 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

NameTypeDescription
ownerstringthe Ethereum address of the validator
stakeSizeBigNumberthe staked balance (in wei) of the validator
dailyRewardBigNumberthe approximate daily reward to the validator (in wei)
confirmationUnixnumberthe unix timestamp of the block the validator was confirmed in
powerBigNumberthe validators approximate current vote power on the Kosu network
detailsstringarbitrary details provided by the validator when they applied

Proposal

Kind: global typedef
Properties

NameTypeDescription
ownerstringthe Ethereum address of the applicant
stakeSizeBigNumberthe total stake the applicant is including with their proposal (in wei)
dailyRewardBigNumberthe approximate daily reward (in wei) the applicant is requesting
powerBigNumberthe estimated vote power the listing would receive if accepted right now
detailsstringarbitrary details provided by the applicant with their proposal
acceptUnixnumberthe approximate unix timestamp the listing will be accepted, if not challenged

StoreChallenge

Kind: global typedef
Properties

NameTypeDescription
listingOwnerstringthe Ethereum address of the owner of the challenged listing
listingStakeBigNumberthe total stake of the challenged listing
listingPowerBigNumberthe current vote power of the listing (if they are a validator)
challengerstringthe Ethereum address of the challenger
challengeIdBigNumberthe incremental ID of the current challenge
challengerStakeBigNumberthe staked balance of the challenger
challengeEndUnixnumberthe estimated unix timestamp the challenge ends at
challengeEndBigNumberthe block at which the challenge reveal period ends
totalTokensBigNumberif finalized, the total number of tokens from participating voters
winningTokensBigNumberif finalized, the number of tokens that voted on the winning side
resultstringthe final result of the challenge; "passed", "failed", or null if not finalized
challengeTypestringthe type of listing the challenge is against, either a "validator" or a "proposal"
listingDetailsstringdetails provided by the listing holder
challengeDetailsstringdetails provided by the challenger

PastChallenge

Kind: global typedef
Properties

NameTypeDescription
balanceBigNumberthe number of tokens (in wei) staked in the challenge
challengeEndBigNumberthe block the challenge ends at
challengerstringthe Ethereum address of the challenger
detailsstringadditional details provided by the challenger
finalizedbooleantrue if the challenge result is final, false if it is ongoing
listingKeystringthe key that corresponds to the challenged listing
listingSnapshotListingSnapshotan object representing the state of the challenged listing at the time of challenge
passedbooleantrue if the challenge was successful, false otherwise
pollIdBigNumberthe incremental ID used to identify the poll
voterTotalBigNumberthe total number of tokens participating in the vote
winningTokensBigNumberthe total number of tokens voting for the winning option

ListingSnapshot

Kind: global typedef
Properties

NameTypeDescription
applicationBlockBigNumberthe block the listing application was submitted
confirmationBlockBigNumberthe block the listing was confirmed (0 if unconfirmed)
currentChallengeBigNumberthe ID of the current challenge against the listing
detailsstringarbitrary details provided by the listing applicant
exitBlockBigNumberthe block (if any) the listing exited at
lastRewardBlockBigNumberthe last block the listing owner claimed rewards for
ownerstringthe Ethereum address of the listing owner
rewardRateBigNumberthe number of tokens (in wei) rewarded to the listing per reward period
stakedBalanceBigNumberthe number of tokens staked by the listing owner (in wei)
statusnumberthe number representing the listing status (0: no listing, 1: proposal, 2: validator, 3: in-challenge, 4: exiting)
tendermintPublicKeystringthe 32 byte Tendermint public key of the listing holder

Vote

Kind: global typedef
Properties

NameTypeDescription
idBigNumberthe challengeId the vote is for
valuestringthe vote value (should be "1" or "0" for challenge votes)
saltstringa secret string used to hash the vote; must use same salt in commit as reveal
encodedstringthe encoded vote, as passed to the contract system
commitTxHashstringthe transaction hash of the commit transaction
revealTxHashstringthe transaction hash of the reveal transaction

ChallengeInfo

Kind: global typedef
Properties

NameTypeDescription
challengeStartnumberthe block at which the challenge was initiated, and when the commit period starts
endCommitPeriodnumberthe block the commit period ends, and the reveal period starts
challengeEndnumberthe block the reveal period ends, and the challenge finalizes

PastGovernanceActivity

Kind: global typedef
Properties

NameTypeDescription
typestringEither "CHALLENGE_BY" for created challenges, "CHALLENGE_AGAINST" for challenges against a user, and "PROPOSAL" for created listings
resultstringEither "PENDING" for active, "ACCEPTED" for successful listings and challenges, and "REJECTED" for failed challenges and applications
actionablebooleanIndicates if some on-chain action can be taken to change the governance activity state
challengeIdnumberIf present, indicates the challenge ID associated with the activity
listingPubKeystringThe public key of the listing (proposal or challenged proposal)
0.1.25-patch.1

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago