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

@iov/cli

v2.5.0

Published

Command line interface for iov core

Downloads

122

Readme

@iov/cli

npm version

Installation and first run

The iov-cli executable is available via npm. We recommend local installations to your demo project. If you don't have one yet, just mkdir iov-cli-installation && cd iov-cli-installation && yarn init -y.

locally with yarn

$ yarn add @iov/cli --dev
$ ./node_modules/.bin/iov-cli

locally with npm

$ npm install @iov/cli --save-dev
$ ./node_modules/.bin/iov-cli

globally with yarn

$ yarn global add @iov/cli
$ iov-cli

globally with npm

$ npm install -g @iov/cli
$ iov-cli

How to use the IOV-Core command line interface

  1. Install @iov/cli and run iov-cli as shown above
  2. Start a local BNS blockchain as described in scripts/bnsd/README.md
  3. Play around as in the following example code:
> const profile = new UserProfile();
> const signer = new MultiChainSigner(profile);
> const { connection } = await signer.addChain(createBnsConnector("ws://localhost:23456"));
> const chainId = connection.chainId;

> chainId
'test-chain-esuZ1V'

> const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic("degree tackle suggest window test behind mesh extra cover prepare oak script"));

> profile.getIdentities(wallet.id)
[]

> const faucet = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0))

> faucet.pubkey
{ algo: 'ed25519',
  data:
   Uint8Array [
     224,
     42, ...

> profile.setIdentityLabel(faucet, "blockchain of value faucet")

> profile.getIdentities(wallet.id)
[ { chainId: 'test-chain-esuZ1V',
    pubkey: { algo: 'ed25519', data: [Uint8Array] } } ]

> const faucetAddress = signer.identityToAddress(faucet);
> faucetAddress
'tiov1k898u78hgs36uqw68dg7va5nfkgstu5z0fhz3f'
> (await connection.getAccount({ address: faucetAddress })).balance

> const recipient = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(1));
> const recipientAddress = signer.identityToAddress(recipient);

> .editor
const sendTx = await connection.withDefaultFee<SendTransaction>({
  kind: "bcp/send",
  chainId: faucet.chainId,
  sender: faucetAddress,
  recipient: recipientAddress,
  memo: "My first transaction",
  amount: {
    quantity: "33123456789",
    fractionalDigits: 9,
    tokenTicker: "CASH" as TokenTicker,
  },
}, faucetAddress);
^D
> await signer.signAndPost(faucet, sendTx);
> (await connection.getAccount({ address: recipientAddress })).balance;

> await connection.searchTx({ sentFromOrTo: faucetAddress });
> await connection.searchTx({ sentFromOrTo: recipientAddress });
  1. Congratulations, you sent your first money!
  2. Add an additional wallet
> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: undefined } ]

> const wallet2 = profile.addWallet(Secp256k1HdWallet.fromMnemonic("organ wheat manage mirror wish truly tool trumpet since equip flight bracket"))

> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: undefined },
  { id: 'FtIcQqMWcRpEIruk', label: undefined } ]

> profile.getIdentities(wallet.id)
[ { chainId: 'test-chain-esuZ1V',
    pubkey: { algo: 'ed25519', data: [Uint8Array] } } ]

> profile.getIdentities(wallet2.id)
[]

> profile.setWalletLabel(wallet.id, "ed")
> profile.setWalletLabel(wallet2.id, "secp")

> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: 'ed' },
  { id: 'FtIcQqMWcRpEIruk', label: 'secp' } ]
  1. Now store to disk
> const db = levelup(leveldown('./my_userprofile_db'))
> await profile.storeIn(db, "secret passwd")
  1. and restore
> const profileFromDb = await UserProfile.loadFrom(db, "secret passwd");
> profileFromDb
UserProfile {
  createdAt: 2018-07-04T16:07:14.583Z,
  keyring:
   Keyring { wallets: [ [Ed25519HdWallet], [Secp256k1HdWallet] ] },
  ...

Disconnecting

When you are done using a WebSocket connection, disconnect the connection

> (await connection.getAccount({ address: faucetAddress })).balance
[ { quantity: '123456755876543211',
    fractionalDigits: 9,
    tokenTicker: 'CASH' } ]
> connection.disconnect()
undefined
> (await connection.getAccount({ address: faucetAddress })).balance
Error: Socket was closed, so no data can be sent anymore.
    at ...

Faucet usage

When using a Testnet, you can use the IovFaucet to receive tokens.

In this example we connect to a public test network.

> const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
> mnemonic
'helmet album grow detail apology thank wire chef fame core private cargo'
> const profile = new UserProfile();
> const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));

> const signer = new MultiChainSigner(profile);
> const { connection } = await signer.addChain(createBnsConnector("ws://rpc-private-a-x-exchangenet.iov.one:16657"));
> const chainId = connection.chainId;

> const alice = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0));
> const aliceAddress = signer.identityToAddress(alice);

> const faucet = new IovFaucet("http://faucet.x-exchangenet.iov.one:8080/");

> await faucet.credit(aliceAddress, "IOV" as TokenTicker)
> (await connection.getAccount({ address: aliceAddress })).balance
[ { quantity: '10000000000',
    fractionalDigits: 9,
    tokenTicker: 'IOV' } ]

License

This package is part of the IOV-Core repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).