Skip to content

Commit 2dd7d6c

Browse files
committed
fix network.tct file generation
1 parent 63b562e commit 2dd7d6c

2 files changed

Lines changed: 45 additions & 37 deletions

File tree

src/features/feeds/utils/feedOutput.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ function resolveSVR(feed: any): "shared" | "aave" | undefined {
9393

9494
export function collectStreamEntries(
9595
type: DataFeedType,
96-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9796
chainCache: Record<string, any>,
9897
options: FeedMarkdownOptions = {}
9998
): StreamEntry[] {
@@ -102,7 +101,6 @@ export function collectStreamEntries(
102101
} as any
103102

104103
const seenFeedIds = new Set<string>()
105-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106104
const raw: any[] = []
107105

108106
for (const chain of CHAINS) {
@@ -216,7 +214,6 @@ export function buildFeedAddressMarkdown(
216214
): string {
217215
const lines: string[] = []
218216
const streams = isStreamsType(type)
219-
220217
const label = FEED_TYPE_LABELS[type]
221218

222219
if (streams) {
@@ -247,6 +244,43 @@ export function buildFeedAddressMarkdown(
247244
} else {
248245
lines.push(`No stream IDs found for type \`${type}\`.`)
249246
}
247+
} else {
248+
lines.push(`# Chainlink Feed Addresses: ${label}`)
249+
lines.push("")
250+
251+
const feedEntries = collectFeedEntries(type, networkFilter, chainCache, options)
252+
253+
if (feedEntries.length === 0) {
254+
lines.push(
255+
networkFilter
256+
? `No feeds found for type \`${type}\` on network \`${networkFilter}\`.`
257+
: `No feeds found for type \`${type}\`.`
258+
)
259+
} else {
260+
let currentNetwork = ""
261+
262+
for (const entry of feedEntries) {
263+
if (entry.network !== currentNetwork) {
264+
currentNetwork = entry.network
265+
const network = feedEntries.find((e) => e.network === currentNetwork)
266+
267+
if (!network) continue
268+
269+
lines.push(`## ${entry.chain}${network.networkName}`)
270+
lines.push(`- Network type: ${network.networkType}`)
271+
lines.push(`- Query string: \`${network.network}\``)
272+
lines.push("")
273+
lines.push("| Feed Name | Proxy Address | Deviation | Heartbeat |")
274+
lines.push("|-----------|--------------|-----------|-----------|")
275+
}
276+
277+
const name = escapePipes(entry.name)
278+
279+
lines.push(`| ${name} | \`${entry.proxyAddress}\` | ${entry.deviation} | ${entry.heartbeat} |`)
280+
}
281+
282+
lines.push("")
283+
}
250284
}
251285

252286
return lines.join("\n")

src/pages/data-feeds/feed-addresses/[type]/[network].txt.ts

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,28 @@ import { buildFeedAddressMarkdown, VALID_FEED_TYPES } from "~/features/feeds/uti
55
import { STREAM_CATEGORY_MAP } from "~/features/feeds/utils/streamMetadata.ts"
66
import type { DataFeedType } from "~/features/feeds/components/FeedList.tsx"
77

8-
// Reverse map: internal → public
8+
export const prerender = false
9+
910
const INTERNAL_TO_PUBLIC: Record<string, string> = Object.fromEntries(
1011
Object.entries(STREAM_CATEGORY_MAP).map(([pub, internal]) => [internal, pub])
1112
)
1213

13-
export async function getStaticPaths() {
14-
const chainCache = await getServerSideChainMetadata(CHAINS)
15-
16-
const paths: { params: { type: string; network: string } }[] = []
17-
const seen = new Set<string>()
18-
19-
for (const type of VALID_FEED_TYPES) {
20-
for (const chain of Object.values(chainCache)) {
21-
const chainNetworks = (chain as { networks?: any[] }).networks ?? []
22-
23-
for (const network of chainNetworks) {
24-
const queryString = network.queryString
25-
if (!queryString) continue
26-
27-
const key = `${type}:${queryString}`
28-
if (seen.has(key)) continue
29-
seen.add(key)
30-
31-
paths.push({
32-
params: {
33-
type,
34-
network: queryString,
35-
},
36-
})
37-
}
38-
}
39-
}
40-
41-
return paths
42-
}
43-
4414
export const GET: APIRoute = async ({ params }) => {
4515
const type = params.type as DataFeedType
46-
const network = params.network ?? null // ✅ FIX
16+
const network = params.network ?? null
4717

4818
if (!VALID_FEED_TYPES.includes(type)) {
4919
return new Response(`Invalid type "${type}"`, { status: 400 })
5020
}
5121

52-
const publicType = INTERNAL_TO_PUBLIC[type] ?? type // ✅ SAFE
22+
const publicType = INTERNAL_TO_PUBLIC[type] ?? type
5323

5424
const chainCache = await getServerSideChainMetadata(CHAINS)
5525

26+
if (!chainCache || Object.keys(chainCache).length === 0) {
27+
return new Response("Failed to load feed data", { status: 500 })
28+
}
29+
5630
const markdown = buildFeedAddressMarkdown(type, network, chainCache, "https://docs.chain.link", { publicType })
5731

5832
return new Response(markdown, {

0 commit comments

Comments
 (0)