JSPM

@ledgerhq/hw-app-exchange

0.19.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1198
  • Score
    100M100P100Q107393F
  • License Apache-2.0

Ledger Hardware Wallet Cosmos Application API

Package Exports

  • @ledgerhq/hw-app-exchange
  • @ledgerhq/hw-app-exchange/lib-es/index.js
  • @ledgerhq/hw-app-exchange/lib/ReturnCode
  • @ledgerhq/hw-app-exchange/lib/ReturnCode.js
  • @ledgerhq/hw-app-exchange/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ledgerhq/hw-app-exchange) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

GitHub, Ledger Devs Discord, Developer Portal

@ledgerhq/hw-app-exchange

Ledger Hardware Wallet Exchange app.

API

Table of Contents

resolveTransactionType

Adapt ExchangeTypes following partner info. For "legacy" partner, we don't change the provided type. For new one, we call the new APDU commands (Ng, Next Gen).

Parameters

  • type ExchangeTypes
  • partnerVersion number?

Returns ExchangeTypes

OkStatus

Those values map the one defined in the app-exchange code (@see protocol.md and swap_errors.h)

Type: number

decodePayloadProtobuf

deprecated use decodeSwapPayload instead

Parameters

Returns Promise<SwapPayload>

Integration test

1. Prerequisite

Download latest version of Ledger SDK.

docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

The rest of the documentation is about testing on NanoSP.

2. Compile app-exchange

docker run --privileged -v '<ABSOLUTE_PATH_TO_APP_EXCHANGE_SRC>:/app' -t -d --name ledger-app-dev-tools ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools

docker exec -it ledger-app-dev-tools bash -c 'export BOLOS_SDK="$<NANO_SDK>" && make -j DEBUG=1 TESTING=1 TEST_PUBLIC_KEY=1'

With <NANO_SDK> possible value:

  • NanoS: NANOS_SDK
  • NanoS+: NANOSP_SDK
  • NanoX: NANOX_SDK
  • Stax: STAX_SDK
  • Flex: FLEX_SDK

It is important to set the value of DEBUG to 1, as we need the fake Ledger private key in our test.

3. Launch speculos

You can compile only the app-exchange, but it can be useful to compile a coin-app like app-ethereum.

In the documentation, we assume the following name for the apps binary:

  • app-exchange: exchange_nanosp.elf
  • app-ethereum: ethereum_nanosp.elf
docker run -v '<ABSOLUTE_PATH_TO_ELFS>:/app' -p 5000:5000 -t -d --name speculos ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools

docker exec -it speculos bash -c 'speculos --model "nanosp" /app/exchange_nanosp.elf -l /app/ethereum_nanosp.elf --display headless'

4. Launch integration tests

From Ledger Live root directory:

pnpm ljs:hw-app-exchange test-integ