Skip to content

Commit 802f655

Browse files
committed
add intent in sign screen
1 parent 6ad0a46 commit 802f655

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

app/ui/view_nbgl.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const char *intro_message = NULL;
5353
const char *intro_submessage = NULL;
5454
char intro_msg_buf[MAX_CHARS_PER_VALUE1_LINE];
5555
char intro_submsg_buf[MAX_CHARS_SUBMSG_LINE];
56+
static char approval_label_buf[64];
5657

5758
#define REVIEW_STANDALONE_SIZE 22
5859
#define REVIEW_MESSAGE_SIZE 18
@@ -476,7 +477,8 @@ static void config_useCaseReview(nbgl_operationType_t type) {
476477
} else {
477478
nbgl_useCaseReview(
478479
type, &pairList, &C_icon_stax_64, (intro_message == NULL ? "Review transaction" : intro_message),
479-
(intro_submessage == NULL ? NULL : intro_submessage), APPROVE_LABEL_NBGL, reviewTransactionChoice);
480+
(intro_submessage == NULL ? NULL : intro_submessage),
481+
(approval_label_buf[0] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL), reviewTransactionChoice);
480482
}
481483
}
482484

@@ -497,9 +499,9 @@ static void config_useCaseMessageReview() {
497499
(intro_message == NULL ? "Review Message" : intro_message), NULL,
498500
"Accept risk and sign message ?", NULL, reviewMessageChoice);
499501
} else {
500-
nbgl_useCaseReview(TYPE_MESSAGE, &pairList, &C_Review_64px,
501-
(intro_message == NULL ? "Review Message" : intro_message), NULL, APPROVE_LABEL_NBGL_MSG,
502-
reviewMessageChoice);
502+
nbgl_useCaseReview(
503+
TYPE_MESSAGE, &pairList, &C_Review_64px, (intro_message == NULL ? "Review Message" : intro_message), NULL,
504+
(approval_label_buf[0] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL_MSG), reviewMessageChoice);
503505
}
504506
}
505507

@@ -595,6 +597,25 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
595597
}
596598
intro_message = intro_msg_buf;
597599
intro_submessage = NULL; // No second line for NBGL
600+
601+
// Format the approval label with intent for the final approval screen
602+
const char *sign_text = (review_type == REVIEW_MSG) ? "Sign message" : "Sign transaction";
603+
ret = snprintf(approval_label_buf, sizeof(approval_label_buf), "%s to %s?", sign_text, intent);
604+
605+
// Check if truncation occurred and add ellipsis if needed
606+
if (ret >= (int)sizeof(approval_label_buf)) {
607+
const size_t buf_len = sizeof(approval_label_buf);
608+
if (buf_len >= 4) {
609+
approval_label_buf[buf_len - 4] = '.';
610+
approval_label_buf[buf_len - 3] = '.';
611+
approval_label_buf[buf_len - 2] = '.';
612+
approval_label_buf[buf_len - 1] = '\0';
613+
}
614+
}
615+
} else {
616+
// Use default labels if no intent
617+
snprintf(approval_label_buf, sizeof(approval_label_buf), "%s",
618+
(review_type == REVIEW_MSG) ? APPROVE_LABEL_NBGL_MSG : APPROVE_LABEL_NBGL);
598619
}
599620

600621
h_paging_init();

0 commit comments

Comments
 (0)