Extract EIP-712 UI code

This commit is contained in:
Alexandre Paillier
2022-08-25 10:26:48 +02:00
parent ab67ae1cb3
commit 1b46ccb190
6 changed files with 10 additions and 12 deletions

View File

@@ -1,57 +0,0 @@
#ifdef HAVE_EIP712_FULL_SUPPORT
#include "ui_flow_712.h"
#include "ui_logic.h"
#include "shared_context.h" // strings
// clang-format off
UX_STEP_NOCB(
ux_712_step_review,
pnn,
{
&C_icon_eye,
"Review",
"typed message",
});
UX_STEP_NOCB(
ux_712_step_dynamic,
bnnn_paging,
{
.title = strings.tmp.tmp2,
.text = strings.tmp.tmp,
}
);
UX_STEP_INIT(
ux_712_step_dummy,
NULL,
NULL,
{
ui_712_next_field();
}
);
UX_STEP_CB(
ux_712_step_approve,
pb,
ui_712_approve(NULL),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(
ux_712_step_reject,
pb,
ui_712_reject(NULL),
{
&C_icon_crossmark,
"Reject",
});
// clang-format on
UX_FLOW(ux_712_flow,
&ux_712_step_review,
&ux_712_step_dynamic,
&ux_712_step_dummy,
&ux_712_step_approve,
&ux_712_step_reject);
#endif // HAVE_EIP712_FULL_SUPPORT

View File

@@ -1,12 +0,0 @@
#ifndef UI_FLOW_712_H_
#define UI_FLOW_712_H_
#ifdef HAVE_EIP712_FULL_SUPPORT
#include "ux_flow_engine.h"
extern const ux_flow_step_t* const ux_712_flow[];
#endif // HAVE_EIP712_FULL_SUPPORT
#endif // UI_FLOW_712_H_

View File

@@ -451,8 +451,8 @@ void ui_712_deinit(void) {
* @param[in] e unused here, just needed to match the UI function signature
* @return unused here, just needed to match the UI function signature
*/
unsigned int ui_712_approve(const bagl_element_t *e) {
ui_712_approve_cb(e);
unsigned int ui_712_approve() {
ui_712_approve_cb();
eip712_context_deinit();
return 0;
}
@@ -464,8 +464,8 @@ unsigned int ui_712_approve(const bagl_element_t *e) {
* @param[in] e unused here, just needed to match the UI function signature
* @return unused here, just needed to match the UI function signature
*/
unsigned int ui_712_reject(const bagl_element_t *e) {
ui_712_reject_cb(e);
unsigned int ui_712_reject() {
ui_712_reject_cb();
eip712_context_deinit();
return 0;
}

View File

@@ -29,8 +29,8 @@ void ui_712_next_field(void);
void ui_712_review_struct(const void *const struct_ptr);
bool ui_712_new_field(const void *const field_ptr, const uint8_t *const data, uint8_t length);
void ui_712_end_sign(void);
unsigned int ui_712_approve(const bagl_element_t *e);
unsigned int ui_712_reject(const bagl_element_t *e);
unsigned int ui_712_approve();
unsigned int ui_712_reject();
void ui_712_set_title(const char *const str, uint8_t length);
void ui_712_set_value(const char *const str, uint8_t length);
void ui_712_message_hash(void);

View File

@@ -5,14 +5,13 @@
static const uint8_t EIP_712_MAGIC[] = {0x19, 0x01};
unsigned int ui_712_approve_cb(const bagl_element_t *e) {
unsigned int ui_712_approve_cb() {
uint8_t privateKeyData[INT256_LENGTH];
uint8_t hash[INT256_LENGTH];
uint8_t signature[100];
cx_ecfp_private_key_t privateKey;
uint32_t tx = 0;
(void) e;
io_seproxyhal_io_heartbeat();
cx_keccak_init(&global_sha3, 256);
cx_hash((cx_hash_t *) &global_sha3,
@@ -74,8 +73,7 @@ unsigned int ui_712_approve_cb(const bagl_element_t *e) {
return 0; // do not redraw the widget
}
unsigned int ui_712_reject_cb(const bagl_element_t *e) {
(void) e;
unsigned int ui_712_reject_cb() {
reset_app_context();
G_io_apdu_buffer[0] = 0x69;
G_io_apdu_buffer[1] = 0x85;

View File

@@ -4,7 +4,7 @@
#include <stdint.h>
#include "ux.h"
unsigned int ui_712_approve_cb(const bagl_element_t *e);
unsigned int ui_712_reject_cb(const bagl_element_t *e);
unsigned int ui_712_approve_cb();
unsigned int ui_712_reject_cb();
#endif // COMMON_EIP712_H_