@hirishh/lisk-ledger.js
v2.2.0
Published
This library eases the interaction with the corresponding ledger nano implementation
Downloads
50
Readme
Lisk Ledger API
This library is meant to be used with the corresponding Ledger C implementation. Given the end-user have:
- His ledger connected & unlocked;
- the corresponding app open;
This JS library will serve as an interface between your code and the hardware wallet handling the communication protocol.
Documentation
Documention is available here.
Environment Support
This library does not make any assumption on the environment on which it is being consumed.
Both Node.JS and minified Browser version of this library are provided.
NodeJS
To consume this library through an app running under the NodeVM, you'll need to use the @ledgerhq/hw-transport-node-hid transport.
This library, and the ledger app, have been developed and tested with [email protected]
.
Browser
The Browser version currently weights 32KB
(non gzipped). It can be used both via webpack or directly including it in your page just like any other script.
This library, and the ledger app, have been tested with @ledgerhq/[email protected]
as Transport.
Platform Indipendent Example
import TransportWebUsb from '@ledgerhq/hw-transport-webusb';
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
import { isBrowser, isNode } from 'browser-or-node';
import { LiskLedger } from '@hirishh/lisk-ledger.js';
let transportMethod;
if (isBrowser) {
transportMethod = TransportWebUsb;
} else if (isNode) {
transportMethod = TransportNodeHid;
} else {
// ??
}
transportMethod.create()
.then((transport) => new LiskLedger(transport));
.then((instance) => {
// ..
});
// Or by using async/await
let transport = TransportNodeHid.create();
let instance = new LiskLedger(transport);
let account = new LedgerAccount();
const res = await instance.getPubKey(account);
Thanks
Any improvement/suggestion is very welcome.