Ledger lightweight app for Nested.
Plugins are lightweight applications that go hand-in-hand with the Ethereum Application on Nano S, X and S+ devices.
They allow users to safely interact with smart contracts by parsing the transaction data and displaying its content in a human readable way.
It is STRONGLY recommended to follow the plugin guide in order to better understand the flow and the context for plugins.
The C source code is expected to be formatted with clang-format
11.0.0 or higher.
Get Docker and Docker-compose.
In a terminal window:
mkdir plugin_dev
cd plugin_dev
git clone https://github.com/LedgerHQ/app-ethereum
git clone https://github.com/LedgerHQ/plugin-tools
git clone https://github.com/NestedFi/nested-ledger-plugin/
Launch Docker.
In the same terminal:
cd plugin-tools
./start.sh
cd ../nested-ledger-plugin/tests/
./build_locals_test.sh all
If needed, replace all
with the appropriate flags to specifically build the plugin for S, X and the ethereum app.
The tests consist of recent snapshots in ./tests/snapshot-tmp
being compared to a set of expected snapshots located in
./tests/snapshots
.
Open another terminal window.
cd <path>/nested-ledger-plugin/tests
.
yarn test
to run all tests
yarn test -t "<name-of-test>"
to run a singular test.
The singular test names can be found in the ./tests/src/<test-folder>/*.test.js
files.
Note: Sometimes, batched tests may fail. It is recommended to launch a singular test for the failed one to make sure the error does not come from the ZEMU tester.
Find more information about the Zondax ZEMU tester.
More information on the speculos doc page.
The plugin has 3 basic components for modifications:
- Number of screens.
- Screen function calls.
- String macros and functions.
There are two variables that can set the screen number.
In ./src/handle_finalize.c
the msg->numScreens
variable defines how many screens will be displayed.
In ./src/handle_provide_token.c
the msg->additionalScreens
variable increases the previously set screen number.
Both are summed into msg->screenIndex
which is used to scroll through screens.
There are two functions where the screen strings are set.
The first screen is the ID screen, set in ./src/handle_query_contract_id.c
.
Note: It is not included in the amount of screens of msg->screenIndex
.
These screens are set in ./src/handle_query_contract_ui.c
.
Edit the switch(msg->screenIndex)
cases of handle_<name-of-action>_ui()
functions if needed.
The strings displayed by the plugin are set by macros and functions.
TITLE_<NAME_OF_ACTION>_SCREEN_#_UI
(top)MSG_<NAME_OF_ACTION>_SCREEN_#_UI
(bottom)
Edit these in ./src/text.h
to modify the strings displayed to the user.
These utilitary functions are used for displaying addresses, tickers, amounts, etc.
They are located in in ./src/text_utils.c
.
Follow this guide to further modify the plugin.
Visit this page to make sure the plugin meets the standards and you have completed all the steps necessary for deployment.