From e503373411a7c159569353ef389e1673bd7da87d Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 19 Jun 2024 11:24:13 +0200 Subject: [PATCH] Fixes --- src_bagl/ui_flow_signTx.c | 11 +++++++++-- src_features/signTx/logic_signTx.c | 21 +++++++-------------- src_nbgl/ui_approve_tx.c | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src_bagl/ui_flow_signTx.c b/src_bagl/ui_flow_signTx.c index 1b9d0f350..c0ecfcc01 100644 --- a/src_bagl/ui_flow_signTx.c +++ b/src_bagl/ui_flow_signTx.c @@ -221,6 +221,11 @@ void ux_approve_tx(bool fromPlugin) { if (fromPlugin) { // Add the special dynamic display logic ux_approval_tx_flow[step++] = &ux_plugin_approval_id_step; + if (pluginType != EXTERNAL) { + if (strings.common.fromAddress[0] != 0) { + ux_approval_tx_flow[step++] = &ux_approval_from_step; + } + } ux_approval_tx_flow[step++] = &ux_plugin_approval_before_step; ux_approval_tx_flow[step++] = &ux_plugin_approval_display_step; ux_approval_tx_flow[step++] = &ux_plugin_approval_after_step; @@ -234,6 +239,9 @@ void ux_approve_tx(bool fromPlugin) { uint64_t chain_id = get_tx_chain_id(); if (has_domain_name(&chain_id, tmpContent.txContent.destination)) { ux_approval_tx_flow[step++] = &ux_domain_name_step; + if (N_storage.verbose_domain_name) { + ux_approval_tx_flow[step++] = &ux_approval_to_step; + } } else { #endif // HAVE_DOMAIN_NAME ux_approval_tx_flow[step++] = &ux_approval_to_step; @@ -242,8 +250,6 @@ void ux_approve_tx(bool fromPlugin) { #endif // HAVE_DOMAIN_NAME } - ux_approval_tx_flow[step++] = &ux_approval_fees_step; - if (N_storage.displayNonce) { ux_approval_tx_flow[step++] = &ux_approval_nonce_step; } @@ -253,6 +259,7 @@ void ux_approve_tx(bool fromPlugin) { ux_approval_tx_flow[step++] = &ux_approval_network_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; diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index 813679237..3b2e281ca 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -349,6 +349,12 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool uint8_t msg_sender[ADDRESS_LENGTH] = {0}; get_public_key(msg_sender, sizeof(msg_sender)); + address_to_string(msg_sender, + ADDRESS_LENGTH, + strings.common.fromAddress, + sizeof(strings.common.fromAddress), + chainConfig->chainId); + PRINTF("FROM address displayed: %s\n", strings.common.fromAddress); // Finalize the plugin handling if (dataContext.tokenContext.pluginStatus >= ETH_PLUGIN_RESULT_SUCCESSFUL) { eth_plugin_prepare_finalize(&pluginFinalize); @@ -473,7 +479,7 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool } else { strlcpy(strings.common.toAddress, displayBuffer, sizeof(strings.common.toAddress)); } - PRINTF("Address displayed: %s\n", strings.common.toAddress); + PRINTF("TO address displayed: %s\n", strings.common.toAddress); // Format the amount in a temporary buffer, if in swap case compare it with validated // amount, else commit it @@ -499,19 +505,6 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool strlcpy(strings.common.fullAmount, displayBuffer, sizeof(strings.common.fullAmount)); } PRINTF("Amount displayed: %s\n", strings.common.fullAmount); - - if (G_called_from_swap) { - // Transaction parameters are managed by the Exchange caller app! - explicit_bzero(strings.common.fromAddress, sizeof(strings.common.fromAddress)); - } else { - // Format the from address in a temporary buffer - address_to_string(msg_sender, - ADDRESS_LENGTH, - strings.common.fromAddress, - sizeof(strings.common.fromAddress), - chainConfig->chainId); - PRINTF("FROM Address displayed: %s\n", strings.common.fromAddress); - } } // Compute the max fee in a temporary buffer, if in swap case compare it with validated max fee, diff --git a/src_nbgl/ui_approve_tx.c b/src_nbgl/ui_approve_tx.c index cae195f85..79f2ee4d1 100644 --- a/src_nbgl/ui_approve_tx.c +++ b/src_nbgl/ui_approve_tx.c @@ -93,6 +93,13 @@ static uint8_t setTagValuePairs(void) { // Setup data to display if (tx_approval_context.fromPlugin) { + if (pluginType != EXTERNAL) { + if (strings.common.fromAddress[0] != 0) { + pairs[nbPairs].item = "From"; + pairs[nbPairs].value = strings.common.fromAddress; + nbPairs++; + } + } for (pairIndex = 0; pairIndex < dataContext.tokenContext.pluginUiMaxItems; pairIndex++) { // for the next dataContext.tokenContext.pluginUiMaxItems items, get tag/value from // plugin_ui_get_item_internal() @@ -143,15 +150,16 @@ static uint8_t setTagValuePairs(void) { #ifdef HAVE_DOMAIN_NAME } #endif - pairs[nbPairs].item = "Max fees"; - pairs[nbPairs].value = strings.common.maxFee; - nbPairs++; - if (N_storage.displayNonce) { pairs[nbPairs].item = "Nonce"; pairs[nbPairs].value = strings.common.nonce; nbPairs++; } + + pairs[nbPairs].item = "Max fees"; + pairs[nbPairs].value = strings.common.maxFee; + nbPairs++; + if (tx_approval_context.displayNetwork) { pairs[nbPairs].item = "Network"; pairs[nbPairs].value = strings.common.network_name;