Skip to content

Commit

Permalink
Don't display main menu during swap
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Feb 1, 2023
1 parent e7d3bc6 commit 4ae4e68
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/getPubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ UX_STEP_NOCB(ux_display_public_flow_5_step,
});
UX_STEP_CB(ux_display_public_flow_6_step,
pb,
sendResponse(set_result_get_pubkey(), true),
sendResponse(set_result_get_pubkey(), true, true),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(ux_display_public_flow_7_step,
pb,
sendResponse(0, false),
sendResponse(0, false, true),
{
&C_icon_crossmark,
"Reject",
Expand Down
9 changes: 3 additions & 6 deletions src/signMessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,19 @@ static uint8_t set_result_sign_message() {
return SIGNATURE_LENGTH;
}

static void send_result_sign_message(void) {
sendResponse(set_result_sign_message(), true);
}

//////////////////////////////////////////////////////////////////////

UX_STEP_CB(ux_approve_step,
pb,
send_result_sign_message(),
sendResponse(set_result_sign_message(), true, true),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(ux_reject_step,
pb,
sendResponse(0, false),
sendResponse(0, false, true),
{
&C_icon_crossmark,
"Reject",
Expand Down Expand Up @@ -225,7 +222,7 @@ void handle_sign_message_ui(volatile unsigned int *flags) {
}
if (check_swap_validity(summary_step_kinds, num_summary_steps)) {
PRINTF("Valid swap transaction signed\n");
send_result_sign_message();
sendResponse(set_result_sign_message(), true, false);
} else {
PRINTF("Refused signing incorrect Swap transaction\n");
THROW(ApduReplySolanaSummaryFinalizeFailed);
Expand Down
4 changes: 2 additions & 2 deletions src/signOffchainMessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ UX_STEP_NOCB(ux_sign_msg_text_step,
});
UX_STEP_CB(ux_sign_msg_approve_step,
pb,
sendResponse(set_result_sign_message(), true),
sendResponse(set_result_sign_message(), true, true),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(ux_sign_msg_reject_step,
pb,
sendResponse(0, false),
sendResponse(0, false, true),
{
&C_icon_crossmark,
"Reject",
Expand Down
8 changes: 5 additions & 3 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ int read_derivation_path(const uint8_t *data_buffer,
return 0;
}

void sendResponse(uint8_t tx, bool approve) {
void sendResponse(uint8_t tx, bool approve, bool display_menu) {
G_io_apdu_buffer[tx++] = approve ? 0x90 : 0x69;
G_io_apdu_buffer[tx++] = approve ? 0x00 : 0x85;
// Send back the response, do not restart the event loop
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx);
// Display back the original UX
ui_idle();
if (display_menu) {
// Display back the original UX
ui_idle();
}
}

unsigned int ui_prepro(const bagl_element_t *element) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int read_derivation_path(const uint8_t *data_buffer,
uint32_t *derivation_path,
uint32_t *derivation_path_length);

void sendResponse(uint8_t tx, bool approve);
void sendResponse(uint8_t tx, bool approve, bool display_menu);

// type userid x y w h str rad fill fg bg fid iid txt
// touchparams... ]
Expand Down

0 comments on commit 4ae4e68

Please sign in to comment.