From 02cdc23751ac53200c93e97f1a17b461149af28c Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Fri, 30 Jun 2023 14:05:46 +0200 Subject: [PATCH] Rename called_from_swap to G_called_from_swap --- src/eth_plugin_handler.c | 2 +- src/handle_swap_sign_transaction.c | 2 +- src/main.c | 4 ++-- src/shared_context.h | 2 +- src_features/getEth2PublicKey/cmd_getEth2PublicKey.c | 2 +- src_features/getPublicKey/cmd_getPublicKey.c | 2 +- src_features/signTx/logic_signTx.c | 12 ++++++------ src_features/signTx/ui_common_signTx.c | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/eth_plugin_handler.c b/src/eth_plugin_handler.c index 29e965f..8baa253 100644 --- a/src/eth_plugin_handler.c +++ b/src/eth_plugin_handler.c @@ -149,7 +149,7 @@ eth_plugin_result_t eth_plugin_perform_init(uint8_t *contractAddress, } // Do not handle a plugin if running in swap mode - if (called_from_swap && (contractAddress != NULL)) { + if (G_called_from_swap && (contractAddress != NULL)) { PRINTF("eth_plug_init aborted in swap mode\n"); return 0; } diff --git a/src/handle_swap_sign_transaction.c b/src/handle_swap_sign_transaction.c index 3a7fcd0..ddb32ec 100644 --- a/src/handle_swap_sign_transaction.c +++ b/src/handle_swap_sign_transaction.c @@ -54,7 +54,7 @@ bool copy_transaction_parameters(create_transaction_parameters_t* sign_transacti void handle_swap_sign_transaction(chain_config_t* config) { chainConfig = config; reset_app_context(); - called_from_swap = true; + G_called_from_swap = true; io_seproxyhal_init(); if (N_storage.initialized != 0x01) { diff --git a/src/main.c b/src/main.c index 6967042..b11b39d 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ cx_sha3_t global_sha3; uint8_t appState; uint16_t apdu_response_code; -bool called_from_swap; +bool G_called_from_swap; pluginType_t pluginType; #ifdef HAVE_STARKWARE bool quantumSet; @@ -77,7 +77,7 @@ chain_config_t *chainConfig = NULL; void reset_app_context() { // PRINTF("!!RESET_APP_CONTEXT\n"); appState = APP_STATE_IDLE; - called_from_swap = false; + G_called_from_swap = false; pluginType = OLD_INTERNAL; #ifdef HAVE_STARKWARE quantumSet = false; diff --git a/src/shared_context.h b/src/shared_context.h index c2fc66a..f83320c 100644 --- a/src/shared_context.h +++ b/src/shared_context.h @@ -213,7 +213,7 @@ extern strings_t strings; extern cx_sha3_t global_sha3; extern const internalStorage_t N_storage_real; -extern bool called_from_swap; +extern bool G_called_from_swap; typedef enum { EXTERNAL, // External plugin, set by setExternalPlugin. diff --git a/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c b/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c index 853d834..b1b38d5 100644 --- a/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c +++ b/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c @@ -49,7 +49,7 @@ void handleGetEth2PublicKey(uint8_t p1, unsigned int *tx) { bip32_path_t bip32; - if (!called_from_swap) { + if (!G_called_from_swap) { reset_app_context(); } if ((p1 != P1_CONFIRM) && (p1 != P1_NON_CONFIRM)) { diff --git a/src_features/getPublicKey/cmd_getPublicKey.c b/src_features/getPublicKey/cmd_getPublicKey.c index 07bab1d..bc8bac6 100644 --- a/src_features/getPublicKey/cmd_getPublicKey.c +++ b/src_features/getPublicKey/cmd_getPublicKey.c @@ -16,7 +16,7 @@ void handleGetPublicKey(uint8_t p1, bip32_path_t bip32; cx_ecfp_private_key_t privateKey; - if (!called_from_swap) { + if (!G_called_from_swap) { reset_app_context(); } diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index 7d8cd37..f42addf 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -424,8 +424,8 @@ void finalizeParsing(bool direct) { } // User has just validated a swap but ETH received apdus about a non standard plugin / contract - if (called_from_swap && !use_standard_UI) { - PRINTF("ERR_SILENT_MODE_CHECK_FAILED, called_from_swap\n"); + if (G_called_from_swap && !use_standard_UI) { + PRINTF("ERR_SILENT_MODE_CHECK_FAILED, G_called_from_swap\n"); THROW(ERR_SILENT_MODE_CHECK_FAILED); } @@ -447,7 +447,7 @@ void finalizeParsing(bool direct) { sizeof(displayBuffer), &global_sha3, chainConfig->chainId); - if (called_from_swap) { + if (G_called_from_swap) { // Ensure the values are the same that the ones that have been previously validated if (strcasecmp_workaround(strings.common.fullAddress, displayBuffer) != 0) { PRINTF("ERR_SILENT_MODE_CHECK_FAILED, address check failed\n"); @@ -466,7 +466,7 @@ void finalizeParsing(bool direct) { ticker, displayBuffer, sizeof(displayBuffer)); - if (called_from_swap) { + if (G_called_from_swap) { // Ensure the values are the same that the ones that have been previously validated if (strcmp(strings.common.fullAmount, displayBuffer) != 0) { PRINTF("ERR_SILENT_MODE_CHECK_FAILED, amount check failed\n"); @@ -484,7 +484,7 @@ void finalizeParsing(bool direct) { &tmpContent.txContent.startgas, displayBuffer, sizeof(displayBuffer)); - if (called_from_swap) { + if (G_called_from_swap) { // Ensure the values are the same that the ones that have been previously validated if (strcmp(strings.common.maxFee, displayBuffer) != 0) { PRINTF("ERR_SILENT_MODE_CHECK_FAILED, fees check failed\n"); @@ -510,7 +510,7 @@ void finalizeParsing(bool direct) { // If called from swap, the user as already validated a standard transaction // We have already checked the fields of this transaction above - no_consent_check = called_from_swap && use_standard_UI; + no_consent_check = G_called_from_swap && use_standard_UI; #ifdef NO_CONSENT no_consent_check = true; diff --git a/src_features/signTx/ui_common_signTx.c b/src_features/signTx/ui_common_signTx.c index ef8171f..fec6ca8 100644 --- a/src_features/signTx/ui_common_signTx.c +++ b/src_features/signTx/ui_common_signTx.c @@ -61,7 +61,7 @@ unsigned int io_seproxyhal_touch_tx_ok(__attribute__((unused)) const bagl_elemen G_io_apdu_buffer[tx++] = 0x00; // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); - if (called_from_swap) { + if (G_called_from_swap) { os_sched_exit(0); } reset_app_context();