Skip to content

Commit

Permalink
Merge pull request #13 from blooo-io/fix/LDG-92-fix-chain-names-display
Browse files Browse the repository at this point in the history
Fix/ldg 92 fix chain names display
  • Loading branch information
Z4karia authored Dec 22, 2022
2 parents b948318 + f7bfd98 commit 245efab
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
35 changes: 29 additions & 6 deletions src/contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,33 @@ const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

// Array containing the chains supported by squid
const char SQUID_SUPPORTED_CHAINS[NUM_SUPPORTED_CHAINS][PARAMETER_LENGTH] = {
"Ethereum", "Polygon", "Arbitrum", "Avalanche", "Moonbeam", "binance",
"cosmoshub", "crescent", "injective", "juno", "kujira", "osmosis",
"secret", "terra-2", "Agoric", "ASSETMANTLE", "Axelarnet", "COMDEX",
"EVMOS", "fetch", "KI", "REGEN", "UMEE"};
const struct chainIdToChainName_t SQUID_SUPPORTED_CHAINS[NUM_SUPPORTED_CHAINS] = {
{"Ethereum", "Ethereum"},
{"Arbitrum", "Arbitrum"},
{"Avalanche", "Avalanche C-Chain"},
{"Moonbeam", "Moonbeam Mainnet"},
{"Polygon", "Polygon"},
{"binance", "Binance"},
{"cosmoshub", "Cosmos Hub"},
{"crescent", "Crescent"},
{"injective", "Injective"},
{"juno", "Juno"},
{"kujira", "Kujira"},
{"osmosis", "Osmosis"},
{"secret", "Secret Network"},
{"terra-2", "Terra-2"},
{"Agoric", "Agoric"},
{"ASSETMANTLE", "AssetMantle"},
{"Axelarnet", "Axelar"},
{"COMDEX", "Comdex"},
{"EVMOS", "Evmos"},
{"fetch", "Fetch"},
{"KI", "Ki"},
{"REGEN", "Regen"},
{"UMEE", "Umee"},
};

// Array containing the 15 most used tokens supported by squid
// Array containing the most used tokens supported by squid
// each represented with their symbol and decimals
const struct tokenSymbolToDecimals_t SQUID_SUPPORTED_TOKENS[NUM_SUPPORTED_TOKENS] = {
{"ETH", 18},
Expand All @@ -49,4 +69,7 @@ const struct tokenSymbolToDecimals_t SQUID_SUPPORTED_TOKENS[NUM_SUPPORTED_TOKENS
{"axlUSDT", 6},
{"WMATIC", 18},
{"WBNB", 18},
{"WGLMR", 18},
{"WFTM", 18},
{"WAVAX", 18},
};
6 changes: 6 additions & 0 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ static void set_to_asset_ui(ethQueryContractUI_t *msg, squid_parameters_t *conte
// Set UI for "Destination Chain" screen.
static void set_dest_chain_ui(ethQueryContractUI_t *msg, squid_parameters_t *context) {
strlcpy(msg->title, "To Chain", msg->titleLength);
for (size_t i = 0; i < NUM_SUPPORTED_CHAINS; i++) {
if (!memcmp(context->dest_chain, SQUID_SUPPORTED_CHAINS[i].chain_id, MAX_CHAIN_ID_LEN)) {
strlcpy(msg->msg, SQUID_SUPPORTED_CHAINS[i].chain_name, msg->msgLength);
return;
}
}
strlcpy(msg->msg, context->dest_chain, msg->msgLength);
}

Expand Down
16 changes: 13 additions & 3 deletions src/squid_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define TOKEN_SENT_FOUND 1

#define NUM_SUPPORTED_CHAINS 23
#define NUM_SUPPORTED_TOKENS 15
#define NUM_SUPPORTED_TOKENS 18

extern const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH];

Expand All @@ -25,7 +25,17 @@ typedef struct tokenSymbolToDecimals_t {
uint8_t decimals_sent;
} tokenSymbolToDecimals_t;

extern const char SQUID_SUPPORTED_CHAINS[NUM_SUPPORTED_CHAINS][PARAMETER_LENGTH];
// Longest chain id is currently "ASSETMANTLE"
#define MAX_CHAIN_ID_LEN 12
// Longest chain name is currently "Avalanche C-Chain"
#define MAX_CHAIN_NAME_LEN 18

typedef struct chainIdToChainName_t {
char chain_id[MAX_CHAIN_ID_LEN];
char chain_name[MAX_CHAIN_NAME_LEN];
} chainIdToChainName_t;

extern const struct chainIdToChainName_t SQUID_SUPPORTED_CHAINS[NUM_SUPPORTED_CHAINS];
extern const struct tokenSymbolToDecimals_t SQUID_SUPPORTED_TOKENS[NUM_SUPPORTED_TOKENS];

// Returns 1 if corresponding address is the address for the chain token (ETH, BNB, MATIC,
Expand Down Expand Up @@ -108,7 +118,7 @@ static inline void printf_hex_array(const char *title __attribute__((unused)),

static inline bool is_chain_supported(squid_parameters_t *context) {
for (size_t i = 0; i < NUM_SUPPORTED_CHAINS; i++) {
if (!memcmp(context->dest_chain, SQUID_SUPPORTED_CHAINS[i], PARAMETER_LENGTH)) {
if (!memcmp(context->dest_chain, SQUID_SUPPORTED_CHAINS[i].chain_id, MAX_CHAIN_ID_LEN)) {
return 1;
}
}
Expand Down
Binary file modified tests/snapshots/bsc_nanos_callBridge_normal_flow/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/bsc_nanosp_callBridge_normal_flow/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/bsc_nanox_callBridge_normal_flow/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 245efab

Please sign in to comment.