GithubHelp home page GithubHelp logo

isabella232 / dai-plugin-ledger-web Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makerdao/dai-plugin-ledger-web

0.0 0.0 0.0 541 KB

Plugin for using Ledger with dai.js in a browser environment.

License: MIT License

Shell 3.80% JavaScript 96.20%

dai-plugin-ledger-web's Introduction

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 = await 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

dai-plugin-ledger-web's People

Contributors

adrianleb avatar dependabot[bot] avatar levity avatar padraic-o-mhuiris avatar tyler17 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.