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

@wavesenterprise/voting-blockchain-tools

v1.3.1

Published

## Installation

Downloads

16

Readme

Voting blockchain tools

Installation

npm i @wavesenterprise/voting-blockchain-tools

Peer dependencies

keccak - for waves cryptography
@wavesenterprise/crypto-gost-js - for gost cryptography
crypto-js - for old browsers
axios - for transaction broadcasting

Seed generation

For browsers with BigInt support

import {
  SeedManager,
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/common'
import {
  WavesBrowserCrypto,
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/waves'
import {
  GostCrypto
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/gost'

const networkByte = 84

const wavesSeedManager = new SeedManager({
  networkByte,
  keysModule: WavesBrowserCrypto,
})

const gostSeedManager = new SeedManager({
  networkByte,
  keysModule: GostCrypto,
})

For old browsers (without BigInt support)

import {
  SeedManager,
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/common'
import {
  WavesLegacyCrypto,
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/waves'
import {
  GostCrypto
} from '@wavesenterprise/voting-blockchain-tools/browser/seed/gost'

const networkByte = 84
const wavesSeedManager = new SeedManager({
  networkByte,
  keysModule: WavesLegacyCrypto,
})

const gostSeedManager = new SeedManager({
  networkByte,
  keysModule: GostCrypto,
})

NodeJS

import {
  SeedManager,
} from '@wavesenterprise/voting-blockchain-tools/node/seed/common'
import {
  WavesNodeCrypto,
} from '@wavesenterprise/voting-blockchain-tools/node/seed/waves'
import {
  GostCrypto
} from '@wavesenterprise/voting-blockchain-tools/node/seed/gost'

const networkByte = 84
const wavesSeedManager = new SeedManager({
  networkByte,
  keysModule: WavesNodeCrypto,
})

const gostSeedManager = new SeedManager({
  networkByte,
  keysModule: GostCrypto,
})

Usage

await wavesSeedManager.create()
/*{
  phrase: 'decade lawn please train problem raise glare survey web fit fence recall curtain usage wine',
  address: '3Mp3twdi87cCVCcGQuYVUVcmb4k66NHTp52',
  keyPair: {
    privateKey: 'Cu456MsAK8MEwyzh4oL1yboSX3brTqcDsmEwjDUxVVbd',
    publicKey: '5RcKNdFR6P8mk2xURroNkJigjuRfsedAfy6h35WcEqF1'
  }
}*/

Encrpytion

For browsers with window.crypto.subtle support

import {
  BrowserEncryption,
} from '@wavesenterprise/voting-blockchain-tools/browser/encryption'

const encryptedStr = BrowserEncryption.encrypt('nice shiny string', 'strong password')

const originalStr = BrowserEncryption.decrypt(encryptedStr, 'strong password')

For old browsers (without window.crypto.subtle support)

import {
  LegacyEncryption,
} from '@wavesenterprise/voting-blockchain-tools/browser/encryption'

const encryptedStr = LegacyEncryption.encrypt('nice shiny string', 'strong password')

const originalStr = LegacyEncryption.decrypt(encryptedStr, 'strong password')

NodeJS

import {
  NodeEncryption,
} from '@wavesenterprise/voting-blockchain-tools/node/encryption'

const encryptedStr = NodeEncryption.encrypt('nice shiny string', 'strong password')

const originalStr = NodeEncryption.decrypt(encryptedStr, 'strong password')

Transactions

List of available transactions

3. Issue:

import { IssueTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new IssueTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  name: 'Some name',
  description: 'Some description',
  quantity: 100000,
  decimals: 2,
  reissuable: true,
  fee: 1000000,
})

4. Transfer:

import { TransferTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new TransferTx({
  senderPublicKey: keys.publicKey,
  fee: 1000000,
  recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  amount: 1000000,
  attachment: '123',
})

5. Reissue:

import { ReissueTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new ReissueTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  assetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
  quantity: 10000,
  reissuable: true,
  fee: 1000000,
})

6. Burn:

import { BurnTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new BurnTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  assetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
  amount: 10000,
  fee: 1000000,
})

8. Lease:

import { LeaseTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new LeaseTx({
  assetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
  senderPublicKey: keys.publicKey,
  recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  amount: 10000,
  fee: 1000000,
})

9. LeaseCancel:

import { LeaseCancelTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new LeaseCancelTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  fee: 1000000,
  leaseId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
})

10. CreateAlias:

import { CreateAliasTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new CreateAliasTx({
  senderPublicKey: keys.publicKey,
  alias: 'Some alias',
  fee: 1000000,
  feeAssetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
})

11. MassTransfer:

import { MassTransferTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new MassTransferTx({
  senderPublicKey: keys.publicKey,
  fee: 6000000,
  transfers: [
    { amount: 1000000, recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF' },
  ],
  attachment: '',
})

12. Data:

import { DataTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new DataTx({
  senderPublicKey: keys.publicKey,
  authorPublicKey: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  data: [{
    type: 'string',
    key: 'vote',
    value: 'Some random text',
  }],
  fee: 10000000,
})

13. SetScript:

import { SetScriptTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new SetScriptTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  script: 'script encoded in base64',
  name: 'Script name',
  description: 'Script description',
  fee: 10000000,
})

14. SponsorFee:

import { SponsorFeeTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new SponsorFeeTx({
  senderPublicKey: keys.publicKey,
  assetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
  isEnabled: true,
  fee: 10000000,
})

15. SetAssetScript:

import { SetAssetScriptTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new SetAssetScriptTx({
  chainId: 84,
  senderPublicKey: keys.publicKey,
  assetId: '5KWHYsx6A8fZSkiJLKDhLZW9KrPUKx9UsVrFix4Qzymj',
  script: 'script encoded in base64',
  fee: 10000000,
})

102. Permit:

import { PermitTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new PermitTx({
  senderPublicKey: keys.publicKey,
  target: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  fee: 10000000,
  opType: 'add',
  role: 'contract_developer',
  duplicate_timestamp: Date.now(),
  dueTimestamp: Date.now() + 60 * 1000,
})

103. CreateContract:

import { CreateContractTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new CreateContractTx({
  senderPublicKey: keys.publicKey,
  image: 'registry.wvservices.com/confidential-voting/voting-contract-js:VOTE-871-change-dkg-complaint',
  imageHash: '384a3f767d83c62b0e9f0f6b7831a57171ce14a7a0ecd5c8383fc732496c7eb9',
  contractName: 'test',
  fee: 100000000,
  params: [{
    type: 'string',
    key: 'vote',
    value: 'Some random text',
  }],
  validationPolicy: { type: 'any' },
  apiVersion: '1.0',
  payments: [{
    assetId: '5rviwnMmmCirkV1eDy1WAQVzRVofuuEHAH9HUCYnMFAS',
    amount: 10000000,
  }]
})

104. CallContract:

import { CallContractTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new CallContractTx({
  senderPublicKey: keys.publicKey,
  contractId: '5rviwnMmmCirkV1eDy1WAQVzRVofuuEHAH9HUCYnMFAS',
  fee: 10000000,
  contractVersion: 1,
  params: [{
    type: 'string',
    key: 'vote',
    value: 'Some random text',
  }],
  payments: [],
})

106. DisableContract:

import { DisableContractTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new DisableContractTx({
  senderPublicKey: keys.publicKey,
  contractId: '5rviwnMmmCirkV1eDy1WAQVzRVofuuEHAH9HUCYnMFAS',
  fee: 10000000,
})

107. UpdateContract:

import { UpdateContractTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new UpdateContractTx({
  senderPublicKey: keys.publicKey,
  contractId: '5rviwnMmmCirkV1eDy1WAQVzRVofuuEHAH9HUCYnMFAS',
  image: 'registry.wvservices.com/confidential-voting/voting-contract-js:VOTE-871-change-dkg-complaint',
  imageHash: '384a3f767d83c62b0e9f0f6b7831a57171ce14a7a0ecd5c8383fc732496c7eb9',
  fee: 100000000,
  validationPolicy: { type: 'any' },
  apiVersion: '1.0',
})

111. RegisterNode:

import { RegisterNodeTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new RegisterNodeTx({
  senderPublicKey: keys.publicKey,
  targetPubKey: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  nodeName: 'Node name',
  opType: 'add',
  fee: 10000000,
})

112. CreatePolicy:

import { CreatePolicyTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new CreatePolicyTx({
  senderPublicKey: keys.publicKey,
  policyName: 'Policy name',
  description: 'Policy description',
  recipients: ['3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF'],
  owners: [keys.publicKey],
  fee: 10000000,
})

113. UpdatePolicy:

import { UpdatePolicyTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new UpdatePolicyTx({
  senderPublicKey: keys.publicKey,
  policyId: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEN',
  recipients: ['3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF'],
  owners: [keys.publicKey],
  opType: 'add',
  fee: 10000000,
})

114. PolicyDataHash:

import { PolicyDataHashTx } from '@wavesenterprise/voting-blockchain-tools/transactions'

new PolicyDataHashTx({
  senderPublicKey: keys.publicKey,
  dataHash: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydED',
  policyId: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEA',
  fee: 10000000,
})

120. Atomic:

import {
  CallContractTx,
  TransferTx,
  AtomicTx,
  TransactionBroadcaster
} from '@wavesenterprise/voting-blockchain-tools/transactions'
import { WavesSignature } from '@wavesenterprise/voting-blockchain-tools/node/signature'

const transfer = new TransferTx({
  senderPublicKey: keys.publicKey,
  fee: 1000000,
  recipient: '3MzLbfKMACfUWt3W3vAAcZ6avcqtrzGkKhU',
  amount: 1000000,
  attachment: '123',
  atomicBadge: { trustedSender: keys.address },
})

const callContract = new CallContractTx({
  senderPublicKey: keys.publicKey,
  contractId: '5rviwnMmmCirkV1eDy1WAQVzRVofuuEHAH9HUCYnMFAS',
  fee: 10000000,
  contractVersion: 1,
  params: [{
    type: 'string',
    key: 'vote',
    value: 'Some random text',
  }],
  atomicBadge: { trustedSender: keys.address },
})

const transactionBroadcaster = new TransactionBroadcaster({ signModule: WavesSignature, nodeAddress })
const signedTransfer1 = await transactionBroadcaster.getSignedTx(transfer, keys, { addTxId: true })
const signedContactCall = await transactionBroadcaster.getSignedTx(callContract, keys, { addTxId: true })

const tx = new AtomicTx({
  senderPublicKey: keys.publicKey,
  transactions: [signedTransfer1, signedContactCall],
})

Sign and broadcast transaction

import { TransferTx, TransactionBroadcaster } from '@wavesenterprise/voting-blockchain-tools/transactions'

// for node
import { WavesSignature } from '@wavesenterprise/voting-blockchain-tools/node/signature'
// for browser 
import { WavesSignature } from '@wavesenterprise/voting-blockchain-tools/browser/signature'

// P.S GostSignature for gost

const networkByte = 84
const transactionSender = new TransactionBroadcaster({
  nodeAddress: 'http://localhost:6863',
  signModule: WavesSignature,
  networkByte,
})
const keyPair = {
  privateKey: 'Cu456MsAK8MEwyzh4oL1yboSX3brTqcDsmEwjDUxVVbd',
  publicKey: '5RcKNdFR6P8mk2xURroNkJigjuRfsedAfy6h35WcEqF1'
}

const tx = new TransferTx({
  senderPublicKey: keyPair.publicKey,
  fee: 1000000,
  recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
  amount: 1000000,
  attachment: '123',
})

const signedTx = transactionSender.getSignedTx(tx, keyPair)
console.log(signed)
// {
//   type: 4,
//     version: 3,
//   senderPublicKey: '843bhQtpR1yaCMAzqJnZN5cWPqLngtDNqXq6h8Z5tAkj',
//   fee: 1000000,
//   recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
//   amount: 1000000,
//   attachment: '123',
//   timestamp: 1634226194396,
//   proofs: [
//   '3Pgjq1LBJUM8jqP83Z8cnt6GqrJAsdaRAUkfj24fqFHrMSCsGFGqyUPDBCYSWEjiTBFHfmyD4yfANujHkTsLzgb6'
// ]
// }
const brodcastRes = transactionSender.broadcast(tx, keyPair)
console.log(brodcastRes)
// {
//   senderPublicKey: '843bhQtpR1yaCMAzqJnZN5cWPqLngtDNqXq6h8Z5tAkj',
//     amount: 1000000,
//   fee: 1000000,
//   type: 4,
//   version: 3,
//   atomicBadge: null,
//   attachment: '123',
//   sender: '3MzLbfKMACfUWt3W3vAAcZ6avcqtrzGkKhU',
//   feeAssetId: null,
//   proofs: [
//   '5S5ddCQDgpcQ4ETvFUhE6NCB1CXGiKagzYS8jU4EKTo9m6Nk1gPvxsizDa9rYgUBXEwA4CBsAQHR5bBF2u9rjGKr'
// ],
//   assetId: null,
//   recipient: '3NA9hBGoVPfJVybremiFgWN8REi9oiDydEF',
//   id: '8USXQ36CHMuXbF2371YkvzyjL7p1gMJVyuc9TXChZASA',
//   timestamp: 1634226194396
// }