Skip to content

Commit 0e7d82f

Browse files
Add API to get small icons from chain_id (get_network_small_icon_from_chain_id)
1 parent 8d3e85f commit 0e7d82f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src_nbgl/network_icons.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,20 @@ const nbgl_icon_details_t *get_network_icon_from_chain_id(const uint64_t *chain_
1818
}
1919
return NULL;
2020
}
21+
22+
/**
23+
* Get the network small icon from a given chain ID
24+
*
25+
* Loops onto the generated \ref g_network_small_icons array until a chain ID matches.
26+
*
27+
* @param[in] chain_id network's chain ID
28+
* @return the network small icon if found, \ref NULL otherwise
29+
*/
30+
const nbgl_icon_details_t *get_network_small_icon_from_chain_id(const uint64_t *chain_id) {
31+
for (size_t i = 0; i < ARRAYLEN(g_network_small_icons); ++i) {
32+
if ((uint64_t) PIC(g_network_small_icons[i].chain_id) == *chain_id) {
33+
return PIC(g_network_small_icons[i].icon);
34+
}
35+
}
36+
return NULL;
37+
}

src_nbgl/network_icons.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
#include "nbgl_types.h"
66

77
const nbgl_icon_details_t *get_network_icon_from_chain_id(const uint64_t *chain_id);
8+
const nbgl_icon_details_t *get_network_small_icon_from_chain_id(const uint64_t *chain_id);
89

910
#endif // NETWORK_ICONS_H_

0 commit comments

Comments
 (0)