Skip to content

Commit

Permalink
Add 'sender' field to review screens
Browse files Browse the repository at this point in the history
  • Loading branch information
cedelavergne-ledger committed May 20, 2024
1 parent e434173 commit eae7f74
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/shared_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ typedef enum {
#define NETWORK_STRING_MAX_SIZE 19

typedef struct txStringProperties_s {
char fromAddress[43];
char fullAddress[43];
char fullAmount[79]; // 2^256 is 78 digits long
char maxFee[50];
Expand Down
15 changes: 14 additions & 1 deletion src_bagl/ui_flow_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,18 @@ UX_STEP_NOCB(
.title = "Amount",
.text = strings.common.fullAmount
});
UX_STEP_NOCB(
ux_approval_from_step,
bnnn_paging,
{
.title = "From",
.text = strings.common.fromAddress,
});
UX_STEP_NOCB(
ux_approval_address_step,
bnnn_paging,
{
.title = "Address",
.title = "To",
.text = strings.common.fullAddress,
});

Expand Down Expand Up @@ -225,10 +232,16 @@ void ux_approve_tx(bool fromPlugin) {
if (has_domain_name(&chain_id, tmpContent.txContent.destination)) {
ux_approval_tx_flow[step++] = &ux_domain_name_step;
if (N_storage.verbose_domain_name) {
if (strings.common.fromAddress[0] != 0) {
ux_approval_tx_flow[step++] = &ux_approval_from_step;
}
ux_approval_tx_flow[step++] = &ux_approval_address_step;
}
} else {
#endif // HAVE_DOMAIN_NAME
if (strings.common.fromAddress[0] != 0) {
ux_approval_tx_flow[step++] = &ux_approval_from_step;
}
ux_approval_tx_flow[step++] = &ux_approval_address_step;
#ifdef HAVE_DOMAIN_NAME
}
Expand Down
18 changes: 16 additions & 2 deletions src_features/signTx/logic_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,13 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
tmpCtx.transactionContext.hash,
32));

uint8_t msg_sender[ADDRESS_LENGTH] = {0};
get_public_key(msg_sender, sizeof(msg_sender));

// Finalize the plugin handling
if (dataContext.tokenContext.pluginStatus >= ETH_PLUGIN_RESULT_SUCCESSFUL) {
eth_plugin_prepare_finalize(&pluginFinalize);

uint8_t msg_sender[ADDRESS_LENGTH] = {0};
get_public_key(msg_sender, sizeof(msg_sender));
pluginFinalize.address = msg_sender;

if (!eth_plugin_call(ETH_PLUGIN_FINALIZE, (void *) &pluginFinalize)) {
Expand Down Expand Up @@ -498,6 +499,19 @@ __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,
Expand Down
8 changes: 7 additions & 1 deletion src_nbgl/ui_approve_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ static uint8_t setTagValuePairs(void) {
pairs[nbPairs].value = strings.common.fullAmount;
nbPairs++;

if (strings.common.fromAddress[0] != 0) {
pairs[nbPairs].item = "From";
pairs[nbPairs].value = strings.common.fromAddress;
nbPairs++;
}

#ifdef HAVE_DOMAIN_NAME
uint64_t chain_id = get_tx_chain_id();
tx_approval_context.domain_name_match =
Expand All @@ -131,7 +137,7 @@ static uint8_t setTagValuePairs(void) {
}
if (!tx_approval_context.domain_name_match || N_storage.verbose_domain_name) {
#endif
pairs[nbPairs].item = "Address";
pairs[nbPairs].item = "To";
pairs[nbPairs].value = strings.common.fullAddress;
nbPairs++;
#ifdef HAVE_DOMAIN_NAME
Expand Down

0 comments on commit eae7f74

Please sign in to comment.