Skip to content

Commit

Permalink
Merge pull request #263 from trilitech/palmer@functori@fix-blindsigni…
Browse files Browse the repository at this point in the history
…ng-warning-arrows

Fix blindsigning warning arrows
  • Loading branch information
ajinkyaraj-23 authored Jul 25, 2024
2 parents 5e961e9 + f8c482c commit 60e819d
Show file tree
Hide file tree
Showing 45 changed files with 54 additions and 51 deletions.
Binary file removed app/glyphs/icon_go_cross.gif
Binary file not shown.
Binary file removed app/glyphs/icon_go_dots.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/apdu_pubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ prompt_address(void)
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_EYE);
#endif
tz_ui_stream_push_all(TZ_UI_STREAM_CB_NOCB, "Address", buf,
TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);
tz_ui_stream_push(TZ_UI_STREAM_CB_ACCEPT, "Approve", "",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_TICK);
tz_ui_stream_push(TZ_UI_STREAM_CB_REJECT, "Reject", "",
Expand Down
38 changes: 19 additions & 19 deletions app/src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ refill_blo_im_full(void)
#ifdef HAVE_BAGL
if (st->field_info.is_field_complex && !N_settings.expert_mode) {
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, st->field_info.field_name,
"Needs Expert mode", TZ_UI_LAYOUT_HOME_BP,
"Needs Expert mode", TZ_UI_LAYOUT_HOME_B,
TZ_UI_ICON_NONE);
tz_ui_stream_push(TZ_UI_STREAM_CB_REJECT, "Home", "",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_BACK);
Expand All @@ -187,15 +187,15 @@ refill_blo_im_full(void)
&& (global.keys.apdu.sign.u.clear.last_field_index
!= st->field_info.field_index)) {
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, "Next field requires",
"careful review", TZ_UI_LAYOUT_HOME_BP,
"careful review", TZ_UI_LAYOUT_HOME_B,
TZ_UI_ICON_NONE);
global.keys.apdu.sign.u.clear.last_field_index
= st->field_info.field_index;
}
}

wrote = tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, st->field_info.field_name,
global.line_buf, TZ_UI_LAYOUT_BNP,
global.line_buf, TZ_UI_LAYOUT_BN,
TZ_UI_ICON_NONE);
#elif HAVE_NBGL
PRINTF("[DEBUG] field=%s complex=%d\n", st->field_info.field_name,
Expand All @@ -208,16 +208,16 @@ refill_blo_im_full(void)
if (!N_settings.expert_mode) {
tz_ui_stream_push_all(TZ_UI_STREAM_CB_EXPERT_MODE_ENABLE,
st->field_info.field_name, "complex",
TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);
}

wrote = tz_ui_stream_push_all(
TZ_UI_STREAM_CB_EXPERT_MODE_FIELD, st->field_info.field_name,
global.line_buf, TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
global.line_buf, TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);
} else {
wrote = tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB,
st->field_info.field_name, global.line_buf,
TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);
}

#endif
Expand Down Expand Up @@ -277,31 +277,31 @@ refill_error(void)
"The transaction",
"cannot be trusted.",
#ifdef TARGET_NANOS
TZ_UI_LAYOUT_HOME_BP,
TZ_UI_LAYOUT_HOME_B,
TZ_UI_ICON_NONE);
#else
TZ_UI_LAYOUT_HOME_PB,
TZ_UI_ICON_WARNING);
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB,
" ",
"This transaction\ncould not be\ndecoded correctly.",
TZ_UI_LAYOUT_NP,
"This transaction",
"could not be\ndecoded correctly.",
TZ_UI_LAYOUT_HOME_N,
TZ_UI_ICON_NONE);
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB,
" ",
"It may not be safe\nto sign this\ntransaction.",
TZ_UI_LAYOUT_NP,
"It may not be safe",
"to sign this\ntransaction.",
TZ_UI_LAYOUT_HOME_N,
TZ_UI_ICON_NONE);
#endif
tz_ui_stream_push_all(TZ_UI_STREAM_CB_NOCB,
"Parsing error",
tz_parser_result_name(st->errno),
TZ_UI_LAYOUT_HOME_BNP,
TZ_UI_LAYOUT_HOME_BN,
TZ_UI_ICON_NONE);
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB,
"Learn More:",
"bit.ly/ledger-tez",
TZ_UI_LAYOUT_HOME_BNP,
TZ_UI_LAYOUT_HOME_BN,
TZ_UI_ICON_NONE);
tz_ui_stream_push(TZ_UI_STREAM_CB_BLINDSIGN,
"Accept risk",
Expand All @@ -318,8 +318,8 @@ refill_error(void)
tz_ui_stream_push_all(TZ_UI_STREAM_CB_CANCEL,
"Parsing error",
tz_parser_result_name(st->errno),
TZ_UI_LAYOUT_BNP,
TZ_UI_ICON_CROSS);
TZ_UI_LAYOUT_BN,
TZ_UI_ICON_NONE);
#endif
// clang-format on

Expand Down Expand Up @@ -432,7 +432,7 @@ bs_push_next(void)
}

tz_ui_stream_push_all(TZ_UI_STREAM_CB_NOCB, "Sign Hash", obuf,
TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);
break;
case BLINDSIGN_ST_HASH:
*step = BLINDSIGN_ST_ACCEPT_REJECT;
Expand Down Expand Up @@ -733,7 +733,7 @@ handle_data_apdu_blind(void)

#ifdef HAVE_BAGL
tz_ui_stream_push_all(TZ_UI_STREAM_CB_NOCB, "Sign Hash", type,
TZ_UI_LAYOUT_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_BN, TZ_UI_ICON_NONE);

tz_ui_stream();
#elif HAVE_NBGL
Expand Down
2 changes: 1 addition & 1 deletion app/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef struct {
+ 1]; /// Buffer to store incoming data.
#ifdef HAVE_BAGL
struct {
bagl_element_t bagls[5 + TZ_SCREEN_LINES_11PX];
bagl_element_t bagls[4 + TZ_SCREEN_LINES_11PX];
} ux; /// Config for history screens for nano devices.
#endif

Expand Down
4 changes: 2 additions & 2 deletions app/src/ui_home.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ ui_home_init(void)
#ifdef HAVE_BAGL
tz_ui_stream_init(cb);
tz_ui_stream_push(SCREEN_HOME, "Application", "is ready",
TZ_UI_LAYOUT_HOME_NP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_HOME_N, TZ_UI_ICON_NONE);
tz_ui_stream_push(SCREEN_VERSION, "Version", APPVERSION,
TZ_UI_LAYOUT_HOME_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_HOME_BN, TZ_UI_ICON_NONE);
tz_ui_stream_push(SCREEN_SETTINGS, "Settings", "", TZ_UI_LAYOUT_HOME_PB,
TZ_UI_ICON_SETTINGS);
tz_ui_stream_push(SCREEN_QUIT, "Quit?", "", TZ_UI_LAYOUT_HOME_PB,
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ui_settings_init(int16_t page)

tz_ui_stream_init(cb);
tz_ui_stream_push(EXPERT_MODE, "Expert mode", exp_mode,
TZ_UI_LAYOUT_HOME_BNP, TZ_UI_ICON_NONE);
TZ_UI_LAYOUT_HOME_BN, TZ_UI_ICON_NONE);
tz_ui_stream_push(BACK, "Back", "", TZ_UI_LAYOUT_HOME_PB,
TZ_UI_ICON_BACK);
tz_ui_stream_close();
Expand Down
41 changes: 21 additions & 20 deletions app/src/ui_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ redisplay_screen(tz_ui_layout_type_t layout, uint8_t icon_pos)
TZ_PREAMBLE(("void"));
tz_ui_stream_t *s = &global.stream;
size_t bucket;
bucket = s->current % TZ_UI_STREAM_HISTORY_SCREENS;
tz_ui_icon_t icon = s->screens[bucket].icon;
bucket = s->current % TZ_UI_STREAM_HISTORY_SCREENS;
tz_ui_icon_t icon = s->screens[bucket].icon;
bool has_home_mask = layout & TZ_UI_LAYOUT_HOME_MASK;
layout = layout & ~TZ_UI_LAYOUT_HOME_MASK;

bagl_element_t init[] = {
// {type, userid, x, y, width, height, stroke, radius,
Expand Down Expand Up @@ -278,16 +280,15 @@ redisplay_screen(tz_ui_layout_type_t layout, uint8_t icon_pos)
= 3; /// first three lines are for black rectangle, left screen icon
/// and right screen icon.

if ((layout == TZ_UI_LAYOUT_BP) || (layout == TZ_UI_LAYOUT_HOME_BP)) {
if (layout == TZ_UI_LAYOUT_B) {
// Change the contents to bold.
for (int i = txt_start_line + 1; i < icon_pos; i++) {
init[i].component.font_id = BOLD;
}
} else if ((layout == TZ_UI_LAYOUT_NP)
|| (layout == TZ_UI_LAYOUT_HOME_NP)) {
} else if (layout == TZ_UI_LAYOUT_N) {
// Set title to Regular.
init[txt_start_line].component.font_id = REGULAR;
} else if (layout == TZ_UI_LAYOUT_HOME_PB) {
} else if (layout == TZ_UI_LAYOUT_PB) {
// Icon will be at txt_start_line.
// modify the x,y coordinates for index txt_start_line to end.
init[txt_start_line].component = init[icon_pos].component;
Expand All @@ -311,30 +312,29 @@ redisplay_screen(tz_ui_layout_type_t layout, uint8_t icon_pos)
= init[txt_start_line].component.y + 16 + 8 + ((i - 4) * 12);
init[i].component.width = 112;
}
}

if (icon) {
init[icon_pos].text = find_icon(icon);
#ifdef TARGET_NANOS
// Make sure text does not overflow on icon line in non-PB layouts.
if (layout != TZ_UI_LAYOUT_HOME_PB) {
init[icon_pos - 1].text = NULL;
if (icon) {
init[icon_pos].text = find_icon(icon);
}
#endif
}
} /// otherwise TZ_UI_LAYOUT_BN

// if the screen layout type is home , set the left and right arrows to
// middle of screen.
if (layout & TZ_UI_LAYOUT_HOME_MASK) {
if (has_home_mask) {
init[1].component.y = (BAGL_HEIGHT / 2) - 3;
init[2].component.y = (BAGL_HEIGHT / 2) - 3;
// as icon_pos = txt_start_line in TZ_UI_LAYOUT_HOME_PB layout,
// as icon_pos = txt_start_line in TZ_UI_LAYOUT_PB layout,
// following changes dont affect it.
for (int i = txt_start_line; i < icon_pos; i++) {
init[i].component.x = 8;
init[i].component.width = 112;
init[i].component.y
= (BAGL_HEIGHT / 2) - 3 + ((i - txt_start_line) * 13);
init[i].component.y =
/// height if title only
((BAGL_HEIGHT / 2) + 3)
/// half a line height for each additional line
- ((s->screens[bucket].body_len * 13) / 2)
/// 13px space between lines
+ ((i - txt_start_line) * 13);
}
}

Expand Down Expand Up @@ -496,7 +496,7 @@ tz_ui_stream_pushl(tz_ui_cb_type_t cb_type, const char *title,
s->screens[bucket].layout_type = layout_type;
s->screens[bucket].icon = icon;

int line = 0;
short line = 0;
while ((offset < length) && (line < TZ_UI_STREAM_CONTENTS_LINES)) {
uint8_t will_fit;

Expand All @@ -517,6 +517,7 @@ tz_ui_stream_pushl(tz_ui_cb_type_t cb_type, const char *title,

line++;
}
s->screens[bucket].body_len = line;

PRINTF("[DEBUG] tz_ui_stream_pushl(%s, %s, %u)\n", title, value, max);
PRINTF("[DEBUG] bucket %d\n", bucket);
Expand Down
16 changes: 9 additions & 7 deletions app/src/ui_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ typedef uint8_t tz_ui_cb_type_t;
*
*/
typedef enum : uint8_t {
TZ_UI_LAYOUT_BNP = 0x01,
TZ_UI_LAYOUT_BP = 0x02,
TZ_UI_LAYOUT_NP = 0x03,
TZ_UI_LAYOUT_HOME_PB = (0x04 | TZ_UI_LAYOUT_HOME_MASK),
TZ_UI_LAYOUT_HOME_BNP = (0x05 | TZ_UI_LAYOUT_HOME_MASK),
TZ_UI_LAYOUT_HOME_BP = (0x06 | TZ_UI_LAYOUT_HOME_MASK),
TZ_UI_LAYOUT_HOME_NP = (0x07 | TZ_UI_LAYOUT_HOME_MASK)
TZ_UI_LAYOUT_BN = 0x01,
TZ_UI_LAYOUT_B = 0x02,
TZ_UI_LAYOUT_N = 0x03,
TZ_UI_LAYOUT_PB = 0x04,
TZ_UI_LAYOUT_HOME_PB = (TZ_UI_LAYOUT_HOME_MASK | TZ_UI_LAYOUT_PB),
TZ_UI_LAYOUT_HOME_BN = (TZ_UI_LAYOUT_HOME_MASK | TZ_UI_LAYOUT_BN),
TZ_UI_LAYOUT_HOME_B = (TZ_UI_LAYOUT_HOME_MASK | TZ_UI_LAYOUT_B),
TZ_UI_LAYOUT_HOME_N = (TZ_UI_LAYOUT_HOME_MASK | TZ_UI_LAYOUT_N)
} tz_ui_layout_type_t;

/**
Expand Down Expand Up @@ -143,6 +144,7 @@ typedef struct {
char *title; /// Title to display on the screen.
char *body[TZ_UI_STREAM_CONTENTS_LINES]; /// Body to display on the
/// screen (Below title).
short body_len; /// number of non-empty lines in the body.
#else
nbgl_layoutTagValue_t
pairs[NB_MAX_DISPLAYED_PAIRS_IN_REVIEW]; /// Title-value pairs to be
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 60e819d

Please sign in to comment.