Skip to content

Commit c353982

Browse files
During signature, move parsing and swap fields checking away from main flow
1 parent b3d96d1 commit c353982

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src_features/signTx/logic_signTx.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,14 @@ static int strcasecmp_workaround(const char *str1, const char *str2) {
319319
return 0;
320320
}
321321

322-
void finalizeParsing(bool direct) {
322+
__attribute__((noinline)) static void finalize_parsing_helper(bool direct, bool *use_standard_UI) {
323323
char displayBuffer[50];
324324
uint8_t decimals = WEI_TO_ETHER;
325325
uint64_t chain_id = get_tx_chain_id();
326326
const char *ticker = get_displayable_ticker(&chain_id);
327327
ethPluginFinalize_t pluginFinalize;
328-
bool use_standard_UI = true;
328+
329+
*use_standard_UI = true;
329330

330331
// Verify the chain
331332
if (chainConfig->chainId != ETHEREUM_MAINNET_CHAINID) {
@@ -396,7 +397,7 @@ void finalizeParsing(bool direct) {
396397
switch (pluginFinalize.uiType) {
397398
case ETH_UI_TYPE_GENERIC:
398399
// Use the dedicated ETH plugin UI
399-
use_standard_UI = false;
400+
*use_standard_UI = false;
400401
tmpContent.txContent.dataPresent = false;
401402
// Add the number of screens + the number of additional screens to get the total
402403
// number of screens needed.
@@ -405,7 +406,7 @@ void finalizeParsing(bool direct) {
405406
break;
406407
case ETH_UI_TYPE_AMOUNT_ADDRESS:
407408
// Use the standard ETH UI as this plugin uses the amount/address UI
408-
use_standard_UI = true;
409+
*use_standard_UI = true;
409410
tmpContent.txContent.dataPresent = false;
410411
if ((pluginFinalize.amount == NULL) || (pluginFinalize.address == NULL)) {
411412
PRINTF("Incorrect amount/address set by plugin\n");
@@ -443,7 +444,7 @@ void finalizeParsing(bool direct) {
443444
}
444445

445446
// User has just validated a swap but ETH received apdus about a non standard plugin / contract
446-
if (G_called_from_swap && !use_standard_UI) {
447+
if (G_called_from_swap && !*use_standard_UI) {
447448
PRINTF("ERR_SILENT_MODE_CHECK_FAILED, G_called_from_swap\n");
448449
THROW(ERR_SILENT_MODE_CHECK_FAILED);
449450
}
@@ -457,7 +458,7 @@ void finalizeParsing(bool direct) {
457458
}
458459

459460
// Prepare destination address and amount to display
460-
if (use_standard_UI) {
461+
if (*use_standard_UI) {
461462
// Format the address in a temporary buffer, if in swap case compare it with validated
462463
// address, else commit it
463464
address_to_string(tmpContent.txContent.destination,
@@ -532,11 +533,14 @@ void finalizeParsing(bool direct) {
532533
// Prepare network field
533534
get_network_as_string(strings.common.network_name, sizeof(strings.common.network_name));
534535
PRINTF("Network: %s\n", strings.common.network_name);
536+
}
535537

538+
void finalizeParsing(bool direct) {
539+
bool use_standard_UI;
536540
bool no_consent_check;
537-
538-
// If called from swap, the user as already validated a standard transaction
539-
// We have already checked the fields of this transaction above
541+
finalize_parsing_helper(direct, &use_standard_UI);
542+
// If called from swap, the user has already validated a standard transaction
543+
// And we have already checked the fields of this transaction above
540544
no_consent_check = G_called_from_swap && use_standard_UI;
541545

542546
#ifdef NO_CONSENT

0 commit comments

Comments
 (0)