/*
* 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";
import {
Operation,
Operation$inboundSchema,
Operation$Outbound,
Operation$outboundSchema,
} from "./operation.js";
export type ConstructionPreprocessRequestMetadata = {};
/**
* ConstructionPreprocessRequest is passed to the `/construction/preprocess` endpoint so that a Rosetta implementation can determine which metadata it needs to request for construction. Metadata provided in this object should NEVER be a product of live data (i.e. the caller must follow some network-specific data fetching strategy outside of the Construction API to populate required Metadata). If live data is required for construction, it MUST be fetched in the call to `/construction/metadata`.
*/
export type ConstructionPreprocessRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
operations: Array<Operation>;
metadata?: ConstructionPreprocessRequestMetadata | undefined;
};
/** @internal */
export const ConstructionPreprocessRequestMetadata$inboundSchema: z.ZodType<
ConstructionPreprocessRequestMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ConstructionPreprocessRequestMetadata$Outbound = {};
/** @internal */
export const ConstructionPreprocessRequestMetadata$outboundSchema: z.ZodType<
ConstructionPreprocessRequestMetadata$Outbound,
z.ZodTypeDef,
ConstructionPreprocessRequestMetadata
> = z.object({});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ConstructionPreprocessRequestMetadata$ {
/** @deprecated use `ConstructionPreprocessRequestMetadata$inboundSchema` instead. */
export const inboundSchema =
ConstructionPreprocessRequestMetadata$inboundSchema;
/** @deprecated use `ConstructionPreprocessRequestMetadata$outboundSchema` instead. */
export const outboundSchema =
ConstructionPreprocessRequestMetadata$outboundSchema;
/** @deprecated use `ConstructionPreprocessRequestMetadata$Outbound` instead. */
export type Outbound = ConstructionPreprocessRequestMetadata$Outbound;
}
export function constructionPreprocessRequestMetadataToJSON(
constructionPreprocessRequestMetadata: ConstructionPreprocessRequestMetadata,
): string {
return JSON.stringify(
ConstructionPreprocessRequestMetadata$outboundSchema.parse(
constructionPreprocessRequestMetadata,
),
);
}
export function constructionPreprocessRequestMetadataFromJSON(
jsonString: string,
): SafeParseResult<ConstructionPreprocessRequestMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConstructionPreprocessRequestMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionPreprocessRequestMetadata' from JSON`,
);
}
/** @internal */
export const ConstructionPreprocessRequest$inboundSchema: z.ZodType<
ConstructionPreprocessRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
operations: z.array(Operation$inboundSchema),
metadata: z.lazy(() => ConstructionPreprocessRequestMetadata$inboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
});
});
/** @internal */
export type ConstructionPreprocessRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
operations: Array<Operation$Outbound>;
metadata?: ConstructionPreprocessRequestMetadata$Outbound | undefined;
};
/** @internal */
export const ConstructionPreprocessRequest$outboundSchema: z.ZodType<
ConstructionPreprocessRequest$Outbound,
z.ZodTypeDef,
ConstructionPreprocessRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
operations: z.array(Operation$outboundSchema),
metadata: z.lazy(() => ConstructionPreprocessRequestMetadata$outboundSchema)
.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 ConstructionPreprocessRequest$ {
/** @deprecated use `ConstructionPreprocessRequest$inboundSchema` instead. */
export const inboundSchema = ConstructionPreprocessRequest$inboundSchema;
/** @deprecated use `ConstructionPreprocessRequest$outboundSchema` instead. */
export const outboundSchema = ConstructionPreprocessRequest$outboundSchema;
/** @deprecated use `ConstructionPreprocessRequest$Outbound` instead. */
export type Outbound = ConstructionPreprocessRequest$Outbound;
}
export function constructionPreprocessRequestToJSON(
constructionPreprocessRequest: ConstructionPreprocessRequest,
): string {
return JSON.stringify(
ConstructionPreprocessRequest$outboundSchema.parse(
constructionPreprocessRequest,
),
);
}
export function constructionPreprocessRequestFromJSON(
jsonString: string,
): SafeParseResult<ConstructionPreprocessRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionPreprocessRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionPreprocessRequest' from JSON`,
);
}