-
Notifications
You must be signed in to change notification settings - Fork 16
feat(ensindexer): extend dependecy info #1157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
12cb6eb
b2b0ea0
13b298c
f7b528e
e6b8c9f
9484725
cb3be0c
d560e15
6cb5d9f
0b84163
54c29d2
ab1a677
e14bda9
f7ca6b3
a95abc7
1055007
b7b8d54
5b6f690
b643fce
5c81da7
e31fa88
77833a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -124,7 +124,7 @@ export function ENSNodeConfigInfo({ | |||||
| value: <p className={cardItemValueStyles}>Postgres</p>, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| }, | ||||||
| ]} | ||||||
| version={ensIndexerConfig.dependencyInfo.ensDb} | ||||||
| version={ensIndexerConfig.versionInfo.ensDb} | ||||||
| docsLink={new URL("https://ensnode.io/ensdb/")} | ||||||
| /> | ||||||
| {/*It's safe to assume that the version number of ENSDb is always equal to the version number of ENSIndexer. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment should now be removed. |
||||||
|
|
@@ -137,27 +137,27 @@ export function ENSNodeConfigInfo({ | |||||
| { | ||||||
| label: "Ponder", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an info tooltip to Ponder similar to the one you created for ens-normalize.js? It would be cool to include a similar link in this tooltip. |
||||||
| value: ( | ||||||
| <p className={cardItemValueStyles}>{ensIndexerConfig.dependencyInfo.ponder}</p> | ||||||
| <p className={cardItemValueStyles}>{ensIndexerConfig.versionInfo.ponder}</p> | ||||||
| ), | ||||||
| }, | ||||||
| { | ||||||
| label: "Node.js", | ||||||
| value: ( | ||||||
| <p className={cardItemValueStyles}>{ensIndexerConfig.dependencyInfo.nodejs}</p> | ||||||
| <p className={cardItemValueStyles}>{ensIndexerConfig.versionInfo.nodejs}</p> | ||||||
| ), | ||||||
| }, | ||||||
| { | ||||||
| label: "ENS Normalize", | ||||||
|
lightwalker-eth marked this conversation as resolved.
Outdated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| value: ( | ||||||
| <p className={cardItemValueStyles}> | ||||||
| {ensIndexerConfig.dependencyInfo.ensNormalize} | ||||||
| {ensIndexerConfig.versionInfo.ensNormalize} | ||||||
| </p> | ||||||
| ), | ||||||
| additionalInfo: ( | ||||||
| <p> | ||||||
| Version of{" "} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <ExternalLinkWithIcon | ||||||
| href={`https://www.npmjs.com/package/@adraffy/ens-normalize/v/${ensIndexerConfig.dependencyInfo.ensNormalize}`} | ||||||
| href={`https://www.npmjs.com/package/@adraffy/ens-normalize/v/${ensIndexerConfig.versionInfo.ensNormalize}`} | ||||||
| > | ||||||
| <code className="text-xs">@adraffy/ens-normalize</code> package | ||||||
| </ExternalLinkWithIcon>{" "} | ||||||
|
|
@@ -251,7 +251,7 @@ export function ENSNodeConfigInfo({ | |||||
| icon: <IconENS width={18} height={18} className="text-[#3F3F46] flex-shrink-0" />, | ||||||
| }, | ||||||
| ]} | ||||||
| version={ensIndexerConfig.dependencyInfo.ensIndexer} | ||||||
| version={ensIndexerConfig.versionInfo.ensIndexer} | ||||||
| docsLink={new URL("https://ensnode.io/ensindexer/")} | ||||||
| /> | ||||||
| {/*TODO: The current approach to displaying the version of ENSIndexer is a stretch. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment should be removed. |
||||||
|
|
@@ -265,7 +265,7 @@ export function ENSNodeConfigInfo({ | |||||
| label: "Schema Version", | ||||||
| value: ( | ||||||
| <p className={cardItemValueStyles}> | ||||||
| {ensIndexerConfig.dependencyInfo.ensRainbowSchema} | ||||||
| {ensIndexerConfig.versionInfo.ensRainbowSchema} | ||||||
| </p> | ||||||
| ), | ||||||
| }, | ||||||
|
|
@@ -300,7 +300,7 @@ export function ENSNodeConfigInfo({ | |||||
| ), | ||||||
| }, | ||||||
| ]} | ||||||
| version={ensIndexerConfig.dependencyInfo.ensRainbow} | ||||||
| version={ensIndexerConfig.versionInfo.ensRainbow} | ||||||
| docsLink={new URL("https://ensnode.io/ensrainbow/")} | ||||||
| /> | ||||||
| </div> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||
| import { existsSync, readFileSync } from "node:fs"; | ||||||
| import { existsSync, readFileSync, readdirSync } from "node:fs"; | ||||||
| import { dirname, join } from "node:path"; | ||||||
| import { fileURLToPath } from "node:url"; | ||||||
| import packageJson from "@/../package.json"; | ||||||
| import { getENSRainbowApiClient } from "@/lib/ensraibow-api-client"; | ||||||
| import { DependencyInfo } from "@ensnode/ensnode-sdk"; | ||||||
| import { makeDependencyInfoSchema } from "@ensnode/ensnode-sdk/internal"; | ||||||
| import { VersionInfo } from "@ensnode/ensnode-sdk"; | ||||||
| import { makeVersionInfoSchema } from "@ensnode/ensnode-sdk/internal"; | ||||||
| import { prettifyError } from "zod/v4"; | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -23,18 +23,23 @@ export function getPackageVersion(packageName: string) { | |||||
| let searchDir = dirname(currentFile); | ||||||
|
|
||||||
| while (true) { | ||||||
| // Check if we've reached the workspace root | ||||||
| const workspaceFile = join(searchDir, "pnpm-workspace.yaml"); | ||||||
| const isWorkspaceRoot = existsSync(workspaceFile); | ||||||
|
|
||||||
| // Check for node_modules in current directory | ||||||
| const nodeModulesPath = join(searchDir, "node_modules", packageName, "package.json"); | ||||||
|
|
||||||
| if (existsSync(nodeModulesPath)) { | ||||||
| const packageJson = JSON.parse(readFileSync(nodeModulesPath, "utf8")); | ||||||
| return packageJson.version; | ||||||
| } | ||||||
|
|
||||||
| // Check PNPM's .pnpm virtual store | ||||||
| const pnpmDir = join(searchDir, "node_modules", ".pnpm"); | ||||||
| if (existsSync(pnpmDir)) { | ||||||
| const version = searchPnpmStore(pnpmDir, packageName); | ||||||
| if (version) return version; | ||||||
| } | ||||||
|
|
||||||
| // If we're at workspace root and still haven't found it, stop searching | ||||||
| if (isWorkspaceRoot) { | ||||||
| throw new Error( | ||||||
|
|
@@ -62,18 +67,43 @@ export function getPackageVersion(packageName: string) { | |||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Get complete {@link DependencyInfo} for ENSIndexer app. | ||||||
| * Search PNPM's .pnpm directory for a package | ||||||
| * PNPM stores packages like: .pnpm/@adraffy+ens-normalize@1.10.1/node_modules/@adraffy/ens-normalize | ||||||
| */ | ||||||
| function searchPnpmStore(pnpmDir: string, packageName: string): string | null { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear what this function returns. |
||||||
| try { | ||||||
| const entries = readdirSync(pnpmDir); | ||||||
|
|
||||||
| // Convert package name to PNPM's format: @scope/name -> @scope+name | ||||||
| const normalizedName = packageName.replace("/", "+"); | ||||||
|
|
||||||
| // Find entries that match the package name | ||||||
| // They will be in format: packagename@version or @scope+packagename@version | ||||||
| for (const entry of entries) { | ||||||
| if (entry.startsWith(normalizedName + "@")) { | ||||||
| const pkgPath = join(pnpmDir, entry, "node_modules", packageName, "package.json"); | ||||||
| if (existsSync(pkgPath)) { | ||||||
| const packageJson = JSON.parse(readFileSync(pkgPath, "utf8")); | ||||||
| return packageJson.version; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } catch (error) { | ||||||
| // Ignore errors in this helper | ||||||
| } | ||||||
|
|
||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Get complete {@link VersionInfo} for ENSIndexer app. | ||||||
| */ | ||||||
| export async function getDependencyInfo(): Promise<DependencyInfo> { | ||||||
| export async function getVersionInfo(): Promise<VersionInfo> { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Goal: We should note how we're going to have nested "VersionInfo" objects for different apps in our overall architecture. Each app's "VersionInfo" should have a name that makes it explicit exactly which app's "VersionInfo" it is related to. |
||||||
| const ensRainbowApiClient = getENSRainbowApiClient(); | ||||||
| const { versionInfo: ensRainbowDependencyInfo } = await ensRainbowApiClient.version(); | ||||||
| const { versionInfo: ensRainbowVersionInfo } = await ensRainbowApiClient.version(); | ||||||
|
|
||||||
| // ENSRainbow version (fetched from the actual ENSRainbow service instance) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // use a fallback for backwards compatibility | ||||||
| const ensRainbowSchema = | ||||||
| ensRainbowDependencyInfo.dbSchemaVersion || | ||||||
| // @ts-ignore | ||||||
| ensRainbowDependencyInfo.schema_version; | ||||||
| const ensRainbowSchema = ensRainbowVersionInfo.dbSchemaVersion; | ||||||
|
|
||||||
| // ENSIndexer version | ||||||
| const ensIndexerVersion = packageJson.version; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest moving the logic to get the ENSIndexer version into a separate helper function. |
||||||
|
|
@@ -84,21 +114,21 @@ export async function getDependencyInfo(): Promise<DependencyInfo> { | |||||
| // the version number of ENSIndexer | ||||||
| const ensDbVersion = ensIndexerVersion; | ||||||
|
|
||||||
| const schema = makeDependencyInfoSchema(); | ||||||
| const schema = makeVersionInfoSchema(); | ||||||
| const data = { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I'm not so clear on what's going on here. Are we creating what is supposed to be a Or are we just attempting to verify that the If so, then suggest to rename |
||||||
| ensRainbow: ensRainbowDependencyInfo.version, | ||||||
| ensRainbow: ensRainbowVersionInfo.version, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we should be building nested schemas. In other words:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This update is a bit more nuanced due to a dual nature of
I'll create a ticket for the requested change so we could address it in a separate PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| nodejs: process.versions.node, | ||||||
| ponder: getPackageVersion("ponder"), | ||||||
| ensDb: ensDbVersion, | ||||||
| ensIndexer: ensIndexerVersion, | ||||||
| ensNormalize: getPackageVersion("@adraffy/ens-normalize"), | ||||||
| ensRainbowSchema, | ||||||
| } satisfies DependencyInfo; | ||||||
| } satisfies VersionInfo; | ||||||
|
|
||||||
| const parsed = schema.safeParse(data); | ||||||
|
|
||||||
| if (parsed.error) { | ||||||
| throw new Error(`Cannot deserialize DependencyInfo:\n${prettifyError(parsed.error)}\n`); | ||||||
| throw new Error(`Cannot deserialize VersionInfo:\n${prettifyError(parsed.error)}\n`); | ||||||
| } | ||||||
|
|
||||||
| return parsed.data; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -85,8 +85,8 @@ The response includes several important configuration categories: | |||||
| - **Feature Flags**: Boolean settings for experimental features and optional | ||||||
| functionality | ||||||
| - **Plugins**: Activated plugins | ||||||
| - **Dependency Information**: Node.js version, Ponder framework version, and | ||||||
| ENSRainbow schema details | ||||||
| - **Version Information**: Node.js version, Ponder framework version, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ENSRainbow version and schema details, ENSDb version, ENSIndexer version, [ENS Normalize version](https://www.npmjs.com/package/@adraffy/ens-normalize) | ||||||
|
|
||||||
| ### Example response | ||||||
|
|
||||||
|
|
@@ -102,8 +102,12 @@ The response includes several important configuration categories: | |||||
| 42161, | ||||||
| 534352 | ||||||
| ], | ||||||
| "databaseSchemaName": "alphaSchema0.31.0", | ||||||
| "databaseSchemaName": "alphaSchema0.35.0", | ||||||
| "isSubgraphCompatible": false, | ||||||
| "labelSet": { | ||||||
| "labelSetId": "subgraph", | ||||||
| "labelSetVersion": 0 | ||||||
| }, | ||||||
| "namespace": "mainnet", | ||||||
| "plugins": [ | ||||||
| "subgraph", | ||||||
|
|
@@ -114,11 +118,14 @@ The response includes several important configuration categories: | |||||
| "referrals", | ||||||
| "tokenscope" | ||||||
| ], | ||||||
| "dependencyInfo": { | ||||||
| "versionInfo": { | ||||||
| "nodejs": "22.18.0", | ||||||
| "ponder": "0.11.43", | ||||||
| "ensRainbow": "0.31.0", | ||||||
| "ensRainbowSchema": 2 | ||||||
| "ensDb": "0.35.0", | ||||||
| "ensIndexer": "0.35.0", | ||||||
| "ensNormalize": "1.11.1", | ||||||
| "ensRainbow": "0.34.0", | ||||||
| "ensRainbowSchema": 3 | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "Serialization Error" case is no longer triggering a serialization error as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!