Requirements and installation
Introduction
All the JavaScript code related to the Ledger Live applications is in the ledger-live
monorepository. The work to integrate a Blockchain in Ledger Live will all happen in this monorepository.
Ledger Live Common (./libs/ledger-live-common
) is the shared core library used by Ledger Live Desktop and Mobile, that also includes a CLI for testing purpose or for using Ledger Live features directly from a terminal (in a limited way).
This library is built upon a pretty standard ES6 + Typescript stack and relies on a bunch of ledgerjs (opens in a new tab) packages, RxJS 6.x (opens in a new tab), bignumber.js (opens in a new tab) and React (opens in a new tab) + Redux (opens in a new tab) for some front-end utilities and hooks.
It is designed to have very generic models and mechanics (for currencies, accounts, storage, synchronisation, events...) that also facilitates new blockchain integrations through flexibility.
All integrated coins are implemented in their own package in the libs
directory, following the naming convention. To be fully integrated, a libs/ledger-live-common/src/families
dedicated folder needs to contain a few "glue" files - that can be shared by multiple crypto-assets that use the same implementation (i.e. Bitcoin-like coins share the same bitcoin
family).
This document only concerns new blockchain integrations using Typescript - we will use an imaginary coin named MyCoin
as a walkthrough.
Setup
Requirements
- Node.js@18.x.x (opens in a new tab)
- PnPm@8.x.x (opens in a new tab)
- Python 2.7 or 3.5+
- A C/C++ toolchain (see node-gyp documentation)
Development tools (used or required)
- eslint (opens in a new tab) - ensure it works in your IDE (vscode plugin (opens in a new tab))
- prettier (opens in a new tab) - through an eslint-plugin
- typescript (opens in a new tab) - ensure it works fine with your IDE
Hardware prerequisites
- A physical device (Ledger Nano S, S Plus, X or a Stax)
- MyCoin app installed on device
Installation
- Fork and clone the
ledger-live
repository https://github.com/LedgerHQ/ledger-live (opens in a new tab) cd ledger-live
- Install with
pnpm i
Structure
Your whole implementation of MyCoin must reside in a mycoin
folder in libs/coin-modules/coin-mycoin
.
You will also need some code in libs/ledger-live-common/src/families/mycoin
, for injection, setup and UI specific requirements.
Here is a typical family folder structure (TS integration):
./libs
βββ coin-modules/coin-mycoin/src
β βββ api
β β βββ index.ts
β βββ bridge
β β βββ broadcast.ts
β β βββ buildTransaction.ts
β β βββ createTransaction.ts
β β βββ estimateMaxSpendable.ts
β β βββ formatters.ts
β β βββ getFeesForTransaction.ts
β β βββ getTransactionStatus.ts
β β βββ prepareTransaction.ts
β β βββ signOperation.ts
β β βββ synchronization.ts
β β βββ index.ts
β βββ logic
β β βββ broadcast.ts
β β βββ craftTransaction.ts
β β βββ estimateFees.ts
β β βββ getBalance.ts
β β βββ lastBlock.ts
β β βββ listOperations.ts
β β βββ signTransaction.ts
β β βββ index.ts
β βββ network
β β βββ explorer.ts
β β βββ index.ts
β βββ signer
β β βββ getAddress.ts
β β βββ index.ts
β βββ test
β β βββ bot-deviceActions.ts
β β βββ bot-specs.ts
β β βββ bridgeDatasetTest.ts
β β βββ cli.ts
β β βββ index.ts
β βββ types
β β βββ bridge.ts
β β βββ errors.ts
β β βββ model.ts
β β βββ signer.ts
β β βββ index.ts
β βββ config.ts
β βββ index.ts
βββ ledger-live-common/src/families/mycoin
β βββ bridge.integration.test.ts
β βββ config.ts
β βββ logic.ts
β βββ react.ts
β βββ setup.ts
β βββ types.ts
β βββ walletApiAdapter.ts
βββ ledgerjs/packages/hw-app-mycoin/src
β βββ MyCoin.ts
β βββ index.ts
You can refer to existing implementations to complete given examples, like Polkadot integration.
Coin-module
src/api
directory: Contains the implementation of B2B interface (a.k.a. Alpaca) - TBD.src/bridge/*
files: Split ofCurrencyBridge
andAccountBridge
logic in dedicated files.src/bridge/index.ts
file: Entry point of Ledger Live integration of the coin-module. This file listsCurrencyBridge
andAccountBridge
implementation.src/network
directory: Contains all the logic to send requests to the explorer.src/signer/getAddress.ts
file: Logic on how to interact with device-app to retrieve addresses.src/test/bot-specs.ts
file: Definition of tests to be run on the bot.src/types/signer.ts
file: Interface definition of the ledger device-app related to this coin.
Ledger live-common
src/config.ts
: TBD.src/logic.ts
: Lists coin specific business logic.src/react.ts
: Defines and lists coin specfic react hooks for UI.src/setup.ts
: Glue file for coin integration.src/types.ts
: Lists coin specific types.src/walletApiAdapter.ts
: TBD.
LedgerJS
All files related to communication with the device-app.