App now has all the network icons and can use them when needed
This commit is contained in:
20
src_nbgl/network_icons.c
Normal file
20
src_nbgl/network_icons.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "os_utils.h"
|
||||
#include "os_pic.h"
|
||||
#include "net_icons.gen.h"
|
||||
|
||||
/**
|
||||
* Get the network icon from a given chain ID
|
||||
*
|
||||
* Loops onto the generated \ref g_network_icons array until a chain ID matches.
|
||||
*
|
||||
* @param[in] chain_id network's chain ID
|
||||
* @return the network icon if found, \ref NULL otherwise
|
||||
*/
|
||||
const nbgl_icon_details_t *get_network_icon_from_chain_id(const uint64_t *chain_id) {
|
||||
for (size_t i = 0; i < ARRAYLEN(g_network_icons); ++i) {
|
||||
if ((uint64_t) PIC(g_network_icons[i].chain_id) == *chain_id) {
|
||||
return PIC(g_network_icons[i].icon);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
9
src_nbgl/network_icons.h
Normal file
9
src_nbgl/network_icons.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef NETWORK_ICONS_H_
|
||||
#define NETWORK_ICONS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "nbgl_types.h"
|
||||
|
||||
const nbgl_icon_details_t *get_network_icon_from_chain_id(const uint64_t *chain_id);
|
||||
|
||||
#endif // NETWORK_ICONS_H_
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "ui_signing.h"
|
||||
#include "plugins.h"
|
||||
#include "domain_name.h"
|
||||
#include "network_icons.h"
|
||||
|
||||
#define TEXT_TX "transaction"
|
||||
// 1 more than actually displayed on screen, because of calculations in StaticReview
|
||||
@@ -190,7 +191,12 @@ static const nbgl_icon_details_t *get_tx_icon(void) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
icon = get_app_icon(false);
|
||||
uint64_t chain_id = get_tx_chain_id();
|
||||
if (chain_id == chainConfig->chainId) {
|
||||
icon = get_app_icon(false);
|
||||
} else {
|
||||
icon = get_network_icon_from_chain_id(&chain_id);
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ui_callbacks.h"
|
||||
#include "ui_nbgl.h"
|
||||
#include "network.h"
|
||||
#include "network_icons.h"
|
||||
|
||||
static void cancel_send(void) {
|
||||
io_seproxyhal_touch_address_cancel(NULL);
|
||||
@@ -34,6 +35,8 @@ static void display_addr(void) {
|
||||
}
|
||||
|
||||
void ui_display_public_key(const uint64_t *chain_id) {
|
||||
const nbgl_icon_details_t *icon;
|
||||
|
||||
// - 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)
|
||||
@@ -45,14 +48,11 @@ void ui_display_public_key(const uint64_t *chain_id) {
|
||||
sizeof(g_stax_shared_buffer));
|
||||
strlcat(g_stax_shared_buffer, "\n", sizeof(g_stax_shared_buffer));
|
||||
}
|
||||
icon = get_network_icon_from_chain_id(chain_id);
|
||||
} else {
|
||||
strlcat(g_stax_shared_buffer, APPNAME "\n", sizeof(g_stax_shared_buffer));
|
||||
icon = get_app_icon(false);
|
||||
}
|
||||
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);
|
||||
nbgl_useCaseReviewStart(icon, g_stax_shared_buffer, NULL, "Cancel", display_addr, reject_addr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user