Skip to content

Commit

Permalink
rename io_seproxyhal_cancel, remove io_seproxyhal_display(), io_event…
Browse files Browse the repository at this point in the history
…() and io_exchange_al()
  • Loading branch information
chris124567 committed Jan 23, 2024
1 parent b1aeff3 commit deccf19
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 79 deletions.
76 changes: 1 addition & 75 deletions src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void io_exchange_with_code(uint16_t code, uint16_t tx) {
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx);
}

unsigned int io_seproxyhal_cancel(void) {
unsigned int io_reject(void) {
io_exchange_with_code(SW_USER_REJECTED, 0);
// Return to the main screen.
ui_idle();
Expand Down Expand Up @@ -272,80 +272,6 @@ static handler_fn_t *lookupHandler(uint8_t ins) {
// Next, we'll look at how the various commands are implemented. We'll start
// with the simplest command, signHash.c.

// override point, but nothing more to do
#ifdef HAVE_BAGL
void io_seproxyhal_display(const bagl_element_t *element) {
io_seproxyhal_display_default((bagl_element_t *) element);
}
#endif

uint8_t io_event(uint8_t channel) {
UNUSED(channel);

switch (G_io_seproxyhal_spi_buffer[0]) {
case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT:
#ifdef HAVE_BAGL
UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer);
#endif // HAVE_BAGL
break;
case SEPROXYHAL_TAG_STATUS_EVENT:
if (G_io_apdu_media == IO_APDU_MEDIA_USB_HID && //
!(U4BE(G_io_seproxyhal_spi_buffer, 3) & //
SEPROXYHAL_TAG_STATUS_EVENT_FLAG_USB_POWERED)) {
THROW(EXCEPTION_IO_RESET);
}
__attribute__((fallthrough));
case SEPROXYHAL_TAG_DISPLAY_PROCESSED_EVENT:
#ifdef HAVE_BAGL
UX_DISPLAYED_EVENT({});
#endif // HAVE_BAGL
#ifdef HAVE_NBGL
UX_DEFAULT_EVENT();
#endif // HAVE_NBGL
break;
#ifdef HAVE_NBGL
case SEPROXYHAL_TAG_FINGER_EVENT:
UX_FINGER_EVENT(G_io_seproxyhal_spi_buffer);
break;
#endif // HAVE_NBGL
case SEPROXYHAL_TAG_TICKER_EVENT:
UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, {});
break;
default:
UX_DEFAULT_EVENT();
break;
}

if (!io_seproxyhal_spi_is_status_sent()) {
io_seproxyhal_general_status();
}

return 1;
}

uint16_t io_exchange_al(uint8_t channel, uint16_t tx_len) {
switch (channel & ~(IO_FLAGS)) {
case CHANNEL_KEYBOARD:
break;
case CHANNEL_SPI:
if (tx_len) {
io_seproxyhal_spi_send(G_io_apdu_buffer, tx_len);

if (channel & IO_RESET_AFTER_REPLIED) {
halt();
}

return 0;
} else {
return io_seproxyhal_spi_recv(G_io_apdu_buffer, sizeof(G_io_apdu_buffer), 0);
}
default:
THROW(INVALID_PARAMETER);
}

return 0;
}

void app_main() {
// Mark the transaction context as uninitialized.
explicit_bzero(&global, sizeof(global));
Expand Down
2 changes: 1 addition & 1 deletion src/calcTxnHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ UX_STEP_VALID(ux_sign_txn_flow_2_step,
io_seproxyhal_touch_txn_hash_ok(),
{&C_icon_validate_14, "Approve"});

UX_STEP_VALID(ux_sign_txn_flow_3_step, pb, io_seproxyhal_cancel(), {&C_icon_crossmark, "Reject"});
UX_STEP_VALID(ux_sign_txn_flow_3_step, pb, io_reject(), {&C_icon_crossmark, "Reject"});

// Flow for the signing transaction menu:
// #1 screen: "Sign this txn?"
Expand Down
2 changes: 1 addition & 1 deletion src/getPublicKey.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ UX_STEP_VALID(ux_approve_pk_flow_2_step,
io_seproxyhal_touch_pk_ok(),
{&C_icon_validate_14, "Approve"});

UX_STEP_VALID(ux_approve_pk_flow_3_step, pb, io_seproxyhal_cancel(), {&C_icon_crossmark, "Reject"});
UX_STEP_VALID(ux_approve_pk_flow_3_step, pb, io_reject(), {&C_icon_crossmark, "Reject"});

// Flow for the public key/address menu:
// #1 screen: "generate address/public key from key #x?"
Expand Down
2 changes: 1 addition & 1 deletion src/sia_ux.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ void ui_menu_about(void);
void io_exchange_with_code(uint16_t code, uint16_t tx);

// standard "reject" function so we don't repeat code
unsigned int io_seproxyhal_cancel(void);
unsigned int io_reject(void);

#endif /* SIA_UX_H */
2 changes: 1 addition & 1 deletion src/signHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ UX_STEP_VALID(ux_approve_hash_flow_2_step,

UX_STEP_VALID(ux_approve_hash_flow_3_step,
pb,
io_seproxyhal_cancel(),
io_reject(),
{&C_icon_crossmark, "Reject"});

// Flow for the signing hash menu:
Expand Down

0 comments on commit deccf19

Please sign in to comment.