16#include "os_io_seph_ux.h"
19#include "os_helpers.h"
26#define PAGE_NB_ELEMENTS_BITS 3
27#define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
28#define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
30#define PAGE_FLAG_BITS 1
31#define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
32#define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
34#define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
35#define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
36#define SET_PAGE_DATA(pageIdx, pageData) \
37 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
38 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
40#define MAX_PAGE_NB 256
43#define STARTING_CONTENT localContentsList[0]
44#define FINISHING_CONTENT localContentsList[1]
47#define QRCODE_NB_MAX_LINES 3
49#define QRCODE_REDUCED_ADDR_LEN 128
52#define keypadContext sharedContext.keypad
53#define reviewWithWarnCtx sharedContext.reviewWithWarning
56#define W3C_DESCRIPTION_MAX_LEN 128
63#define RISKY_OPERATION (1 << 6)
70#define NO_THREAT_OPERATION (1 << 7)
82 ADDRESS_QRCODE_BUTTON_TOKEN,
94 QUIT_TIPBOX_MODAL_TOKEN,
97 DISMISS_WARNING_TOKEN,
109typedef struct DetailsContext_s {
115 const char *nextPageStart;
118typedef struct AddressConfirmationContext_s {
121} AddressConfirmationContext_t;
124typedef struct KeypadContext_s {
127 uint8_t pinMinDigits;
128 uint8_t pinMaxDigits;
134typedef struct ReviewWithWarningContext_s {
139 const char *reviewTitle;
140 const char *reviewSubTitle;
141 const char *finishTitle;
146 uint8_t securityReportLevel;
148} ReviewWithWarningContext_t;
154 KeypadContext_t keypad;
156 ReviewWithWarningContext_t reviewWithWarning;
160 USE_CASE_GENERIC = 0,
162} GenericContextType_t;
165 GenericContextType_t type;
166 uint8_t spinnerPosition;
168 int8_t currentContentIdx;
169 uint8_t currentContentElementNb;
170 uint8_t currentElementIdx;
171 bool hasStartingContent;
172 bool hasFinishingContent;
173 const char *detailsItem;
174 const char *detailsvalue;
175 bool detailsWrapping;
176 bool validWarningCtx;
194} nbgl_homeAndSettingsContext_t;
199} nbgl_reviewContext_t;
207} nbgl_reviewStreamingContext_t;
210 nbgl_homeAndSettingsContext_t homeAndSettings;
211 nbgl_reviewContext_t review;
212 nbgl_reviewStreamingContext_t reviewStreaming;
213} nbgl_BundleNavContext_t;
219} SecurityReportItem_t;
226static char tmpString[W3C_DESCRIPTION_MAX_LEN];
246static const char *pageTitle;
253static bool forwardNavOnly;
254static NavType_t navType;
256static DetailsContext_t detailsContext;
259static SharedContext_t sharedContext;
262static AddressConfirmationContext_t addressConfirmationContext;
265static GenericContext_t genericContext;
267 localContentsList[3];
268static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
271static nbgl_BundleNavContext_t bundleNavContext;
274static const uint8_t nbMaxElementsPerContentType[] = {
291 .icon = &WARNING_ICON,
292 .text =
"Blind signing required",
293 .subText =
"This transaction's details are not fully verifiable. If "
294 "you sign, you could lose all your assets."
297 .icon = &WARNING_ICON,
298 .text =
"Transaction Check unavailable",
302 .icon = &WARNING_ICON,
303 .text =
"Risk detected",
304 .subText =
"This transaction was scanned as risky by Web3 Checks."
307 .icon = &WARNING_ICON,
308 .text =
"Critical threat",
309 .subText =
"This transaction was scanned as malicious by Web3 Checks."
313 .text =
"No threat detected",
314 .subText =
"Transaction Check didn't find any threat, but always "
315 "review transaction details carefully."
325static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
331static void displayReviewPage(uint8_t page,
bool forceFullRefresh);
332static void displayDetailsPage(uint8_t page,
bool forceFullRefresh);
333static void displayFullValuePage(
const char *backText,
334 const char *aliasText,
336static void displayInfosListModal(
const char *modalTitle,
339static void displaySettingsPage(uint8_t page,
bool forceFullRefresh);
340static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh);
341static void pageCallback(
int token, uint8_t index);
343static void displayAddressQRCode(
void);
345static void modalLayoutTouchCallback(
int token, uint8_t index);
346static void displaySkipWarning(
void);
348static void bundleNavStartHome(
void);
349static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
350static void bundleNavStartSettings(
void);
352static void bundleNavReviewStreamingChoice(
bool confirm);
353static void displaySecurityReport(uint32_t set);
355static void displayInitialWarning(
void);
359 const char *reviewTitle,
360 const char *reviewSubTitle,
361 const char *finishTitle,
365 bool playNotifSound);
368 const char *reviewTitle,
369 const char *reviewSubTitle,
371 bool playNotifSound);
372static void useCaseHomeExt(
const char *appName,
379static void displayDetails(
const char *tag,
const char *value,
bool wrapping);
381static void reset_callbacks(
void)
388 onContentAction = NULL;
390 onModalConfirm = NULL;
392 onValidatePin = NULL;
397static void genericContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements,
bool flag)
399 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements) + SET_PAGE_FLAG(flag);
401 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
402 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
403 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
404 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
408static void genericContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements,
bool *flag)
410 uint8_t pageData = genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
411 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
412 if (nbElements != NULL) {
413 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
416 *flag = GET_PAGE_FLAG(pageData);
423 switch (content->
type) {
447 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
464static void prepareNavInfo(
bool isReview, uint8_t nbPages,
const char *rejectText)
466 memset(&navInfo, 0,
sizeof(navInfo));
469 navInfo.
tuneId = TUNE_TAP_CASUAL;
473 if (isReview ==
false) {
482 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false : true;
489 const char *reviewTitle,
490 const char *reviewSubTitle)
492 contentCenter->
icon = icon;
493 contentCenter->
title = reviewTitle;
495 contentCenter->
subText =
"Swipe to review";
498 contentCenter->
padding =
false;
504 if (finishTitle != NULL) {
509 return "Sign transaction";
511 return "Sign message";
513 return "Sign operation";
520 const char *finishTitle)
522 infoLongPress->
text = getFinishTitle(operationType, finishTitle);
523 infoLongPress->
icon = icon;
531 const char *finishTitle)
533 infoButton->
text = getFinishTitle(operationType, finishTitle);
534 infoButton->
icon = icon;
541 UNUSED(operationType);
547static void pageModalCallback(
int token, uint8_t index)
551 if (token == INFOS_TIP_BOX_TOKEN) {
558 else if (token == INFO_ALIAS_TOKEN) {
560 displayFullValuePage(genericContext.currentInfos->infoTypes[index],
561 genericContext.currentInfos->infoContents[index],
562 &genericContext.currentInfos->infoExtensions[index]);
566 modalPageContext = NULL;
567 if (token == NAV_TOKEN) {
574 displayDetailsPage(index,
false);
577 else if (token == QUIT_TOKEN) {
582 else if (token == QUIT_TIPBOX_MODAL_TOKEN) {
584 if (reviewWithWarnCtx.securityReportLevel == 2) {
585 reviewWithWarnCtx.securityReportLevel = 1;
586 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
594 else if (token == SKIP_TOKEN) {
605 else if (token == CHOICE_TOKEN) {
607 if (onModalConfirm != NULL) {
620static void pageCallback(
int token, uint8_t index)
623 if (token == QUIT_TOKEN) {
624 if (onQuit != NULL) {
628 else if (token == CONTINUE_TOKEN) {
629 if (onContinue != NULL) {
633 else if (token == CHOICE_TOKEN) {
634 if (onChoice != NULL) {
635 onChoice((index == 0) ?
true : false);
638 else if (token == ACTION_BUTTON_TOKEN) {
639 if ((index == 0) && (onAction != NULL)) {
642 else if ((index == 1) && (onQuit != NULL)) {
647 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
648 displayAddressQRCode();
651 else if (token == CONFIRM_TOKEN) {
652 if (onChoice != NULL) {
656 else if (token == REJECT_TOKEN) {
657 if (onChoice != NULL) {
661 else if (token == DETAILS_BUTTON_TOKEN) {
662 displayDetails(genericContext.detailsItem,
663 genericContext.detailsvalue,
664 genericContext.detailsWrapping);
666 else if (token == NAV_TOKEN) {
668 if (onQuit != NULL) {
673 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
674 displayGenericContextPage(index,
false);
676 else if (navType == REVIEW_NAV) {
677 displayReviewPage(index,
false);
680 displaySettingsPage(index,
false);
684 else if (token == NEXT_TOKEN) {
686 displayReviewPage(navInfo.
activePage + 1,
false);
689 displayGenericContextPage(navInfo.
activePage + 1,
false);
692 else if (token == BACK_TOKEN) {
694 displayReviewPage(navInfo.
activePage - 1,
true);
697 displayGenericContextPage(navInfo.
activePage - 1,
false);
700 else if (token == SKIP_TOKEN) {
702 displaySkipWarning();
704 else if (token == VALUE_ALIAS_TOKEN) {
707 if (genericContext.currentPairs != NULL) {
708 pair = &genericContext.currentPairs[genericContext.currentElementIdx + index];
711 pair = genericContext.currentCallback(genericContext.currentElementIdx + index);
715 else if (token == BLIND_WARNING_TOKEN) {
716 reviewWithWarnCtx.isIntro =
false;
717 reviewWithWarnCtx.warning = NULL;
720 else if (token == WARNING_BUTTON_TOKEN) {
722 reviewWithWarnCtx.securityReportLevel = 1;
724 if (reviewWithWarnCtx.warning->predefinedSet) {
725 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
729 if (reviewWithWarnCtx.isIntro) {
730 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->introDetails);
733 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->reviewDetails);
737 else if (token == TIP_BOX_TOKEN) {
739 if (genericContext.validWarningCtx && (reviewWithWarnCtx.warning->predefinedSet != 0)) {
740 reviewWithWarnCtx.securityReportLevel = 1;
741 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
744 displayInfosListModal(activeTipBox.
modalTitle, &activeTipBox.
infos,
false);
748 if (onContentAction != NULL) {
749 onContentAction(token, index, navInfo.
activePage);
751 if (onControls != NULL) {
752 onControls(token, index);
758static void tickerCallback(
void)
761 if (onQuit != NULL) {
767static void displaySettingsPage(uint8_t page,
bool forceFullRefresh)
771 if ((onNav == NULL) || (onNav(page, &content) ==
false)) {
776 content.
title = pageTitle;
779 content.
tuneId = TUNE_TAP_CASUAL;
784 if (forceFullRefresh) {
793static void displayReviewPage(uint8_t page,
bool forceFullRefresh)
802 if ((onNav == NULL) || (onNav(navInfo.
activePage, &content) ==
false)) {
807 content.
title = NULL;
809 content.
tuneId = TUNE_TAP_CASUAL;
816 if (forwardNavOnly) {
840 if (forceFullRefresh) {
850static const nbgl_content_t *genericContextComputeNextPageParams(uint8_t pageIdx,
852 uint8_t *p_nbElementsInNextPage,
855 int8_t nextContentIdx = genericContext.currentContentIdx;
856 int16_t nextElementIdx = genericContext.currentElementIdx;
857 uint8_t nbElementsInNextPage;
860 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
861 *p_nbElementsInNextPage = nbElementsInNextPage;
866 uint8_t nbElementsInCurrentPage;
868 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
869 nextElementIdx += nbElementsInCurrentPage;
874 if ((nextElementIdx >= genericContext.currentContentElementNb)
875 && (genericContext.currentContentElementNb > 0)) {
885 nextElementIdx -= nbElementsInNextPage;
891 if (nextElementIdx < 0) {
893 nextElementIdx = -nbElementsInNextPage;
899 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
900 p_content = &STARTING_CONTENT;
902 else if ((nextContentIdx == genericContext.genericContents.nbContents)
903 && (genericContext.hasFinishingContent)) {
904 p_content = &FINISHING_CONTENT;
907 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
909 if (p_content == NULL) {
924 if ((nextContentIdx != genericContext.currentContentIdx)
925 || (genericContext.currentContentElementNb == 0)) {
926 genericContext.currentContentIdx = nextContentIdx;
927 genericContext.currentContentElementNb = getContentNbElement(p_content);
929 if (nextElementIdx < 0) {
930 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
935 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
937 "Invalid element index %d / %d\n",
939 genericContext.currentContentElementNb);
944 genericContext.currentElementIdx = nextElementIdx;
952static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
953 uint8_t nbElementsInPage,
957 uint8_t nextElementIdx = genericContext.currentElementIdx;
959 pageContent->
title = pageTitle;
962 pageContent->
tuneId = TUNE_TAP_CASUAL;
964 pageContent->
type = p_content->
type;
965 switch (pageContent->
type) {
1017 p_tagValueList = NULL;
1029 genericContext.detailsItem = pair->
item;
1030 genericContext.detailsvalue = pair->
value;
1035 if (p_tagValueList != NULL) {
1036 p_tagValueList->
nbPairs = nbElementsInPage;
1039 p_tagValueList->
pairs
1042 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1044 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1050 p_tagValueList->
pairs = NULL;
1054 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1058 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1072 if ((nextElementIdx + nbElementsInPage)
1079 p_tagValueList->
nbPairs = nbElementsInPage;
1080 p_tagValueList->
pairs
1087 p_tagValueList->
nbPairs = nbElementsInPage;
1088 p_tagValueList->
pairs
1113 < nextElementIdx + nbElementsInPage)) {
1133 bool isFirstOrLastPage
1137 = (navType == STREAMING_NAV)
1138 ? bundleNavContext.reviewStreaming.operationType
1139 : ((navType == GENERIC_NAV) ? bundleNavContext.review.operationType : 0);
1142 if (isFirstOrLastPage
1143 && (operationType & (
BLIND_OPERATION | RISKY_OPERATION | NO_THREAT_OPERATION))) {
1145 if ((operationType & NO_THREAT_OPERATION)
1154 = (operationType &
BLIND_OPERATION) ? BLIND_WARNING_TOKEN : WARNING_BUTTON_TOKEN;
1161static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh)
1165 uint8_t nbElementsInPage;
1169 if (navType == STREAMING_NAV) {
1171 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1172 bundleNavContext.reviewStreaming.skipCallback();
1176 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1177 bundleNavReviewStreamingChoice(
true);
1184 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1189 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1190 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1200 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1203 if (p_content == NULL) {
1209 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1215 if (forceFullRefresh) {
1224static const char *getDetailsPageAt(uint8_t detailsPage)
1227 const char *currentChar = detailsContext.value;
1228 while (page < detailsPage) {
1238 detailsContext.wrapping);
1240 currentChar = currentChar + len;
1248static void displayDetailsPage(uint8_t detailsPage,
bool forceFullRefresh)
1252 .nbPages = detailsContext.nbPages,
1254 .quitToken = QUIT_TOKEN,
1255 .navWithButtons.navToken = NAV_TOKEN,
1256 .navWithButtons.quitButton =
true,
1257 .navWithButtons.backButton =
true,
1258 .navWithButtons.quitText = NULL,
1259 .progressIndicator =
false,
1260 .tuneId = TUNE_TAP_CASUAL};
1262 .topRightIcon = NULL,
1263 .tagValueList.nbPairs = 1,
1264 .tagValueList.pairs = ¤tPair,
1265 .tagValueList.smallCaseForValue =
true,
1266 .tagValueList.wrapping = detailsContext.wrapping};
1268 if (modalPageContext != NULL) {
1271 currentPair.
item = detailsContext.tag;
1273 if (detailsPage <= detailsContext.currentPage) {
1275 currentPair.
value = getDetailsPageAt(detailsPage);
1276 forceFullRefresh =
true;
1280 currentPair.
value = detailsContext.nextPageStart;
1282 detailsContext.currentPage = detailsPage;
1293 detailsContext.wrapping);
1296 detailsContext.nextPageStart = currentPair.
value + len;
1302 detailsContext.nextPageStart = NULL;
1311 if (forceFullRefresh) {
1320static void displayFullValuePage(
const char *backText,
1321 const char *aliasText,
1324 const char *modalTitle
1325 = (extension->
backText != NULL) ? PIC(extension->
backText) : PIC(backText);
1327 genericContext.currentInfos = extension->
infolist;
1328 displayInfosListModal(modalTitle, extension->
infolist,
true);
1332 .withLeftBorder =
true,
1333 .onActionCallback = &modalLayoutTouchCallback,
1334 .tapActionText = NULL};
1336 .separationLine =
false,
1337 .backAndText.token = 0,
1338 .backAndText.tuneId = TUNE_TAP_CASUAL,
1339 .backAndText.text = modalTitle};
1348 .text1 = (extension->
title != NULL) ? extension->
title : extension->fullValue,
1349 .text2 = extension->explanation,
1360 info =
"ENS names are resolved by Ledger backend.";
1363 info =
"This account label comes from your Address Book in Ledger Live.";
1369 genericContext.modalLayout, aliasText, extension->
fullValue, info);
1378static void displayInfosListModal(
const char *modalTitle,
1385 .quitToken = QUIT_TIPBOX_MODAL_TOKEN,
1386 .navWithButtons.navToken = NAV_TOKEN,
1387 .navWithButtons.quitButton =
false,
1388 .navWithButtons.backButton =
true,
1389 .navWithButtons.quitText = NULL,
1390 .progressIndicator =
false,
1391 .tuneId = TUNE_TAP_CASUAL};
1394 .topRightIcon = NULL,
1395 .infosList.nbInfos = infos->
nbInfos,
1397 .infosList.infoTypes = infos->
infoTypes,
1400 .infosList.token = fromReview ? INFO_ALIAS_TOKEN : INFOS_TIP_BOX_TOKEN,
1401 .
title = modalTitle,
1402 .titleToken = QUIT_TIPBOX_MODAL_TOKEN,
1403 .tuneId = TUNE_TAP_CASUAL};
1405 if (modalPageContext != NULL) {
1414static void displayAddressQRCode(
void)
1418 .withLeftBorder =
true,
1419 .onActionCallback = &modalLayoutTouchCallback,
1420 .tapActionText = NULL};
1422 .
type =
HEADER_EMPTY, .separationLine =
false, .emptySpace.height = SMALL_CENTERING_HEADER};
1428 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1433 SMALL_REGULAR_FONT, addressConfirmationContext.tagValuePair.value,
AVAILABLE_WIDTH,
false);
1435 if (nbLines <= QRCODE_NB_MAX_LINES) {
1436 qrCode.
text2 = addressConfirmationContext.tagValuePair.value;
1441 addressConfirmationContext.tagValuePair.value,
1443 QRCODE_NB_MAX_LINES,
1445 QRCODE_REDUCED_ADDR_LEN);
1446 qrCode.
text2 = reducedAddress;
1452 addressConfirmationContext.modalLayout,
"Close", DISMISS_QR_TOKEN, TUNE_TAP_CASUAL);
1460static void modalLayoutTouchCallback(
int token, uint8_t index)
1463 if (token == DISMISS_QR_TOKEN) {
1466 addressConfirmationContext.modalLayout = NULL;
1469 else if (token == DISMISS_WARNING_TOKEN) {
1473 if (reviewWithWarnCtx.securityReportLevel <= 1) {
1474 reviewWithWarnCtx.modalLayout = NULL;
1479 reviewWithWarnCtx.securityReportLevel = 1;
1481 if (reviewWithWarnCtx.warning->predefinedSet) {
1482 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1487 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1488 : reviewWithWarnCtx.warning->reviewDetails;
1489 displayCustomizedSecurityReport(details);
1494 else if ((token >= FIRST_WARN_BAR_TOKEN) && (token <= LAST_WARN_BAR_TOKEN)) {
1497 reviewWithWarnCtx.securityReportLevel = 2;
1499 if (reviewWithWarnCtx.warning->predefinedSet) {
1500 displaySecurityReport(1 << (token - FIRST_WARN_BAR_TOKEN));
1505 ? reviewWithWarnCtx.warning->introDetails
1506 : reviewWithWarnCtx.warning->reviewDetails;
1508 displayCustomizedSecurityReport(
1517 genericContext.modalLayout = NULL;
1524static void layoutTouchCallback(
int token, uint8_t index)
1527 if (token == WARNING_CHOICE_TOKEN) {
1529 reviewWithWarnCtx.choiceCallback(
false);
1532 reviewWithWarnCtx.isIntro =
false;
1533 if (reviewWithWarnCtx.isStreaming) {
1534 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1535 reviewWithWarnCtx.icon,
1536 reviewWithWarnCtx.reviewTitle,
1537 reviewWithWarnCtx.reviewSubTitle,
1538 reviewWithWarnCtx.choiceCallback,
1542 useCaseReview(reviewWithWarnCtx.operationType,
1543 reviewWithWarnCtx.tagValueList,
1544 reviewWithWarnCtx.icon,
1545 reviewWithWarnCtx.reviewTitle,
1546 reviewWithWarnCtx.reviewSubTitle,
1547 reviewWithWarnCtx.finishTitle,
1549 reviewWithWarnCtx.choiceCallback,
1556 else if (token == WARNING_BUTTON_TOKEN) {
1558 reviewWithWarnCtx.securityReportLevel = 1;
1560 if (reviewWithWarnCtx.warning->predefinedSet) {
1561 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1566 ? reviewWithWarnCtx.warning->introDetails
1567 : reviewWithWarnCtx.warning->reviewDetails;
1568 displayCustomizedSecurityReport(details);
1574static void displaySkipWarning(
void)
1577 .cancelText =
"Go back to review",
1578 .centeredInfo.text1 =
"Skip review?",
1580 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
1581 .centeredInfo.text3 = NULL,
1583 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
1584 .centeredInfo.offsetY = 0,
1585 .confirmationText =
"Yes, skip",
1586 .confirmationToken = SKIP_TOKEN,
1587 .
tuneId = TUNE_TAP_CASUAL,
1589 if (modalPageContext != NULL) {
1601static void updateKeyPad(
bool add)
1603 bool enableValidate, enableBackspace, enableDigits;
1604 bool redrawKeypad =
false;
1607 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
1608 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
1609 enableBackspace = (keypadContext.pinLen > 0);
1611 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
1613 (keypadContext.pinLen == keypadContext.pinMaxDigits)
1615 (keypadContext.pinLen == 1)) {
1616 redrawKeypad =
true;
1620 if ((keypadContext.pinLen == 0) ||
1621 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
1623 (keypadContext.pinLen
1624 == (keypadContext.pinMaxDigits - 1))) {
1625 redrawKeypad =
true;
1628 if (keypadContext.hidden ==
true) {
1633 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
1637 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
1640 if ((!add) && (keypadContext.pinLen == 0)) {
1648static void keypadCallback(
char touchedKey)
1650 switch (touchedKey) {
1652 if (keypadContext.pinLen > 0) {
1653 keypadContext.pinLen--;
1654 keypadContext.pinEntry[keypadContext.pinLen] = 0;
1656 updateKeyPad(
false);
1665 onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
1669 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1670 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
1671 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
1672 keypadContext.pinLen++;
1681static void keypadGenericUseCase(
const char *title,
1687 tune_index_e tuneId,
1693 .separationLine =
true,
1694 .backAndText.token = backToken,
1695 .backAndText.tuneId = tuneId,
1696 .backAndText.text = NULL};
1705 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
1709 layoutDescription.
modal =
false;
1712 keypadContext.hidden = hidden;
1724 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
1731 onValidatePin = validatePinCallback;
1733 keypadContext.pinMinDigits = minDigits;
1734 keypadContext.pinMaxDigits = maxDigits;
1755static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
1759 bool hasConfirmationButton,
1760 bool *requireSpecificDisplay)
1762 uint8_t nbPairsInPage = 0;
1763 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
1769 maxUsableHeight -= TOUCHABLE_HEADER_BAR_HEIGHT - SMALL_CENTERING_HEADER;
1772 *requireSpecificDisplay =
false;
1773 while (nbPairsInPage < nbPairs) {
1780 if (nbPairsInPage > 0) {
1781 currentHeight += INTER_TAG_VALUE_MARGIN;
1784 if (tagValueList->
pairs != NULL) {
1785 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
1788 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
1797 if (nbPairsInPage > 0) {
1804 *requireSpecificDisplay =
true;
1816 value_font = SMALL_REGULAR_FONT;
1819 value_font = LARGE_MEDIUM_FONT;
1828 if (nbPairsInPage == 0) {
1832 *requireSpecificDisplay =
true;
1841 if (hasConfirmationButton && (nbPairsInPage == nbPairs)) {
1842 maxUsableHeight -= UP_FOOTER_BUTTON_HEIGHT;
1843 if (currentHeight > maxUsableHeight) {
1847 return nbPairsInPage;
1850static uint8_t getNbPagesForContent(
const nbgl_content_t *content,
1851 uint8_t pageIdxStart,
1855 uint8_t nbElements = 0;
1856 uint8_t nbPages = 0;
1857 uint8_t nbElementsInPage;
1858 uint8_t elemIdx = 0;
1861 nbElements = getContentNbElement(content);
1863 while (nbElements > 0) {
1866 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
1868 nbElementsInPage = getNbTagValuesInPage(
1872 nbElementsInPage = getNbTagValuesInPage(nbElements,
1896 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
1899 elemIdx += nbElementsInPage;
1900 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
1901 nbElements -= nbElementsInPage;
1909 uint8_t pageIdxStart,
1912 uint8_t nbPages = 0;
1916 for (
int i = 0; i < genericContents->
nbContents; i++) {
1917 p_content = getContentAtIdx(genericContents, i, &content);
1918 if (p_content == NULL) {
1921 nbPages += getNbPagesForContent(p_content,
1922 pageIdxStart + nbPages,
1930static void prepareAddressConfirmationPages(
const char *address,
1937 addressConfirmationContext.tagValuePair.item =
"Address";
1938 addressConfirmationContext.tagValuePair.value = address;
1947 if (tagValueList != NULL) {
1958 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1966 if (tagValueList != NULL) {
1976 if (tagValueList != NULL) {
1984 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1989static void bundleNavStartHome(
void)
1991 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
1993 useCaseHomeExt(context->appName,
1996 context->settingContents != NULL ?
true : false,
1997 &context->homeAction,
1998 bundleNavStartSettings,
1999 context->quitCallback);
2002static void bundleNavStartSettingsAtPage(uint8_t initSettingPage)
2004 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2008 context->settingContents,
2010 bundleNavStartHome);
2013static void bundleNavStartSettings(
void)
2015 bundleNavStartSettingsAtPage(0);
2018static void bundleNavReviewConfirmRejection(
void)
2020 bundleNavContext.review.choiceCallback(
false);
2027 const char *confirmText;
2032 title =
"Reject transaction?";
2033 confirmText =
"Go back to transaction";
2036 title =
"Reject message?";
2037 confirmText =
"Go back to message";
2040 title =
"Reject operation?";
2041 confirmText =
"Go back to operation";
2048static void bundleNavReviewChoice(
bool confirm)
2051 bundleNavContext.review.choiceCallback(
true);
2054 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
2055 bundleNavReviewConfirmRejection);
2059static void bundleNavReviewStreamingConfirmRejection(
void)
2061 bundleNavContext.reviewStreaming.choiceCallback(
false);
2064static void bundleNavReviewStreamingChoice(
bool confirm)
2071 bundleNavContext.reviewStreaming.choiceCallback(
true);
2074 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
2075 bundleNavReviewStreamingConfirmRejection);
2082static void displaySecurityReport(uint32_t set)
2085 .withLeftBorder =
true,
2086 .onActionCallback = modalLayoutTouchCallback,
2087 .tapActionText = NULL};
2089 .separationLine =
true,
2090 .backAndText.icon = NULL,
2091 .backAndText.tuneId = TUNE_TAP_CASUAL,
2092 .backAndText.token = DISMISS_WARNING_TOKEN};
2096 uint8_t nbWarnings = 0;
2097 const char *provider;
2099 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2112 if ((reviewWithWarnCtx.securityReportLevel == 1) && (!reviewWithWarnCtx.isIntro)) {
2114 if (reviewWithWarnCtx.warning->predefinedSet & (1 << i)) {
2117 || (reviewWithWarnCtx.warning->providerMessage == NULL)) {
2118 bar.
subText = securityReportItems[i].subText;
2121 bar.
subText = reviewWithWarnCtx.warning->providerMessage;
2123 bar.
text = securityReportItems[i].text;
2126 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2127 bar.tuneId = TUNE_TAP_CASUAL;
2132 bar.
iconLeft = securityReportItems[i].icon;
2143 if (reviewWithWarnCtx.warning && reviewWithWarnCtx.warning->reportProvider) {
2144 provider = reviewWithWarnCtx.warning->reportProvider;
2147 provider =
"[unknown]";
2153 + W3C_DESCRIPTION_MAX_LEN / 2;
2157 .text1 = reviewWithWarnCtx.warning->reportUrl,
2158 .text2 =
"Scan to view full report",
2163 W3C_DESCRIPTION_MAX_LEN / 2,
2165 reviewWithWarnCtx.warning->reportUrl);
2166 urlLen = strlen(destStr) + 1;
2171 snprintf(destStr + urlLen, W3C_DESCRIPTION_MAX_LEN / 2 - urlLen,
"%s report", provider);
2177 info.
icon = &LARGE_WARNING_ICON;
2178 info.
title =
"This transaction cannot be Clear Signed";
2180 =
"This transaction or message cannot be decoded fully. If you choose to sign, you "
2181 "could be authorizing malicious actions that can drain your wallet.\n\nLearn more: "
2190 info.
icon = &LARGE_WARNING_ICON;
2191 info.
title =
"Transaction Check unavailable";
2193 =
"If you're not using the\nLedger Live app, Transaction Check might not work. If your "
2194 "are using Ledger Live, reject the transaction and try again.\n\nGet help at "
2214 .withLeftBorder =
true,
2215 .onActionCallback = modalLayoutTouchCallback,
2216 .tapActionText = NULL};
2218 .separationLine =
true,
2219 .backAndText.icon = NULL,
2220 .backAndText.tuneId = TUNE_TAP_CASUAL,
2221 .backAndText.token = DISMISS_WARNING_TOKEN};
2224 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2235 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2236 bar.tuneId = TUNE_TAP_CASUAL;
2260static void displayInitialWarning(
void)
2263#ifdef HAVE_PIEZO_SOUND
2264 tune_index_e tune = TUNE_RESERVED;
2268 .token = WARNING_CHOICE_TOKEN,
2269 .topText =
"Back to safety",
2271 .tuneId = TUNE_TAP_CASUAL};
2273 .separationLine =
false,
2274 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2275 uint32_t set = reviewWithWarnCtx.warning->predefinedSet
2278 reviewWithWarnCtx.isIntro =
true;
2280 layoutDescription.
modal =
false;
2286 layoutDescription.
ticker.tickerCallback = NULL;
2287 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2290 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2292 reviewWithWarnCtx.layoutCtx,
2294 WARNING_BUTTON_TOKEN,
2297 else if (reviewWithWarnCtx.warning->introTopRightIcon != NULL) {
2299 reviewWithWarnCtx.warning->introTopRightIcon,
2300 WARNING_BUTTON_TOKEN,
2305 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2308 const char *provider;
2311 info.
icon = &LARGE_WARNING_ICON;
2315 if (reviewWithWarnCtx.warning->reportProvider) {
2316 provider = reviewWithWarnCtx.warning->reportProvider;
2319 provider =
"[unknown]";
2322 snprintf(tmpString, W3C_DESCRIPTION_MAX_LEN,
"Detected by %s", provider);
2326 info.
title =
"Blind signing ahead";
2328 =
"This transaction's details are not fully verifiable. If you sign, you could "
2329 "lose all your assets.";
2331#ifdef HAVE_PIEZO_SOUND
2332 tune = TUNE_NEUTRAL;
2336 info.
title =
"Potential risk";
2337 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2341 info.
description = reviewWithWarnCtx.warning->providerMessage;
2343 buttonsInfo.
bottomText =
"Accept risk and continue";
2344#ifdef HAVE_PIEZO_SOUND
2345 tune = TUNE_NEUTRAL;
2349 info.
title =
"Critical threat";
2350 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2354 info.
description = reviewWithWarnCtx.warning->providerMessage;
2356 buttonsInfo.
bottomText =
"Accept threat and continue";
2357#ifdef HAVE_PIEZO_SOUND
2363 else if (reviewWithWarnCtx.warning->info != NULL) {
2366#ifdef HAVE_PIEZO_SOUND
2367 tune = TUNE_LOOK_AT_ME;
2373#ifdef HAVE_PIEZO_SOUND
2374 if (tune != TUNE_RESERVED) {
2375 os_io_seph_cmd_piezo_play_tune(tune);
2385 const char *predefinedTipBoxText = NULL;
2388 if (reviewWithWarnCtx.warning) {
2389 if (reviewWithWarnCtx.warning->predefinedSet & (1 <<
W3C_ISSUE_WARN)) {
2391 predefinedTipBoxText =
"Transaction Check unavailable.\nBlind signing required.";
2394 predefinedTipBoxText =
"Transaction Check unavailable";
2399 predefinedTipBoxText =
"Critical threat detected.\nBlind signing required.";
2402 predefinedTipBoxText =
"Critical threat detected.";
2407 predefinedTipBoxText =
"Potential risk detected.\nBlind signing required.";
2410 predefinedTipBoxText =
"Potential risk detected.";
2415 predefinedTipBoxText
2416 =
"No threat detected by Transaction Check but blind signing required.";
2419 predefinedTipBoxText =
"No threat detected by Transaction Check.";
2423 predefinedTipBoxText =
"Blind signing required.";
2427 if ((tipBox != NULL) || (predefinedTipBoxText != NULL)) {
2429 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
2430 if (predefinedTipBoxText != NULL) {
2431 genericContext.validWarningCtx =
true;
2432 STARTING_CONTENT.content.extendedCenter.tipBox.icon = NULL;
2433 STARTING_CONTENT.content.extendedCenter.tipBox.text = predefinedTipBoxText;
2436 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
2437 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
2439 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
2440 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
2448 const char *reviewTitle,
2449 const char *reviewSubTitle,
2450 const char *finishTitle,
2454 bool playNotifSound)
2457 memset(&genericContext, 0,
sizeof(genericContext));
2459 bundleNavContext.review.operationType = operationType;
2460 bundleNavContext.review.choiceCallback = choiceCallback;
2463 onChoice = bundleNavReviewChoice;
2464 navType = GENERIC_NAV;
2467 genericContext.genericContents.contentsList = localContentsList;
2468 genericContext.genericContents.nbContents = 3;
2473 prepareReviewFirstPage(
2474 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2477 initWarningTipBox(tipBox);
2481 memcpy(&localContentsList[1].content.tagValueList,
2489 prepareReviewLightLastPage(
2490 operationType, &localContentsList[2].content.infoButton, icon, finishTitle);
2494 prepareReviewLastPage(
2495 operationType, &localContentsList[2].content.infoLongPress, icon, finishTitle);
2499 uint8_t nbPages = getNbPagesForGenericContents(
2501 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
2504 if (playNotifSound) {
2505#ifdef HAVE_PIEZO_SOUND
2506 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
2510 displayGenericContextPage(0,
true);
2516 const char *reviewTitle,
2517 const char *reviewSubTitle,
2519 bool playNotifSound)
2522 memset(&genericContext, 0,
sizeof(genericContext));
2524 bundleNavContext.reviewStreaming.operationType = operationType;
2525 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
2526 bundleNavContext.reviewStreaming.icon = icon;
2529 onChoice = bundleNavReviewStreamingChoice;
2530 navType = STREAMING_NAV;
2533 genericContext.genericContents.contentsList = localContentsList;
2534 genericContext.genericContents.nbContents = 1;
2539 prepareReviewFirstPage(
2540 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2543 initWarningTipBox(NULL);
2546 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
2553 if (playNotifSound) {
2554#ifdef HAVE_PIEZO_SOUND
2555 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
2559 displayGenericContextPage(0,
true);
2578static void useCaseHomeExt(
const char *appName,
2580 const char *tagline,
2589 .centeredInfo.text1 = appName,
2590 .centeredInfo.text3 = NULL,
2592 .centeredInfo.offsetY = 0,
2595 .tapActionText = NULL,
2597 .topRightToken = CONTINUE_TOKEN,
2598 .tuneId = TUNE_TAP_CASUAL};
2599 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
2614 if (tagline == NULL) {
2618 "This app enables signing\ntransactions on its network.");
2645 onContinue = topRightCallback;
2646 onQuit = quitCallback;
2660static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
2662 memset(&detailsContext, 0,
sizeof(detailsContext));
2668 detailsContext.tag = tag;
2669 detailsContext.value = value;
2671 detailsContext.currentPage = 0;
2672 detailsContext.wrapping = wrapping;
2674 if (detailsContext.nbPages > 1) {
2675 uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3;
2678 uint8_t nbLinesInLastPage
2684 detailsContext.nbPages++;
2688 displayDetailsPage(0,
true);
2710 bool *requireSpecificDisplay)
2712 return getNbTagValuesInPage(
2713 nbPairs, tagValueList, startIndex,
false,
false, requireSpecificDisplay);
2733 bool *requireSpecificDisplay)
2735 return getNbTagValuesInPage(
2736 nbPairs, tagValueList, startIndex, isSkippable,
false, requireSpecificDisplay);
2753 uint8_t nbInfosInPage = 0;
2754 uint16_t currentHeight = 0;
2755 uint16_t previousHeight;
2756 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2757 const char *
const *infoTypes = PIC(infosList->
infoTypes);
2758 const char *
const *infoContents = PIC(infosList->
infoContents);
2760 while (nbInfosInPage < nbInfos) {
2762 currentHeight += PRE_TEXT_MARGIN;
2766 SMALL_BOLD_FONT, PIC(infoTypes[startIndex + nbInfosInPage]),
AVAILABLE_WIDTH,
true);
2768 currentHeight += TEXT_SUBTEXT_MARGIN;
2772 PIC(infoContents[startIndex + nbInfosInPage]),
2775 currentHeight += POST_SUBTEXT_MARGIN;
2780 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2785 previousHeight = currentHeight;
2788 return nbInfosInPage;
2805 uint8_t nbSwitchesInPage = 0;
2806 uint16_t currentHeight = 0;
2807 uint16_t previousHeight;
2808 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2811 while (nbSwitchesInPage < nbSwitches) {
2813 currentHeight += PRE_TEXT_MARGIN;
2817 switchArray[startIndex + nbSwitchesInPage].text,
2821 currentHeight += TEXT_SUBTEXT_MARGIN;
2826 switchArray[startIndex + nbSwitchesInPage].subText,
2829 currentHeight += POST_SUBTEXT_MARGIN;
2834 previousHeight = currentHeight;
2839 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2842 return nbSwitchesInPage;
2859 uint8_t nbBarsInPage = 0;
2860 uint16_t currentHeight = 0;
2861 uint16_t previousHeight;
2862 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2867 while (nbBarsInPage < nbBars) {
2868 currentHeight += TOUCHABLE_BAR_HEIGHT;
2873 previousHeight = currentHeight;
2878 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2881 return nbBarsInPage;
2898 uint8_t nbChoicesInPage = 0;
2899 uint16_t currentHeight = 0;
2900 uint16_t previousHeight;
2901 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2903 UNUSED(choicesList);
2906 while (nbChoicesInPage < nbChoices) {
2907 currentHeight += TOUCHABLE_BAR_HEIGHT;
2912 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2917 previousHeight = currentHeight;
2920 return nbChoicesInPage;
2931 uint8_t nbPages = 0;
2932 uint8_t nbPairs = tagValueList->
nbPairs;
2933 uint8_t nbPairsInPage;
2937 while (i < tagValueList->nbPairs) {
2941 nbPairs -= nbPairsInPage;
2953 const char *tagline,
2960 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
2969 const char *tagline,
2971 const char *actionButtonText,
2979 .text = actionButtonText};
2982 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
3008 onQuit = quitCallback;
3009 onNav = navCallback;
3010 onControls = controlsCallback;
3012 navType = SETTINGS_NAV;
3015 prepareNavInfo(
false, nbPages, NULL);
3017 displaySettingsPage(initPage,
true);
3035 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
3057 memset(&genericContext, 0,
sizeof(genericContext));
3060 onQuit = quitCallback;
3061 pageTitle = appName;
3062 navType = GENERIC_NAV;
3064 if (settingContents != NULL) {
3067 if (infosList != NULL) {
3068 genericContext.hasFinishingContent =
true;
3071 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
3075 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3076 if (infosList != NULL) {
3077 nbPages += getNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
3080 prepareNavInfo(
false, nbPages, NULL);
3082 displayGenericContextPage(initPage,
true);
3121 const char *appName,
3123 const char *tagline,
3131 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
3133 context->appName = appName;
3134 context->appIcon = appIcon;
3135 context->tagline = tagline;
3136 context->settingContents = settingContents;
3137 context->infosList = infosList;
3138 if (action != NULL) {
3144 context->quitCallback = quitCallback;
3147 bundleNavStartSettingsAtPage(initSettingPage);
3150 bundleNavStartHome();
3166 .tickerIntervale = 0,
3169 onQuit = quitCallback;
3171#ifdef HAVE_PIEZO_SOUND
3172 os_io_seph_cmd_piezo_play_tune(TUNE_LEDGER_MOMENT);
3180 .centeredInfo.icon = &DENIED_CIRCLE_ICON,
3181 .centeredInfo.offsetY = SMALL_FOOTER_HEIGHT / 2,
3182 .centeredInfo.onTop =
false,
3184 .centeredInfo.text1 = message,
3185 .centeredInfo.text2 = NULL,
3186 .centeredInfo.text3 = NULL,
3187 .tapActionText =
"",
3188 .isSwipeable =
false,
3189 .tapActionToken = QUIT_TOKEN,
3191 .actionButtonText = NULL,
3192 .tuneId = TUNE_TAP_CASUAL};
3209 switch (reviewStatusType) {
3211 msg =
"Operation signed";
3215 msg =
"Operation rejected";
3219 msg =
"Transaction signed";
3223 msg =
"Transaction rejected";
3227 msg =
"Message signed";
3231 msg =
"Message rejected";
3235 msg =
"Address verified";
3239 msg =
"Address verification\ncancelled";
3261 const char *message,
3262 const char *subMessage,
3263 const char *confirmText,
3264 const char *cancelText,
3271 .centeredInfo.text2 = subMessage,
3272 .centeredInfo.text3 = NULL,
3274 .centeredInfo.icon = icon,
3275 .centeredInfo.offsetY = 0,
3276 .confirmationText = confirmText,
3277 .confirmationToken = CHOICE_TOKEN,
3278 .tuneId = TUNE_TAP_CASUAL,
3281 if ((confirmText == NULL) || (cancelText == NULL)) {
3284 onChoice = callback;
3303 const char *subMessage,
3304 const char *confirmText,
3305 const char *cancelText,
3311 .centeredInfo.text1 = message,
3312 .centeredInfo.text2 = subMessage,
3313 .centeredInfo.text3 = NULL,
3315 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
3316 .centeredInfo.offsetY = 0,
3317 .confirmationText = confirmText,
3318 .confirmationToken = CHOICE_TOKEN,
3319 .tuneId = TUNE_TAP_CASUAL,
3321 onModalConfirm = callback;
3322 if (modalPageContext != NULL) {
3340 const char *message,
3341 const char *actionText,
3347 onAction = callback;
3349 content.
tuneId = TUNE_TAP_CASUAL;
3372 const char *reviewTitle,
3373 const char *reviewSubTitle,
3374 const char *rejectText,
3381 .footerToken = QUIT_TOKEN,
3382 .tapActionText = NULL,
3383 .isSwipeable =
true,
3384 .tapActionToken = CONTINUE_TOKEN,
3386 .actionButtonText = NULL,
3387 .
tuneId = TUNE_TAP_CASUAL};
3394 onQuit = rejectCallback;
3395 onContinue = continueCallback;
3397#ifdef HAVE_PIEZO_SOUND
3399 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3412 const char *rejectText,
3420 onChoice = choiceCallback;
3421 onNav = navCallback;
3422 onControls = buttonCallback;
3423 forwardNavOnly =
false;
3424 navType = REVIEW_NAV;
3428 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3430 displayReviewPage(initPage,
true);
3447 const char *rejectText,
3453 memset(&genericContext, 0,
sizeof(genericContext));
3456 onChoice = callback;
3457 navType = GENERIC_NAV;
3461 genericContext.genericContents.contentsList = localContentsList;
3464 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
3466 memcpy(&localContentsList[offset].content.tagValueList,
3473 memcpy(&localContentsList[offset].content.infoLongPress,
3479 genericContext.genericContents.nbContents = offset;
3482 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3484 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3486 displayGenericContextPage(0,
true);
3504 const char *rejectText,
3510 memset(&genericContext, 0,
sizeof(genericContext));
3513 onChoice = callback;
3514 navType = GENERIC_NAV;
3517 genericContext.genericContents.contentsList = localContentsList;
3520 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
3522 memcpy(&localContentsList[offset].content.tagValueList,
3536 genericContext.genericContents.nbContents = offset;
3539 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3541 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3543 displayGenericContextPage(0,
true);
3565 const char *reviewTitle,
3566 const char *reviewSubTitle,
3567 const char *finishTitle,
3570 useCaseReview(operationType,
3604 const char *reviewTitle,
3605 const char *reviewSubTitle,
3606 const char *finishTitle,
3617 &blindSigningWarning,
3646 const char *reviewTitle,
3647 const char *reviewSubTitle,
3648 const char *finishTitle,
3653 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
3655 if (tipBox != NULL) {
3656 memcpy(&activeTipBox, tipBox,
sizeof(activeTipBox));
3659 memset(&activeTipBox, 0,
sizeof(activeTipBox));
3662 if ((warning == NULL)
3665 useCaseReview(operationType,
3678 operationType |= NO_THREAT_OPERATION;
3681 operationType |= RISKY_OPERATION;
3684 reviewWithWarnCtx.isStreaming =
false;
3685 reviewWithWarnCtx.operationType = operationType;
3686 reviewWithWarnCtx.tagValueList = tagValueList;
3687 reviewWithWarnCtx.icon = icon;
3688 reviewWithWarnCtx.reviewTitle = reviewTitle;
3689 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
3690 reviewWithWarnCtx.finishTitle = finishTitle;
3691 reviewWithWarnCtx.warning = warning;
3692 reviewWithWarnCtx.choiceCallback = choiceCallback;
3698 useCaseReview(operationType,
3711 displayInitialWarning();
3733 const char *reviewTitle,
3734 const char *reviewSubTitle,
3735 const char *finishTitle,
3738 useCaseReview(operationType,
3759 const char *rejectText,
3763 memset(&genericContext, 0,
sizeof(genericContext));
3766 onQuit = rejectCallback;
3767 navType = GENERIC_NAV;
3774 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3775 prepareNavInfo(
true, nbPages, rejectText);
3778#ifdef HAVE_PIEZO_SOUND
3780 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3783 displayGenericContextPage(0,
true);
3800 const char *reviewTitle,
3801 const char *reviewSubTitle,
3804 useCaseReviewStreamingStart(
3805 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3823 const char *reviewTitle,
3824 const char *reviewSubTitle,
3828 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
3848 const char *reviewTitle,
3849 const char *reviewSubTitle,
3853 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
3855 if ((warning == NULL)
3858 useCaseReviewStreamingStart(
3859 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3863 operationType |= NO_THREAT_OPERATION;
3866 operationType |= RISKY_OPERATION;
3869 reviewWithWarnCtx.isStreaming =
true;
3870 reviewWithWarnCtx.operationType = operationType;
3871 reviewWithWarnCtx.icon = icon;
3872 reviewWithWarnCtx.reviewTitle = reviewTitle;
3873 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
3874 reviewWithWarnCtx.choiceCallback = choiceCallback;
3875 reviewWithWarnCtx.warning = warning;
3881 useCaseReviewStreamingStart(
3882 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3885 displayInitialWarning();
3906 memset(&genericContext, 0,
sizeof(genericContext));
3908 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3909 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
3912 onChoice = bundleNavReviewStreamingChoice;
3913 navType = STREAMING_NAV;
3916 genericContext.genericContents.contentsList = localContentsList;
3917 genericContext.genericContents.nbContents = 1;
3926 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3927 &genericContext.genericContents,
3930 prepareNavInfo(
true,
3932 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3940 displayGenericContextPage(0,
true);
3971 memset(&genericContext, 0,
sizeof(genericContext));
3973 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3976 onChoice = bundleNavReviewStreamingChoice;
3977 navType = STREAMING_NAV;
3980 genericContext.genericContents.contentsList = localContentsList;
3981 genericContext.genericContents.nbContents = 1;
3986 prepareReviewLastPage(bundleNavContext.reviewStreaming.operationType,
3987 &STARTING_CONTENT.content.infoLongPress,
3988 bundleNavContext.reviewStreaming.icon,
3992 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3993 &genericContext.genericContents,
3996 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3998 displayGenericContextPage(0,
true);
4010 memset(&genericContext, 0,
sizeof(genericContext));
4011 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4014 onChoice = callback;
4015 navType = GENERIC_NAV;
4018 genericContext.genericContents.contentsList = localContentsList;
4019 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
4021 prepareAddressConfirmationPages(
4022 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
4025 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4027 prepareNavInfo(
true, nbPages,
"Cancel");
4029#ifdef HAVE_PIEZO_SOUND
4031 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4034 displayGenericContextPage(0,
true);
4056 const char *reviewTitle,
4057 const char *reviewSubTitle,
4061 memset(&genericContext, 0,
sizeof(genericContext));
4063 if (addressConfirmationContext.modalLayout) {
4066 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4069 onChoice = choiceCallback;
4070 navType = GENERIC_NAV;
4074 genericContext.genericContents.contentsList = localContentsList;
4075 genericContext.genericContents.nbContents = (additionalTagValueList == NULL) ? 2 : 3;
4080 prepareReviewFirstPage(
4081 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
4082 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
4085 prepareAddressConfirmationPages(
4086 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
4089 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4091 prepareNavInfo(
true, nbPages,
"Cancel");
4093#ifdef HAVE_PIEZO_SOUND
4095 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4098 displayGenericContextPage(0,
true);
4112 if (genericContext.type != USE_CASE_SPINNER) {
4113 memset(&genericContext, 0,
sizeof(genericContext));
4114 genericContext.type = USE_CASE_SPINNER;
4119 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
4122 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4129 genericContext.spinnerPosition++;
4132 genericContext.spinnerPosition = 0;
4135 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4139 else if (ret == 2) {
4170 tune_index_e tuneId,
4174 keypadGenericUseCase(title,
4181 validatePinCallback,
4208 tune_index_e tuneId,
4212 keypadGenericUseCase(title,
4219 validatePinCallback,
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
@ INFO_LONG_PRESS
a centered info and a long press button
@ EXTENDED_CENTER
a centered content and a possible tip-box
@ CHOICES_LIST
list of choices through radio buttons
@ CENTERED_INFO
a centered info
@ SWITCHES_LIST
list of switches with descriptions
@ TAG_VALUE_DETAILS
a tag/value pair and a small button to get details.
@ INFOS_LIST
list of infos with titles
@ TAG_VALUE_CONFIRM
tag/value pairs and a black button/footer to confirm/cancel.
@ TAG_VALUE_LIST
list of tag/value pairs
@ BARS_LIST
list of touchable bars (with > on the right to go to sub-pages)
@ INFO_BUTTON
a centered info and a simple black button
@ INFO_LIST_ALIAS
alias is list of infos
@ ENS_ALIAS
alias comes from ENS
@ ADDRESS_BOOK_ALIAS
alias comes from Address Book
@ QR_CODE_ALIAS
alias is an address to be displayed as a QR Code
void(* nbgl_contentActionCallback_t)(int token, uint8_t index, int page)
prototype of function to be called when an action on a content object occurs
#define LOG_DEBUG(__logger,...)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
compute the len of the given text (in bytes) fitting in the given maximum nb lines,...
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
Create a reduced version of given ASCII text to wrap it on the given max width (in pixels),...
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
return the height of the given multiline text, with the given font.
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
compute the number of lines of the given text fitting in the given maxWidth
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, const char *title, const char *description, const char *info)
Creates in the main container three text areas:
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_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.
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_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,...
@ 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.
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,...
@ 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.
#define NB_SPINNER_POSITIONS
void nbgl_refresh(void)
This functions refreshes the actual screen on display with what has changed since the last refresh.
#define KEYPAD_MAX_DIGITS
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
This functions refreshes the actual screen on display with what has changed since the last refresh,...
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
nbgl_page_t * nbgl_pageDrawGenericContent(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content)
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
nbgl_page_t * nbgl_pageDrawLedgerInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const char *text, int tapActionToken)
draw a page with a centered text in large case, with a round check icon
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...
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.
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
This function redraws the whole screen on top of stack and its children.
@ 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()
@ 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
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)
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool isSkippable, bool *requireSpecificDisplay)
void(* nbgl_callback_t)(void)
prototype of generic callback function
#define SKIPPABLE_OPERATION
This is to use in nbgl_operationType_t when the operation is skippable. This is used.
void nbgl_useCaseGenericSettings(const char *appName, uint8_t initPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadPIN(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
uint32_t nbgl_operationType_t
This mask is used to describe the type of operation to review with additional options It is a mask of...
void nbgl_useCaseReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAction(const nbgl_icon_details_t *icon, const char *message, const char *actionText, nbgl_callback_t callback)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList)
DEPRECATED void nbgl_useCaseRegularReview(uint8_t initPage, uint8_t nbPages, const char *rejectText, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, nbgl_choiceCallback_t choiceCallback)
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)
void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos, const nbgl_contentInfoList_t *infosList, uint8_t startIndex, bool withNav)
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
uint8_t nbgl_useCaseGetNbBarsInPage(uint8_t nbBars, const nbgl_contentBarsList_t *barsList, uint8_t startIndex, bool withNav)
void nbgl_useCaseNavigableContent(const char *title, uint8_t initPage, uint8_t nbPages, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
#define INFOS_AREA_HEIGHT
height available for infos pairs display
@ STRONG_HOME_ACTION
Black button, implicating the main action of the App.
void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
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)
DEPRECATED void nbgl_useCaseHomeExt(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, const char *actionButtonText, nbgl_callback_t actionCallback, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadDigits(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
#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.
@ 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_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 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_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)
#define REAL_TYPE_MASK
This is the mask to apply on nbgl_operationType_t to get the real type provided by app.
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,...
@ CENTERED_INFO_WARNING
Centered info.
@ BAR_LIST_WARNING
list of touchable bars, to display sub-pages
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.
void nbgl_useCaseAddressReview(const char *address, const nbgl_contentTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
@ TYPE_TRANSACTION
For operations transferring a coin or taken from an account to another.
@ TYPE_OPERATION
For other types of operation (generic type)
void nbgl_useCaseAdvancedReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwitches, const nbgl_contentSwitchesList_t *switchesList, uint8_t startIndex, bool withNav)
This structure contains data to build a BARS_LIST content.
const uint8_t * tokens
array of tokens, one for each bar (nbBars items)
const char *const * barTexts
array of texts for each bar (nbBars items, in black/bold)
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
This structure contains data to build a INFOS_LIST content.
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
const nbgl_contentValueExt_t * infoExtensions
uint8_t nbInfos
number of elements in infoTypes and infoContents array
This structure contains data to build a centered info + long press button content.
const char * longPressText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t initChoice
index of the current choice
const char *const * names
array of strings giving the choices (nbChoices)
uint8_t nbChoices
number of choices
This structure contains info to build a switch (on the right) with a description (on the left),...
This structure contains [item,value] pair(s) and info about a potential "details" button,...
const char * confirmationText
text of the confirmation button, if NULL "It matches" is used
uint8_t detailsButtonToken
uint8_t confirmationToken
the token used as argument of the onActionCallback
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
const char * detailsButtonText
this text is used for "details" button (if NULL, no button)
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
uint8_t detailsButtonToken
const char * detailsButtonText
this text is used for "details" button
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
This structure contains a list of [tag,value] pairs.
nbgl_contentActionCallback_t actionCallback
called when a valueIcon is touched on a given pair
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
bool wrapping
if set to true, value text will be wrapped on ' ' to avoid cutting words
uint8_t startIndex
index of the first pair to get with callback
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
This structure contains a [tag,value] pair and possible extensions.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const nbgl_icon_details_t * valueIcon
int8_t centeredInfo
if set to 1, the tag will be displayed as a centered info
const char * value
string giving the value name
const char * item
string giving the tag name
This structure contains additions to a tag/value pair, to be able to build a screen to display these ...
const char * fullValue
full string of the value when used as an alias
nbgl_contentValueAliasType_t aliasType
type of alias
const char * backText
used as title of the popping page, if not NULL, otherwise "item" is used
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
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
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
This structure contains info to build a clickable "bar" with a text and an icon.
bool inactive
if set to true, the bar is grayed-out and cannot be touched
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
bool large
set to true only for the main level of OS settings
const char * subText
sub text (can be NULL)
const nbgl_icon_details_t * iconLeft
a buffer containing the 1BPP icon for icon on left (can be NULL)
const nbgl_icon_details_t * iconRight
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_screenTickerConfiguration_t ticker
const char * tapActionText
Light gray text used when main container is "tapable".
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * url
URL for QR code.
Structure containing all specific information when creating a confirmation page.
const char * cancelText
the text used for cancel action, if NULL a simple X button is used
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is pressed
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent)
nbgl_contentTagValueDetails_t tagValueDetails
TAG_VALUE_DETAILS type
const char * title
text for the title of the page (if NULL, no title)
uint8_t topRightToken
token used when top-right button (if not NULL) is touched
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when title is touched
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
const nbgl_icon_details_t * topRightIcon
nbgl_contentType_t type
type of page content in the following union
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
bool isTouchableTitle
if set to true, the title is preceded by <- arrow to go back
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
Structure containing all specific information when creating an information page.
nbgl_layoutButtonStyle_t actionButtonStyle
style of "action" button
const char * actionButtonText
if not NULL an "action" button is set under the centered info
uint8_t bottomButtonsToken
const nbgl_icon_details_t * actionButtonIcon
potential icon of "action" button
nbgl_pageButtonStyle_t bottomButtonStyle
style to apply to the Bottom button
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
Structure containing all specific information when creating a multi-screens page.
uint8_t nbPages
the number of pages to display (if <2, no navigation bar)
uint8_t quitToken
the token used as argument of the actionCallback when the footer is touched
uint8_t skipToken
if skipText is NULL the token used when right part of footer is touched
nbgl_pageNavigationType_t navType
uint8_t activePage
the index of the page to display at start-up
bool progressIndicator
if set to true, display a progress indicator on top of the page
nbgl_pageNavWithButtons_t navWithButtons
structure used when navigation with buttons
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when next or back is pressed
bool visiblePageIndicator
if set to true, the page indicator will be visible in navigation
const char * quitText
the text displayed in footer (on the left), used to quit (only on Flex)
bool backButton
if set to true, a back button (<-) is displayed in the nav bar
This structure contains data to build a SWITCHES_LIST content.
uint8_t nbSwitches
number of elements in switches and tokens array
const nbgl_contentSwitch_t * switches
array of switches (nbSwitches items)
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
const char * modalTitle
title given to modal window displayed when tip-box is touched
nbgl_contentInfoList_t infos
infos pairs displayed in modal, if type is INFOS_LIST.
const char * text
text of the tip-box
const nbgl_icon_details_t * icon
icon of the tip-box
const char *const * texts
array of texts for each bar (nbBars items, in black/bold)
const struct nbgl_warningDetails_s * details
array of nbBars structures giving what to display when each bar is touched.
const char *const * subTexts
array of texts for each bar (nbBars items, in black)
uint8_t nbBars
number of touchable bars
const nbgl_icon_details_t ** icons
array of icons for each bar (nbBars items)
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
nbgl_warningDetailsType_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
const char * title
text of the page (used to go back)
nbgl_layoutQRCode_t qrCode
QR code, if type == QRCODE_WARNING.
nbgl_warningBarList_t barList
touchable bars list, if type == BAR_LIST_WARNING
The necessary parameters to build a warning page preceding a review. One can either use predefinedSet...
const nbgl_warningDetails_t * introDetails
const nbgl_warningDetails_t * reviewDetails
Union of the different type of contents.
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type