Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,18 @@ typedef struct swap_app_context_s {
extern swap_app_context_t G_swap_ctx;

#ifdef HAVE_NBGL

// Boolean like status + a special value
typedef enum last_cycle_status_e {
LAST_CYCLE_ERROR = 0,
LAST_CYCLE_SUCCESS = 1,
LAST_CYCLE_EXCEPTION = 2,
} last_cycle_status_t;

// On Stax, remember some data from the previous cycle if applicable to display a status screen
typedef struct previous_cycle_data_s {
bool had_previous_cycle;
bool was_successful;
last_cycle_status_t was_successful;
char appname_last_cycle[BOLOS_APPNAME_MAX_SIZE_B + 1];
} previous_cycle_data_t;

Expand Down
10 changes: 7 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ __attribute__((section(".boot"))) int main(__attribute__((unused)) int arg0) {
// - we need a BSS reset + UX_INIT
if (G_previous_cycle_data.had_previous_cycle) {
G_previous_cycle_data.had_previous_cycle = false;
if (G_previous_cycle_data.was_successful) {
if (G_previous_cycle_data.was_successful == LAST_CYCLE_ERROR) {
PRINTF("Displaying modal for failed last cycle\n");
display_signing_failure(G_previous_cycle_data.appname_last_cycle);
} else if (G_previous_cycle_data.was_successful == LAST_CYCLE_SUCCESS) {
PRINTF("Displaying modal for successful last cycle\n");
display_signing_success();
} else {
PRINTF("Displaying modal for failed last cycle\n");
display_signing_failure(G_previous_cycle_data.appname_last_cycle);
// LAST_CYCLE_EXCEPTION
PRINTF("Displaying modal for exception last cycle\n");
display_signing_exception(G_previous_cycle_data.appname_last_cycle);
}
} else {
ui_idle();
Expand Down
17 changes: 17 additions & 0 deletions src/ui/sign_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
(sizeof(REFUSAL_TEXT_PART_2) - 1) + 1)
static char refusal_text[REFUSAL_TEXT_MAX_SIZE];

#define EXCEPTION_TEXT_PART_1 "Exception raised\nby the\n"
#define EXCEPTION_TEXT_PART_2 " app.\nTransaction state is unknown"
#define EXCEPTION_TEXT_MAX_SIZE \
((sizeof(EXCEPTION_TEXT_PART_1) - 1) + (sizeof(G_swap_ctx.payin_binary_name) - 1) + \
(sizeof(EXCEPTION_TEXT_PART_2) - 1) + 1)
static char exception_text[EXCEPTION_TEXT_MAX_SIZE];

void display_signing_failure(const char *appname) {
snprintf(refusal_text,
sizeof(refusal_text),
Expand All @@ -26,4 +33,14 @@ void display_signing_success(void) {
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, ui_idle);
}

void display_signing_exception(const char *appname) {
snprintf(exception_text,
sizeof(exception_text),
"%s%s%s",
REFUSAL_TEXT_PART_1,
appname,
REFUSAL_TEXT_PART_2);
nbgl_useCaseStatus(exception_text, false, ui_idle);
}

#endif // HAVE_NBGL
1 change: 1 addition & 0 deletions src/ui/sign_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
// The "Ledger Moment" modal is only available on Stax
void display_signing_success(void);
void display_signing_failure(const char *appname);
void display_signing_exception(const char *appname);
#endif // HAVE_NBGL
Loading