Skip to content

Commit

Permalink
Increase the defined max word length to 16 to match wallet names (#22)
Browse files Browse the repository at this point in the history
The ui_list component is defined with rows size of 15 in one of its
parameter. Using the component to list wallet names results in trimming
of last letter of the wallet name.

Fixes https://app.clickup.com/t/37308523/CHI-2010
  • Loading branch information
ujjwal-cyph authored Apr 26, 2023
2 parents 10affe5 + 4f82435 commit 6adc401
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
Empty file added common/CMakeLists.txt
Empty file.
2 changes: 1 addition & 1 deletion common/coin_support/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define MAX_NUMBER_OF_MNEMONIC_WORDS 24

/// Max length of mnemonic word
#define MAX_MNEMONIC_WORD_LENGTH 15
#define MAX_MNEMONIC_WORD_LENGTH 16

/// Max length of passphrase entered
#define MAX_PASSPHRASE_INPUT_LENGTH 65
Expand Down
2 changes: 1 addition & 1 deletion common/interfaces/user_interface/ui_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
static struct List_Data *data = NULL;
static struct List_Object *obj = NULL;

void list_init(const char option_list[24][15],
void list_init(const char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN],
const int number_of_options,
const char *heading,
bool dynamic_heading) {
Expand Down
10 changes: 7 additions & 3 deletions common/interfaces/user_interface/ui_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

#include "ui_common.h"

// TODO : Add constant
#define MAX_UI_LIST_WORDS MAX_NUMBER_OF_MNEMONIC_WORDS
#define MAX_UI_LIST_CHAR_LEN MAX_MNEMONIC_WORD_LENGTH

// TODO: Update count for higher coin list

/**
* @brief struct to store list data
* @details
Expand All @@ -24,7 +28,7 @@
* @note
*/
struct List_Data {
char option_list[24][15];
char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN];
int number_of_options;
int current_index;
bool dynamic_heading;
Expand Down Expand Up @@ -67,7 +71,7 @@ struct List_Object {
*
* @note Do not use this if number of options to be displayed in list is 1.
*/
void list_init(const char option_list[24][15],
void list_init(const char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN],
int number_of_options,
const char *heading,
bool dynamic_heading);
Expand Down
14 changes: 8 additions & 6 deletions common/libraries/util/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ uint32_t byte_array_to_hex_string(const uint8_t *bytes,
return (i * 2 + 1);
}

void __single_to_multi_line(const char *input,
const uint16_t input_len,
char output[24][15]) {
void __single_to_multi_line(
const char *input,
const uint16_t input_len,
char output[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH]) {
if (input == NULL || output == NULL)
return;
uint16_t i = 0U;
Expand All @@ -198,9 +199,10 @@ void __single_to_multi_line(const char *input,
}
}

void __multi_to_single_line(const char input[24][15],
const uint8_t number_of_mnemonics,
char *output) {
void __multi_to_single_line(
const char input[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH],
const uint8_t number_of_mnemonics,
char *output) {
if (input == NULL || output == NULL)
return;
uint8_t word_len;
Expand Down
14 changes: 8 additions & 6 deletions common/libraries/util/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ uint32_t byte_array_to_hex_string(const uint8_t *bytes,
*
* @note
*/
void __single_to_multi_line(const char *input,
uint16_t input_len,
char output[24][15]);
void __single_to_multi_line(
const char *input,
uint16_t input_len,
char output[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH]);

/**
* @brief convert multi-d mnemonics to single-d array for trezor crypto
Expand All @@ -203,9 +204,10 @@ void __single_to_multi_line(const char *input,
*
* @note
*/
void __multi_to_single_line(const char input[24][15],
uint8_t number_of_mnemonics,
char *output);
void __multi_to_single_line(
const char input[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH],
uint8_t number_of_mnemonics,
char *output);

/**
* @brief Converts a hex string to a byte array.
Expand Down
6 changes: 5 additions & 1 deletion src/level_four/card_health_check/cyt_card_hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ void cyt_card_hc() {
if (wallet_count == 0) {
message_scr_init(ui_text_no_wallets_present);
} else if (wallet_count <= MAX_WALLETS_ALLOWED) {
char choices[MAX_WALLETS_ALLOWED][15] = {"", "", "", ""}, heading[50];
char choices[MAX_WALLETS_ALLOWED][MAX_MNEMONIC_WORD_LENGTH] = {"",
"",
"",
""},
heading[50];
for (int i = 0; i < wallet_count; i++) {
strcpy(choices[i], (char *)wallet_list[i][0]);
}
Expand Down

0 comments on commit 6adc401

Please sign in to comment.