Skip to content

Commit

Permalink
[WIP] Refactor ui_path_and_hash_state_t
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Mar 21, 2023
1 parent 466daeb commit 212360c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/ui/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ bool ui_display_message_hash(dispatcher_context_t *context,
const char *message_hash) {
ui_path_and_hash_state_t *state = (ui_path_and_hash_state_t *) &g_ui_state;

strncpy(state->bip32_path_str, bip32_path_str, sizeof(state->bip32_path_str));
strncpy(state->hash_hex, message_hash, sizeof(state->hash_hex));
state->bip32_path_str = bip32_path_str;
state->bip32_path_str_len = strlen(bip32_path_str);

state->hash_hex = message_hash;
state->hash_hex_len = strlen(message_hash);

ui_sign_message_flow();

Expand Down
8 changes: 6 additions & 2 deletions src/ui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ typedef struct {
} ui_path_and_pubkey_state_t;

typedef struct {
char bip32_path_str[MAX_SERIALIZED_BIP32_PATH_LENGTH + 1];
char hash_hex[64 + 1];
ui_title_and_text_state_t title_and_text;

const char *bip32_path_str;
size_t bip32_path_str_len;
const char *hash_hex;
size_t hash_hex_len;
} ui_path_and_hash_state_t;

typedef struct {
Expand Down
34 changes: 22 additions & 12 deletions src/ui/display_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,29 @@ UX_STEP_NOCB(ux_sign_message_step,
"message",
});

UX_STEP_NOCB(ux_message_sign_display_path_step,
bnnn_paging,
{
.title = "Path",
.text = g_ui_state.path_and_hash.bip32_path_str,
});
UX_STEP_NOCB_INIT(ux_message_sign_display_path_step,
bnnn_paging,
{
update_title("Path", sizeof("Path"));
update_text(g_ui_state.path_and_hash.bip32_path_str,
g_ui_state.path_and_hash.bip32_path_str_len);
},
{
.title = g_ui_state.title_and_text.title,
.text = g_ui_state.title_and_text.text,
});

UX_STEP_NOCB(ux_message_hash_step,
bnnn_paging,
{
.title = "Message hash",
.text = g_ui_state.path_and_hash.hash_hex,
});
UX_STEP_NOCB_INIT(ux_message_hash_step,
bnnn_paging,
{
update_title("Message hash", sizeof("Message hash"));
update_text(g_ui_state.path_and_hash.hash_hex,
g_ui_state.path_and_hash.hash_hex_len);
},
{
.title = g_ui_state.title_and_text.title,
.text = g_ui_state.title_and_text.text,
});

UX_STEP_CB(ux_sign_message_accept_new,
pbb,
Expand Down

0 comments on commit 212360c

Please sign in to comment.