Port EIP712 to the new NBGL streaming use case
Fixes the Flex navigation issue
This commit is contained in:
@@ -41,10 +41,18 @@ void ui_message_start(const char *title,
|
|||||||
ui_message_confirm_rejection);
|
ui_message_confirm_rejection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_message_712_approved(void) {
|
static void ui_message_712_approved(void) {
|
||||||
ui_712_approve();
|
ui_712_approve();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_message_712_rejected(void) {
|
static void ui_message_712_rejected(void) {
|
||||||
ui_712_reject();
|
ui_712_reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ui_typed_message_review_choice(bool confirm) {
|
||||||
|
if (confirm) {
|
||||||
|
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved);
|
||||||
|
} else {
|
||||||
|
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_message_712_rejected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ void ui_message_start(const char *title,
|
|||||||
void (*start_func)(void),
|
void (*start_func)(void),
|
||||||
void (*approved_func)(void),
|
void (*approved_func)(void),
|
||||||
void (*rejected_func)(void));
|
void (*rejected_func)(void));
|
||||||
|
void ui_typed_message_review_choice(bool confirm);
|
||||||
void ui_message_712_approved(void);
|
|
||||||
void ui_message_712_rejected(void);
|
|
||||||
|
|
||||||
#endif // UI_MESSAGE_SIGNING_H_
|
#endif // UI_MESSAGE_SIGNING_H_
|
||||||
|
|||||||
@@ -1,80 +1,67 @@
|
|||||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|
||||||
|
#include <string.h> // explicit_bzero
|
||||||
#include "common_ui.h"
|
#include "common_ui.h"
|
||||||
#include "ui_nbgl.h"
|
#include "ui_nbgl.h"
|
||||||
#include "ui_logic.h"
|
#include "ui_logic.h"
|
||||||
#include "common_712.h"
|
#include "common_712.h"
|
||||||
#include "nbgl_use_case.h"
|
#include "nbgl_use_case.h"
|
||||||
#include "network.h"
|
|
||||||
#include "ui_message_signing.h"
|
#include "ui_message_signing.h"
|
||||||
#include "ui_signing.h"
|
|
||||||
|
|
||||||
static nbgl_contentTagValue_t pair;
|
static nbgl_contentTagValue_t pair;
|
||||||
|
static nbgl_contentTagValueList_t pairs_list;
|
||||||
|
|
||||||
static bool display_sign_page(uint8_t page, nbgl_pageContent_t *content) {
|
static void message_progress(bool confirm) {
|
||||||
(void) page;
|
if (confirm) {
|
||||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
|
if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
|
||||||
content->infoLongPress.text = TEXT_SIGN_EIP712;
|
ui_712_switch_to_sign();
|
||||||
content->infoLongPress.longPressText = SIGN_BUTTON;
|
}
|
||||||
return true;
|
} else {
|
||||||
|
ui_typed_message_review_choice(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
|
static void message_update(bool confirm) {
|
||||||
bool ret;
|
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
|
|
||||||
switch (page) {
|
if (confirm) {
|
||||||
case 0:
|
explicit_bzero(&pair, sizeof(pair));
|
||||||
// limit the value to one page
|
explicit_bzero(&pairs_list, sizeof(pairs_list));
|
||||||
nbgl_getTextMaxLenInNbLines(LARGE_MEDIUM_FONT,
|
|
||||||
strings.tmp.tmp,
|
|
||||||
SCREEN_WIDTH - (2 * BORDER_MARGIN),
|
|
||||||
NB_MAX_LINES_IN_REVIEW,
|
|
||||||
&len,
|
|
||||||
false);
|
|
||||||
strings.tmp.tmp[len] = '\0';
|
|
||||||
|
|
||||||
pair.item = strings.tmp.tmp2;
|
// limit the value to one page
|
||||||
pair.value = strings.tmp.tmp;
|
nbgl_getTextMaxLenInNbLines(LARGE_MEDIUM_FONT,
|
||||||
content->type = TAG_VALUE_LIST;
|
strings.tmp.tmp,
|
||||||
content->tagValueList.nbPairs = 1;
|
SCREEN_WIDTH - (2 * BORDER_MARGIN),
|
||||||
content->tagValueList.pairs = &pair;
|
NB_MAX_LINES_IN_REVIEW,
|
||||||
content->tagValueList.wrapping = false;
|
&len,
|
||||||
ret = true;
|
false);
|
||||||
break;
|
strings.tmp.tmp[len] = '\0';
|
||||||
|
|
||||||
case 1:
|
pair.item = strings.tmp.tmp2;
|
||||||
if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
|
pair.value = strings.tmp.tmp;
|
||||||
ui_712_switch_to_sign();
|
pairs_list.nbPairs = 1;
|
||||||
}
|
pairs_list.pairs = &pair;
|
||||||
__attribute__((fallthrough));
|
pairs_list.wrapping = false;
|
||||||
default:
|
nbgl_useCaseReviewStreamingContinue(&pairs_list, message_progress);
|
||||||
ret = false;
|
} else {
|
||||||
break;
|
ui_typed_message_review_choice(false);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_display(nbgl_navCallback_t cb) {
|
|
||||||
nbgl_useCaseRegularReview(0, 0, REJECT_BUTTON, NULL, cb, ui_message_review_choice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_712_start(void) {
|
void ui_712_start(void) {
|
||||||
g_position = UI_SIGNING_POSITION_START;
|
nbgl_useCaseReviewStreamingStart(TYPE_MESSAGE,
|
||||||
ui_message_start(TEXT_REVIEW_EIP712,
|
&C_Review_64px,
|
||||||
&ui_712_switch_to_message,
|
TEXT_REVIEW_EIP712,
|
||||||
&ui_message_712_approved,
|
NULL,
|
||||||
&ui_message_712_rejected);
|
message_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_712_switch_to_message(void) {
|
void ui_712_switch_to_message(void) {
|
||||||
g_position = UI_SIGNING_POSITION_REVIEW;
|
message_update(true);
|
||||||
handle_display(display_review_page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_712_switch_to_sign(void) {
|
void ui_712_switch_to_sign(void) {
|
||||||
g_position = UI_SIGNING_POSITION_SIGN;
|
nbgl_useCaseReviewStreamingFinish(TEXT_SIGN_EIP712, ui_typed_message_review_choice);
|
||||||
handle_display(display_sign_page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|||||||
@@ -8,14 +8,6 @@
|
|||||||
static nbgl_contentTagValue_t pairs[2];
|
static nbgl_contentTagValue_t pairs[2];
|
||||||
static nbgl_contentTagValueList_t pairs_list;
|
static nbgl_contentTagValueList_t pairs_list;
|
||||||
|
|
||||||
static void message_review_choice(bool confirm) {
|
|
||||||
if (confirm) {
|
|
||||||
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved);
|
|
||||||
} else {
|
|
||||||
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_message_712_rejected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) {
|
static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) {
|
||||||
array_bytes_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE);
|
array_bytes_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE);
|
||||||
return buffer + offset;
|
return buffer + offset;
|
||||||
@@ -46,5 +38,5 @@ void ui_sign_712_v0(void) {
|
|||||||
TEXT_REVIEW_EIP712,
|
TEXT_REVIEW_EIP712,
|
||||||
NULL,
|
NULL,
|
||||||
TEXT_SIGN_EIP712,
|
TEXT_SIGN_EIP712,
|
||||||
message_review_choice);
|
ui_typed_message_review_choice);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user