Files
app-ethereum/src_nbgl/ui_sign_712.c

85 lines
2.5 KiB
C
Raw Normal View History

#ifdef HAVE_EIP712_FULL_SUPPORT
2023-02-21 11:01:18 +01:00
#include "common_ui.h"
#include "ui_nbgl.h"
#include "ui_logic.h"
#include "common_712.h"
#include "nbgl_use_case.h"
#include "network.h"
2023-06-06 16:58:27 +02:00
#include "ui_message_signing.h"
2023-06-16 11:57:08 +02:00
#include "ui_signing.h"
2023-02-21 11:01:18 +01:00
static nbgl_layoutTagValue_t pair;
2023-02-21 11:01:18 +01:00
static bool display_sign_page(uint8_t page, nbgl_pageContent_t *content) {
2023-02-21 11:01:18 +01:00
(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;
2023-02-21 11:01:18 +01:00
return true;
}
static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
bool ret;
uint16_t len;
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,
2023-12-01 18:43:30 +01:00
#if (API_LEVEL == 0 || API_LEVEL >= 14)
2023-11-21 16:59:31 +01:00
&len,
false);
2023-12-01 16:35:14 +01:00
#else
&len);
#endif
strings.tmp.tmp[len] = '\0';
2023-02-21 11:01:18 +01:00
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;
case 1:
2024-03-18 08:58:05 +01:00
if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
ui_712_switch_to_sign();
}
__attribute__((fallthrough));
default:
ret = false;
break;
2023-02-21 11:01:18 +01:00
}
return ret;
2023-02-21 11:01:18 +01:00
}
static void handle_display(nbgl_navCallback_t cb) {
nbgl_useCaseRegularReview(0, 0, REJECT_BUTTON, NULL, cb, ui_message_review_choice);
2023-02-21 11:01:18 +01:00
}
void ui_712_start(void) {
2023-06-16 11:57:08 +02:00
g_position = UI_SIGNING_POSITION_START;
ui_message_start(TEXT_REVIEW_EIP712,
2023-06-06 16:58:27 +02:00
&ui_712_switch_to_message,
&ui_message_712_approved,
&ui_message_712_rejected);
2023-02-21 11:01:18 +01:00
}
void ui_712_switch_to_message(void) {
2023-06-16 11:57:08 +02:00
g_position = UI_SIGNING_POSITION_REVIEW;
handle_display(display_review_page);
2023-02-21 11:01:18 +01:00
}
void ui_712_switch_to_sign(void) {
2023-06-16 11:57:08 +02:00
g_position = UI_SIGNING_POSITION_SIGN;
handle_display(display_sign_page);
}
#endif // HAVE_EIP712_FULL_SUPPORT