Skip to content

Commit

Permalink
fix chainID handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4karia committed Jan 8, 2025
1 parent 4e25608 commit 6bf5576
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
16 changes: 16 additions & 0 deletions app/src/coin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "coin.h"
#include <stdint.h>
#include <stddef.h>

#define MAX_CHAIN_ID_LEN 20

static const char SUPPORTED_CHAIN_IDS[SUPPORTED_CHAIN_COUNT][MAX_CHAIN_ID_LEN] = {
"thorchain",
"thorchain-1",
"thorchain-stagenet-2"
};

const char* get_supported_chain(uint8_t index) {
if (index >= SUPPORTED_CHAIN_COUNT) return NULL;
return SUPPORTED_CHAIN_IDS[index];
}
8 changes: 3 additions & 5 deletions app/src/coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
extern "C" {
#endif

#include <stdint.h>
#define CLA 0x55u

#define HDPATH_LEN_DEFAULT 5
Expand Down Expand Up @@ -79,11 +80,8 @@ typedef enum {
#define INS_GET_ADDR_SECP256K1 0x04u

#define SUPPORTED_CHAIN_COUNT 3
static const char* const SUPPORTED_CHAIN_IDS[SUPPORTED_CHAIN_COUNT] = {
"thorchain",
"thorchain-1",
"thorchain-stagenet-2"
};

const char* get_supported_chain(uint8_t index);

#ifdef __cplusplus
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/tx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ __Z_INLINE parser_error_t calculate_is_default_chainid() {

// Check if chain ID matches any of the supported ones
for (uint8_t i = 0; i < SUPPORTED_CHAIN_COUNT; i++) {
if (strcmp(outVal, SUPPORTED_CHAIN_IDS[i]) == 0) {
const char* supported_chain = get_supported_chain(i);
if (supported_chain == NULL) {
return parser_unexpected_value;
}
if (strcmp(outVal, supported_chain) == 0) {
display_cache.is_default_chain = true;
zemu_log_stack("Supported Chain");
return parser_ok;
Expand Down

0 comments on commit 6bf5576

Please sign in to comment.