Now shows the network name in the Stax public address UI flow
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
#define _COMMON_UI_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.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_public_key(const uint64_t *chain_id);
|
||||
void ui_sign_712_v0(void);
|
||||
void ui_display_stark_public(void);
|
||||
void ui_confirm_selector(void);
|
||||
|
||||
@@ -28,7 +28,8 @@ void ui_display_privacy_shared_secret(void) {
|
||||
ux_flow_init(0, ux_display_privacy_shared_secret_flow, NULL);
|
||||
}
|
||||
|
||||
void ui_display_public_key(void) {
|
||||
void ui_display_public_key(const uint64_t *chain_id) {
|
||||
(void) chain_id;
|
||||
ux_flow_init(0, ux_display_public_flow, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifdef HAVE_DOMAIN_NAME
|
||||
|
||||
#include "ux.h"
|
||||
#include "ui_domain_name.h"
|
||||
#include "domain_name.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -158,6 +158,7 @@ UX_STEP_NOCB(
|
||||
.title = "Max Fees",
|
||||
.text = strings.common.maxFee,
|
||||
});
|
||||
|
||||
UX_STEP_NOCB(
|
||||
ux_approval_network_step,
|
||||
bnnn_paging,
|
||||
@@ -240,7 +241,7 @@ void ux_approve_tx(bool fromPlugin) {
|
||||
}
|
||||
|
||||
uint64_t chain_id = get_tx_chain_id();
|
||||
if (chainConfig->chainId == ETHEREUM_MAINNET_CHAINID && chain_id != chainConfig->chainId) {
|
||||
if ((chainConfig->chainId == ETHEREUM_MAINNET_CHAINID) && (chain_id != chainConfig->chainId)) {
|
||||
ux_approval_tx_flow[step++] = &ux_approval_network_step;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ void handleGetPublicKey(uint8_t p1,
|
||||
}
|
||||
|
||||
if ((p1 != P1_CONFIRM) && (p1 != P1_NON_CONFIRM)) {
|
||||
PRINTF("Error: Unexpected P1 (%u)!\n", p1);
|
||||
THROW(APDU_RESPONSE_INVALID_P1_P2);
|
||||
}
|
||||
if ((p2 != P2_CHAINCODE) && (p2 != P2_NO_CHAINCODE)) {
|
||||
PRINTF("Error: Unexpected P2 (%u)!\n", p2);
|
||||
THROW(APDU_RESPONSE_INVALID_P1_P2);
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ void handleGetPublicKey(uint8_t p1,
|
||||
|
||||
(void) dataBuffer; // to prevent dead increment warning
|
||||
if (dataLength > 0) {
|
||||
PRINTF("Error: Leftover unwanted data (%u bytes long)!\n", dataLength);
|
||||
THROW(APDU_RESPONSE_INVALID_DATA);
|
||||
}
|
||||
|
||||
@@ -78,7 +81,8 @@ void handleGetPublicKey(uint8_t p1,
|
||||
"0x%.*s",
|
||||
40,
|
||||
tmpCtx.publicKeyContext.address);
|
||||
ui_display_public_key();
|
||||
// don't unnecessarily pass the current app's chain ID
|
||||
ui_display_public_key(chainConfig->chainId == chain_id ? NULL : &chain_id);
|
||||
|
||||
*flags |= IO_ASYNCH_REPLY;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,7 @@ static void nonce_to_string(const txInt256_t *nonce, char *out, size_t out_size)
|
||||
static void get_network_as_string(char *out, size_t out_size) {
|
||||
uint64_t chain_id = get_tx_chain_id();
|
||||
const char *name = get_network_name_from_chain_id(&chain_id);
|
||||
|
||||
if (name == NULL) {
|
||||
// No network name found so simply copy the chain ID as the network name.
|
||||
u64_to_string(chain_id, out, out_size);
|
||||
@@ -504,7 +505,7 @@ void finalizeParsing(bool direct) {
|
||||
sizeof(strings.common.nonce));
|
||||
PRINTF("Nonce: %s\n", strings.common.nonce);
|
||||
|
||||
// Prepare chainID field
|
||||
// Prepare network field
|
||||
get_network_as_string(strings.common.network_name, sizeof(strings.common.network_name));
|
||||
PRINTF("Network: %s\n", strings.common.network_name);
|
||||
|
||||
|
||||
@@ -2,27 +2,57 @@
|
||||
#include "shared_context.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "network.h"
|
||||
|
||||
static void reviewReject(void) {
|
||||
static void cancel_send(void) {
|
||||
io_seproxyhal_touch_address_cancel(NULL);
|
||||
}
|
||||
|
||||
static void confirmTransation(void) {
|
||||
static void confirm_send(void) {
|
||||
io_seproxyhal_touch_address_ok(NULL);
|
||||
}
|
||||
|
||||
static void reviewChoice(bool confirm) {
|
||||
static void confirm_addr(void) {
|
||||
// display a status page and go back to main
|
||||
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirm_send);
|
||||
}
|
||||
|
||||
static void reject_addr(void) {
|
||||
nbgl_useCaseStatus("Address verification\ncancelled", false, cancel_send);
|
||||
}
|
||||
|
||||
static void review_choice(bool confirm) {
|
||||
if (confirm) {
|
||||
// display a status page and go back to main
|
||||
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation);
|
||||
confirm_addr();
|
||||
} else {
|
||||
nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject);
|
||||
reject_addr();
|
||||
}
|
||||
}
|
||||
|
||||
static void buildScreen(void) {
|
||||
nbgl_useCaseAddressConfirmation(strings.common.fullAddress, reviewChoice);
|
||||
static void display_addr(void) {
|
||||
nbgl_useCaseAddressConfirmation(strings.common.fullAddress, review_choice);
|
||||
}
|
||||
|
||||
void ui_display_public_key(const uint64_t *chain_id) {
|
||||
// - if a chain_id is given and it's - known, we specify its network name
|
||||
// - unknown, we don't specify anything
|
||||
// - if no chain_id is given we specify the APPNAME (legacy behaviour)
|
||||
strlcpy(g_stax_shared_buffer, "Verify ", sizeof(g_stax_shared_buffer));
|
||||
if (chain_id != NULL) {
|
||||
if (chain_is_ethereum_compatible(chain_id)) {
|
||||
strlcat(g_stax_shared_buffer,
|
||||
get_network_name_from_chain_id(chain_id),
|
||||
sizeof(g_stax_shared_buffer));
|
||||
strlcat(g_stax_shared_buffer, "\n", sizeof(g_stax_shared_buffer));
|
||||
}
|
||||
} else {
|
||||
strlcat(g_stax_shared_buffer, APPNAME "\n", sizeof(g_stax_shared_buffer));
|
||||
}
|
||||
strlcat(g_stax_shared_buffer, "address", sizeof(g_stax_shared_buffer));
|
||||
nbgl_useCaseReviewStart(get_app_icon(false),
|
||||
g_stax_shared_buffer,
|
||||
NULL,
|
||||
"Cancel",
|
||||
display_addr,
|
||||
reject_addr);
|
||||
}
|
||||
void ui_display_public_key(void) {
|
||||
buildScreen();
|
||||
}
|
||||
Reference in New Issue
Block a user