forked from LedgerHQ/app-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_flow_signMessage.c
142 lines (129 loc) · 3.02 KB
/
ui_flow_signMessage.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "shared_context.h"
#include "ui_callbacks.h"
#include "common_ui.h"
#include "sign_message.h"
typedef enum { UI_191_POS_REVIEW, UI_191_POS_QUESTION, UI_191_POS_END } e_ui_191_position;
static uint8_t ui_pos;
static void dummy_pre_cb(void) {
if (ui_pos == UI_191_POS_REVIEW) {
question_switcher();
} else {
ux_flow_prev();
ui_pos = UI_191_POS_REVIEW;
}
}
static void dummy_post_cb(void) {
if (ui_pos == UI_191_POS_QUESTION) {
// temporarily disable button clicks, they will be re-enabled as soon as new data
// is received and the page is redrawn with ux_flow_init()
G_ux.stack[0].button_push_callback = NULL;
continue_displaying_message();
} else // UI_191_END
{
ui_191_switch_to_message_end();
}
}
static unsigned int signMessage_ok_cb(void) {
ui_idle();
return io_seproxyhal_touch_signMessage_ok();
}
static unsigned int signMessage_cancel_cb(void) {
ui_idle();
return io_seproxyhal_touch_signMessage_cancel();
}
// clang-format off
UX_STEP_NOCB(
ux_191_step_review,
pnn,
{
&C_icon_certificate,
"Review",
"message",
});
UX_STEP_NOCB(
ux_191_step_message,
bnnn_paging,
{
.title = "Message",
.text = strings.tmp.tmp,
});
UX_STEP_INIT(
ux_191_step_dummy_pre,
NULL,
NULL,
{
dummy_pre_cb();
});
UX_STEP_CB(
ux_191_step_theres_more,
#ifdef TARGET_NANOS
nn,
#else
nnn,
#endif
G_ux.stack[0].button_push_callback = NULL; // disable button clicks
skip_rest_of_message(),
{
#ifndef TARGET_NANOS
"Press right to",
"continue message",
#else
"Press right to read",
#endif
"Double-press to skip"
});
UX_STEP_INIT(
ux_191_step_dummy_post,
NULL,
NULL,
{
dummy_post_cb();
});
UX_STEP_CB(
ux_191_step_sign,
pbb,
signMessage_ok_cb(),
{
&C_icon_validate_14,
"Sign",
"message",
});
UX_STEP_CB(
ux_191_step_cancel,
pbb,
signMessage_cancel_cb(),
{
&C_icon_crossmark,
"Cancel",
"signature",
});
// clang-format on
UX_FLOW(ux_191_flow,
&ux_191_step_review,
&ux_191_step_message,
&ux_191_step_dummy_pre,
&ux_191_step_theres_more,
&ux_191_step_dummy_post,
&ux_191_step_sign,
&ux_191_step_cancel);
void ui_191_start(void) {
ux_flow_init(0, ux_191_flow, NULL);
ui_pos = UI_191_POS_REVIEW;
}
void ui_191_switch_to_message(void) {
ux_flow_init(0, ux_191_flow, &ux_191_step_message);
ui_pos = UI_191_POS_REVIEW;
}
void ui_191_switch_to_message_end(void) {
// Force it to a value that will make it automatically do a prev()
ui_pos = UI_191_POS_QUESTION;
ux_flow_init(0, ux_191_flow, &ux_191_step_dummy_pre);
}
void ui_191_switch_to_sign(void) {
ux_flow_init(0, ux_191_flow, &ux_191_step_sign);
ui_pos = UI_191_POS_END;
}
void ui_191_switch_to_question(void) {
ux_flow_init(0, ux_191_flow, &ux_191_step_theres_more);
ui_pos = UI_191_POS_QUESTION;
}