|
2 | 2 |
|
3 | 3 |  
|
4 | 4 |
|
5 |
| -This is a boilerplate application written in Rust which can be forked to start a new project for the Ledger Nano X/SP, Stax and Flex devices. |
| 5 | +This is a boilerplate application written in Rust which can be forked to start a new project for the Ledger Nano X, S+, Stax and Flex devices. |
6 | 6 |
|
7 | 7 | :warning: Nano S is not supported
|
8 | 8 |
|
@@ -42,93 +42,88 @@ By using Ledger's own developer tools [Docker image](https://github.com/LedgerHQ
|
42 | 42 |
|
43 | 43 | ### Prerequisites
|
44 | 44 |
|
45 |
| -If you do not wish to use the [VS Code extension](#with-vs-code), you can follow the following steps to setup a development environment on Linux or MacOS. |
46 |
| - |
47 |
| -The [ledger-app-dev-tools](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools) Docker image contains all the required tools and libraries to build, test and load an application on a device. |
48 |
| - |
49 |
| -You can download it from the ghcr.io docker repository: |
| 45 | +If you do not wish to use the [VS Code extension](#with-vs-code), you can follow the following steps to setup a development environment on Linux, Windows or MacOS. |
50 | 46 |
|
| 47 | +* The [ledger-app-dev-tools](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools) Docker image contains all the required tools and libraries to build, test and load an application on a device. You can download it from the ghcr.io docker repository: |
51 | 48 | ```shell
|
52 | 49 | sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
|
53 | 50 | ```
|
54 |
| - |
55 |
| -You can then enter into this development environment by executing the following command from the directory of the application (`git` repository): |
56 |
| - |
57 |
| -**Linux (Ubuntu)** |
58 |
| - |
59 |
| -```shell |
60 |
| -sudo docker run --rm -ti --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
61 |
| -``` |
62 |
| - |
63 |
| -**macOS** |
64 |
| - |
65 |
| -```shell |
66 |
| -sudo docker run --rm -ti --privileged -v "$(pwd -P):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
67 |
| -``` |
68 |
| - |
69 |
| -**Windows (with PowerShell)** |
70 |
| - |
71 |
| -```shell |
72 |
| -docker run --rm -ti --privileged -v "$(Get-Location):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
73 |
| -``` |
| 51 | +* Make sure you have an X11 server running : |
| 52 | + * On Ubuntu Linux, it should be running by default. |
| 53 | + * On macOS, install and launch [XQuartz](https://www.xquartz.org/) (make sure to go to XQuartz > Preferences > Security and check "Allow client connections"). |
| 54 | + * On Windows, install and launch [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (make sure to configure it to disable access control). |
| 55 | +* You can then enter into this development environment by executing the following command from the directory of the application (`git` repository): |
| 56 | + * Linux (Ubuntu): |
| 57 | + ```shell |
| 58 | + sudo docker run --rm -ti --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" --publish 5001:5001 --publish 9999:9999 -e DISPLAY=$DISPLAY -v '/tmp/.X11-unix:/tmp/.X11-unix' ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
| 59 | + ``` |
| 60 | + * macOS: |
| 61 | + ```shell |
| 62 | + sudo docker run --rm -ti --privileged -v "$(pwd -P):/app" --publish 5001:5001 --publish 9999:9999 -e DISPLAY='host.docker.internal:0' -v '/tmp/.X11-unix:/tmp/.X11-unix' ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
| 63 | + ``` |
| 64 | + * Windows (with PowerShell): |
| 65 | + ```shell |
| 66 | + docker run --rm -ti --privileged -v "$(Get-Location):/app" -e DISPLAY='host.docker.internal:0' --publish 5001:5001 --publish 9999:9999 ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest |
| 67 | + ``` |
74 | 68 |
|
75 | 69 | The application's code will be available from inside the docker container, you can proceed to the following compilation steps to build your app.
|
76 | 70 |
|
77 | 71 | ### Building
|
78 | 72 |
|
79 | 73 | You can build the boilerplate with the following command executed in the root directory of the app.
|
80 |
| - |
81 | 74 | ```bash
|
82 | 75 | cargo ledger build nanox
|
83 | 76 | ```
|
84 |
| - |
85 | 77 | This command will build the app for the Nano X, but you can use any supported device (`nanox`, `nanosplus`, `stax`, `flex`)
|
86 | 78 |
|
87 |
| -### Loading |
88 |
| - |
89 |
| -ℹ️ Your device must be connected, unlocked and the screen showing the dashboard (not inside an application). |
90 |
| - |
91 |
| -[cargo-ledger](https://github.com/LedgerHQ/cargo-ledger) also allows you to side load the binary with the following command line executed in the root directory of the boilerplate app. |
92 |
| - |
93 |
| -```bash |
94 |
| -cargo ledger build nanox --load |
95 |
| -``` |
96 |
| - |
97 |
| -As for the build command, you can replace `nanox` with `nanosplus`, `stax` or `flex`. |
98 |
| - |
99 |
| -## Test |
100 |
| - |
101 |
| -### Ragger functional tests |
102 |
| - |
| 79 | +### Testing |
| 80 | +#### Ragger functional tests |
103 | 81 | This boilerplate app comes with functional tests implemented with Ledger's [Ragger](https://github.com/LedgerHQ/ragger) test framework.
|
104 | 82 |
|
105 | 83 | * Install the tests requirements
|
106 |
| - |
107 | 84 | ```bash
|
108 | 85 | pip install -r tests/requirements.txt
|
109 | 86 | ```
|
110 |
| - |
111 | 87 | * Run the functional tests :
|
112 | 88 |
|
113 | 89 | ```shell
|
114 | 90 | pytest tests/ --tb=short -v --device {nanosp | nanox | stax | flex}
|
115 | 91 | ```
|
| 92 | +#### Emulator |
| 93 | +You can also run the app directly on the [Speculos emulator](https://github.com/LedgerHQ/speculos) from the Docker container |
| 94 | +#### Nano S+ or X |
| 95 | +```bash |
| 96 | +speculos --apdu-port 9999 --api-port 5001 --display headless --model nanosp target/nanosplus/release/app-boilerplate-rust |
| 97 | +``` |
| 98 | +:warning: UI is displayed on `localhost:5001` |
| 99 | +#### Stax or Flex |
| 100 | +```bash |
| 101 | +speculos --apdu-port 9999 --api-port 5001 --model stax target/stax/release/app-boilerplate-rust |
| 102 | +``` |
| 103 | +:warning: UI is displayed by your X server |
116 | 104 |
|
117 |
| -### Emulator |
118 |
| - |
119 |
| -You can also run the app directly on the [Speculos emulator](https://github.com/LedgerHQ/speculos) |
| 105 | +You can then send APDU using `ledgercomm` (`pip install ledgercomm`): |
| 106 | +``` |
| 107 | +ledgercomm-send file test.apdu |
| 108 | +``` |
| 109 | +### Loading on device |
| 110 | +:warning: Loading the built application on a device shall be performed out of the Docker container, by using [ledgerctl](https://github.com/LedgerHQ/ledgerctl): |
| 111 | +```shell |
| 112 | +pip3 install ledgerwallet |
| 113 | +```` |
| 114 | +ℹ️ Your device must be connected, unlocked and the screen showing the dashboard (not inside an application). |
120 | 115 |
|
| 116 | +For instance, for Flex: |
121 | 117 | ```bash
|
122 |
| -speculos --model nanox target/nanox/release/app-boilerplate-rust |
| 118 | +ledgerctl install -f target/flex/release/app_flex.json |
123 | 119 | ```
|
124 | 120 |
|
125 | 121 | ## Continuous Integration
|
126 |
| - |
127 | 122 | The following workflows are executed in [GitHub Actions](https://github.com/features/actions) :
|
128 | 123 |
|
129 | 124 | * Ledger guidelines enforcer which verifies that an app is compliant with Ledger guidelines. The successful completion of this reusable workflow is a mandatory step for an app to be available on the Ledger application store. More information on the guidelines can be found in the repository [ledger-app-workflow](https://github.com/LedgerHQ/ledger-app-workflows)
|
130 | 125 | * Compilation of the application for all supported devices in the [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder) docker image
|
131 | 126 | * End-to-end tests with the [Speculos](https://github.com/LedgerHQ/speculos) emulator and [ragger](https://github.com/LedgerHQ/ragger) (see [tests/](tests/))
|
132 | 127 | * Various lint checks :
|
133 | 128 | * Source code lint checks with `cargo fmt`
|
134 |
| - * Python functional test code lint checks with `pylint` and `mypy` |
| 129 | + * Python functional test code lint checks with `pylint` and `mypy` |
0 commit comments