7 - Ledger Live Desktop and Mobile
- Fork github.com/LedgerHQ/ledger-live
- Clone the repo
Ledger Live Common
Ledger Live Common is the repo where all the common logic and setup (between desktop and mobile) is done.
Even if CoinModules are made with Ledger Live as first class citizen user, it is not the only Ledger product that relies on. Therefore, some setup is required to allow LLD and LLM to use your CoinModule.
For a dedicated CoinModule (i.e. MyCoin), all those setup files will be in libs/ledger-live-common/src/families/mycoin
directory.
Setup
The setup file (libs/ledger-live-common/src/families/mycoin/setup.ts
) is responsible for the instanciation of the CoinModule.
It injects all required elements.
Some helpers function exist in LLC (libs/ledger-live-common/src/bridge/setup.ts
), to avoid too much boilerplate.
import {
MyCoinAccount,
TransactionStatus,
createBridges,
type Transaction,
} from "@ledgerhq/coin-mycoin";
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
import Transport from "@ledgerhq/hw-transport";
import MyCoin from "@ledgerhq/hw-app-mycoin";
import type { Bridge } from "@ledgerhq/types-live";
import { MyCoinCoinConfig } from "@ledgerhq/coin-mycoin/config";
import myCoinResolver from "@ledgerhq/coin-mycoin/signer/index";
import makeCliTools, { type CliTools } from "@ledgerhq/coin-mycoin/test/cli";
import { createResolver, executeWithSigner, type CreateSigner } from "../../bridge/setup";
import { Resolver } from "../../hw/getAddress/types";
import { getCurrencyConfiguration } from "../../config";
const createSigner: CreateSigner<MyCoin> = (transport: Transport) => {
return new MyCoin(transport);
};
const myCoin = getCryptoCurrencyById("myCoin");
// Closure that will load dynamically the current config linked to this coin. The config may change during LLD and LLM lifecyle.
const getCurrencyConfig = (): MyCoinCoinConfig => getCurrencyConfiguration(myCoin);
const bridge: Bridge<Transaction, MyCoinAccount, TransactionStatus> = createBridges(
executeWithSigner(createSigner),
getCurrencyConfig,
);
const resolver: Resolver = createResolver(createSigner, myCoinResolver);
const cliTools: CliTools = makeCliTools();
export { bridge, cliTools, resolver };
Config
Ledger Live use a dynamic configuration for some parts of its logic. CoinModules use this tool to seamlessly update some key elements.
The status
element of the following object is mandatory. The other properties are depending on your needs in the CoinModule.
libs/ledger-live-common/src/bridge/config.ts
:
import { ConfigInfo } from "@ledgerhq/live-config/LiveConfig";
import { getEnv } from "@ledgerhq/live-env";
export const myCoinConfig: Record<string, ConfigInfo> = {
config_currency_mycoin: {
type: "object",
default: {
status: {
type: "active",
},
node: {
url: getEnv("API_MYCOIN_NODE"),
},
},
},
};
Ledger Live Desktop
Adding the crypto in LLD
- In
live-common-set-supported-currencies.js
add the name you gave in the table. E.g.,mycoin
- Add the error translation keys in
static/i18n/en
.
Running the Desktop project
cd ledger-live
pnpm dev:lld
Ledger Live Mobile
Adding the crypto in LLM
- Similarly step as for instructions for LLD, except it is in file
live-common-setup.js
. - Add the error translation keys in
src/locales/en/common.json
Running the Mobile project on iOS (Mac only)
The prerequisites to running the project are found in the README file.
cd ledger-live
pnpm dev:llm
Running the Mobile project on Android or iOS
Android
pnpm mobile android
or open android/
in Android Studio.
iOS
pnpm mobile ios
or open ios/ledgerlivemobile.xcworkspace