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

partisia-zk-voting-js-interface

v1.0.6

Published

Source WASM and ABI for contract: `https://github.com/INSNetwork/zk-vote/tree/main/whitelisted_voting` `feature/6-vote-options` Paris testnet deploy: `https://testnet.mpcexplorer.com/address/03c0ae04c4ca74c3bafea9ca179f553aebb33f0e60`

Downloads

1

Readme

Voting Contract JavaScript Interface

Source WASM and ABI for contract: https://github.com/INSNetwork/zk-vote/tree/main/whitelisted_voting feature/6-vote-options Paris testnet deploy: https://testnet.mpcexplorer.com/address/03c0ae04c4ca74c3bafea9ca179f553aebb33f0e60

config testnet

const rpcConfig = {
  urlBaseGlobal: { url: 'https://node1.testnet.partisiablockchain.com', shard_id: 99 },
  urlBaseShards: [
    { url: 'https://node1.testnet.partisiablockchain.com/shards/Shard0', shard_id: 0 },
    { url: 'https://node1.testnet.partisiablockchain.com/shards/Shard1', shard_id: 1 },
    { url: 'https://node1.testnet.partisiablockchain.com/shards/Shard2', shard_id: 2 },
  ],
}
const addressContract = '03c0ae04c4ca74c3bafea9ca179f553aebb33f0e60'

Example Cast Vote directly on Chain with Private Key

;(async () => {
  const PRIVATE_KEY = '<64 len hex string>'
  const vote_option = 0 // 0, 1, 2, 3

  const votingContract = new VotingContract(addressContract, rpcConfig)
  const res = await votingContract.castVote(PRIVATE_KEY, vote_option, false, 35000)
  console.log('res', JSON.stringify(res, null, 2))

  // Expected output:
  /* 
 {
  "isFinalOnChain": true,
  "trxHash": "054832b76b571db97c5894e9bd2fbc12cdc3587e47e478ca6e99aa08d9357e09",
  "hasError": false,
  "eventTrace": [
    {
      "shardId": 0,
      "txHash": "81d21b600de076f6a592dea024f3a203e56dec2fa9d33888f1ee3135cce33cdb"
    },
    {
      "shardId": 2,
      "txHash": "edaa4e5a8cfbe7bef711e0b82d76d6e1e73b19efa13a7c5ca68a0e101f3b8910"
    }
  ]
} */
})()

Example Get Contract State

;(async () => {
  const votingContract = new VotingContract(addressContract, rpcConfig)
  const res = await votingContract.getContractState()
  console.log('res', JSON.stringify(res, null, 2))

  // Expected output:
  /* 
{
  "owner": "00b48ffc5d275744b14b609f80180c44ef77992aac",
  "whitelist": [
    "00b48ffc5d275744b14b609f80180c44ef77992aac",
    "00a7e41597691d4a46b1871a6d82b32c9a8329b563",
    "008e9ef52d67add43f6f2d00865a1128da83bd183b"
  ],
  "voting_info": {
    "name": "ZK Vote",
    "description": "Zero Knowledge",
    "voting_options": [
      {
        "title": "Option 1"
      },
      {
        "title": "Option 2"
      },
      {
        "title": "Option 3"
      },
      {
        "title": "Option 4"
      }
    ]
  },
  "current_voter_id": 3,
  "voters": [
    {
      "key": "008e9ef52d67add43f6f2d00865a1128da83bd183b",
      "value": 2
    },
    {
      "key": "00a7e41597691d4a46b1871a6d82b32c9a8329b563",
      "value": 3
    },
    {
      "key": "00b48ffc5d275744b14b609f80180c44ef77992aac",
      "value": 1
    }
  ],
  "voting_result": {
    "isSome": true,
    "innerValue": {
      "votes": [
        2,
        1,
        0,
        0
      ]
    }
  }
}
 */
})()

Example Get Whitelist addresses

;(async () => {
  const votingContract = new VotingContract(addressContract, rpcConfig)
  const res = await votingContract.getContractWhitelist()
  console.log('res', JSON.stringify(res, null, 2))

  // Expected output:
  /* 
[
  "00b48ffc5d275744b14b609f80180c44ef77992aac",
  "00a7e41597691d4a46b1871a6d82b32c9a8329b563",
  "008e9ef52d67add43f6f2d00865a1128da83bd183b"
]
 */
})()

Example Get Voting Results at end of vote

;(async () => {
  const votingContract = new VotingContract(addressContract, rpcConfig)
  const res = await votingContract.getContractResult()
  console.log('res', JSON.stringify(res, null, 2))

  // Expected output:
  /* 
 [
  2,
  1,
  0,
  0
] 
*/
})()