Files
app-ethereum/src_bagl/ui_flow_signTx.c

254 lines
5.8 KiB
C
Raw Normal View History

2020-06-27 13:24:04 +02:00
#include "shared_context.h"
#include "ui_callbacks.h"
#include "chainConfig.h"
2024-01-16 13:51:36 +01:00
#include "common_utils.h"
#include "feature_signTx.h"
#include "network.h"
#include "eth_plugin_handler.h"
#include "ui_plugin.h"
2022-08-24 09:25:01 +02:00
#include "common_ui.h"
2022-10-13 12:59:57 +02:00
#include "plugins.h"
2023-02-17 16:56:12 +01:00
#include "domain_name.h"
#include "ui_domain_name.h"
2020-12-01 16:20:13 +01:00
// clang-format off
UX_STEP_NOCB(
2020-06-27 13:24:04 +02:00
ux_confirm_selector_flow_1_step,
pnn,
{
&C_icon_eye,
"Verify",
"selector",
});
UX_STEP_NOCB(
2020-06-27 13:24:04 +02:00
ux_confirm_selector_flow_2_step,
bn,
{
"Selector",
strings.tmp.tmp
});
UX_STEP_CB(
2020-06-27 13:24:04 +02:00
ux_confirm_selector_flow_3_step,
pb,
io_seproxyhal_touch_data_ok(NULL),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(
2020-06-27 13:24:04 +02:00
ux_confirm_selector_flow_4_step,
pb,
io_seproxyhal_touch_data_cancel(NULL),
{
&C_icon_crossmark,
"Reject",
});
2020-12-01 16:20:13 +01:00
// clang-format on
2020-06-27 13:24:04 +02:00
2020-12-01 16:20:13 +01:00
UX_FLOW(ux_confirm_selector_flow,
&ux_confirm_selector_flow_1_step,
&ux_confirm_selector_flow_2_step,
&ux_confirm_selector_flow_3_step,
&ux_confirm_selector_flow_4_step);
2020-06-27 13:24:04 +02:00
//////////////////////////////////////////////////////////////////////
2020-12-01 16:20:13 +01:00
// clang-format off
UX_STEP_NOCB(
2020-06-27 13:24:04 +02:00
ux_confirm_parameter_flow_1_step,
pnn,
{
&C_icon_eye,
"Verify",
strings.tmp.tmp2
});
UX_STEP_NOCB(
2020-06-27 13:24:04 +02:00
ux_confirm_parameter_flow_2_step,
bnnn_paging,
{
.title = "Parameter",
.text = strings.tmp.tmp,
});
UX_STEP_CB(
2020-06-27 13:24:04 +02:00
ux_confirm_parameter_flow_3_step,
pb,
io_seproxyhal_touch_data_ok(NULL),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(
2020-06-27 13:24:04 +02:00
ux_confirm_parameter_flow_4_step,
pb,
io_seproxyhal_touch_data_cancel(NULL),
{
&C_icon_crossmark,
"Reject",
});
2020-12-01 16:20:13 +01:00
// clang-format on
2020-06-27 13:24:04 +02:00
UX_FLOW(ux_confirm_parameter_flow,
2020-12-01 16:20:13 +01:00
&ux_confirm_parameter_flow_1_step,
&ux_confirm_parameter_flow_2_step,
&ux_confirm_parameter_flow_3_step,
&ux_confirm_parameter_flow_4_step);
2020-06-27 13:24:04 +02:00
//////////////////////////////////////////////////////////////////////
2020-12-01 16:20:13 +01:00
// clang-format off
UX_STEP_NOCB(ux_approval_review_step,
2020-06-27 13:24:04 +02:00
pnn,
{
&C_icon_eye,
"Review",
"transaction",
});
UX_STEP_NOCB(
ux_approval_amount_step,
2020-06-27 13:24:04 +02:00
bnnn_paging,
{
.title = "Amount",
.text = strings.common.fullAmount
});
UX_STEP_NOCB(
ux_approval_address_step,
2020-06-27 13:24:04 +02:00
bnnn_paging,
{
.title = "Address",
.text = strings.common.fullAddress,
});
UX_STEP_NOCB_INIT(
ux_plugin_approval_id_step,
bnnn_paging,
plugin_ui_get_id(),
{
.title = strings.common.fullAddress,
.text = strings.common.fullAmount
});
UX_STEP_INIT(
ux_plugin_approval_before_step,
NULL,
NULL,
{
display_next_plugin_item(true);
});
UX_FLOW_DEF_NOCB(
ux_plugin_approval_display_step,
bnnn_paging,
{
.title = strings.common.fullAddress,
.text = strings.common.fullAmount
});
UX_STEP_INIT(
ux_plugin_approval_after_step,
NULL,
NULL,
{
display_next_plugin_item(false);
});
UX_STEP_NOCB(
ux_approval_fees_step,
2020-06-27 13:24:04 +02:00
bnnn_paging,
{
.title = "Max Fees",
.text = strings.common.maxFee,
});
UX_STEP_NOCB(
ux_approval_network_step,
bnnn_paging,
{
.title = "Network",
.text = strings.common.network_name,
});
UX_STEP_CB(
ux_approval_accept_step,
2020-06-27 13:24:04 +02:00
pbb,
io_seproxyhal_touch_tx_ok(NULL),
{
&C_icon_validate_14,
"Accept",
"and send",
});
UX_STEP_CB(
ux_approval_reject_step,
2020-06-27 13:24:04 +02:00
pb,
io_seproxyhal_touch_tx_cancel(NULL),
{
&C_icon_crossmark,
"Reject",
});
UX_STEP_NOCB(
ux_approval_nonce_step,
bnnn_paging,
{
.title = "Nonce",
.text = strings.common.nonce,
});
UX_STEP_NOCB(ux_approval_blind_signing_warning_step,
2020-06-27 13:24:04 +02:00
pbb,
{
&C_icon_warning,
"Blind",
"Signing",
2020-06-27 13:24:04 +02:00
});
2020-12-01 16:20:13 +01:00
// clang-format on
2020-06-27 13:24:04 +02:00
const ux_flow_step_t *ux_approval_tx_flow[15];
2020-06-27 13:24:04 +02:00
void ux_approve_tx(bool fromPlugin) {
2021-02-05 17:58:21 +01:00
int step = 0;
2021-06-11 11:37:16 +02:00
ux_approval_tx_flow[step++] = &ux_approval_review_step;
2021-06-15 10:18:32 +02:00
if (!fromPlugin && tmpContent.txContent.dataPresent && !N_storage.contractDetails) {
ux_approval_tx_flow[step++] = &ux_approval_blind_signing_warning_step;
2021-02-05 17:58:21 +01:00
}
if (fromPlugin) {
// Add the special dynamic display logic
ux_approval_tx_flow[step++] = &ux_plugin_approval_id_step;
ux_approval_tx_flow[step++] = &ux_plugin_approval_before_step;
ux_approval_tx_flow[step++] = &ux_plugin_approval_display_step;
ux_approval_tx_flow[step++] = &ux_plugin_approval_after_step;
} else {
// We're in a regular transaction, just show the amount and the address
ux_approval_tx_flow[step++] = &ux_approval_amount_step;
2023-02-17 16:56:12 +01:00
#ifdef HAVE_DOMAIN_NAME
2023-05-04 11:52:16 +02:00
uint64_t chain_id = get_tx_chain_id();
2023-02-17 16:56:12 +01:00
if (has_domain_name(&chain_id, tmpContent.txContent.destination)) {
ux_approval_tx_flow[step++] = &ux_domain_name_step;
if (N_storage.verbose_domain_name) {
ux_approval_tx_flow[step++] = &ux_approval_address_step;
}
} else {
#endif // HAVE_DOMAIN_NAME
ux_approval_tx_flow[step++] = &ux_approval_address_step;
#ifdef HAVE_DOMAIN_NAME
}
#endif // HAVE_DOMAIN_NAME
}
2021-02-05 17:58:21 +01:00
if (N_storage.displayNonce) {
2021-06-11 11:37:16 +02:00
ux_approval_tx_flow[step++] = &ux_approval_nonce_step;
}
2023-05-04 11:52:16 +02:00
uint64_t chain_id = get_tx_chain_id();
if ((chainConfig->chainId == ETHEREUM_MAINNET_CHAINID) && (chain_id != chainConfig->chainId)) {
ux_approval_tx_flow[step++] = &ux_approval_network_step;
2021-06-11 11:37:16 +02:00
}
2021-06-24 18:46:18 +02:00
ux_approval_tx_flow[step++] = &ux_approval_fees_step;
2021-06-11 11:37:16 +02:00
ux_approval_tx_flow[step++] = &ux_approval_accept_step;
ux_approval_tx_flow[step++] = &ux_approval_reject_step;
ux_approval_tx_flow[step++] = FLOW_END_STEP;
2021-06-11 11:37:16 +02:00
ux_flow_init(0, ux_approval_tx_flow, NULL);
2023-02-17 16:56:12 +01:00
}