Skip to content

Commit

Permalink
Add 'sender' field
Browse files Browse the repository at this point in the history
  • Loading branch information
cedelavergne-ledger committed Mar 12, 2024
1 parent fec3317 commit 6bcb4bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
8 changes: 6 additions & 2 deletions src_bagl/ui_flow_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +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) {
ux_approval_tx_flow[step++] = &ux_approval_from_step;
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
ux_approval_tx_flow[step++] = &ux_approval_from_step;
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
29 changes: 11 additions & 18 deletions src_features/signTx/logic_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,27 +499,20 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
}
PRINTF("Amount displayed: %s\n", strings.common.fullAmount);

// Format the from address in a temporary buffer, if in swap case compare it with validated
// address, else commit it
address_to_string(msg_sender,
ADDRESS_LENGTH,
displayBuffer,
sizeof(displayBuffer),
&global_sha3,
chainConfig->chainId); // TODO CHECK chainId here!

// TODO CHECK swap case here!
if (G_called_from_swap) {
PRINTF("CHECK FROM Address from swap...\n");
// Ensure the values are the same that the ones that have been previously validated
if (strcasecmp_workaround(strings.common.fromAddress, displayBuffer) != 0) {
PRINTF("ERR_SILENT_MODE_CHECK_FAILED, FROM address check failed\n");
THROW(ERR_SILENT_MODE_CHECK_FAILED);
}
// Transaction parameters are managed by the Exchange caller app!
explicit_bzero(strings.common.fromAddress, sizeof(strings.common.fromAddress));
} else {
strlcpy(strings.common.fromAddress, displayBuffer, sizeof(strings.common.fromAddress));
// Format the from address in a temporary buffer, if in swap case compare it with validated
// address, else commit it
address_to_string(msg_sender,
ADDRESS_LENGTH,
strings.common.fromAddress,
sizeof(strings.common.fromAddress),
&global_sha3,
chainConfig->chainId);
PRINTF("FROM Address displayed: %s\n", strings.common.fromAddress);
}
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
2 changes: 1 addition & 1 deletion src_nbgl/ui_approve_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) {
pair.item = "Amount";
pair.value = strings.common.fullAmount;
}
if (pairIndex == target_index++) {
if ((strings.common.fromAddress[0] != 0) && (pairIndex == target_index++)) {
pair.item = "Address From";
pair.value = strings.common.fromAddress;
}
Expand Down

0 comments on commit 6bcb4bc

Please sign in to comment.