Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify and enrich W3C Use Cases (and related ones) #871

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib_nbgl/doc/nbgl_use_case.dox
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ A few APIs are available to draw typical Use-Cases, such as:
- @ref nbgl_useCaseReviewLight() to draw the pages of a transaction review with a simple button confirmation, when all info are available from the beginning (see @subpage use_case_review_light)
- @ref nbgl_useCaseReviewStreamingStart() to draw the pages of a regular coin transaction review, when all info are not available from the beginning (see @subpage use_case_review_streaming)
- for reviews with a warning prolog:
- @ref nbgl_useCaseReviewWithWarning() to draw the pages of a regular coin transaction review, when all info are available from the beginning, but with an identified risk requiring a warning prolog (see @subpage use_case_review_with_warning)
- @ref nbgl_useCaseReviewStreamingWithWarningStart() to draw the pages of a regular coin transaction review, when all info are not available from the beginning, but with an identified risk requiring a warning prolog (see @subpage use_case_review_with_warning and @subpage use_case_review_streaming)
- @ref nbgl_useCaseAdvancedReview() to draw the pages of a regular coin transaction review, when all info are available from the beginning, but with an identified risk requiring a warning prolog (see @subpage use_case_review_with_warning)
- @ref nbgl_useCaseAdvancedReviewStreamingStart() to draw the pages of a regular coin transaction review, when all info are not available from the beginning, but with an identified risk requiring a warning prolog (see @subpage use_case_review_with_warning and @subpage use_case_review_streaming)
- for address verification:
- @ref nbgl_useCaseAddressReview() to draw an address confirmation page, with a possibility to see it as QR Code and some extra tag/value pairs (see @subpage use_case_addr_review)
- for keypad:
Expand Down Expand Up @@ -469,7 +469,7 @@ The review itself behaves like in @subpage use_case_review. The main differences
- The review itself is preceded by a warning page offering the possibility to cancel the review ("Back to safety") or to start it ("Continue anyway")
- In the first and last pages of the actual review, a top-right button offers the possibility to get more information about the warning

The API to initiate the display of the series of pages is @ref nbgl_useCaseReviewWithWarning(), providing:
The API to initiate the display of the series of pages is @ref nbgl_useCaseAdvancedReview(), providing:

- the type of operation to review (transaction, message or generic operation)
- the list of tag/value pairs (or a callback to get them one by one)
Expand Down Expand Up @@ -507,13 +507,13 @@ static void onReviewResult(bool confirm) {
}

void staticReview(void) {
warningDesc.predefinedSet = (1 << W3C_LOSING_SWAP_WARN) | (1 << BLIND_SIGNING_WARN);
warningDesc.predefinedSet = (1 << W3C_RISK_DETECTED_WARN) | (1 << BLIND_SIGNING_WARN);
warningDesc.reportProvider = "Blockaid";
warningDesc.providerMessage = "Losing swap";
warningDesc.reportUrl = "url.com/od24xz";

// static review, providing the whole list of pairs
nbgl_useCaseReviewWithWarning(TYPE_TRANSACTION, // type of operation
nbgl_useCaseAdvancedReview(TYPE_TRANSACTION, // type of operation
&pairList, // list of tag/value pairs
coinIcon, // icon of the coin
"Review transaction\nto send coin", // title of the first page
Expand Down Expand Up @@ -615,7 +615,7 @@ static void onReviewResult(bool confirm) {

void staticReview(void) {
// static review, providing the whole list of pairs
nbgl_useCaseReviewWithWarning(TYPE_TRANSACTION, // type of operation
nbgl_useCaseAdvancedReview(TYPE_TRANSACTION, // type of operation
&pairList, // list of tag/value pairs
coinIcon, // icon of the coin
"Review transaction\nto send coin", // title of the first page
Expand Down
Binary file added lib_nbgl/glyphs/32px/Question_32px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib_nbgl/glyphs/40px/Question_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib_nbgl/glyphs/64px/Info_Circle_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ typedef enum {
NO_ALIAS_TYPE = 0,
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
QR_CODE_ALIAS, ///< alias is an address to be displayed as a QR Code
INFO_LIST_ALIAS ///< alias is list of infos
} nbgl_contentValueAliasType_t;

/**
Expand All @@ -153,7 +154,8 @@ typedef struct {
///< only used if aliasType is @ref NO_ALIAS_TYPE
const char *title; ///< if not NULL and aliasType is @ref QR_CODE_ALIAS, is used as title of
///< the QR Code
nbgl_contentValueAliasType_t aliasType; ///< type of alias
const struct nbgl_contentInfoList_s *infolist; ///< if aliasType is INFO_LIST_ALIAS
nbgl_contentValueAliasType_t aliasType; ///< type of alias
} nbgl_contentValueExt_t;

/**
Expand All @@ -172,8 +174,8 @@ typedef struct {
int8_t forcePageStart : 1; ///< if set to 1, the tag will be displayed at the top of a new
///< review page
int8_t centeredInfo : 1; ///< if set to 1, the tag will be displayed as a centered info
int8_t aliasValue : 1; ///< if set to 1, the value represents an alias and an icon enables to
///< view the full value
int8_t aliasValue : 1; ///< if set to 1, the value represents an alias and an > icon enables to
///< view the full value (extension field in union)
#endif
} nbgl_contentTagValue_t;

Expand Down Expand Up @@ -279,7 +281,7 @@ typedef struct nbgl_pageSwitchesList_s {
/**
* @brief This structure contains data to build a @ref INFOS_LIST content
*/
typedef struct {
typedef struct nbgl_contentInfoList_s {
const char *const *infoTypes; ///< array of types of infos (in black/bold)
const char *const *infoContents; ///< array of contents of infos (in black)
const nbgl_contentValueExt_t
Expand Down
41 changes: 18 additions & 23 deletions lib_nbgl/include/nbgl_use_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ typedef struct {
const char *modalTitle; ///< title given to modal window displayed when tip-box is touched
nbgl_contentType_t type; ///< type of page content in the following union
union {
nbgl_contentInfoList_t infos; ///< infos pairs displayed in modal.
nbgl_contentInfoList_t
infos; ///< infos pairs displayed in modal, if type is @ref INFOS_LIST.
};
} nbgl_tipBox_t;

Expand Down Expand Up @@ -235,10 +236,11 @@ typedef struct nbgl_warningDetails_s {
*
*/
typedef enum {
BLIND_SIGNING_WARN = 0, ///< Blind signing
W3C_ISSUE_WARN, ///< Web3 Checks issue
W3C_LOSING_SWAP_WARN, ///< Web3 Checks: Losing Swap risk
W3C_THREAT_DETECTED_WARN, ///< Web3 Checks: Thread detexted, malicious (know drainer)
W3C_ISSUE_WARN = 0, ///< Web3 Checks issue (not available)
W3C_RISK_DETECTED_WARN, ///< Web3 Checks: Risk detected (see reportRisk field)
W3C_THREAT_DETECTED_WARN, ///< Web3 Checks: Threat detected (see reportRisk field)
W3C_NO_THREAT_WARN, ///< Web3 Checks: No Threat detected
BLIND_SIGNING_WARN, ///< Blind signing
NB_WARNING_TYPES
} nbgl_warningType_t;

Expand All @@ -252,10 +254,11 @@ typedef enum {
*
*/
typedef struct {
uint32_t predefinedSet; ///< bitfield of pre-defined warnings, to be taken in @ref
///< nbgl_warningType_t set it to 0 if not using pre-defined warnings
uint32_t predefinedSet; ///< bitfield of pre-defined warnings, to be taken in @ref
///< nbgl_warningType_t set it to 0 if not using pre-defined warnings
const char *dAppProvider; ///< name of the dApp provider, used in some strings
const char *reportUrl; ///< URL of the report, used in some strings
const char *reportProvider; ///< name of the security report provider, used in some strings
const char *reportUrl; ///< URL of the report, used in some strings
const char *providerMessage; ///< Dedicated provider message. Default one will be used if NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we'll need a second buffer, in the very specific cases Other risk or Other threat, where we have to display a different string between pre-transaction warning screen and security report screen?

const nbgl_warningDetails_t
*introDetails; ///< details displayed when top-right button is touched in intro page
Expand Down Expand Up @@ -348,22 +351,14 @@ void nbgl_useCaseReviewBlindSigning(nbgl_operationType_t operationT
const char *finishTitle,
const nbgl_tipBox_t *tipBox,
nbgl_choiceCallback_t choiceCallback);
void nbgl_useCaseReviewWithWarning(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);
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);

void nbgl_useCaseReviewLight(nbgl_operationType_t operationType,
Expand Down Expand Up @@ -396,12 +391,12 @@ void nbgl_useCaseReviewStreamingBlindSigningStart(nbgl_operationType_t ope
const char *reviewSubTitle,
nbgl_choiceCallback_t choiceCallback);

void nbgl_useCaseReviewStreamingWithWarningStart(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_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_useCaseReviewStreamingContinueExt(const nbgl_contentTagValueList_t *tagValueList,
nbgl_choiceCallback_t choiceCallback,
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/src/nbgl_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static void touchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType)
return;
}
LOG_DEBUG(LAYOUT_LOGGER, "touchCallback(): layout->callback = %p\n", layout->callback);
if (layout->callback != NULL) {
if ((layout->callback != NULL) && (layoutObj->token != NBGL_INVALID_TOKEN)) {
#ifdef HAVE_PIEZO_SOUND
if (layoutObj->tuneId < NBGL_NO_TUNE) {
io_seproxyhal_play_tune(layoutObj->tuneId);
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/src/nbgl_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void addContent(nbgl_pageContent_t *content,
break;

case EXTENDED_CENTER:
if ((!headerAdded) && (content->extendedCenter.tipBox.text == NULL)) {
if (!headerAdded) {
addEmptyHeader(layout, SMALL_CENTERING_HEADER);
}
nbgl_layoutAddContentCenter(layout, &content->extendedCenter.contentCenter);
Expand Down
Loading
Loading