From bd85e730ec70d75ead39f9a491682cb65e3bee5f Mon Sep 17 00:00:00 2001 From: abenso Date: Thu, 22 Aug 2024 18:31:05 -0300 Subject: [PATCH] fixes --- app/src/items.c | 24 ++++++++++++------------ app/src/items_defs.h | 2 +- app/src/parser.c | 2 +- app/src/parser_impl.c | 4 ++-- app/src/parser_impl.h | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/items.c b/app/src/items.c index 46e81af..f05fbc4 100644 --- a/app/src/items.c +++ b/app/src/items.c @@ -53,9 +53,9 @@ char base64_hash[45]; items_error_t items_initItems() { MEMZERO(&item_array, sizeof(item_array_t)); - item_array.numOfUnknownCapabitilies = 1; + item_array.numOfUnknownCapabilities = 1; - for (uint8_t i = 0; i < sizeof(item_array.items) / sizeof(item_array.items[0]); i++) { + for (uint8_t i = 0; i < MAX_NUMBER_OF_ITEMS; i++) { item_array.items[i].can_display = bool_true; } @@ -412,8 +412,8 @@ static items_error_t items_storeGasItem(uint16_t json_token_index) { PARSER_TO_ITEMS_ERROR(array_get_element_count(json_all, token_index, &args_count)); if (args_count > 0) { - snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabitilies); - item_array.numOfUnknownCapabitilies++; + snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabilities); + item_array.numOfUnknownCapabilities++; item_array.toString[item_array.numOfItems] = items_unknownCapabilityToDisplayString; } else { strcpy(item->key, "Paying Gas"); @@ -437,8 +437,8 @@ static items_error_t items_storeTxItem(parsed_json_t *json_all, uint16_t transfe (*num_of_transfers)++; item_array.toString[item_array.numOfItems] = items_transferToDisplayString; } else { - snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabitilies); - item_array.numOfUnknownCapabitilies++; + snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabilities); + item_array.numOfUnknownCapabilities++; item_array.toString[item_array.numOfItems] = items_unknownCapabilityToDisplayString; if (num_of_args > 5 || @@ -465,8 +465,8 @@ static items_error_t items_storeTxCrossItem(parsed_json_t *json_all, uint16_t tr (*num_of_transfers)++; item_array.toString[item_array.numOfItems] = items_crossTransferToDisplayString; } else { - snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabitilies); - item_array.numOfUnknownCapabitilies++; + snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabilities); + item_array.numOfUnknownCapabilities++; item_array.toString[item_array.numOfItems] = items_unknownCapabilityToDisplayString; if (num_of_args > 5 || @@ -491,8 +491,8 @@ static items_error_t items_storeTxRotateItem(parsed_json_t *json_all, uint16_t t snprintf(item->key, sizeof(item->key), "Rotate for account"); item_array.toString[item_array.numOfItems] = items_rotateToDisplayString; } else { - snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabitilies); - item_array.numOfUnknownCapabitilies++; + snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabilities); + item_array.numOfUnknownCapabilities++; item_array.toString[item_array.numOfItems] = items_unknownCapabilityToDisplayString; if (num_of_args > 5 || @@ -513,8 +513,8 @@ static items_error_t items_storeUnknownItem(parsed_json_t *json_all, uint16_t tr PARSER_TO_ITEMS_ERROR(array_get_element_count(json_all, token_index, &num_of_args)); - snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabitilies); - item_array.numOfUnknownCapabitilies++; + snprintf(item->key, sizeof(item->key), "Unknown Capability %d", item_array.numOfUnknownCapabilities); + item_array.numOfUnknownCapabilities++; item_array.toString[item_array.numOfItems] = items_unknownCapabilityToDisplayString; if (num_of_args > 5 || diff --git a/app/src/items_defs.h b/app/src/items_defs.h index 8d14cfc..46ef308 100644 --- a/app/src/items_defs.h +++ b/app/src/items_defs.h @@ -51,6 +51,6 @@ typedef enum { typedef struct { item_t items[MAX_NUMBER_OF_ITEMS]; uint8_t numOfItems; - uint8_t numOfUnknownCapabitilies; + uint8_t numOfUnknownCapabilities; items_error_t (*toString[MAX_NUMBER_OF_ITEMS])(item_t item, char *outVal, uint16_t outValLen); } item_array_t; diff --git a/app/src/parser.c b/app/src/parser.c index 83b0d97..c7b7a98 100644 --- a/app/src/parser.c +++ b/app/src/parser.c @@ -48,7 +48,7 @@ parser_error_t parser_parse(parser_context_t *ctx, const uint8_t *data, size_t d CHECK_ERROR(parser_init_context(ctx, data, dataLen)) ctx->tx_obj = tx_obj; - CHECK_ERROR(_read_json_tx(ctx, tx_obj)); + CHECK_ERROR(_read_json_tx(ctx)); ITEMS_TO_PARSER_ERROR(items_initItems()); ITEMS_TO_PARSER_ERROR(items_storeItems()); diff --git a/app/src/parser_impl.c b/app/src/parser_impl.c index 7208b54..0d85826 100644 --- a/app/src/parser_impl.c +++ b/app/src/parser_impl.c @@ -21,8 +21,8 @@ tx_json_t *parser_tx_obj; -parser_error_t _read_json_tx(parser_context_t *c, tx_json_t *v) { - parser_tx_obj = v; +parser_error_t _read_json_tx(parser_context_t *c) { + parser_tx_obj = c->tx_obj; CHECK_ERROR(json_parse(&(parser_tx_obj->json), (const char *)c->buffer, c->bufferLen)); diff --git a/app/src/parser_impl.h b/app/src/parser_impl.h index 7641d80..1cc0f23 100644 --- a/app/src/parser_impl.h +++ b/app/src/parser_impl.h @@ -46,7 +46,7 @@ typedef struct { tx_json_t *tx_obj; } parser_context_t; -parser_error_t _read_json_tx(parser_context_t *c, tx_json_t *v); +parser_error_t _read_json_tx(parser_context_t *c); tx_json_t *parser_getParserTxObj(); parser_error_t parser_findPubKeyInClist(uint16_t key_token_index); parser_error_t parser_arrayElementToString(uint16_t json_token_index, uint16_t element_idx, char *outVal,