diff --git a/src_nbgl/ui_sign_712.c b/src_nbgl/ui_sign_712.c index fa63a34..6ad32d4 100644 --- a/src_nbgl/ui_sign_712.c +++ b/src_nbgl/ui_sign_712.c @@ -7,6 +7,7 @@ #include "nbgl_use_case.h" #include "network.h" #include "ui_message_signing.h" +#include "ui_signing.h" static nbgl_layoutTagValue_t pair; @@ -45,7 +46,8 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { case 1: switch (ui_712_next_field()) { case EIP712_NO_MORE_FIELD: - return display_sign_page(page, content); + ui_712_switch_to_sign(); + ret = true; break; case EIP712_FIELD_INCOMING: case EIP712_FIELD_LATER: @@ -65,19 +67,38 @@ static void handle_display(nbgl_navCallback_t cb) { nbgl_useCaseRegularReview(0, 0, "Reject", NULL, cb, ui_message_review_choice); } +static void resume_review(void) { + switch (g_position) { + case UI_SIGNING_POSITION_START: + ui_712_start(); + break; + case UI_SIGNING_POSITION_REVIEW: + ui_712_switch_to_message(); + break; + case UI_SIGNING_POSITION_SIGN: + ui_712_switch_to_sign(); + break; + default: + return; // should not happen + } +} + void ui_712_start(void) { + g_position = UI_SIGNING_POSITION_START; ui_message_start("Review typed message", - NULL, &ui_712_switch_to_message, + &resume_review, &ui_message_712_approved, &ui_message_712_rejected); } void ui_712_switch_to_message(void) { + g_position = UI_SIGNING_POSITION_REVIEW; handle_display(display_review_page); } void ui_712_switch_to_sign(void) { + g_position = UI_SIGNING_POSITION_SIGN; handle_display(display_sign_page); } diff --git a/src_nbgl/ui_sign_712_v0.c b/src_nbgl/ui_sign_712_v0.c index 7d6eddb..1022c58 100644 --- a/src_nbgl/ui_sign_712_v0.c +++ b/src_nbgl/ui_sign_712_v0.c @@ -4,6 +4,7 @@ #include "network.h" #include "ethUtils.h" #include "ui_message_signing.h" +#include "ui_signing.h" static nbgl_layoutTagValue_t pairs[2]; @@ -32,6 +33,7 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { content->tagValueList.nbMaxLinesForValue = 0; 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 = "Sign typed message"; content->infoLongPress.longPressText = "Hold to sign"; @@ -42,14 +44,45 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { 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_useCaseRegularReview(page, + 2, + "Reject", + NULL, + display_review_page, + ui_message_review_choice); +} + static void start_review(void) { - nbgl_useCaseRegularReview(0, 2, "Reject", NULL, display_review_page, ui_message_review_choice); + g_position = UI_SIGNING_POSITION_REVIEW; + display_review(); +} + +static void resume_review(void) { + if (g_position == UI_SIGNING_POSITION_START) { + ui_sign_712_v0(); + } else { + display_review(); + } } void ui_sign_712_v0(void) { + g_position = UI_SIGNING_POSITION_START; ui_message_start("Sign typed message", - NULL, &start_review, + &resume_review, &ui_message_712_approved, &ui_message_712_rejected); }