Remove detailed fees display

This commit is contained in:
pscott
2021-06-24 18:46:18 +02:00
parent a944387c11
commit 0294c5e60f
9 changed files with 7 additions and 110 deletions

View File

@@ -147,7 +147,7 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter) {
switch (method) {
case ETH_PLUGIN_INIT_CONTRACT:
((ethPluginInitContract_t *) parameter)->interfaceVersion =
ETH_PLUGIN_INTERFACE_VERSION_2;
ETH_PLUGIN_INTERFACE_VERSION_1;
((ethPluginInitContract_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethPluginInitContract_t *) parameter)->pluginSharedRW = &pluginRW;
((ethPluginInitContract_t *) parameter)->pluginSharedRO = &pluginRO;

View File

@@ -12,7 +12,6 @@
// Interface version. To be updated everytime we introduce breaking changes to the plugin interface.
typedef enum {
ETH_PLUGIN_INTERFACE_VERSION_1 = 1, // Version 1
ETH_PLUGIN_INTERFACE_VERSION_2 = 2 // Add dataPresent to txContent
} eth_plugin_interface_version_t;
typedef enum {

View File

@@ -778,7 +778,6 @@ void coin_main(chain_config_t *coin_config) {
#endif
storage.contractDetails = 0x00;
storage.displayNonce = 0x00;
storage.displayFeeDetails = 0x00;
storage.initialized = 0x01;
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
}

View File

@@ -30,7 +30,6 @@ typedef struct internalStorage_t {
unsigned char dataAllowed;
unsigned char contractDetails;
unsigned char displayNonce;
unsigned char displayFeeDetails;
uint8_t initialized;
} internalStorage_t;
@@ -166,8 +165,7 @@ typedef enum {
typedef struct txStringProperties_t {
char fullAddress[43];
char fullAmount[50];
char maxFee[50]; // Used as BaseFee when detailing fees
char priorityFee[50];
char maxFee[50];
char nonce[8]; // 10M tx per account ought to be enough for everybody
char chainID[8]; // 10M different chainID ought to be enough for people to find a unique
// chainID for their token / chain.

View File

@@ -5,7 +5,6 @@ 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);
void switch_settings_display_fee_details(void);
//////////////////////////////////////////////////////////////////////
// clang-format off
@@ -79,15 +78,6 @@ UX_STEP_CB(
.text = strings.common.fullAddress + 26
});
UX_STEP_CB(
ux_settings_flow_4_step,
bnnn_paging,
switch_settings_display_fee_details(),
{
.title = "Fee Details",
.text = strings.common.fullAddress + 40
});
#else
UX_STEP_CB(
@@ -123,21 +113,10 @@ UX_STEP_CB(
strings.common.fullAddress + 26
});
UX_STEP_CB(
ux_settings_flow_4_step,
bnnn,
switch_settings_display_fee_details(),
{
"Fee Details",
"Display fee details",
"when available",
strings.common.fullAddress + 40
});
#endif
UX_STEP_CB(
ux_settings_flow_5_step,
ux_settings_flow_4_step,
pb,
ui_idle(),
{
@@ -150,8 +129,7 @@ UX_FLOW(ux_settings_flow,
&ux_settings_flow_1_step,
&ux_settings_flow_2_step,
&ux_settings_flow_3_step,
&ux_settings_flow_4_step,
&ux_settings_flow_5_step);
&ux_settings_flow_4_step);
void display_settings(const ux_flow_step_t* const start_step) {
strcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Allowed" : "NOT Allowed"));
@@ -159,8 +137,6 @@ void display_settings(const ux_flow_step_t* const start_step) {
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"));
strcpy(strings.common.fullAddress + 26,
(N_storage.displayNonce ? "Displayed" : "NOT Displayed"));
strcpy(strings.common.fullAddress + 40,
(N_storage.displayFeeDetails ? "Displayed" : "NOT Displayed"));
ux_flow_init(0, ux_settings_flow, start_step);
}
@@ -181,9 +157,3 @@ void switch_settings_display_nonce() {
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
display_settings(&ux_settings_flow_3_step);
}
void switch_settings_display_fee_details() {
uint8_t value = (N_storage.displayFeeDetails ? 0 : 1);
nvm_write((void*) &N_storage.displayFeeDetails, (void*) &value, sizeof(uint8_t));
display_settings(&ux_settings_flow_4_step);
}

View File

@@ -168,28 +168,6 @@ static void processNonce(txContext_t *context) {
}
}
static void processMaxPriorityFeePerGas(txContext_t *context) {
PRINTF("PRIORITY\n");
if (context->currentFieldIsList) {
PRINTF("Invalid type for RLP_MAX_PRIORITY_FEE_PER_GAS\n");
THROW(EXCEPTION);
}
if (context->currentFieldLength > MAX_INT256) {
PRINTF("Invalid length for RLP_MAX_PRIORITY_FEE_PER_GAS\n");
THROW(EXCEPTION);
}
if (context->currentFieldPos < context->currentFieldLength) {
uint32_t copySize =
MIN(context->commandLength, context->currentFieldLength - context->currentFieldPos);
copyTxData(context, context->content->maxPriorityFeePerGas.value + context->currentFieldPos, copySize);
}
if (context->currentFieldPos == context->currentFieldLength) {
context->content->maxPriorityFeePerGas.length = context->currentFieldLength;
context->currentField++;
context->processingField = false;
}
}
static void processStartGas(txContext_t *context) {
if (context->currentFieldIsList) {
PRINTF("Invalid type for RLP_STARTGAS\n");
@@ -358,10 +336,6 @@ static bool processEIP1559Tx(txContext_t *context) {
processNonce(context);
break;
}
case EIP1559_RLP_MAX_PRIORITY_FEE_PER_GAS: {
processMaxPriorityFeePerGas(context);
break;
}
case EIP1559_RLP_MAX_FEE_PER_GAS: {
processGasprice(context);
break;
@@ -390,6 +364,7 @@ static bool processEIP1559Tx(txContext_t *context) {
processV(context);
break;
}
case EIP1559_RLP_MAX_PRIORITY_FEE_PER_GAS:
case EIP1559_RLP_SENDER_R:
case EIP1559_RLP_SENDER_S:
processAndDiscard(context);

View File

@@ -127,7 +127,6 @@ typedef struct txInt256_t {
typedef struct txContent_t {
txInt256_t gasprice; // Used as MaxFeePerGas when dealing with EIP1559 transactions.
txInt256_t startgas; // Also known as `gasLimit`.
txInt256_t maxPriorityFeePerGas;
txInt256_t value;
txInt256_t nonce;
txInt256_t chainID;

View File

@@ -251,32 +251,8 @@ void prepareAndCopyFees(txInt256_t *BEGasPrice, txInt256_t *BEGasLimit, char *di
feesToString(&rawFee, displayBuffer, displayBufferSize);
}
static void prepareAndCopyDetailedFees() {
uint256_t rawPriorityFee = {0};
uint256_t rawMaxFee = {0};
uint256_t rawBaseFee = {0};
// Compute the priorityFee and the maxFee.
computeFees(&tmpContent.txContent.maxPriorityFeePerGas, &tmpContent.txContent.startgas, &rawPriorityFee);
computeFees(&tmpContent.txContent.gasprice, &tmpContent.txContent.startgas, &rawMaxFee);
// Substract priorityFee from maxFee -> this is the baseFee
minus256(&rawMaxFee, &rawPriorityFee, &rawBaseFee);
// Transform priorityFee to string (with a ticker).
PRINTF("Computing priority fee\n");
feesToString(&rawPriorityFee, strings.common.priorityFee, sizeof(strings.common.priorityFee));
PRINTF("Computing base fee\n");
// Transform priorityFee to string (with a ticker).
feesToString(&rawBaseFee, strings.common.maxFee, sizeof(strings.common.maxFee));
}
void prepareFeeDisplay() {
if (N_storage.displayFeeDetails) {
prepareAndCopyDetailedFees();
} else {
prepareAndCopyFees(&tmpContent.txContent.gasprice, &tmpContent.txContent.startgas, strings.common.maxFee, sizeof(strings.common.maxFee));
}
prepareAndCopyFees(&tmpContent.txContent.gasprice, &tmpContent.txContent.startgas, strings.common.maxFee, sizeof(strings.common.maxFee));
}
uint32_t get_chainID() {

View File

@@ -216,20 +216,6 @@ UX_STEP_INIT(
display_next_plugin_item(false);
});
UX_STEP_NOCB(
ux_approval_base_fee_step,
bnnn_paging,
{
.title = "Base Fee",
.text = strings.common.maxFee,
});
UX_STEP_NOCB(
ux_approval_priority_fee_step,
bnnn_paging,
{
.title = "Priority Fee",
.text = strings.common.priorityFee,
});
UX_STEP_NOCB(
ux_approval_fees_step,
bnnn_paging,
@@ -321,12 +307,7 @@ void ux_approve_tx(bool fromPlugin) {
if (id != ETHEREUM_MAINNET_CHAINID) {
ux_approval_tx_flow[step++] = &ux_approval_chainid_step;
}
if (txContext.txType == EIP1559 && N_storage.displayFeeDetails) {
ux_approval_tx_flow[step++] = &ux_approval_base_fee_step;
ux_approval_tx_flow[step++] = &ux_approval_priority_fee_step;
} else {
ux_approval_tx_flow[step++] = &ux_approval_fees_step;
}
ux_approval_tx_flow[step++] = &ux_approval_fees_step;
ux_approval_tx_flow[step++] = &ux_approval_accept_step;
ux_approval_tx_flow[step++] = &ux_approval_reject_step;
ux_approval_tx_flow[step++] = FLOW_END_STEP;