diff --git a/.changeset/orange-dancers-watch.md b/.changeset/orange-dancers-watch.md new file mode 100644 index 000000000..6f4aff33a --- /dev/null +++ b/.changeset/orange-dancers-watch.md @@ -0,0 +1,5 @@ +--- +"@ensnode/ensnode-sdk": minor +--- + +Create shared module for `pagination` features. diff --git a/packages/ensnode-sdk/src/api/config/deserialize.ts b/packages/ensnode-sdk/src/api/config/deserialize.ts new file mode 100644 index 000000000..2715b9336 --- /dev/null +++ b/packages/ensnode-sdk/src/api/config/deserialize.ts @@ -0,0 +1,12 @@ +import { deserializeENSApiPublicConfig } from "../../ensapi"; +import type { ConfigResponse } from "./response"; +import type { SerializedConfigResponse } from "./serialized-response"; + +/** + * Deserialize a {@link ConfigResponse} object. + */ +export function deserializeConfigResponse( + serializedResponse: SerializedConfigResponse, +): ConfigResponse { + return deserializeENSApiPublicConfig(serializedResponse); +} diff --git a/packages/ensnode-sdk/src/api/config/index.ts b/packages/ensnode-sdk/src/api/config/index.ts new file mode 100644 index 000000000..c33e8f883 --- /dev/null +++ b/packages/ensnode-sdk/src/api/config/index.ts @@ -0,0 +1,4 @@ +export * from "./deserialize"; +export * from "./response"; +export * from "./serialize"; +export * from "./serialized-response"; diff --git a/packages/ensnode-sdk/src/api/config/response.ts b/packages/ensnode-sdk/src/api/config/response.ts new file mode 100644 index 000000000..ac3d5f3df --- /dev/null +++ b/packages/ensnode-sdk/src/api/config/response.ts @@ -0,0 +1,6 @@ +import type { ENSApiPublicConfig } from "../../ensapi"; + +/** + * ENSApi Public Config Response + */ +export type ConfigResponse = ENSApiPublicConfig; diff --git a/packages/ensnode-sdk/src/api/config/serialize.ts b/packages/ensnode-sdk/src/api/config/serialize.ts new file mode 100644 index 000000000..7c9e6b020 --- /dev/null +++ b/packages/ensnode-sdk/src/api/config/serialize.ts @@ -0,0 +1,7 @@ +import { serializeENSApiPublicConfig } from "../../ensapi"; +import type { ConfigResponse } from "./response"; +import type { SerializedConfigResponse } from "./serialized-response"; + +export function serializeConfigResponse(response: ConfigResponse): SerializedConfigResponse { + return serializeENSApiPublicConfig(response); +} diff --git a/packages/ensnode-sdk/src/api/config/serialized-response.ts b/packages/ensnode-sdk/src/api/config/serialized-response.ts new file mode 100644 index 000000000..9fa34e3e4 --- /dev/null +++ b/packages/ensnode-sdk/src/api/config/serialized-response.ts @@ -0,0 +1,3 @@ +import type { SerializedENSApiPublicConfig } from "../../ensapi"; + +export type SerializedConfigResponse = SerializedENSApiPublicConfig; diff --git a/packages/ensnode-sdk/src/api/deserialize.ts b/packages/ensnode-sdk/src/api/deserialize.ts deleted file mode 100644 index bf1aa6263..000000000 --- a/packages/ensnode-sdk/src/api/deserialize.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { prettifyError } from "zod/v4"; - -import type { - SerializedIndexingStatusResponse, - SerializedRegistrarActionsResponse, -} from "./serialized-types"; -import type { ErrorResponse, IndexingStatusResponse, RegistrarActionsResponse } from "./types"; -import { - ErrorResponseSchema, - makeIndexingStatusResponseSchema, - makeRegistrarActionsResponseSchema, -} from "./zod-schemas"; - -export function deserializeErrorResponse(maybeErrorResponse: unknown): ErrorResponse { - const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse); - - if (parsed.error) { - throw new Error(`Cannot deserialize ErrorResponse:\n${prettifyError(parsed.error)}\n`); - } - - return parsed.data; -} - -export function deserializeIndexingStatusResponse( - maybeResponse: SerializedIndexingStatusResponse, -): IndexingStatusResponse { - const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse); - - if (parsed.error) { - throw new Error(`Cannot deserialize IndexingStatusResponse:\n${prettifyError(parsed.error)}\n`); - } - - return parsed.data; -} - -export function deserializeRegistrarActionsResponse( - maybeResponse: SerializedRegistrarActionsResponse, -): RegistrarActionsResponse { - const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse); - - if (parsed.error) { - throw new Error( - `Cannot deserialize RegistrarActionsResponse:\n${prettifyError(parsed.error)}\n`, - ); - } - - return parsed.data; -} diff --git a/packages/ensnode-sdk/src/api/index.ts b/packages/ensnode-sdk/src/api/index.ts index 282cf2e14..01f1d4223 100644 --- a/packages/ensnode-sdk/src/api/index.ts +++ b/packages/ensnode-sdk/src/api/index.ts @@ -1,5 +1,5 @@ -export * from "./deserialize"; +export * from "./config"; +export * from "./indexing-status"; export * from "./registrar-actions"; -export * from "./serialize"; -export * from "./serialized-types"; -export * from "./types"; +export * from "./resolution"; +export * from "./shared"; diff --git a/packages/ensnode-sdk/src/api/indexing-status/deserialize.ts b/packages/ensnode-sdk/src/api/indexing-status/deserialize.ts new file mode 100644 index 000000000..e566d9dcd --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/deserialize.ts @@ -0,0 +1,20 @@ +import { prettifyError } from "zod/v4"; + +import type { IndexingStatusResponse } from "./response"; +import type { SerializedIndexingStatusResponse } from "./serialized-response"; +import { makeIndexingStatusResponseSchema } from "./zod-schemas"; + +/** + * Deserialize a {@link IndexingStatusResponse} object. + */ +export function deserializeIndexingStatusResponse( + maybeResponse: SerializedIndexingStatusResponse, +): IndexingStatusResponse { + const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse); + + if (parsed.error) { + throw new Error(`Cannot deserialize IndexingStatusResponse:\n${prettifyError(parsed.error)}\n`); + } + + return parsed.data; +} diff --git a/packages/ensnode-sdk/src/api/indexing-status/index.ts b/packages/ensnode-sdk/src/api/indexing-status/index.ts new file mode 100644 index 000000000..54913353d --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/index.ts @@ -0,0 +1,5 @@ +export * from "./deserialize"; +export * from "./request"; +export * from "./response"; +export * from "./serialize"; +export * from "./serialized-response"; diff --git a/packages/ensnode-sdk/src/api/indexing-status/request.ts b/packages/ensnode-sdk/src/api/indexing-status/request.ts new file mode 100644 index 000000000..28e4ac086 --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/request.ts @@ -0,0 +1,4 @@ +/** + * Represents a request to Indexing Status API. + */ +export type IndexingStatusRequest = {}; diff --git a/packages/ensnode-sdk/src/api/indexing-status/response.ts b/packages/ensnode-sdk/src/api/indexing-status/response.ts new file mode 100644 index 000000000..1af15928c --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/response.ts @@ -0,0 +1,45 @@ +import type { RealtimeIndexingStatusProjection } from "../../ensindexer"; + +/** + * A status code for indexing status responses. + */ +export const IndexingStatusResponseCodes = { + /** + * Represents that the indexing status is available. + */ + Ok: "ok", + + /** + * Represents that the indexing status is unavailable. + */ + Error: "error", +} as const; + +/** + * The derived string union of possible {@link IndexingStatusResponseCodes}. + */ +export type IndexingStatusResponseCode = + (typeof IndexingStatusResponseCodes)[keyof typeof IndexingStatusResponseCodes]; + +/** + * An indexing status response when the indexing status is available. + */ +export type IndexingStatusResponseOk = { + responseCode: typeof IndexingStatusResponseCodes.Ok; + realtimeProjection: RealtimeIndexingStatusProjection; +}; + +/** + * An indexing status response when the indexing status is unavailable. + */ +export type IndexingStatusResponseError = { + responseCode: typeof IndexingStatusResponseCodes.Error; +}; + +/** + * Indexing status response. + * + * Use the `responseCode` field to determine the specific type interpretation + * at runtime. + */ +export type IndexingStatusResponse = IndexingStatusResponseOk | IndexingStatusResponseError; diff --git a/packages/ensnode-sdk/src/api/indexing-status/serialize.ts b/packages/ensnode-sdk/src/api/indexing-status/serialize.ts new file mode 100644 index 000000000..d0e30029d --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/serialize.ts @@ -0,0 +1,21 @@ +import { serializeRealtimeIndexingStatusProjection } from "../../ensindexer"; +import { type IndexingStatusResponse, IndexingStatusResponseCodes } from "./response"; +import type { + SerializedIndexingStatusResponse, + SerializedIndexingStatusResponseOk, +} from "./serialized-response"; + +export function serializeIndexingStatusResponse( + response: IndexingStatusResponse, +): SerializedIndexingStatusResponse { + switch (response.responseCode) { + case IndexingStatusResponseCodes.Ok: + return { + responseCode: response.responseCode, + realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection), + } satisfies SerializedIndexingStatusResponseOk; + + case IndexingStatusResponseCodes.Error: + return response; + } +} diff --git a/packages/ensnode-sdk/src/api/indexing-status/serialized-response.ts b/packages/ensnode-sdk/src/api/indexing-status/serialized-response.ts new file mode 100644 index 000000000..9166e744f --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/serialized-response.ts @@ -0,0 +1,22 @@ +import type { SerializedRealtimeIndexingStatusProjection } from "../../ensindexer"; +import type { IndexingStatusResponseError, IndexingStatusResponseOk } from "./response"; + +/** + * Serialized representation of {@link IndexingStatusResponseError}. + */ +export type SerializedIndexingStatusResponseError = IndexingStatusResponseError; + +/** + * Serialized representation of {@link IndexingStatusResponseOk}. + */ +export interface SerializedIndexingStatusResponseOk + extends Omit { + realtimeProjection: SerializedRealtimeIndexingStatusProjection; +} + +/** + * Serialized representation of {@link IndexingStatusResponse}. + */ +export type SerializedIndexingStatusResponse = + | SerializedIndexingStatusResponseOk + | SerializedIndexingStatusResponseError; diff --git a/packages/ensnode-sdk/src/api/indexing-status/zod-schemas.ts b/packages/ensnode-sdk/src/api/indexing-status/zod-schemas.ts new file mode 100644 index 000000000..5786f1dd1 --- /dev/null +++ b/packages/ensnode-sdk/src/api/indexing-status/zod-schemas.ts @@ -0,0 +1,39 @@ +import z from "zod/v4"; + +import { makeRealtimeIndexingStatusProjectionSchema } from "../../internal"; +import { + type IndexingStatusResponse, + IndexingStatusResponseCodes, + type IndexingStatusResponseError, + type IndexingStatusResponseOk, +} from "./response"; + +/** + * Schema for {@link IndexingStatusResponseOk} + **/ +export const makeIndexingStatusResponseOkSchema = ( + valueLabel: string = "Indexing Status Response OK", +) => + z.strictObject({ + responseCode: z.literal(IndexingStatusResponseCodes.Ok), + realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel), + }); + +/** + * Schema for {@link IndexingStatusResponseError} + **/ +export const makeIndexingStatusResponseErrorSchema = ( + _valueLabel: string = "Indexing Status Response Error", +) => + z.strictObject({ + responseCode: z.literal(IndexingStatusResponseCodes.Error), + }); + +/** + * Schema for {@link IndexingStatusResponse} + **/ +export const makeIndexingStatusResponseSchema = (valueLabel: string = "Indexing Status Response") => + z.discriminatedUnion("responseCode", [ + makeIndexingStatusResponseOkSchema(valueLabel), + makeIndexingStatusResponseErrorSchema(valueLabel), + ]); diff --git a/packages/ensnode-sdk/src/api/registrar-actions/deserialize.ts b/packages/ensnode-sdk/src/api/registrar-actions/deserialize.ts new file mode 100644 index 000000000..5cf7e5b4c --- /dev/null +++ b/packages/ensnode-sdk/src/api/registrar-actions/deserialize.ts @@ -0,0 +1,22 @@ +import { prettifyError } from "zod/v4"; + +import type { RegistrarActionsResponse } from "./response"; +import type { SerializedRegistrarActionsResponse } from "./serialized-response"; +import { makeRegistrarActionsResponseSchema } from "./zod-schemas"; + +/** + * Deserialize a {@link RegistrarActionsResponse} object. + */ +export function deserializeRegistrarActionsResponse( + maybeResponse: SerializedRegistrarActionsResponse, +): RegistrarActionsResponse { + const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse); + + if (parsed.error) { + throw new Error( + `Cannot deserialize RegistrarActionsResponse:\n${prettifyError(parsed.error)}\n`, + ); + } + + return parsed.data; +} diff --git a/packages/ensnode-sdk/src/api/registrar-actions/filters.ts b/packages/ensnode-sdk/src/api/registrar-actions/filters.ts index f4ec911ba..7f8f62027 100644 --- a/packages/ensnode-sdk/src/api/registrar-actions/filters.ts +++ b/packages/ensnode-sdk/src/api/registrar-actions/filters.ts @@ -3,7 +3,7 @@ import { type RegistrarActionsFilter, RegistrarActionsFilterTypes, type RegistrarActionsFilterWithEncodedReferral, -} from "../types"; +} from "./request"; /** * Build a "parent node" filter object for Registrar Actions query. diff --git a/packages/ensnode-sdk/src/api/registrar-actions/index.ts b/packages/ensnode-sdk/src/api/registrar-actions/index.ts index 4cb7e000c..8f0b7c3f5 100644 --- a/packages/ensnode-sdk/src/api/registrar-actions/index.ts +++ b/packages/ensnode-sdk/src/api/registrar-actions/index.ts @@ -1,2 +1,7 @@ +export * from "./deserialize"; export * from "./filters"; export * from "./prerequisites"; +export * from "./request"; +export * from "./response"; +export * from "./serialize"; +export * from "./serialized-response"; diff --git a/packages/ensnode-sdk/src/api/registrar-actions/request.ts b/packages/ensnode-sdk/src/api/registrar-actions/request.ts new file mode 100644 index 000000000..adf9c81d1 --- /dev/null +++ b/packages/ensnode-sdk/src/api/registrar-actions/request.ts @@ -0,0 +1,57 @@ +import type { Node } from "../../ens"; + +/** + * Records Filters: Filter Types + */ +export const RegistrarActionsFilterTypes = { + BySubregistryNode: "bySubregistryNode", + WithEncodedReferral: "withEncodedReferral", +} as const; + +export type RegistrarActionsFilterType = + (typeof RegistrarActionsFilterTypes)[keyof typeof RegistrarActionsFilterTypes]; + +export type RegistrarActionsFilterBySubregistryNode = { + filterType: typeof RegistrarActionsFilterTypes.BySubregistryNode; + value: Node; +}; + +export type RegistrarActionsFilterWithEncodedReferral = { + filterType: typeof RegistrarActionsFilterTypes.WithEncodedReferral; +}; + +export type RegistrarActionsFilter = + | RegistrarActionsFilterBySubregistryNode + | RegistrarActionsFilterWithEncodedReferral; + +/** + * Records Orders + */ +export const RegistrarActionsOrders = { + LatestRegistrarActions: "orderBy[timestamp]=desc", +} as const; + +export type RegistrarActionsOrder = + (typeof RegistrarActionsOrders)[keyof typeof RegistrarActionsOrders]; + +/** + * Represents a request to Registrar Actions API. + */ +export type RegistrarActionsRequest = { + /** + * Filters to be applied while generating results. + */ + filters?: RegistrarActionsFilter[]; + + /** + * Order applied while generating results. + */ + order?: RegistrarActionsOrder; + + /** + * Limit the count of items per page to selected count of records. + * + * Guaranteed to be a positive integer (if defined). + */ + itemsPerPage?: number; +}; diff --git a/packages/ensnode-sdk/src/api/registrar-actions/response.ts b/packages/ensnode-sdk/src/api/registrar-actions/response.ts new file mode 100644 index 000000000..3beca3ea3 --- /dev/null +++ b/packages/ensnode-sdk/src/api/registrar-actions/response.ts @@ -0,0 +1,66 @@ +import type { InterpretedName } from "../../ens"; +import type { RegistrarAction } from "../../registrars"; +import type { IndexingStatusResponseCodes } from "../indexing-status"; +import type { ErrorResponse } from "../shared/errors"; + +/** + * A status code for Registrar Actions API responses. + */ +export const RegistrarActionsResponseCodes = { + /** + * Represents that Registrar Actions are available. + */ + Ok: "ok", + + /** + * Represents that Registrar Actions are unavailable. + */ + Error: "error", +} as const; + +/** + * The derived string union of possible {@link RegistrarActionsResponseCodes}. + */ +export type RegistrarActionsResponseCode = + (typeof RegistrarActionsResponseCodes)[keyof typeof RegistrarActionsResponseCodes]; + +/** + * "Logical registrar action" with its associated name. + */ +export interface NamedRegistrarAction { + action: RegistrarAction; + + /** + * Name + * + * FQDN of the name associated with `action`. + * + * Guarantees: + * - `namehash(name)` is always `action.registrationLifecycle.node`. + */ + name: InterpretedName; +} + +/** + * A response when Registrar Actions are available. + */ +export type RegistrarActionsResponseOk = { + responseCode: typeof RegistrarActionsResponseCodes.Ok; + registrarActions: NamedRegistrarAction[]; +}; + +/** + * A response when Registrar Actions are unavailable. + */ +export interface RegistrarActionsResponseError { + responseCode: typeof IndexingStatusResponseCodes.Error; + error: ErrorResponse; +} + +/** + * Registrar Actions response. + * + * Use the `responseCode` field to determine the specific type interpretation + * at runtime. + */ +export type RegistrarActionsResponse = RegistrarActionsResponseOk | RegistrarActionsResponseError; diff --git a/packages/ensnode-sdk/src/api/serialize.ts b/packages/ensnode-sdk/src/api/registrar-actions/serialize.ts similarity index 53% rename from packages/ensnode-sdk/src/api/serialize.ts rename to packages/ensnode-sdk/src/api/registrar-actions/serialize.ts index 970b8fefe..fa80a93fc 100644 --- a/packages/ensnode-sdk/src/api/serialize.ts +++ b/packages/ensnode-sdk/src/api/registrar-actions/serialize.ts @@ -1,34 +1,14 @@ -import { serializeRealtimeIndexingStatusProjection } from "../ensindexer"; -import { serializeRegistrarAction } from "../registrars"; -import type { - SerializedIndexingStatusResponse, - SerializedIndexingStatusResponseOk, - SerializedNamedRegistrarAction, - SerializedRegistrarActionsResponse, - SerializedRegistrarActionsResponseOk, -} from "./serialized-types"; +import { serializeRegistrarAction } from "../../registrars"; import { - type IndexingStatusResponse, - IndexingStatusResponseCodes, type NamedRegistrarAction, type RegistrarActionsResponse, RegistrarActionsResponseCodes, -} from "./types"; - -export function serializeIndexingStatusResponse( - response: IndexingStatusResponse, -): SerializedIndexingStatusResponse { - switch (response.responseCode) { - case IndexingStatusResponseCodes.Ok: - return { - responseCode: response.responseCode, - realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection), - } satisfies SerializedIndexingStatusResponseOk; - - case IndexingStatusResponseCodes.Error: - return response; - } -} +} from "./response"; +import type { + SerializedNamedRegistrarAction, + SerializedRegistrarActionsResponse, + SerializedRegistrarActionsResponseOk, +} from "./serialized-response"; export function serializeNamedRegistrarAction({ action, diff --git a/packages/ensnode-sdk/src/api/registrar-actions/serialized-response.ts b/packages/ensnode-sdk/src/api/registrar-actions/serialized-response.ts new file mode 100644 index 000000000..b95c076cd --- /dev/null +++ b/packages/ensnode-sdk/src/api/registrar-actions/serialized-response.ts @@ -0,0 +1,33 @@ +import type { SerializedRegistrarAction } from "../../registrars"; +import type { + NamedRegistrarAction, + RegistrarActionsResponseError, + RegistrarActionsResponseOk, +} from "./response"; + +/** + * Serialized representation of {@link RegistrarActionsResponseError}. + */ +export type SerializedRegistrarActionsResponseError = RegistrarActionsResponseError; + +/** + * Serialized representation of {@link NamedRegistrarAction}. + */ +export interface SerializedNamedRegistrarAction extends Omit { + action: SerializedRegistrarAction; +} + +/** + * Serialized representation of {@link RegistrarActionsResponseOk}. + */ +export interface SerializedRegistrarActionsResponseOk + extends Omit { + registrarActions: SerializedNamedRegistrarAction[]; +} + +/** + * Serialized representation of {@link SerializedRegistrarActionsResponse}. + */ +export type SerializedRegistrarActionsResponse = + | SerializedRegistrarActionsResponseOk + | SerializedRegistrarActionsResponseError; diff --git a/packages/ensnode-sdk/src/api/zod-schemas.test.ts b/packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.test.ts similarity index 94% rename from packages/ensnode-sdk/src/api/zod-schemas.test.ts rename to packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.test.ts index d6e918d48..efb3b1158 100644 --- a/packages/ensnode-sdk/src/api/zod-schemas.test.ts +++ b/packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.test.ts @@ -1,14 +1,14 @@ import { describe, expect, it } from "vitest"; -import type { InterpretedName } from "../ens"; -import { makeRegistrarActionsResponseSchema } from "../internal"; -import { registrarActionsPrerequisites } from "./registrar-actions"; +import type { InterpretedName } from "../../ens"; +import { registrarActionsPrerequisites } from "../registrar-actions"; +import { RegistrarActionsResponseCodes, type RegistrarActionsResponseError } from "./response"; import type { SerializedNamedRegistrarAction, SerializedRegistrarActionsResponseError, SerializedRegistrarActionsResponseOk, -} from "./serialized-types"; -import { RegistrarActionsResponseCodes, type RegistrarActionsResponseError } from "./types"; +} from "./serialized-response"; +import { makeRegistrarActionsResponseSchema } from "./zod-schemas"; describe("ENSNode API Schema", () => { describe("Registrar Actions API", () => { diff --git a/packages/ensnode-sdk/src/api/zod-schemas.ts b/packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.ts similarity index 52% rename from packages/ensnode-sdk/src/api/zod-schemas.ts rename to packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.ts index da0963245..87c314d6c 100644 --- a/packages/ensnode-sdk/src/api/zod-schemas.ts +++ b/packages/ensnode-sdk/src/api/registrar-actions/zod-schemas.ts @@ -1,60 +1,10 @@ -import { namehash } from "viem"; +import { namehash } from "viem/ens"; import z from "zod/v4"; import type { ParsePayload } from "zod/v4/core"; -import { makeRealtimeIndexingStatusProjectionSchema } from "../ensindexer/indexing-status/zod-schemas"; -import { makeReinterpretedNameSchema } from "../internal"; -import { makeRegistrarActionSchema } from "../registrars/zod-schemas"; -import { - type IndexingStatusResponse, - IndexingStatusResponseCodes, - type IndexingStatusResponseError, - type IndexingStatusResponseOk, - type NamedRegistrarAction, - RegistrarActionsResponse, - RegistrarActionsResponseCodes, - RegistrarActionsResponseError, - RegistrarActionsResponseOk, -} from "./types"; - -export const ErrorResponseSchema = z.object({ - message: z.string(), - details: z.optional(z.unknown()), -}); - -// Indexing Status API - -/** - * Schema for {@link IndexingStatusResponseOk} - **/ -export const makeIndexingStatusResponseOkSchema = ( - valueLabel: string = "Indexing Status Response OK", -) => - z.strictObject({ - responseCode: z.literal(IndexingStatusResponseCodes.Ok), - realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel), - }); - -/** - * Schema for {@link IndexingStatusResponseError} - **/ -export const makeIndexingStatusResponseErrorSchema = ( - _valueLabel: string = "Indexing Status Response Error", -) => - z.strictObject({ - responseCode: z.literal(IndexingStatusResponseCodes.Error), - }); - -/** - * Schema for {@link IndexingStatusResponse} - **/ -export const makeIndexingStatusResponseSchema = (valueLabel: string = "Indexing Status Response") => - z.discriminatedUnion("responseCode", [ - makeIndexingStatusResponseOkSchema(valueLabel), - makeIndexingStatusResponseErrorSchema(valueLabel), - ]); - -// Registrar Action API +import { makeRegistrarActionSchema, makeReinterpretedNameSchema } from "../../internal"; +import { ErrorResponseSchema } from "../shared/errors/zod-schemas"; +import { type NamedRegistrarAction, RegistrarActionsResponseCodes } from "./response"; function invariant_registrationLifecycleNodeMatchesName(ctx: ParsePayload) { const { name, action } = ctx.value; @@ -83,7 +33,7 @@ export const makeNamedRegistrarActionSchema = (valueLabel: string = "Named Regis /** * Schema for {@link RegistrarActionsResponseOk} - **/ + */ export const makeRegistrarActionsResponseOkSchema = ( valueLabel: string = "Registrar Actions Response OK", ) => @@ -94,7 +44,7 @@ export const makeRegistrarActionsResponseOkSchema = ( /** * Schema for {@link RegistrarActionsResponseError} - **/ + */ export const makeRegistrarActionsResponseErrorSchema = ( _valueLabel: string = "Registrar Actions Response Error", ) => @@ -105,7 +55,7 @@ export const makeRegistrarActionsResponseErrorSchema = ( /** * Schema for {@link RegistrarActionsResponse} - **/ + */ export const makeRegistrarActionsResponseSchema = ( valueLabel: string = "Registrar Actions Response", ) => diff --git a/packages/ensnode-sdk/src/api/resolution/index.ts b/packages/ensnode-sdk/src/api/resolution/index.ts new file mode 100644 index 000000000..eea524d65 --- /dev/null +++ b/packages/ensnode-sdk/src/api/resolution/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/packages/ensnode-sdk/src/api/resolution/types.ts b/packages/ensnode-sdk/src/api/resolution/types.ts new file mode 100644 index 000000000..075a9a737 --- /dev/null +++ b/packages/ensnode-sdk/src/api/resolution/types.ts @@ -0,0 +1,68 @@ +import type { + ForwardResolutionArgs, + MultichainPrimaryNameResolutionArgs, + MultichainPrimaryNameResolutionResult, + ResolverRecordsResponse, + ResolverRecordsSelection, + ReverseResolutionArgs, + ReverseResolutionResult, +} from "../../resolution"; +import type { ProtocolTrace } from "../../tracing"; + +export interface TraceableRequest { + trace?: boolean; +} + +export interface TraceableResponse { + trace?: ProtocolTrace; +} + +export interface AcceleratableRequest { + accelerate?: boolean; +} + +export interface AcceleratableResponse { + accelerationRequested: boolean; + accelerationAttempted: boolean; +} + +/** + * Resolve Records Request Type + */ +export interface ResolveRecordsRequest + extends ForwardResolutionArgs, + AcceleratableRequest, + TraceableRequest {} + +/** + * Resolve Records Response Type + */ +export interface ResolveRecordsResponse + extends AcceleratableResponse, + TraceableResponse { + records: ResolverRecordsResponse; +} + +/** + * Resolve Primary Name Request Type + */ +export interface ResolvePrimaryNameRequest + extends ReverseResolutionArgs, + AcceleratableRequest, + TraceableRequest {} + +/** + * Resolve Primary Name Response Type + */ +export interface ResolvePrimaryNameResponse extends AcceleratableResponse, TraceableResponse { + name: ReverseResolutionResult; +} + +export interface ResolvePrimaryNamesRequest + extends MultichainPrimaryNameResolutionArgs, + AcceleratableRequest, + TraceableRequest {} + +export interface ResolvePrimaryNamesResponse extends AcceleratableResponse, TraceableResponse { + names: MultichainPrimaryNameResolutionResult; +} diff --git a/packages/ensnode-sdk/src/api/serialized-types.ts b/packages/ensnode-sdk/src/api/serialized-types.ts deleted file mode 100644 index e189a1818..000000000 --- a/packages/ensnode-sdk/src/api/serialized-types.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { SerializedRealtimeIndexingStatusProjection } from "../ensindexer"; -import type { SerializedRegistrarAction } from "../registrars"; -import { - IndexingStatusResponse, - type IndexingStatusResponseError, - type IndexingStatusResponseOk, - type NamedRegistrarAction, - type RegistrarActionsResponseError, - type RegistrarActionsResponseOk, -} from "./types"; - -/** - * Serialized representation of {@link IndexingStatusResponseError}. - */ -export type SerializedIndexingStatusResponseError = IndexingStatusResponseError; - -/** - * Serialized representation of {@link IndexingStatusResponseOk}. - */ -export interface SerializedIndexingStatusResponseOk - extends Omit { - realtimeProjection: SerializedRealtimeIndexingStatusProjection; -} - -/** - * Serialized representation of {@link IndexingStatusResponse}. - */ -export type SerializedIndexingStatusResponse = - | SerializedIndexingStatusResponseOk - | SerializedIndexingStatusResponseError; - -/** - * Serialized representation of {@link RegistrarActionsResponseError}. - */ -export type SerializedRegistrarActionsResponseError = RegistrarActionsResponseError; - -/** - * Serialized representation of {@link NamedRegistrarAction}. - */ -export interface SerializedNamedRegistrarAction extends Omit { - action: SerializedRegistrarAction; -} - -/** - * Serialized representation of {@link RegistrarActionsResponseOk}. - */ -export interface SerializedRegistrarActionsResponseOk - extends Omit { - registrarActions: SerializedNamedRegistrarAction[]; -} - -/** - * Serialized representation of {@link SerializedRegistrarActionsResponse}. - */ -export type SerializedRegistrarActionsResponse = - | SerializedRegistrarActionsResponseOk - | SerializedRegistrarActionsResponseError; diff --git a/packages/ensnode-sdk/src/api/shared/errors/deserialize.ts b/packages/ensnode-sdk/src/api/shared/errors/deserialize.ts new file mode 100644 index 000000000..c96d00961 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/errors/deserialize.ts @@ -0,0 +1,17 @@ +import { prettifyError } from "zod/v4"; + +import type { ErrorResponse } from "./response"; +import { ErrorResponseSchema } from "./zod-schemas"; + +/** + * Deserialize a {@link ErrorResponse} object. + */ +export function deserializeErrorResponse(maybeErrorResponse: unknown): ErrorResponse { + const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse); + + if (parsed.error) { + throw new Error(`Cannot deserialize ErrorResponse:\n${prettifyError(parsed.error)}\n`); + } + + return parsed.data; +} diff --git a/packages/ensnode-sdk/src/api/shared/errors/index.ts b/packages/ensnode-sdk/src/api/shared/errors/index.ts new file mode 100644 index 000000000..9be6b93a5 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/errors/index.ts @@ -0,0 +1,2 @@ +export * from "./deserialize"; +export * from "./response"; diff --git a/packages/ensnode-sdk/src/api/shared/errors/response.ts b/packages/ensnode-sdk/src/api/shared/errors/response.ts new file mode 100644 index 000000000..5fdc88c4b --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/errors/response.ts @@ -0,0 +1,8 @@ +import type z from "zod/v4"; + +import type { ErrorResponseSchema } from "./zod-schemas"; + +/** + * API Error Response Type + */ +export type ErrorResponse = z.infer; diff --git a/packages/ensnode-sdk/src/api/shared/errors/zod-schemas.ts b/packages/ensnode-sdk/src/api/shared/errors/zod-schemas.ts new file mode 100644 index 000000000..7d76a13df --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/errors/zod-schemas.ts @@ -0,0 +1,11 @@ +import z from "zod/v4"; + +import type { ErrorResponse } from "./response"; + +/** + * Schema for {@link ErrorResponse}. + */ +export const ErrorResponseSchema = z.object({ + message: z.string(), + details: z.optional(z.unknown()), +}); diff --git a/packages/ensnode-sdk/src/api/shared/index.ts b/packages/ensnode-sdk/src/api/shared/index.ts new file mode 100644 index 000000000..2514d6e37 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/index.ts @@ -0,0 +1,2 @@ +export * from "./errors"; +export * from "./pagination"; diff --git a/packages/ensnode-sdk/src/api/shared/pagination/index.ts b/packages/ensnode-sdk/src/api/shared/pagination/index.ts new file mode 100644 index 000000000..346dac3b3 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/pagination/index.ts @@ -0,0 +1,2 @@ +export * from "./request"; +export * from "./response"; diff --git a/packages/ensnode-sdk/src/api/shared/pagination/request.ts b/packages/ensnode-sdk/src/api/shared/pagination/request.ts new file mode 100644 index 000000000..edc254841 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/pagination/request.ts @@ -0,0 +1,22 @@ +export const RECORDS_PER_PAGE_DEFAULT = 10; + +export const RECORDS_PER_PAGE_MAX = 100; + +/** + * Request pagination params. + */ +export interface RequestPaginationParams { + /** + * Requested page number (1-indexed) + * @invariant Must be a positive integer (>= 1) + * @default 1 + */ + page?: number; + + /** + * Maximum number of records to return per page + * @invariant Must be a positive integer (>= 1) and less than or equal to {@link RECORDS_PER_PAGE_MAX} + * @default {@link RECORDS_PER_PAGE_DEFAULT} + */ + recordsPerPage?: number; +} diff --git a/packages/ensnode-sdk/src/api/shared/pagination/response.ts b/packages/ensnode-sdk/src/api/shared/pagination/response.ts new file mode 100644 index 000000000..c1f35208b --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/pagination/response.ts @@ -0,0 +1,79 @@ +import type { RequestPaginationParams } from "./request"; + +export interface ResponsePaginationContextWithNoRecords extends Required { + /** + * Total number of records across all pages + */ + totalRecords: 0; + + /** + * Total number of pages + */ + totalPages: 1; + + /** + * Indicates if there is a next page available + */ + hasNext: false; + + /** + * Indicates if there is a previous page available + */ + hasPrev: false; + + /** + * The start index of the records on the page (0-indexed) + */ + startIndex: undefined; + + /** + * The end index of the records on the page (0-indexed) + */ + endIndex: undefined; +} + +export interface ResponsePaginationContextWithRecords extends Required { + /** + * Total number of records across all pages + * @invariant Guaranteed to be a non-negative integer (>= 0) + */ + totalRecords: number; + + /** + * Total number of pages + * @invariant Guaranteed to be a positive integer (>= 1) + */ + totalPages: number; + + /** + * Indicates if there is a next page available + * @invariant true if and only if (`page` * `recordsPerPage` < `totalRecords`) + */ + hasNext: boolean; + + /** + * Indicates if there is a previous page available + * @invariant true if and only if (`page` > 1) + */ + hasPrev: boolean; + + /** + * The start index of the records on the page (0-indexed) + * + * @invariant Guaranteed to be a non-negative integer (>= 0) + */ + startIndex: number; + + /** + * The end index of the records on the page (0-indexed) + * + * @invariant Guaranteed to be a non-negative integer (>= 0) + * @invariant Guaranteed to be greater than or equal to `startIndex`. + * @invariant Guaranteed to be less than `totalRecords`. + */ + endIndex: number; +} + +export type ResponsePaginationContext = + | ResponsePaginationContextWithNoRecords + | ResponsePaginationContextWithRecords; diff --git a/packages/ensnode-sdk/src/api/shared/pagination/zod-schemas.ts b/packages/ensnode-sdk/src/api/shared/pagination/zod-schemas.ts new file mode 100644 index 000000000..dd6789423 --- /dev/null +++ b/packages/ensnode-sdk/src/api/shared/pagination/zod-schemas.ts @@ -0,0 +1,110 @@ +import z from "zod/v4"; +import type { ParsePayload } from "zod/v4/core"; + +import { makeNonNegativeIntegerSchema, makePositiveIntegerSchema } from "../../../internal"; +import { RECORDS_PER_PAGE_MAX, RequestPaginationParams } from "./request"; +import { + ResponsePaginationContext, + ResponsePaginationContextWithNoRecords, + type ResponsePaginationContextWithRecords, +} from "./response"; + +/** + * Schema for {@link RequestPaginationParams} + */ +export const makeRequestPaginationParamsSchema = (valueLabel: string = "RequestPaginationParams") => + z.object({ + page: makePositiveIntegerSchema(`${valueLabel}.page`), + recordsPerPage: makePositiveIntegerSchema(`${valueLabel}.recordsPerPage`).max( + RECORDS_PER_PAGE_MAX, + `${valueLabel}.recordsPerPage must not exceed ${RECORDS_PER_PAGE_MAX}`, + ), + }); + +/** + * Schema for {@link ResponsePaginationContextWithNoRecords} + */ +export const makeResponsePaginationContextSchemaWithNoRecords = ( + valueLabel: string = "ResponsePaginationContextWithNoRecords", +) => + z + .object({ + totalRecords: z.literal(0), + totalPages: z.literal(1), + hasNext: z.literal(false), + hasPrev: z.literal(false), + startIndex: z.undefined(), + endIndex: z.undefined(), + }) + .extend(makeRequestPaginationParamsSchema(valueLabel).shape); + +function invariant_responsePaginationWithRecordsIsCorrect( + ctx: ParsePayload, +) { + const { hasNext, hasPrev, recordsPerPage, page, totalRecords, startIndex, endIndex } = ctx.value; + + const expectedHasNext = page * recordsPerPage < totalRecords; + if (hasNext !== expectedHasNext) { + ctx.issues.push({ + code: "custom", + input: ctx.value, + message: `hasNext must be equal to '${expectedHasNext ? "true" : "false"}'`, + }); + } + + const expectedHasPrev = page > 1; + if (hasPrev !== expectedHasPrev) { + ctx.issues.push({ + code: "custom", + input: ctx.value, + message: `hasPrev must be equal to '${expectedHasPrev ? "true" : "false"}'`, + }); + } + + if (endIndex < startIndex) { + ctx.issues.push({ + code: "custom", + input: ctx.value, + message: `endIndex must be greater than or equal to startIndex`, + }); + } + + if (endIndex >= totalRecords) { + ctx.issues.push({ + code: "custom", + input: ctx.value, + message: `endIndex must be lower than totalRecords`, + }); + } +} + +/** + * Schema for {@link ResponsePaginationContextWithRecords} + */ +export const makeResponsePaginationContextSchemaWithRecords = ( + valueLabel: string = "ResponsePaginationContextWithRecords", +) => + z + .object({ + totalRecords: makeNonNegativeIntegerSchema(`${valueLabel}.totalRecords`), + totalPages: makePositiveIntegerSchema(`${valueLabel}.totalPages`), + hasNext: z.boolean(), + hasPrev: z.boolean(), + startIndex: makeNonNegativeIntegerSchema(`${valueLabel}.startIndex`), + endIndex: makeNonNegativeIntegerSchema(`${valueLabel}.endIndex`), + }) + .extend(makeRequestPaginationParamsSchema(valueLabel).shape) + .check(invariant_responsePaginationWithRecordsIsCorrect); + +/** + * Schema for {@link ResponsePaginationContext} + */ +export const makeResponsePaginationContextSchema = ( + valueLabel: string = "ResponsePaginationContext", +) => + z.object({ + paginationContext: z.discriminatedUnion("totalRecords", [ + makeResponsePaginationContextSchemaWithNoRecords(valueLabel), + makeResponsePaginationContextSchemaWithRecords(valueLabel), + ]), + }); diff --git a/packages/ensnode-sdk/src/api/types.ts b/packages/ensnode-sdk/src/api/types.ts deleted file mode 100644 index 753b7676f..000000000 --- a/packages/ensnode-sdk/src/api/types.ts +++ /dev/null @@ -1,256 +0,0 @@ -import type z from "zod/v4"; - -import type { InterpretedName, Node } from "../ens"; -import type { ENSApiPublicConfig } from "../ensapi"; -import type { RealtimeIndexingStatusProjection } from "../ensindexer"; -import type { RegistrarAction } from "../registrars"; -import type { - ForwardResolutionArgs, - MultichainPrimaryNameResolutionArgs, - MultichainPrimaryNameResolutionResult, - ResolverRecordsResponse, - ResolverRecordsSelection, - ReverseResolutionArgs, - ReverseResolutionResult, -} from "../resolution"; -import type { ProtocolTrace } from "../tracing"; -import type { ErrorResponseSchema } from "./zod-schemas"; - -/** - * API Error Response Type - */ -export type ErrorResponse = z.infer; - -export interface TraceableRequest { - trace?: boolean; -} - -export interface TraceableResponse { - trace?: ProtocolTrace; -} - -export interface AcceleratableRequest { - accelerate?: boolean; -} - -export interface AcceleratableResponse { - accelerationRequested: boolean; - accelerationAttempted: boolean; -} - -/** - * Resolve Records Request Type - */ -export interface ResolveRecordsRequest - extends ForwardResolutionArgs, - AcceleratableRequest, - TraceableRequest {} - -/** - * Resolve Records Response Type - */ -export interface ResolveRecordsResponse - extends AcceleratableResponse, - TraceableResponse { - records: ResolverRecordsResponse; -} - -/** - * Resolve Primary Name Request Type - */ -export interface ResolvePrimaryNameRequest - extends ReverseResolutionArgs, - AcceleratableRequest, - TraceableRequest {} - -/** - * Resolve Primary Name Response Type - */ -export interface ResolvePrimaryNameResponse extends AcceleratableResponse, TraceableResponse { - name: ReverseResolutionResult; -} - -export interface ResolvePrimaryNamesRequest - extends MultichainPrimaryNameResolutionArgs, - AcceleratableRequest, - TraceableRequest {} - -export interface ResolvePrimaryNamesResponse extends AcceleratableResponse, TraceableResponse { - names: MultichainPrimaryNameResolutionResult; -} - -/** - * ENSIndexer Public Config Response - */ -export type ConfigResponse = ENSApiPublicConfig; - -/** - * Represents a request to Indexing Status API. - */ -export type IndexingStatusRequest = {}; - -/** - * A status code for indexing status responses. - */ -export const IndexingStatusResponseCodes = { - /** - * Represents that the indexing status is available. - */ - Ok: "ok", - - /** - * Represents that the indexing status is unavailable. - */ - Error: "error", -} as const; - -/** - * The derived string union of possible {@link IndexingStatusResponseCodes}. - */ -export type IndexingStatusResponseCode = - (typeof IndexingStatusResponseCodes)[keyof typeof IndexingStatusResponseCodes]; - -/** - * An indexing status response when the indexing status is available. - */ -export type IndexingStatusResponseOk = { - responseCode: typeof IndexingStatusResponseCodes.Ok; - realtimeProjection: RealtimeIndexingStatusProjection; -}; - -/** - * An indexing status response when the indexing status is unavailable. - */ -export type IndexingStatusResponseError = { - responseCode: typeof IndexingStatusResponseCodes.Error; -}; - -/** - * Indexing status response. - * - * Use the `responseCode` field to determine the specific type interpretation - * at runtime. - */ -export type IndexingStatusResponse = IndexingStatusResponseOk | IndexingStatusResponseError; - -/** - * Registrar Actions response - */ - -/** - * Records Filters: Filter Types - */ -export const RegistrarActionsFilterTypes = { - BySubregistryNode: "bySubregistryNode", - WithEncodedReferral: "withEncodedReferral", -} as const; - -export type RegistrarActionsFilterType = - (typeof RegistrarActionsFilterTypes)[keyof typeof RegistrarActionsFilterTypes]; - -export type RegistrarActionsFilterBySubregistryNode = { - filterType: typeof RegistrarActionsFilterTypes.BySubregistryNode; - value: Node; -}; - -export type RegistrarActionsFilterWithEncodedReferral = { - filterType: typeof RegistrarActionsFilterTypes.WithEncodedReferral; -}; - -export type RegistrarActionsFilter = - | RegistrarActionsFilterBySubregistryNode - | RegistrarActionsFilterWithEncodedReferral; - -/** - * Records Orders - */ -export const RegistrarActionsOrders = { - LatestRegistrarActions: "orderBy[timestamp]=desc", -} as const; - -export type RegistrarActionsOrder = - (typeof RegistrarActionsOrders)[keyof typeof RegistrarActionsOrders]; - -/** - * Represents a request to Registrar Actions API. - */ -export type RegistrarActionsRequest = { - /** - * Filters to be applied while generating results. - */ - filters?: RegistrarActionsFilter[]; - - /** - * Order applied while generating results. - */ - order?: RegistrarActionsOrder; - - /** - * Limit the count of items per page to selected count of records. - * - * Guaranteed to be a positive integer (if defined). - */ - itemsPerPage?: number; -}; - -/** - * A status code for Registrar Actions API responses. - */ -export const RegistrarActionsResponseCodes = { - /** - * Represents that Registrar Actions are available. - */ - Ok: "ok", - - /** - * Represents that Registrar Actions are unavailable. - */ - Error: "error", -} as const; - -/** - * The derived string union of possible {@link RegistrarActionsResponseCodes}. - */ -export type RegistrarActionsResponseCode = - (typeof RegistrarActionsResponseCodes)[keyof typeof RegistrarActionsResponseCodes]; - -/** - * "Logical registrar action" with its associated name. - */ -export interface NamedRegistrarAction { - action: RegistrarAction; - - /** - * Name - * - * FQDN of the name associated with `action`. - * - * Guarantees: - * - `namehash(name)` is always `action.registrationLifecycle.node`. - */ - name: InterpretedName; -} - -/** - * A response when Registrar Actions are available. - */ -export type RegistrarActionsResponseOk = { - responseCode: typeof RegistrarActionsResponseCodes.Ok; - registrarActions: NamedRegistrarAction[]; -}; - -/** - * A response when Registrar Actions are unavailable. - */ -export interface RegistrarActionsResponseError { - responseCode: typeof IndexingStatusResponseCodes.Error; - error: ErrorResponse; -} - -/** - * Registrar Actions response. - * - * Use the `responseCode` field to determine the specific type interpretation - * at runtime. - */ -export type RegistrarActionsResponse = RegistrarActionsResponseOk | RegistrarActionsResponseError; diff --git a/packages/ensnode-sdk/src/client.ts b/packages/ensnode-sdk/src/client.ts index 0771a9acb..6ddfca883 100644 --- a/packages/ensnode-sdk/src/client.ts +++ b/packages/ensnode-sdk/src/client.ts @@ -1,27 +1,27 @@ import { + type ConfigResponse, + deserializeConfigResponse, deserializeErrorResponse, deserializeIndexingStatusResponse, deserializeRegistrarActionsResponse, + type ErrorResponse, + type IndexingStatusResponse, + type RegistrarActionsFilter, RegistrarActionsFilterTypes, + type RegistrarActionsOrder, RegistrarActionsOrders, + type RegistrarActionsRequest, + type RegistrarActionsResponse, + type ResolvePrimaryNameRequest, + type ResolvePrimaryNameResponse, + type ResolvePrimaryNamesRequest, + type ResolvePrimaryNamesResponse, + type ResolveRecordsRequest, + type ResolveRecordsResponse, + type SerializedConfigResponse, type SerializedIndexingStatusResponse, type SerializedRegistrarActionsResponse, } from "./api"; -import type { - ConfigResponse, - ErrorResponse, - IndexingStatusResponse, - RegistrarActionsFilter, - RegistrarActionsOrder, - RegistrarActionsRequest, - RegistrarActionsResponse, - ResolvePrimaryNameRequest, - ResolvePrimaryNameResponse, - ResolvePrimaryNamesRequest, - ResolvePrimaryNamesResponse, - ResolveRecordsRequest, - ResolveRecordsResponse, -} from "./api/types"; import { ClientError } from "./client-error"; import { deserializeReferrerLeaderboardPageResponse, @@ -29,7 +29,6 @@ import { type ReferrerLeaderboardPaginationRequest, type SerializedReferrerLeaderboardPageResponse, } from "./ensanalytics"; -import { deserializeENSApiPublicConfig, type SerializedENSApiPublicConfig } from "./ensapi"; import type { ResolverRecordsSelection } from "./resolution"; /** @@ -315,7 +314,7 @@ export class ENSNodeClient { throw new Error(`Fetching ENSNode Config Failed: ${errorResponse.message}`); } - return deserializeENSApiPublicConfig(responseData as SerializedENSApiPublicConfig); + return deserializeConfigResponse(responseData as SerializedConfigResponse); } /** diff --git a/packages/ensnode-sdk/src/internal.ts b/packages/ensnode-sdk/src/internal.ts index 63e0c985b..938d9e336 100644 --- a/packages/ensnode-sdk/src/internal.ts +++ b/packages/ensnode-sdk/src/internal.ts @@ -12,8 +12,13 @@ * app/package in the monorepo which requires `@ensnode/ensnode-sdk` dependency. */ -export * from "./api/zod-schemas"; +export * from "./api/indexing-status/zod-schemas"; +export * from "./api/registrar-actions/zod-schemas"; +export * from "./api/shared/errors/zod-schemas"; +export * from "./api/shared/pagination/zod-schemas"; export * from "./ensindexer/config/zod-schemas"; +export * from "./ensindexer/indexing-status/zod-schemas"; +export * from "./registrars/zod-schemas"; export * from "./shared/config/build-rpc-urls"; export * from "./shared/config/environments"; export * from "./shared/config/pretty-printing";