Port 'nbgl_useCaseSettings' to 'nbgl_useCaseHomeAndSettings'
This commit is contained in:
@@ -13,6 +13,7 @@ void ui_display_public_key(const uint64_t *chain_id);
|
|||||||
void ui_sign_712_v0(void);
|
void ui_sign_712_v0(void);
|
||||||
void ui_confirm_selector(void);
|
void ui_confirm_selector(void);
|
||||||
void ui_confirm_parameter(void);
|
void ui_confirm_parameter(void);
|
||||||
|
void app_quit(void);
|
||||||
|
|
||||||
// EIP-191
|
// EIP-191
|
||||||
void ui_191_start(void);
|
void ui_191_start(void);
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
#include "ui_nbgl.h"
|
#include "ui_nbgl.h"
|
||||||
#include "nbgl_use_case.h"
|
#include "nbgl_use_case.h"
|
||||||
|
|
||||||
static const char* const infoTypes[] = {"Version", APPNAME " App"};
|
// settings info definition
|
||||||
static const char* const infoContents[] = {APPVERSION, "(c) " BUILD_YEAR " Ledger"};
|
#define SETTING_INFO_NB 2
|
||||||
|
|
||||||
|
// settings menu definition
|
||||||
|
#define SETTING_CONTENTS_NB 1
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN,
|
BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN,
|
||||||
@@ -11,106 +14,69 @@ enum {
|
|||||||
NONCE_TOKEN,
|
NONCE_TOKEN,
|
||||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||||
EIP712_VERBOSE_TOKEN,
|
EIP712_VERBOSE_TOKEN,
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif
|
||||||
#ifdef HAVE_DOMAIN_NAME
|
#ifdef HAVE_DOMAIN_NAME
|
||||||
DOMAIN_NAME_VERBOSE_TOKEN
|
DOMAIN_NAME_VERBOSE_TOKEN
|
||||||
#endif // HAVE_DOMAIN_NAME
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static nbgl_layoutSwitch_t switches[3];
|
enum {
|
||||||
|
BLIND_SIGNING_ID = 0,
|
||||||
static bool navCallback(uint8_t page, nbgl_pageContent_t* content) {
|
DEBUG_ID,
|
||||||
uint8_t index = 0;
|
NONCE_ID,
|
||||||
|
|
||||||
switch (page) {
|
|
||||||
case 0:
|
|
||||||
content->type = INFOS_LIST;
|
|
||||||
content->infosList.nbInfos = 2;
|
|
||||||
content->infosList.infoTypes = (const char**) infoTypes;
|
|
||||||
content->infosList.infoContents = (const char**) infoContents;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
switches[index++] =
|
|
||||||
(nbgl_layoutSwitch_t){.initState = N_storage.dataAllowed ? ON_STATE : OFF_STATE,
|
|
||||||
.text = "Blind signing",
|
|
||||||
.subText = "Enable transaction blind\nsigning",
|
|
||||||
.token = BLIND_SIGNING_TOKEN,
|
|
||||||
.tuneId = TUNE_TAP_CASUAL};
|
|
||||||
switches[index++] =
|
|
||||||
(nbgl_layoutSwitch_t){.initState = N_storage.contractDetails ? ON_STATE : OFF_STATE,
|
|
||||||
.text = "Debug",
|
|
||||||
.subText = "Display contract data\ndetails",
|
|
||||||
.token = DEBUG_TOKEN,
|
|
||||||
.tuneId = TUNE_TAP_CASUAL};
|
|
||||||
switches[index++] =
|
|
||||||
(nbgl_layoutSwitch_t){.initState = N_storage.displayNonce ? ON_STATE : OFF_STATE,
|
|
||||||
.text = "Nonce",
|
|
||||||
.subText = "Display account nonce\nin transaction",
|
|
||||||
.token = NONCE_TOKEN,
|
|
||||||
.tuneId = TUNE_TAP_CASUAL};
|
|
||||||
|
|
||||||
content->type = SWITCHES_LIST;
|
|
||||||
content->switchesList.nbSwitches = index;
|
|
||||||
content->switchesList.switches = (nbgl_layoutSwitch_t*) switches;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||||
switches[index++] =
|
EIP712_VERBOSE_ID,
|
||||||
(nbgl_layoutSwitch_t){.initState = N_storage.verbose_eip712 ? ON_STATE : OFF_STATE,
|
#endif
|
||||||
.text = "Verbose EIP712",
|
|
||||||
.subText = "Ignore filtering and\ndisplay raw content",
|
|
||||||
.token = EIP712_VERBOSE_TOKEN,
|
|
||||||
.tuneId = TUNE_TAP_CASUAL};
|
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
|
||||||
#ifdef HAVE_DOMAIN_NAME
|
#ifdef HAVE_DOMAIN_NAME
|
||||||
switches[index++] = (nbgl_layoutSwitch_t){
|
DOMAIN_NAME_VERBOSE_ID,
|
||||||
.initState = N_storage.verbose_domain_name ? ON_STATE : OFF_STATE,
|
#endif
|
||||||
.text = "Verbose domains",
|
SETTINGS_SWITCHES_NB
|
||||||
.subText = "Show resolved address",
|
};
|
||||||
.token = DOMAIN_NAME_VERBOSE_TOKEN,
|
|
||||||
.tuneId = TUNE_TAP_CASUAL};
|
|
||||||
#endif // HAVE_DOMAIN_NAME
|
|
||||||
|
|
||||||
content->type = SWITCHES_LIST;
|
static uint8_t initSettingPage;
|
||||||
content->switchesList.nbSwitches = index;
|
|
||||||
content->switchesList.switches = (nbgl_layoutSwitch_t*) switches;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
// settings definition
|
||||||
return false;
|
static const char* const infoTypes[SETTING_INFO_NB] = {"Version", APPNAME " App"};
|
||||||
break;
|
static const char* const infoContents[SETTING_INFO_NB] = {APPVERSION, "(c) " BUILD_YEAR " Ledger"};
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
static nbgl_contentInfoList_t infoList = {0};
|
||||||
}
|
static nbgl_contentSwitch_t switches[SETTINGS_SWITCHES_NB] = {0};
|
||||||
|
static nbgl_content_t contents[SETTING_CONTENTS_NB] = {0};
|
||||||
|
static nbgl_genericContents_t settingContents = {0};
|
||||||
|
|
||||||
static void controlsCallback(int token, uint8_t index) {
|
static void controlsCallback(int token, uint8_t index, int page) {
|
||||||
(void) index;
|
UNUSED(index);
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|
||||||
|
initSettingPage = page;
|
||||||
|
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case BLIND_SIGNING_TOKEN:
|
case BLIND_SIGNING_TOKEN:
|
||||||
value = (N_storage.dataAllowed ? 0 : 1);
|
value = (N_storage.dataAllowed ? 0 : 1);
|
||||||
|
switches[BLIND_SIGNING_ID].initState = (nbgl_state_t) value;
|
||||||
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
|
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
case DEBUG_TOKEN:
|
case DEBUG_TOKEN:
|
||||||
value = (N_storage.contractDetails ? 0 : 1);
|
value = (N_storage.contractDetails ? 0 : 1);
|
||||||
|
switches[DEBUG_ID].initState = (nbgl_state_t) value;
|
||||||
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
|
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
case NONCE_TOKEN:
|
case NONCE_TOKEN:
|
||||||
value = (N_storage.displayNonce ? 0 : 1);
|
value = (N_storage.displayNonce ? 0 : 1);
|
||||||
|
switches[NONCE_ID].initState = (nbgl_state_t) value;
|
||||||
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
|
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||||
case EIP712_VERBOSE_TOKEN:
|
case EIP712_VERBOSE_TOKEN:
|
||||||
value = (N_storage.verbose_eip712 ? 0 : 1);
|
value = (N_storage.verbose_eip712 ? 0 : 1);
|
||||||
|
switches[EIP712_VERBOSE_ID].initState = (nbgl_state_t) value;
|
||||||
nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(uint8_t));
|
nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
#ifdef HAVE_DOMAIN_NAME
|
#ifdef HAVE_DOMAIN_NAME
|
||||||
case DOMAIN_NAME_VERBOSE_TOKEN:
|
case DOMAIN_NAME_VERBOSE_TOKEN:
|
||||||
value = (N_storage.verbose_domain_name ? 0 : 1);
|
value = (N_storage.verbose_domain_name ? 0 : 1);
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].initState = (nbgl_state_t) value;
|
||||||
nvm_write((void*) &N_storage.verbose_domain_name, (void*) &value, sizeof(uint8_t));
|
nvm_write((void*) &N_storage.verbose_domain_name, (void*) &value, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
#endif // HAVE_DOMAIN_NAME
|
#endif // HAVE_DOMAIN_NAME
|
||||||
@@ -118,15 +84,60 @@ static void controlsCallback(int token, uint8_t index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ui_menu_settings(void) {
|
void ui_menu_settings(void) {
|
||||||
uint8_t nb_screens = 2;
|
switches[BLIND_SIGNING_ID].initState = N_storage.dataAllowed ? ON_STATE : OFF_STATE;
|
||||||
#if defined(HAVE_EIP712_FULL_SUPPORT) || defined(HAVE_DOMAIN_NAME)
|
switches[BLIND_SIGNING_ID].text = "Blind signing";
|
||||||
nb_screens += 1;
|
switches[BLIND_SIGNING_ID].subText = "Enable transaction blind\nsigning";
|
||||||
#endif
|
switches[BLIND_SIGNING_ID].token = BLIND_SIGNING_TOKEN;
|
||||||
nbgl_useCaseSettings(APPNAME " settings",
|
switches[BLIND_SIGNING_ID].tuneId = TUNE_TAP_CASUAL;
|
||||||
0,
|
|
||||||
nb_screens,
|
switches[DEBUG_ID].initState = N_storage.contractDetails ? ON_STATE : OFF_STATE;
|
||||||
false,
|
switches[DEBUG_ID].text = "Debug";
|
||||||
ui_idle,
|
switches[DEBUG_ID].subText = "Display contract data\ndetails";
|
||||||
navCallback,
|
switches[DEBUG_ID].token = DEBUG_TOKEN;
|
||||||
controlsCallback);
|
switches[DEBUG_ID].tuneId = TUNE_TAP_CASUAL;
|
||||||
|
|
||||||
|
switches[NONCE_ID].initState = N_storage.displayNonce ? ON_STATE : OFF_STATE;
|
||||||
|
switches[NONCE_ID].text = "Nonce";
|
||||||
|
switches[NONCE_ID].subText = "Display account nonce\nin transaction";
|
||||||
|
switches[NONCE_ID].token = NONCE_TOKEN;
|
||||||
|
switches[NONCE_ID].tuneId = TUNE_TAP_CASUAL;
|
||||||
|
|
||||||
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||||
|
switches[EIP712_VERBOSE_ID].initState = N_storage.verbose_eip712 ? ON_STATE : OFF_STATE;
|
||||||
|
switches[EIP712_VERBOSE_ID].text = "Verbose EIP712";
|
||||||
|
switches[EIP712_VERBOSE_ID].subText = "Ignore filtering and\ndisplay raw content";
|
||||||
|
switches[EIP712_VERBOSE_ID].token = EIP712_VERBOSE_TOKEN;
|
||||||
|
switches[EIP712_VERBOSE_ID].tuneId = TUNE_TAP_CASUAL;
|
||||||
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|
||||||
|
#ifdef HAVE_DOMAIN_NAME
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].initState =
|
||||||
|
N_storage.verbose_domain_name ? ON_STATE : OFF_STATE;
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].text = "Verbose domains";
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].subText = "Show resolved address";
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].token = DOMAIN_NAME_VERBOSE_TOKEN;
|
||||||
|
switches[DOMAIN_NAME_VERBOSE_ID].tuneId = TUNE_TAP_CASUAL;
|
||||||
|
#endif // HAVE_DOMAIN_NAME
|
||||||
|
|
||||||
|
contents[0].type = SWITCHES_LIST;
|
||||||
|
contents[0].content.switchesList.nbSwitches = SETTINGS_SWITCHES_NB;
|
||||||
|
contents[0].content.switchesList.switches = switches;
|
||||||
|
contents[0].contentActionCallback = controlsCallback;
|
||||||
|
|
||||||
|
settingContents.callbackCallNeeded = false;
|
||||||
|
settingContents.contentsList = contents;
|
||||||
|
settingContents.nbContents = SETTING_CONTENTS_NB;
|
||||||
|
|
||||||
|
infoList.nbInfos = SETTING_INFO_NB;
|
||||||
|
infoList.infoTypes = infoTypes;
|
||||||
|
infoList.infoContents = infoContents;
|
||||||
|
|
||||||
|
nbgl_useCaseHomeAndSettings(APPNAME,
|
||||||
|
get_app_icon(true),
|
||||||
|
NULL,
|
||||||
|
initSettingPage,
|
||||||
|
&settingContents,
|
||||||
|
&infoList,
|
||||||
|
NULL,
|
||||||
|
app_quit);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user