LedgerHQ / app-vechain

Apache License 2.0
6 stars 11 forks source link

ledger-app-vet

VeChain wallet application framework for Ledger Nano S/SP/X and Stax

Quick start guide

Follow the steps of Quick start guide of app-boilerplate reported below just for the sake of completeness.

With VSCode

You can quickly setup a convenient environment to build and test your application by using Ledger's VSCode developer tools extension which leverages the ledger-app-dev-tools docker image.

It will allow you, whether you are developing on macOS, Windows or Linux to quickly build your apps, test them on Speculos and load them on any supported device.

:information_source: The terminal tab of VSCode will show you what commands the extension runs behind the scene.

With a terminal

The ledger-app-dev-tools docker image contains all the required tools and libraries to build, test and load an application.

You can download it from the ghcr.io docker repository:

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

You can then enter this development environment by executing the following command from the directory of the application git repository:

Linux (Ubuntu)

sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

macOS

sudo docker run  --rm -ti --user "$(id -u):$(id -g)" --privileged -v "$(pwd -P):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

Windows (with PowerShell)

docker run --rm -ti --privileged -v "$(Get-Location):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

The application's code will be available from inside the docker container, you can proceed to the following compilation steps to build your app.

Building and testing the application

With VsCode

Supposing you have followed the steps of the previous section with VSCode, you can now build and test the application with ease thanks to the Ledger extension. The steps should be:

  1. Docker Container > Update container
  2. Select target for the desired target.
  3. Build > Build to build the application and app.elf file (used by Speculos).
  4. Functional Tests > Run tests to test the application

With Speculos

Manually run with Speculos. Once you have the Speculos installed, you can run the application with the following command:

It's possible to generate the transaction and the APDU codes for the transaction by running tests/generatetx.py script with desired args or directly changing the body of the transaction there.

If you encounter any issue with APDU codes generated by tests/generatetx.py try by extracting APDU codes from the test suite.

  1. Get the hex of transaction.
  2. To generate the APDU codes, you can change the transaction in the test tests/test_sign_tx_long_cmd.py and run the test.
  3. The test should fail for a wrong signature. This is normal because different transaction should have different blake2 message hash and consequentially different signature.
  4. Given that the test failed, you can extract the APDU codes from the logs of the failed test.