Skip to content

Commit

Permalink
add support for key sharing view in stax
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Jul 9, 2024
1 parent 4d2993c commit 35b9b61
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef enum {
REVIEW_ADDRESS,
REVIEW_TXN,
REVIEW_MSG,
REVIEW_KEYS,
} review_type_e;

#ifdef APP_SECRET_MODE_ENABLED
Expand Down
4 changes: 4 additions & 0 deletions app/ui/view_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ zxerr_t h_review_update_data() {
intro_value = PIC(review_addrvalue);
break;

case REVIEW_KEYS:
intro_value = PIC(review_addrvalue);
break;

case REVIEW_TXN:
default:
intro_value = PIC(review_txvalue);
Expand Down
60 changes: 60 additions & 0 deletions app/ui/view_stax.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ static const char* const INFO_VALUES[] = {APPVERSION, "Zondax AG", "https://zond
static const char* txn_choice_message = "Reject transaction?";
static const char* add_choice_message = "Reject address?";
static const char* ui_choice_message = "Reject configuration?";
static const char* keys_choice_message = "Reject keys?";

static const char* txn_verified = "TRANSACTION\nSIGNED";
static const char* txn_cancelled = "Transaction rejected";

static const char* add_verified = "ADDRESS\nVERIFIED";
static const char* add_cancelled = "Address verification\ncancelled";

static const char* keys_verified = "KEYS\nSHARED";
static const char* keys_cancelled = "Key sharing\ncancelled";

static void h_expert_toggle() {
app_mode_set_expert(!app_mode_expert());
}
Expand All @@ -117,6 +121,10 @@ static void confirm_callback(bool confirm) {
message = confirm ? add_verified : add_cancelled;
break;

case REVIEW_KEYS:
message = confirm ? keys_verified : keys_cancelled;
break;

case REVIEW_TXN:
message = confirm ? txn_verified : txn_cancelled;
break;
Expand Down Expand Up @@ -151,6 +159,10 @@ static void action_callback(bool confirm) {
message = add_choice_message;
break;

case REVIEW_KEYS:
message = keys_choice_message;
break;

case REVIEW_TXN:
message = txn_choice_message;
break;
Expand Down Expand Up @@ -449,6 +461,40 @@ static void review_address() {
nbgl_useCaseAddressConfirmationExt(viewdata.value, action_callback, extraPagesPtr);
}

static void review_keys() {
nbgl_layoutTagValueList_t* extraPagesPtr = NULL;

uint8_t numItems = 0;
if (viewdata.viewfuncGetNumItems == NULL ||
viewdata.viewfuncGetNumItems(&numItems) != zxerr_ok ||
numItems > NB_MAX_DISPLAYED_PAIRS_IN_REVIEW) {
ZEMU_LOGF(50, "Show keys error\n")
view_error_show();
}

for (uint8_t idx = 1; idx < numItems; idx++) {
pairs[idx - 1].item = viewdata.keys[idx];
pairs[idx - 1].value = viewdata.values[idx];

viewdata.itemIdx = idx;
viewdata.key = viewdata.keys[idx];
viewdata.value = viewdata.values[idx];
h_review_update_data();

pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = idx;
pairList.pairs = pairs;
extraPagesPtr = &pairList;
}

viewdata.itemIdx = 0;
viewdata.key = viewdata.keys[0];
viewdata.value = viewdata.values[0];
h_review_update_data();

nbgl_useCaseAddressConfirmationExt(viewdata.value, action_callback, extraPagesPtr);
}

static nbgl_layoutTagValue_t* update_item_callback(uint8_t index) {
uint8_t internalIndex = index % NB_MAX_DISPLAYED_PAIRS_IN_REVIEW;

Expand Down Expand Up @@ -522,6 +568,20 @@ void view_review_show_impl(unsigned int requireReply){
cancel);
break;
}
case REVIEW_KEYS: {
#if defined(CUSTOM_KEYS_TEXT)
const char KEYS_TEXT[] = CUSTOM_KEYS_TEXT;
#else
const char KEYS_TEXT[] = "Share " MENU_MAIN_APP_LINE1 "\nkeys";
#endif
nbgl_useCaseReviewStart(&C_icon_stax_64,
KEYS_TEXT,
NULL,
CANCEL_LABEL,
review_keys,
cancel);
break;
}
case REVIEW_TXN:
default:
nbgl_useCaseReviewStart(&C_icon_stax_64,
Expand Down
4 changes: 4 additions & 0 deletions app/ui/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ void run_ux_review_flow(review_type_e reviewType, const ux_flow_step_t* const st
ux_review_flow[index++] = &ux_review_flow_2_review_title;
break;

case REVIEW_KEYS:
ux_review_flow[index++] = &ux_review_flow_2_review_title;
break;

case REVIEW_MSG:
ux_review_flow[index++] = &ux_review_flow_4_review_title;
break;
Expand Down

0 comments on commit 35b9b61

Please sign in to comment.