Coin families contract

From LedgerHQ/ledger-live · View interactive version

Coin families contract is an AI agent skill from the GitHub repository LedgerHQ/ledger-live. Coin-specific families logic must live in families/. Generic UI uses the families contract only (no if (family === "evm") in shared code). Use when working in "**/families/**", "**/mvvm/**", "**/renderer/**" and "**/screens/**".

How to use this skill

Skill file

Coin families contract (Desktop & Mobile UI)

Principle: Coin-specific UI and behavior must live in families/. Generic screens, hooks, and components must not branch on family === "evm" (or any family name). They must use the families contract: optional slots defined in the family type, implemented per family, and consumed via a single lookup (e.g. useLLDCoinFamily(currency.family).SlotName). This keeps generic code family-agnostic and supports modularisation and lazy loading.

Do not do (anti-patterns)

Do (correct pattern)

  1. Define a slot on the contract
  1. Implement only in the family
  1. Use the contract in generic code

Reference example: Scan Device "no associated accounts"

apps/ledger-live-desktop/src/renderer/families/types.ts — NoAssociatedAccounts?: React.ComponentType<AddAccountsStepProps> on LLDCoinFamily.

apps/ledger-live-desktop/src/renderer/families/hedera/NoAssociatedAccounts.tsx and hedera/index.ts exporting it in the family object.

apps/ledger-live-desktop/src/mvvm/features/AddAccountDrawer/screens/ScanAccounts/useScanAccounts.ts: useLLDCoinFamily(currency.family).NoAssociatedAccounts, with no Hedera-specific branch.

useScanDeviceAccountsViewModel.ts: getCustomNoAssociatedAccounts(currency) from ~/generated/NoAssociatedAccounts; result passed as CustomNoAssociatedAccounts to the NoAssociatedAccounts screen. No if (family === "hedera") in the VM.

When you need new coin-specific behavior in a generic flow (e.g. post-add-account navigation, custom empty state): extend the contract (add a new optional slot and document it), implement it in the relevant family folder, and have the generic code only read from the contract. Do not add new if (family === "…") branches in shared UI.

Paths

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.