@@ -2,40 +2,23 @@ import { useEffect, useState } from "preact/hooks"
22import { getFeedRiskTiersBatch } from "~/db/feedCategories.js"
33import { ChainNetwork } from "~/features/data/chains.ts"
44
5- // Patch mismatches
6- const SUPABASE_NETWORK_SLUG_OVERRIDES : Record < string , string > = {
7- // Ethereum
8- "ethereum-mainnet" : "mainnet" ,
9-
10- // L2s / EVM networks that db stores as ethereum-*-<chain>-1
11- "arbitrum-mainnet" : "ethereum-mainnet-arbitrum-1" ,
12- "base-mainnet" : "ethereum-mainnet-base-1" ,
13- "optimism-mainnet" : "ethereum-mainnet-optimism-1" ,
14- "scroll-mainnet" : "ethereum-mainnet-scroll-1" ,
15- "linea-mainnet" : "ethereum-mainnet-linea-1" ,
16- "mantle-mainnet" : "ethereum-mainnet-mantle-1" ,
17- "metis-mainnet" : "ethereum-mainnet-andromeda-1" ,
18- "xlayer-mainnet" : "ethereum-mainnet-xlayer-1" ,
19- "starknet-mainnet" : "ethereum-mainnet-starknet-1" ,
20- "zksync-mainnet" : "ethereum-mainnet-zksync-1" ,
21- "polygon-zkevm-mainnet" : "ethereum-mainnet-polygon-zkevm-1" ,
22-
23- // Legacy/alt naming in db
24- "bnb-mainnet" : "bsc-mainnet" ,
25- "polygon-mainnet" : "matic-mainnet" ,
26- "moonbeam-mainnet" : "polkadot-mainnet-moonbeam" ,
27- "moonriver-mainnet" : "kusama-mainnet-moonriver" ,
28- "bob-mainnet" : "bitcoin-mainnet-bob-1" ,
29- "botanix-mainnet" : "bitcoin-mainnet-botanix" ,
30-
31- // typo in chains.ts (queryString is "katara-mainnet")
32- "katara-mainnet" : "polygon-mainnet-katana" ,
33- }
34-
5+ /**
6+ * Extract the database network identifier from the rddUrl.
7+ * Falls back to queryString if rddUrl is not available.
8+ */
359export const getNetworkIdentifier = ( network ?: ChainNetwork | null ) : string => {
3610 if ( ! network ) return "unknown"
37- const slug = network . queryString ?? "unknown"
38- return SUPABASE_NETWORK_SLUG_OVERRIDES [ slug ] ?? slug
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 ( / f e e d s - ( .+ ) \. j s o n $ / )
15+ if ( match ) {
16+ return match [ 1 ]
17+ }
18+ }
19+
20+ // Fallback to queryString for networks without rddUrl or in case of parsing failure
21+ return network . queryString ?? "unknown"
3922}
4023
4124// Final category only
0 commit comments