Skip to content

Commit b554dd7

Browse files
committed
feat: extract network identifier from rddUrl instead of hardcoded mapping
- Replace hardcoded queryString logic with dynamic extraction from rddUrl - Extract network identifier using regex pattern from feeds JSON URLs - Maintain fallback to queryString for networks without rddUrl - Eliminates need for manual mapping maintenance for new networks Examples: - linea-mainnet: feeds-ethereum-mainnet-linea-1.json → ethereum-mainnet-linea-1 - mantle-mainnet: feeds-ethereum-mainnet-mantle-1.json → ethereum-mainnet-mantle-1 - ethereum-mainnet: feeds-mainnet.json → mainnet
1 parent 5ef217b commit b554dd7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/features/feeds/components/useBatchedFeedCategories.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ import { useEffect, useState } from "preact/hooks"
22
import { getFeedRiskTiersBatch } from "~/db/feedCategories.js"
33
import { ChainNetwork } from "~/features/data/chains.ts"
44

5-
// Prefer the slug, but patch Ethereum until Supabase data is normalized (it still stores "mainnet").
5+
/**
6+
* Extract the database network identifier from the rddUrl.
7+
* Falls back to queryString if rddUrl is not available.
8+
*/
69
export const getNetworkIdentifier = (network?: ChainNetwork | null): string => {
710
if (!network) return "unknown"
8-
if (network.queryString === "ethereum-mainnet") {
9-
return "mainnet"
11+
12+
// Extract network identifier from rddUrl (e.g., "feeds-ethereum-mainnet-linea-1.json" -> "ethereum-mainnet-linea-1")
13+
if (network.rddUrl) {
14+
const match = network.rddUrl.match(/feeds-(.+)\.json$/)
15+
if (match) {
16+
return match[1]
17+
}
1018
}
19+
20+
// Fallback to queryString for networks without rddUrl or in case of parsing failure
1121
return network.queryString ?? "unknown"
1222
}
1323

0 commit comments

Comments
 (0)