/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. If neither property is specified, it is assumed that the client is making a request at the current block.
*/
export type PartialBlockIdentifier = {
index?: number | undefined;
hash?: string | undefined;
};
/** @internal */
export const PartialBlockIdentifier$inboundSchema: z.ZodType<
PartialBlockIdentifier,
z.ZodTypeDef,
unknown
> = z.object({
index: z.number().int().optional(),
hash: z.string().optional(),
});
/** @internal */
export type PartialBlockIdentifier$Outbound = {
index?: number | undefined;
hash?: string | undefined;
};
/** @internal */
export const PartialBlockIdentifier$outboundSchema: z.ZodType<
PartialBlockIdentifier$Outbound,
z.ZodTypeDef,
PartialBlockIdentifier
> = z.object({
index: z.number().int().optional(),
hash: z.string().optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PartialBlockIdentifier$ {
/** @deprecated use `PartialBlockIdentifier$inboundSchema` instead. */
export const inboundSchema = PartialBlockIdentifier$inboundSchema;
/** @deprecated use `PartialBlockIdentifier$outboundSchema` instead. */
export const outboundSchema = PartialBlockIdentifier$outboundSchema;
/** @deprecated use `PartialBlockIdentifier$Outbound` instead. */
export type Outbound = PartialBlockIdentifier$Outbound;
}
export function partialBlockIdentifierToJSON(
partialBlockIdentifier: PartialBlockIdentifier,
): string {
return JSON.stringify(
PartialBlockIdentifier$outboundSchema.parse(partialBlockIdentifier),
);
}
export function partialBlockIdentifierFromJSON(
jsonString: string,
): SafeParseResult<PartialBlockIdentifier, SDKValidationError> {
return safeParse(
jsonString,
(x) => PartialBlockIdentifier$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PartialBlockIdentifier' from JSON`,
);
}