Fix swap issue with nonce update, save a few bytes and improve settings switch feedback

This commit is contained in:
TamtamHero
2021-02-12 11:53:41 +01:00
parent 9874ab4116
commit a96caadc4f
3 changed files with 18 additions and 17 deletions

View File

@@ -158,7 +158,7 @@ typedef struct txStringProperties_t {
char fullAddress[43];
char fullAmount[50];
char maxFee[50];
char nonce[14]; // size needed to write "NOT Displayed"
char nonce[8]; // 10M tx per account ought to be enough for everybody
} txStringProperties_t;
typedef struct strDataTmp_t {

View File

@@ -1,7 +1,7 @@
#include "shared_context.h"
#include "ui_callbacks.h"
void display_settings(void);
void display_settings(const ux_flow_step_t* const start_step);
void switch_settings_contract_data(void);
void switch_settings_display_data(void);
void switch_settings_display_nonce(void);
@@ -26,7 +26,7 @@ UX_STEP_NOCB(
UX_STEP_CB(
ux_idle_flow_3_step,
pb,
display_settings(),
display_settings(NULL),
{
&C_icon_eye,
"Settings",
@@ -66,7 +66,7 @@ UX_STEP_CB(
switch_settings_display_data(),
{
.title = "Debug data",
.text = strings.common.fullAddress + 20
.text = strings.common.fullAddress + 12
});
UX_STEP_CB(
@@ -75,7 +75,7 @@ UX_STEP_CB(
switch_settings_display_nonce(),
{
.title = "Account nonce",
.text = strings.common.nonce
.text = strings.common.fullAddress + 26
});
#else
@@ -99,9 +99,9 @@ UX_STEP_CB(
"Debug data",
"Display contract data",
"details",
strings.common.fullAddress + 20
strings.common.fullAddress + 12
});
UX_STEP_CB(
ux_settings_flow_3_step,
bnnn,
@@ -109,8 +109,8 @@ UX_STEP_CB(
{
"Nonce",
"Display account nonce",
"details",
strings.common.nonce
"in transactions",
strings.common.fullAddress + 26
});
#endif
@@ -131,28 +131,29 @@ UX_FLOW(ux_settings_flow,
&ux_settings_flow_3_step,
&ux_settings_flow_4_step);
void display_settings() {
void display_settings(const ux_flow_step_t* const start_step) {
strcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Allowed" : "NOT Allowed"));
strcpy(strings.common.fullAddress + 20,
strcpy(strings.common.fullAddress + 12,
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"));
strcpy(strings.common.nonce, (N_storage.displayNonce ? "Displayed" : "NOT Displayed"));
ux_flow_init(0, ux_settings_flow, NULL);
strcpy(strings.common.fullAddress + 26,
(N_storage.displayNonce ? "Displayed" : "NOT Displayed"));
ux_flow_init(0, ux_settings_flow, start_step);
}
void switch_settings_contract_data() {
uint8_t value = (N_storage.dataAllowed ? 0 : 1);
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
display_settings();
display_settings(&ux_settings_flow_1_step);
}
void switch_settings_display_data() {
uint8_t value = (N_storage.contractDetails ? 0 : 1);
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
display_settings();
display_settings(&ux_settings_flow_2_step);
}
void switch_settings_display_nonce() {
uint8_t value = (N_storage.displayNonce ? 0 : 1);
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
display_settings();
display_settings(&ux_settings_flow_3_step);
}

View File

@@ -360,7 +360,7 @@ void finalizeParsing(bool direct) {
tmpContent.txContent.nonce.length,
&nonce);
tostring256(&nonce, 10, displayBuffer, sizeof(displayBuffer));
compareOrCopy(strings.common.nonce, displayBuffer, called_from_swap);
strncpy(strings.common.nonce, displayBuffer, sizeof(strings.common.nonce));
}
// Compute maximum fee
if (genericUI) {