npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kosu/gov-portal-helper

v0.1.25-patch.1

Published

Abstraction library for interacting with the Kosu contract system governance functions.

Downloads

42

Readme

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

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