16#include "os_io_seph_ux.h"
19#include "os_helpers.h"
26#define PAGE_NB_ELEMENTS_BITS 3
27#define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
28#define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
30#define PAGE_FLAG_BITS 1
31#define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
32#define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
34#define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
35#define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
36#define SET_PAGE_DATA(pageIdx, pageData) \
37 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
38 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
40#define MAX_PAGE_NB 256
41#define MAX_MODAL_PAGE_NB 32
44#define STARTING_CONTENT localContentsList[0]
45#define FINISHING_CONTENT localContentsList[1]
48#define QRCODE_NB_MAX_LINES 3
50#define QRCODE_REDUCED_ADDR_LEN 128
53#define ADDR_VERIF_NB_PAIRS 3
56#define sharedContext genericContext.sharedCtx
57#define keypadContext sharedContext.keypad
58#define keyboardContext sharedContext.keyboard
59#define reviewWithWarnCtx sharedContext.reviewWithWarning
60#define choiceWithDetailsCtx sharedContext.choiceWithDetails
63#define W3C_DESCRIPTION_MAX_LEN 128
76 ADDRESS_QRCODE_BUTTON_TOKEN,
89 QUIT_TIPBOX_MODAL_TOKEN,
92 DISMISS_WARNING_TOKEN,
93 DISMISS_DETAILS_TOKEN,
95 KEYBOARD_BUTTON_TOKEN,
109typedef struct DetailsContext_s {
112 uint8_t currentPairIdx;
116 const char *nextPageStart;
119typedef struct AddressConfirmationContext_s {
123} AddressConfirmationContext_t;
126typedef struct KeypadContext_s {
129 uint8_t pinMinDigits;
130 uint8_t pinMaxDigits;
138typedef struct KeyboardContext_s {
149typedef struct ReviewWithWarningContext_s {
154 const char *reviewTitle;
155 const char *reviewSubTitle;
156 const char *finishTitle;
161 uint8_t securityReportLevel;
163} ReviewWithWarningContext_t;
165typedef struct ChoiceWithDetailsContext_s {
170} ChoiceWithDetailsContext_t;
174 SHARE_CTX_REVIEW_WITH_WARNING,
175 SHARE_CTX_CHOICE_WITH_DETAILS,
176} SharedContextUsage_t;
183 KeypadContext_t keypad;
186 KeyboardContext_t keyboard;
188 ReviewWithWarningContext_t reviewWithWarning;
189 ChoiceWithDetailsContext_t choiceWithDetails;
191 SharedContextUsage_t usage;
195 USE_CASE_GENERIC = 0,
197} GenericContextType_t;
200 GenericContextType_t type;
201 uint8_t spinnerPosition;
203 int8_t currentContentIdx;
204 uint8_t currentContentElementNb;
205 uint8_t currentElementIdx;
206 bool hasStartingContent;
207 bool hasFinishingContent;
208 const char *detailsItem;
209 const char *detailsvalue;
210 bool detailsWrapping;
211 bool validWarningCtx;
221 SharedContext_t sharedCtx;
232} nbgl_homeAndSettingsContext_t;
237} nbgl_reviewContext_t;
245} nbgl_reviewStreamingContext_t;
248 nbgl_homeAndSettingsContext_t homeAndSettings;
249 nbgl_reviewContext_t review;
250 nbgl_reviewStreamingContext_t reviewStreaming;
251} nbgl_BundleNavContext_t;
257} SecurityReportItem_t;
264static char tmpString[W3C_DESCRIPTION_MAX_LEN];
281static const char *pageTitle;
284#define activeTipBox genericContext.tipBox
288static bool forwardNavOnly;
289static NavType_t navType;
291static DetailsContext_t detailsContext;
294static AddressConfirmationContext_t addressConfirmationContext;
297static GenericContext_t genericContext;
299 localContentsList[3];
300static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
301static uint8_t modalContextPagesInfo[MAX_MODAL_PAGE_NB / PAGES_PER_UINT8];
304static nbgl_BundleNavContext_t bundleNavContext;
307static const uint8_t nbMaxElementsPerContentType[] = {
325 .text =
"Blind signing required",
326 .subText =
"This transaction's details are not fully verifiable. If "
327 "you sign, you could lose all your assets."
331 .text =
"Transaction Check unavailable",
336 .text =
"Risk detected",
337 .subText =
"This transaction was scanned as risky by Web3 Checks."
341 .text =
"Critical threat",
342 .subText =
"This transaction was scanned as malicious by Web3 Checks."
346 .text =
"No threat detected",
347 .subText =
"Transaction Check didn't find any threat, but always "
348 "review transaction details carefully."
358static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
364static void displayReviewPage(uint8_t page,
bool forceFullRefresh);
365static void displayDetailsPage(uint8_t page,
bool forceFullRefresh);
366static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh);
367static void displayFullValuePage(
const char *backText,
368 const char *aliasText,
370static void displayInfosListModal(
const char *modalTitle,
374static void displaySettingsPage(uint8_t page,
bool forceFullRefresh);
375static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh);
376static void pageCallback(
int token, uint8_t index);
378static void displayAddressQRCode(
void);
380static void modalLayoutTouchCallback(
int token, uint8_t index);
381static void displaySkipWarning(
void);
383static void bundleNavStartHome(
void);
384static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
385static void bundleNavStartSettings(
void);
387static void bundleNavReviewStreamingChoice(
bool confirm);
389static void displaySecurityReport(uint32_t set);
391static void displayInitialWarning(
void);
395 const char *reviewTitle,
396 const char *reviewSubTitle,
397 const char *finishTitle,
401 bool playNotifSound);
404 const char *reviewTitle,
405 const char *reviewSubTitle,
407 bool playNotifSound);
408static void useCaseHomeExt(
const char *appName,
415static void displayDetails(
const char *tag,
const char *value,
bool wrapping);
417static void reset_callbacks_and_context(
void)
424 onContentAction = NULL;
426 memset(&genericContext, 0,
sizeof(genericContext));
430static void genericContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements,
bool flag)
432 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements) + SET_PAGE_FLAG(flag);
434 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
435 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
436 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
437 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
441static void genericContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements,
bool *flag)
443 uint8_t pageData = genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
444 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
445 if (nbElements != NULL) {
446 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
449 *flag = GET_PAGE_FLAG(pageData);
454static void modalContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements)
456 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements);
458 modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
459 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
460 modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
461 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
465static void modalContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements)
467 uint8_t pageData = modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
468 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
469 if (nbElements != NULL) {
470 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
477 switch (content->
type) {
501 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
518static void prepareNavInfo(
bool isReview, uint8_t nbPages,
const char *rejectText)
520 memset(&navInfo, 0,
sizeof(navInfo));
523 navInfo.
tuneId = TUNE_TAP_CASUAL;
527 if (isReview ==
false) {
536 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false : true;
543 const char *reviewTitle,
544 const char *reviewSubTitle)
546 contentCenter->
icon = icon;
547 contentCenter->
title = reviewTitle;
549 contentCenter->
subText =
"Swipe to review";
552 contentCenter->
padding =
false;
558 if (finishTitle != NULL) {
563 return "Sign transaction";
565 return "Sign message";
567 return "Sign operation";
574 const char *finishTitle)
576 infoLongPress->
text = getFinishTitle(operationType, finishTitle);
577 infoLongPress->
icon = icon;
585 const char *finishTitle)
587 infoButton->
text = getFinishTitle(operationType, finishTitle);
588 infoButton->
icon = icon;
608static void pageModalCallback(
int token, uint8_t index)
612 if (token == INFOS_TIP_BOX_TOKEN) {
614 displayFullValuePage(activeTipBox.infos.infoTypes[index],
615 activeTipBox.infos.infoContents[index],
616 &activeTipBox.infos.infoExtensions[index]);
619 else if (token == INFO_ALIAS_TOKEN) {
621 displayFullValuePage(genericContext.currentInfos->infoTypes[index],
622 genericContext.currentInfos->infoContents[index],
623 &genericContext.currentInfos->infoExtensions[index]);
627 modalPageContext = NULL;
628 if (token == NAV_TOKEN) {
629 if (index == EXIT_PAGE) {
635 displayDetailsPage(index,
false);
638 if (token == MODAL_NAV_TOKEN) {
639 if (index == EXIT_PAGE) {
645 displayTagValueListModalPage(index,
false);
648 else if (token == QUIT_TOKEN) {
653 else if (token == QUIT_TIPBOX_MODAL_TOKEN) {
655 if (reviewWithWarnCtx.securityReportLevel == 2) {
656 reviewWithWarnCtx.securityReportLevel = 1;
657 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
665 else if (token == SKIP_TOKEN) {
676 else if (token == CHOICE_TOKEN) {
678 if (onModalConfirm != NULL) {
680 onModalConfirm = NULL;
692static void pageCallback(
int token, uint8_t index)
695 if (token == QUIT_TOKEN) {
696 if (onQuit != NULL) {
700 else if (token == CONTINUE_TOKEN) {
701 if (onContinue != NULL) {
705 else if (token == CHOICE_TOKEN) {
706 if (onChoice != NULL) {
707 onChoice((index == 0) ?
true : false);
710 else if (token == ACTION_BUTTON_TOKEN) {
711 if ((index == 0) && (onAction != NULL)) {
714 else if ((index == 1) && (onQuit != NULL)) {
719 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
720 displayAddressQRCode();
723 else if (token == CONFIRM_TOKEN) {
724 if (onChoice != NULL) {
728 else if (token == REJECT_TOKEN) {
729 if (onChoice != NULL) {
733 else if (token == DETAILS_BUTTON_TOKEN) {
734 displayDetails(genericContext.detailsItem,
735 genericContext.detailsvalue,
736 genericContext.detailsWrapping);
738 else if (token == NAV_TOKEN) {
739 if (index == EXIT_PAGE) {
740 if (onQuit != NULL) {
745 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
746 displayGenericContextPage(index,
false);
748 else if (navType == REVIEW_NAV) {
749 displayReviewPage(index,
false);
752 displaySettingsPage(index,
false);
756 else if (token == NEXT_TOKEN) {
758 displayReviewPage(navInfo.
activePage + 1,
false);
761 displayGenericContextPage(navInfo.
activePage + 1,
false);
764 else if (token == BACK_TOKEN) {
766 displayReviewPage(navInfo.
activePage - 1,
true);
769 displayGenericContextPage(navInfo.
activePage - 1,
false);
772 else if (token == SKIP_TOKEN) {
774 displaySkipWarning();
776 else if (token == VALUE_ALIAS_TOKEN) {
779 if (genericContext.currentPairs != NULL) {
780 pair = &genericContext.currentPairs[genericContext.currentElementIdx + index];
783 pair = genericContext.currentCallback(genericContext.currentElementIdx + index);
787 else if (token == BLIND_WARNING_TOKEN) {
788 reviewWithWarnCtx.isIntro =
false;
789 reviewWithWarnCtx.warning = NULL;
792 else if (token == WARNING_BUTTON_TOKEN) {
794 reviewWithWarnCtx.securityReportLevel = 1;
796 if (reviewWithWarnCtx.warning->predefinedSet) {
797 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
801 if (reviewWithWarnCtx.isIntro) {
802 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->introDetails);
805 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->reviewDetails);
809 else if (token == TIP_BOX_TOKEN) {
811 if (genericContext.validWarningCtx && (reviewWithWarnCtx.warning->predefinedSet != 0)) {
812 reviewWithWarnCtx.securityReportLevel = 1;
813 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
816 displayInfosListModal(activeTipBox.modalTitle, &activeTipBox.infos,
false);
820 if (onContentAction != NULL) {
821 onContentAction(token, index, navInfo.
activePage);
823 if (onControls != NULL) {
824 onControls(token, index);
830static void tickerCallback(
void)
833 if (onQuit != NULL) {
839static void displaySettingsPage(uint8_t page,
bool forceFullRefresh)
843 if ((onNav == NULL) || (onNav(page, &content) ==
false)) {
848 content.
title = pageTitle;
851 content.
tuneId = TUNE_TAP_CASUAL;
856 if (forceFullRefresh) {
865static void displayReviewPage(uint8_t page,
bool forceFullRefresh)
874 if ((onNav == NULL) || (onNav(navInfo.
activePage, &content) ==
false)) {
879 content.
title = NULL;
881 content.
tuneId = TUNE_TAP_CASUAL;
888 if (forwardNavOnly) {
913 if (forceFullRefresh) {
923static const nbgl_content_t *genericContextComputeNextPageParams(uint8_t pageIdx,
925 uint8_t *p_nbElementsInNextPage,
928 int8_t nextContentIdx = genericContext.currentContentIdx;
929 int16_t nextElementIdx = genericContext.currentElementIdx;
930 uint8_t nbElementsInNextPage;
933 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
934 *p_nbElementsInNextPage = nbElementsInNextPage;
939 uint8_t nbElementsInCurrentPage;
941 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
942 nextElementIdx += nbElementsInCurrentPage;
947 if ((nextElementIdx >= genericContext.currentContentElementNb)
948 && (genericContext.currentContentElementNb > 0)) {
958 nextElementIdx -= nbElementsInNextPage;
964 if (nextElementIdx < 0) {
966 nextElementIdx = -nbElementsInNextPage;
972 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
973 p_content = &STARTING_CONTENT;
975 else if ((nextContentIdx == genericContext.genericContents.nbContents)
976 && (genericContext.hasFinishingContent)) {
977 p_content = &FINISHING_CONTENT;
980 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
982 if (p_content == NULL) {
997 if ((nextContentIdx != genericContext.currentContentIdx)
998 || (genericContext.currentContentElementNb == 0)) {
999 genericContext.currentContentIdx = nextContentIdx;
1000 genericContext.currentContentElementNb = getContentNbElement(p_content);
1002 if (nextElementIdx < 0) {
1003 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
1008 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
1010 "Invalid element index %d / %d\n",
1012 genericContext.currentContentElementNb);
1017 genericContext.currentElementIdx = nextElementIdx;
1025static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
1026 uint8_t nbElementsInPage,
1030 uint8_t nextElementIdx = genericContext.currentElementIdx;
1032 pageContent->
title = pageTitle;
1035 pageContent->
tuneId = TUNE_TAP_CASUAL;
1037 pageContent->
type = p_content->
type;
1038 switch (pageContent->
type) {
1090 p_tagValueList = NULL;
1102 genericContext.detailsItem = pair->
item;
1103 genericContext.detailsvalue = pair->
value;
1108 if (p_tagValueList != NULL) {
1109 p_tagValueList->
nbPairs = nbElementsInPage;
1112 p_tagValueList->
pairs
1115 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1117 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1123 p_tagValueList->
pairs = NULL;
1127 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1131 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1147 if ((nextElementIdx + nbElementsInPage)
1163 p_tagValueList->
nbPairs = nbElementsInPage;
1164 p_tagValueList->
pairs
1167 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1169 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1174 genericContext.currentPairs = p_tagValueList->
pairs;
1175 genericContext.currentCallback = p_tagValueList->
callback;
1199 < nextElementIdx + nbElementsInPage)) {
1219 bool isFirstOrLastPage
1223 = (navType == STREAMING_NAV)
1224 ? bundleNavContext.reviewStreaming.operationType
1225 : ((navType == GENERIC_NAV) ? bundleNavContext.review.operationType : 0);
1228 if (isFirstOrLastPage
1240 = (operationType &
BLIND_OPERATION) ? BLIND_WARNING_TOKEN : WARNING_BUTTON_TOKEN;
1247static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh)
1251 uint8_t nbElementsInPage;
1255 if (navType == STREAMING_NAV) {
1257 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1258 bundleNavContext.reviewStreaming.skipCallback();
1262 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1263 bundleNavReviewStreamingChoice(
true);
1270 pageIdx = navInfo.
nbPages - 1;
1276 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1281 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1282 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1292 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1295 if (p_content == NULL) {
1299 if ((navType != STREAMING_NAV)
1302 if ((pageIdx > 0) && (pageIdx < (navInfo.
nbPages - 1))) {
1314 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1320 if (forceFullRefresh) {
1329static const char *getDetailsPageAt(uint8_t detailsPage)
1332 const char *currentChar = detailsContext.value;
1333 while (page < detailsPage) {
1343 detailsContext.wrapping);
1345 if (currentChar[len] ==
'\n') {
1348 else if (detailsContext.wrapping ==
false) {
1351 currentChar = currentChar + len;
1359static void displayDetailsPage(uint8_t detailsPage,
bool forceFullRefresh)
1363 .nbPages = detailsContext.nbPages,
1365 .quitToken = QUIT_TOKEN,
1366 .navWithButtons.navToken = NAV_TOKEN,
1367 .navWithButtons.quitButton =
true,
1368 .navWithButtons.backButton =
true,
1369 .navWithButtons.quitText = NULL,
1370 .progressIndicator =
false,
1371 .tuneId = TUNE_TAP_CASUAL};
1373 .topRightIcon = NULL,
1374 .tagValueList.nbPairs = 1,
1375 .tagValueList.pairs = ¤tPair,
1376 .tagValueList.smallCaseForValue =
true,
1377 .tagValueList.wrapping = detailsContext.wrapping};
1379 if (modalPageContext != NULL) {
1382 currentPair.
item = detailsContext.tag;
1384 if (detailsPage <= detailsContext.currentPage) {
1386 currentPair.
value = getDetailsPageAt(detailsPage);
1387 forceFullRefresh =
true;
1391 currentPair.
value = detailsContext.nextPageStart;
1393 detailsContext.currentPage = detailsPage;
1404 detailsContext.wrapping);
1407 if (currentPair.
value[len] ==
'\n') {
1410 else if (!detailsContext.wrapping) {
1415 detailsContext.nextPageStart = currentPair.
value + len;
1421 detailsContext.nextPageStart = NULL;
1430 if (forceFullRefresh) {
1439static void displayFullValuePage(
const char *backText,
1440 const char *aliasText,
1443 const char *modalTitle
1444 = (extension->
backText != NULL) ? PIC(extension->
backText) : PIC(backText);
1446 genericContext.currentInfos = extension->
infolist;
1447 displayInfosListModal(modalTitle, extension->
infolist,
true);
1450 genericContext.currentTagValues = extension->
tagValuelist;
1455 .withLeftBorder =
true,
1456 .onActionCallback = &modalLayoutTouchCallback,
1457 .tapActionText = NULL};
1458 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
1459 .separationLine =
false,
1460 .backAndText.token = 0,
1461 .backAndText.tuneId = TUNE_TAP_CASUAL,
1462 .backAndText.text = modalTitle};
1465 nbgl_layoutAddHeader(genericContext.modalLayout, &headerDesc);
1469 nbgl_layoutQRCode_t qrCode
1471 .text1 = (extension->
title != NULL) ? extension->
title : extension->fullValue,
1472 .text2 = extension->explanation,
1476 nbgl_layoutAddQRCode(genericContext.modalLayout, &qrCode);
1481 content.
title = aliasText;
1483 content.
info =
"ENS names are resolved by Ledger backend.";
1502 nbgl_layoutAddTextContent(genericContext.modalLayout, &content);
1511static void displayInfosListModal(
const char *modalTitle,
1518 .quitToken = QUIT_TIPBOX_MODAL_TOKEN,
1519 .navWithButtons.navToken = NAV_TOKEN,
1520 .navWithButtons.quitButton =
false,
1521 .navWithButtons.backButton =
true,
1522 .navWithButtons.quitText = NULL,
1523 .progressIndicator =
false,
1524 .tuneId = TUNE_TAP_CASUAL};
1527 .topRightIcon = NULL,
1528 .infosList.nbInfos = infos->
nbInfos,
1530 .infosList.infoTypes = infos->
infoTypes,
1533 .infosList.token = fromReview ? INFO_ALIAS_TOKEN : INFOS_TIP_BOX_TOKEN,
1534 .
title = modalTitle,
1535 .titleToken = QUIT_TIPBOX_MODAL_TOKEN,
1536 .tuneId = TUNE_TAP_CASUAL};
1538 if (modalPageContext != NULL) {
1547static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh)
1550 .nbPages = detailsContext.nbPages,
1552 .quitToken = QUIT_TOKEN,
1553 .navWithButtons.navToken = MODAL_NAV_TOKEN,
1554 .navWithButtons.quitButton =
true,
1555 .navWithButtons.backButton =
true,
1556 .navWithButtons.quitText = NULL,
1557 .progressIndicator =
false,
1558 .tuneId = TUNE_TAP_CASUAL};
1560 .topRightIcon = NULL,
1561 .tagValueList.smallCaseForValue =
true,
1562 .tagValueList.wrapping = detailsContext.wrapping};
1563 uint8_t nbElementsInPage;
1566 if (detailsContext.currentPage <= pageIdx) {
1567 modalContextGetPageInfo(pageIdx, &nbElementsInPage);
1571 modalContextGetPageInfo(pageIdx + 1, &nbElementsInPage);
1572 detailsContext.currentPairIdx -= nbElementsInPage;
1573 modalContextGetPageInfo(pageIdx, &nbElementsInPage);
1574 detailsContext.currentPairIdx -= nbElementsInPage;
1576 detailsContext.currentPage = pageIdx;
1579 = &genericContext.currentTagValues->pairs[detailsContext.currentPairIdx];
1581 detailsContext.currentPairIdx += nbElementsInPage;
1587 if (modalPageContext != NULL) {
1592 if (forceFullRefresh) {
1601static void displayAddressQRCode(
void)
1605 .withLeftBorder =
true,
1606 .onActionCallback = &modalLayoutTouchCallback,
1607 .tapActionText = NULL};
1608 nbgl_layoutHeader_t headerDesc = {
1609 .type = HEADER_EMPTY, .separationLine =
false, .emptySpace.height = SMALL_CENTERING_HEADER};
1610 nbgl_layoutQRCode_t qrCode = {.url = addressConfirmationContext.tagValuePairs[0].value,
1615 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1617 nbgl_layoutAddHeader(addressConfirmationContext.modalLayout, &headerDesc);
1620 addressConfirmationContext.tagValuePairs[0].value,
1624 if (nbLines <= QRCODE_NB_MAX_LINES) {
1625 qrCode.text2 = addressConfirmationContext.tagValuePairs[0].value;
1630 addressConfirmationContext.tagValuePairs[0].value,
1632 QRCODE_NB_MAX_LINES,
1634 QRCODE_REDUCED_ADDR_LEN);
1635 qrCode.text2 = reducedAddress;
1638 nbgl_layoutAddQRCode(addressConfirmationContext.modalLayout, &qrCode);
1640 nbgl_layoutAddFooter(
1641 addressConfirmationContext.modalLayout,
"Close", DISMISS_QR_TOKEN, TUNE_TAP_CASUAL);
1649static void modalLayoutTouchCallback(
int token, uint8_t index)
1652 if (token == DISMISS_QR_TOKEN) {
1655 addressConfirmationContext.modalLayout = NULL;
1658 else if (token == DISMISS_WARNING_TOKEN) {
1662 if (reviewWithWarnCtx.securityReportLevel <= 1) {
1663 reviewWithWarnCtx.modalLayout = NULL;
1668 reviewWithWarnCtx.securityReportLevel = 1;
1670 if (reviewWithWarnCtx.warning->predefinedSet) {
1671 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1676 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1677 : reviewWithWarnCtx.warning->reviewDetails;
1678 displayCustomizedSecurityReport(details);
1683 else if (token == DISMISS_DETAILS_TOKEN) {
1687 if (choiceWithDetailsCtx.level <= 1) {
1688 choiceWithDetailsCtx.modalLayout = NULL;
1693 choiceWithDetailsCtx.level = 1;
1694 choiceWithDetailsCtx.modalLayout
1695 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
1698 else if ((token >= FIRST_WARN_BAR_TOKEN) && (token <= LAST_WARN_BAR_TOKEN)) {
1699 if (sharedContext.usage == SHARE_CTX_REVIEW_WITH_WARNING) {
1702 reviewWithWarnCtx.securityReportLevel = 2;
1704 if (reviewWithWarnCtx.warning->predefinedSet) {
1705 displaySecurityReport(1 << (token - FIRST_WARN_BAR_TOKEN));
1710 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1711 : reviewWithWarnCtx.warning->reviewDetails;
1713 displayCustomizedSecurityReport(
1718 else if (sharedContext.usage == SHARE_CTX_CHOICE_WITH_DETAILS) {
1720 = &choiceWithDetailsCtx.details->
barList.
details[token - FIRST_WARN_BAR_TOKEN];
1724 choiceWithDetailsCtx.level = 2;
1725 choiceWithDetailsCtx.modalLayout
1726 = displayModalDetails(details, DISMISS_DETAILS_TOKEN);
1734 genericContext.modalLayout = NULL;
1741static void layoutTouchCallback(
int token, uint8_t index)
1744 if (token == WARNING_CHOICE_TOKEN) {
1746 reviewWithWarnCtx.choiceCallback(
false);
1749 reviewWithWarnCtx.isIntro =
false;
1750 if (reviewWithWarnCtx.isStreaming) {
1751 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1752 reviewWithWarnCtx.icon,
1753 reviewWithWarnCtx.reviewTitle,
1754 reviewWithWarnCtx.reviewSubTitle,
1755 reviewWithWarnCtx.choiceCallback,
1759 useCaseReview(reviewWithWarnCtx.operationType,
1760 reviewWithWarnCtx.tagValueList,
1761 reviewWithWarnCtx.icon,
1762 reviewWithWarnCtx.reviewTitle,
1763 reviewWithWarnCtx.reviewSubTitle,
1764 reviewWithWarnCtx.finishTitle,
1766 reviewWithWarnCtx.choiceCallback,
1773 else if (token == WARNING_BUTTON_TOKEN) {
1775 reviewWithWarnCtx.securityReportLevel = 1;
1777 if (reviewWithWarnCtx.warning->predefinedSet) {
1778 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1783 ? reviewWithWarnCtx.warning->introDetails
1784 : reviewWithWarnCtx.warning->reviewDetails;
1785 displayCustomizedSecurityReport(details);
1789 else if (token == CHOICE_DETAILS_TOKEN) {
1790 choiceWithDetailsCtx.level = 1;
1791 choiceWithDetailsCtx.modalLayout
1792 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
1795 else if (token == PRELUDE_CHOICE_TOKEN) {
1797 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->prelude->details);
1801 displayInitialWarning();
1804 reviewWithWarnCtx.isIntro =
false;
1805 if (reviewWithWarnCtx.isStreaming) {
1806 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1807 reviewWithWarnCtx.icon,
1808 reviewWithWarnCtx.reviewTitle,
1809 reviewWithWarnCtx.reviewSubTitle,
1810 reviewWithWarnCtx.choiceCallback,
1814 useCaseReview(reviewWithWarnCtx.operationType,
1815 reviewWithWarnCtx.tagValueList,
1816 reviewWithWarnCtx.icon,
1817 reviewWithWarnCtx.reviewTitle,
1818 reviewWithWarnCtx.reviewSubTitle,
1819 reviewWithWarnCtx.finishTitle,
1821 reviewWithWarnCtx.choiceCallback,
1829 else if (token == CHOICE_TOKEN) {
1830 if (onChoice != NULL) {
1831 onChoice((index == 0) ?
true : false);
1837static void displaySkipWarning(
void)
1840 .cancelText =
"Go back to review",
1841 .centeredInfo.text1 =
"Skip review?",
1843 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
1844 .centeredInfo.text3 = NULL,
1845 .centeredInfo.style = LARGE_CASE_INFO,
1846 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
1847 .centeredInfo.offsetY = 0,
1848 .confirmationText =
"Yes, skip",
1849 .confirmationToken = SKIP_TOKEN,
1850 .
tuneId = TUNE_TAP_CASUAL,
1852 if (modalPageContext != NULL) {
1864static void updateKeyPad(
bool add)
1866 bool enableValidate, enableBackspace, enableDigits;
1867 bool redrawKeypad =
false;
1870 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
1871 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
1872 enableBackspace = (keypadContext.pinLen > 0);
1874 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
1876 (keypadContext.pinLen == keypadContext.pinMaxDigits)
1878 (keypadContext.pinLen == 1)) {
1879 redrawKeypad =
true;
1883 if ((keypadContext.pinLen == 0) ||
1884 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
1886 (keypadContext.pinLen
1887 == (keypadContext.pinMaxDigits - 1))) {
1888 redrawKeypad =
true;
1891 if (keypadContext.hidden ==
true) {
1896 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
1900 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
1903 if ((!add) && (keypadContext.pinLen == 0)) {
1911static void keypadCallback(
char touchedKey)
1913 switch (touchedKey) {
1915 if (keypadContext.pinLen > 0) {
1916 keypadContext.pinLen--;
1917 keypadContext.pinEntry[keypadContext.pinLen] = 0;
1919 updateKeyPad(
false);
1928 keypadContext.onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
1932 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1933 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
1934 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
1935 keypadContext.pinLen++;
1943static void keypadGeneric_cb(
int token, uint8_t index)
1946 if (token != BACK_TOKEN) {
1955static void keyboardCallback(
char touchedKey)
1958 size_t textLen = strlen(keyboardContext.entryBuffer);
1964 keyboardContext.entryBuffer[--textLen] =
'\0';
1967 keyboardContext.entryBuffer[textLen] = touchedKey;
1968 keyboardContext.entryBuffer[++textLen] =
'\0';
1972 keyboardContext.getSuggestionButtons(&keyboardContext.keyboardContent, &mask);
1974 else if (textLen >= keyboardContext.entryMaxLen) {
1978 nbgl_layoutUpdateKeyboardContent(keyboardContext.layoutCtx, &keyboardContext.keyboardContent);
1980 keyboardContext.keyboardIndex,
1983 keyboardContext.casing);
1987static void keyboardGeneric_cb(
int token, uint8_t index)
1994 case KEYBOARD_CROSS_TOKEN:
1996 keyboardContext.entryBuffer[0] =
'a';
1997 keyboardContext.entryBuffer[1] =
'\0';
2000 case KEYBOARD_BUTTON_TOKEN:
2007 && (token >= keyboardContext.keyboardContent.suggestionButtons.firstButtonToken)) {
2008 onControls(token, index);
2029static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
2033 bool hasConfirmationButton,
2034 bool hasDetailsButton,
2035 bool *requireSpecificDisplay)
2037 uint8_t nbPairsInPage = 0;
2038 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2044 maxUsableHeight -= TOUCHABLE_HEADER_BAR_HEIGHT - SMALL_CENTERING_HEADER;
2047 *requireSpecificDisplay =
false;
2048 while (nbPairsInPage < nbPairs) {
2055 if (nbPairsInPage > 0) {
2056 currentHeight += INTER_TAG_VALUE_MARGIN;
2059 if (tagValueList->
pairs != NULL) {
2060 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2063 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2072 if (nbPairsInPage > 0) {
2079 *requireSpecificDisplay =
true;
2088 currentHeight += TAG_VALUE_INTERVALE;
2091 value_font = SMALL_REGULAR_FONT;
2094 value_font = LARGE_MEDIUM_FONT;
2117 if (nbPairsInPage == 0) {
2121 *requireSpecificDisplay =
true;
2132 if (hasConfirmationButton && (nbPairsInPage == nbPairs)) {
2133 maxUsableHeight -= UP_FOOTER_BUTTON_HEIGHT;
2134 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2139 else if (hasDetailsButton) {
2140 maxUsableHeight -= (SMALL_BUTTON_RADIUS * 2);
2141 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2145 return nbPairsInPage;
2157static uint8_t getNbTagValuesInDetailsPage(uint8_t nbPairs,
2161 uint8_t nbPairsInPage = 0;
2162 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2165 while (nbPairsInPage < nbPairs) {
2170 if (nbPairsInPage > 0) {
2171 currentHeight += INTER_TAG_VALUE_MARGIN;
2174 if (tagValueList->
pairs != NULL) {
2175 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2178 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2192 if (currentHeight >= maxUsableHeight) {
2197 return nbPairsInPage;
2200static uint8_t getNbPagesForContent(
const nbgl_content_t *content,
2201 uint8_t pageIdxStart,
2205 uint8_t nbElements = 0;
2206 uint8_t nbPages = 0;
2207 uint8_t nbElementsInPage;
2208 uint8_t elemIdx = 0;
2211 nbElements = getContentNbElement(content);
2213 while (nbElements > 0) {
2216 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
2218 nbElementsInPage = getNbTagValuesInPage(nbElements,
2227 nbElementsInPage = getNbTagValuesInPage(nbElements,
2252 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
2255 elemIdx += nbElementsInPage;
2256 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
2257 nbElements -= nbElementsInPage;
2265 uint8_t pageIdxStart,
2268 uint8_t nbPages = 0;
2272 for (
int i = 0; i < genericContents->
nbContents; i++) {
2273 p_content = getContentAtIdx(genericContents, i, &content);
2274 if (p_content == NULL) {
2277 nbPages += getNbPagesForContent(p_content,
2278 pageIdxStart + nbPages,
2286static void prepareAddressConfirmationPages(
const char *address,
2292 uint8_t nbAddressChunks;
2302 if (nbAddressChunks > ADDR_VERIF_NB_PAIRS) {
2303 nbAddressChunks = ADDR_VERIF_NB_PAIRS;
2306 const char *chunkStart = address;
2307 for (uint8_t i = 0; i < nbAddressChunks; i++) {
2308 addressConfirmationContext.tagValuePairs[i].item =
"Address";
2309 addressConfirmationContext.tagValuePairs[i].value = chunkStart;
2310 addressConfirmationContext.tagValuePairs[i].forcePageStart = (i > 0);
2311 if (i + 1 < nbAddressChunks) {
2323 addressConfirmationContext.nbPairs = nbAddressChunks;
2333 if ((tagValueList != NULL) && (nbAddressChunks == 1)
2334 && (tagValueList->
nbPairs < ADDR_VERIF_NB_PAIRS)) {
2338 for (uint8_t i = 0; i < tagValueList->
nbPairs; i++) {
2339 memcpy(&addressConfirmationContext.tagValuePairs[1 + i],
2340 &tagValueList->
pairs[i],
2342 addressConfirmationContext.nbPairs++;
2346 tmpList.
nbPairs = addressConfirmationContext.nbPairs;
2347 tmpList.
pairs = addressConfirmationContext.tagValuePairs;
2348 addressConfirmationContext.nbPairs = getNbTagValuesInPage(
2349 addressConfirmationContext.nbPairs, &tmpList, 0,
false,
true,
true, &flag);
2351 if (tmpList.
nbPairs > addressConfirmationContext.nbPairs) {
2352 addressConfirmationContext.nbPairs = 1;
2363 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2375 uint8_t extrasPlaced
2376 = (tagValueList != NULL) ? (addressConfirmationContext.nbPairs - nbAddressChunks) : 0;
2377 bool extrasNeedSecondPage = (tagValueList != NULL) && (tagValueList->
nbPairs > extrasPlaced);
2379 if (extrasNeedSecondPage) {
2389 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2401static void bundleNavStartHome(
void)
2403 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2405 useCaseHomeExt(context->appName,
2408 context->settingContents != NULL ?
true : false,
2409 &context->homeAction,
2410 bundleNavStartSettings,
2411 context->quitCallback);
2414static void bundleNavStartSettingsAtPage(uint8_t initSettingPage)
2416 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2420 context->settingContents,
2422 bundleNavStartHome);
2425static void bundleNavStartSettings(
void)
2427 bundleNavStartSettingsAtPage(0);
2430static void bundleNavReviewConfirmRejection(
void)
2432 bundleNavContext.review.choiceCallback(
false);
2439 const char *confirmText;
2444 title =
"Reject transaction?";
2445 confirmText =
"Go back to transaction";
2448 title =
"Reject message?";
2449 confirmText =
"Go back to message";
2452 title =
"Reject operation?";
2453 confirmText =
"Go back to operation";
2460static void bundleNavReviewChoice(
bool confirm)
2463 bundleNavContext.review.choiceCallback(
true);
2466 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
2467 bundleNavReviewConfirmRejection);
2471static void bundleNavReviewStreamingConfirmRejection(
void)
2473 bundleNavContext.reviewStreaming.choiceCallback(
false);
2476static void bundleNavReviewStreamingChoice(
bool confirm)
2479 bundleNavContext.reviewStreaming.choiceCallback(
true);
2482 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
2483 bundleNavReviewStreamingConfirmRejection);
2493 .withLeftBorder =
true,
2494 .onActionCallback = modalLayoutTouchCallback,
2495 .tapActionText = NULL};
2496 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
2497 .separationLine =
true,
2498 .backAndText.icon = NULL,
2499 .backAndText.tuneId = TUNE_TAP_CASUAL,
2500 .backAndText.token = token};
2505 headerDesc.backAndText.text = details->
title;
2506 nbgl_layoutAddHeader(layout, &headerDesc);
2528 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2529 bar.
tuneId = TUNE_TAP_CASUAL;
2532 nbgl_layoutAddTouchableBar(layout, &bar);
2533 nbgl_layoutAddSeparationLine(layout);
2539 nbgl_layoutAddQRCode(layout, &details->qrCode);
2541 headerDesc.backAndText.text = details->
title;
2546 headerDesc.separationLine =
false;
2556static void displaySecurityReport(uint32_t set)
2559 .withLeftBorder =
true,
2560 .onActionCallback = modalLayoutTouchCallback,
2561 .tapActionText = NULL};
2562 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
2563 .separationLine =
true,
2564 .backAndText.icon = NULL,
2565 .backAndText.tuneId = TUNE_TAP_CASUAL,
2566 .backAndText.token = DISMISS_WARNING_TOKEN};
2567 nbgl_layoutFooter_t footerDesc
2568 = {.type = FOOTER_EMPTY, .separationLine =
false, .emptySpace.height = 0};
2570 const char *provider;
2572 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2578 if ((reviewWithWarnCtx.securityReportLevel == 1) && (!reviewWithWarnCtx.isIntro)) {
2582 && (reviewWithWarnCtx.warning->predefinedSet & (1 << i))) {
2585 || (reviewWithWarnCtx.warning->providerMessage == NULL)) {
2586 bar.
subText = securityReportItems[i].subText;
2589 bar.
subText = reviewWithWarnCtx.warning->providerMessage;
2591 bar.
text = securityReportItems[i].text;
2594 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2595 bar.
tuneId = TUNE_TAP_CASUAL;
2600 bar.
iconLeft = securityReportItems[i].icon;
2601 nbgl_layoutAddTouchableBar(reviewWithWarnCtx.modalLayout, &bar);
2602 nbgl_layoutAddSeparationLine(reviewWithWarnCtx.modalLayout);
2605 headerDesc.backAndText.text =
"Security report";
2606 nbgl_layoutAddHeader(reviewWithWarnCtx.modalLayout, &headerDesc);
2611 if (reviewWithWarnCtx.warning && reviewWithWarnCtx.warning->reportProvider) {
2612 provider = reviewWithWarnCtx.warning->reportProvider;
2615 provider =
"[unknown]";
2621 + W3C_DESCRIPTION_MAX_LEN / 2;
2624 nbgl_layoutQRCode_t qrCode = {.url = destStr,
2625 .text1 = reviewWithWarnCtx.warning->reportUrl,
2626 .text2 =
"Scan to view full report",
2631 W3C_DESCRIPTION_MAX_LEN / 2,
2633 reviewWithWarnCtx.warning->reportUrl);
2634 urlLen = strlen(destStr) + 1;
2635 nbgl_layoutAddQRCode(reviewWithWarnCtx.modalLayout, &qrCode);
2636 footerDesc.emptySpace.height = 24;
2639 snprintf(destStr + urlLen, W3C_DESCRIPTION_MAX_LEN / 2 - urlLen,
"%s report", provider);
2640 headerDesc.backAndText.text = destStr + urlLen;
2645 info.
icon = &LARGE_WARNING_ICON;
2646 info.
title =
"This transaction cannot be Clear Signed";
2648 =
"This transaction or message cannot be decoded fully. If you choose to sign, you "
2649 "could be authorizing malicious actions that can drain your wallet.\n\nLearn more: "
2652 footerDesc.emptySpace.height = SMALL_CENTERING_HEADER;
2653 headerDesc.separationLine =
false;
2658 info.
icon = &LARGE_WARNING_ICON;
2659 info.
title =
"Transaction Check unavailable";
2661 =
"If you're not using the Ledger Wallet app, Transaction Check might not work. If "
2663 "are using Ledger Wallet, reject the transaction and try again.\n\nGet help at "
2666 footerDesc.emptySpace.height = SMALL_CENTERING_HEADER;
2667 headerDesc.separationLine =
false;
2669 nbgl_layoutAddHeader(reviewWithWarnCtx.modalLayout, &headerDesc);
2670 if (footerDesc.emptySpace.height > 0) {
2671 nbgl_layoutAddExtendedFooter(reviewWithWarnCtx.modalLayout, &footerDesc);
2682 reviewWithWarnCtx.modalLayout = displayModalDetails(details, DISMISS_WARNING_TOKEN);
2686static void displayInitialWarning(
void)
2689#ifdef HAVE_PIEZO_SOUND
2690 tune_index_e tune = TUNE_RESERVED;
2693 nbgl_layoutChoiceButtons_t buttonsInfo = {.bottomText =
"Continue anyway",
2694 .token = WARNING_CHOICE_TOKEN,
2695 .topText =
"Back to safety",
2696 .style = ROUNDED_AND_FOOTER_STYLE,
2697 .tuneId = TUNE_TAP_CASUAL};
2698 nbgl_layoutHeader_t headerDesc = {.type = HEADER_EMPTY,
2699 .separationLine =
false,
2700 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2701 uint32_t set = reviewWithWarnCtx.warning->predefinedSet
2704 bool isBlindSigningOnly
2706 reviewWithWarnCtx.isIntro =
true;
2708 layoutDescription.
modal =
false;
2709 layoutDescription.withLeftBorder =
true;
2712 layoutDescription.tapActionText = NULL;
2714 layoutDescription.
ticker.tickerCallback = NULL;
2715 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2717 nbgl_layoutAddHeader(reviewWithWarnCtx.layoutCtx, &headerDesc);
2718 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2720 nbgl_layoutAddTopRightButton(reviewWithWarnCtx.layoutCtx,
2721 isBlindSigningOnly ? &INFO_I_ICON : &QRCODE_ICON,
2722 WARNING_BUTTON_TOKEN,
2725 else if (reviewWithWarnCtx.warning->introTopRightIcon != NULL) {
2726 nbgl_layoutAddTopRightButton(reviewWithWarnCtx.layoutCtx,
2727 reviewWithWarnCtx.warning->introTopRightIcon,
2728 WARNING_BUTTON_TOKEN,
2733 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2736 const char *provider;
2739 info.
icon = &LARGE_WARNING_ICON;
2742 if (isBlindSigningOnly ==
false) {
2743 if (reviewWithWarnCtx.warning->reportProvider) {
2744 provider = reviewWithWarnCtx.warning->reportProvider;
2747 provider =
"[unknown]";
2750 snprintf(tmpString, W3C_DESCRIPTION_MAX_LEN,
"Detected by %s", provider);
2754 if (isBlindSigningOnly) {
2755 info.
title =
"Blind signing ahead";
2758 =
"If you sign this transaction, you could lose your assets. "
2759 "Explore safer alternatives: ledger.com/integrated-apps";
2760 buttonsInfo.bottomText =
"Accept risk and continue";
2764 =
"This transaction's details are not fully verifiable. If you sign, you could "
2765 "lose all your assets.";
2766 buttonsInfo.bottomText =
"Continue anyway";
2768#ifdef HAVE_PIEZO_SOUND
2769 tune = TUNE_NEUTRAL;
2773 info.
title =
"Potential risk";
2774 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2778 info.
description = reviewWithWarnCtx.warning->providerMessage;
2780 buttonsInfo.bottomText =
"Accept risk and continue";
2781#ifdef HAVE_PIEZO_SOUND
2782 tune = TUNE_NEUTRAL;
2786 info.
title =
"Critical threat";
2787 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2791 info.
description = reviewWithWarnCtx.warning->providerMessage;
2793 buttonsInfo.bottomText =
"Accept threat and continue";
2794#ifdef HAVE_PIEZO_SOUND
2800 else if (reviewWithWarnCtx.warning->info != NULL) {
2803#ifdef HAVE_PIEZO_SOUND
2804 tune = TUNE_LOOK_AT_ME;
2808 nbgl_layoutAddChoiceButtons(reviewWithWarnCtx.layoutCtx, &buttonsInfo);
2810#ifdef HAVE_PIEZO_SOUND
2811 if (tune != TUNE_RESERVED) {
2812 os_io_seph_cmd_piezo_play_tune(tune);
2820static void displayPrelude(
void)
2823 nbgl_layoutChoiceButtons_t buttonsInfo
2824 = {.bottomText = reviewWithWarnCtx.warning->prelude->footerText,
2825 .token = PRELUDE_CHOICE_TOKEN,
2826 .topText = reviewWithWarnCtx.warning->prelude->buttonText,
2827 .style = ROUNDED_AND_FOOTER_STYLE,
2828 .tuneId = TUNE_TAP_CASUAL};
2829 nbgl_layoutHeader_t headerDesc = {.type = HEADER_EMPTY,
2830 .separationLine =
false,
2831 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2833 reviewWithWarnCtx.isIntro =
true;
2835 layoutDescription.
modal =
false;
2836 layoutDescription.withLeftBorder =
true;
2838 layoutDescription.tapActionText = NULL;
2839 layoutDescription.
ticker.tickerCallback = NULL;
2840 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2842 nbgl_layoutAddHeader(reviewWithWarnCtx.layoutCtx, &headerDesc);
2847 info.
icon = reviewWithWarnCtx.warning->prelude->icon;
2849 info.
title = reviewWithWarnCtx.warning->prelude->title;
2850 info.
description = reviewWithWarnCtx.warning->prelude->description;
2854 nbgl_layoutAddChoiceButtons(reviewWithWarnCtx.layoutCtx, &buttonsInfo);
2856#ifdef HAVE_PIEZO_SOUND
2857 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
2866 const char *predefinedTipBoxText = NULL;
2869 if (reviewWithWarnCtx.warning) {
2870 if (reviewWithWarnCtx.warning->predefinedSet & (1 <<
W3C_ISSUE_WARN)) {
2872 predefinedTipBoxText =
"Transaction Check unavailable.\nBlind signing required.";
2875 predefinedTipBoxText =
"Transaction Check unavailable";
2880 predefinedTipBoxText =
"Critical threat detected.\nBlind signing required.";
2883 predefinedTipBoxText =
"Critical threat detected.";
2888 predefinedTipBoxText =
"Potential risk detected.\nBlind signing required.";
2891 predefinedTipBoxText =
"Potential risk detected.";
2896 predefinedTipBoxText
2897 =
"No threat detected by Transaction Check but blind signing required.";
2900 predefinedTipBoxText =
"No threat detected by Transaction Check.";
2904 predefinedTipBoxText =
"Blind signing required.";
2908 if ((tipBox != NULL) || (predefinedTipBoxText != NULL)) {
2910 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
2911 if (predefinedTipBoxText != NULL) {
2912 genericContext.validWarningCtx =
true;
2913 STARTING_CONTENT.content.extendedCenter.tipBox.icon = NULL;
2914 STARTING_CONTENT.content.extendedCenter.tipBox.text = predefinedTipBoxText;
2917 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
2918 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
2920 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
2921 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
2929 const char *reviewTitle,
2930 const char *reviewSubTitle,
2931 const char *finishTitle,
2935 bool playNotifSound)
2937 bundleNavContext.review.operationType = operationType;
2938 bundleNavContext.review.choiceCallback = choiceCallback;
2941 onChoice = bundleNavReviewChoice;
2942 navType = GENERIC_NAV;
2945 genericContext.genericContents.contentsList = localContentsList;
2946 genericContext.genericContents.nbContents = 3;
2951 prepareReviewFirstPage(
2952 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2955 initWarningTipBox(tipBox);
2959 memcpy(&localContentsList[1].content.tagValueList,
2967 prepareReviewLightLastPage(
2968 operationType, &localContentsList[2].content.infoButton, icon, finishTitle);
2972 prepareReviewLastPage(
2973 operationType, &localContentsList[2].content.infoLongPress, icon, finishTitle);
2977 uint8_t nbPages = getNbPagesForGenericContents(
2979 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
2982 if (playNotifSound) {
2983#ifdef HAVE_PIEZO_SOUND
2984 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
2988 displayGenericContextPage(0,
true);
2994 const char *reviewTitle,
2995 const char *reviewSubTitle,
2997 bool playNotifSound)
2999 bundleNavContext.reviewStreaming.operationType = operationType;
3000 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3001 bundleNavContext.reviewStreaming.icon = icon;
3004 onChoice = bundleNavReviewStreamingChoice;
3005 navType = STREAMING_NAV;
3008 genericContext.genericContents.contentsList = localContentsList;
3009 genericContext.genericContents.nbContents = 1;
3014 prepareReviewFirstPage(
3015 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3018 initWarningTipBox(NULL);
3021 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3028 if (playNotifSound) {
3029#ifdef HAVE_PIEZO_SOUND
3030 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3034 displayGenericContextPage(0,
true);
3053static void useCaseHomeExt(
const char *appName,
3055 const char *tagline,
3062 .centeredInfo.text1 = appName,
3063 .centeredInfo.text3 = NULL,
3064 .centeredInfo.style = LARGE_CASE_INFO,
3065 .centeredInfo.offsetY = 0,
3068 .tapActionText = NULL,
3070 .topRightToken = CONTINUE_TOKEN,
3071 .tuneId = TUNE_TAP_CASUAL};
3072 reset_callbacks_and_context();
3074 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
3089 if (tagline == NULL) {
3093 "This app enables signing\ntransactions on its network.");
3120 onContinue = topRightCallback;
3121 onQuit = quitCallback;
3135static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
3137 memset(&detailsContext, 0,
sizeof(detailsContext));
3143 detailsContext.tag = tag;
3144 detailsContext.value = value;
3146 detailsContext.currentPage = 0;
3147 detailsContext.wrapping = wrapping;
3149 if (detailsContext.nbPages > 1) {
3150 uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3;
3153 uint8_t nbLinesInLastPage
3159 detailsContext.nbPages++;
3163 displayDetailsPage(0,
true);
3169 uint8_t nbElements = 0;
3170 uint8_t nbElementsInPage;
3171 uint8_t elemIdx = 0;
3174 memset(&detailsContext, 0,
sizeof(detailsContext));
3175 nbElements = tagValues->
nbPairs;
3177 while (nbElements > 0) {
3178 nbElementsInPage = getNbTagValuesInDetailsPage(nbElements, tagValues, elemIdx);
3180 elemIdx += nbElementsInPage;
3181 modalContextSetPageInfo(detailsContext.nbPages, nbElementsInPage);
3182 nbElements -= nbElementsInPage;
3183 detailsContext.nbPages++;
3186 displayTagValueListModalPage(0,
true);
3208 bool *requireSpecificDisplay)
3210 return getNbTagValuesInPage(
3211 nbPairs, tagValueList, startIndex,
false,
false,
false, requireSpecificDisplay);
3231 bool *requireSpecificDisplay)
3233 return getNbTagValuesInPage(
3234 nbPairs, tagValueList, startIndex, isSkippable,
false,
false, requireSpecificDisplay);
3251 uint8_t nbInfosInPage = 0;
3252 uint16_t currentHeight = 0;
3253 uint16_t previousHeight;
3254 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3255 const char *
const *infoContents = PIC(infosList->
infoContents);
3257 while (nbInfosInPage < nbInfos) {
3260 += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING + LIST_ITEM_HEADING_SUB_TEXT;
3264 PIC(infoContents[startIndex + nbInfosInPage]),
3271 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3276 previousHeight = currentHeight;
3279 return nbInfosInPage;
3296 uint8_t nbSwitchesInPage = 0;
3297 uint16_t currentHeight = 0;
3298 uint16_t previousHeight = 0;
3299 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3302 while (nbSwitchesInPage < nbSwitches) {
3306 uint16_t textHeight =
MAX(
3307 LIST_ITEM_MIN_TEXT_HEIGHT,
3309 currentHeight += textHeight + 2 * LIST_ITEM_PRE_HEADING;
3312 currentHeight += LIST_ITEM_HEADING_SUB_TEXT;
3322 previousHeight = currentHeight;
3327 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3330 return nbSwitchesInPage;
3347 uint8_t nbBarsInPage = 0;
3348 uint16_t currentHeight = 0;
3349 uint16_t previousHeight;
3350 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3355 while (nbBarsInPage < nbBars) {
3356 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3361 previousHeight = currentHeight;
3366 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3369 return nbBarsInPage;
3386 uint8_t nbChoicesInPage = 0;
3387 uint16_t currentHeight = 0;
3388 uint16_t previousHeight;
3389 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3391 UNUSED(choicesList);
3394 while (nbChoicesInPage < nbChoices) {
3395 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3400 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3405 previousHeight = currentHeight;
3408 return nbChoicesInPage;
3419 uint8_t nbPages = 0;
3420 uint8_t nbPairs = tagValueList->
nbPairs;
3421 uint8_t nbPairsInPage;
3425 while (i < tagValueList->nbPairs) {
3429 nbPairs -= nbPairsInPage;
3439void nbgl_useCaseHome(
const char *appName,
3441 const char *tagline,
3448 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
3455void nbgl_useCaseHomeExt(
const char *appName,
3457 const char *tagline,
3459 const char *actionButtonText,
3467 .text = actionButtonText};
3470 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
3493 reset_callbacks_and_context();
3496 onQuit = quitCallback;
3497 onNav = navCallback;
3498 onControls = controlsCallback;
3500 navType = SETTINGS_NAV;
3503 prepareNavInfo(
false, nbPages, NULL);
3505 displaySettingsPage(initPage,
true);
3513void nbgl_useCaseSettings(
const char *title,
3523 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
3544 reset_callbacks_and_context();
3547 onQuit = quitCallback;
3548 pageTitle = appName;
3549 navType = GENERIC_NAV;
3551 if (settingContents != NULL) {
3554 if (infosList != NULL) {
3555 genericContext.hasFinishingContent =
true;
3558 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
3562 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3563 if (infosList != NULL) {
3564 nbPages += getNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
3567 prepareNavInfo(
false, nbPages, NULL);
3569 displayGenericContextPage(initPage,
true);
3608 const char *appName,
3610 const char *tagline,
3618 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
3620 reset_callbacks_and_context();
3622 context->appName = appName;
3623 context->appIcon = appIcon;
3624 context->tagline = tagline;
3625 context->settingContents = settingContents;
3626 context->infosList = infosList;
3627 if (action != NULL) {
3633 context->quitCallback = quitCallback;
3636 bundleNavStartSettingsAtPage(initSettingPage);
3639 bundleNavStartHome();
3653 .tickerIntervale = 0,
3657 reset_callbacks_and_context();
3659 onQuit = quitCallback;
3661#ifdef HAVE_PIEZO_SOUND
3662 os_io_seph_cmd_piezo_play_tune(TUNE_LEDGER_MOMENT);
3665 info.
centeredInfo.
icon = isSuccess ? &CHECK_CIRCLE_ICON : &DENIED_CIRCLE_ICON;
3670 info.
tuneId = TUNE_TAP_CASUAL;
3686 switch (reviewStatusType) {
3688 msg =
"Operation signed";
3692 msg =
"Operation rejected";
3696 msg =
"Transaction signed";
3700 msg =
"Transaction rejected";
3704 msg =
"Message signed";
3708 msg =
"Message rejected";
3712 msg =
"Address verified";
3716 msg =
"Address verification\ncancelled";
3738 const char *message,
3739 const char *subMessage,
3740 const char *confirmText,
3741 const char *cancelText,
3746 if ((confirmText == NULL) || (cancelText == NULL)) {
3749 reset_callbacks_and_context();
3758 info.
tuneId = TUNE_TAP_CASUAL;
3760 onChoice = callback;
3780 const char *message,
3781 const char *subMessage,
3782 const char *confirmText,
3783 const char *cancelText,
3788 (details != NULL) ? &SEARCH_ICON : NULL,
3823 const char *message,
3824 const char *subMessage,
3825 const char *confirmText,
3826 const char *cancelText,
3831 nbgl_layoutChoiceButtons_t buttonsInfo = {.bottomText = cancelText,
3832 .token = CHOICE_TOKEN,
3833 .topText = confirmText,
3834 .style = ROUNDED_AND_FOOTER_STYLE,
3835 .tuneId = TUNE_TAP_CASUAL};
3837 nbgl_layoutHeader_t headerDesc = {.type = HEADER_EMPTY,
3838 .separationLine =
false,
3839 .emptySpace.height = MEDIUM_CENTERING_HEADER};
3841 if ((confirmText == NULL) || (cancelText == NULL)) {
3845 reset_callbacks_and_context();
3847#ifdef HAVE_PIEZO_SOUND
3848 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3851 onChoice = callback;
3852 layoutDescription.
modal =
false;
3853 layoutDescription.withLeftBorder =
true;
3855 layoutDescription.tapActionText = NULL;
3856 layoutDescription.
ticker.tickerCallback = NULL;
3857 sharedContext.usage = SHARE_CTX_CHOICE_WITH_DETAILS;
3858 choiceWithDetailsCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
3859 choiceWithDetailsCtx.details = details;
3861 nbgl_layoutAddHeader(choiceWithDetailsCtx.layoutCtx, &headerDesc);
3862 nbgl_layoutAddChoiceButtons(choiceWithDetailsCtx.layoutCtx, &buttonsInfo);
3863 centeredInfo.
icon = centerIcon;
3864 centeredInfo.
title = title;
3866 centeredInfo.
subText = subMessage;
3869 if ((details != NULL) && (headerIcon != NULL)) {
3870 nbgl_layoutAddTopRightButton(
3871 choiceWithDetailsCtx.layoutCtx, headerIcon, CHOICE_DETAILS_TOKEN, TUNE_TAP_CASUAL);
3892 const char *subMessage,
3893 const char *confirmText,
3894 const char *cancelText,
3900 .centeredInfo.text1 = message,
3901 .centeredInfo.text2 = subMessage,
3902 .centeredInfo.text3 = NULL,
3903 .centeredInfo.style = LARGE_CASE_INFO,
3904 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
3905 .centeredInfo.offsetY = 0,
3906 .confirmationText = confirmText,
3907 .confirmationToken = CHOICE_TOKEN,
3908 .tuneId = TUNE_TAP_CASUAL,
3910 onModalConfirm = callback;
3911 if (modalPageContext != NULL) {
3929 const char *message,
3930 const char *actionText,
3935 reset_callbacks_and_context();
3937 onAction = callback;
3939 content.
tuneId = TUNE_TAP_CASUAL;
3962 const char *reviewTitle,
3963 const char *reviewSubTitle,
3964 const char *rejectText,
3969 .footerToken = QUIT_TOKEN,
3970 .tapActionText = NULL,
3971 .isSwipeable =
true,
3972 .tapActionToken = CONTINUE_TOKEN,
3974 .actionButtonText = NULL,
3975 .
tuneId = TUNE_TAP_CASUAL};
3977 reset_callbacks_and_context();
3985 onQuit = rejectCallback;
3986 onContinue = continueCallback;
3988#ifdef HAVE_PIEZO_SOUND
3990 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4001void nbgl_useCaseRegularReview(uint8_t initPage,
4003 const char *rejectText,
4008 reset_callbacks_and_context();
4011 onChoice = choiceCallback;
4012 onNav = navCallback;
4013 onControls = buttonCallback;
4014 forwardNavOnly =
false;
4015 navType = REVIEW_NAV;
4019 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4021 displayReviewPage(initPage,
true);
4038 const char *rejectText,
4043 reset_callbacks_and_context();
4046 onChoice = callback;
4047 navType = GENERIC_NAV;
4051 genericContext.genericContents.contentsList = localContentsList;
4054 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
4056 memcpy(&localContentsList[offset].content.tagValueList,
4063 memcpy(&localContentsList[offset].content.infoLongPress,
4069 genericContext.genericContents.nbContents = offset;
4072 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4074 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4076 displayGenericContextPage(0,
true);
4094 const char *rejectText,
4099 reset_callbacks_and_context();
4102 onChoice = callback;
4103 navType = GENERIC_NAV;
4106 genericContext.genericContents.contentsList = localContentsList;
4109 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
4111 memcpy(&localContentsList[offset].content.tagValueList,
4125 genericContext.genericContents.nbContents = offset;
4128 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4130 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4132 displayGenericContextPage(0,
true);
4154 const char *reviewTitle,
4155 const char *reviewSubTitle,
4156 const char *finishTitle,
4159 reset_callbacks_and_context();
4161 useCaseReview(operationType,
4195 const char *reviewTitle,
4196 const char *reviewSubTitle,
4197 const char *finishTitle,
4208 &blindSigningWarning,
4237 const char *reviewTitle,
4238 const char *reviewSubTitle,
4239 const char *finishTitle,
4244 reset_callbacks_and_context();
4247 if (tipBox != NULL) {
4248 memcpy(&activeTipBox, tipBox,
sizeof(activeTipBox));
4251 if ((warning == NULL)
4254 useCaseReview(operationType,
4272 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4273 reviewWithWarnCtx.isStreaming =
false;
4274 reviewWithWarnCtx.operationType = operationType;
4275 reviewWithWarnCtx.tagValueList = tagValueList;
4276 reviewWithWarnCtx.icon = icon;
4277 reviewWithWarnCtx.reviewTitle = reviewTitle;
4278 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4279 reviewWithWarnCtx.finishTitle = finishTitle;
4280 reviewWithWarnCtx.warning = warning;
4281 reviewWithWarnCtx.choiceCallback = choiceCallback;
4284 if (reviewWithWarnCtx.warning->prelude) {
4289 displayInitialWarning();
4292 useCaseReview(operationType,
4324 const char *reviewTitle,
4325 const char *reviewSubTitle,
4326 const char *finishTitle,
4329 reset_callbacks_and_context();
4331 useCaseReview(operationType,
4352 const char *rejectText,
4355 reset_callbacks_and_context();
4358 onQuit = rejectCallback;
4359 navType = GENERIC_NAV;
4366 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4367 prepareNavInfo(
true, nbPages, rejectText);
4370#ifdef HAVE_PIEZO_SOUND
4372 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4375 displayGenericContextPage(0,
true);
4392 const char *reviewTitle,
4393 const char *reviewSubTitle,
4396 reset_callbacks_and_context();
4398 useCaseReviewStreamingStart(
4399 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4417 const char *reviewTitle,
4418 const char *reviewSubTitle,
4422 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
4442 const char *reviewTitle,
4443 const char *reviewSubTitle,
4447 reset_callbacks_and_context();
4450 if ((warning == NULL)
4453 useCaseReviewStreamingStart(
4454 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4464 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4465 reviewWithWarnCtx.isStreaming =
true;
4466 reviewWithWarnCtx.operationType = operationType;
4467 reviewWithWarnCtx.icon = icon;
4468 reviewWithWarnCtx.reviewTitle = reviewTitle;
4469 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4470 reviewWithWarnCtx.choiceCallback = choiceCallback;
4471 reviewWithWarnCtx.warning = warning;
4474 if (reviewWithWarnCtx.warning->prelude) {
4479 displayInitialWarning();
4482 useCaseReviewStreamingStart(
4483 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4505 memset(&genericContext, 0,
sizeof(genericContext));
4507 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4508 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
4511 onChoice = bundleNavReviewStreamingChoice;
4512 navType = STREAMING_NAV;
4515 genericContext.genericContents.contentsList = localContentsList;
4516 genericContext.genericContents.nbContents = 1;
4525 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4526 &genericContext.genericContents,
4529 prepareNavInfo(
true,
4531 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4539 displayGenericContextPage(0,
true);
4570 memset(&genericContext, 0,
sizeof(genericContext));
4572 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4575 onChoice = bundleNavReviewStreamingChoice;
4576 navType = STREAMING_NAV;
4579 genericContext.genericContents.contentsList = localContentsList;
4580 genericContext.genericContents.nbContents = 1;
4585 prepareReviewLastPage(bundleNavContext.reviewStreaming.operationType,
4586 &STARTING_CONTENT.content.infoLongPress,
4587 bundleNavContext.reviewStreaming.icon,
4591 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4592 &genericContext.genericContents,
4595 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4597 displayGenericContextPage(0,
true);
4604void nbgl_useCaseAddressConfirmationExt(
const char *address,
4608 reset_callbacks_and_context();
4609 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4612 onChoice = callback;
4613 navType = GENERIC_NAV;
4616 genericContext.genericContents.contentsList = localContentsList;
4617 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
4619 prepareAddressConfirmationPages(
4620 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
4623 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4625 prepareNavInfo(
true, nbPages,
"Cancel");
4627#ifdef HAVE_PIEZO_SOUND
4629 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4632 displayGenericContextPage(0,
true);
4654 const char *reviewTitle,
4655 const char *reviewSubTitle,
4658 reset_callbacks_and_context();
4661 if (addressConfirmationContext.modalLayout) {
4664 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4667 onChoice = choiceCallback;
4668 navType = GENERIC_NAV;
4672 genericContext.genericContents.contentsList = localContentsList;
4677 prepareReviewFirstPage(
4678 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
4679 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
4682 prepareAddressConfirmationPages(
4683 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
4686 genericContext.genericContents.nbContents
4688 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4690 prepareNavInfo(
true, nbPages,
"Cancel");
4692#ifdef HAVE_PIEZO_SOUND
4694 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4697 displayGenericContextPage(0,
true);
4711 if (genericContext.type != USE_CASE_SPINNER) {
4712 memset(&genericContext, 0,
sizeof(genericContext));
4713 genericContext.type = USE_CASE_SPINNER;
4716 layoutDescription.withLeftBorder =
true;
4718 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
4720 nbgl_layoutAddSpinner(
4721 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4728 genericContext.spinnerPosition++;
4730 if (genericContext.spinnerPosition == NB_SPINNER_POSITIONS) {
4731 genericContext.spinnerPosition = 0;
4733 int ret = nbgl_layoutUpdateSpinner(
4734 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4738 else if (ret == 2) {
4772 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
4773 .separationLine =
true,
4774 .backAndText.token = BACK_TOKEN,
4775 .backAndText.tuneId = TUNE_TAP_CASUAL};
4782 reset_callbacks_and_context();
4784 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
4787 onQuit = backCallback;
4791 layoutDescription.
modal =
false;
4792 layoutDescription.withLeftBorder =
false;
4794 keypadContext.hidden = hidden;
4797 nbgl_layoutAddHeader(keypadContext.layoutCtx, &headerDesc);
4806 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
4812 keypadContext.onValidatePin = validatePinCallback;
4814 keypadContext.pinMinDigits = minDigits;
4815 keypadContext.pinMaxDigits = maxDigits;
4853 nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_TEXT,
4854 .backAndText.token = BACK_TOKEN,
4855 .backAndText.tuneId = TUNE_TAP_CASUAL};
4858 .mode = params->
mode,
4859 .casing = params->casing};
4863 reset_callbacks_and_context();
4865 memset(&keyboardContext, 0,
sizeof(KeyboardContext_t));
4868 onQuit = backCallback;
4874 nbgl_layoutAddHeader(keyboardContext.layoutCtx, &headerDesc);
4881 keyboardContext.keyboardIndex = status;
4882 keyboardContext.casing = params->casing;
4884 keyboardContext.entryMaxLen = params->
entryMaxLen;
4885 keyboardContext.entryBuffer[0] =
'\0';
4888 .type = params->
type,
4889 .title = PIC(params->
title),
4890 .numbered = params->numbered,
4891 .number = params->number,
4893 .textToken = KEYBOARD_CROSS_TOKEN,
4894 .tuneId = TUNE_TAP_CASUAL,
4896 switch (params->
type) {
4901 .token = KEYBOARD_BUTTON_TOKEN,
4907 keyboardContext.getSuggestionButtons
4917 status = nbgl_layoutAddKeyboardContent(keyboardContext.layoutCtx,
4918 &keyboardContext.keyboardContent);
nbgl_contentTagValue_t *(* nbgl_contentTagValueCallback_t)(uint8_t pairIndex)
prototype of tag/value pair retrieval callback
@ ICON_ILLUSTRATION
simple icon
@ INFO_LONG_PRESS
a centered info and a long press button
@ EXTENDED_CENTER
a centered content and a possible tip-box
@ CHOICES_LIST
list of choices through radio buttons
@ CENTERED_INFO
a centered info
@ SWITCHES_LIST
list of switches with descriptions
@ TAG_VALUE_DETAILS
a tag/value pair and a small button to get details.
@ INFOS_LIST
list of infos with titles
@ TAG_VALUE_CONFIRM
tag/value pairs and a black button/footer to confirm/cancel.
@ TAG_VALUE_LIST
list of tag/value pairs
@ BARS_LIST
list of touchable bars (with > on the right to go to sub-pages)
@ INFO_BUTTON
a centered info and a simple black button
@ INFO_LIST_ALIAS
alias is list of infos
@ ENS_ALIAS
alias comes from ENS
@ ADDRESS_BOOK_ALIAS
alias comes from Address Book
@ QR_CODE_ALIAS
alias is an address to be displayed as a QR Code
void(* nbgl_contentActionCallback_t)(int token, uint8_t index, int page)
prototype of function to be called when an action on a content object occurs
#define LOG_DEBUG(__logger,...)
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
int nbgl_layoutAddKeyboard(nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
Creates a keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t keyMask)
Updates an existing keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace)
Updates an existing keypad on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, bool hidden, uint8_t nbDigits, const char *text)
Adds an area with a title and a placeholder for hidden digits on top of a keypad, to represent the en...
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
void * nbgl_layout_t
type shared externally
#define NBGL_INVALID_TOKEN
int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout, bool hidden, uint8_t nbActiveDigits, const char *text)
Updates an existing set of hidden digits, with the given configuration.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, const char *text, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
keyboardCase_t
Letters casing in which to open/set the keyboard.
#define KEYPAD_MAX_DIGITS
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
nbgl_page_t * nbgl_pageDrawGenericContent(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content)
nbgl_page_t * nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const nbgl_pageInfoDescription_t *info)
void * nbgl_page_t
type shared externally
@ NAV_WITH_BUTTONS
move forward and backward with buttons in bottom nav bar
nbgl_page_t * nbgl_pageDrawConfirmation(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageConfirmationDescription_t *info)
int nbgl_pageRelease(nbgl_page_t *)
nbgl_page_t * nbgl_pageDrawGenericContentExt(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content, bool modal)
@ QUIT_APP_TEXT
A full width button with "Quit app" text (only for bottom button)
@ INFO_ICON
info (i) icon in the button.
@ NO_BUTTON_STYLE
no button.
@ SETTINGS_ICON
settings (wheel) icon in the button.
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
nbgl_refresh_mode_t
different modes of refresh for nbgl_refreshSpecial()
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ FULL_COLOR_CLEAN_REFRESH
to be used for lock screen display (cleaner but longer refresh)
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
@ FULL_COLOR_REFRESH
to be used for normal refresh
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
#define NB_MAX_LINES_IN_REVIEW
maximum number of lines for value field in review pages
@ NO_TYPE_WARNING
Invalid type (to use for bars leading to nothing)
@ CENTERED_INFO_WARNING
Centered info.
@ BAR_LIST_WARNING
list of touchable bars, to display sub-pages
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool isSkippable, bool *requireSpecificDisplay)
void(* nbgl_callback_t)(void)
prototype of generic callback function
#define SKIPPABLE_OPERATION
This is to use in nbgl_operationType_t when the operation is skippable. This is used.
void nbgl_useCaseGenericSettings(const char *appName, uint8_t initPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, nbgl_callback_t quitCallback)
uint32_t nbgl_operationType_t
This mask is used to describe the type of operation to review with additional options It is a mask of...
void nbgl_useCaseReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAction(const nbgl_icon_details_t *icon, const char *message, const char *actionText, nbgl_callback_t callback)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList)
void(* nbgl_pinValidCallback_t)(const uint8_t *pin, uint8_t pinLen)
prototype of pin validation callback function
void nbgl_useCaseReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseHomeAndSettings(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, const uint8_t initSettingPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, const nbgl_homeAction_t *action, nbgl_callback_t quitCallback)
#define RISKY_OPERATION
This is to use in nbgl_operationType_t when the operation is concerned by an internal warning....
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos, const nbgl_contentInfoList_t *infosList, uint8_t startIndex, bool withNav)
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
uint8_t nbgl_useCaseGetNbBarsInPage(uint8_t nbBars, const nbgl_contentBarsList_t *barsList, uint8_t startIndex, bool withNav)
void nbgl_useCaseNavigableContent(const char *title, uint8_t initPage, uint8_t nbPages, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
#define INFOS_AREA_HEIGHT
height available for infos pairs display
@ STRONG_HOME_ACTION
Black button, implicating the main action of the App.
void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
#define NO_THREAT_OPERATION
This is to use in nbgl_operationType_t when the operation is concerned by an internal information....
void nbgl_useCaseChoiceWithDetails(const nbgl_icon_details_t *icon, const char *message, const char *subMessage, const char *confirmText, const char *cancelText, nbgl_warningDetails_t *details, nbgl_choiceCallback_t callback)
void nbgl_useCaseAdvancedChoiceWithDetails(const nbgl_icon_details_t *centerIcon, const nbgl_icon_details_t *headerIcon, const char *title, const char *message, const char *subMessage, const char *confirmText, const char *cancelText, nbgl_warningDetails_t *details, nbgl_choiceCallback_t callback)
void nbgl_useCaseSpinner(const char *text)
void nbgl_useCaseConfirm(const char *message, const char *subMessage, const char *confirmText, const char *rejectText, nbgl_callback_t callback)
#define NB_MAX_LINES_IN_DETAILS
maximum number of lines for value field in details pages
#define APP_DESCRIPTION_MAX_LEN
Length of buffer used for the default Home tagline.
void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback)
@ W3C_THREAT_DETECTED_WARN
Web3 Checks: Threat detected (see reportRisk field)
@ W3C_ISSUE_WARN
Web3 Checks issue (not available)
@ BLIND_SIGNING_WARN
Blind signing.
@ GATED_SIGNING_WARN
Gated signing.
@ W3C_NO_THREAT_WARN
Web3 Checks: No Threat detected.
@ W3C_RISK_DETECTED_WARN
Web3 Checks: Risk detected (see reportRisk field)
void nbgl_useCaseGenericConfiguration(const char *title, uint8_t initPage, const nbgl_genericContents_t *contents, nbgl_callback_t quitCallback)
#define INIT_HOME_PAGE
Value to pass to nbgl_useCaseHomeAndSettings() initSettingPage parameter to initialize the use case o...
void nbgl_useCaseKeypad(const char *title, uint8_t minDigits, uint8_t maxDigits, bool shuffled, bool hidden, nbgl_pinValidCallback_t validatePinCallback, nbgl_callback_t backCallback)
void nbgl_useCaseReviewStreamingContinueExt(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback, nbgl_callback_t skipCallback)
void nbgl_useCaseReviewBlindSigning(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseChoice(const nbgl_icon_details_t *icon, const char *message, const char *subMessage, const char *confirmText, const char *rejectString, nbgl_choiceCallback_t callback)
#define FIRST_USER_TOKEN
when using controls in page content (nbgl_pageContent_t), this is the first token value usable for th...
#define TAG_VALUE_AREA_HEIGHT
height available for tag/value pairs display
#define BLIND_OPERATION
This is to use in nbgl_operationType_t when the operation is "blind" This is used to indicate a warni...
#define TAGLINE_PART1
Default strings used in the Home tagline.
void nbgl_useCaseGenericReview(const nbgl_genericContents_t *contents, const char *rejectText, nbgl_callback_t rejectCallback)
#define STATUS_SCREEN_DURATION
void nbgl_useCaseKeyboard(const nbgl_keyboardParams_t *params, nbgl_callback_t backCallback)
void nbgl_useCaseReviewStreamingBlindSigningStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewStreamingContinue(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewLight(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoices, const nbgl_contentRadioChoice_t *choicesList, uint8_t startIndex, bool withNav)
void(* nbgl_keyboardButtonsCallback_t)(nbgl_layoutKeyboardContent_t *content, uint32_t *mask)
prototype of keyboard buttons callback function
#define REAL_TYPE_MASK
Mask to apply on nbgl_operationType_t to extract the base nbgl_opType_t. Bits 0-3 are reserved for th...
void nbgl_useCaseReviewStatus(nbgl_reviewStatusType_t reviewStatusType, nbgl_callback_t quitCallback)
#define LAST_PAGE_FOR_REVIEW
value of page parameter used with navigation callback when "skip" button is touched,...
#define ADDRESS_BOOK_OPERATION
This is to use in nbgl_operationType_t when the operation is related to "Address Book" to adapt wordi...
nbgl_reviewStatusType_t
The different types of review status.
@ STATUS_TYPE_TRANSACTION_REJECTED
@ STATUS_TYPE_ADDRESS_REJECTED
@ STATUS_TYPE_TRANSACTION_SIGNED
@ STATUS_TYPE_OPERATION_REJECTED
@ STATUS_TYPE_OPERATION_SIGNED
@ STATUS_TYPE_ADDRESS_VERIFIED
@ STATUS_TYPE_MESSAGE_SIGNED
@ STATUS_TYPE_MESSAGE_REJECTED
bool(* nbgl_navCallback_t)(uint8_t page, nbgl_pageContent_t *content)
prototype of navigation callback function
#define MAX_APP_NAME_FOR_SDK_TAGLINE
Max supported length of appName used for the default Home tagline.
#define HAS_INITIAL_WARNING(_warning)
void nbgl_useCaseAddressReview(const char *address, const nbgl_contentTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
@ TYPE_TRANSACTION
For operations transferring a coin or taken from an account to another.
@ TYPE_OPERATION
For other types of operation (generic type)
void nbgl_useCaseAdvancedReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwitches, const nbgl_contentSwitchesList_t *switchesList, uint8_t startIndex, bool withNav)
This structure contains data to build a BARS_LIST content.
const uint8_t * tokens
array of tokens, one for each bar (nbBars items)
const char *const * barTexts
array of texts for each bar (nbBars items, in black/bold)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when a bar is touched
uint8_t nbBars
number of elements in barTexts and tokens array
This structure contains info to build a centered (vertically and horizontally) area,...
uint16_t iconHug
vertical margin to apply on top and bottom of the icon
const nbgl_icon_details_t * icon
the icon (can be null)
const char * title
title in black large (can be null)
const char * description
description in black small regular case (can be null)
const char * subText
sub-text in dark gray regular small case
bool padding
if true, apply a padding of 40px at the bottom
const char * smallTitle
sub-title in black small bold case (can be null)
nbgl_contentIllustrationType_t illustrType
const char * text2
second text (can be null)
const char * text1
first text (can be null)
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
nbgl_contentCenter_t contentCenter
centered content (icon + text(s))
This structure contains data to build a centered info + simple black button content.
const char * buttonText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is touched
This structure contains data to build a INFOS_LIST content.
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
const nbgl_contentValueExt_t * infoExtensions
uint8_t nbInfos
number of elements in infoTypes and infoContents array
This structure contains data to build a centered info + long press button content.
const char * longPressText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t initChoice
index of the current choice
const char *const * names
array of strings giving the choices (nbChoices)
uint8_t nbChoices
number of choices
This structure contains info to build a switch (on the right) with a description (on the left),...
const char * text
main text for the switch
const char * subText
description under main text (NULL terminated, single line, may be null)
This structure contains [item,value] pair(s) and info about a potential "details" button,...
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when details button is touched
const char * confirmationText
text of the confirmation button, if NULL "It matches" is used
uint8_t detailsButtonToken
uint8_t confirmationToken
the token used as argument of the onActionCallback
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
const char * detailsButtonText
this text is used for "details" button (if NULL, no button)
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
uint8_t detailsButtonToken
const char * detailsButtonText
this text is used for "details" button
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
This structure contains a list of [tag,value] pairs.
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
if > 0, set the max number of lines for value field.
bool hideEndOfLastLine
if set to true, replace 3 last chars of last line by "..."
bool wrapping
if set to true, value text will be wrapped on ' ' to avoid cutting words
uint8_t startIndex
index of the first pair to get with callback
nbgl_contentActionCallback_t actionCallback
called when a valueIcon is touched on a given pair
This structure contains a [tag,value] pair and possible extensions.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const nbgl_icon_details_t * valueIcon
int8_t centeredInfo
if set to 1, the tag will be displayed as a centered info
const char * value
string giving the value name
const char * item
string giving the tag name
This structure contains additions to a tag/value pair, to be able to build a screen to display these ...
const char * fullValue
full string of the value when used as an alias
nbgl_contentValueAliasType_t aliasType
type of alias
const struct nbgl_contentTagValueList_s * tagValuelist
if aliasType is TAG_VALUE_LIST_ALIAS
const char * backText
used as title of the popping page, if not NULL, otherwise "item" is used
const char * aliasSubName
string displayed under alias and in details view
const struct nbgl_contentInfoList_s * infolist
if aliasType is INFO_LIST_ALIAS
This structure contains data to build a content.
nbgl_contentActionCallback_t contentActionCallback
callback to be called when an action on an object occurs
nbgl_contentType_t type
type of page content in the content union
const struct nbgl_genericDetails_s * details
array of nbBars structures giving what to display when each bar is touched.
uint8_t nbBars
number of touchable bars
const nbgl_icon_details_t ** icons
array of icons for each bar (nbBars items)
const char *const * subTexts
array of texts for each bar (nbBars items, in black)
const char *const * texts
array of texts for each bar (nbBars items, in black/bold)
uint8_t nbContents
number of contents
const nbgl_content_t * contentsList
array of nbgl_content_t (nbContents items).
nbgl_contentCallback_t contentGetterCallback
function to call to retrieve a given content
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
const char * title
text of the page (used to go back)
nbgl_genericBarList_t barList
touchable bars list, if type == BAR_LIST_WARNING
nbgl_genericDetailsType_t type
type of content in the page, determining what to use in the following union
nbgl_contentCenter_t centeredInfo
centered info, if type == CENTERED_INFO_WARNING
Structure describing the action button in Home Screen.
const nbgl_icon_details_t * icon
icon to use in action button in Home page
nbgl_callback_t callback
function to call when action button is touched in Home page
const char * text
text to use in action button in Home page
nbgl_homeActionStyle_t style
style of action button
nbgl_keyboardButtonsCallback_t updateButtonsCallback
callback to call when a key is pressed to update suggestions
nbgl_layoutTouchCallback_t onButtonCallback
callback to call when one of the buttons is pressed
const char ** buttons
array of strings for buttons (last ones can be NULL)
int firstButtonToken
first token used for buttons, provided in onButtonCallback
Structure containing all parameters for keyboard use case.
keyboardMode_t mode
keyboard mode to start with
nbgl_kbdSuggestParams_t suggestionParams
nbgl_kbdButtonParams_t confirmationParams
used if type is KEYBOARD_WITH_SUGGESTIONS
bool lettersOnly
if true, only display letter keys and Backspace
uint8_t entryMaxLen
maximum length of text that can be entered
nbgl_layoutKeyboardContentType_t type
type of content
const char * title
centered title explaining the screen
char * entryBuffer
already entered text
This structure contains info to build a clickable "bar" with a text and an icon.
bool inactive
if set to true, the bar is grayed-out and cannot be touched
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
bool large
set to true only for the main level of OS settings
const char * subText
sub text (can be NULL)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
const nbgl_icon_details_t * iconLeft
a buffer containing the 1BPP icon for icon on left (can be NULL)
const nbgl_icon_details_t * iconRight
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_screenTickerConfiguration_t ticker
nbgl_layoutButtonCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard()
keyboardCallback_t callback
function called when an active key is pressed
This structure contains info to build a keyboard content (controls that are linked to keyboard)
This structure contains info for Text content, to be set with nbgl_layoutAddTextContent().
const char * descriptions[NB_MAX_DESCRIPTIONS]
uint8_t nbDescriptions
number of used descriptions in above array
const char * info
description at bottom (in small gray)
const char * title
main text (in large bold font)
Structure containing all specific information when creating a confirmation page.
const char * cancelText
the text used for cancel action, if NULL a simple X button is used
uint8_t confirmationToken
the token used as argument of the onActionCallback
const char * confirmationText
text of the confirmation button
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is pressed
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent)
nbgl_contentTagValueDetails_t tagValueDetails
TAG_VALUE_DETAILS type
const char * title
text for the title of the page (if NULL, no title)
uint8_t topRightToken
token used when top-right button (if not NULL) is touched
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when title is touched
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
const nbgl_icon_details_t * topRightIcon
nbgl_contentType_t type
type of page content in the following union
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
bool isTouchableTitle
if set to true, the title is preceded by <- arrow to go back
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
Structure containing all specific information when creating an information page.
nbgl_layoutButtonStyle_t actionButtonStyle
style of "action" button
const char * actionButtonText
if not NULL an "action" button is set under the centered info
const char * tapActionText
uint8_t bottomButtonsToken
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button/footer is pressed
const nbgl_icon_details_t * actionButtonIcon
potential icon of "action" button
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
Structure containing all specific information when creating a multi-screens page.
uint8_t nbPages
the number of pages to display (if <2, no navigation bar)
uint8_t quitToken
the token used as argument of the actionCallback when the footer is touched
uint8_t skipToken
if skipText is NULL the token used when right part of footer is touched
nbgl_pageNavigationType_t navType
uint8_t activePage
the index of the page to display at start-up
bool progressIndicator
if set to true, display a progress indicator on top of the page
nbgl_pageNavWithButtons_t navWithButtons
structure used when navigation with buttons
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when next or back is pressed
bool visiblePageIndicator
if set to true, the page indicator will be visible in navigation
const char * quitText
the text displayed in footer (on the left), used to quit (only on Flex)
bool backButton
if set to true, a back button (<-) is displayed in the nav bar
This structure contains data to build a SWITCHES_LIST content.
uint8_t nbSwitches
number of elements in switches and tokens array
const nbgl_contentSwitch_t * switches
array of switches (nbSwitches items)
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
const char * text
text of the tip-box
const nbgl_icon_details_t * icon
icon of the tip-box
The necessary parameters to build a warning page preceding a review. One can either use predefinedSet...
const nbgl_preludeDetails_t * prelude
if not null, means that the review can start by a prelude
const nbgl_warningDetails_t * introDetails
const nbgl_warningDetails_t * reviewDetails
Union of the different type of contents.
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type