8 - Wallet API
- Fork github.com/LedgerHQ/wallet-api
- Clone the repo
Running the Wallet API project
cd wallet-api
pnpm i
pnpm devAdding the crypto in the Wallet API
-
In
packages/core/src/familiescreate a folder for your family if it doesn’t already exist -
In
packages/core/src/families/common.tsupdate theFAMILIESarray to add your new coin family name -
In
packages/core/src/families/{COIN_FAMILY}/validation.tsdefine and export coin family types related schema using Zod. At minimum, aschemaRaw{COIN_FAMILY}Transaction -
In
packages/core/src/families/{COIN_FAMILY}/types.tsdefine and export types related to your type. At minimum, a{COIN_FAMILY}Transactionand aRaw{COIN_FAMILY}Transaction -
In
packages/core/src/families/{COIN_FAMILY}/serializer.tsadd 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 -
In
packages/core/src/families/index.tsexport your new family types -
In
packages/core/src/families/types.tsupdateTransactiontype to add your new coin related transaction type -
In
packages/core/src/families/validation.tsupdateschemaRawTransactionto add your new coin related transaction schema -
In
packages/core/src/families/serializer.tsadd your new coin family transactions serialization and deserialization logics inserializeTransactionanddeserializeTransaction -
Create a changeset with the command
pnpm changelog, you should only need to select@ledgerhq/wallet-api-corethen 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 repo in order to get a new version to use in LL
Examples:
Updating Ledger Wallet
-
Clone the repo
-
Update the version of
@ledgerhq/wallet-api-core,@ledgerhq/wallet-api-serverand@ledgerhq/wallet-api-clientused in Ledger Wallet -
In LL, you might need to create an adapter for your coin family to transform a WalletAPITransaction (the type of the transaction from the Ledger Wallet API point of view) to a Ledger Wallet Transaction (the type of the transaction from the Ledger Wallet point of view)
libs/ledger-live-common/src/generated/walletApiAdapter.tsimport your adapter and add it to the export
The file above is automatically generated at build time by this script. 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.tsthe actual transaction adapter
(here is an example adapter for ethereum:libs/ledger-live-common/src/families/ethereum/walletApiAdapter.ts)