Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@lunie/cosmos-ledger

luniehq349MIT0.1.8TypeScript support: included

provide simple Ledger tooling for the Cosmos Ledger App with user friendly errors

cosmos, cosmos.network, cosmos wallet, cosmos signer, ledger, cosmos javascript, cosmos sdk, cosmos-sdk

readme

Cosmos Ledger

Cosmos Ledger is a library for interacting with the Cosmos Ledger Nano App. It provides a developer-friendly interface and user friendly error messages for an improved Ledger Nano development experience.

This library is based on ledger-cosmos-js by Juan Leni who also implemented the official Cosmos Ledger Nano App.

Thank you Juan! 🙌

Installation

yarn add @lunie/cosmos-ledger

Usage

Signing with the Ledger Nano

import Ledger from "@lunie/cosmos-ledger"

// generate messages with "@lunie/cosmos-api"
const signMessage = {} || ``
const ledger = await Ledger().connect()
const signature = await ledger.sign(signMessage)

Using with cosmos-api

import Ledger from "@lunie/cosmos-ledger"
import Cosmos from "@lunie/cosmos-api"

const privateKey = Buffer.from(...)
const publicKey = Buffer.from(...)

// init cosmos API object
const cosmos = Cosmos(API_URL, ADDRESS)

// create a message
const msg = cosmos
  .MsgSend({
    toAddress: 'cosmos1abcd09876', 
    amounts: [{ denom: 'stake', amount: 10 }]
  })

// create a signer
const ledgerSigner = async (signMessage) => {
  const ledger = new Ledger()
  await ledger.connect()
  const publicKey = await ledger.getPubKey()
  const signature = await ledger.sign(signMessage)

  return {
    signature,
    publicKey
  }
}

// send the transaction
const { included } = await msg.send({ gas: 200000 }, ledgerSigner)

// wait for the transaction to be included in a block
await included()

Constructor options

Ledger(
  { testModeAllowed = false },
  hdPath = [44, 118, 0, 0, 0], // HDPATH
  hrp = 'cosmos', // BECH32PREFIX
);

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[0.1.8] - 2020-05-21

Security

  • Fix resolution of dependency @faboweb

Code Improvements

  • Updated several libraries including Ledger transportation @faboweb

[0.1.7] - 2020-02-01

Fixed

  • Unknown errors were not bubbled up to the user @faboweb

[0.1.6] - 2020-01-29

Repository

  • Updated transport dependencies @faboweb

[0.1.5] - 2020-01-07

Fixed

  • reenable confirmLedgerAddress @faboweb

[0.1.4] - 2019-12-07

Added

  • Handle outdated browser error @faboweb

Fixed

  • Show correct feature flag URL for HID support @faboweb

[0.1.3] - 2019-12-04

Changed

  • Handle the case were the Ledger is already used by another tab @faboweb

[0.1.2] - 2019-12-04

Fixed

  • Reduce requirement to app version 1.5.3 @faboweb

[0.1.1] - 2019-12-04

Fixed

  • Removes webpack as it didn't work properly with lazy loading dependencies @faboweb

[0.1.0] - 2019-12-04

Changed

  • #13 Switched to WebHID on Windows and WebUSB on OSX/Linux @faboweb

[0.0.7] - 2019-11-28

Changed

  • Support new Cosmos App v2 @faboweb

Repository

  • Updated ledger cosmos js dependency @faboweb

[0.0.6] - 2019-10-07

Repository

  • Reduced size of library @williamchong007

Fixed

  • Fixed address confirmation @faboweb

[0.0.4] - 2019-06-12

Fixed

  • Removed webusb due to lack of support @faboweb

[0.0.3] - 2019-06-05

Repository

  • Simplified and unified repository (using webpack) @faboweb
  • Migrated to cosmos ledger lib v2 @faboweb

[0.0.2] - 2019-05-24

Added

  • Extracted the Ledger Cosmos App wrapper from Lunie into this repo @faboweb