This repository hosts libraries to communicate with Ledger Nano / Nano S / Blue
applications. There are implementations for Node and Browser.
![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
Published Packages
Examples
Basic example:
import Transport from "@ledgerhq/hw-transport-node-hid";
import AppBtc from "@ledgerhq/hw-app-btc";
const getBtcAddress = async () => {
const transport = await Transport.create();
const btc = new AppBtc(transport);
const result = await btc.getWalletPublicKey("44'/0'/0'/0/0");
return result.bitcoinAddress;
};
getBtcAddress().then(a => console.log(a));
When using in a browser, make sure to set up "Browser mode" in the application
settings on the device if available.
More advanced examples:
Documentation
Contributing
Please read our contribution guidelines before getting
started.
You need to have a recent Node.js and
Yarn installed.
Install dependencies
yarn
Build
Build all packages
yarn build
Watch
Watch all packages change. Very useful during development to build only file that changes.
yarn watch
Lint
Lint all packages
yarn lint
Run Tests
First of all, this ensure the libraries are correctly building, and passing lint and flow:
yarn test
then to test on a real device...
Plug a device like the Nano S and open Bitcoin app.
Then run the test and accept the commands on the devices for the tests to
continue.
yarn test-node
You can also test on the web:
yarn test-browser
make sure to configure your device app with "Browser support" set to "YES".
Deploy
Checklist before deploying a new release:
- you have the right in the LedgerHQ org on NPM
- you have run
npm login
once (check npm whoami
) - Go to master branch
- your master point on LedgerHQ repository (check with
git config remote.$(git config branch.master.remote).url
and fix it with git branch --set-upstream master origin/master
) - you are in sync (
git pull
) and there is no changes in git status
- Run
yarn
once, there is still no changes in git status
deploy a new release
yarn run publish
then, go to /releases and create a release with change logs.
alternatively:
deploy a canary release (beta, etc)
yarn run publish -- -c beta
NB: if there is a new package, AFAIK you need to manually npm publish
it once on NPM.