17#include "os_io_seph_ux.h"
20#include "os_helpers.h"
27#define PAGE_NB_ELEMENTS_BITS 3
28#define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
29#define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
31#define PAGE_FLAG_BITS 1
32#define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
33#define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
35#define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
36#define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
37#define SET_PAGE_DATA(pageIdx, pageData) \
38 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
39 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
41#define MAX_PAGE_NB 256
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 {
115 const char *nextPageStart;
118typedef struct AddressConfirmationContext_s {
122} AddressConfirmationContext_t;
125typedef struct KeypadContext_s {
128 uint8_t pinMinDigits;
129 uint8_t pinMaxDigits;
137typedef struct KeyboardContext_s {
138 nbgl_layoutKeyboardContent_t keyboardContent;
148typedef struct ReviewWithWarningContext_s {
153 const char *reviewTitle;
154 const char *reviewSubTitle;
155 const char *finishTitle;
156 const nbgl_warning_t *warning;
160 uint8_t securityReportLevel;
162} ReviewWithWarningContext_t;
164typedef struct ChoiceWithDetailsContext_s {
169} ChoiceWithDetailsContext_t;
173 SHARE_CTX_REVIEW_WITH_WARNING,
174 SHARE_CTX_CHOICE_WITH_DETAILS,
175} SharedContextUsage_t;
182 KeypadContext_t keypad;
185 KeyboardContext_t keyboard;
187 ReviewWithWarningContext_t reviewWithWarning;
188 ChoiceWithDetailsContext_t choiceWithDetails;
190 SharedContextUsage_t usage;
194 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;
216 uint8_t currentNbPairs;
217 uint8_t currentStartIndex;
226 SharedContext_t sharedCtx;
237} nbgl_homeAndSettingsContext_t;
242} nbgl_reviewContext_t;
250} nbgl_reviewStreamingContext_t;
253 nbgl_homeAndSettingsContext_t homeAndSettings;
254 nbgl_reviewContext_t review;
255 nbgl_reviewStreamingContext_t reviewStreaming;
256} nbgl_BundleNavContext_t;
262} SecurityReportItem_t;
269static char tmpString[W3C_DESCRIPTION_MAX_LEN];
286static const char *pageTitle;
289#define activeTipBox genericContext.tipBox
293static NavType_t navType;
295static DetailsContext_t detailsContext;
298static AddressConfirmationContext_t addressConfirmationContext;
301static GenericContext_t genericContext;
303 localContentsList[3];
304static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
307static nbgl_BundleNavContext_t bundleNavContext;
310static const uint8_t nbMaxElementsPerContentType[] = {
327 .icon = &WARNING_ICON,
328 .text =
"Blind signing required",
329 .subText =
"This transaction's details are not fully verifiable. If "
330 "you sign, you could lose all your assets."
333 .icon = &WARNING_ICON,
334 .text =
"Transaction Check unavailable",
338 .icon = &WARNING_ICON,
339 .text =
"Risk detected",
340 .subText =
"This transaction was scanned as risky by Web3 Checks."
343 .icon = &WARNING_ICON,
344 .text =
"Critical threat",
345 .subText =
"This transaction was scanned as malicious by Web3 Checks."
349 .text =
"No threat detected",
350 .subText =
"Transaction Check didn't find any threat, but always "
351 "review transaction details carefully."
364static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
370static void displayReviewPage(uint8_t page,
bool forceFullRefresh);
371static void displayDetailsPage(uint8_t page,
bool forceFullRefresh);
372static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh);
373static void displayFullValuePage(
const char *backText,
374 const char *aliasText,
376static void displayInfosListModal(
const char *modalTitle,
380static void displaySettingsPage(uint8_t page,
bool forceFullRefresh);
381static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh);
382static void pageCallback(
int token, uint8_t index);
384static uint8_t getNbInfosInPage(uint8_t nbInfos,
388static uint8_t getNbSwitchesInPage(uint8_t nbSwitches,
392static uint8_t getNbBarsInPage(uint8_t nbBars,
397static void displayAddressQRCode(
void);
401static uint8_t getNbTagValuesInDetailsPage(uint8_t nbPairs,
405static void modalLayoutTouchCallback(
int token, uint8_t index);
406static void displaySkipWarning(
void);
409static void bundleNavStartIdle(
void);
411static void bundleNavStartHome(
void);
412static void bundleNavStartSettings(
void);
414static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
416static void bundleNavReviewStreamingChoice(
bool confirm);
418static void displaySecurityReport(uint32_t set);
420static void displayInitialWarning(
void);
424 const char *reviewTitle,
425 const char *reviewSubTitle,
426 const char *finishTitle,
430 bool playNotifSound);
433 const char *reviewTitle,
434 const char *reviewSubTitle,
436 bool playNotifSound);
437static void useCaseHomeExt(
const char *appName,
444static void displayDetails(
const char *tag,
const char *value,
bool wrapping);
446static void reset_callbacks_and_context(
void)
453 onContentAction = NULL;
455 memset(&genericContext, 0,
sizeof(genericContext));
459static void genericContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements,
bool flag)
461 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements) + SET_PAGE_FLAG(flag);
463 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
464 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
465 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
466 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
470static void genericContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements,
bool *flag)
472 uint8_t pageData = genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
473 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
474 if (nbElements != NULL) {
475 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
478 *flag = GET_PAGE_FLAG(pageData);
485 switch (content->
type) {
512 if (tagValueList->
pairs != NULL) {
513 return PIC(&tagValueList->
pairs[index]);
519 memset(&emptyPair, 0,
sizeof(emptyPair));
521 emptyPair.
value =
"";
533 tagValueList.
callback = genericContext.currentCallback;
544 tagValueList.
callback = genericContext.currentTagValues->callback;
555 uint8_t *nbPairsInPage)
557 uint8_t startIdx = 0;
561 while (startIdx < tagValues->nbPairs) {
563 = getNbTagValuesInDetailsPage(tagValues->
nbPairs - startIdx, tagValues, startIdx);
564 if (page == pageIdx) {
565 *nbPairsInPage = nbPairs;
593 return (infoList != NULL) && (infoList->
nbInfos > 0);
597 return (aliasList != NULL) && (aliasList->
nbPairs > 0)
598 && checkTagValueList(aliasList,
false);
610 if (tagValueList->
nbPairs == 0) {
613 if (tagValueList->
pairs == NULL) {
614 if ((tagValueList->
callback == NULL)
615 || (((uint16_t) tagValueList->
startIndex + tagValueList->
nbPairs) > (UINT8_MAX + 1))) {
619 else if (!checkAliases) {
622 for (uint8_t i = 0; i < tagValueList->
nbPairs; i++) {
625 if (tagValueList->
pairs != NULL) {
626 pair = PIC(&tagValueList->
pairs[i]);
631 if ((pair == NULL) || (checkAliases && !isAliasDetailsValid(pair))) {
645 return (tagValueList == NULL) || checkTagValueList(tagValueList,
true);
651static bool isAddressReviewable(
const char *address)
653 if (address == NULL) {
658 return (nbChunks > 0) && (nbChunks <= ADDR_VERIF_NB_PAIRS);
667 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
692 for (
int i = 0; i < genericContents->
nbContents; i++) {
693 p_content = getContentAtIdx(genericContents, i, &content);
694 if (p_content == NULL) {
706 if ((tagValueList->
nbPairs == 0) || !isTagValueListValid(tagValueList)) {
713static void prepareNavInfo(
bool isReview, uint8_t nbPages,
const char *rejectText)
715 memset(&navInfo, 0,
sizeof(navInfo));
718 navInfo.
tuneId = TUNE_TAP_CASUAL;
722 if (isReview ==
false) {
731 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false : true;
738 const char *reviewTitle,
739 const char *reviewSubTitle)
741 contentCenter->
icon = icon;
742 contentCenter->
title = reviewTitle;
744 contentCenter->
subText =
"Swipe to review";
747 contentCenter->
padding =
false;
753 if (finishTitle != NULL) {
758 return "Sign transaction";
760 return "Sign message";
762 return "Sign operation";
769 const char *finishTitle)
771 infoLongPress->
text = getFinishTitle(operationType, finishTitle);
772 infoLongPress->
icon = icon;
780 const char *finishTitle)
782 infoButton->
text = getFinishTitle(operationType, finishTitle);
783 infoButton->
icon = icon;
803static void pageModalCallback(
int token, uint8_t index)
807 if (token == INFOS_TIP_BOX_TOKEN) {
809 displayFullValuePage(activeTipBox.infos.infoTypes[index],
810 activeTipBox.infos.infoContents[index],
811 &activeTipBox.infos.infoExtensions[index]);
814 else if (token == INFO_ALIAS_TOKEN) {
816 displayFullValuePage(genericContext.currentInfos->infoTypes[index],
817 genericContext.currentInfos->infoContents[index],
818 &genericContext.currentInfos->infoExtensions[index]);
822 modalPageContext = NULL;
823 if (token == NAV_TOKEN) {
830 displayDetailsPage(index,
false);
833 if (token == MODAL_NAV_TOKEN) {
840 displayTagValueListModalPage(index,
false);
843 else if (token == QUIT_TOKEN) {
848 else if (token == QUIT_TIPBOX_MODAL_TOKEN) {
850 if (reviewWithWarnCtx.securityReportLevel == 2) {
851 reviewWithWarnCtx.securityReportLevel = 1;
852 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
860 else if (token == SKIP_TOKEN) {
871 else if (token == CHOICE_TOKEN) {
873 if (onModalConfirm != NULL) {
875 onModalConfirm = NULL;
887static void pageCallback(
int token, uint8_t index)
890 if (token == QUIT_TOKEN) {
891 if (onQuit != NULL) {
895 else if (token == CONTINUE_TOKEN) {
896 if (onContinue != NULL) {
900 else if (token == CHOICE_TOKEN) {
901 if (onChoice != NULL) {
902 onChoice((index == 0) ?
true :
false);
905 else if (token == ACTION_BUTTON_TOKEN) {
906 if ((index == 0) && (onAction != NULL)) {
909 else if ((index == 1) && (onQuit != NULL)) {
914 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
915 displayAddressQRCode();
918 else if (token == CONFIRM_TOKEN) {
919 if (onChoice != NULL) {
923 else if (token == REJECT_TOKEN) {
924 if (onChoice != NULL) {
928 else if (token == DETAILS_BUTTON_TOKEN) {
929 displayDetails(genericContext.detailsItem,
930 genericContext.detailsvalue,
931 genericContext.detailsWrapping);
933 else if (token == NAV_TOKEN) {
935 if (onQuit != NULL) {
940 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
941 displayGenericContextPage(index,
false);
943 else if (navType == REVIEW_NAV) {
944 displayReviewPage(index,
false);
947 displaySettingsPage(index,
false);
951 else if (token == NEXT_TOKEN) {
953 displayReviewPage(navInfo.
activePage + 1,
false);
956 displayGenericContextPage(navInfo.
activePage + 1,
false);
959 else if (token == BACK_TOKEN) {
961 displayReviewPage(navInfo.
activePage - 1,
true);
964 displayGenericContextPage(navInfo.
activePage - 1,
false);
967 else if (token == SKIP_TOKEN) {
969 displaySkipWarning();
971 else if (token == VALUE_ALIAS_TOKEN) {
976 uint16_t absoluteIdx = (uint16_t) genericContext.currentElementIdx + index;
977 if (absoluteIdx < genericContext.currentNbPairs) {
978 if (genericContext.currentPairs != NULL) {
979 pair = &genericContext.currentPairs[absoluteIdx];
981 else if (genericContext.currentCallback != NULL) {
983 genericContext.currentCallback(genericContext.currentStartIndex + absoluteIdx));
986 if ((pair != NULL) && (pair->
extension != NULL)) {
993 else if (token == INFO_ALIAS_TOKEN) {
997 uint16_t absoluteIdx = (uint16_t) genericContext.currentElementIdx + index;
998 if ((absoluteIdx < infos->nbInfos) && (infos->withExtensions)
999 && (infos->infoExtensions != NULL)) {
1001 displayFullValuePage(PIC(((
const char *
const *) PIC(infos->infoTypes))[absoluteIdx]),
1002 PIC(((
const char *
const *) PIC(infos->infoContents))[absoluteIdx]),
1009 else if (token == BLIND_WARNING_TOKEN) {
1010 reviewWithWarnCtx.isIntro =
false;
1011 reviewWithWarnCtx.warning = NULL;
1014 else if (token == WARNING_BUTTON_TOKEN) {
1016 reviewWithWarnCtx.securityReportLevel = 1;
1018 if (reviewWithWarnCtx.warning->predefinedSet) {
1019 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1023 if (reviewWithWarnCtx.isIntro) {
1024 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->introDetails);
1027 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->reviewDetails);
1031 else if (token == TIP_BOX_TOKEN) {
1033 if (genericContext.validWarningCtx && (reviewWithWarnCtx.warning->predefinedSet != 0)) {
1034 reviewWithWarnCtx.securityReportLevel = 1;
1035 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1038 displayInfosListModal(activeTipBox.modalTitle, &activeTipBox.infos,
false);
1042 if (onContentAction != NULL) {
1043 onContentAction(token, index, navInfo.
activePage);
1045 if (onControls != NULL) {
1046 onControls(token, index);
1052static void tickerCallback(
void)
1055 if (onQuit != NULL) {
1061static void displaySettingsPage(uint8_t page,
bool forceFullRefresh)
1065 if (onNav == NULL) {
1069 if (onNav(page, &content) ==
false) {
1074 content.
title = pageTitle;
1077 content.
tuneId = TUNE_TAP_CASUAL;
1082 if (forceFullRefresh) {
1091static void displayReviewPage(uint8_t page,
bool forceFullRefresh)
1100 if (onNav == NULL) {
1104 if (onNav(navInfo.
activePage, &content) ==
false) {
1109 content.
title = NULL;
1111 content.
tuneId = TUNE_TAP_CASUAL;
1139 if (forceFullRefresh) {
1149static const nbgl_content_t *genericContextComputeNextPageParams(uint8_t pageIdx,
1151 uint8_t *p_nbElementsInNextPage,
1154 int8_t nextContentIdx = genericContext.currentContentIdx;
1155 int16_t nextElementIdx = genericContext.currentElementIdx;
1156 uint8_t nbElementsInNextPage;
1159 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
1160 *p_nbElementsInNextPage = nbElementsInNextPage;
1165 uint8_t nbElementsInCurrentPage;
1167 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
1168 nextElementIdx += nbElementsInCurrentPage;
1173 if ((nextElementIdx >= genericContext.currentContentElementNb)
1174 && (genericContext.currentContentElementNb > 0)) {
1175 nextContentIdx += 1;
1184 nextElementIdx -= nbElementsInNextPage;
1190 if (nextElementIdx < 0) {
1191 nextContentIdx -= 1;
1192 nextElementIdx = -nbElementsInNextPage;
1198 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
1199 p_content = &STARTING_CONTENT;
1201 else if ((nextContentIdx == genericContext.genericContents.nbContents)
1202 && (genericContext.hasFinishingContent)) {
1203 p_content = &FINISHING_CONTENT;
1206 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
1208 if (p_content == NULL) {
1223 if ((nextContentIdx != genericContext.currentContentIdx)
1224 || (genericContext.currentContentElementNb == 0)) {
1225 genericContext.currentContentIdx = nextContentIdx;
1226 genericContext.currentContentElementNb = getContentNbElement(p_content);
1228 if (nextElementIdx < 0) {
1229 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
1234 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
1236 "Invalid element index %d / %d\n",
1238 genericContext.currentContentElementNb);
1243 genericContext.currentElementIdx = nextElementIdx;
1251static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
1252 uint8_t nbElementsInPage,
1256 uint8_t nextElementIdx = genericContext.currentElementIdx;
1258 pageContent->
title = pageTitle;
1261 pageContent->
tuneId = TUNE_TAP_CASUAL;
1263 pageContent->
type = p_content->
type;
1264 switch (pageContent->
type) {
1312 p_tagValueList = NULL;
1324 genericContext.detailsItem = pair->
item;
1325 genericContext.detailsvalue = pair->
value;
1330 if (p_tagValueList != NULL) {
1331 p_tagValueList->
nbPairs = nbElementsInPage;
1334 p_tagValueList->
pairs
1337 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1339 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1345 p_tagValueList->
pairs = NULL;
1346 p_tagValueList->
callback = getCurrentPageTagValuePair;
1350 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1354 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1371 if ((nextElementIdx + nbElementsInPage)
1387 p_tagValueList->
nbPairs = nbElementsInPage;
1389 p_tagValueList->
pairs
1392 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1394 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1400 p_tagValueList->
pairs = NULL;
1401 p_tagValueList->
callback = getCurrentPageTagValuePair;
1405 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1409 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1416 genericContext.currentPairs
1418 genericContext.currentCallback
1421 genericContext.currentStartIndex
1458 < nextElementIdx + nbElementsInPage)) {
1478 bool isFirstOrLastPage
1482 = (navType == STREAMING_NAV)
1483 ? bundleNavContext.reviewStreaming.operationType
1484 : ((navType == GENERIC_NAV) ? bundleNavContext.review.operationType : 0);
1487 if (isFirstOrLastPage
1499 = (operationType &
BLIND_OPERATION) ? BLIND_WARNING_TOKEN : WARNING_BUTTON_TOKEN;
1503 else if (isFirstOrLastPage && ((navType == STREAMING_NAV) || (navType == GENERIC_NAV))
1504 && (sharedContext.usage == SHARE_CTX_REVIEW_WITH_WARNING)
1505 && (reviewWithWarnCtx.warning != NULL)
1506 && (reviewWithWarnCtx.warning->predefinedSet == 0)
1507 && (reviewWithWarnCtx.warning->reviewDetails != NULL)) {
1508 pageContent->topRightIcon = (reviewWithWarnCtx.warning->reviewTopRightIcon != NULL)
1509 ? reviewWithWarnCtx.warning->reviewTopRightIcon
1511 pageContent->topRightToken = WARNING_BUTTON_TOKEN;
1518static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh)
1522 uint8_t nbElementsInPage;
1526 if (navType == STREAMING_NAV) {
1528 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1529 bundleNavContext.reviewStreaming.skipCallback();
1533 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1534 bundleNavReviewStreamingChoice(
true);
1541 pageIdx = navInfo.
nbPages - 1;
1547 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1552 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1553 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1563 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1566 if (p_content == NULL) {
1570 if ((navType != STREAMING_NAV)
1573 if ((pageIdx > 0) && (pageIdx < (navInfo.
nbPages - 1))) {
1585 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1591 if (forceFullRefresh) {
1604static uint16_t getDetailsPageLen(
const char *text,
bool *ellipsis)
1608 if (ellipsis != NULL) {
1620 detailsContext.wrapping);
1622 if (text[len] ==
'\n') {
1625 else if (!detailsContext.wrapping) {
1627 if (ellipsis != NULL) {
1635static const char *getDetailsPageAt(uint8_t detailsPage)
1638 const char *currentChar = detailsContext.value;
1639 while (page < detailsPage) {
1640 currentChar = currentChar + getDetailsPageLen(currentChar, NULL);
1647static void displayDetailsPage(uint8_t detailsPage,
bool forceFullRefresh)
1651 .nbPages = detailsContext.nbPages,
1653 .quitToken = QUIT_TOKEN,
1654 .navWithButtons.navToken = NAV_TOKEN,
1655 .navWithButtons.quitButton =
true,
1656 .navWithButtons.backButton =
true,
1657 .navWithButtons.quitText = NULL,
1658 .progressIndicator =
false,
1659 .tuneId = TUNE_TAP_CASUAL};
1661 .topRightIcon = NULL,
1662 .tagValueList.nbPairs = 1,
1663 .tagValueList.pairs = ¤tPair,
1664 .tagValueList.smallCaseForValue =
true,
1665 .tagValueList.wrapping = detailsContext.wrapping};
1667 if (modalPageContext != NULL) {
1670 currentPair.
item = detailsContext.tag;
1672 if (detailsPage <= detailsContext.currentPage) {
1674 currentPair.
value = getDetailsPageAt(detailsPage);
1675 forceFullRefresh =
true;
1679 currentPair.
value = detailsContext.nextPageStart;
1681 detailsContext.currentPage = detailsPage;
1683 uint16_t len = getDetailsPageLen(currentPair.
value, &ellipsis);
1688 detailsContext.nextPageStart = currentPair.
value + len;
1694 detailsContext.nextPageStart = NULL;
1703 if (forceFullRefresh) {
1712static void displayFullValuePage(
const char *backText,
1713 const char *aliasText,
1716 const char *modalTitle
1717 = (extension->
backText != NULL) ? PIC(extension->
backText) : PIC(backText);
1725 genericContext.currentInfos = extension->
infolist;
1726 displayInfosListModal(modalTitle, extension->
infolist,
true);
1729 genericContext.currentTagValues = extension->
tagValuelist;
1734 .withLeftBorder =
true,
1735 .onActionCallback = &modalLayoutTouchCallback,
1736 .tapActionText = NULL};
1738 .separationLine =
false,
1739 .backAndText.token = 0,
1740 .backAndText.tuneId = TUNE_TAP_CASUAL,
1741 .backAndText.text = modalTitle};
1750 .text1 = (extension->
title != NULL) ? extension->
title : extension->fullValue,
1751 .text2 = extension->explanation,
1760 content.
title = aliasText;
1762 content.
info =
"ENS names are resolved by Ledger backend.";
1790static void displayInfosListModal(
const char *modalTitle,
1797 .quitToken = QUIT_TIPBOX_MODAL_TOKEN,
1798 .navWithButtons.navToken = NAV_TOKEN,
1799 .navWithButtons.quitButton =
false,
1800 .navWithButtons.backButton =
true,
1801 .navWithButtons.quitText = NULL,
1802 .progressIndicator =
false,
1803 .tuneId = TUNE_TAP_CASUAL};
1806 .topRightIcon = NULL,
1807 .infosList.nbInfos = infos->
nbInfos,
1809 .infosList.infoTypes = infos->
infoTypes,
1812 .infosList.token = fromReview ? INFO_ALIAS_TOKEN : INFOS_TIP_BOX_TOKEN,
1813 .
title = modalTitle,
1814 .titleToken = QUIT_TIPBOX_MODAL_TOKEN,
1815 .tuneId = TUNE_TAP_CASUAL};
1817 if (modalPageContext != NULL) {
1826static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh)
1829 .nbPages = detailsContext.nbPages,
1831 .quitToken = QUIT_TOKEN,
1832 .navWithButtons.navToken = MODAL_NAV_TOKEN,
1833 .navWithButtons.quitButton =
true,
1834 .navWithButtons.backButton =
true,
1835 .navWithButtons.quitText = NULL,
1836 .progressIndicator =
false,
1837 .tuneId = TUNE_TAP_CASUAL};
1839 .topRightIcon = NULL,
1840 .tagValueList.smallCaseForValue =
true,
1841 .tagValueList.wrapping = detailsContext.wrapping};
1842 uint8_t nbElementsInPage;
1843 uint8_t firstPairIdx;
1846 = getTagValueListModalPage(genericContext.currentTagValues, pageIdx, &nbElementsInPage);
1847 detailsContext.currentPage = pageIdx;
1850 if (genericContext.currentTagValues->pairs != NULL) {
1851 content.
tagValueList.
pairs = &genericContext.currentTagValues->pairs[firstPairIdx];
1857 = genericContext.currentTagValues->startIndex + firstPairIdx;
1859 if (nbElementsInPage == 1) {
1863 getTagValuePair(genericContext.currentTagValues, firstPairIdx));
1871 if (modalPageContext != NULL) {
1876 if (forceFullRefresh) {
1885static void displayAddressQRCode(
void)
1889 .withLeftBorder =
true,
1890 .onActionCallback = &modalLayoutTouchCallback,
1891 .tapActionText = NULL};
1893 .type =
HEADER_EMPTY, .separationLine =
false, .emptySpace.height = SMALL_CENTERING_HEADER};
1899 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1904 addressConfirmationContext.tagValuePairs[0].value,
1908 if (nbLines <= QRCODE_NB_MAX_LINES) {
1909 qrCode.
text2 = addressConfirmationContext.tagValuePairs[0].value;
1914 addressConfirmationContext.tagValuePairs[0].value,
1916 QRCODE_NB_MAX_LINES,
1918 QRCODE_REDUCED_ADDR_LEN);
1919 qrCode.
text2 = reducedAddress;
1925 addressConfirmationContext.modalLayout,
"Close", DISMISS_QR_TOKEN, TUNE_TAP_CASUAL);
1933static void modalLayoutTouchCallback(
int token, uint8_t index)
1936 if (token == DISMISS_QR_TOKEN) {
1939 addressConfirmationContext.modalLayout = NULL;
1942 else if (token == DISMISS_WARNING_TOKEN) {
1946 if (reviewWithWarnCtx.securityReportLevel <= 1) {
1947 reviewWithWarnCtx.modalLayout = NULL;
1952 reviewWithWarnCtx.securityReportLevel = 1;
1954 if (reviewWithWarnCtx.warning->predefinedSet) {
1955 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1960 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1961 : reviewWithWarnCtx.warning->reviewDetails;
1962 displayCustomizedSecurityReport(details);
1967 else if (token == DISMISS_DETAILS_TOKEN) {
1971 if (choiceWithDetailsCtx.level <= 1) {
1972 choiceWithDetailsCtx.modalLayout = NULL;
1977 choiceWithDetailsCtx.level = 1;
1978 choiceWithDetailsCtx.modalLayout
1979 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
1982 else if ((token >= FIRST_WARN_BAR_TOKEN) && (token <= LAST_WARN_BAR_TOKEN)) {
1983 if (sharedContext.usage == SHARE_CTX_REVIEW_WITH_WARNING) {
1986 reviewWithWarnCtx.securityReportLevel = 2;
1988 if (reviewWithWarnCtx.warning->predefinedSet) {
1989 displaySecurityReport(1 << (token - FIRST_WARN_BAR_TOKEN));
1994 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1995 : reviewWithWarnCtx.warning->reviewDetails;
1997 displayCustomizedSecurityReport(
2002 else if ((sharedContext.usage == SHARE_CTX_CHOICE_WITH_DETAILS)
2003 && (choiceWithDetailsCtx.details->barList.details != NULL)) {
2005 = &choiceWithDetailsCtx.details->barList.details[token - FIRST_WARN_BAR_TOKEN];
2009 choiceWithDetailsCtx.level = 2;
2010 choiceWithDetailsCtx.modalLayout
2011 = displayModalDetails(details, DISMISS_DETAILS_TOKEN);
2019 genericContext.modalLayout = NULL;
2026static void layoutTouchCallback(
int token, uint8_t index)
2029 if (token == WARNING_CHOICE_TOKEN) {
2031 reviewWithWarnCtx.choiceCallback(
false);
2034 reviewWithWarnCtx.isIntro =
false;
2035 if (reviewWithWarnCtx.isStreaming) {
2036 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
2037 reviewWithWarnCtx.icon,
2038 reviewWithWarnCtx.reviewTitle,
2039 reviewWithWarnCtx.reviewSubTitle,
2040 reviewWithWarnCtx.choiceCallback,
2044 useCaseReview(reviewWithWarnCtx.operationType,
2045 reviewWithWarnCtx.tagValueList,
2046 reviewWithWarnCtx.icon,
2047 reviewWithWarnCtx.reviewTitle,
2048 reviewWithWarnCtx.reviewSubTitle,
2049 reviewWithWarnCtx.finishTitle,
2051 reviewWithWarnCtx.choiceCallback,
2058 else if (token == WARNING_BUTTON_TOKEN) {
2060 reviewWithWarnCtx.securityReportLevel = 1;
2062 if (reviewWithWarnCtx.warning->predefinedSet) {
2063 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
2068 ? reviewWithWarnCtx.warning->introDetails
2069 : reviewWithWarnCtx.warning->reviewDetails;
2070 displayCustomizedSecurityReport(details);
2074 else if (token == CHOICE_DETAILS_TOKEN) {
2075 choiceWithDetailsCtx.level = 1;
2076 choiceWithDetailsCtx.modalLayout
2077 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
2080 else if (token == PRELUDE_CHOICE_TOKEN) {
2082 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->prelude->details);
2086 displayInitialWarning();
2089 reviewWithWarnCtx.isIntro =
false;
2090 if (reviewWithWarnCtx.isStreaming) {
2091 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
2092 reviewWithWarnCtx.icon,
2093 reviewWithWarnCtx.reviewTitle,
2094 reviewWithWarnCtx.reviewSubTitle,
2095 reviewWithWarnCtx.choiceCallback,
2099 useCaseReview(reviewWithWarnCtx.operationType,
2100 reviewWithWarnCtx.tagValueList,
2101 reviewWithWarnCtx.icon,
2102 reviewWithWarnCtx.reviewTitle,
2103 reviewWithWarnCtx.reviewSubTitle,
2104 reviewWithWarnCtx.finishTitle,
2106 reviewWithWarnCtx.choiceCallback,
2114 else if (token == CHOICE_TOKEN) {
2115 if (onChoice != NULL) {
2116 onChoice((index == 0) ?
true :
false);
2122static void displaySkipWarning(
void)
2125 .cancelText =
"Go back to review",
2126 .centeredInfo.text1 =
"Skip review?",
2128 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
2129 .centeredInfo.text3 = NULL,
2131 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
2132 .centeredInfo.offsetY = 0,
2133 .confirmationText =
"Yes, skip",
2134 .confirmationToken = SKIP_TOKEN,
2135 .cancelToken = SKIP_TOKEN,
2136 .tuneId = TUNE_TAP_CASUAL,
2138 if (modalPageContext != NULL) {
2150static void updateKeyPad(
bool add)
2152 bool enableValidate, enableBackspace, enableDigits;
2153 bool redrawKeypad =
false;
2156 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
2157 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
2158 enableBackspace = (keypadContext.pinLen > 0);
2160 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
2162 (keypadContext.pinLen == keypadContext.pinMaxDigits)
2164 (keypadContext.pinLen == 1)) {
2165 redrawKeypad =
true;
2169 if ((keypadContext.pinLen == 0) ||
2170 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
2172 (keypadContext.pinLen
2173 == (keypadContext.pinMaxDigits - 1))) {
2174 redrawKeypad =
true;
2177 if (keypadContext.hidden ==
true) {
2182 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
2186 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
2189 if ((!add) && (keypadContext.pinLen == 0)) {
2197static void keypadCallback(
char touchedKey)
2199 switch (touchedKey) {
2201 if (keypadContext.pinLen > 0) {
2202 keypadContext.pinLen--;
2203 keypadContext.pinEntry[keypadContext.pinLen] = 0;
2205 updateKeyPad(
false);
2214 keypadContext.onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
2218 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
2219 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
2220 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
2221 keypadContext.pinLen++;
2229static void keypadGeneric_cb(
int token, uint8_t index)
2232 if (token != BACK_TOKEN) {
2241static void keyboardCallback(
char touchedKey)
2244 size_t textLen = strlen(keyboardContext.entryBuffer);
2250 keyboardContext.entryBuffer[--textLen] =
'\0';
2253 if (textLen >= keyboardContext.entryMaxLen) {
2258 keyboardContext.entryBuffer[textLen] = touchedKey;
2259 keyboardContext.entryBuffer[++textLen] =
'\0';
2264 keyboardContext.getSuggestionButtons(&keyboardContext.keyboardContent, &mask);
2266 if (textLen >= keyboardContext.entryMaxLen) {
2272 keyboardContext.keyboardIndex,
2275 keyboardContext.casing);
2279static void keyboardGeneric_cb(
int token, uint8_t index)
2286 case KEYBOARD_CROSS_TOKEN:
2288 keyboardContext.entryBuffer[0] =
'a';
2289 keyboardContext.entryBuffer[1] =
'\0';
2292 case KEYBOARD_BUTTON_TOKEN:
2300 && (token >= keyboardContext.keyboardContent.suggestionButtons.firstButtonToken)
2301 && (token < (keyboardContext.keyboardContent.suggestionButtons.firstButtonToken
2302 + keyboardContext.keyboardContent.suggestionButtons.nbUsedButtons))) {
2303 onControls(token, index);
2322 uint8_t listMaxLines,
2336 if ((maxLines > 0) && (*nbLines > maxLines)) {
2337 *nbLines = maxLines;
2362static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
2366 bool hasConfirmationButton,
2367 bool hasDetailsButton,
2368 bool *requireSpecificDisplay)
2370 uint8_t nbPairsInPage = 0;
2371 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2377 maxUsableHeight -= TOUCHABLE_HEADER_BAR_HEIGHT - SMALL_CENTERING_HEADER;
2380 *requireSpecificDisplay =
false;
2381 while (nbPairsInPage < nbPairs) {
2388 if (nbPairsInPage > 0) {
2389 currentHeight += INTER_TAG_VALUE_MARGIN;
2392 pair = getTagValuePair(tagValueList, startIndex + nbPairsInPage);
2400 if (nbPairsInPage > 0) {
2407 *requireSpecificDisplay =
true;
2434 += getTagValueHeight(pair, value_font, listMaxLines, tagValueList->
wrapping, &nbLines);
2436 if (nbPairsInPage == 0) {
2440 *requireSpecificDisplay =
true;
2451 if (hasConfirmationButton && (nbPairsInPage == nbPairs)) {
2452 maxUsableHeight -= UP_FOOTER_BUTTON_HEIGHT;
2453 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2458 else if (hasDetailsButton) {
2459 maxUsableHeight -= (SMALL_BUTTON_RADIUS * 2);
2460 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2464 return nbPairsInPage;
2477static uint8_t getNbTagValuesInDetailsPage(uint8_t nbPairs,
2481 uint8_t nbPairsInPage = 0;
2482 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2485 while (nbPairsInPage < nbPairs) {
2491 if (nbPairsInPage > 0) {
2492 currentHeight += INTER_TAG_VALUE_MARGIN;
2495 pair = getTagValuePair(tagValueList, startIndex + nbPairsInPage);
2500 += getTagValueHeight(pair, SMALL_BOLD_FONT, 0, detailsContext.wrapping, &nbLines);
2503 if (currentHeight >= maxUsableHeight) {
2504 if (nbPairsInPage == 0) {
2516 if ((nbPairsInPage == 0) && (nbPairs > 0)) {
2519 return nbPairsInPage;
2535 = PRE_TAG_VALUE_MARGIN
2536 + getTagValueHeight(pair, SMALL_BOLD_FONT, 0, detailsContext.wrapping, &nbLines);
2542 height -= nbLines * lineHeight;
2550static uint8_t getNbPagesForContent(
const nbgl_content_t *content,
2551 uint8_t pageIdxStart,
2555 uint8_t nbElements = 0;
2556 uint8_t nbPages = 0;
2557 uint8_t nbElementsInPage;
2558 uint8_t elemIdx = 0;
2561 nbElements = getContentNbElement(content);
2571 while (nbElements > 0) {
2574 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
2576 nbElementsInPage = getNbTagValuesInPage(
2577 nbElements, &drawnList, elemIdx, isSkippable,
false,
false, &flag);
2580 nbElementsInPage = getNbTagValuesInPage(nbElements,
2590 = getNbInfosInPage(nbElements, &content->
content.
infosList, elemIdx, hasNav);
2598 = getNbBarsInPage(nbElements, &content->
content.
barsList, elemIdx, hasNav);
2605 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
2608 if (nbElementsInPage == 0) {
2610 "getNbPagesForContent(): element %d doesn't fit in a page\n",
2612 nbElementsInPage = 1;
2615 elemIdx += nbElementsInPage;
2616 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
2617 nbElements -= nbElementsInPage;
2625 uint8_t pageIdxStart,
2628 uint8_t nbPages = 0;
2632 for (
int i = 0; i < genericContents->
nbContents; i++) {
2633 p_content = getContentAtIdx(genericContents, i, &content);
2634 if (p_content == NULL) {
2637 nbPages += getNbPagesForContent(p_content,
2638 pageIdxStart + nbPages,
2646static void prepareAddressConfirmationPages(
const char *address,
2652 uint8_t nbAddressChunks;
2665 if (nbAddressChunks > ADDR_VERIF_NB_PAIRS) {
2666 nbAddressChunks = ADDR_VERIF_NB_PAIRS;
2669 const char *chunkStart = address;
2670 for (uint8_t i = 0; i < nbAddressChunks; i++) {
2671 addressConfirmationContext.tagValuePairs[i].item =
"Address";
2672 addressConfirmationContext.tagValuePairs[i].value = chunkStart;
2673 addressConfirmationContext.tagValuePairs[i].forcePageStart = (i > 0);
2674 if (i + 1 < nbAddressChunks) {
2686 addressConfirmationContext.nbPairs = nbAddressChunks;
2696 if ((tagValueList != NULL) && (nbAddressChunks == 1)
2697 && (tagValueList->
nbPairs < ADDR_VERIF_NB_PAIRS)) {
2701 for (uint8_t i = 0; i < tagValueList->
nbPairs; i++) {
2702 memcpy(&addressConfirmationContext.tagValuePairs[1 + i],
2703 &tagValueList->
pairs[i],
2705 addressConfirmationContext.nbPairs++;
2709 tmpList.
nbPairs = addressConfirmationContext.nbPairs;
2710 tmpList.
pairs = addressConfirmationContext.tagValuePairs;
2713 addressConfirmationContext.nbPairs = getNbTagValuesInPage(
2714 addressConfirmationContext.nbPairs, &tmpList, 0,
false,
true,
true, &flag);
2716 if (tmpList.
nbPairs > addressConfirmationContext.nbPairs) {
2717 addressConfirmationContext.nbPairs = 1;
2728 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2740 uint8_t extrasPlaced
2741 = (tagValueList != NULL) ? (addressConfirmationContext.nbPairs - nbAddressChunks) : 0;
2742 bool extrasNeedSecondPage = (tagValueList != NULL) && (tagValueList->
nbPairs > extrasPlaced);
2744 if (extrasNeedSecondPage) {
2754 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2767static void bundleNavStartHome(
void)
2769 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2771 useCaseHomeExt(context->appName,
2774 context->settingContents != NULL ?
true :
false,
2775 &context->homeAction,
2776 bundleNavStartSettings,
2777 context->quitCallback);
2778 genericContext.type = USE_CASE_IDLE;
2781static void bundleNavStartSettings(
void)
2783 bundleNavStartSettingsAtPage(0);
2787static void bundleNavStartIdle(
void)
2791 reset_callbacks_and_context();
2792 genericContext.type = USE_CASE_IDLE;
2794 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
2800static void bundleNavStartSettingsAtPage(uint8_t initSettingPage)
2802 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2806 context->settingContents,
2809 bundleNavStartIdle);
2811 bundleNavStartHome);
2815static void bundleNavReviewConfirmRejection(
void)
2817 bundleNavContext.review.choiceCallback(
false);
2824 const char *confirmText;
2829 title =
"Reject transaction?";
2830 confirmText =
"Go back to transaction";
2833 title =
"Reject message?";
2834 confirmText =
"Go back to message";
2837 title =
"Reject operation?";
2838 confirmText =
"Go back to operation";
2845static void bundleNavReviewChoice(
bool confirm)
2848 bundleNavContext.review.choiceCallback(
true);
2851 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
2852 bundleNavReviewConfirmRejection);
2856static void bundleNavReviewStreamingConfirmRejection(
void)
2858 bundleNavContext.reviewStreaming.choiceCallback(
false);
2861static void bundleNavReviewStreamingChoice(
bool confirm)
2864 bundleNavContext.reviewStreaming.choiceCallback(
true);
2867 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
2868 bundleNavReviewStreamingConfirmRejection);
2878 .withLeftBorder =
true,
2879 .onActionCallback = modalLayoutTouchCallback,
2880 .tapActionText = NULL};
2882 .separationLine =
true,
2883 .backAndText.icon = NULL,
2884 .backAndText.tuneId = TUNE_TAP_CASUAL,
2885 .backAndText.token = token};
2910 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2911 bar.
tuneId = TUNE_TAP_CASUAL;
2939static void displaySecurityReport(uint32_t set)
2942 .withLeftBorder =
true,
2943 .onActionCallback = modalLayoutTouchCallback,
2944 .tapActionText = NULL};
2946 .separationLine =
true,
2947 .backAndText.icon = NULL,
2948 .backAndText.tuneId = TUNE_TAP_CASUAL,
2949 .backAndText.token = DISMISS_WARNING_TOKEN};
2951 = {.type =
FOOTER_EMPTY, .separationLine =
false, .emptySpace.height = 0};
2953 const char *provider;
2955 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2961 if ((reviewWithWarnCtx.securityReportLevel == 1) && (!reviewWithWarnCtx.isIntro)) {
2965 && (reviewWithWarnCtx.warning->predefinedSet & (1 << i))) {
2968 || (reviewWithWarnCtx.warning->providerMessage == NULL)) {
2969 bar.
subText = securityReportItems[i].subText;
2972 bar.
subText = reviewWithWarnCtx.warning->providerMessage;
2974 bar.
text = securityReportItems[i].text;
2977 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2978 bar.
tuneId = TUNE_TAP_CASUAL;
2983 bar.
iconLeft = securityReportItems[i].icon;
2994 if (reviewWithWarnCtx.warning && reviewWithWarnCtx.warning->reportProvider) {
2995 provider = reviewWithWarnCtx.warning->reportProvider;
2998 provider =
"[unknown]";
3003 const size_t destSize = W3C_DESCRIPTION_MAX_LEN / 2;
3004 char *destStr = tmpString + destSize;
3006 size_t destLen = destSize;
3009 const char *reportUrl = reviewWithWarnCtx.warning->reportUrl;
3012 len = (reportUrl != NULL) ? snprintf(destStr, destLen,
"https://%s", reportUrl) : -1;
3013 if ((len >= 0) && ((
size_t) len < destLen)) {
3016 .text2 =
"Scan to view full report",
3025 else if (reportUrl != NULL) {
3035 len = (destLen > 0) ? snprintf(destStr, destLen,
"%s report", provider) : -1;
3036 if ((len >= 0) && ((
size_t) len < destLen)) {
3046 info.
icon = &LARGE_WARNING_ICON;
3047 info.
title =
"This transaction cannot be Clear Signed";
3049 =
"This transaction or message cannot be decoded fully. If you choose to sign, you "
3050 "could be authorizing malicious actions that can drain your wallet.\n\nLearn more: "
3059 info.
icon = &LARGE_WARNING_ICON;
3060 info.
title =
"Transaction Check unavailable";
3062 =
"If you're not using the Ledger Wallet app, Transaction Check might not work. If "
3064 "are using Ledger Wallet, reject the transaction and try again.\n\nGet help at "
3083 reviewWithWarnCtx.modalLayout = displayModalDetails(details, DISMISS_WARNING_TOKEN);
3087static void displayInitialWarning(
void)
3090#ifdef HAVE_PIEZO_SOUND
3091 tune_index_e tune = TUNE_RESERVED;
3096 .token = WARNING_CHOICE_TOKEN,
3097 .topText =
"Back to safety",
3099 .tuneId = TUNE_TAP_CASUAL};
3101 .emptySpace.height = MEDIUM_CENTERING_HEADER};
3105 bool isBlindSigningOnly
3107 reviewWithWarnCtx.isIntro =
true;
3111 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
3114 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
3117 isBlindSigningOnly ? &INFO_I_ICON : &QRCODE_ICON,
3118 WARNING_BUTTON_TOKEN,
3121 else if (reviewWithWarnCtx.warning->introTopRightIcon != NULL) {
3123 reviewWithWarnCtx.warning->introTopRightIcon,
3124 WARNING_BUTTON_TOKEN,
3129 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
3132 const char *provider;
3135 info.
icon = &LARGE_WARNING_ICON;
3138 if (isBlindSigningOnly ==
false) {
3139 if (reviewWithWarnCtx.warning->reportProvider) {
3140 provider = reviewWithWarnCtx.warning->reportProvider;
3143 provider =
"[unknown]";
3146 snprintf(tmpString, W3C_DESCRIPTION_MAX_LEN,
"Detected by %s", provider);
3150 if (isBlindSigningOnly) {
3151 info.
title =
"Blind signing ahead";
3154 =
"If you sign this transaction, you could lose your assets. "
3155 "Explore safer alternatives: ledger.com/integrated-apps";
3156 buttonsInfo.
bottomText =
"Accept risk and continue";
3160 =
"This transaction's details are not fully verifiable. If you sign, you could "
3161 "lose all your assets.";
3164#ifdef HAVE_PIEZO_SOUND
3165 tune = TUNE_NEUTRAL;
3169 info.
title =
"Critical threat";
3170 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
3174 info.
description = reviewWithWarnCtx.warning->providerMessage;
3176 buttonsInfo.
bottomText =
"Accept threat and continue";
3177#ifdef HAVE_PIEZO_SOUND
3182 info.
title =
"Potential risk";
3183 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
3187 info.
description = reviewWithWarnCtx.warning->providerMessage;
3189 buttonsInfo.
bottomText =
"Accept risk and continue";
3190#ifdef HAVE_PIEZO_SOUND
3191 tune = TUNE_NEUTRAL;
3196 else if (reviewWithWarnCtx.warning->info != NULL) {
3199#ifdef HAVE_PIEZO_SOUND
3200 tune = TUNE_LOOK_AT_ME;
3206#ifdef HAVE_PIEZO_SOUND
3207 if (tune != TUNE_RESERVED) {
3208 os_io_seph_cmd_piezo_play_tune(tune);
3216static void displayPrelude(
void)
3221 = {.bottomText = reviewWithWarnCtx.warning->prelude->footerText,
3222 .token = PRELUDE_CHOICE_TOKEN,
3223 .topText = reviewWithWarnCtx.warning->prelude->buttonText,
3225 .tuneId = TUNE_TAP_CASUAL};
3227 .emptySpace.height = MEDIUM_CENTERING_HEADER};
3230 reviewWithWarnCtx.isIntro =
true;
3234 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
3241 info.
icon = reviewWithWarnCtx.warning->prelude->icon;
3243 info.
title = reviewWithWarnCtx.warning->prelude->title;
3244 info.
description = reviewWithWarnCtx.warning->prelude->description;
3250#ifdef HAVE_PIEZO_SOUND
3251 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3260 const char *predefinedTipBoxText = NULL;
3263 if (reviewWithWarnCtx.warning) {
3264 if (reviewWithWarnCtx.warning->predefinedSet & (1 <<
W3C_ISSUE_WARN)) {
3266 predefinedTipBoxText =
"Transaction Check unavailable.\nBlind signing required.";
3269 predefinedTipBoxText =
"Transaction Check unavailable";
3274 predefinedTipBoxText =
"Critical threat detected.\nBlind signing required.";
3277 predefinedTipBoxText =
"Critical threat detected.";
3282 predefinedTipBoxText =
"Potential risk detected.\nBlind signing required.";
3285 predefinedTipBoxText =
"Potential risk detected.";
3290 predefinedTipBoxText
3291 =
"No threat detected by Transaction Check but blind signing required.";
3294 predefinedTipBoxText =
"No threat detected by Transaction Check.";
3298 predefinedTipBoxText =
"Blind signing required.";
3302 if ((tipBox != NULL) || (predefinedTipBoxText != NULL)) {
3304 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
3305 if (predefinedTipBoxText != NULL) {
3306 genericContext.validWarningCtx =
true;
3307 STARTING_CONTENT.content.extendedCenter.tipBox.icon = NULL;
3308 STARTING_CONTENT.content.extendedCenter.tipBox.text = predefinedTipBoxText;
3311 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
3312 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
3314 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
3315 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
3323 const char *reviewTitle,
3324 const char *reviewSubTitle,
3325 const char *finishTitle,
3329 bool playNotifSound)
3332 if ((tagValueList == NULL) || (tagValueList->
nbPairs == 0)
3333 || !isTagValueListValid(tagValueList)) {
3334 if (choiceCallback != NULL) {
3335 choiceCallback(
false);
3339 bundleNavContext.review.operationType = operationType;
3340 bundleNavContext.review.choiceCallback = choiceCallback;
3343 onChoice = bundleNavReviewChoice;
3344 navType = GENERIC_NAV;
3347 genericContext.genericContents.contentsList = localContentsList;
3348 genericContext.genericContents.nbContents = 3;
3353 prepareReviewFirstPage(
3354 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3357 initWarningTipBox(tipBox);
3361 memcpy(&localContentsList[1].content.tagValueList,
3369 prepareReviewLightLastPage(
3370 operationType, &localContentsList[2].content.infoButton, icon, finishTitle);
3374 prepareReviewLastPage(
3375 operationType, &localContentsList[2].content.infoLongPress, icon, finishTitle);
3379 uint8_t nbPages = getNbPagesForGenericContents(
3381 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
3384 if (playNotifSound) {
3385#ifdef HAVE_PIEZO_SOUND
3386 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3390 displayGenericContextPage(0,
true);
3396 const char *reviewTitle,
3397 const char *reviewSubTitle,
3399 bool playNotifSound)
3401 bundleNavContext.reviewStreaming.operationType = operationType;
3402 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3403 bundleNavContext.reviewStreaming.icon = icon;
3406 onChoice = bundleNavReviewStreamingChoice;
3407 navType = STREAMING_NAV;
3410 genericContext.genericContents.contentsList = localContentsList;
3411 genericContext.genericContents.nbContents = 1;
3416 prepareReviewFirstPage(
3417 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3420 initWarningTipBox(NULL);
3423 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3430 if (playNotifSound) {
3431#ifdef HAVE_PIEZO_SOUND
3432 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3436 displayGenericContextPage(0,
true);
3455static void useCaseHomeExt(
const char *appName,
3457 const char *tagline,
3464 .centeredInfo.text1 = appName,
3465 .centeredInfo.text3 = NULL,
3467 .centeredInfo.offsetY = 0,
3470 .tapActionText = NULL,
3472 .topRightToken = CONTINUE_TOKEN,
3473 .tuneId = TUNE_TAP_CASUAL};
3474 reset_callbacks_and_context();
3476 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
3491 if (tagline == NULL) {
3495 "This app enables signing\ntransactions on its network.");
3522 onContinue = topRightCallback;
3523 onQuit = quitCallback;
3537static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
3539 memset(&detailsContext, 0,
sizeof(detailsContext));
3542 detailsContext.tag = tag;
3543 detailsContext.value = value;
3544 detailsContext.currentPage = 0;
3545 detailsContext.wrapping = wrapping;
3547 detailsContext.nbPages = 1;
3549 while (((len = getDetailsPageLen(value, NULL)) > 0) && (detailsContext.nbPages < UINT8_MAX)) {
3551 detailsContext.nbPages++;
3554 displayDetailsPage(0,
true);
3560 uint8_t nbElements = 0;
3561 uint8_t nbElementsInPage;
3562 uint8_t elemIdx = 0;
3566 if ((tagValues == NULL) || (tagValues->
nbPairs == 0)) {
3572 memset(&detailsContext, 0,
sizeof(detailsContext));
3573 nbElements = tagValues->
nbPairs;
3578 while (nbElements > 0) {
3579 nbElementsInPage = getNbTagValuesInDetailsPage(nbElements, tagValues, elemIdx);
3581 elemIdx += nbElementsInPage;
3582 nbElements -= nbElementsInPage;
3583 detailsContext.nbPages++;
3586 displayTagValueListModalPage(0,
true);
3593 return (warning == NULL)
3596 && (warning->
prelude == NULL));
3609 memcpy(&normalizedWarning, warning,
sizeof(normalizedWarning));
3611 return &normalizedWarning;
3634 bool *requireSpecificDisplay)
3636 return getNbTagValuesInPage(
3637 nbPairs, tagValueList, startIndex,
false,
false,
false, requireSpecificDisplay);
3649static uint8_t getNbInfosInPage(uint8_t nbInfos,
3654 uint8_t nbInfosInPage = 0;
3655 uint16_t currentHeight = 0;
3656 uint16_t previousHeight = 0;
3657 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3658 const char *
const *infoContents = PIC(infosList->
infoContents);
3660 while (nbInfosInPage < nbInfos) {
3663 += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING + LIST_ITEM_HEADING_SUB_TEXT;
3667 PIC(infoContents[startIndex + nbInfosInPage]),
3674 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3679 previousHeight = currentHeight;
3684 if ((nbInfosInPage == 0) && (nbInfos > 0)) {
3687 return nbInfosInPage;
3699static uint8_t getNbSwitchesInPage(uint8_t nbSwitches,
3704 uint8_t nbSwitchesInPage = 0;
3705 uint16_t currentHeight = 0;
3706 uint16_t previousHeight = 0;
3707 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3710 while (nbSwitchesInPage < nbSwitches) {
3714 uint16_t textHeight =
MAX(
3715 LIST_ITEM_MIN_TEXT_HEIGHT,
3717 currentHeight += textHeight + 2 * LIST_ITEM_PRE_HEADING;
3720 currentHeight += LIST_ITEM_HEADING_SUB_TEXT;
3730 previousHeight = currentHeight;
3735 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3740 if ((nbSwitchesInPage == 0) && (nbSwitches > 0)) {
3741 nbSwitchesInPage = 1;
3743 return nbSwitchesInPage;
3755static uint8_t getNbBarsInPage(uint8_t nbBars,
3760 uint8_t nbBarsInPage = 0;
3761 uint16_t currentHeight = 0;
3762 uint16_t previousHeight = 0;
3763 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3768 while (nbBarsInPage < nbBars) {
3769 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3774 previousHeight = currentHeight;
3779 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3782 return nbBarsInPage;
3803 uint8_t nbChoicesInPage = 0;
3804 uint16_t currentHeight = 0;
3805 uint16_t previousHeight = 0;
3806 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3808 UNUSED(choicesList);
3811 while (nbChoicesInPage < nbChoices) {
3812 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3817 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3822 previousHeight = currentHeight;
3825 return nbChoicesInPage;
3834 const char *tagline,
3841 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
3864 reset_callbacks_and_context();
3867 onQuit = quitCallback;
3868 onNav = navCallback;
3869 onControls = controlsCallback;
3871 navType = SETTINGS_NAV;
3874 prepareNavInfo(
false, nbPages, NULL);
3876 displaySettingsPage(initPage,
true);
3894 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
3915 reset_callbacks_and_context();
3918 onQuit = quitCallback;
3919 pageTitle = appName;
3920 navType = GENERIC_NAV;
3922 if (settingContents != NULL) {
3925 if (infosList != NULL) {
3926 genericContext.hasFinishingContent =
true;
3929 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
3933 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3934 if (infosList != NULL) {
3935 nbPages += getNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
3938 prepareNavInfo(
false, nbPages, NULL);
3940 displayGenericContextPage(initPage,
true);
3984 const char *appName,
3986 const char *tagline,
3994 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
3996 reset_callbacks_and_context();
3998 context->appName = appName;
3999 context->appIcon = appIcon;
4000 context->tagline = tagline;
4001 context->settingContents = settingContents;
4002 context->infosList = infosList;
4003 if (action != NULL) {
4009 context->quitCallback = quitCallback;
4012 bundleNavStartSettingsAtPage(initSettingPage);
4017 bundleNavStartIdle();
4019 bundleNavStartHome();
4036 if ((genericContext.type != USE_CASE_IDLE) || (modalPageContext != NULL)
4037 || (bundleNavContext.homeAndSettings.appName == NULL)
4038 || ((bundleNavContext.homeAndSettings.settingContents == NULL)
4039 && (bundleNavContext.homeAndSettings.infosList == NULL))) {
4042 bundleNavStartSettingsAtPage(initPage);
4056 .tickerIntervale = 0,
4060 reset_callbacks_and_context();
4062 onQuit = quitCallback;
4064#ifdef HAVE_PIEZO_SOUND
4065 os_io_seph_cmd_piezo_play_tune(TUNE_LEDGER_MOMENT);
4068 info.
centeredInfo.
icon = isSuccess ? &CHECK_CIRCLE_ICON : &DENIED_CIRCLE_ICON;
4073 info.
tuneId = TUNE_TAP_CASUAL;
4089 switch (reviewStatusType) {
4091 msg =
"Operation signed";
4095 msg =
"Operation rejected";
4099 msg =
"Transaction signed";
4103 msg =
"Transaction rejected";
4107 msg =
"Message signed";
4111 msg =
"Message rejected";
4115 msg =
"Address verified";
4119 msg =
"Address verification\ncancelled";
4141 const char *message,
4142 const char *subMessage,
4143 const char *confirmText,
4144 const char *cancelText,
4149 if ((confirmText == NULL) || (cancelText == NULL)) {
4153 reset_callbacks_and_context();
4163 info.
tuneId = TUNE_TAP_CASUAL;
4165 onChoice = callback;
4185 const char *message,
4186 const char *subMessage,
4187 const char *confirmText,
4188 const char *cancelText,
4193 (details != NULL) ? &SEARCH_ICON : NULL,
4228 const char *message,
4229 const char *subMessage,
4230 const char *confirmText,
4231 const char *cancelText,
4238 .token = CHOICE_TOKEN,
4239 .topText = confirmText,
4241 .tuneId = TUNE_TAP_CASUAL};
4244 .emptySpace.height = MEDIUM_CENTERING_HEADER};
4247 if ((confirmText == NULL) || (cancelText == NULL)) {
4249 "nbgl_useCaseAdvancedChoiceWithDetails(): confirmText or cancelText is NULL\n");
4253 reset_callbacks_and_context();
4255#ifdef HAVE_PIEZO_SOUND
4256 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4259 onChoice = callback;
4262 sharedContext.usage = SHARE_CTX_CHOICE_WITH_DETAILS;
4263 choiceWithDetailsCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
4264 choiceWithDetailsCtx.details = details;
4268 centeredInfo.
icon = centerIcon;
4269 centeredInfo.
title = title;
4271 centeredInfo.
subText = subMessage;
4274 if ((details != NULL) && (headerIcon != NULL)) {
4276 choiceWithDetailsCtx.layoutCtx, headerIcon, CHOICE_DETAILS_TOKEN, TUNE_TAP_CASUAL);
4297 const char *subMessage,
4298 const char *confirmText,
4299 const char *cancelText,
4305 .centeredInfo.text1 = message,
4306 .centeredInfo.text2 = subMessage,
4307 .centeredInfo.text3 = NULL,
4309 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
4310 .centeredInfo.offsetY = 0,
4311 .confirmationText = confirmText,
4312 .confirmationToken = CHOICE_TOKEN,
4313 .cancelToken = CHOICE_TOKEN,
4314 .tuneId = TUNE_TAP_CASUAL,
4316 onModalConfirm = callback;
4317 if (modalPageContext != NULL) {
4335 const char *message,
4336 const char *actionText,
4341 reset_callbacks_and_context();
4343 onAction = callback;
4345 content.
tuneId = TUNE_TAP_CASUAL;
4368 const char *reviewTitle,
4369 const char *reviewSubTitle,
4370 const char *rejectText,
4375 .footerToken = QUIT_TOKEN,
4376 .tapActionText = NULL,
4377 .isSwipeable =
true,
4378 .tapActionToken = CONTINUE_TOKEN,
4380 .actionButtonText = NULL,
4381 .tuneId = TUNE_TAP_CASUAL};
4383 reset_callbacks_and_context();
4391 onQuit = rejectCallback;
4392 onContinue = continueCallback;
4394#ifdef HAVE_PIEZO_SOUND
4396 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4417 const char *rejectText,
4422 if (!isTagValueListValid(tagValueList)) {
4423 if (callback != NULL) {
4428 reset_callbacks_and_context();
4431 onChoice = callback;
4432 navType = GENERIC_NAV;
4436 genericContext.genericContents.contentsList = localContentsList;
4439 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
4441 memcpy(&localContentsList[offset].content.tagValueList,
4448 memcpy(&localContentsList[offset].content.infoLongPress,
4454 genericContext.genericContents.nbContents = offset;
4457 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4459 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4461 displayGenericContextPage(0,
true);
4479 const char *rejectText,
4484 if (!isTagValueListValid(tagValueList)) {
4485 if (callback != NULL) {
4490 reset_callbacks_and_context();
4493 onChoice = callback;
4494 navType = GENERIC_NAV;
4497 genericContext.genericContents.contentsList = localContentsList;
4500 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
4502 memcpy(&localContentsList[offset].content.tagValueList,
4516 genericContext.genericContents.nbContents = offset;
4519 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4521 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4523 displayGenericContextPage(0,
true);
4545 const char *reviewTitle,
4546 const char *reviewSubTitle,
4547 const char *finishTitle,
4550 reset_callbacks_and_context();
4552 useCaseReview(operationType,
4586 const char *reviewTitle,
4587 const char *reviewSubTitle,
4588 const char *finishTitle,
4599 &blindSigningWarning,
4628 const char *reviewTitle,
4629 const char *reviewSubTitle,
4630 const char *finishTitle,
4635 reset_callbacks_and_context();
4638 if (tipBox != NULL) {
4639 memcpy(&activeTipBox, tipBox,
sizeof(activeTipBox));
4642 if (isWarningEmpty(warning)) {
4643 useCaseReview(operationType,
4661 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4662 reviewWithWarnCtx.isStreaming =
false;
4663 reviewWithWarnCtx.operationType = operationType;
4664 reviewWithWarnCtx.tagValueList = tagValueList;
4665 reviewWithWarnCtx.icon = icon;
4666 reviewWithWarnCtx.reviewTitle = reviewTitle;
4667 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4668 reviewWithWarnCtx.finishTitle = finishTitle;
4669 reviewWithWarnCtx.warning = normalizeWarning(warning);
4670 reviewWithWarnCtx.choiceCallback = choiceCallback;
4673 if (reviewWithWarnCtx.warning->prelude) {
4678 displayInitialWarning();
4681 useCaseReview(operationType,
4713 const char *reviewTitle,
4714 const char *reviewSubTitle,
4715 const char *finishTitle,
4718 reset_callbacks_and_context();
4720 useCaseReview(operationType,
4741 const char *rejectText,
4744 if (!isGenericContentsValid(contents)) {
4745 if (rejectCallback != NULL) {
4750 reset_callbacks_and_context();
4753 onQuit = rejectCallback;
4754 navType = GENERIC_NAV;
4761 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4762 prepareNavInfo(
true, nbPages, rejectText);
4765#ifdef HAVE_PIEZO_SOUND
4767 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4770 displayGenericContextPage(0,
true);
4787 const char *reviewTitle,
4788 const char *reviewSubTitle,
4791 reset_callbacks_and_context();
4793 useCaseReviewStreamingStart(
4794 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4812 const char *reviewTitle,
4813 const char *reviewSubTitle,
4817 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
4837 const char *reviewTitle,
4838 const char *reviewSubTitle,
4842 reset_callbacks_and_context();
4845 if (isWarningEmpty(warning)) {
4846 useCaseReviewStreamingStart(
4847 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4857 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4858 reviewWithWarnCtx.isStreaming =
true;
4859 reviewWithWarnCtx.operationType = operationType;
4860 reviewWithWarnCtx.icon = icon;
4861 reviewWithWarnCtx.reviewTitle = reviewTitle;
4862 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4863 reviewWithWarnCtx.choiceCallback = choiceCallback;
4864 reviewWithWarnCtx.warning = normalizeWarning(warning);
4867 if (reviewWithWarnCtx.warning->prelude) {
4872 displayInitialWarning();
4875 useCaseReviewStreamingStart(
4876 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4897 if ((tagValueList == NULL) || !isTagValueListValid(tagValueList)) {
4898 if (choiceCallback != NULL) {
4899 choiceCallback(
false);
4905 memset(&genericContext, 0, offsetof(GenericContext_t, sharedCtx));
4907 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4908 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
4911 onChoice = bundleNavReviewStreamingChoice;
4912 navType = STREAMING_NAV;
4915 genericContext.genericContents.contentsList = localContentsList;
4916 genericContext.genericContents.nbContents = 1;
4925 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4926 &genericContext.genericContents,
4929 prepareNavInfo(
true,
4931 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4939 displayGenericContextPage(0,
true);
4971 memset(&genericContext, 0, offsetof(GenericContext_t, sharedCtx));
4973 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4976 onChoice = bundleNavReviewStreamingChoice;
4977 navType = STREAMING_NAV;
4980 genericContext.genericContents.contentsList = localContentsList;
4981 genericContext.genericContents.nbContents = 1;
4986 prepareReviewLastPage(bundleNavContext.reviewStreaming.operationType,
4987 &STARTING_CONTENT.content.infoLongPress,
4988 bundleNavContext.reviewStreaming.icon,
4992 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4993 &genericContext.genericContents,
4996 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4998 displayGenericContextPage(0,
true);
5009 if (!isAddressReviewable(address) || !isTagValueListValid(tagValueList)) {
5010 if (callback != NULL) {
5015 reset_callbacks_and_context();
5016 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
5019 onChoice = callback;
5020 navType = GENERIC_NAV;
5023 genericContext.genericContents.contentsList = localContentsList;
5024 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
5026 prepareAddressConfirmationPages(
5027 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
5030 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
5032 prepareNavInfo(
true, nbPages,
"Cancel");
5034#ifdef HAVE_PIEZO_SOUND
5036 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
5039 displayGenericContextPage(0,
true);
5061 const char *reviewTitle,
5062 const char *reviewSubTitle,
5065 if (!isAddressReviewable(address) || !isTagValueListValid(additionalTagValueList)) {
5066 if (choiceCallback != NULL) {
5067 choiceCallback(
false);
5071 reset_callbacks_and_context();
5074 if (addressConfirmationContext.modalLayout) {
5077 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
5080 onChoice = choiceCallback;
5081 navType = GENERIC_NAV;
5085 genericContext.genericContents.contentsList = localContentsList;
5090 prepareReviewFirstPage(
5091 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
5092 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
5095 prepareAddressConfirmationPages(
5096 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
5099 genericContext.genericContents.nbContents
5101 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
5103 prepareNavInfo(
true, nbPages,
"Cancel");
5105#ifdef HAVE_PIEZO_SOUND
5107 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
5110 displayGenericContextPage(0,
true);
5124 if (genericContext.type != USE_CASE_SPINNER) {
5125 memset(&genericContext, 0,
sizeof(genericContext));
5126 genericContext.type = USE_CASE_SPINNER;
5131 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
5134 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
5141 genericContext.spinnerPosition++;
5144 genericContext.spinnerPosition = 0;
5147 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
5151 else if (ret == 2) {
5186 .separationLine =
true,
5187 .backAndText.token = BACK_TOKEN,
5188 .backAndText.tuneId = TUNE_TAP_CASUAL};
5193 "nbgl_useCaseKeypad(): digits out of range (%d/%d > %d)\n",
5200 reset_callbacks_and_context();
5202 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
5205 onQuit = backCallback;
5210 keypadContext.hidden = hidden;
5219 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
5224 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
5227 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
5232 keypadContext.onValidatePin = validatePinCallback;
5234 keypadContext.pinMinDigits = minDigits;
5235 keypadContext.pinMaxDigits = maxDigits;
5276 .backAndText.token = BACK_TOKEN,
5277 .backAndText.tuneId = TUNE_TAP_CASUAL};
5280 .mode = params->
mode,
5281 .casing = params->
casing};
5291 reset_callbacks_and_context();
5293 memset(&keyboardContext, 0,
sizeof(KeyboardContext_t));
5296 onQuit = backCallback;
5308 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
5311 keyboardContext.keyboardIndex = status;
5312 keyboardContext.casing = params->
casing;
5313 keyboardContext.entryBuffer = PIC(params->
entryBuffer);
5314 keyboardContext.entryMaxLen = params->
entryMaxLen;
5315 keyboardContext.entryBuffer[0] =
'\0';
5318 .type = params->
type,
5319 .title = PIC(params->
title),
5321 .number = params->
number,
5323 .text = keyboardContext.entryBuffer,
5324 .textToken = KEYBOARD_CROSS_TOKEN,
5325 .tuneId = TUNE_TAP_CASUAL,
5327 switch (params->
type) {
5332 .token = KEYBOARD_BUTTON_TOKEN,
5338 keyboardContext.getSuggestionButtons
5349 &keyboardContext.keyboardContent);
5352 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
struct nbgl_pageSwitchesList_s nbgl_contentSwitchesList_t
This structure contains data to build a SWITCHES_LIST content.
nbgl_contentTagValue_t *(* nbgl_contentTagValueCallback_t)(uint8_t pairIndex)
prototype of tag/value pair retrieval callback
@ ICON_ILLUSTRATION
simple icon
@ LARGE_CASE_INFO
text in BLACK and large case (INTER 32px), subText in black in Inter24px
struct nbgl_contentTagValueList_s nbgl_contentTagValueList_t
This structure contains a list of [tag,value] pairs.
@ 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
struct nbgl_contentInfoList_s nbgl_contentInfoList_t
This structure contains data to build a INFOS_LIST content.
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
struct nbgl_pageContent_s nbgl_pageContent_t
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent).
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)
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t keyMask, bool updateCasing, keyboardCase_t casing)
Updates an existing keyboard on bottom of the screen, with the given configuration.
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_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace, bool enableDigits)
Updates an existing keypad on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Adds an area containing a potential title, a text entry and either confirmation or suggestion buttons...
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout)
adds a separation line on bottom of the last added item
int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info)
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under...
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
int nbgl_layoutAddTouchableBar(nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout)
Creates a touchable bar in main panel.
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
@ BLACK_BACKGROUND
rounded bordered button, with text/icon in white, on black background
int nbgl_layoutAddTopRightButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId)
Creates a Top-right button in the top right corner of the top panel.
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, nbgl_layoutTextContent_t *content)
Creates in the main container three text areas:
void * nbgl_layout_t
type shared externally
@ HEADER_EMPTY
empty space, to have a better vertical centering of centered info
@ HEADER_BACK_AND_TEXT
back key and optional text
int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Updates an area containing a potential title, a text entry and either confirmation or suggestion butt...
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, const char *title, 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...
#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
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
int nbgl_layoutAddLeftContent(nbgl_layout_t *layout, const nbgl_layoutLeftContent_t *info)
Creates an area with a title, and rows of icon + text, left aligned.
@ ROUNDED_AND_FOOTER_STYLE
A black background button on top of a footer.
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
int nbgl_layoutUpdateSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t position)
Update an existing spinner (must be the only object of the layout).
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
struct nbgl_layoutDescription_s nbgl_layoutDescription_t
Structure containing all information when creating a layout. This structure must be passed as argumen...
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
#define TAG_VALUE_INTERVALE
@ FOOTER_EMPTY
empty space, to have a better vertical centering of centered info
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet().
int nbgl_layoutAddFooter(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the...
int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
nbgl_contentTagValue_t nbgl_layoutTagValue_t
Deprecated, kept for retro compatibility.
Internal functions/constants of NBGL layout layer.
static nbgl_font_id_e layoutGetTagValueFont(bool smallCaseForValue)
returns the font used to display the values of a list of tag/value pairs
static uint8_t layoutGetTagValueMaxLines(uint8_t listMaxLines, const nbgl_contentTagValue_t *pair, bool *forceEllipsis)
returns the max number of lines of the value of the given tag/value pair, which is the smallest non-z...
static uint16_t layoutGetTagValueWidth(const nbgl_icon_details_t *icon)
returns the width of the value of a tag/value pair. Shared by the layout and the use cases,...
static const nbgl_icon_details_t * layoutGetTagValueIcon(const nbgl_contentTagValue_t *pair)
returns the icon displayed on the right of the value of the given tag/value pair
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
#define NB_SPINNER_POSITIONS
#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)
keyboardCase_t
Letters casing in which to open/set the keyboard.
struct nbgl_pageInfoDescription_s nbgl_pageInfoDescription_t
Structure containing all specific information when creating an information page.
nbgl_page_t * nbgl_pageDrawGenericContent(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
nbgl_page_t * nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const nbgl_pageInfoDescription_t *info)
draw a page with a centered info (icon and/or texts) with a touchable footer, in a potential "tapable...
void * nbgl_page_t
type shared externally
@ NAV_WITH_BUTTONS
move forward and backward with buttons in bottom nav bar
struct nbgl_pageMultiScreensDescription_s nbgl_pageNavigationInfo_t
Structure containing all specific information when creating a multi-screens page.
nbgl_page_t * nbgl_pageDrawConfirmation(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageConfirmationDescription_t *info)
draw a confirmation page, with a centered info (icon and/or text), a button to confirm and a footer t...
struct nbgl_pageConfirmationDescription_s nbgl_pageConfirmationDescription_t
Structure containing all specific information when creating a confirmation page.
int nbgl_pageRelease(nbgl_page_t *)
Release the page obtained with any of the nbgl_pageDrawXXX() functions.
nbgl_page_t * nbgl_pageDrawGenericContentExt(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content, bool modal)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
@ 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.
nbgl_contentInfoLongPress_t nbgl_pageInfoLongPress_t
Deprecated, kept for retro compatibility.
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.
DEPRECATED void nbgl_useCaseHome(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
#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).
@ LEFT_CONTENT_WARNING
left-aligned title and icon/text rows (touch devices only)
@ CENTERED_INFO_WARNING
Centered info.
@ BAR_LIST_WARNING
list of touchable bars, to display sub-pages
DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle, uint8_t initPage, uint8_t nbPages, bool touchableTitle, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
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 to add a Skip bu...
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)
struct nbgl_genericDetails_s nbgl_genericDetails_t
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
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)
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)
nbgl_genericDetails_t nbgl_warningDetails_t
void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
#define RISKY_OPERATION
This is to use in nbgl_operationType_t when the operation is concerned by an internal warning....
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
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
void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *rejectText, nbgl_callback_t continueCallback, nbgl_callback_t rejectCallback)
bool nbgl_useCaseShowInfoAndSettings(uint8_t initPage)
#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).
DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, nbgl_choiceCallback_t callback, const nbgl_contentTagValueList_t *tagValueList)
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_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
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 "AddressBook" to adapt wordin...
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)
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
int16_t offsetY
vertical shift to apply to this info (if >0, shift to bottom)
const char * text3
third text (can be null)
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
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
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
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
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
const char * value
string giving the value name
const char * item
string giving the tag name
uint8_t centeredInfo
if set to 1, the tag will be displayed as a centered info
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
const char * title
text of the page (used to go back)
nbgl_genericBarList_t barList
touchable bars list, if type == BAR_LIST_WARNING
nbgl_layoutQRCode_t qrCode
QR code, if type == QRCODE_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
nbgl_layoutLeftContent_t leftContent
left content, if type == LEFT_CONTENT_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
nbgl_layoutKeyboardContentType_t type
type of content
bool numbered
if set to true, the text is preceded on the left by 'number.'
keyboardCase_t casing
keyboard casing mode (lower, upper once or upper locked)
const char * title
centered title explaining the screen
bool obfuscated
if true, entered text and suggestions use the obfuscated font
char * entryBuffer
already entered text
uint8_t number
if numbered is true, number used to build 'number.' text
This structure contains info to build a clickable "bar" with a text and an icon.
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
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
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard().
This structure contains info to build a keyboard content (controls that are linked to keyboard).
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
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)
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
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
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
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
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
const nbgl_contentCenter_t * info
parameters to build the intro warning page, if not using pre-defined
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