Skip to content

Conversation

@aditya520
Copy link
Member

Summary

Rationale

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

@vercel
Copy link

vercel bot commented Nov 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
component-library Ready Ready Preview Comment Nov 20, 2025 9:15pm
developer-hub Ready Ready Preview Comment Nov 20, 2025 9:15pm
5 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
api-reference Skipped Skipped Nov 20, 2025 9:15pm
entropy-explorer Skipped Skipped Nov 20, 2025 9:15pm
insights Skipped Skipped Nov 20, 2025 9:15pm
proposals Skipped Skipped Nov 20, 2025 9:15pm
staking Skipped Skipped Nov 20, 2025 9:15pm

Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, great work! Minor suggestions to help make the code a bit cleaner but up to you if you care to implement them.

Comment on lines 26 to 60
const endpoints = [
"https://hermes.pyth.network",
"https://hermes-beta.pyth.network",
];
const responses = await Promise.all(
endpoints.map((url) =>
fetch(`${url}/v2/price_feeds`, {
next: { revalidate: 3600 },
}).then((res) => res.json() as Promise<unknown>),
),
);

const allFeeds: AdvancedIndex[] = [];

for (const data of responses) {
const parsed = hermesSchema.safeParse(data);
if (parsed.success) {
for (const feed of parsed.data) {
allFeeds.push({
title: `${feed.attributes.symbol} (Core)`,
description: `Price Feed ID: ${feed.id}`,
url: `/price-feeds/core/price-feeds/price-feed-ids?search=${feed.attributes.symbol}`,
id: feed.id,
tag: "price-feed-core",
structuredData: {
headings: [],
contents: [
{ heading: "Symbol", content: feed.attributes.symbol },
{ heading: "ID", content: feed.id },
],
},
});
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const endpoints = [
"https://hermes.pyth.network",
"https://hermes-beta.pyth.network",
];
const responses = await Promise.all(
endpoints.map((url) =>
fetch(`${url}/v2/price_feeds`, {
next: { revalidate: 3600 },
}).then((res) => res.json() as Promise<unknown>),
),
);
const allFeeds: AdvancedIndex[] = [];
for (const data of responses) {
const parsed = hermesSchema.safeParse(data);
if (parsed.success) {
for (const feed of parsed.data) {
allFeeds.push({
title: `${feed.attributes.symbol} (Core)`,
description: `Price Feed ID: ${feed.id}`,
url: `/price-feeds/core/price-feeds/price-feed-ids?search=${feed.attributes.symbol}`,
id: feed.id,
tag: "price-feed-core",
structuredData: {
headings: [],
contents: [
{ heading: "Symbol", content: feed.attributes.symbol },
{ heading: "ID", content: feed.id },
],
},
});
}
}
}
const [hermesFeeds, hermesBetaFeeds] = await Promise.all(
[HERMES_URL, HERMES_BETA_URL].map((url) => {
const hermesResult = await fetch(new URL('/v2/price_feeds', url), {
next: { revalidate: 3600 },
});
const parsed = hermesSchema.safeParse(await hermesResult.json());
return parsed.success
? parsed.data.map(feed => toAdvancedIndex(feed))
: undefined
})
);
return [...hermesFeeds, ...hermesBetaFeeds];

And then just add a toAdvancedIndex: (fee: z.infer<typeof hermesSchema>[number]) => AdvancedFeed function.

Simpler, requires less procedural / mutable object building, and keeps processing close to data fetching.

Comment on lines 74 to 75
const data = (await res.json()) as unknown;
const parsed = lazerSchema.safeParse(data);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const data = (await res.json()) as unknown;
const parsed = lazerSchema.safeParse(data);
const parsed = lazerSchema.safeParse(await res.json());

Little trick when using zod schemas with fetch that avoids the awkward need to typecast to unknown

@vercel vercel bot temporarily deployed to Preview – entropy-explorer November 20, 2025 21:12 Inactive
@vercel vercel bot temporarily deployed to Preview – insights November 20, 2025 21:12 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference November 20, 2025 21:12 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals November 20, 2025 21:12 Inactive
@vercel vercel bot temporarily deployed to Preview – staking November 20, 2025 21:12 Inactive
@aditya520 aditya520 merged commit a690832 into main Nov 20, 2025
8 of 10 checks passed
@aditya520 aditya520 deleted the feat(dev-hub)-search-feeds branch November 20, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants