Now uses macros for NBGL contstant texts
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
#include "ui_callbacks.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ethUtils.h"
|
||||
#include "ui_signing.h"
|
||||
#include "plugins.h"
|
||||
#include "domain_name.h"
|
||||
|
||||
#define TEXT_TX "transaction"
|
||||
// 1 more than actually displayed on screen, because of calculations in StaticReview
|
||||
#define MAX_PLUGIN_ITEMS_PER_SCREEN 4
|
||||
#define TAG_MAX_LEN 43
|
||||
@@ -51,10 +53,10 @@ static void onConfirmAbandon(void) {
|
||||
}
|
||||
|
||||
static void rejectTransactionQuestion(void) {
|
||||
nbgl_useCaseConfirm("Reject transaction?",
|
||||
nbgl_useCaseConfirm(REJECT_QUESTION(TEXT_TX),
|
||||
NULL,
|
||||
"Yes, reject",
|
||||
"Go back to transaction",
|
||||
REJECT_CONFIRM_BUTTON,
|
||||
RESUME(TEXT_TX),
|
||||
onConfirmAbandon);
|
||||
}
|
||||
|
||||
@@ -159,7 +161,7 @@ static void reviewContinue(void) {
|
||||
.centeredInfo.text3 = NULL,
|
||||
.centeredInfo.style = LARGE_CASE_INFO,
|
||||
.centeredInfo.offsetY = -32,
|
||||
.footerText = "Reject transaction",
|
||||
.footerText = REJECT(TEXT_TX),
|
||||
.footerToken = REJECT_TOKEN,
|
||||
.tapActionText = "Tap to continue",
|
||||
.tapActionToken = START_REVIEW_TOKEN,
|
||||
@@ -211,12 +213,9 @@ static void reviewContinueCommon(void) {
|
||||
useCaseTagValueList.smallCaseForValue = false;
|
||||
useCaseTagValueList.wrapping = false;
|
||||
infoLongPress.icon = get_app_icon(true);
|
||||
infoLongPress.text = tx_approval_context.fromPlugin ? staxSharedBuffer : "Review transaction";
|
||||
infoLongPress.longPressText = "Hold to sign";
|
||||
nbgl_useCaseStaticReview(&useCaseTagValueList,
|
||||
&infoLongPress,
|
||||
"Reject transaction",
|
||||
reviewChoice);
|
||||
infoLongPress.text = tx_approval_context.fromPlugin ? staxSharedBuffer : SIGN(TEXT_TX);
|
||||
infoLongPress.longPressText = SIGN_BUTTON;
|
||||
nbgl_useCaseStaticReview(&useCaseTagValueList, &infoLongPress, REJECT(TEXT_TX), reviewChoice);
|
||||
}
|
||||
|
||||
// Replace "Review" by "Sign" and add questionmark
|
||||
@@ -264,15 +263,15 @@ static void buildFirstPage(void) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||
staxSharedBuffer,
|
||||
NULL,
|
||||
"Reject transaction",
|
||||
REJECT(TEXT_TX),
|
||||
reviewContinue,
|
||||
rejectTransactionQuestion);
|
||||
prepare_sign_text();
|
||||
} else {
|
||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||
"Review transaction",
|
||||
REVIEW(TEXT_TX),
|
||||
NULL,
|
||||
"Reject transaction",
|
||||
REJECT(TEXT_TX),
|
||||
reviewContinue,
|
||||
rejectTransactionQuestion);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common_ui.h"
|
||||
#include "ui_signing.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "network.h"
|
||||
|
||||
@@ -61,7 +62,7 @@ static void buildScreen(void) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||
staxSharedBuffer,
|
||||
NULL,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
reviewContinue,
|
||||
reviewReject);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common_ui.h"
|
||||
#include "ui_signing.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "nbgl_use_case.h"
|
||||
@@ -45,14 +46,14 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
}
|
||||
|
||||
static void reviewContinue(void) {
|
||||
nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice);
|
||||
nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice);
|
||||
}
|
||||
|
||||
static void buildFirstPage(void) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||
review_string,
|
||||
NULL,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
reviewContinue,
|
||||
reviewReject);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_signing.h"
|
||||
#include "common_712.h"
|
||||
#include "ui_message_signing.h"
|
||||
#include "glyphs.h"
|
||||
@@ -17,10 +18,10 @@ static void ui_message_rejection_handler(bool confirm) {
|
||||
|
||||
static void ui_message_confirm_rejection(void) {
|
||||
nbgl_useCaseChoice(&C_warning64px,
|
||||
"Reject message?",
|
||||
REJECT_QUESTION(TEXT_MESSAGE),
|
||||
NULL,
|
||||
"Yes, reject",
|
||||
"Go back to message",
|
||||
REJECT_CONFIRM_BUTTON,
|
||||
RESUME(TEXT_MESSAGE),
|
||||
ui_message_rejection_handler);
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ void ui_message_start(const char *title,
|
||||
nbgl_useCaseReviewStart(&C_Message_64px,
|
||||
title,
|
||||
NULL,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
start_func,
|
||||
ui_message_confirm_rejection);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define TEXT_MESSAGE "message"
|
||||
#define TEXT_TYPED_MESSAGE "typed " TEXT_MESSAGE
|
||||
#define TEXT_REVIEW_EIP712 REVIEW(TEXT_TYPED_MESSAGE)
|
||||
#define TEXT_SIGN_EIP712 SIGN(TEXT_TYPED_MESSAGE)
|
||||
|
||||
void ui_message_review_choice(bool confirm);
|
||||
void ui_message_start(const char *title,
|
||||
void (*start_func)(void),
|
||||
|
||||
@@ -14,8 +14,8 @@ static nbgl_layoutTagValue_t pair;
|
||||
static bool display_sign_page(uint8_t page, nbgl_pageContent_t *content) {
|
||||
(void) page;
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
|
||||
content->infoLongPress.text = "Sign typed message";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.text = TEXT_SIGN_EIP712;
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
|
||||
}
|
||||
|
||||
static void handle_display(nbgl_navCallback_t cb) {
|
||||
nbgl_useCaseRegularReview(0, 0, "Reject", NULL, cb, ui_message_review_choice);
|
||||
nbgl_useCaseRegularReview(0, 0, REJECT_BUTTON, NULL, cb, ui_message_review_choice);
|
||||
}
|
||||
|
||||
static void resume_review(void) {
|
||||
@@ -85,7 +85,7 @@ static void resume_review(void) {
|
||||
|
||||
void ui_712_start(void) {
|
||||
g_position = UI_SIGNING_POSITION_START;
|
||||
ui_message_start("Review typed message",
|
||||
ui_message_start(TEXT_REVIEW_EIP712,
|
||||
&ui_712_switch_to_message,
|
||||
&resume_review,
|
||||
&ui_message_712_approved,
|
||||
|
||||
@@ -35,8 +35,8 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
|
||||
} else if (page == 1) {
|
||||
g_position = UI_SIGNING_POSITION_SIGN;
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
|
||||
content->infoLongPress.text = "Sign typed message";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.text = TEXT_SIGN_EIP712;
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ static void display_review(void) {
|
||||
}
|
||||
nbgl_useCaseRegularReview(page,
|
||||
2,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
NULL,
|
||||
display_review_page,
|
||||
ui_message_review_choice);
|
||||
@@ -80,7 +80,7 @@ static void resume_review(void) {
|
||||
|
||||
void ui_sign_712_v0(void) {
|
||||
g_position = UI_SIGNING_POSITION_START;
|
||||
ui_message_start("Sign typed message",
|
||||
ui_message_start(TEXT_REVIEW_EIP712,
|
||||
&start_review,
|
||||
&resume_review,
|
||||
&ui_message_712_approved,
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "ui_message_signing.h"
|
||||
#include "ui_signing.h"
|
||||
|
||||
#define TEXT_REVIEW_EIP191 REVIEW(TEXT_MESSAGE)
|
||||
#define TEXT_SIGN_EIP191 SIGN(TEXT_MESSAGE)
|
||||
|
||||
typedef enum {
|
||||
UI_191_ACTION_IDLE = 0,
|
||||
UI_191_ACTION_ADVANCE_IN_MESSAGE,
|
||||
@@ -21,7 +24,6 @@ static bool skip_message;
|
||||
|
||||
static nbgl_layoutTagValue_t pair;
|
||||
|
||||
//
|
||||
static uint32_t eip191MessageIdx = 0;
|
||||
static uint32_t stringsTmpTmpIdx = 0;
|
||||
|
||||
@@ -82,8 +84,8 @@ static bool display_message(nbgl_pageContent_t *content) {
|
||||
|
||||
static void display_sign(nbgl_pageContent_t *content) {
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &C_Message_64px;
|
||||
content->infoLongPress.text = "Sign Message";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.text = TEXT_SIGN_EIP191;
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
g_position = UI_SIGNING_POSITION_SIGN;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ static bool nav_callback(uint8_t page, nbgl_pageContent_t *content) {
|
||||
}
|
||||
|
||||
static void continue_review(void) {
|
||||
nbgl_useCaseForwardOnlyReview("Reject", NULL, nav_callback, ui_message_review_choice);
|
||||
nbgl_useCaseForwardOnlyReview(REJECT_BUTTON, NULL, nav_callback, ui_message_review_choice);
|
||||
}
|
||||
|
||||
static void resume_message(void) {
|
||||
@@ -131,7 +133,7 @@ void ui_191_start(void) {
|
||||
eip191MessageIdx = 0;
|
||||
stringsTmpTmpIdx = 0;
|
||||
|
||||
ui_message_start("Review message",
|
||||
ui_message_start(TEXT_REVIEW_EIP191,
|
||||
&ui_191_switch_to_message,
|
||||
&resume_message,
|
||||
&sign_message,
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
#ifndef UI_SIGNING_H_
|
||||
#define UI_SIGNING_H_
|
||||
|
||||
#define SIGN_BUTTON "Hold to sign"
|
||||
#define REJECT_BUTTON "Reject"
|
||||
#define SIGN(msg) "Sign " msg "?"
|
||||
#define REVIEW(msg) "Review " msg
|
||||
#define REJECT(msg) "Reject " msg
|
||||
#define REJECT_QUESTION(msg) REJECT(msg) "?"
|
||||
#define REJECT_CONFIRM_BUTTON "Yes, reject"
|
||||
#define RESUME(msg) "Go back to " msg
|
||||
|
||||
typedef enum {
|
||||
UI_SIGNING_POSITION_START = 0,
|
||||
UI_SIGNING_POSITION_REVIEW,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common_ui.h"
|
||||
#include "ui_signing.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "nbgl_use_case.h"
|
||||
@@ -39,7 +40,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
} else if (page == 1) {
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
|
||||
content->infoLongPress.text = "Review stark limit order";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -48,14 +49,14 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
}
|
||||
|
||||
static void reviewContinue(void) {
|
||||
nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice);
|
||||
nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice);
|
||||
}
|
||||
|
||||
static void buildFirstPage(void) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(false),
|
||||
"Review stark limit order",
|
||||
NULL,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
reviewContinue,
|
||||
reviewReject);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "shared_context.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_signing.h"
|
||||
#include "starkDisplayUtils.h"
|
||||
#include "ethUtils.h"
|
||||
#include "network.h"
|
||||
@@ -84,7 +85,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
if (page == 2) {
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
|
||||
content->infoLongPress.text = "Review transaction";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -93,7 +94,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
static void reviewContinue(void) {
|
||||
nbgl_useCaseRegularReview(0,
|
||||
context.conditional ? 3 : 2,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
NULL,
|
||||
displayTransactionPage,
|
||||
reviewChoice);
|
||||
@@ -119,7 +120,7 @@ void ui_stark_transfer(bool selfTransfer, bool conditional) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(false),
|
||||
"Review stark transaction",
|
||||
subTitle,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
reviewContinue,
|
||||
reviewReject);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "common_ui.h"
|
||||
#include "ui_signing.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "nbgl_use_case.h"
|
||||
@@ -42,7 +42,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
} else if (page == 1) {
|
||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
|
||||
content->infoLongPress.text = "Unsafe Stark Sign";
|
||||
content->infoLongPress.longPressText = "Hold to sign";
|
||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -51,14 +51,14 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
}
|
||||
|
||||
static void reviewContinue(void) {
|
||||
nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice);
|
||||
nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice);
|
||||
}
|
||||
|
||||
static void buildFirstPage(void) {
|
||||
nbgl_useCaseReviewStart(get_app_icon(false),
|
||||
"Unsafe Stark Sign",
|
||||
NULL,
|
||||
"Reject",
|
||||
REJECT_BUTTON,
|
||||
reviewContinue,
|
||||
reviewReject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user