Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Flex target and update to the latest NBGL use cases #17

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default

- name: Upload scan result
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: scan-build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ jobs:
name: code-coverage
path: unit-tests/coverage

- name: Install codecov dependencies
run: apk add gpg gpg-agent

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./unit-tests/coverage.info
flags: unittests
name: codecov-app-aptos
fail_ci_if_error: true
verbose: true
os: alpine
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add support for Flex target.

### Changed

- Update according to the latest NBGL use cases and guidelines:
- `nbgl_useCaseHomeAndSettings`
- `nbgl_useCaseAddressReview`
- `nbgl_useCaseReview`
- `nbgl_useCaseReviewBlindSigning`

## [0.6.9] - 2024-01-23

### Added
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ ifeq ($(TARGET_NAME),TARGET_STAX)
# still need to find the right value
DEFINES += MAX_TRANSACTION_PACKETS=70
endif
ifeq ($(TARGET_NAME),TARGET_FLEX)
# still need to find the right value
DEFINES += MAX_TRANSACTION_PACKETS=70
endif

########################################
# Mandatory configuration #
Expand All @@ -48,7 +52,7 @@ APPNAME = "Aptos"
# Application version
APPVERSION_M = 0
APPVERSION_N = 6
APPVERSION_P = 9
APPVERSION_P = 10
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
Expand All @@ -59,6 +63,7 @@ ICON_NANOS = icons/app_aptos_16px.gif
ICON_NANOX = icons/app_aptos_14px.gif
ICON_NANOSP = icons/app_aptos_14px.gif
ICON_STAX = icons/app_aptos_32px.gif
ICON_FLEX = icons/app_aptos_40px.gif

# Application allowed derivation curves
CURVE_APP_LOAD_PARAMS = ed25519
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Ledger Aptos Application

Aptos wallet application for Nano S, Nano S Plus and Nano X.
Aptos wallet application supporting the following Ledger devices:

- Nano S
- Nano S Plus
- Nano X
- Stax
- Flex

## Prerequisite

Expand Down
Binary file added icons/app_aptos_40px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]
devices = ["nanos", "nanox", "nanos+", "stax", "flex"]

[tests]
unit_directory = "./unit-tests/"
Expand Down
58 changes: 27 additions & 31 deletions src/ui/nbgl_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,54 @@

static use_case_review_ctx_t blind_sign_ctx;

nbgl_layoutTagValue_t pairs[6];
nbgl_layoutTagValueList_t pairList;
nbgl_pageInfoLongPress_t infoLongPress;

static void blind_sign_continue() {
nbgl_useCaseReviewStart(blind_sign_ctx.icon,
blind_sign_ctx.review_title,
blind_sign_ctx.review_sub_title,
blind_sign_ctx.reject_text,
blind_sign_ctx.continue_callback,
blind_sign_ctx.reject_callback);
}
nbgl_contentTagValue_t pairs[6];
nbgl_contentTagValueList_t pair_list;

static void blind_sign_info() {
nbgl_useCaseReviewStart(&C_round_warning_64px,
"Blind Signing",
"This operation cannot be\nsecurely interpreted by\nLedger Stax.\n"
"It might put your assets\nat risk.",
blind_sign_ctx.reject_text,
blind_sign_continue,
blind_sign_ctx.reject_callback);
nbgl_useCaseReviewBlindSigning(blind_sign_ctx.operation_type,
blind_sign_ctx.tag_value_list,
blind_sign_ctx.icon,
blind_sign_ctx.review_title,
blind_sign_ctx.review_sub_title,
blind_sign_ctx.finish_title,
blind_sign_ctx.tip_box,
blind_sign_ctx.choice_callback);
}

static void blind_sign_choice(bool enable) {
if (enable) {
settings_allow_blind_signing_change(1);
nbgl_useCaseStatus("BLIND SIGNING\nENABLED", true, blind_sign_info);
nbgl_useCaseStatus("Blind signing enabled", true, blind_sign_info);
} else {
blind_sign_ctx.reject_callback();
blind_sign_ctx.choice_callback(false);
}
}

void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon,
void nbgl_useCaseReviewVerify(nbgl_operationType_t operation_type,
const nbgl_contentTagValueList_t *tag_value_list,
const nbgl_icon_details_t *icon,
const char *review_title,
const char *review_sub_title,
const char *reject_text,
nbgl_callback_t continue_callback,
nbgl_callback_t reject_callback) {
const char *finish_title,
const nbgl_tipBox_t *tip_box,
nbgl_choiceCallback_t choice_callback) {
blind_sign_ctx.operation_type = operation_type;
blind_sign_ctx.tag_value_list = tag_value_list;
blind_sign_ctx.icon = icon;
blind_sign_ctx.review_title = review_title;
blind_sign_ctx.review_sub_title = review_sub_title;
blind_sign_ctx.reject_text = reject_text;
blind_sign_ctx.continue_callback = continue_callback;
blind_sign_ctx.reject_callback = reject_callback;
blind_sign_ctx.finish_title = finish_title;
blind_sign_ctx.tip_box = tip_box;
blind_sign_ctx.choice_callback = choice_callback;

if (N_storage.settings.allow_blind_signing) {
blind_sign_info();
} else {
nbgl_useCaseChoice(&C_round_warning_64px,
"Enable blind signing to\nauthorize this\noperation",
nbgl_useCaseChoice(&C_Warning_64px,
"Enable blind signing to authorize this operation?",
lpascal-ledger marked this conversation as resolved.
Show resolved Hide resolved
NULL,
"Enable blind signing",
reject_text,
"Reject operation",
blind_sign_choice);
}
}
Expand Down
23 changes: 13 additions & 10 deletions src/ui/nbgl_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

#include "nbgl_use_case.h"

extern nbgl_layoutTagValue_t pairs[6];
extern nbgl_layoutTagValueList_t pairList;
extern nbgl_pageInfoLongPress_t infoLongPress;
extern nbgl_contentTagValue_t pairs[6];
extern nbgl_contentTagValueList_t pair_list;

typedef struct use_case_review_ctx_s {
nbgl_operationType_t operation_type;
const nbgl_contentTagValueList_t *tag_value_list;
const nbgl_icon_details_t *icon;
const char *review_title;
const char *review_sub_title;
const char *reject_text;
nbgl_callback_t continue_callback;
nbgl_callback_t reject_callback;
const char *finish_title;
const nbgl_tipBox_t *tip_box;
nbgl_choiceCallback_t choice_callback;
} use_case_review_ctx_t;

void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon,
void nbgl_useCaseReviewVerify(nbgl_operationType_t operation_type,
const nbgl_contentTagValueList_t *tag_value_list,
const nbgl_icon_details_t *icon,
const char *review_title,
const char *review_sub_title,
const char *reject_text,
nbgl_callback_t continue_callback,
nbgl_callback_t reject_callback);
const char *finish_title,
const nbgl_tipBox_t *tip_box,
nbgl_choiceCallback_t choice_callback);
35 changes: 14 additions & 21 deletions src/ui/nbgl_display_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,27 @@

static void confirm_address(bool choice) {
validate_pubkey(choice);
nbgl_useCaseStatus(choice ? "ADDRESS\nVERIFIED" : "Address verification\ncanceled",
nbgl_useCaseStatus(choice ? "Address verified" : "Address verification canceled",
choice,
ui_menu_main);
}

static void confirm_address_rejection(void) {
confirm_address(false);
}

static void continue_review(void) {
pairs[0].item = "Derivation Path";
pairs[0].value = g_bip32_path;

pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 1;
pairList.pairs = pairs;
nbgl_useCaseAddressConfirmationExt(g_address, confirm_address, &pairList);
}

int ui_display_address() {
const int ret = ui_prepare_address();
if (ret == UI_PREPARED) {
nbgl_useCaseReviewStart(&C_aptos_logo_64px,
"Verify Aptos\naddress",
NULL,
"Cancel",
continue_review,
confirm_address_rejection);
pairs[0].item = "Derivation path";
pairs[0].value = g_bip32_path;

pair_list.nbMaxLinesForValue = 0;
pair_list.nbPairs = 1;
pair_list.pairs = pairs;

nbgl_useCaseAddressReview(g_address,
&pair_list,
&C_aptos_logo_64px,
"Verify Aptos address",
NULL,
confirm_address);
return 0;
}

Expand Down
Loading
Loading