/*
* 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";
/**
* ConstructionParseRequest is the input to the `/construction/parse` endpoint. It allows the caller to parse either an unsigned or signed transaction.
*/
export type ConstructionParseRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* Signed is a boolean indicating whether the transaction is signed.
*/
signed: boolean;
/**
* This must be either the unsigned transaction blob returned by `/construction/payloads` or the signed transaction blob returned by `/construction/combine`.
*/
transaction: string;
};
/** @internal */
export const ConstructionParseRequest$inboundSchema: z.ZodType<
ConstructionParseRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
signed: z.boolean(),
transaction: z.string(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
});
});
/** @internal */
export type ConstructionParseRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
signed: boolean;
transaction: string;
};
/** @internal */
export const ConstructionParseRequest$outboundSchema: z.ZodType<
ConstructionParseRequest$Outbound,
z.ZodTypeDef,
ConstructionParseRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
signed: z.boolean(),
transaction: z.string(),
}).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 ConstructionParseRequest$ {
/** @deprecated use `ConstructionParseRequest$inboundSchema` instead. */
export const inboundSchema = ConstructionParseRequest$inboundSchema;
/** @deprecated use `ConstructionParseRequest$outboundSchema` instead. */
export const outboundSchema = ConstructionParseRequest$outboundSchema;
/** @deprecated use `ConstructionParseRequest$Outbound` instead. */
export type Outbound = ConstructionParseRequest$Outbound;
}
export function constructionParseRequestToJSON(
constructionParseRequest: ConstructionParseRequest,
): string {
return JSON.stringify(
ConstructionParseRequest$outboundSchema.parse(constructionParseRequest),
);
}
export function constructionParseRequestFromJSON(
jsonString: string,
): SafeParseResult<ConstructionParseRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionParseRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionParseRequest' from JSON`,
);
}