Skip to content

Commit

Permalink
Update zxlib
Browse files Browse the repository at this point in the history
  • Loading branch information
relatko committed Aug 6, 2024
1 parent b51a0fc commit f33465a
Show file tree
Hide file tree
Showing 2,436 changed files with 62 additions and 215 deletions.
10 changes: 10 additions & 0 deletions deps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Updating zx-lib

Menu feaure requires us o change zxlib menu layout. Thus insead of a submodule, we have ledger-zxlib included as a copy. In case you need to update zxlib, this is the list of changes performed.

- Menu conains new "Show address"/"View address" entries which display address and pubkey according to data saved on slot 0
- Menu changes. Remove "Developed by" and "Website" entries.
- Set MAX_CHARS_PER_VALUE1_LINE to 120
We experienced crashes with certain strings too long.
- Removed duplicate base58.* files to avoid warnings.

2 changes: 1 addition & 1 deletion deps/ledger-zxlib/app/ui/view_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "nbgl_use_case.h"
#define MAX_LINES_PER_PAGE_REVIEW NB_MAX_LINES_IN_REVIEW
#define MAX_CHARS_PER_KEY_LINE 64
#define MAX_CHARS_PER_VALUE1_LINE 180
#define MAX_CHARS_PER_VALUE1_LINE 120 //we experienced a crash wih 180
#define MAX_CHARS_HEXMESSAGE 160
#else
#ifndef MAX_CHARS_PER_VALUE_LINE
Expand Down
28 changes: 20 additions & 8 deletions deps/ledger-zxlib/app/ui/view_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nbgl_use_case.h"
#include "ux.h"
#include "view_internal.h"
#include "menu_handler.h"

#ifdef APP_SECRET_MODE_ENABLED
zxerr_t secret_enabled();
Expand Down Expand Up @@ -72,6 +73,7 @@ typedef enum {
EXPERT_MODE_TOKEN = FIRST_USER_TOKEN,
ACCOUNT_MODE_TOKEN,
SECRET_MODE_TOKEN,
REVIEW_ADDRESS_TOKEN,
} config_token_e;

void app_quit(void) {
Expand All @@ -91,8 +93,8 @@ static void view_idle_show_impl_callback() { view_idle_show_impl(0, NULL); }
#define MAX_INFO_LIST_ITEM_PER_PAGE 2
#endif

static const char *const INFO_KEYS_PAGE[] = {"Version", "Developed by", "Website", "License"};
static const char *const INFO_VALUES_PAGE[] = {APPVERSION, "Zondax AG", "https://zondax.ch", "Apache 2.0"};
static const char *const INFO_KEYS_PAGE[] = {"Version", "License"};
static const char *const INFO_VALUES_PAGE[] = {APPVERSION, "Apache 2.0"};

static void h_expert_toggle() { app_mode_set_expert(!app_mode_expert()); }

Expand All @@ -114,6 +116,10 @@ static void reviewTransactionChoice(bool confirm) {
}
}

static void h_view_address() {
handleMenuShowAddress();
}

static void reviewGenericChoice(bool confirm) {
const char *msg = "Operation rejected";
bool isSuccess = false;
Expand Down Expand Up @@ -270,20 +276,22 @@ static bool settings_screen_callback(uint8_t page, nbgl_pageContent_t *content)
}

// Info page 1
// We have just two elements, which fits one screen.
// It allows to keep three setting pages, while adding "Show address"
case 1: {
content->type = INFOS_LIST;
content->infosList.nbInfos = MAX_INFO_LIST_ITEM_PER_PAGE;
content->infosList.nbInfos = infoElements;
content->infosList.infoContents = INFO_VALUES_PAGE;
content->infosList.infoTypes = INFO_KEYS_PAGE;
break;
}

// Info page 2
case 2: {
content->type = INFOS_LIST;
content->infosList.nbInfos = infoElements - MAX_INFO_LIST_ITEM_PER_PAGE;
content->infosList.infoContents = &INFO_VALUES_PAGE[MAX_INFO_LIST_ITEM_PER_PAGE];
content->infosList.infoTypes = &INFO_KEYS_PAGE[MAX_INFO_LIST_ITEM_PER_PAGE];
content->type = INFO_BUTTON;
content->infoButton.text = "Show address";
content->infoButton.icon = NULL;
content->infoButton.buttonText = "Review address";
content->infoButton.buttonToken = REVIEW_ADDRESS_TOKEN;
break;
}

Expand Down Expand Up @@ -313,6 +321,10 @@ static void settings_toggle_callback(int token, __Z_UNUSED uint8_t index) {
break;
#endif

case REVIEW_ADDRESS_TOKEN:
h_view_address();
break;

default:
ZEMU_LOGF(50, "Toggling setting not found\n")
break;
Expand Down
15 changes: 10 additions & 5 deletions deps/ledger-zxlib/app/ui/view_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "zxutils_ledger.h"
#include "view_nano.h"
#include "view_nano_inspect.h"
#include "menu_handler.h"

#define BAGL_WIDTH 128
#define BAGL_HEIGHT 32
Expand All @@ -44,6 +45,7 @@ static void h_expert_update();
static void h_review_button_left();
static void h_review_button_right();
static void h_review_button_both();
static void h_view_address();

bool is_accept_item();
void set_accept_item();
Expand Down Expand Up @@ -96,25 +98,24 @@ const ux_menu_entry_t menu_main[] = {
#endif

{NULL, NULL, 0, &C_icon_app, APPVERSION_LINE1, APPVERSION_LINE2, 33, 12},
{NULL, h_view_address, 0, &C_icon_app, "View", "address", 33, 12},

{NULL,
#ifdef APP_SECRET_MODE_ENABLED
h_secret_click,
#else
NULL,
#endif
0, &C_icon_app, "Developed by:", "Zondax.ch", 33, 12},

{NULL, NULL, 0, &C_icon_app, "License: ", "Apache 2.0", 33, 12},
{NULL, os_exit, 0, &C_icon_dashboard, "Quit", NULL, 50, 29},
0, &C_icon_app, "License: ", "Apache 2.0", 33, 12},

{NULL, os_exit, 0, &C_icon_dashboard, "Quit", NULL, 50, 29},
UX_MENU_END
};

const ux_menu_entry_t menu_initialize[] = {
{NULL, NULL, 0, &C_icon_app, MENU_MAIN_APP_LINE1, "Not Ready", 33, 12},
{NULL, h_initialize, 0, &C_icon_app, "Click to", "Initialize", 33, 12},
{NULL, NULL, 0, &C_icon_app, APPVERSION_LINE1, APPVERSION_LINE2, 33, 12},
{NULL, NULL, 0, &C_icon_app, "Developed by:", "Zondax.ch", 33, 12},
{NULL, NULL, 0, &C_icon_app, "License: ", "Apache 2.0", 33, 12},
{NULL, os_exit, 0, &C_icon_dashboard, "Quit", NULL, 50, 29},
UX_MENU_END
Expand Down Expand Up @@ -248,6 +249,10 @@ const bagl_element_t *view_prepro_idle(const bagl_element_t *element) {
return element;
}

static void h_view_address() {
handleMenuShowAddress();
}

void h_review_update() {
zxerr_t err = h_review_update_data();
switch(err) {
Expand Down
13 changes: 10 additions & 3 deletions deps/ledger-zxlib/app/ui/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "tx.h"
#include "view_nano.h"
#include "view_nano_inspect.h"
#include "menu_handler.h"

#ifdef APP_SECRET_MODE_ENABLED
#include "secret.h"
Expand All @@ -48,6 +49,7 @@ static void h_expert_update();
static void h_review_loop_start();
static void h_review_loop_inside();
static void h_review_loop_end();
static void h_view_address();

#ifdef APP_SECRET_MODE_ENABLED
static void h_secret_click();
Expand Down Expand Up @@ -77,14 +79,14 @@ extern unsigned int review_type;
UX_STEP_NOCB(ux_idle_flow_1_step, pbb, { &C_icon_app, MENU_MAIN_APP_LINE1, viewdata.key,});
UX_STEP_CB_INIT(ux_idle_flow_2_step, bn, h_expert_update(), h_expert_toggle(), { "Expert mode:", viewdata.value, });
UX_STEP_NOCB(ux_idle_flow_3_step, bn, { APPVERSION_LINE1, APPVERSION_LINE2, });
UX_STEP_CB(ux_idle_flow_4_step, bn, h_view_address(), { "View", "address", });

#ifdef APP_SECRET_MODE_ENABLED
UX_STEP_CB(ux_idle_flow_4_step, bn, h_secret_click(), { "Developed by:", "Zondax.ch", });
UX_STEP_CB(ux_idle_flow_5_step, bn, h_secret_click(), { "License:", "Apache 2.0", });
#else
UX_STEP_NOCB(ux_idle_flow_4_step, bn, { "Developed by:", "Zondax.ch", });
UX_STEP_NOCB(ux_idle_flow_5_step, bn, { "License:", "Apache 2.0", });
#endif

UX_STEP_NOCB(ux_idle_flow_5_step, bn, { "License:", "Apache 2.0", });
UX_STEP_CB(ux_idle_flow_6_step, pb, os_sched_exit(-1), { &C_icon_dashboard, "Quit",});

#ifdef APP_ACCOUNT_MODE_ENABLED
Expand Down Expand Up @@ -183,6 +185,11 @@ UX_STEP_CB_INIT(ux_review_flow_5_step, pb, NULL, h_shortcut(0), { &C_icon_eye,
//////////////////////////
//////////////////////////

static void h_view_address() {
handleMenuShowAddress();
// view_review_show_impl();

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
}

void h_review_update() {
zxerr_t err = h_review_update_data();
switch(err) {
Expand Down
38 changes: 0 additions & 38 deletions deps/ledger-zxlib/include/base58.h

This file was deleted.

155 changes: 0 additions & 155 deletions deps/ledger-zxlib/src/base58.c

This file was deleted.

Loading

0 comments on commit f33465a

Please sign in to comment.