/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { remap as remap$ } from "../lib/primitives.js";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
import {
NetworkIdentifier,
NetworkIdentifier$inboundSchema,
NetworkIdentifier$Outbound,
NetworkIdentifier$outboundSchema,
} from "./networkidentifier.js";
/**
* EventsBlocksRequest is utilized to fetch a sequence of BlockEvents indicating which blocks were added and removed from storage to reach the current state.
*/
export type EventsBlocksRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* offset is the offset into the event stream to sync events from. If this field is not populated, we return the limit events backwards from tip. If this is set to 0, we start from the beginning.
*/
offset?: number | undefined;
/**
* limit is the maximum number of events to fetch in one call. The implementation may return <= limit events.
*/
limit?: number | undefined;
};
/** @internal */
export const EventsBlocksRequest$inboundSchema: z.ZodType<
EventsBlocksRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
offset: z.number().int().optional(),
limit: z.number().int().optional(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
});
});
/** @internal */
export type EventsBlocksRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
offset?: number | undefined;
limit?: number | undefined;
};
/** @internal */
export const EventsBlocksRequest$outboundSchema: z.ZodType<
EventsBlocksRequest$Outbound,
z.ZodTypeDef,
EventsBlocksRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
offset: z.number().int().optional(),
limit: z.number().int().optional(),
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace EventsBlocksRequest$ {
/** @deprecated use `EventsBlocksRequest$inboundSchema` instead. */
export const inboundSchema = EventsBlocksRequest$inboundSchema;
/** @deprecated use `EventsBlocksRequest$outboundSchema` instead. */
export const outboundSchema = EventsBlocksRequest$outboundSchema;
/** @deprecated use `EventsBlocksRequest$Outbound` instead. */
export type Outbound = EventsBlocksRequest$Outbound;
}
export function eventsBlocksRequestToJSON(
eventsBlocksRequest: EventsBlocksRequest,
): string {
return JSON.stringify(
EventsBlocksRequest$outboundSchema.parse(eventsBlocksRequest),
);
}
export function eventsBlocksRequestFromJSON(
jsonString: string,
): SafeParseResult<EventsBlocksRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => EventsBlocksRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'EventsBlocksRequest' from JSON`,
);
}