Skip to content

Commit

Permalink
NBGL: change ui to use flex compatible useCase
Browse files Browse the repository at this point in the history
  • Loading branch information
sgliner-ledger committed Apr 18, 2024
1 parent bd8d380 commit 67b20cd
Show file tree
Hide file tree
Showing 7 changed files with 431 additions and 541 deletions.
7 changes: 1 addition & 6 deletions src/handler/sign_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ static bool display_message_content_and_confirm(dispatcher_context_t* dc,
message_chunk[total_chunk_len] = '\0';
}

if (!ui_display_path_and_message_content(dc,
(char*) path_str,
(char*) message_chunk,
(n_chunks - 1) / MESSAGE_CHUNK_PER_DISPLAY)) {
if (!ui_display_path_and_message_content(dc, (char*) path_str, (char*) message_chunk)) {
return false;
}
}
Expand Down Expand Up @@ -184,13 +181,11 @@ void handler_sign_message(dispatcher_context_t* dc, uint8_t protocol_version) {
n_chunks,
(uint8_t*) path_str)) {
SEND_SW(dc, SW_DENY);
ui_post_processing_confirm_message(dc, false);
return;
}
} else {
if (!ui_display_message_path_hash_and_confirm(dc, path_str, message_hash_str)) {
SEND_SW(dc, SW_DENY);
ui_post_processing_confirm_message(dc, false);
return;
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/handler/sign_psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,15 +690,10 @@ init_global_state(dispatcher_context_t *dc, sign_psbt_state_t *st) {
// If it's not a default wallet policy, ask the user for confirmation, and abort if they deny
if (!st->is_wallet_default && !ui_authorize_wallet_spend(dc, wallet_header.name)) {
SEND_SW(dc, SW_DENY);
ui_post_processing_confirm_wallet_spend(dc, false);
return false;
}

st->master_key_fingerprint = crypto_get_master_key_fingerprint();

if (!st->is_wallet_default) {
ui_post_processing_confirm_wallet_spend(dc, true);
}
return true;
}

Expand Down Expand Up @@ -1312,7 +1307,7 @@ process_outputs(dispatcher_context_t *dc, sign_psbt_state_t *st) {

if (!read_outputs(dc, st, &placeholder_info, true)) return false;

if (!G_swap_state.called_from_swap && !ui_transaction_prompt(dc, st->outputs.n_external)) {
if (!G_swap_state.called_from_swap && !ui_transaction_prompt(dc)) {
SEND_SW(dc, SW_DENY);
return false;
}
Expand Down
27 changes: 7 additions & 20 deletions src/ui/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ bool ui_display_pubkey(dispatcher_context_t *context,

bool ui_display_path_and_message_content(dispatcher_context_t *context,
const char *path_str,
const char *message_content,
uint8_t pageCount) {
const char *message_content) {
ui_path_and_message_state_t *state = (ui_path_and_message_state_t *) &g_ui_state;
strncpy(state->bip32_path_str, path_str, sizeof(state->bip32_path_str));
strncpy(state->message, message_content, sizeof(state->message));

ui_sign_message_content_flow(pageCount);
ui_sign_message_content_flow();

return io_ui_process(context, true);
}
Expand Down Expand Up @@ -221,8 +220,8 @@ bool ui_warn_nondefault_sighash(dispatcher_context_t *context) {
return io_ui_process(context, true);
}

bool ui_transaction_prompt(dispatcher_context_t *context, const int external_outputs_total_count) {
ui_display_transaction_prompt(external_outputs_total_count);
bool ui_transaction_prompt(dispatcher_context_t *context) {
ui_display_transaction_prompt();
return io_ui_process(context, true);
}

Expand Down Expand Up @@ -274,12 +273,6 @@ bool ui_post_processing_confirm_wallet_registration(dispatcher_context_t *contex
return true;
}

bool ui_post_processing_confirm_wallet_spend(dispatcher_context_t *context, bool success) {
(void) context;
(void) success;
return true;
}

bool ui_post_processing_confirm_transaction(dispatcher_context_t *context, bool success) {
(void) context;
(void) success;
Expand All @@ -300,26 +293,20 @@ void ui_pre_processing_message(void) {
#ifdef HAVE_NBGL
bool ui_post_processing_confirm_wallet_registration(dispatcher_context_t *context, bool success) {
(void) context;
ui_display_post_processing_confirm_wallet_registation(success);
ui_display_post_processing(success);

return true;
}

bool ui_post_processing_confirm_wallet_spend(dispatcher_context_t *context, bool success) {
ui_display_post_processing_confirm_wallet_spend(success);

return io_ui_process(context, success);
}

bool ui_post_processing_confirm_transaction(dispatcher_context_t *context, bool success) {
ui_display_post_processing_confirm_transaction(success);
ui_display_post_processing(success);

return io_ui_process(context, success);
}

bool ui_post_processing_confirm_message(dispatcher_context_t *context, bool success) {
(void) context;
ui_display_post_processing_confirm_message(success);
ui_display_post_processing(success);

return true;
}
Expand Down
14 changes: 5 additions & 9 deletions src/ui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ bool ui_display_pubkey(dispatcher_context_t *context,

bool ui_display_path_and_message_content(dispatcher_context_t *context,
const char *path_str,
const char *message_content,
uint8_t pageCount);
const char *message_content);

bool ui_display_message_path_hash_and_confirm(dispatcher_context_t *context,
const char *path_str,
Expand Down Expand Up @@ -164,7 +163,7 @@ void ui_display_pubkey_suspicious_flow(void);

void ui_sign_message_path_hash_and_confirm_flow(void);

void ui_sign_message_content_flow(uint8_t pageCount);
void ui_sign_message_content_flow(void);

void ui_sign_message_confirm_flow(void);

Expand Down Expand Up @@ -192,7 +191,7 @@ void ui_warn_high_fee_flow(void);

void ui_accept_transaction_flow(bool is_self_transfer);

void ui_display_transaction_prompt(const int external_outputs_total_count);
void ui_display_transaction_prompt(void);

bool ui_post_processing_confirm_wallet_registration(dispatcher_context_t *context, bool success);

Expand All @@ -205,11 +204,8 @@ bool ui_post_processing_confirm_message(dispatcher_context_t *context, bool succ
void ui_pre_processing_message(void);

#ifdef HAVE_NBGL
bool ui_transaction_prompt(dispatcher_context_t *context, const int external_outputs_total_count);
void ui_display_post_processing_confirm_message(bool success);
void ui_display_post_processing_confirm_wallet_registation(bool success);
void ui_display_post_processing_confirm_transaction(bool success);
void ui_display_post_processing_confirm_wallet_spend(bool success);
bool ui_transaction_prompt(dispatcher_context_t *context);
void ui_display_post_processing(bool success);
void ui_set_display_prompt(void);
#else
#define ux_layout_custom_params_t ux_layout_paging_params_t
Expand Down
3 changes: 1 addition & 2 deletions src/ui/display_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ void ui_sign_message_path_hash_and_confirm_flow(void) {
ux_flow_init(0, ux_sign_message_path_hash_and_confirm_flow, NULL);
}

void ui_sign_message_content_flow(uint8_t pageCount) {
(void) pageCount;
void ui_sign_message_content_flow(void) {
if (get_streaming_index() == 0) {
ux_flow_init(0, ux_sign_message_path_and_content_flow, NULL);
} else {
Expand Down
Loading

0 comments on commit 67b20cd

Please sign in to comment.