Improve error-handling of chain ID when parsing APDUs
This commit is contained in:
@@ -144,3 +144,15 @@ const char *get_displayable_ticker(const uint64_t *chain_id) {
|
||||
}
|
||||
return ticker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks wether the app can support the given chain ID
|
||||
*
|
||||
* - If the given chain ID is the same as the app's one
|
||||
* - If both chain IDs are present in the array of Ethereum-compatible networks
|
||||
*/
|
||||
bool app_compatible_with_chain_id(const uint64_t *chain_id) {
|
||||
return ((chainConfig->chainId == *chain_id) ||
|
||||
(chain_is_ethereum_compatible(&chainConfig->chainId) &&
|
||||
chain_is_ethereum_compatible(chain_id)));
|
||||
}
|
||||
|
||||
@@ -3,10 +3,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define UNSUPPORTED_CHAIN_ID_MSG(id) \
|
||||
do { \
|
||||
PRINTF("Unsupported chain ID: %u (app: %u)\n", id, chainConfig->chainId); \
|
||||
} while (0)
|
||||
|
||||
const char *get_network_name_from_chain_id(const uint64_t *chain_id);
|
||||
const char *get_network_ticker_from_chain_id(const uint64_t *chain_id);
|
||||
|
||||
bool chain_is_ethereum_compatible(const uint64_t *chain_id);
|
||||
bool app_compatible_with_chain_id(const uint64_t *chain_id);
|
||||
|
||||
uint64_t get_tx_chain_id(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user