Plugin for using Ledger with dai.js in a browser environment.
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts initial commit Aug 30, 2018
src prettier now set to single quotes Nov 27, 2018
.babelrc initial commit Aug 30, 2018
.eslintrc initial commit Aug 30, 2018
.gitignore initial commit Aug 30, 2018
README.md npm publish instructions on readme Nov 29, 2018
package.json version bump 0.9.4 Nov 29, 2018
yarn.lock initial commit Aug 30, 2018

README.md

dai-plugin-ledger-web

A Dai.js plugin for using Ledger in a browser environment.

Example usage

import LedgerPlugin from '@makerdao/dai-plugin-ledger-web';
import Maker from '@makerdao/dai';

const maker = Maker.create('http', {
  plugins: [LedgerPlugin],
  accounts: {
    myLedger1: { type: 'ledger' }
  }
});

// this will not resolve until the Ledger account is set up
await maker.authenticate();

// or you can defer setting the account up until later
await maker.addAccount('myLedger2', { type: 'ledger' });

Options

  • accountsLength: Set this to the number of accounts to fetch. Must also set choose if greater than 1; see below. (Default: 1)
  • accountsOffset: Set this to the index offset number to fetch accounts from (Default: 0)
  • path: Set this to the derivation path to use. (Default: "44'/60'/0'/0/0")
  • legacy: Set this to use the old Ledger address derivation method. More info

Listing multiple accounts

await maker.addAccount('myLedger', {
  type: 'ledger',
  accountsLength: 10,
  choose: (addresses, callback) => {
    // show the list of addresses in your UI and have the user pick one; then
    // call the callback with the chosen address. `addAccount` will not resolve
    // until the callback is called. if you pass an error object as the first
    // argument, `addAccount` will throw it.
    setTimeout(() => callback(null, addresses[7]), 20000);
  }
});

Try the demo app

You can find an example of this plugin being used in an app here.

Publishing to NPM

yarn
// version bump on package.json
yarn build
cd /dist
npm publish