diff --git a/src_nbgl/ui_message_signing.c b/src_nbgl/ui_message_signing.c index 40544df418..c243196445 100644 --- a/src_nbgl/ui_message_signing.c +++ b/src_nbgl/ui_message_signing.c @@ -7,23 +7,11 @@ static void (*g_approved_func)(void) = NULL; static void (*g_rejected_func)(void) = NULL; -static void ui_message_rejection_handler() { - nbgl_useCaseStatus("Message signing\ncancelled", false, g_rejected_func); -} - -static void ui_message_confirm_rejection(void) { - nbgl_useCaseConfirm(REJECT_QUESTION(TEXT_MESSAGE), - NULL, - REJECT_CONFIRM_BUTTON, - RESUME(TEXT_MESSAGE), - ui_message_rejection_handler); -} - void ui_message_review_choice(bool confirm) { if (confirm) { - nbgl_useCaseStatus("MESSAGE\nSIGNED", true, g_approved_func); + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, g_approved_func); } else { - ui_message_confirm_rejection(); + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, g_rejected_func); } } @@ -33,12 +21,12 @@ void ui_message_start(const char *title, void (*rejected_func)(void)) { g_approved_func = approved_func; g_rejected_func = rejected_func; - nbgl_useCaseReviewStart(&C_Review_64px, - title, - NULL, - REJECT_BUTTON, - start_func, - ui_message_confirm_rejection); + // nbgl_useCaseReviewStart(&C_Review_64px, + // title, + // NULL, + // REJECT_BUTTON, + // start_func, + // ui_message_confirm_rejection); } void ui_message_712_approved(void) { diff --git a/src_nbgl/ui_sign_712.c b/src_nbgl/ui_sign_712.c index c612fcfc96..a658f065ec 100644 --- a/src_nbgl/ui_sign_712.c +++ b/src_nbgl/ui_sign_712.c @@ -10,75 +10,56 @@ #include "ui_signing.h" static nbgl_layoutTagValue_t pair; +static nbgl_layoutTagValueList_t pairsList; -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 = TEXT_SIGN_EIP712; - content->infoLongPress.longPressText = SIGN_BUTTON; - return true; +static void reviewChoice(bool confirm) { + if (confirm) { + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved); + } else { + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_rejected); + } } -static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { - bool ret; +void ui_712_start(void) { uint16_t len; + g_position = UI_SIGNING_POSITION_START; - switch (page) { - case 0: - // limit the value to one page - nbgl_getTextMaxLenInNbLines(BAGL_FONT_INTER_MEDIUM_32px, - strings.tmp.tmp, - SCREEN_WIDTH - (2 * BORDER_MARGIN), - NB_MAX_LINES_IN_REVIEW, + // limit the value to one page + nbgl_getTextMaxLenInNbLines(BAGL_FONT_INTER_MEDIUM_32px, + strings.tmp.tmp, + SCREEN_WIDTH - (2 * BORDER_MARGIN), + NB_MAX_LINES_IN_REVIEW, #if (API_LEVEL == 0 || API_LEVEL >= 14) - &len, - false); + &len, + false); #else - &len); + &len); #endif - strings.tmp.tmp[len] = '\0'; + strings.tmp.tmp[len] = '\0'; - pair.item = strings.tmp.tmp2; - pair.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = &pair; - content->tagValueList.wrapping = false; - ret = true; - break; + pair.item = strings.tmp.tmp2; + pair.value = strings.tmp.tmp; - case 1: - if (ui_712_next_field() == EIP712_NO_MORE_FIELD) { - ui_712_switch_to_sign(); - } - __attribute__((fallthrough)); - default: - ret = false; - break; - } - return ret; -} + pairsList.nbPairs = 1; + pairsList.pairs = &pair; -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) { - g_position = UI_SIGNING_POSITION_START; - ui_message_start(TEXT_REVIEW_EIP712, - &ui_712_switch_to_message, - &ui_message_712_approved, - &ui_message_712_rejected); + nbgl_useCaseReview(TYPE_MESSAGE, + &pairsList, + &C_Review_64px, + TEXT_REVIEW_EIP712, + NULL, + TEXT_SIGN_EIP712, + reviewChoice); } void ui_712_switch_to_message(void) { g_position = UI_SIGNING_POSITION_REVIEW; - handle_display(display_review_page); + ui_712_start(); } void ui_712_switch_to_sign(void) { g_position = UI_SIGNING_POSITION_SIGN; - handle_display(display_sign_page); + ui_712_start(); } #endif // HAVE_EIP712_FULL_SUPPORT diff --git a/src_nbgl/ui_sign_712_v0.c b/src_nbgl/ui_sign_712_v0.c index 0681009bcd..65a8964d81 100644 --- a/src_nbgl/ui_sign_712_v0.c +++ b/src_nbgl/ui_sign_712_v0.c @@ -6,72 +6,45 @@ #include "ui_signing.h" static nbgl_layoutTagValue_t pairs[2]; - -static void start_review(void); // forward declaration +static nbgl_layoutTagValueList_t pairsList; static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) { snprintf(buffer + offset, buffer_size - offset, "0x%.*H", KECCAK256_HASH_BYTESIZE, hash); return buffer + offset; } -static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - pairs[0].item = "Domain hash"; - pairs[0].value = format_hash(tmpCtx.messageSigningContext712.domainHash, - strings.tmp.tmp, - sizeof(strings.tmp.tmp), - 0); - pairs[1].item = "Message hash"; - pairs[1].value = format_hash(tmpCtx.messageSigningContext712.messageHash, - strings.tmp.tmp, - sizeof(strings.tmp.tmp), - 70); - - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs; - } 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 = TEXT_SIGN_EIP712; - content->infoLongPress.longPressText = SIGN_BUTTON; +static void reviewChoice(bool confirm) { + if (confirm) { + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved); } else { - return false; - } - // valid page so return true - return true; -} - -static void display_review(void) { - uint8_t page; - - switch (g_position) { - case UI_SIGNING_POSITION_REVIEW: - page = 0; - break; - case UI_SIGNING_POSITION_SIGN: - page = 1; - break; - default: - return; // should not happen + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_rejected); } - nbgl_useCaseRegularReview(page, - 2, - REJECT_BUTTON, - NULL, - display_review_page, - ui_message_review_choice); -} - -static void start_review(void) { - g_position = UI_SIGNING_POSITION_REVIEW; - display_review(); } void ui_sign_712_v0(void) { g_position = UI_SIGNING_POSITION_START; - ui_message_start(TEXT_REVIEW_EIP712, - &start_review, - &ui_message_712_approved, - &ui_message_712_rejected); + explicit_bzero(pairs, sizeof(pairs)); + explicit_bzero(&pairsList, sizeof(pairsList)); + + pairs[0].item = "Domain hash"; + pairs[0].value = format_hash(tmpCtx.messageSigningContext712.domainHash, + strings.tmp.tmp, + sizeof(strings.tmp.tmp), + 0); + pairs[1].item = "Message hash"; + pairs[1].value = format_hash(tmpCtx.messageSigningContext712.messageHash, + strings.tmp.tmp, + sizeof(strings.tmp.tmp), + 70); + + pairsList.nbPairs = 2; + pairsList.pairs = pairs; + + nbgl_useCaseReview(TYPE_MESSAGE, + &pairsList, + &C_Review_64px, + TEXT_REVIEW_EIP712, + NULL, + "Sign transaction\nto send BOL", + reviewChoice); } diff --git a/src_nbgl/ui_sign_message.c b/src_nbgl/ui_sign_message.c index 314fce1bf4..6947eca6e5 100644 --- a/src_nbgl/ui_sign_message.c +++ b/src_nbgl/ui_sign_message.c @@ -23,6 +23,7 @@ static e_ui_191_action g_action; static bool skip_message; static nbgl_layoutTagValue_t pair; +static nbgl_layoutTagValueList_t pairsList; static uint32_t eip191MessageIdx = 0; static uint32_t stringsTmpTmpIdx = 0;