8 - Wallet API
- Fork github.com/LedgerHQ/wallet-api (opens in a new tab)
- Clone the repo
Running the Wallet API project
cd wallet-api
pnpm i
pnpm dev
Adding the crypto in Wallet API
-
In
packages/core/src/families
create a folder for your family if it doesn't already exist -
In
packages/core/src/families/common.ts
update theFAMILIES
array to add your new coin family name -
In
packages/core/src/families/{COIN_FAMILY}/validation.ts
define and export coin family types related schema using Zod (opens in a new tab). At minimum, aschemaRaw{COIN_FAMILY}Transaction
-
In
packages/core/src/families/{COIN_FAMILY}/types.ts
define and export types related to your type. At minimum, a{COIN_FAMILY}Transaction
(opens in a new tab) and aRaw{COIN_FAMILY}Transaction
(opens in a new tab) -
In
packages/core/src/families/{COIN_FAMILY}/serializer.ts
add the logic to serialize and deserialize a transaction in a raw transaction (type comprised of only json compatible types) to be transferred through JSON-RPC (opens in a new tab) -
In
packages/core/src/families/index.ts
export your new family types -
In
packages/core/src/families/types.ts
updateTransaction
type to add your new coin related transaction type -
In
packages/core/src/families/validation.ts
updateschemaRawTransaction
to add your new coin related transaction schema -
In
packages/core/src/families/serializer.ts
add your new coin family transactions serialization and deserialization logics inserializeTransaction
anddeserializeTransaction
-
Create a changeset with the command
pnpm changelog
, you should only need to select@ledgerhq/wallet-api-core
then you can select it again for the minor bump as we introduce a new feature and add a summary of the changes (you can edit the file after creation) -
Create a PR on the wallet-api (opens in a new tab) repo in order to get a new version to use in LL
Examples:
- Filecoin (opens in a new tab)
- Hedera (opens in a new tab)
- Celo (opens in a new tab)
- Near (opens in a new tab)
- Neo (opens in a new tab)
- Solana (opens in a new tab)
- Elrond (opens in a new tab)
- Cardano (opens in a new tab)
- Vechain (opens in a new tab)
Updating Ledger Live
-
Clone the repo
-
Update the version of
@ledgerhq/wallet-api-core
,@ledgerhq/wallet-api-server
and@ledgerhq/wallet-api-client
used in Ledger Live -
In LL, you might need to create an adapter for your coin family to transform a WalletAPITransaction (the type of the transaction from the Wallet API point of view) to a Ledger Live Transaction (the type of the transaction from the Ledger Live point of view)
libs/ledger-live-common/src/generated/walletApiAdapter.ts
import your adapter and add it to the export
The file above is automatically generated at build time by this script (opens in a new tab). It should not be updated manually but you should still check that your adapter is included in this file once added.
The actual adapted file to add is described bellow:
libs/ledger-live-common/src/families/{COIN_FAMILY}/walletApiAdapter.ts
the actual transaction adapter
(here is an example adapter for ethereum:libs/ledger-live-common/src/families/ethereum/walletApiAdapter.ts
)