Git Product home page Git Product logo

digixglobal--react-ledger-container's Introduction

React Ledger Container (WIP)

⚠️ Works with the 1.2+ Ledger firmware. EIP155 Replay protection only works with 1.3+

❗️ Use with cation; Developer accepts no liability for loss of funds!

React component that implements the Ledger Wallet API.

Features

  • Ledger Wallet config automatically passed as props
    • version
    • arbitraryDataEnabled
    • eip155
  • Auto-configured ethLedger methods injection
    • signTransaction
    • getAddress (TODO)
    • signPersonalMessage (TODO)
  • More convenient API
    • Pass transaction object rather than rawTx (and handle compatibility)
    • Automatically self-configures raw transaction data based on device version
    • Polls for connectivity, with intelligent poll times for enhanced UX
  • expect option for validating address
  • onReady event handler for triggering actions

Example

import React, { PropTypes, Component } from 'react';
import LedgerContianer from '@digix/react-ledger-container';

export default class SignLedgerTransaction extends Component {
  constructor(props) {
    super(props);
    this.handleSign = this.handleSign.bind(this);
  }
  handleSign({ signTransaction }) {
    // txData = { to, nonce, gasPrice, value, data, gas } (w/ optional `from` for validating)
    const { txData, account, publishTransaction } = this.props;
    // kdPath = "44'/60'/0'/0";
    const { kdPath } = account;
    // signTransaction method will show the signing UI on ledger screen
    signTransaction(kdPath, txData).then((signedTx) => {
      publishTransaction({ signedTx });
    })
  }
  render() {
    const { kdPath, address } = this.props.account;
    return (
      <LedgerContianer
        expect={{ kdPath, address }}
        onReady={this.handleSign}
        renderReady={({ config }) => <p>Ready to sign! Using ledger version {config.version}.</p>}
      />
    );
  }
}

SignLedgerTransaction.propTypes = {
  publishTransaction: PropTypes.func.isRequired,
  account: PropTypes.object.isRequired,
  txData: PropTypes.object.isRequired,
};

TODO

  • Test with new version of Ledger firmware
  • getAddress & signPersonalMessage
  • Support for Bitcoin API

digixglobal--react-ledger-container's People

Contributors

istoramandiri avatar mrenoon avatar

Watchers

 avatar  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.