eth: split ux from rest of source
This commit is contained in:
24
src/common_ui.h
Normal file
24
src/common_ui.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _COMMON_UI_H_
|
||||
#define _COMMON_UI_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void ui_idle(void);
|
||||
void ui_warning_contract_data(void);
|
||||
void ui_display_public_eth2(void);
|
||||
void ui_display_privacy_public_key(void);
|
||||
void ui_display_privacy_shared_secret(void);
|
||||
void ui_display_public_key(void);
|
||||
void ui_display_sign(void);
|
||||
void ui_sign_712_v0(void);
|
||||
void ui_display_stark_public(void);
|
||||
void ui_confirm_selector(void);
|
||||
void ui_confirm_parameter(void);
|
||||
void ui_stark_limit_order(void);
|
||||
void ui_stark_unsafe_sign(void);
|
||||
void ui_stark_transfer(bool selfTransfer, bool conditional);
|
||||
|
||||
#include "ui_callbacks.h"
|
||||
#include <string.h>
|
||||
|
||||
#endif // _COMMON_UI_H_
|
||||
@@ -1,8 +1,4 @@
|
||||
#include "shared_context.h"
|
||||
#ifdef HAVE_UX_FLOW
|
||||
#include "ui_flow.h"
|
||||
#endif
|
||||
#include "ui_callbacks.h"
|
||||
#include "eth_plugin_handler.h"
|
||||
#include "ux.h"
|
||||
#include "feature_signTx.h"
|
||||
|
||||
21
src/main.c
21
src/main.c
@@ -17,8 +17,7 @@
|
||||
|
||||
#include "shared_context.h"
|
||||
#include "apdu_constants.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "ui_flow.h"
|
||||
#include "common_ui.h"
|
||||
|
||||
#include "os_io_seproxyhal.h"
|
||||
|
||||
@@ -84,24 +83,6 @@ void reset_app_context() {
|
||||
memset((uint8_t *) &tmpContent, 0, sizeof(tmpContent));
|
||||
}
|
||||
|
||||
void ui_idle(void) {
|
||||
// reserve a display stack slot if none yet
|
||||
if (G_ux.stack_count == 0) {
|
||||
ux_stack_push();
|
||||
}
|
||||
ux_flow_init(0, ux_idle_flow, NULL);
|
||||
}
|
||||
|
||||
void ui_warning_contract_data(void) {
|
||||
ux_flow_init(0, ux_warning_contract_data_flow, NULL);
|
||||
}
|
||||
|
||||
unsigned int io_seproxyhal_touch_exit(__attribute__((unused)) const bagl_element_t *e) {
|
||||
// Go back to the dashboard
|
||||
os_sched_exit(0);
|
||||
return 0; // do not redraw the widget
|
||||
}
|
||||
|
||||
void io_seproxyhal_send_status(uint32_t sw) {
|
||||
G_io_apdu_buffer[0] = ((sw >> 8) & 0xff);
|
||||
G_io_apdu_buffer[1] = (sw & 0xff);
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
#include "shared_context.h"
|
||||
#include "stark_utils.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "utils.h"
|
||||
#include "ethUtils.h"
|
||||
|
||||
extraInfo_t *getKnownToken(uint8_t *contractAddress);
|
||||
|
||||
static unsigned char const C_cx_Stark256_n[] = {
|
||||
// n: 0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
||||
@@ -19,6 +19,9 @@ unsigned int io_seproxyhal_touch_signMessage712_v0_cancel(const bagl_element_t *
|
||||
unsigned int io_seproxyhal_touch_eth2_address_ok(const bagl_element_t *e);
|
||||
unsigned int io_seproxyhal_touch_privacy_ok(const bagl_element_t *e);
|
||||
unsigned int io_seproxyhal_touch_privacy_cancel(const bagl_element_t *e);
|
||||
unsigned int io_seproxyhal_touch_stark_unsafe_sign_ok(const bagl_element_t *e);
|
||||
unsigned int io_seproxyhal_touch_stark_pubkey_ok(const bagl_element_t *e);
|
||||
unsigned int io_seproxyhal_touch_stark_ok(const bagl_element_t *e);
|
||||
|
||||
void ui_idle(void);
|
||||
void ui_warning_contract_data(void);
|
||||
|
||||
187
src/ui_flow.c
187
src/ui_flow.c
@@ -1,187 +0,0 @@
|
||||
#include "shared_context.h"
|
||||
#include "ui_callbacks.h"
|
||||
|
||||
void display_settings(const ux_flow_step_t* const start_step);
|
||||
void switch_settings_blind_signing(void);
|
||||
void switch_settings_display_data(void);
|
||||
void switch_settings_display_nonce(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
UX_STEP_NOCB(
|
||||
ux_idle_flow_1_step,
|
||||
nn, //pnn,
|
||||
{
|
||||
//"", //&C_icon_dashboard,
|
||||
"Application",
|
||||
"is ready",
|
||||
});
|
||||
UX_STEP_NOCB(
|
||||
ux_idle_flow_2_step,
|
||||
bn,
|
||||
{
|
||||
"Version",
|
||||
APPVERSION,
|
||||
});
|
||||
UX_STEP_CB(
|
||||
ux_idle_flow_3_step,
|
||||
pb,
|
||||
display_settings(NULL),
|
||||
{
|
||||
&C_icon_eye,
|
||||
"Settings",
|
||||
});
|
||||
UX_STEP_CB(
|
||||
ux_idle_flow_4_step,
|
||||
pb,
|
||||
os_sched_exit(-1),
|
||||
{
|
||||
&C_icon_dashboard_x,
|
||||
"Quit",
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
UX_FLOW(ux_idle_flow,
|
||||
&ux_idle_flow_1_step,
|
||||
&ux_idle_flow_2_step,
|
||||
&ux_idle_flow_3_step,
|
||||
&ux_idle_flow_4_step,
|
||||
FLOW_LOOP);
|
||||
|
||||
#if defined(TARGET_NANOS)
|
||||
|
||||
// clang-format off
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_1_step,
|
||||
bnnn_paging,
|
||||
switch_settings_blind_signing(),
|
||||
{
|
||||
.title = "Blind signing",
|
||||
.text = strings.common.fullAddress,
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_2_step,
|
||||
bnnn_paging,
|
||||
switch_settings_display_data(),
|
||||
{
|
||||
.title = "Debug data",
|
||||
.text = strings.common.fullAddress + 12
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_3_step,
|
||||
bnnn_paging,
|
||||
switch_settings_display_nonce(),
|
||||
{
|
||||
.title = "Account nonce",
|
||||
.text = strings.common.fullAddress + 26
|
||||
});
|
||||
|
||||
#else
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_1_step,
|
||||
bnnn,
|
||||
switch_settings_blind_signing(),
|
||||
{
|
||||
"Blind signing",
|
||||
"Enable transaction",
|
||||
"blind signing",
|
||||
strings.common.fullAddress,
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_2_step,
|
||||
bnnn,
|
||||
switch_settings_display_data(),
|
||||
{
|
||||
"Debug data",
|
||||
"Display contract data",
|
||||
"details",
|
||||
strings.common.fullAddress + 12
|
||||
});
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_3_step,
|
||||
bnnn,
|
||||
switch_settings_display_nonce(),
|
||||
{
|
||||
"Nonce",
|
||||
"Display account nonce",
|
||||
"in transactions",
|
||||
strings.common.fullAddress + 26
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
UX_STEP_CB(
|
||||
ux_settings_flow_4_step,
|
||||
pb,
|
||||
ui_idle(),
|
||||
{
|
||||
&C_icon_back_x,
|
||||
"Back",
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
UX_FLOW(ux_settings_flow,
|
||||
&ux_settings_flow_1_step,
|
||||
&ux_settings_flow_2_step,
|
||||
&ux_settings_flow_3_step,
|
||||
&ux_settings_flow_4_step);
|
||||
|
||||
void display_settings(const ux_flow_step_t* const start_step) {
|
||||
strlcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Enabled" : "NOT Enabled"), 12);
|
||||
strlcpy(strings.common.fullAddress + 12,
|
||||
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"),
|
||||
26 - 12);
|
||||
strlcpy(strings.common.fullAddress + 26,
|
||||
(N_storage.displayNonce ? "Displayed" : "NOT Displayed"),
|
||||
sizeof(strings.common.fullAddress) - 26);
|
||||
ux_flow_init(0, ux_settings_flow, start_step);
|
||||
}
|
||||
|
||||
void switch_settings_blind_signing() {
|
||||
uint8_t value = (N_storage.dataAllowed ? 0 : 1);
|
||||
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
|
||||
display_settings(&ux_settings_flow_1_step);
|
||||
}
|
||||
|
||||
void switch_settings_display_data() {
|
||||
uint8_t value = (N_storage.contractDetails ? 0 : 1);
|
||||
nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t));
|
||||
display_settings(&ux_settings_flow_2_step);
|
||||
}
|
||||
|
||||
void switch_settings_display_nonce() {
|
||||
uint8_t value = (N_storage.displayNonce ? 0 : 1);
|
||||
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
|
||||
display_settings(&ux_settings_flow_3_step);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
#if defined(TARGET_NANOS)
|
||||
UX_STEP_CB(
|
||||
ux_warning_contract_data_step,
|
||||
bnnn_paging,
|
||||
ui_idle(),
|
||||
{
|
||||
"Error",
|
||||
"Blind signing must be enabled in Settings",
|
||||
});
|
||||
#elif defined(TARGET_NANOX) || defined(TARGET_NANOS2)
|
||||
UX_STEP_CB(
|
||||
ux_warning_contract_data_step,
|
||||
pnn,
|
||||
ui_idle(),
|
||||
{
|
||||
&C_icon_crossmark,
|
||||
"Blind signing must be",
|
||||
"enabled in Settings",
|
||||
});
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
UX_FLOW(ux_warning_contract_data_flow, &ux_warning_contract_data_step);
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef _UI_FLOW_H_
|
||||
#define _UI_FLOW_H_
|
||||
|
||||
#include "shared_context.h"
|
||||
|
||||
#include "os_io_seproxyhal.h"
|
||||
#include "ux.h"
|
||||
|
||||
extern const ux_flow_step_t* const ux_idle_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_warning_contract_data_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_settings_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_display_public_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_confirm_selector_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_confirm_parameter_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_allowance_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_sign_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_sign_712_v0_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_display_public_eth2_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_display_privacy_public_key_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_display_privacy_shared_secret_flow[];
|
||||
|
||||
#ifdef HAVE_STARKWARE
|
||||
|
||||
extern const ux_flow_step_t* const ux_display_stark_public_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_limit_order_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_transfer_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_self_transfer_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_transfer_conditional_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_self_transfer_conditional_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_register_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_deposit_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_withdraw_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_verify_vault_id_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_escape_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_approval_starkware_verify_escape_flow[];
|
||||
|
||||
extern const ux_flow_step_t* const ux_stark_unsafe_sign_flow[];
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _UI_FLOW_H_
|
||||
Reference in New Issue
Block a user