Skip to content

Commit

Permalink
refactor: changed chainID handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4karia committed Jan 8, 2025
1 parent 7b1a8b6 commit 4e25608
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=4
# This is the patch version of this release
APPVERSION_P=1
APPVERSION_P=2
9 changes: 7 additions & 2 deletions app/src/coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ typedef enum {
#define APPVERSION_LINE1 "Version:"
#define APPVERSION_LINE2 ("v" APPVERSION)

#define COIN_DEFAULT_CHAINID "thorchain"

#define COIN_DEFAULT_DENOM_BASE "rune"
#define COIN_DEFAULT_DENOM_REPR "RUNE"
#define COIN_DEFAULT_DENOM_REPR_2 "THOR.RUNE"
Expand All @@ -80,6 +78,13 @@ typedef enum {
#define INS_SIGN_SECP256K1 0x02u
#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"
};

#ifdef __cplusplus
}
#endif
18 changes: 10 additions & 8 deletions app/src/tx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,21 @@ __Z_INLINE parser_error_t calculate_is_default_chainid() {
0, &pageCount))

zemu_log_stack(outVal);
zemu_log_stack(COIN_DEFAULT_CHAINID);

if (strcmp(outVal, COIN_DEFAULT_CHAINID) == 0) {
// If we don't match the default chainid, switch to expert mode
display_cache.is_default_chain = true;
zemu_log_stack("DEFAULT Chain ");
} else if ((outVal[0] == 0x30 || outVal[0] == 0x31) && strlen(outVal) == 1) {
// 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) {
display_cache.is_default_chain = true;
zemu_log_stack("Supported Chain");
return parser_ok;
}
}
if ((outVal[0] == 0x30 || outVal[0] == 0x31) && strlen(outVal) == 1) {
zemu_log_stack("Not Allowed chain");
return parser_unexpected_chain;
} else {
zemu_log_stack("Chain is NOT DEFAULT");
}

zemu_log_stack("Chain is NOT supported");
return parser_ok;
}

Expand Down

0 comments on commit 4e25608

Please sign in to comment.