Skip to content

Commit 021106d

Browse files
committed
Apply AI agent feedback
1 parent a090398 commit 021106d

6 files changed

Lines changed: 44 additions & 37 deletions

File tree

packages/ensnode-sdk/src/ensapi/api/name-tokens/prerequisites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const nameTokensPrerequisites = Object.freeze({
1616
requiredPlugins: [PluginName.Registrars, PluginName.TokenScope] as const,
1717

1818
/**
19-
* Check if provided ENSApiPublicConfig supports the Name Tokens API.
19+
* Check if provided EnsIndexerPublicConfig supports the Name Tokens API.
2020
*/
2121
hasEnsIndexerConfigSupport(config: EnsIndexerPublicConfig): boolean {
2222
return nameTokensPrerequisites.requiredPlugins.every((plugin) =>

packages/ensnode-sdk/src/ensapi/api/registrar-actions/prerequisites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const registrarActionsPrerequisites = Object.freeze({
2727
] as const,
2828

2929
/**
30-
* Check if provided ENSApiPublicConfig supports the Registrar Actions API.
30+
* Check if provided EnsIndexerPublicConfig supports the Registrar Actions API.
3131
*/
3232
hasEnsIndexerConfigSupport(config: EnsIndexerPublicConfig): boolean {
3333
return registrarActionsPrerequisites.requiredPlugins.every((plugin) =>

packages/ensnode-sdk/src/ensapi/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ describe("EnsApiClient", () => {
449449

450450
const client = new EnsApiClient();
451451

452-
await expect(client.config()).rejects.toThrow(/Fetching ENSNode Config Failed/i);
452+
await expect(client.config()).rejects.toThrow(/Fetching ENSApi Config Failed/i);
453453
});
454454
});
455455

@@ -479,7 +479,7 @@ describe("EnsApiClient", () => {
479479

480480
// act & assert
481481
await expect(client.indexingStatus()).rejects.toThrow(
482-
/Fetching ENSNode Indexing Status Failed/i,
482+
/Fetching ENSApi Indexing Status Failed/i,
483483
);
484484
});
485485
});

packages/ensnode-sdk/src/ensapi/client.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { ResolverRecordsSelection } from "../resolution";
22
import {
3-
type ConfigResponse,
4-
deserializeConfigResponse,
53
deserializedNameTokensResponse,
4+
deserializeEnsApiConfigResponse,
5+
deserializeEnsApiIndexingStatusResponse,
66
deserializeErrorResponse,
7-
deserializeIndexingStatusResponse,
87
deserializeRegistrarActionsResponse,
8+
type EnsApiConfigResponse,
9+
type EnsApiIndexingStatusResponse,
910
type ErrorResponse,
10-
type IndexingStatusResponse,
1111
type NameTokensRequest,
1212
type NameTokensResponse,
1313
type RegistrarActionsFilter,
@@ -22,8 +22,8 @@ import {
2222
type ResolvePrimaryNamesResponse,
2323
type ResolveRecordsRequest,
2424
type ResolveRecordsResponse,
25-
type SerializedConfigResponse,
26-
type SerializedIndexingStatusResponse,
25+
type SerializedEnsApiConfigResponse,
26+
type SerializedEnsApiIndexingStatusResponse,
2727
type SerializedNameTokensResponse,
2828
type SerializedRegistrarActionsResponse,
2929
} from "./api";
@@ -304,22 +304,22 @@ export class EnsApiClient {
304304
}
305305

306306
/**
307-
* Fetch ENSNode Config
307+
* Fetch ENSApi Config
308308
*
309-
* Fetch the ENSNode's configuration.
309+
* Fetch the ENSApi's configuration.
310310
*
311-
* @returns {ConfigResponse}
311+
* @returns {EnsApiConfigResponse}
312312
*
313-
* @throws if the ENSNode request fails
314-
* @throws if the ENSNode API returns an error response
315-
* @throws if the ENSNode response breaks required invariants
313+
* @throws if the ENSApi request fails
314+
* @throws if the ENSApi returns an error response
315+
* @throws if the ENSApi response breaks required invariants
316316
*/
317-
async config(): Promise<ConfigResponse> {
317+
async config(): Promise<EnsApiConfigResponse> {
318318
const url = new URL(`/api/config`, this.options.url);
319319

320320
const response = await fetch(url);
321321

322-
// ENSNode API should always allow parsing a response as JSON object.
322+
// ENSApi should always allow parsing a response as JSON object.
323323
// If for some reason it's not the case, throw an error.
324324
let responseData: unknown;
325325
try {
@@ -330,27 +330,27 @@ export class EnsApiClient {
330330

331331
if (!response.ok) {
332332
const errorResponse = deserializeErrorResponse(responseData);
333-
throw new Error(`Fetching ENSNode Config Failed: ${errorResponse.message}`);
333+
throw new Error(`Fetching ENSApi Config Failed: ${errorResponse.message}`);
334334
}
335335

336-
return deserializeConfigResponse(responseData as SerializedConfigResponse);
336+
return deserializeEnsApiConfigResponse(responseData as SerializedEnsApiConfigResponse);
337337
}
338338

339339
/**
340-
* Fetch ENSNode Indexing Status
340+
* Fetch ENSApi Indexing Status
341341
*
342-
* @returns {IndexingStatusResponse}
342+
* @returns {EnsApiIndexingStatusResponse}
343343
*
344-
* @throws if the ENSNode request fails
345-
* @throws if the ENSNode API returns an error response
346-
* @throws if the ENSNode response breaks required invariants
344+
* @throws if the ENSApi request fails
345+
* @throws if the ENSApi returns an error response
346+
* @throws if the ENSApi response breaks required invariants
347347
*/
348-
async indexingStatus(): Promise<IndexingStatusResponse> {
348+
async indexingStatus(): Promise<EnsApiIndexingStatusResponse> {
349349
const url = new URL(`/api/indexing-status`, this.options.url);
350350

351351
const response = await fetch(url);
352352

353-
// ENSNode API should always allow parsing a response as JSON object.
353+
// ENSApi should always allow parsing a response as JSON object.
354354
// If for some reason it's not the case, throw an error.
355355
let responseData: unknown;
356356
try {
@@ -374,11 +374,13 @@ export class EnsApiClient {
374374
// however, if errorResponse was defined,
375375
// throw an error with the generic server error message
376376
if (typeof errorResponse !== "undefined") {
377-
throw new Error(`Fetching ENSNode Indexing Status Failed: ${errorResponse.message}`);
377+
throw new Error(`Fetching ENSApi Indexing Status Failed: ${errorResponse.message}`);
378378
}
379379
}
380380

381-
return deserializeIndexingStatusResponse(responseData as SerializedIndexingStatusResponse);
381+
return deserializeEnsApiIndexingStatusResponse(
382+
responseData as SerializedEnsApiIndexingStatusResponse,
383+
);
382384
}
383385

384386
/**

packages/ensnode-sdk/src/ensindexer/config/zod-schemas.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { prettifyError, type ZodSafeParseResult } from "zod/v4";
44
import { type EnsIndexerVersionInfo, PluginName } from "./types";
55
import {
66
makeDatabaseSchemaNameSchema,
7-
makeENSIndexerPublicConfigSchema,
8-
makeENSIndexerVersionInfoSchema,
7+
makeEnsIndexerPublicConfigSchema,
8+
makeEnsIndexerVersionInfoSchema,
99
makeFullyPinnedLabelSetSchema,
1010
makeIndexedChainIdsSchema,
1111
makePluginsListSchema,
@@ -101,7 +101,7 @@ describe("ENSIndexer: Config", () => {
101101

102102
it("can parse version info values", () => {
103103
expect(
104-
makeENSIndexerVersionInfoSchema().parse({
104+
makeEnsIndexerVersionInfoSchema().parse({
105105
nodejs: "v22.22.22",
106106
ponder: "0.11.25",
107107
ensDb: "0.32.0",
@@ -122,7 +122,7 @@ describe("ENSIndexer: Config", () => {
122122

123123
expect(
124124
formatParseError(
125-
makeENSIndexerVersionInfoSchema().safeParse({
125+
makeEnsIndexerVersionInfoSchema().safeParse({
126126
nodejs: "",
127127
ponder: "",
128128
ensDb: "",
@@ -170,7 +170,7 @@ describe("ENSIndexer: Config", () => {
170170
} satisfies EnsIndexerVersionInfo,
171171
};
172172

173-
const parsedConfig = makeENSIndexerPublicConfigSchema().parse(validConfig);
173+
const parsedConfig = makeEnsIndexerPublicConfigSchema().parse(validConfig);
174174

175175
// The schema transforms URLs and arrays, so we need to check the transformed values
176176
expect(parsedConfig.indexedChainIds).toBeInstanceOf(Set);
@@ -185,7 +185,7 @@ describe("ENSIndexer: Config", () => {
185185
// Test invalid labelSetId
186186
expect(
187187
formatParseError(
188-
makeENSIndexerPublicConfigSchema().safeParse({
188+
makeEnsIndexerPublicConfigSchema().safeParse({
189189
...validConfig,
190190
labelSet: { ...validConfig.labelSet, labelSetId: "" },
191191
}),
@@ -195,7 +195,7 @@ describe("ENSIndexer: Config", () => {
195195
// Test invalid labelSetVersion
196196
expect(
197197
formatParseError(
198-
makeENSIndexerPublicConfigSchema().safeParse({
198+
makeEnsIndexerPublicConfigSchema().safeParse({
199199
...validConfig,
200200
labelSet: { ...validConfig.labelSet, labelSetVersion: "not-a-number" },
201201
}),

packages/ensnode-sdk/src/ensindexer/config/zod-schemas.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const makeFullyPinnedLabelSetSchema = (valueLabel: string = "Label set")
119119
const makeNonEmptyStringSchema = (valueLabel: string = "Value") =>
120120
z.string().nonempty({ error: `${valueLabel} must be a non-empty string.` });
121121

122-
export const makeENSIndexerVersionInfoSchema = (valueLabel: string = "Value") =>
122+
export const makeEnsIndexerVersionInfoSchema = (valueLabel: string = "Value") =>
123123
z
124124
.strictObject(
125125
{
@@ -137,6 +137,11 @@ export const makeENSIndexerVersionInfoSchema = (valueLabel: string = "Value") =>
137137
)
138138
.check(invariant_ensDbVersionIsSameAsEnsIndexerVersion);
139139

140+
/**
141+
* @deprecated Use {@link makeEnsIndexerVersionInfoSchema} instead.
142+
*/
143+
export const makeENSIndexerVersionInfoSchema = makeEnsIndexerVersionInfoSchema;
144+
140145
// Invariant: If config.isSubgraphCompatible, the config must pass isSubgraphCompatible(config)
141146
export function invariant_isSubgraphCompatibleRequirements(
142147
ctx: ZodCheckFnInput<

0 commit comments

Comments
 (0)