Skip to content

Latest commit

 

History

History
80 lines (53 loc) · 2.74 KB

CONTRIBUTING.md

File metadata and controls

80 lines (53 loc) · 2.74 KB

Developing an Alamgu ledger App

Dependencies and development environments

Background info

An Alamgu ledger app is mostly written in Rust, and efforts have been taken to ensure it is developed in a fairly standard way (for embedded Rust programs).

These dependencies are needed:

Additionally for testing these are needed:

  • Node
  • Yarn
  • Speculos the official Ledger emulator

Getting a development environment with Nix

The easiest way to get all these dependencies is with Nix:

nix-shell -A $DEVICE.rustShell
cd rust-app/
cargo ledger build -l $DEVICE

where DEVICE is one of

  • nanos for Nano S
  • nanox for Nano X
  • nanosplus for Nano S+

Getting a development environment without Nix

Exact instructions are not provided. See the ./docker subdirectory or GitHub Actions secondary CI.

Updating the lock file (Cargo.lock)

Nix needs additional information not provided in the Cargo lock file for the most robust form of supply-chain integrity for git dependencies. This information is contained in crate-hashes.json at the root of this repo.

After modifying Cargo.lock, please run

./update-crate-hashes.sh

in order to regenerate this file and keep it up to date.

Running automated tests with Speculos

Using Nix, from the root level of this repo, run:

nix-shell -A $DEVICE.rustShell
cd rust-app/
cargo test --target=$TARGET_JSON

Deploying development builds to real hardware

The easiest thing to do is just run a Nix build as described in the main read-me. Nix will always track the latest changes, freshly rebuilding components as needed.

That said, it is also possible to use Cargo build. This useful for the quickest "debug loop".

The cargo-ledger builds, outputs a hex file and a manifest file for ledgerctl, and loads it on a device in a single cargo-ledger ledger -l nanos command in the rust-app folder within app directory.

(You do not need to install cargo-ledger if you are using the nix-provided development shell, as it provides it.)

Before installing with either method, please ensure that your device is plugged, unlocked, and on the device home screen.

Note as described in the main read-me, it is currently not possible to side-load apps on the on Nano X, so one can only test in the emulator.