Skip to content

Commit

Permalink
Port transaction review steps to 'nbgl_useCaseReview' in ui_display_p…
Browse files Browse the repository at this point in the history
…rivacy.c
  • Loading branch information
cedelavergne-ledger committed Apr 15, 2024
1 parent 5836767 commit c85656e
Showing 1 changed file with 22 additions and 36 deletions.
58 changes: 22 additions & 36 deletions src_nbgl/ui_display_privacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "network.h"

static nbgl_layoutTagValue_t pairs[2];
static char *review_string;
static nbgl_layoutTagValueList_t pairsList;

static void reviewReject(void) {
io_seproxyhal_touch_privacy_cancel(NULL);
Expand All @@ -18,52 +18,38 @@ static void confirmTransation(void) {

static void reviewChoice(bool confirm) {
if (confirm) {
confirmTransation();
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, confirmTransation);
} else {
reviewReject();
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, reviewReject);
}
}

static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
if (page == 0) {
pairs[0].item = "Address";
pairs[0].value = strings.common.fullAddress;
pairs[1].item = "Key";
pairs[1].value = strings.common.fullAmount;
static void buildFirstPage(const char *review_string) {
explicit_bzero(pairs, sizeof(pairs));
explicit_bzero(&pairsList, sizeof(pairsList));

content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = review_string;
content->infoLongPress.longPressText = "Hold to approve";
} else {
return false;
}
// valid page so return true
return true;
}
pairs[0].item = "Address";
pairs[0].value = strings.common.fullAddress;

static void reviewContinue(void) {
nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice);
}
pairs[1].item = "Key";
pairs[1].value = strings.common.fullAmount;

pairsList.nbPairs = 2;
pairsList.pairs = pairs;

static void buildFirstPage(void) {
nbgl_useCaseReviewStart(get_app_icon(true),
review_string,
NULL,
REJECT_BUTTON,
reviewContinue,
reviewReject);
nbgl_useCaseReview(TYPE_TRANSACTION,
&pairsList,
get_app_icon(true),
review_string,
NULL,
review_string,
reviewChoice);
}

void ui_display_privacy_public_key(void) {
review_string = (char *) "Provide public\nprivacy key";
buildFirstPage();
buildFirstPage("Provide public\nprivacy key");
}

void ui_display_privacy_shared_secret(void) {
review_string = (char *) "Provide public\nsecret key";
buildFirstPage();
buildFirstPage("Provide public\nsecret key");
}

0 comments on commit c85656e

Please sign in to comment.