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

five-bells-wallet-client

v1.0.1

Published

Client for the five-bells-wallet

Downloads

12

Readme

npm standard circle

Installation

npm install five-bells-wallet-client --save

Usage

This is a client for the five-bells-wallet.

To use it with a hosted demo wallet, create an account on red.ilpdemo.org or blue.ilpdemo.org (it doesn't matter which because they're connected via the Interledger Protocol!).

Sending

const WalletClient = require('five-bells-wallet-client')

const sender = new WalletClient({
  address: '[email protected]',
  password: 'super-secret-password'
})

sender.on('connect', () => {
  console.log('Sender connected')
})

sender.send({
  destination: '[email protected]',
  destinationAmount: '0.01',
  message: 'Still love you!',
  onQuote: (payment) => {
    console.log('Received a quote; this will cost us: ' + payment.sourceAmount)
  }
}).then((payment) => {
  console.log('Sent payment:', payment)
  console.log('')
}).catch((err) => {
  console.error(err.stack)
})

Receiving

const WalletClient = require('five-bells-wallet-client')

const receiver = new WalletClient({
  address: '[email protected]',
  password: 'ultra-secret-password'
})

receiver.on('connect', () => {
  console.log('Receiver connected')
})

receiver.on('incoming', (payment) => {
  console.log('Received ' + payment.destinationAmount + ' bucks!')
  console.log(payment.sourceAccount + ' says: ' + payment.message)
})

API Reference

Client for connecting to the five-bells-wallet

WalletClient~WalletClient

Kind: inner class of WalletClient

new WalletClient(opts)

| Param | Type | Default | Description | | --- | --- | --- | --- | | opts | Object | | WalletClient options | | opts.address | String | | Account at five-bells-wallet in the form [email protected] | | opts.password | String | | Account password for five-bells-wallet | | [opts.autoConnect] | Boolean | true | Subscribe to WebSocket notifications automatically when new event listeners are added |

walletClient.connect() ⇒ Promise.<null>

Login to wallet and subscribe to WebSocket notifications

Kind: instance method of WalletClient
Returns: Promise.<null> - Resolves once client is subscribed

walletClient.isConnected() ⇒ Boolean

Check if the client is currently subscribed to wallet notifications

Kind: instance method of WalletClient

walletClient.getAccount() ⇒ Promise.<String>

Get the ledger account URI corresponding to the user's address

Kind: instance method of WalletClient

walletClient.disconnect() ⇒ null

Unsubscribe from wallet notifications

Kind: instance method of WalletClient

walletClient.payment(params) ⇒ Payment

Create a new Payment object

Kind: instance method of WalletClient

| Param | Type | Description | | --- | --- | --- | | params | PaymentParams | Payment parameters |

walletClient.send(params) ⇒ Promise.<Object>

Create a new Payment object, get a quote, and send the payment. Resolves when the payment is complete.

Kind: instance method of WalletClient
Returns: Promise.<Object> - Payment result

| Param | Type | Description | | --- | --- | --- | | params | PaymentParams | Payment parameters | | [params.onQuote] | function | Function to call when a quote is received | | [params.onSent] | function | Function to call when payment is sent (before it is complete) |

walletClient.convertAmount() ⇒ Promise.<BigNumber>

Convert the given destination amount into the local asset

Kind: instance method of WalletClient
Returns: Promise.<BigNumber> - Source amount as a BigNumber

| Param | Type | Description | | --- | --- | --- | | params.destinationAmount | String | Number | The destination amount to convert | | params.destinationAccount | String | Destination account to convert amount for |

Class for quoting and sending payments

Payment~Payment

Kind: inner class of Payment

new Payment(walletClient, params)

| Param | Type | Description | | --- | --- | --- | | walletClient | WalletClient | WalletClient instance used for quoting and sending | | params | PaymentParams | Payment parameters |

payment.quote() ⇒ Promise.<PaymentParams>

Get a quote to fill in either the sourceAmount or destinationAmount, whichever was not given.

Kind: instance method of Payment
Returns: Promise.<PaymentParams> - Original payment params with sourceAmount or destinationAmount filled in
Emits: quote

payment.send() ⇒ Promise.<Object>

Execute the payment

Kind: instance method of Payment
Returns: Promise.<Object> - Resolves when the payment is complete
Emits: sent

Payment~PaymentParams : Object

Kind: inner typedef of Payment

| Param | Type | Default | Description | | --- | --- | --- | --- | | destinationAccount | String | | Receiver account URI | | [sourceAmount] | String | Number | BigNumber | (quoted from destinationAmount) | Either sourceAmount or destinationAmount must be supplied | | [destinationAmount] | String | Number | BigNumber | (quoted from sourceAmount) | Either sourceAmount or destinationAmount must be supplied | | [message] | String | "" | Message to send to recipient |