Skip to content

Commit

Permalink
Merge pull request #587 from LedgerHQ/fix/apa/nbgl_eip712_v0
Browse files Browse the repository at this point in the history
Fix NBGL EIP-712 v0
  • Loading branch information
apaillier-ledger authored May 23, 2024
2 parents 78c1c88 + 7ad2e89 commit a864510
Showing 1 changed file with 16 additions and 35 deletions.
51 changes: 16 additions & 35 deletions src_nbgl/ui_sign_712_v0.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include <string.h> // explicit_bzero
#include "os_utils.h" // ARRAYLEN
#include "common_ui.h"
#include "ui_nbgl.h"
#include "common_712.h"
#include "network.h"
#include "ui_message_signing.h"
#include "ui_signing.h"
#include "uint_common.h"

static nbgl_contentTagValue_t pairs[2];
static nbgl_contentTagValueList_t pairsList;

static void messageReviewChoice_cb(bool confirm) {
static void message_review_choice(bool confirm) {
if (confirm) {
nbgl_useCaseStatus("MESSAGE\nSIGNED", true, ui_message_712_approved);
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved);
} else {
nbgl_useCaseStatus("Message signing\ncancelled", false, ui_message_712_rejected);
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_message_712_rejected);
}
}

Expand All @@ -22,7 +22,7 @@ static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size,
return buffer + offset;
}

static void setTagValuePairs(void) {
void ui_sign_712_v0(void) {
explicit_bzero(pairs, sizeof(pairs));
explicit_bzero(&pairsList, sizeof(pairsList));

Expand All @@ -37,34 +37,15 @@ static void setTagValuePairs(void) {
sizeof(strings.tmp.tmp),
70);

pairsList.nbPairs = 2;
pairsList.nbPairs = ARRAYLEN(pairs);
pairsList.pairs = pairs;
pairsList.smallCaseForValue = false;
pairsList.nbMaxLinesForValue = NB_MAX_LINES_IN_REVIEW;
pairsList.wrapping = false;
}

static void more_data_cb(bool confirm) {
if (confirm) {
if (g_position != UI_SIGNING_POSITION_SIGN) {
setTagValuePairs();
nbgl_useCaseReviewStreamingContinue(&pairsList, more_data_cb);
// Switch to signature
g_position = UI_SIGNING_POSITION_SIGN;
} else {
// the last page must contain a long press button
nbgl_useCaseReviewStreamingFinish(TEXT_SIGN_EIP712, messageReviewChoice_cb);
}
} else {
ui_message_712_rejected();
}
}

void ui_sign_712_v0(void) {
g_position = UI_SIGNING_POSITION_START;
nbgl_useCaseReviewStreamingStart(TYPE_MESSAGE,
&C_Review_64px,
TEXT_REVIEW_EIP712,
NULL,
more_data_cb);
pairsList.nbMaxLinesForValue = 0;

nbgl_useCaseReview(TYPE_MESSAGE,
&pairsList,
&C_Review_64px,
TEXT_REVIEW_EIP712,
NULL,
TEXT_SIGN_EIP712,
message_review_choice);
}

0 comments on commit a864510

Please sign in to comment.