Skip to content

Latest commit

 

History

History
155 lines (100 loc) · 3.55 KB

README.md

File metadata and controls

155 lines (100 loc) · 3.55 KB

ledger-cosmos-js

License

This package provides a basic client library to communicate with a Decimal App running in a Ledger Nano S/X

This repo also includes a simple Vue example for U2F and WebUSB.

Example

Methods for ledger Nano

Serialize human readable part of Bech32 (HRP).

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const serializehrp = _decimal.serializeHRP('dx');

Get Bech32 from PK

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const bech32 = _decimal.getBech32FromPK('dx', pk);

Serialize derivation path

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const serializePath = await _decimal.serializePath('dx', path);

Sign get Chunks

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const signedChunks = await _decimal.signGetChunks(path, messageVariable);

Get app version

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const version = await _decimal.getVersion();

Get app info

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const appInfo = await _decimal.appInfo();

Get device info

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const deviceInfo = await _decimal.deviceInfo();

Get public key

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const publicKey = await _decimal.publicKey(path);

Get address and public key

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const wallet = await _decimal.getAddressAndPubKey(path, 'dx');

Sign send Chunk

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const res = await _decimal.signSendChunk(chunkIdx, chunkNum, chunk);

Sing transaction

import DecimalApp from "./src";
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

const transport = await TransportWebUSB.create();
const _decimal = new DecimalApp(transport);

const path = [44, 60, 0, 0, 0];

const res = await _decimal.sign(path, unsignedTx);