-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Split ENSApi config data model #1975
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
base: main
Are you sure you want to change the base?
Changes from all commits
aabb5bd
240c36d
142dc2a
1fecc67
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 |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ import { useMemo, useState } from "react"; | |
|
|
||
| import { | ||
| buildEnsNodeStackInfo, | ||
| deserializeENSApiPublicConfig, | ||
| deserializeEnsApiPublicConfig, | ||
| deserializeEnsIndexerPublicConfig, | ||
| type EnsDbPublicConfig, | ||
| SerializedENSApiPublicConfig, | ||
| } from "@ensnode/ensnode-sdk"; | ||
|
|
@@ -41,14 +42,23 @@ export default function MockConfigPage() { | |
|
|
||
| default: | ||
| try { | ||
| const ensApiPublicConfig = deserializeENSApiPublicConfig(mockConfigData[selectedConfig]); | ||
| const ensApiPublicConfig = deserializeEnsApiPublicConfig(mockConfigData[selectedConfig]); | ||
| const ensIndexerPublicConfig = deserializeEnsIndexerPublicConfig( | ||
| mockConfigData[selectedConfig], | ||
| ); | ||
|
Comment on lines
+45
to
+48
Contributor
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.
The correct source for the ENSIndexer config is the nested property, e.g. |
||
| const ensRainbowPublicConfig = ensIndexerPublicConfig.ensRainbowPublicConfig; | ||
| const ensDbPublicConfig = { | ||
| versionInfo: { | ||
| postgresql: "18.1", | ||
| }, | ||
| } satisfies EnsDbPublicConfig; | ||
| return { | ||
| ensNodeStackInfo: buildEnsNodeStackInfo(ensApiPublicConfig, ensDbPublicConfig), | ||
| ensNodeStackInfo: buildEnsNodeStackInfo( | ||
| ensApiPublicConfig, | ||
| ensDbPublicConfig, | ||
| ensIndexerPublicConfig, | ||
| ensRainbowPublicConfig, | ||
| ), | ||
| } satisfies ENSNodeConfigInfoViewProps; | ||
| } catch (error) { | ||
| const errorMessage = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,22 +155,11 @@ describe("buildEnsApiPublicConfig", () => { | |
| const mockConfig = { | ||
| port: ENSApi_DEFAULT_PORT, | ||
| ensDbUrl: BASE_ENV.ENSDB_URL, | ||
| ensIndexerPublicConfig: ENSINDEXER_PUBLIC_CONFIG, | ||
| namespace: ENSINDEXER_PUBLIC_CONFIG.namespace, | ||
| ensIndexerSchemaName: ENSINDEXER_PUBLIC_CONFIG.ensIndexerSchemaName, | ||
| rpcConfigs: new Map([ | ||
| [ | ||
| 1, | ||
| { | ||
|
Contributor
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. |
||
| httpRPCs: [new URL(VALID_RPC_URL)], | ||
| websocketRPC: undefined, | ||
| } satisfies RpcConfig, | ||
| ], | ||
| ]), | ||
| referralProgramEditionConfigSetUrl: undefined, | ||
| }; | ||
|
|
||
| const result = buildEnsApiPublicConfig(mockConfig); | ||
| const result = buildEnsApiPublicConfig(mockConfig, ENSINDEXER_PUBLIC_CONFIG); | ||
|
|
||
| expect(result).toStrictEqual({ | ||
| versionInfo: ensApiVersionInfo, | ||
|
|
@@ -182,52 +171,16 @@ describe("buildEnsApiPublicConfig", () => { | |
| }); | ||
| }); | ||
|
|
||
| it("preserves the complete ENSIndexer public config structure", () => { | ||
| const mockConfig = { | ||
| port: ENSApi_DEFAULT_PORT, | ||
| ensDbUrl: BASE_ENV.ENSDB_URL, | ||
| ensIndexerPublicConfig: ENSINDEXER_PUBLIC_CONFIG, | ||
| namespace: ENSINDEXER_PUBLIC_CONFIG.namespace, | ||
| ensIndexerSchemaName: ENSINDEXER_PUBLIC_CONFIG.ensIndexerSchemaName, | ||
| rpcConfigs: new Map(), | ||
| referralProgramEditionConfigSetUrl: undefined, | ||
| }; | ||
|
|
||
| const result = buildEnsApiPublicConfig(mockConfig); | ||
|
|
||
| // Verify that all ENSIndexer public config fields are preserved | ||
| expect(result.ensIndexerPublicConfig.namespace).toBe(ENSINDEXER_PUBLIC_CONFIG.namespace); | ||
| expect(result.ensIndexerPublicConfig.plugins).toEqual(ENSINDEXER_PUBLIC_CONFIG.plugins); | ||
| expect(result.ensIndexerPublicConfig.versionInfo).toEqual(ENSINDEXER_PUBLIC_CONFIG.versionInfo); | ||
| expect(result.ensIndexerPublicConfig.indexedChainIds).toEqual( | ||
| ENSINDEXER_PUBLIC_CONFIG.indexedChainIds, | ||
| ); | ||
| expect(result.ensIndexerPublicConfig.isSubgraphCompatible).toBe( | ||
| ENSINDEXER_PUBLIC_CONFIG.isSubgraphCompatible, | ||
| ); | ||
| expect(result.ensIndexerPublicConfig.labelSet).toEqual(ENSINDEXER_PUBLIC_CONFIG.labelSet); | ||
| expect(result.ensIndexerPublicConfig.ensIndexerSchemaName).toBe( | ||
| ENSINDEXER_PUBLIC_CONFIG.ensIndexerSchemaName, | ||
| ); | ||
| }); | ||
|
|
||
| it("includes the theGraphFallback and redacts api key", () => { | ||
| const mockConfig = { | ||
| port: ENSApi_DEFAULT_PORT, | ||
| ensDbUrl: BASE_ENV.ENSDB_URL, | ||
| ensIndexerPublicConfig: { | ||
| ...ENSINDEXER_PUBLIC_CONFIG, | ||
| plugins: ["subgraph"], | ||
| isSubgraphCompatible: true, | ||
| }, | ||
| namespace: ENSINDEXER_PUBLIC_CONFIG.namespace, | ||
| ensIndexerSchemaName: ENSINDEXER_PUBLIC_CONFIG.ensIndexerSchemaName, | ||
| rpcConfigs: new Map(), | ||
| referralProgramEditionConfigSetUrl: undefined, | ||
| theGraphApiKey: "secret-api-key", | ||
| }; | ||
|
|
||
| const result = buildEnsApiPublicConfig(mockConfig); | ||
| const result = buildEnsApiPublicConfig(mockConfig, ENSINDEXER_PUBLIC_CONFIG); | ||
|
|
||
| expect(result.theGraphFallback.canFallback).toBe(true); | ||
| // discriminate the type... | ||
|
|
||
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.
deserializeEnsIndexerPublicConfigexpects aSerializedEnsIndexerPublicConfig, but this code passes the entireSerializedENSApiPublicConfigobject (which in the current mock JSON containsensIndexerPublicConfignested). As a result, deserialization will fail because required indexer fields aren’t at the top level.Use the nested
ensIndexerPublicConfigvalue from the mock JSON (or update the mock JSON to the new split shape), and updatemockConfigData’s type accordingly so TypeScript reflects the actual structure.