18#include "os_helpers.h"
25#define PAGE_NB_ELEMENTS_BITS 3
26#define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
27#define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
29#define PAGE_FLAG_BITS 1
30#define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
31#define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
33#define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
34#define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
35#define SET_PAGE_DATA(pageIdx, pageData) \
36 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
37 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
39#define MAX_PAGE_NB 256
42#define STARTING_CONTENT localContentsList[0]
43#define FINISHING_CONTENT localContentsList[1]
46#define QRCODE_NB_MAX_LINES 3
48#define QRCODE_REDUCED_ADDR_LEN 128
51#define keypadContext sharedContext.keypad
52#define reviewWithWarnCtx sharedContext.reviewWithWarning
55#define W3C_DESCRIPTION_MAX_LEN 128
62#define RISKY_OPERATION (1 << 6)
69#define NO_THREAT_OPERATION (1 << 7)
81 ADDRESS_QRCODE_BUTTON_TOKEN,
93 QUIT_TIPBOX_MODAL_TOKEN,
96 DISMISS_WARNING_TOKEN,
108typedef struct DetailsContext_s {
114 const char *nextPageStart;
117typedef struct AddressConfirmationContext_s {
120} AddressConfirmationContext_t;
123typedef struct KeypadContext_s {
133typedef struct ReviewWithWarningContext_s {
138 const char *reviewTitle;
139 const char *reviewSubTitle;
140 const char *finishTitle;
147} ReviewWithWarningContext_t;
153 KeypadContext_t keypad;
155 ReviewWithWarningContext_t reviewWithWarning;
159 USE_CASE_GENERIC = 0,
161} GenericContextType_t;
164 GenericContextType_t type;
168 uint8_t currentContentElementNb;
170 bool hasStartingContent;
171 bool hasFinishingContent;
172 const char *detailsItem;
173 const char *detailsvalue;
174 bool detailsWrapping;
175 bool validWarningCtx;
193} nbgl_homeAndSettingsContext_t;
198} nbgl_reviewContext_t;
206} nbgl_reviewStreamingContext_t;
209 nbgl_homeAndSettingsContext_t homeAndSettings;
210 nbgl_reviewContext_t review;
211 nbgl_reviewStreamingContext_t reviewStreaming;
212} nbgl_BundleNavContext_t;
218} SecurityReportItem_t;
225static char tmpString[W3C_DESCRIPTION_MAX_LEN];
245static const char *pageTitle;
252static bool forwardNavOnly;
253static NavType_t navType;
255static DetailsContext_t detailsContext;
258static SharedContext_t sharedContext;
261static AddressConfirmationContext_t addressConfirmationContext;
264static GenericContext_t genericContext;
266 localContentsList[3];
267static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
270static nbgl_BundleNavContext_t bundleNavContext;
273static const uint8_t nbMaxElementsPerContentType[] = {
290 .icon = &WARNING_ICON,
291 .text =
"Blind signing required",
292 .subText =
"This transaction's details are not fully verifiable. If "
293 "you sign, you could lose all your assets."
296 .icon = &WARNING_ICON,
297 .text =
"Transaction Check unavailable",
301 .icon = &WARNING_ICON,
302 .text =
"Risk detected",
303 .subText =
"This transaction was scanned as risky by Web3 Checks."
306 .icon = &WARNING_ICON,
307 .text =
"Critical threat",
308 .subText =
"This transaction was scanned as malicious by Web3 Checks."
312 .text =
"No threat detected",
313 .subText =
"Transaction Check didn't find any threat, but always "
314 "review transaction details carefully."
324static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
330static void displayReviewPage(
uint8_t page,
bool forceFullRefresh);
331static void displayDetailsPage(
uint8_t page,
bool forceFullRefresh);
332static void displayFullValuePage(
const char *backText,
333 const char *aliasText,
335static void displayInfosListModal(
const char *modalTitle,
338static void displaySettingsPage(
uint8_t page,
bool forceFullRefresh);
339static void displayGenericContextPage(
uint8_t pageIdx,
bool forceFullRefresh);
340static void pageCallback(
int token,
uint8_t index);
342static void displayAddressQRCode(
void);
344static void modalLayoutTouchCallback(
int token,
uint8_t index);
345static void displaySkipWarning(
void);
347static void bundleNavStartHome(
void);
348static void bundleNavStartSettingsAtPage(
uint8_t initSettingPage);
349static void bundleNavStartSettings(
void);
351static void bundleNavReviewStreamingChoice(
bool confirm);
352static void displaySecurityReport(uint32_t set);
354static void displayInitialWarning(
void);
358 const char *reviewTitle,
359 const char *reviewSubTitle,
360 const char *finishTitle,
365 bool validWarningCtx);
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) {
445 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
462static void prepareNavInfo(
bool isReview,
uint8_t nbPages,
const char *rejectText)
464 memset(&navInfo, 0,
sizeof(navInfo));
467 navInfo.
tuneId = TUNE_TAP_CASUAL;
471 if (isReview ==
false) {
480 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false : true;
487 const char *reviewTitle,
488 const char *reviewSubTitle)
490 contentCenter->
icon = icon;
491 contentCenter->
title = reviewTitle;
493 contentCenter->
subText =
"Swipe to review";
496 contentCenter->
padding =
false;
502 const char *finishTitle)
504 infoLongPress->
text = finishTitle;
505 infoLongPress->
icon = icon;
512 const char *finishTitle)
514 infoButton->
text = finishTitle;
515 infoButton->
icon = icon;
522 UNUSED(operationType);
528static void pageModalCallback(
int token,
uint8_t index)
532 if (token == INFOS_TIP_BOX_TOKEN) {
539 else if (token == INFO_ALIAS_TOKEN) {
541 displayFullValuePage(genericContext.currentInfos->infoTypes[index],
542 genericContext.currentInfos->infoContents[index],
543 &genericContext.currentInfos->infoExtensions[index]);
547 modalPageContext = NULL;
548 if (token == NAV_TOKEN) {
555 displayDetailsPage(index,
false);
558 else if (token == QUIT_TOKEN) {
563 else if (token == QUIT_TIPBOX_MODAL_TOKEN) {
565 if (reviewWithWarnCtx.securityReportLevel == 2) {
566 reviewWithWarnCtx.securityReportLevel = 1;
567 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
575 else if (token == SKIP_TOKEN) {
586 else if (token == CHOICE_TOKEN) {
588 if (onModalConfirm != NULL) {
601static void pageCallback(
int token,
uint8_t index)
604 if (token == QUIT_TOKEN) {
605 if (onQuit != NULL) {
609 else if (token == CONTINUE_TOKEN) {
610 if (onContinue != NULL) {
614 else if (token == CHOICE_TOKEN) {
615 if (onChoice != NULL) {
616 onChoice((index == 0) ?
true : false);
619 else if (token == ACTION_BUTTON_TOKEN) {
620 if ((index == 0) && (onAction != NULL)) {
623 else if ((index == 1) && (onQuit != NULL)) {
628 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
629 displayAddressQRCode();
632 else if (token == CONFIRM_TOKEN) {
633 if (onChoice != NULL) {
637 else if (token == REJECT_TOKEN) {
638 if (onChoice != NULL) {
642 else if (token == DETAILS_BUTTON_TOKEN) {
643 displayDetails(genericContext.detailsItem,
644 genericContext.detailsvalue,
645 genericContext.detailsWrapping);
647 else if (token == NAV_TOKEN) {
649 if (onQuit != NULL) {
654 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
655 displayGenericContextPage(index,
false);
657 else if (navType == REVIEW_NAV) {
658 displayReviewPage(index,
false);
661 displaySettingsPage(index,
false);
665 else if (token == NEXT_TOKEN) {
667 displayReviewPage(navInfo.
activePage + 1,
false);
670 displayGenericContextPage(navInfo.
activePage + 1,
false);
673 else if (token == BACK_TOKEN) {
675 displayReviewPage(navInfo.
activePage - 1,
true);
678 displayGenericContextPage(navInfo.
activePage - 1,
false);
681 else if (token == SKIP_TOKEN) {
683 displaySkipWarning();
685 else if (token == VALUE_ALIAS_TOKEN) {
688 if (genericContext.currentPairs != NULL) {
689 pair = &genericContext.currentPairs[genericContext.currentElementIdx + index];
692 pair = genericContext.currentCallback(genericContext.currentElementIdx + index);
696 else if (token == BLIND_WARNING_TOKEN) {
697 reviewWithWarnCtx.isIntro =
false;
698 reviewWithWarnCtx.warning = NULL;
701 else if (token == WARNING_BUTTON_TOKEN) {
703 reviewWithWarnCtx.securityReportLevel = 1;
705 if (reviewWithWarnCtx.warning->predefinedSet) {
706 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
710 if (reviewWithWarnCtx.isIntro) {
711 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->introDetails);
714 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->reviewDetails);
718 else if (token == TIP_BOX_TOKEN) {
720 if (genericContext.validWarningCtx && (reviewWithWarnCtx.warning->predefinedSet != 0)) {
721 reviewWithWarnCtx.securityReportLevel = 1;
722 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
725 displayInfosListModal(activeTipBox.
modalTitle, &activeTipBox.
infos,
false);
729 if (onContentAction != NULL) {
730 onContentAction(token, index, navInfo.
activePage);
732 if (onControls != NULL) {
733 onControls(token, index);
739static void tickerCallback(
void)
742 if (onQuit != NULL) {
748static void displaySettingsPage(
uint8_t page,
bool forceFullRefresh)
752 if ((onNav == NULL) || (onNav(page, &content) ==
false)) {
757 content.
title = pageTitle;
760 content.
tuneId = TUNE_TAP_CASUAL;
765 if (forceFullRefresh) {
774static void displayReviewPage(
uint8_t page,
bool forceFullRefresh)
783 if ((onNav == NULL) || (onNav(navInfo.
activePage, &content) ==
false)) {
788 content.
title = NULL;
790 content.
tuneId = TUNE_TAP_CASUAL;
797 if (forwardNavOnly) {
821 if (forceFullRefresh) {
833 uint8_t *p_nbElementsInNextPage,
836 int8_t nextContentIdx = genericContext.currentContentIdx;
837 int16_t nextElementIdx = genericContext.currentElementIdx;
841 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
842 *p_nbElementsInNextPage = nbElementsInNextPage;
847 uint8_t nbElementsInCurrentPage;
849 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
850 nextElementIdx += nbElementsInCurrentPage;
855 if ((nextElementIdx >= genericContext.currentContentElementNb)
856 && (genericContext.currentContentElementNb > 0)) {
866 nextElementIdx -= nbElementsInNextPage;
872 if (nextElementIdx < 0) {
874 nextElementIdx = -nbElementsInNextPage;
880 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
881 p_content = &STARTING_CONTENT;
883 else if ((nextContentIdx == genericContext.genericContents.nbContents)
884 && (genericContext.hasFinishingContent)) {
885 p_content = &FINISHING_CONTENT;
888 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
890 if (p_content == NULL) {
905 if ((nextContentIdx != genericContext.currentContentIdx)
906 || (genericContext.currentContentElementNb == 0)) {
907 genericContext.currentContentIdx = nextContentIdx;
908 genericContext.currentContentElementNb = getContentNbElement(p_content);
910 if (nextElementIdx < 0) {
911 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
916 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
918 "Invalid element index %d / %d\n",
920 genericContext.currentContentElementNb);
925 genericContext.currentElementIdx = nextElementIdx;
933static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
938 uint8_t nextElementIdx = genericContext.currentElementIdx;
940 pageContent->
title = pageTitle;
943 pageContent->
tuneId = TUNE_TAP_CASUAL;
945 pageContent->
type = p_content->
type;
946 switch (pageContent->
type) {
998 p_tagValueList = NULL;
1010 genericContext.detailsItem = pair->
item;
1011 genericContext.detailsvalue = pair->
value;
1016 if (p_tagValueList != NULL) {
1017 p_tagValueList->
nbPairs = nbElementsInPage;
1020 p_tagValueList->
pairs
1023 for (
uint8_t i = 0; i < nbElementsInPage; i++) {
1025 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1031 p_tagValueList->
pairs = NULL;
1035 for (
uint8_t i = 0; i < nbElementsInPage; i++) {
1039 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1077 < nextElementIdx + nbElementsInPage)) {
1097 bool isFirstOrLastPage
1101 = (navType == STREAMING_NAV)
1102 ? bundleNavContext.reviewStreaming.operationType
1103 : ((navType == GENERIC_NAV) ? bundleNavContext.review.operationType : 0);
1106 if (isFirstOrLastPage
1107 && (operationType & (
BLIND_OPERATION | RISKY_OPERATION | NO_THREAT_OPERATION))) {
1109 if ((operationType & NO_THREAT_OPERATION)
1118 = (operationType &
BLIND_OPERATION) ? BLIND_WARNING_TOKEN : WARNING_BUTTON_TOKEN;
1125static void displayGenericContextPage(
uint8_t pageIdx,
bool forceFullRefresh)
1133 if (navType == STREAMING_NAV) {
1135 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1136 bundleNavContext.reviewStreaming.skipCallback();
1140 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1141 bundleNavReviewStreamingChoice(
true);
1148 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1153 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1154 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1164 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1167 if (p_content == NULL) {
1173 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1179 if (forceFullRefresh) {
1188static const char *getDetailsPageAt(
uint8_t detailsPage)
1191 const char *currentChar = detailsContext.value;
1192 while (page < detailsPage) {
1195 if (nbLines > NB_MAX_LINES_IN_DETAILS) {
1200 NB_MAX_LINES_IN_DETAILS,
1202 detailsContext.wrapping);
1204 currentChar = currentChar + len;
1212static void displayDetailsPage(
uint8_t detailsPage,
bool forceFullRefresh)
1216 .nbPages = detailsContext.nbPages,
1218 .quitToken = QUIT_TOKEN,
1219 .navWithButtons.navToken = NAV_TOKEN,
1220 .navWithButtons.quitButton =
true,
1221 .navWithButtons.backButton =
true,
1222 .navWithButtons.quitText = NULL,
1223 .progressIndicator =
false,
1224 .tuneId = TUNE_TAP_CASUAL};
1226 .topRightIcon = NULL,
1227 .tagValueList.nbPairs = 1,
1228 .tagValueList.pairs = ¤tPair,
1229 .tagValueList.smallCaseForValue =
true,
1230 .tagValueList.wrapping = detailsContext.wrapping};
1232 if (modalPageContext != NULL) {
1235 currentPair.
item = detailsContext.tag;
1237 if (detailsPage <= detailsContext.currentPage) {
1239 currentPair.
value = getDetailsPageAt(detailsPage);
1240 forceFullRefresh =
true;
1244 currentPair.
value = detailsContext.nextPageStart;
1246 detailsContext.currentPage = detailsPage;
1250 if (nbLines > NB_MAX_LINES_IN_DETAILS) {
1255 NB_MAX_LINES_IN_DETAILS,
1257 detailsContext.wrapping);
1260 detailsContext.nextPageStart = currentPair.
value + len;
1266 detailsContext.nextPageStart = NULL;
1275 if (forceFullRefresh) {
1284static void displayFullValuePage(
const char *backText,
1285 const char *aliasText,
1288 const char *modalTitle
1289 = (extension->
backText != NULL) ? PIC(extension->
backText) : PIC(backText);
1291 genericContext.currentInfos = extension->
infolist;
1292 displayInfosListModal(modalTitle, extension->
infolist,
true);
1296 .withLeftBorder =
true,
1297 .onActionCallback = &modalLayoutTouchCallback,
1298 .tapActionText = NULL};
1300 .separationLine =
false,
1301 .backAndText.token = 0,
1302 .backAndText.tuneId = TUNE_TAP_CASUAL,
1303 .backAndText.text = modalTitle};
1312 .text1 = (extension->
title != NULL) ? extension->
title : extension->fullValue,
1313 .text2 = extension->explanation,
1324 info =
"ENS names are resolved by Ledger backend.";
1327 info =
"This account label comes from your Address Book in Ledger Live.";
1333 genericContext.modalLayout, aliasText, extension->
fullValue, info);
1342static void displayInfosListModal(
const char *modalTitle,
1349 .quitToken = QUIT_TIPBOX_MODAL_TOKEN,
1350 .navWithButtons.navToken = NAV_TOKEN,
1351 .navWithButtons.quitButton =
false,
1352 .navWithButtons.backButton =
true,
1353 .navWithButtons.quitText = NULL,
1354 .progressIndicator =
false,
1355 .tuneId = TUNE_TAP_CASUAL};
1358 .topRightIcon = NULL,
1359 .infosList.nbInfos = infos->
nbInfos,
1361 .infosList.infoTypes = infos->
infoTypes,
1364 .infosList.token = fromReview ? INFO_ALIAS_TOKEN : INFOS_TIP_BOX_TOKEN,
1365 .
title = modalTitle,
1366 .titleToken = QUIT_TIPBOX_MODAL_TOKEN,
1367 .tuneId = TUNE_TAP_CASUAL};
1369 if (modalPageContext != NULL) {
1378static void displayAddressQRCode(
void)
1382 .withLeftBorder =
true,
1383 .onActionCallback = &modalLayoutTouchCallback,
1384 .tapActionText = NULL};
1386 .
type =
HEADER_EMPTY, .separationLine =
false, .emptySpace.height = SMALL_CENTERING_HEADER};
1392 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1397 SMALL_REGULAR_FONT, addressConfirmationContext.tagValuePair.value,
AVAILABLE_WIDTH,
false);
1399 if (nbLines <= QRCODE_NB_MAX_LINES) {
1400 qrCode.
text2 = addressConfirmationContext.tagValuePair.value;
1405 addressConfirmationContext.tagValuePair.value,
1407 QRCODE_NB_MAX_LINES,
1409 QRCODE_REDUCED_ADDR_LEN);
1410 qrCode.
text2 = reducedAddress;
1416 addressConfirmationContext.modalLayout,
"Close", DISMISS_QR_TOKEN, TUNE_TAP_CASUAL);
1424static void modalLayoutTouchCallback(
int token,
uint8_t index)
1427 if (token == DISMISS_QR_TOKEN) {
1430 addressConfirmationContext.modalLayout = NULL;
1433 else if (token == DISMISS_WARNING_TOKEN) {
1437 if (reviewWithWarnCtx.securityReportLevel <= 1) {
1438 reviewWithWarnCtx.modalLayout = NULL;
1443 reviewWithWarnCtx.securityReportLevel = 1;
1445 if (reviewWithWarnCtx.warning->predefinedSet) {
1446 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1451 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1452 : reviewWithWarnCtx.warning->reviewDetails;
1453 displayCustomizedSecurityReport(details);
1458 else if ((token >= FIRST_WARN_BAR_TOKEN) && (token <= LAST_WARN_BAR_TOKEN)) {
1461 reviewWithWarnCtx.securityReportLevel = 2;
1463 if (reviewWithWarnCtx.warning->predefinedSet) {
1464 displaySecurityReport(1 << (token - FIRST_WARN_BAR_TOKEN));
1469 ? reviewWithWarnCtx.warning->introDetails
1470 : reviewWithWarnCtx.warning->reviewDetails;
1472 displayCustomizedSecurityReport(
1481 genericContext.modalLayout = NULL;
1488static void layoutTouchCallback(
int token,
uint8_t index)
1491 if (token == WARNING_CHOICE_TOKEN) {
1493 reviewWithWarnCtx.choiceCallback(
false);
1496 reviewWithWarnCtx.isIntro =
false;
1497 if (reviewWithWarnCtx.isStreaming) {
1498 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1499 reviewWithWarnCtx.icon,
1500 reviewWithWarnCtx.reviewTitle,
1501 reviewWithWarnCtx.reviewSubTitle,
1502 reviewWithWarnCtx.choiceCallback,
1506 useCaseReview(reviewWithWarnCtx.operationType,
1507 reviewWithWarnCtx.tagValueList,
1508 reviewWithWarnCtx.icon,
1509 reviewWithWarnCtx.reviewTitle,
1510 reviewWithWarnCtx.reviewSubTitle,
1511 reviewWithWarnCtx.finishTitle,
1513 reviewWithWarnCtx.choiceCallback,
1521 else if (token == WARNING_BUTTON_TOKEN) {
1523 reviewWithWarnCtx.securityReportLevel = 1;
1525 if (reviewWithWarnCtx.warning->predefinedSet) {
1526 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1531 ? reviewWithWarnCtx.warning->introDetails
1532 : reviewWithWarnCtx.warning->reviewDetails;
1533 displayCustomizedSecurityReport(details);
1539static void displaySkipWarning(
void)
1542 .cancelText =
"Go back to review",
1543 .centeredInfo.text1 =
"Skip review?",
1545 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
1546 .centeredInfo.text3 = NULL,
1548 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
1549 .centeredInfo.offsetY = 0,
1550 .confirmationText =
"Yes, skip",
1551 .confirmationToken = SKIP_TOKEN,
1552 .
tuneId = TUNE_TAP_CASUAL,
1554 if (modalPageContext != NULL) {
1566static void updateKeyPad(
bool add)
1568 bool enableValidate, enableBackspace, enableDigits;
1569 bool redrawKeypad =
false;
1572 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
1573 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
1574 enableBackspace = (keypadContext.pinLen > 0);
1576 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
1578 (keypadContext.pinLen == keypadContext.pinMaxDigits)
1580 (keypadContext.pinLen == 1)) {
1581 redrawKeypad =
true;
1585 if ((keypadContext.pinLen == 0) ||
1586 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
1588 (keypadContext.pinLen
1589 == (keypadContext.pinMaxDigits - 1))) {
1590 redrawKeypad =
true;
1593 if (keypadContext.hidden ==
true) {
1598 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
1602 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
1605 if ((!add) && (keypadContext.pinLen == 0)) {
1613static void keypadCallback(
char touchedKey)
1615 switch (touchedKey) {
1617 if (keypadContext.pinLen > 0) {
1618 keypadContext.pinLen--;
1619 keypadContext.pinEntry[keypadContext.pinLen] = 0;
1621 updateKeyPad(
false);
1630 onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
1634 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1635 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
1636 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
1637 keypadContext.pinLen++;
1646static void keypadGenericUseCase(
const char *title,
1652 tune_index_e tuneId,
1658 .separationLine =
true,
1659 .backAndText.token = backToken,
1660 .backAndText.tuneId = tuneId,
1661 .backAndText.text = NULL};
1670 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
1674 layoutDescription.
modal =
false;
1677 keypadContext.hidden = hidden;
1689 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
1696 onValidatePin = validatePinCallback;
1698 keypadContext.pinMinDigits = minDigits;
1699 keypadContext.pinMaxDigits = maxDigits;
1717 nbElements = getContentNbElement(content);
1719 while (nbElements > 0) {
1722 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
1744 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
1747 elemIdx += nbElementsInPage;
1748 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
1749 nbElements -= nbElementsInPage;
1764 for (
int i = 0; i < genericContents->
nbContents; i++) {
1765 p_content = getContentAtIdx(genericContents, i, &content);
1766 if (p_content == NULL) {
1769 nbPages += nbgl_useCaseGetNbPagesForContent(p_content,
1770 pageIdxStart + nbPages,
1778static void prepareAddressConfirmationPages(
const char *address,
1785 addressConfirmationContext.tagValuePair.item =
"Address";
1786 addressConfirmationContext.tagValuePair.value = address;
1795 if (tagValueList != NULL) {
1806 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1814 if (tagValueList != NULL) {
1824 if (tagValueList != NULL) {
1832 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1837static void bundleNavStartHome(
void)
1839 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
1841 useCaseHomeExt(context->appName,
1844 context->settingContents != NULL ?
true : false,
1845 &context->homeAction,
1846 bundleNavStartSettings,
1847 context->quitCallback);
1850static void bundleNavStartSettingsAtPage(
uint8_t initSettingPage)
1852 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
1856 context->settingContents,
1858 bundleNavStartHome);
1861static void bundleNavStartSettings(
void)
1863 bundleNavStartSettingsAtPage(0);
1866static void bundleNavReviewConfirmRejection(
void)
1868 bundleNavContext.review.choiceCallback(
false);
1875 const char *confirmText;
1880 title =
"Reject transaction?";
1881 confirmText =
"Go back to transaction";
1884 title =
"Reject message?";
1885 confirmText =
"Go back to message";
1888 title =
"Reject operation?";
1889 confirmText =
"Go back to operation";
1896static void bundleNavReviewChoice(
bool confirm)
1899 bundleNavContext.review.choiceCallback(
true);
1902 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
1903 bundleNavReviewConfirmRejection);
1907static void bundleNavReviewStreamingConfirmRejection(
void)
1909 bundleNavContext.reviewStreaming.choiceCallback(
false);
1912static void bundleNavReviewStreamingChoice(
bool confirm)
1919 bundleNavContext.reviewStreaming.choiceCallback(
true);
1922 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
1923 bundleNavReviewStreamingConfirmRejection);
1930static void displaySecurityReport(uint32_t set)
1933 .withLeftBorder =
true,
1934 .onActionCallback = modalLayoutTouchCallback,
1935 .tapActionText = NULL};
1937 .separationLine =
true,
1938 .backAndText.icon = NULL,
1939 .backAndText.tuneId = TUNE_TAP_CASUAL,
1940 .backAndText.token = DISMISS_WARNING_TOKEN};
1945 const char *provider;
1947 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
1960 if ((reviewWithWarnCtx.securityReportLevel == 1) && (!reviewWithWarnCtx.isIntro)) {
1962 if (reviewWithWarnCtx.warning->predefinedSet & (1 << i)) {
1965 || (reviewWithWarnCtx.warning->providerMessage == NULL)) {
1966 bar.
subText = securityReportItems[i].subText;
1969 bar.
subText = reviewWithWarnCtx.warning->providerMessage;
1971 bar.
text = securityReportItems[i].text;
1974 bar.
token = FIRST_WARN_BAR_TOKEN + i;
1975 bar.tuneId = TUNE_TAP_CASUAL;
1980 bar.
iconLeft = securityReportItems[i].icon;
1991 if (reviewWithWarnCtx.warning && reviewWithWarnCtx.warning->reportProvider) {
1992 provider = reviewWithWarnCtx.warning->reportProvider;
1995 provider =
"[unknown]";
2001 + W3C_DESCRIPTION_MAX_LEN / 2;
2005 .text1 = reviewWithWarnCtx.warning->reportUrl,
2006 .text2 =
"Scan to view full report",
2011 W3C_DESCRIPTION_MAX_LEN / 2,
2013 reviewWithWarnCtx.warning->reportUrl);
2014 urlLen = strlen(destStr) + 1;
2019 snprintf(destStr + urlLen, W3C_DESCRIPTION_MAX_LEN / 2 - urlLen,
"%s report", provider);
2025 info.
icon = &LARGE_WARNING_ICON;
2026 info.
title =
"This transaction cannot be Clear Signed";
2028 =
"This transaction or message cannot be decoded fully. If you choose to sign, you "
2029 "could be authorizing malicious actions that can drain your wallet.\n\nLearn more: "
2038 info.
icon = &LARGE_WARNING_ICON;
2039 info.
title =
"Transaction Check unavailable";
2041 =
"If you're not using the\nLedger Live app, Transaction Check might not work. If your "
2042 "are using Ledger Live, reject the transaction and try again.\n\nGet help at "
2062 .withLeftBorder =
true,
2063 .onActionCallback = modalLayoutTouchCallback,
2064 .tapActionText = NULL};
2066 .separationLine =
true,
2067 .backAndText.icon = NULL,
2068 .backAndText.tuneId = TUNE_TAP_CASUAL,
2069 .backAndText.token = DISMISS_WARNING_TOKEN};
2072 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2083 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2084 bar.tuneId = TUNE_TAP_CASUAL;
2108static void displayInitialWarning(
void)
2111#ifdef HAVE_PIEZO_SOUND
2112 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
2116 .token = WARNING_CHOICE_TOKEN,
2117 .topText =
"Back to safety",
2119 .tuneId = TUNE_TAP_CASUAL};
2121 .separationLine =
false,
2122 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2123 uint32_t set = reviewWithWarnCtx.warning->predefinedSet
2126 reviewWithWarnCtx.isIntro =
true;
2128 layoutDescription.
modal =
false;
2134 layoutDescription.
ticker.tickerCallback = NULL;
2135 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2138 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2140 reviewWithWarnCtx.layoutCtx,
2142 WARNING_BUTTON_TOKEN,
2145 else if (reviewWithWarnCtx.warning->introTopRightIcon != NULL) {
2147 reviewWithWarnCtx.warning->introTopRightIcon,
2148 WARNING_BUTTON_TOKEN,
2153 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2156 const char *provider;
2159 info.
icon = &LARGE_WARNING_ICON;
2163 if (reviewWithWarnCtx.warning->reportProvider) {
2164 provider = reviewWithWarnCtx.warning->reportProvider;
2167 provider =
"[unknown]";
2170 snprintf(tmpString, W3C_DESCRIPTION_MAX_LEN,
"Detected by %s", provider);
2174 info.
title =
"Blind signing ahead";
2176 =
"This transaction's details are not fully verifiable. If you sign, you could "
2177 "lose all your assets.";
2181 info.
title =
"Potential risk";
2182 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2186 info.
description = reviewWithWarnCtx.warning->providerMessage;
2188 buttonsInfo.
bottomText =
"Accept risk and continue";
2191 info.
title =
"Critical threat";
2192 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2196 info.
description = reviewWithWarnCtx.warning->providerMessage;
2198 buttonsInfo.
bottomText =
"Accept threat and continue";
2202 else if (reviewWithWarnCtx.warning->info != NULL) {
2217 const char *reviewTitle,
2218 const char *reviewSubTitle,
2219 const char *finishTitle,
2223 bool playNotifSound,
2224 bool validWarningCtx)
2226 const char *predefinedTipBoxText = NULL;
2228 memset(&genericContext, 0,
sizeof(genericContext));
2230 bundleNavContext.review.operationType = operationType;
2231 bundleNavContext.review.choiceCallback = choiceCallback;
2234 onChoice = bundleNavReviewChoice;
2235 navType = GENERIC_NAV;
2238 genericContext.validWarningCtx = validWarningCtx;
2239 genericContext.genericContents.contentsList = localContentsList;
2240 genericContext.genericContents.nbContents = 3;
2245 prepareReviewFirstPage(
2246 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2249 if (validWarningCtx) {
2250 if (reviewWithWarnCtx.warning->predefinedSet & (1 <<
W3C_ISSUE_WARN)) {
2252 predefinedTipBoxText =
"Transaction Check unavailable.\nBlind signing required.";
2255 predefinedTipBoxText =
"Transaction Check unavailable";
2260 predefinedTipBoxText =
"Critical threat detected.\nBlind signing required.";
2263 predefinedTipBoxText =
"Critical threat detected.";
2268 predefinedTipBoxText =
"Potential risk detected.\nBlind signing required.";
2271 predefinedTipBoxText =
"Potential risk detected.";
2276 predefinedTipBoxText
2277 =
"No threat detected by Transaction Check but blind signing required.";
2280 predefinedTipBoxText =
"No threat detected by Transaction Check.";
2284 predefinedTipBoxText =
"Blind signing required.";
2287 if ((tipBox != NULL) || (predefinedTipBoxText != NULL)) {
2289 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
2290 if (predefinedTipBoxText != NULL) {
2291 STARTING_CONTENT.content.extendedCenter.tipBox.icon = NULL;
2292 STARTING_CONTENT.content.extendedCenter.tipBox.text = predefinedTipBoxText;
2295 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
2296 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
2298 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
2299 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
2304 memcpy(&localContentsList[1].content.tagValueList,
2312 prepareReviewLightLastPage(&localContentsList[2].content.infoButton, icon, finishTitle);
2316 prepareReviewLastPage(&localContentsList[2].content.infoLongPress, icon, finishTitle);
2320 uint8_t nbPages = getNbPagesForGenericContents(
2322 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
2325 if (playNotifSound) {
2326#ifdef HAVE_PIEZO_SOUND
2327 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
2331 displayGenericContextPage(0,
true);
2337 const char *reviewTitle,
2338 const char *reviewSubTitle,
2340 bool playNotifSound)
2343 memset(&genericContext, 0,
sizeof(genericContext));
2345 bundleNavContext.reviewStreaming.operationType = operationType;
2346 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
2347 bundleNavContext.reviewStreaming.icon = icon;
2350 onChoice = bundleNavReviewStreamingChoice;
2351 navType = STREAMING_NAV;
2354 genericContext.genericContents.contentsList = localContentsList;
2355 genericContext.genericContents.nbContents = 1;
2360 prepareReviewFirstPage(
2361 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2364 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
2371 if (playNotifSound) {
2372#ifdef HAVE_PIEZO_SOUND
2373 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
2377 displayGenericContextPage(0,
true);
2396static void useCaseHomeExt(
const char *appName,
2398 const char *tagline,
2407 .centeredInfo.text1 = appName,
2408 .centeredInfo.text3 = NULL,
2410 .centeredInfo.offsetY = 0,
2413 .tapActionText = NULL,
2415 .topRightToken = CONTINUE_TOKEN,
2416 .tuneId = TUNE_TAP_CASUAL};
2417 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
2432 if (tagline == NULL) {
2436 "This app enables signing\ntransactions on its network.");
2463 onContinue = topRightCallback;
2464 onQuit = quitCallback;
2478static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
2480 memset(&detailsContext, 0,
sizeof(detailsContext));
2486 detailsContext.tag = tag;
2487 detailsContext.value = value;
2488 detailsContext.nbPages = (nbLines + NB_MAX_LINES_IN_DETAILS - 1) / NB_MAX_LINES_IN_DETAILS;
2489 detailsContext.currentPage = 0;
2490 detailsContext.wrapping = wrapping;
2492 if (detailsContext.nbPages > 1) {
2493 uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3;
2497 = nbLines - ((detailsContext.nbPages - 1) * NB_MAX_LINES_IN_DETAILS);
2499 detailsContext.nbPages += nbLostLines / NB_MAX_LINES_IN_DETAILS;
2500 if ((nbLinesInLastPage + (nbLostLines % NB_MAX_LINES_IN_DETAILS))
2501 > NB_MAX_LINES_IN_DETAILS) {
2502 detailsContext.nbPages++;
2506 displayDetailsPage(0,
true);
2528 bool *requireSpecificDisplay)
2531 nbPairs, tagValueList, startIndex,
false, requireSpecificDisplay);
2551 bool *requireSpecificDisplay)
2554 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2560 maxUsableHeight -= TOUCHABLE_HEADER_BAR_HEIGHT - SMALL_CENTERING_HEADER;
2563 *requireSpecificDisplay =
false;
2564 while (nbPairsInPage < nbPairs) {
2571 if (nbPairsInPage > 0) {
2572 currentHeight += INTER_TAG_VALUE_MARGIN;
2575 if (tagValueList->
pairs != NULL) {
2576 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2579 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2588 if (nbPairsInPage > 0) {
2595 *requireSpecificDisplay =
true;
2607 value_font = SMALL_REGULAR_FONT;
2610 value_font = LARGE_MEDIUM_FONT;
2618 if ((currentHeight >= maxUsableHeight) || (nbLines > NB_MAX_LINES_IN_REVIEW)) {
2619 if (nbPairsInPage == 0) {
2623 *requireSpecificDisplay =
true;
2629 return nbPairsInPage;
2649 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2650 const char *
const *infoTypes = PIC(infosList->
infoTypes);
2651 const char *
const *infoContents = PIC(infosList->
infoContents);
2653 while (nbInfosInPage < nbInfos) {
2655 currentHeight += PRE_TEXT_MARGIN;
2659 SMALL_BOLD_FONT, PIC(infoTypes[startIndex + nbInfosInPage]),
AVAILABLE_WIDTH,
true);
2661 currentHeight += TEXT_SUBTEXT_MARGIN;
2665 PIC(infoContents[startIndex + nbInfosInPage]),
2668 currentHeight += POST_SUBTEXT_MARGIN;
2673 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2678 previousHeight = currentHeight;
2681 return nbInfosInPage;
2701 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2704 while (nbSwitchesInPage < nbSwitches) {
2706 currentHeight += PRE_TEXT_MARGIN;
2710 switchArray[startIndex + nbSwitchesInPage].text,
2714 currentHeight += TEXT_SUBTEXT_MARGIN;
2719 switchArray[startIndex + nbSwitchesInPage].subText,
2722 currentHeight += POST_SUBTEXT_MARGIN;
2727 previousHeight = currentHeight;
2732 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2735 return nbSwitchesInPage;
2755 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2760 while (nbBarsInPage < nbBars) {
2761 currentHeight += TOUCHABLE_BAR_HEIGHT;
2766 previousHeight = currentHeight;
2771 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2774 return nbBarsInPage;
2794 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
2796 UNUSED(choicesList);
2799 while (nbChoicesInPage < nbChoices) {
2800 currentHeight += TOUCHABLE_BAR_HEIGHT;
2805 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
2810 previousHeight = currentHeight;
2813 return nbChoicesInPage;
2830 while (i < tagValueList->nbPairs) {
2834 nbPairs -= nbPairsInPage;
2846 const char *tagline,
2853 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
2862 const char *tagline,
2864 const char *actionButtonText,
2872 .text = actionButtonText};
2875 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
2901 onQuit = quitCallback;
2902 onNav = navCallback;
2903 onControls = controlsCallback;
2905 navType = SETTINGS_NAV;
2908 prepareNavInfo(
false, nbPages, NULL);
2910 displaySettingsPage(initPage,
true);
2928 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
2950 memset(&genericContext, 0,
sizeof(genericContext));
2953 onQuit = quitCallback;
2954 pageTitle = appName;
2955 navType = GENERIC_NAV;
2957 if (settingContents != NULL) {
2960 if (infosList != NULL) {
2961 genericContext.hasFinishingContent =
true;
2964 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
2968 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
2969 if (infosList != NULL) {
2970 nbPages += nbgl_useCaseGetNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
2973 prepareNavInfo(
false, nbPages, NULL);
2975 displayGenericContextPage(initPage,
true);
3014 const char *appName,
3016 const char *tagline,
3024 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
3026 context->appName = appName;
3027 context->appIcon = appIcon;
3028 context->tagline = tagline;
3029 context->settingContents = settingContents;
3030 context->infosList = infosList;
3031 if (action != NULL) {
3037 context->quitCallback = quitCallback;
3040 bundleNavStartSettingsAtPage(initSettingPage);
3043 bundleNavStartHome();
3059 .tickerIntervale = 0,
3062 onQuit = quitCallback;
3064#ifdef HAVE_PIEZO_SOUND
3065 io_seproxyhal_play_tune(TUNE_LEDGER_MOMENT);
3073 .centeredInfo.icon = &DENIED_CIRCLE_ICON,
3074 .centeredInfo.offsetY = SMALL_FOOTER_HEIGHT / 2,
3075 .centeredInfo.onTop =
false,
3077 .centeredInfo.text1 = message,
3078 .centeredInfo.text2 = NULL,
3079 .centeredInfo.text3 = NULL,
3080 .tapActionText =
"",
3081 .isSwipeable =
false,
3082 .tapActionToken = QUIT_TOKEN,
3084 .actionButtonText = NULL,
3085 .tuneId = TUNE_TAP_CASUAL};
3102 switch (reviewStatusType) {
3104 msg =
"Operation signed";
3108 msg =
"Operation rejected";
3112 msg =
"Transaction signed";
3116 msg =
"Transaction rejected";
3120 msg =
"Message signed";
3124 msg =
"Message rejected";
3128 msg =
"Address verified";
3132 msg =
"Address verification\ncancelled";
3154 const char *message,
3155 const char *subMessage,
3156 const char *confirmText,
3157 const char *cancelText,
3164 .centeredInfo.text2 = subMessage,
3165 .centeredInfo.text3 = NULL,
3167 .centeredInfo.icon = icon,
3168 .centeredInfo.offsetY = 0,
3169 .confirmationText = confirmText,
3170 .confirmationToken = CHOICE_TOKEN,
3171 .tuneId = TUNE_TAP_CASUAL,
3174 if ((confirmText == NULL) || (cancelText == NULL)) {
3177 onChoice = callback;
3196 const char *subMessage,
3197 const char *confirmText,
3198 const char *cancelText,
3204 .centeredInfo.text1 = message,
3205 .centeredInfo.text2 = subMessage,
3206 .centeredInfo.text3 = NULL,
3208 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
3209 .centeredInfo.offsetY = 0,
3210 .confirmationText = confirmText,
3211 .confirmationToken = CHOICE_TOKEN,
3212 .tuneId = TUNE_TAP_CASUAL,
3214 onModalConfirm = callback;
3215 if (modalPageContext != NULL) {
3234 const char *reviewTitle,
3235 const char *reviewSubTitle,
3236 const char *rejectText,
3243 .footerToken = QUIT_TOKEN,
3244 .tapActionText = NULL,
3245 .isSwipeable =
true,
3246 .tapActionToken = CONTINUE_TOKEN,
3248 .actionButtonText = NULL,
3249 .
tuneId = TUNE_TAP_CASUAL};
3256 onQuit = rejectCallback;
3257 onContinue = continueCallback;
3259#ifdef HAVE_PIEZO_SOUND
3261 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3274 const char *rejectText,
3282 onChoice = choiceCallback;
3283 onNav = navCallback;
3284 onControls = buttonCallback;
3285 forwardNavOnly =
false;
3286 navType = REVIEW_NAV;
3290 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3292 displayReviewPage(initPage,
true);
3309 const char *rejectText,
3315 memset(&genericContext, 0,
sizeof(genericContext));
3318 onChoice = callback;
3319 navType = GENERIC_NAV;
3323 genericContext.genericContents.contentsList = localContentsList;
3326 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
3328 memcpy(&localContentsList[offset].content.tagValueList,
3335 memcpy(&localContentsList[offset].content.infoLongPress,
3341 genericContext.genericContents.nbContents = offset;
3344 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3346 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3348 displayGenericContextPage(0,
true);
3366 const char *rejectText,
3372 memset(&genericContext, 0,
sizeof(genericContext));
3375 onChoice = callback;
3376 navType = GENERIC_NAV;
3379 genericContext.genericContents.contentsList = localContentsList;
3382 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
3384 memcpy(&localContentsList[offset].content.tagValueList,
3398 genericContext.genericContents.nbContents = offset;
3401 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3403 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
3405 displayGenericContextPage(0,
true);
3427 const char *reviewTitle,
3428 const char *reviewSubTitle,
3429 const char *finishTitle,
3432 useCaseReview(operationType,
3467 const char *reviewTitle,
3468 const char *reviewSubTitle,
3469 const char *finishTitle,
3480 &blindSigningWarning,
3509 const char *reviewTitle,
3510 const char *reviewSubTitle,
3511 const char *finishTitle,
3517 if (tipBox != NULL) {
3518 memcpy(&activeTipBox, tipBox,
sizeof(activeTipBox));
3521 memset(&activeTipBox, 0,
sizeof(activeTipBox));
3524 if ((warning == NULL)
3527 useCaseReview(operationType,
3541 operationType |= NO_THREAT_OPERATION;
3544 operationType |= RISKY_OPERATION;
3547 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
3548 reviewWithWarnCtx.isStreaming =
false;
3549 reviewWithWarnCtx.operationType = operationType;
3550 reviewWithWarnCtx.tagValueList = tagValueList;
3551 reviewWithWarnCtx.icon = icon;
3552 reviewWithWarnCtx.reviewTitle = reviewTitle;
3553 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
3554 reviewWithWarnCtx.finishTitle = finishTitle;
3555 reviewWithWarnCtx.warning = warning;
3556 reviewWithWarnCtx.choiceCallback = choiceCallback;
3562 useCaseReview(operationType,
3576 displayInitialWarning();
3598 const char *reviewTitle,
3599 const char *reviewSubTitle,
3600 const char *finishTitle,
3603 useCaseReview(operationType,
3625 const char *rejectText,
3629 memset(&genericContext, 0,
sizeof(genericContext));
3632 onQuit = rejectCallback;
3633 navType = GENERIC_NAV;
3640 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3641 prepareNavInfo(
true, nbPages, rejectText);
3644#ifdef HAVE_PIEZO_SOUND
3646 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3649 displayGenericContextPage(0,
true);
3666 const char *reviewTitle,
3667 const char *reviewSubTitle,
3670 useCaseReviewStreamingStart(
3671 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3689 const char *reviewTitle,
3690 const char *reviewSubTitle,
3694 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
3714 const char *reviewTitle,
3715 const char *reviewSubTitle,
3720 if ((warning == NULL)
3723 useCaseReviewStreamingStart(
3724 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3728 operationType |= NO_THREAT_OPERATION;
3731 operationType |= RISKY_OPERATION;
3733 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
3735 reviewWithWarnCtx.isStreaming =
true;
3736 reviewWithWarnCtx.operationType = operationType;
3737 reviewWithWarnCtx.icon = icon;
3738 reviewWithWarnCtx.reviewTitle = reviewTitle;
3739 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
3740 reviewWithWarnCtx.choiceCallback = choiceCallback;
3741 reviewWithWarnCtx.warning = warning;
3747 useCaseReviewStreamingStart(
3748 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3751 displayInitialWarning();
3772 memset(&genericContext, 0,
sizeof(genericContext));
3774 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3775 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
3778 onChoice = bundleNavReviewStreamingChoice;
3779 navType = STREAMING_NAV;
3782 genericContext.genericContents.contentsList = localContentsList;
3783 genericContext.genericContents.nbContents = 1;
3792 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3793 &genericContext.genericContents,
3796 prepareNavInfo(
true,
3798 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3806 displayGenericContextPage(0,
true);
3837 memset(&genericContext, 0,
sizeof(genericContext));
3839 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3842 onChoice = bundleNavReviewStreamingChoice;
3843 navType = STREAMING_NAV;
3846 genericContext.genericContents.contentsList = localContentsList;
3847 genericContext.genericContents.nbContents = 1;
3852 prepareReviewLastPage(&STARTING_CONTENT.content.infoLongPress,
3853 bundleNavContext.reviewStreaming.icon,
3857 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3858 &genericContext.genericContents,
3861 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3863 displayGenericContextPage(0,
true);
3875 memset(&genericContext, 0,
sizeof(genericContext));
3876 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
3879 onChoice = callback;
3880 navType = GENERIC_NAV;
3883 genericContext.genericContents.contentsList = localContentsList;
3884 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
3886 prepareAddressConfirmationPages(
3887 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
3890 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3892 prepareNavInfo(
true, nbPages,
"Cancel");
3894#ifdef HAVE_PIEZO_SOUND
3896 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3899 displayGenericContextPage(0,
true);
3921 const char *reviewTitle,
3922 const char *reviewSubTitle,
3926 memset(&genericContext, 0,
sizeof(genericContext));
3928 if (addressConfirmationContext.modalLayout) {
3931 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
3934 onChoice = choiceCallback;
3935 navType = GENERIC_NAV;
3939 genericContext.genericContents.contentsList = localContentsList;
3940 genericContext.genericContents.nbContents = (additionalTagValueList == NULL) ? 2 : 3;
3945 prepareReviewFirstPage(
3946 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3947 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
3950 prepareAddressConfirmationPages(
3951 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
3954 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3956 prepareNavInfo(
true, nbPages,
"Cancel");
3958#ifdef HAVE_PIEZO_SOUND
3960 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3963 displayGenericContextPage(0,
true);
3977 if (genericContext.type != USE_CASE_SPINNER) {
3978 memset(&genericContext, 0,
sizeof(genericContext));
3979 genericContext.type = USE_CASE_SPINNER;
3984 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
3987 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
3994 genericContext.spinnerPosition++;
3997 genericContext.spinnerPosition = 0;
4000 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4004 else if (ret == 2) {
4035 tune_index_e tuneId,
4039 keypadGenericUseCase(title,
4046 validatePinCallback,
4073 tune_index_e tuneId,
4077 keypadGenericUseCase(title,
4084 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)
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)
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)
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)
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