Skip to content

Commit 0b93e27

Browse files
Fix dynamic network matching with chain ID 0 when uninitialized
1 parent 5633f4b commit 0b93e27

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/network.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,21 @@ static const network_info_t NETWORK_MAPPING[] = {
111111
};
112112

113113
static const network_info_t *get_network_from_chain_id(const uint64_t *chain_id) {
114-
// Look if the network is available
115-
for (size_t i = 0; i < MAX_DYNAMIC_NETWORKS; i++) {
116-
if (DYNAMIC_NETWORK_INFO[i].chain_id == *chain_id) {
117-
PRINTF("[NETWORK] - Found dynamic %s\n", DYNAMIC_NETWORK_INFO[i].name);
118-
return (const network_info_t *) &DYNAMIC_NETWORK_INFO[i];
114+
if (*chain_id != 0) {
115+
// Look if the network is available
116+
for (size_t i = 0; i < MAX_DYNAMIC_NETWORKS; i++) {
117+
if (DYNAMIC_NETWORK_INFO[i].chain_id == *chain_id) {
118+
PRINTF("[NETWORK] - Found dynamic %s\n", DYNAMIC_NETWORK_INFO[i].name);
119+
return (const network_info_t *) &DYNAMIC_NETWORK_INFO[i];
120+
}
119121
}
120-
}
121-
// Fallback to hardcoded table
122-
for (size_t i = 0; i < ARRAYLEN(NETWORK_MAPPING); i++) {
123-
if (NETWORK_MAPPING[i].chain_id == *chain_id) {
124-
PRINTF("[NETWORK] - Fallback on hardcoded list. Found %s\n", NETWORK_MAPPING[i].name);
125-
return (const network_info_t *) &NETWORK_MAPPING[i];
122+
// Fallback to hardcoded table
123+
for (size_t i = 0; i < ARRAYLEN(NETWORK_MAPPING); i++) {
124+
if (NETWORK_MAPPING[i].chain_id == *chain_id) {
125+
PRINTF("[NETWORK] - Fallback on hardcoded list. Found %s\n",
126+
NETWORK_MAPPING[i].name);
127+
return (const network_info_t *) &NETWORK_MAPPING[i];
128+
}
126129
}
127130
}
128131
return NULL;

0 commit comments

Comments
 (0)