diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 29e17faf..1556f75c 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -26,7 +26,7 @@ jobs: name: C tests runs-on: ubuntu-latest container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest steps: - name: Clone uses: actions/checkout@v3 diff --git a/README.md b/README.md index 5d144947..ac8ab3a1 100644 --- a/README.md +++ b/README.md @@ -12,118 +12,84 @@ Current Features: - Blind sign arbitrary transactions (Enabled via settings) ## Prerequisites + ### For building the app + * [Install Docker](https://docs.docker.com/get-docker/) * For Linux hosts, install the Ledger Nano [udev rules](https://github.com/LedgerHQ/udev-rules) -#### Build the [Ledger App Builder](https://developers.ledger.com/docs/nano-app/build/) Docker image -1. Clone the git repository -``` -git clone https://github.com/LedgerHQ/ledger-app-builder.git -``` -2. Change directories -``` -cd ledger-app-builder -``` -3. Checkout the target commit -``` -git checkout 73c9e07 -``` -4. Build the image -``` -docker build -t ledger-app-builder:73c9e07 . -``` - * If permissions errors are encountered, ensure that your user is in the `docker` -group and that the session has been restarted +* Pull Ledger Development Tools image -### For working with the device -#### Install Python3 PIP -Ubuntu Linux: -``` -sudo apt install pip3 -``` -MacOS -``` -brew install python3 +```sh +$ docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest ``` -#### Install ledgerblue python module -``` -pip3 install ledgerblue -``` -#### Locally clone SDK repos corresponding to those included in the Docker image -* Setup environment -```bash -cat >>"${HOME}"/.profile < +Build the app in the container. The BOLOS_SDK variable is used to specify the target SDK, allowing to compile the application for each Ledger device. See [Ledger Application Builder](https://github.com/LedgerHQ/ledger-app-builder?tab=readme-ov-file#compile-your-app-in-the-container) for more details. + +```sh +# E.g. for Nano S +$ sudo docker run --rm -ti -v "$(realpath .):/app" --user $(id -u $USER):$(id -g $USER) ghcr.io/ledgerhq/ledger-app-builder//ledger-app-dev-tools:latest +bash$ BOLOS_SDK=$NANOS_SDK make ``` ### Clean -```bash -./docker-make clean + +Within the running development container + +```sh +bash$ BOLOS_SDK=$NANOS_SDK make clean ``` ## Working with the device -Requires that the `BOLOS_SDK` envvar [be set](https://developers.ledger.com/docs/embedded-app/build-app/#b-build-the-application). -This can be achieved by first [building](#build) for the desired target device. + +See [Ledger Application Builder](https://github.com/LedgerHQ/ledger-app-builder?tab=readme-ov-file#compile-your-app-in-the-container) for more details. + ### Load + ```bash -make load-only +$ sudo docker run --rm -ti -v "$(realpath .):/app" --privileged -v "/dev/bus/usb:/dev/bus/usb" --user $(id -u $USER):$(id -g $USER) ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest +bash$ BOLOS_SDK=$NANOS_SDK make load ``` ### Delete -```bash -make delete + +Within the running development container + +```sh +bash$ BOLOS_SDK=$NANOS_SDK make delete ``` ## Test + ### Unit + Run C tests: -```bash -make -C libsol + +```sh +bash$ make -C libsol +``` + +### Ragger + +Make sure that you have already built the application for the specific device. + +Run Ragger tests: + +```sh +# Install python test suite dependencies +bash$ pip install -r "tests/python/requirements.txt" + +# Run test suite for the specific device, e.g. nanos +bash$ pytest tests/python/ --tb=short -v --device nanos -k "" ``` + +To regenerate golden snapshots, use `--golden_run` option. + ### Integration + First enable `blind-signing` in the App settings -```bash -cargo run --manifest-path tests/Cargo.toml + +```sh +bash$ cargo run --manifest-path tests/Cargo.toml ``` diff --git a/docker-make b/docker-make deleted file mode 100755 index 26605154..00000000 --- a/docker-make +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -docker_tag=73c9e07 -docker_image_base=ledger-app-builder -docker_image="${docker_image_base}:${docker_tag}" - -if ! docker image inspect "$docker_image" &>/dev/null; then - echo "docker image \`$docker_image\` not found. please see README.md" 1>&2 - exit 1 -fi - -here="$(readlink -f "$(dirname "$0")")" -source "$here"/util/active-target.sh - -last_target_sdk="$(read_last_target_sdk_mnemonic "$here")" -maybe_target_sdk="$(normalize_mnemonic "${1:-''}" false)" -if [[ -n "$maybe_target_sdk" ]]; then - shift -fi -target_sdk="${maybe_target_sdk:-"$last_target_sdk"}" - -if [[ -z "$target_sdk" ]]; then - echo 'cannot resolve target sdk. please pass `s`, `x` or `sp` as the first argument' 1>&2 - exit 1 -elif [[ -z "$last_target_sdk" ]]; then - write_last_target_sdk_mnemonic "$here" "$target_sdk" -elif [[ "$target_sdk" != "$last_target_sdk" ]]; then - echo "target_sdk change requested. please run \`$0 clean\` first" 1>&2 - exit 1 -fi - -bolos_sdk_var="$(sdk_mnemonic_to_bolos_variable "$target_sdk")" - -user=$(id -u) -group=$(id -g) -owner="$user:$group" - -IFS='' read -r -d '' container_script <address); + summary_item_set_pubkey(item, "Create token account", info->address); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "From mint", info->mint); + summary_item_set_pubkey(item, "For", info->owner); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Owned by", info->owner); + summary_item_set_pubkey(item, "Token address", info->mint); item = transaction_summary_general_item(); summary_item_set_pubkey(item, "Funded by", info->funder); diff --git a/libsol/spl_token_instruction.c b/libsol/spl_token_instruction.c index 9de0b8fb..7dae2df8 100644 --- a/libsol/spl_token_instruction.c +++ b/libsol/spl_token_instruction.c @@ -461,7 +461,7 @@ static int print_spl_token_initialize_account_info(const char* primary_title, summary_item_set_pubkey(item, "Owner", info->owner); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); return 0; } @@ -503,13 +503,13 @@ int print_spl_token_transfer_info(const SplTokenTransferInfo* info, info->body.decimals); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "From", info->src_account); + summary_item_set_pubkey(item, "From (token account)", info->src_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "To", info->dest_account); + summary_item_set_pubkey(item, "To (token account)", info->dest_account); print_spl_token_sign(&info->sign, print_config); @@ -532,10 +532,10 @@ static int print_spl_token_approve_info(const SplTokenApproveInfo* info, info->body.decimals); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "From", info->token_account); + summary_item_set_pubkey(item, "From (token account)", info->token_account); print_spl_token_sign(&info->sign, print_config); @@ -598,10 +598,10 @@ static int print_spl_token_mint_to_info(const SplTokenMintToInfo* info, info->body.decimals); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "To", info->token_account); + summary_item_set_pubkey(item, "To (token account)", info->token_account); print_spl_token_sign(&info->sign, print_config); @@ -623,10 +623,10 @@ static int print_spl_token_burn_info(const SplTokenBurnInfo* info, info->body.decimals); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "From", info->token_account); + summary_item_set_pubkey(item, "From (token account)", info->token_account); print_spl_token_sign(&info->sign, print_config); @@ -640,7 +640,7 @@ static int print_spl_token_close_account_info(const SplTokenCloseAccountInfo* in SummaryItem* item; item = transaction_summary_primary_item(); - summary_item_set_pubkey(item, "Close acct", info->token_account); + summary_item_set_pubkey(item, "Close token account", info->token_account); item = transaction_summary_general_item(); summary_item_set_pubkey(item, "Withdraw to", info->dest_account); @@ -655,11 +655,11 @@ static int print_spl_token_freeze_account_info(const SplTokenFreezeAccountInfo* SummaryItem* item; item = transaction_summary_primary_item(); - summary_item_set_pubkey(item, "Freeze acct", info->token_account); + summary_item_set_pubkey(item, "Freeze token account", info->token_account); if (print_config->expert_mode) { item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); } print_spl_token_sign(&info->sign, print_config); @@ -672,11 +672,11 @@ static int print_spl_token_thaw_account_info(const SplTokenThawAccountInfo* info SummaryItem* item; item = transaction_summary_primary_item(); - summary_item_set_pubkey(item, "Thaw acct", info->token_account); + summary_item_set_pubkey(item, "Thaw token account", info->token_account); if (print_config->expert_mode) { item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Mint", info->mint_account); + summary_item_set_pubkey(item, "Token address", info->mint_account); } print_spl_token_sign(&info->sign, print_config); @@ -691,7 +691,7 @@ static int print_spl_token_sync_native_info(const SplTokenSyncNativeInfo* info, SummaryItem* item; item = transaction_summary_primary_item(); - summary_item_set_pubkey(item, "Sync native acct", info->token_account); + summary_item_set_pubkey(item, "Sync native account", info->token_account); return 0; } diff --git a/libsol/transaction_printers.c b/libsol/transaction_printers.c index 91c5848d..d3fcd9c7 100644 --- a/libsol/transaction_printers.c +++ b/libsol/transaction_printers.c @@ -512,13 +512,13 @@ static int print_spl_token_create_account(const PrintConfig* print_config, const SplTokenInitializeAccountInfo* ia_info = &infos[1]->spl_token.initialize_account; SummaryItem* item = transaction_summary_primary_item(); - summary_item_set_pubkey(item, "Create token acct", ia_info->token_account); + summary_item_set_pubkey(item, "Create token account", ia_info->token_account); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "From mint", ia_info->mint_account); + summary_item_set_pubkey(item, "For", ia_info->owner); item = transaction_summary_general_item(); - summary_item_set_pubkey(item, "Owned by", ia_info->owner); + summary_item_set_pubkey(item, "Token address", ia_info->mint_account); if (print_config_show_authority(print_config, ca_info->from)) { item = transaction_summary_general_item();