stax eip712
This commit is contained in:
+16
-4
@@ -8,16 +8,17 @@ static const char* const infoContents[] = {APPVERSION, "(c) 2022 Ledger"};
|
||||
enum {
|
||||
BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN,
|
||||
DEBUG_TOKEN,
|
||||
NONCE_TOKEN
|
||||
NONCE_TOKEN,
|
||||
EIP712_VERBOSE_TOKEN
|
||||
};
|
||||
|
||||
static nbgl_layoutSwitch_t switches[3];
|
||||
static nbgl_layoutSwitch_t switches[4];
|
||||
|
||||
static bool navCallback(uint8_t page, nbgl_pageContent_t* content) {
|
||||
switches[0] = (nbgl_layoutSwitch_t) {
|
||||
.initState = N_storage.dataAllowed ? ON_STATE : OFF_STATE,
|
||||
.text = "Blind signing",
|
||||
.subText = "Enable transaction blind\nsigning",
|
||||
.subText = "Enable transaction blind signing",
|
||||
.token = BLIND_SIGNING_TOKEN,
|
||||
.tuneId = TUNE_TAP_CASUAL
|
||||
};
|
||||
@@ -35,12 +36,19 @@ static bool navCallback(uint8_t page, nbgl_pageContent_t* content) {
|
||||
.token = NONCE_TOKEN,
|
||||
.tuneId = TUNE_TAP_CASUAL
|
||||
};
|
||||
switches[3] = (nbgl_layoutSwitch_t) {
|
||||
.initState = N_storage.verbose_eip712 ? ON_STATE : OFF_STATE,
|
||||
.text = "Verbose EIP712",
|
||||
.subText = "Ignore filtering and\ndisplay raw content",
|
||||
.token = EIP712_VERBOSE_TOKEN,
|
||||
.tuneId = TUNE_TAP_CASUAL
|
||||
};
|
||||
|
||||
switch (page)
|
||||
{
|
||||
case 0:
|
||||
content->type = SWITCHES_LIST;
|
||||
content->switchesList.nbSwitches = 3;
|
||||
content->switchesList.nbSwitches = 4;
|
||||
content->switchesList.switches = (nbgl_layoutSwitch_t*)switches;
|
||||
break;
|
||||
|
||||
@@ -75,6 +83,10 @@ static void controlsCallback(int token, uint8_t index) {
|
||||
value = (N_storage.displayNonce ? 0 : 1);
|
||||
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
|
||||
break;
|
||||
case EIP712_VERBOSE_TOKEN:
|
||||
value = (N_storage.verbose_eip712 ? 0 : 1);
|
||||
nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(uint8_t));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+62
-3
@@ -1,6 +1,65 @@
|
||||
#include "common_ui.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "ui_logic.h"
|
||||
#include "common_712.h"
|
||||
#include "nbgl_use_case.h"
|
||||
|
||||
void ui_712_start(void) {}
|
||||
void ui_712_switch_to_message(void) {}
|
||||
void ui_712_switch_to_sign(void) {}
|
||||
// 4 pairs of tag/value to display
|
||||
static nbgl_layoutTagValue_t tlv;
|
||||
|
||||
static void reject_message(void) {
|
||||
ui_712_reject(NULL);
|
||||
}
|
||||
|
||||
static void sign_message() {
|
||||
ui_712_approve(NULL);
|
||||
}
|
||||
|
||||
static void reviewChoice(bool confirm) {
|
||||
if (confirm) {
|
||||
sign_message();
|
||||
} else {
|
||||
reject_message();
|
||||
}
|
||||
}
|
||||
static bool displaySignPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
content->type = INFO_LONG_PRESS,
|
||||
content->infoLongPress.icon = &C_badge_transaction_56;
|
||||
content->infoLongPress.text = "Sign typed message";
|
||||
content->infoLongPress.longPressText = "Hold to confirm";
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
||||
if (page == 0) {
|
||||
tlv.item = strings.tmp.tmp2;
|
||||
tlv.value = strings.tmp.tmp;
|
||||
content->type = TAG_VALUE_LIST;
|
||||
content->tagValueList.nbPairs = 1;
|
||||
content->tagValueList.pairs = &tlv;
|
||||
return true;
|
||||
} else {
|
||||
switch (ui_712_next_field()) {
|
||||
case EIP712_NO_MORE_FIELD:
|
||||
return displaySignPage(page, content);
|
||||
break;
|
||||
case EIP712_FIELD_INCOMING:
|
||||
case EIP712_FIELD_LATER:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ui_712_switch_to_sign(void) {
|
||||
nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displaySignPage, reviewChoice);
|
||||
}
|
||||
|
||||
void ui_712_start(void) {
|
||||
nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice);
|
||||
}
|
||||
|
||||
void ui_712_switch_to_message(void) {
|
||||
nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user