0.1.10 • Published 5 years ago

@digix/react-ledger-container v0.1.10

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
5 years ago

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
0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.2-alpha.3

7 years ago

0.0.2-alpha.2

7 years ago

0.0.2-alpha.1

7 years ago

0.0.2-rc.1

7 years ago

0.0.1

7 years ago