Skip to content

Commit

Permalink
Merge pull request #175 from Zondax/group_txs
Browse files Browse the repository at this point in the history
Review Group feature on nano devices
  • Loading branch information
0xPxt authored Feb 18, 2025
2 parents df58617 + 042f800 commit 9eb8360
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef enum {
REVIEW_GENERIC,
REVIEW_TXN,
REVIEW_MSG,
REVIEW_GROUP_TXN,
} review_type_e;

#ifdef APP_SECRET_MODE_ENABLED
Expand Down
4 changes: 2 additions & 2 deletions app/ui/view_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ zxerr_t h_review_update_data() {
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, APPROVE_LABEL);
} else {
#if defined(APP_BLINDSIGN_MODE_ENABLED)
if (app_mode_blindsign_required() && review_type == REVIEW_TXN) {
if (app_mode_blindsign_required() && (review_type == REVIEW_TXN || review_type == REVIEW_GROUP_TXN)) {
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s %s", APPROVE_LABEL_1, APPROVE_LABEL_2);
} else {
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", APPROVE_LABEL);
Expand Down Expand Up @@ -247,7 +247,7 @@ zxerr_t h_review_update_data() {
intro_key = PIC(shortcut_key);
intro_value = PIC(shortcut_value);
#elif defined(APP_BLINDSIGN_MODE_ENABLED)
if (app_mode_blindsign_required() && review_type == REVIEW_TXN) {
if (app_mode_blindsign_required() && (review_type == REVIEW_TXN || review_type == REVIEW_GROUP_TXN)) {
switch (viewdata.itemIdx) {
case 0:
intro_key = PIC(review_skip_key);
Expand Down
4 changes: 2 additions & 2 deletions app/ui/view_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ bool should_show_skip_menu_right() {
// When going forwards: we're at last page of current item
// When going backwards: we're at first page of current item
return viewdata.with_confirmation &&
(review_type == REVIEW_TXN || review_type == REVIEW_MSG) &&
(review_type == REVIEW_TXN || review_type == REVIEW_GROUP_TXN || review_type == REVIEW_MSG) &&
// To enable left arrow rendering
viewdata.pageIdx > 0 &&
// only if all item's pages has been rendered
Expand All @@ -240,7 +240,7 @@ bool should_show_skip_menu_right() {
// Helper to check if we should show skip menu
bool should_show_skip_menu_left() {
return viewdata.with_confirmation &&
(review_type == REVIEW_TXN || review_type == REVIEW_MSG) &&
(review_type == REVIEW_TXN || review_type == REVIEW_GROUP_TXN || review_type == REVIEW_MSG) &&
viewdata.itemIdx > 0 && // Not the first item
// if all pages have been rendered
// Reached first page of current item
Expand Down
21 changes: 18 additions & 3 deletions app/ui/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include <stdio.h>
#include <string.h>

char intro_msg_buf[MAX_CHARS_PER_KEY_LINE];
char intro_submsg_buf[MAX_CHARS_PER_VALUE1_LINE];

bool custom_callback_active = false;
// Add global variable to store original callback at the top with other globals
unsigned int (*original_button_callback)(unsigned int button_mask, unsigned int button_mask_counter) = NULL;
Expand Down Expand Up @@ -260,6 +263,12 @@ UX_FLOW_DEF_NOCB(ux_review_flow_1_review_title, pbb,
REVIEW_SCREEN_TITLE,
REVIEW_SCREEN_TXN_VALUE,
});
UX_FLOW_DEF_NOCB(ux_review_flow_1_review_group_title, pbb,
{
&C_icon_app,
intro_msg_buf,
intro_submsg_buf,
});
UX_FLOW_DEF_NOCB(ux_review_flow_2_review_title, pbb,
{
&C_icon_app,
Expand Down Expand Up @@ -366,7 +375,7 @@ void h_review_loop_end() {
ux_layout_bnnn_paging_reset();
// If we're at the end of current item and there's more to show
if (viewdata.with_confirmation &&
(review_type == REVIEW_TXN || review_type == REVIEW_MSG) &&
(review_type == REVIEW_TXN || review_type == REVIEW_GROUP_TXN || review_type == REVIEW_MSG) &&
viewdata.pageIdx == viewdata.pageCount - 1 &&
// Ensure that at least the first item is displayed.
// The UI design may vary between applications. For example, item 0 might
Expand Down Expand Up @@ -591,7 +600,13 @@ void run_ux_review_flow(review_type_e reviewType, const ux_flow_step_t *const st
ux_review_flow[index++] = &ux_approval_blind_signing_message_step;
}
#endif
ux_review_flow[index++] = &ux_review_flow_1_review_title;
if (reviewType == REVIEW_GROUP_TXN) {
viewdata.viewfuncGetItem(0xFF, intro_msg_buf, MAX_CHARS_PER_KEY_LINE, intro_submsg_buf,
MAX_CHARS_PER_VALUE1_LINE, 0, &viewdata.pageCount);
ux_review_flow[index++] = &ux_review_flow_1_review_group_title;
} else {
ux_review_flow[index++] = &ux_review_flow_1_review_title;
}
if (app_mode_shortcut()) {
ux_review_flow[index++] = &ux_review_flow_5_step;
}
Expand All @@ -607,7 +622,7 @@ void run_ux_review_flow(review_type_e reviewType, const ux_flow_step_t *const st
ux_review_flow[index++] = &ux_review_flow_4_step;
} else {
#ifdef APP_BLINDSIGN_MODE_ENABLED
if (app_mode_blindsign_required() && reviewType == REVIEW_TXN) {
if (app_mode_blindsign_required() && (reviewType == REVIEW_TXN || reviewType == REVIEW_GROUP_TXN)) {
ux_review_flow[index++] = &ux_review_flow_3_step_blindsign;
} else {
ux_review_flow[index++] = &ux_review_flow_3_step;
Expand Down
2 changes: 1 addition & 1 deletion include/zxversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
#pragma once

#define ZXLIB_MAJOR 32
#define ZXLIB_MINOR 2
#define ZXLIB_MINOR 3
#define ZXLIB_PATCH 0

0 comments on commit 9eb8360

Please sign in to comment.