2020-06-27 13:24:04 +02:00
|
|
|
#include "shared_context.h"
|
|
|
|
|
#include "ui_callbacks.h"
|
|
|
|
|
|
2021-02-12 11:53:41 +01:00
|
|
|
void display_settings(const ux_flow_step_t* const start_step);
|
2021-09-28 12:32:06 +02:00
|
|
|
void switch_settings_blind_signing(void);
|
2020-06-27 13:24:04 +02:00
|
|
|
void switch_settings_display_data(void);
|
2021-02-05 17:33:12 +01:00
|
|
|
void switch_settings_display_nonce(void);
|
2020-06-27 13:24:04 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format off
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_NOCB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_idle_flow_1_step,
|
|
|
|
|
nn, //pnn,
|
|
|
|
|
{
|
|
|
|
|
//"", //&C_icon_dashboard,
|
|
|
|
|
"Application",
|
|
|
|
|
"is ready",
|
|
|
|
|
});
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_NOCB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_idle_flow_2_step,
|
|
|
|
|
bn,
|
|
|
|
|
{
|
|
|
|
|
"Version",
|
|
|
|
|
APPVERSION,
|
|
|
|
|
});
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_idle_flow_3_step,
|
|
|
|
|
pb,
|
2021-02-12 11:53:41 +01:00
|
|
|
display_settings(NULL),
|
2020-06-27 13:24:04 +02:00
|
|
|
{
|
|
|
|
|
&C_icon_eye,
|
|
|
|
|
"Settings",
|
|
|
|
|
});
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_idle_flow_4_step,
|
|
|
|
|
pb,
|
|
|
|
|
os_sched_exit(-1),
|
|
|
|
|
{
|
|
|
|
|
&C_icon_dashboard_x,
|
|
|
|
|
"Quit",
|
|
|
|
|
});
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format on
|
|
|
|
|
|
2020-06-29 15:43:02 +02:00
|
|
|
UX_FLOW(ux_idle_flow,
|
2020-12-01 16:20:13 +01:00
|
|
|
&ux_idle_flow_1_step,
|
|
|
|
|
&ux_idle_flow_2_step,
|
|
|
|
|
&ux_idle_flow_3_step,
|
|
|
|
|
&ux_idle_flow_4_step,
|
|
|
|
|
FLOW_LOOP);
|
2020-06-27 13:24:04 +02:00
|
|
|
|
|
|
|
|
#if defined(TARGET_NANOS)
|
|
|
|
|
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format off
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_settings_flow_1_step,
|
|
|
|
|
bnnn_paging,
|
2021-09-28 12:32:06 +02:00
|
|
|
switch_settings_blind_signing(),
|
2020-06-27 13:24:04 +02:00
|
|
|
{
|
2021-10-08 10:27:59 +02:00
|
|
|
.title = "Blind signing",
|
2020-06-27 13:24:04 +02:00
|
|
|
.text = strings.common.fullAddress,
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_settings_flow_2_step,
|
|
|
|
|
bnnn_paging,
|
|
|
|
|
switch_settings_display_data(),
|
|
|
|
|
{
|
|
|
|
|
.title = "Debug data",
|
2021-02-12 11:53:41 +01:00
|
|
|
.text = strings.common.fullAddress + 12
|
2020-06-27 13:24:04 +02:00
|
|
|
});
|
|
|
|
|
|
2021-02-05 17:33:12 +01:00
|
|
|
UX_STEP_CB(
|
|
|
|
|
ux_settings_flow_3_step,
|
|
|
|
|
bnnn_paging,
|
|
|
|
|
switch_settings_display_nonce(),
|
|
|
|
|
{
|
|
|
|
|
.title = "Account nonce",
|
2021-02-12 11:53:41 +01:00
|
|
|
.text = strings.common.fullAddress + 26
|
2021-02-05 17:33:12 +01:00
|
|
|
});
|
|
|
|
|
|
2020-06-27 13:24:04 +02:00
|
|
|
#else
|
|
|
|
|
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_settings_flow_1_step,
|
|
|
|
|
bnnn,
|
2021-09-28 12:32:06 +02:00
|
|
|
switch_settings_blind_signing(),
|
2020-06-27 13:24:04 +02:00
|
|
|
{
|
2021-10-08 10:27:59 +02:00
|
|
|
"Blind signing",
|
|
|
|
|
"Enable transaction",
|
|
|
|
|
"blind signing",
|
2020-06-27 13:24:04 +02:00
|
|
|
strings.common.fullAddress,
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2020-06-27 13:24:04 +02:00
|
|
|
ux_settings_flow_2_step,
|
|
|
|
|
bnnn,
|
|
|
|
|
switch_settings_display_data(),
|
|
|
|
|
{
|
|
|
|
|
"Debug data",
|
|
|
|
|
"Display contract data",
|
|
|
|
|
"details",
|
2021-02-12 11:53:41 +01:00
|
|
|
strings.common.fullAddress + 12
|
2020-06-27 13:24:04 +02:00
|
|
|
});
|
2021-02-12 11:53:41 +01:00
|
|
|
|
2021-02-05 17:33:12 +01:00
|
|
|
UX_STEP_CB(
|
|
|
|
|
ux_settings_flow_3_step,
|
|
|
|
|
bnnn,
|
|
|
|
|
switch_settings_display_nonce(),
|
|
|
|
|
{
|
|
|
|
|
"Nonce",
|
|
|
|
|
"Display account nonce",
|
2021-02-12 11:53:41 +01:00
|
|
|
"in transactions",
|
|
|
|
|
strings.common.fullAddress + 26
|
2021-02-05 17:33:12 +01:00
|
|
|
});
|
2020-06-27 13:24:04 +02:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2021-02-05 17:33:12 +01:00
|
|
|
ux_settings_flow_4_step,
|
2020-06-27 13:24:04 +02:00
|
|
|
pb,
|
|
|
|
|
ui_idle(),
|
|
|
|
|
{
|
|
|
|
|
&C_icon_back_x,
|
|
|
|
|
"Back",
|
|
|
|
|
});
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format on
|
2020-06-27 13:24:04 +02:00
|
|
|
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_FLOW(ux_settings_flow,
|
2020-12-01 16:20:13 +01:00
|
|
|
&ux_settings_flow_1_step,
|
|
|
|
|
&ux_settings_flow_2_step,
|
2021-02-05 17:33:12 +01:00
|
|
|
&ux_settings_flow_3_step,
|
|
|
|
|
&ux_settings_flow_4_step);
|
2020-06-27 13:24:04 +02:00
|
|
|
|
2021-02-12 11:53:41 +01:00
|
|
|
void display_settings(const ux_flow_step_t* const start_step) {
|
2021-09-28 12:32:06 +02:00
|
|
|
strlcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Enabled" : "NOT Enabled"), 12);
|
2021-07-16 12:04:39 +02:00
|
|
|
strlcpy(strings.common.fullAddress + 12,
|
|
|
|
|
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"),
|
|
|
|
|
26 - 12);
|
|
|
|
|
strlcpy(strings.common.fullAddress + 26,
|
|
|
|
|
(N_storage.displayNonce ? "Displayed" : "NOT Displayed"),
|
|
|
|
|
sizeof(strings.common.fullAddress) - 26);
|
2021-02-12 11:53:41 +01:00
|
|
|
ux_flow_init(0, ux_settings_flow, start_step);
|
2020-06-27 13:24:04 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 12:32:06 +02:00
|
|
|
void switch_settings_blind_signing() {
|
2020-12-01 16:20:13 +01:00
|
|
|
uint8_t value = (N_storage.dataAllowed ? 0 : 1);
|
|
|
|
|
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
|
2021-02-12 11:53:41 +01:00
|
|
|
display_settings(&ux_settings_flow_1_step);
|
2020-06-27 13:24:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void switch_settings_display_data() {
|
2020-12-01 16:20:13 +01:00
|
|
|
uint8_t value = (N_storage.contractDetails ? 0 : 1);
|
|
|
|
|
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
|
2021-02-12 11:53:41 +01:00
|
|
|
display_settings(&ux_settings_flow_2_step);
|
2020-06-27 13:24:04 +02:00
|
|
|
}
|
2021-02-05 17:33:12 +01:00
|
|
|
|
|
|
|
|
void switch_settings_display_nonce() {
|
|
|
|
|
uint8_t value = (N_storage.displayNonce ? 0 : 1);
|
|
|
|
|
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
|
2021-02-12 11:53:41 +01:00
|
|
|
display_settings(&ux_settings_flow_3_step);
|
2021-02-05 17:33:12 +01:00
|
|
|
}
|
2021-09-28 12:32:06 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// clang-format off
|
|
|
|
|
#if defined(TARGET_NANOS)
|
|
|
|
|
UX_STEP_CB(
|
|
|
|
|
ux_warning_contract_data_step,
|
|
|
|
|
bnnn_paging,
|
|
|
|
|
ui_idle(),
|
|
|
|
|
{
|
|
|
|
|
"Error",
|
2021-10-08 10:27:59 +02:00
|
|
|
"Blind signing must be enabled in Settings",
|
2021-09-28 12:32:06 +02:00
|
|
|
});
|
2022-02-01 16:48:36 +01:00
|
|
|
#elif defined(TARGET_NANOX) || defined(TARGET_NANOS2)
|
2021-09-28 12:32:06 +02:00
|
|
|
UX_STEP_CB(
|
|
|
|
|
ux_warning_contract_data_step,
|
|
|
|
|
pnn,
|
|
|
|
|
ui_idle(),
|
|
|
|
|
{
|
|
|
|
|
&C_icon_crossmark,
|
2021-10-08 10:27:59 +02:00
|
|
|
"Blind signing must be",
|
2021-09-28 12:32:06 +02:00
|
|
|
"enabled in Settings",
|
|
|
|
|
});
|
|
|
|
|
#endif
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
UX_FLOW(ux_warning_contract_data_flow, &ux_warning_contract_data_step);
|