Add nonce display settings ; nonce is always displayed
This commit is contained in:
@@ -60,6 +60,7 @@ void handle_swap_sign_transaction(chain_config_t* config) {
|
||||
storage.dataAllowed = 0x00;
|
||||
storage.contractDetails = 0x00;
|
||||
storage.initialized = 0x01;
|
||||
storage.displayNonce = 0x00;
|
||||
nvm_write((void*) &N_storage, (void*) &storage, sizeof(internalStorage_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -714,6 +714,7 @@ void coin_main(chain_config_t *coin_config) {
|
||||
internalStorage_t storage;
|
||||
storage.dataAllowed = 0x00;
|
||||
storage.contractDetails = 0x00;
|
||||
storage.displayNonce = 0x00;
|
||||
storage.initialized = 0x01;
|
||||
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
typedef struct internalStorage_t {
|
||||
unsigned char dataAllowed;
|
||||
unsigned char contractDetails;
|
||||
unsigned char displayNonce;
|
||||
uint8_t initialized;
|
||||
} internalStorage_t;
|
||||
|
||||
@@ -157,6 +158,7 @@ typedef struct txStringProperties_t {
|
||||
char fullAddress[43];
|
||||
char fullAmount[50];
|
||||
char maxFee[50];
|
||||
char nonce[14]; // size needed to write "NOT Displayed"
|
||||
} txStringProperties_t;
|
||||
|
||||
typedef struct strDataTmp_t {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
void display_settings(void);
|
||||
void switch_settings_contract_data(void);
|
||||
void switch_settings_display_data(void);
|
||||
void switch_settings_display_nonce(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
@@ -68,6 +69,15 @@ UX_STEP_CB(
|
||||
.text = strings.common.fullAddress + 20
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_3_step,
|
||||
bnnn_paging,
|
||||
switch_settings_display_nonce(),
|
||||
{
|
||||
.title = "Account nonce",
|
||||
.text = strings.common.nonce
|
||||
});
|
||||
|
||||
#else
|
||||
|
||||
UX_STEP_CB(
|
||||
@@ -91,11 +101,22 @@ UX_STEP_CB(
|
||||
"details",
|
||||
strings.common.fullAddress + 20
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_3_step,
|
||||
bnnn,
|
||||
switch_settings_display_nonce(),
|
||||
{
|
||||
"Nonce",
|
||||
"Display account nonce",
|
||||
"details",
|
||||
strings.common.nonce
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_3_step,
|
||||
ux_settings_flow_4_step,
|
||||
pb,
|
||||
ui_idle(),
|
||||
{
|
||||
@@ -107,12 +128,15 @@ UX_STEP_CB(
|
||||
UX_FLOW(ux_settings_flow,
|
||||
&ux_settings_flow_1_step,
|
||||
&ux_settings_flow_2_step,
|
||||
&ux_settings_flow_3_step);
|
||||
&ux_settings_flow_3_step,
|
||||
&ux_settings_flow_4_step);
|
||||
|
||||
void display_settings() {
|
||||
strcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Allowed" : "NOT Allowed"));
|
||||
strcpy(strings.common.fullAddress + 20,
|
||||
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"));
|
||||
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"));
|
||||
strcpy(strings.common.nonce,
|
||||
(N_storage.displayNonce ? "Displayed" : "NOT Displayed"));
|
||||
ux_flow_init(0, ux_settings_flow, NULL);
|
||||
}
|
||||
|
||||
@@ -127,3 +151,9 @@ void switch_settings_display_data() {
|
||||
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
|
||||
display_settings();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -117,9 +117,10 @@ static void processNonce(txContext_t *context) {
|
||||
if (context->currentFieldPos < context->currentFieldLength) {
|
||||
uint32_t copySize =
|
||||
MIN(context->commandLength, context->currentFieldLength - context->currentFieldPos);
|
||||
copyTxData(context, NULL, copySize);
|
||||
copyTxData(context, context->content->nonce.value, copySize);
|
||||
}
|
||||
if (context->currentFieldPos == context->currentFieldLength) {
|
||||
context->content->nonce.length = context->currentFieldLength;
|
||||
context->currentField++;
|
||||
context->processingField = false;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ typedef struct txContent_t {
|
||||
txInt256_t gasprice;
|
||||
txInt256_t startgas;
|
||||
txInt256_t value;
|
||||
txInt256_t nonce;
|
||||
uint8_t destination[20];
|
||||
uint8_t destinationLength;
|
||||
uint8_t v[4];
|
||||
|
||||
@@ -229,7 +229,7 @@ void computeFees(char *displayBuffer, uint32_t displayBufferSize) {
|
||||
}
|
||||
|
||||
void finalizeParsing(bool direct) {
|
||||
char displayBuffer[50];
|
||||
char displayBuffer[79]; // required to store the string representation of uint256_t max
|
||||
uint8_t decimals = WEI_TO_ETHER;
|
||||
uint8_t *ticker = (uint8_t *) PIC(chainConfig->coinName);
|
||||
ethPluginFinalize_t pluginFinalize;
|
||||
@@ -353,6 +353,15 @@ void finalizeParsing(bool direct) {
|
||||
sizeof(displayBuffer));
|
||||
compareOrCopy(strings.common.fullAmount, displayBuffer, called_from_swap);
|
||||
}
|
||||
// Prepare nonce to display
|
||||
if (genericUI) {
|
||||
uint256_t nonce;
|
||||
convertUint256BE(tmpContent.txContent.nonce.value,
|
||||
tmpContent.txContent.nonce.length,
|
||||
&nonce);
|
||||
tostring256(&nonce, 10, displayBuffer, sizeof(displayBuffer));
|
||||
compareOrCopy(strings.common.nonce, displayBuffer, called_from_swap);
|
||||
}
|
||||
// Compute maximum fee
|
||||
if (genericUI) {
|
||||
computeFees(displayBuffer, sizeof(displayBuffer));
|
||||
|
||||
@@ -131,6 +131,14 @@ UX_STEP_CB(
|
||||
"Reject",
|
||||
});
|
||||
|
||||
UX_STEP_NOCB(
|
||||
ux_approval_tx_display_nonce_step,
|
||||
bnnn_paging,
|
||||
{
|
||||
.title = "Nonce",
|
||||
.text = strings.common.nonce,
|
||||
});
|
||||
|
||||
UX_STEP_NOCB(ux_approval_tx_data_warning_step,
|
||||
pbb,
|
||||
{
|
||||
@@ -144,6 +152,7 @@ UX_FLOW(ux_approval_tx_flow,
|
||||
&ux_approval_tx_1_step,
|
||||
&ux_approval_tx_2_step,
|
||||
&ux_approval_tx_3_step,
|
||||
&ux_approval_tx_display_nonce_step,
|
||||
&ux_approval_tx_4_step,
|
||||
&ux_approval_tx_5_step,
|
||||
&ux_approval_tx_6_step);
|
||||
@@ -153,6 +162,7 @@ UX_FLOW(ux_approval_tx_data_warning_flow,
|
||||
&ux_approval_tx_data_warning_step,
|
||||
&ux_approval_tx_2_step,
|
||||
&ux_approval_tx_3_step,
|
||||
&ux_approval_tx_display_nonce_step,
|
||||
&ux_approval_tx_4_step,
|
||||
&ux_approval_tx_5_step,
|
||||
&ux_approval_tx_6_step);
|
||||
Reference in New Issue
Block a user