/*
* 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 {
AccountIdentifier,
AccountIdentifier$inboundSchema,
AccountIdentifier$Outbound,
AccountIdentifier$outboundSchema,
} from "./accountidentifier.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
import {
Operation,
Operation$inboundSchema,
Operation$Outbound,
Operation$outboundSchema,
} from "./operation.js";
export type ConstructionParseResponseMetadata = {};
/**
* ConstructionParseResponse contains an array of operations that occur in a transaction blob. This should match the array of operations provided to `/construction/preprocess` and `/construction/payloads`.
*/
export type ConstructionParseResponse = {
operations: Array<Operation>;
/**
* [DEPRECATED by `account_identifier_signers` in `v1.4.4`] All signers (addresses) of a particular transaction. If the transaction is unsigned, it should be empty.
*/
signers?: Array<string> | undefined;
accountIdentifierSigners?: Array<AccountIdentifier> | undefined;
metadata?: ConstructionParseResponseMetadata | undefined;
};
/** @internal */
export const ConstructionParseResponseMetadata$inboundSchema: z.ZodType<
ConstructionParseResponseMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ConstructionParseResponseMetadata$Outbound = {};
/** @internal */
export const ConstructionParseResponseMetadata$outboundSchema: z.ZodType<
ConstructionParseResponseMetadata$Outbound,
z.ZodTypeDef,
ConstructionParseResponseMetadata
> = 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 ConstructionParseResponseMetadata$ {
/** @deprecated use `ConstructionParseResponseMetadata$inboundSchema` instead. */
export const inboundSchema = ConstructionParseResponseMetadata$inboundSchema;
/** @deprecated use `ConstructionParseResponseMetadata$outboundSchema` instead. */
export const outboundSchema =
ConstructionParseResponseMetadata$outboundSchema;
/** @deprecated use `ConstructionParseResponseMetadata$Outbound` instead. */
export type Outbound = ConstructionParseResponseMetadata$Outbound;
}
export function constructionParseResponseMetadataToJSON(
constructionParseResponseMetadata: ConstructionParseResponseMetadata,
): string {
return JSON.stringify(
ConstructionParseResponseMetadata$outboundSchema.parse(
constructionParseResponseMetadata,
),
);
}
export function constructionParseResponseMetadataFromJSON(
jsonString: string,
): SafeParseResult<ConstructionParseResponseMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionParseResponseMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionParseResponseMetadata' from JSON`,
);
}
/** @internal */
export const ConstructionParseResponse$inboundSchema: z.ZodType<
ConstructionParseResponse,
z.ZodTypeDef,
unknown
> = z.object({
operations: z.array(Operation$inboundSchema),
signers: z.array(z.string()).optional(),
account_identifier_signers: z.array(AccountIdentifier$inboundSchema)
.optional(),
metadata: z.lazy(() => ConstructionParseResponseMetadata$inboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
"account_identifier_signers": "accountIdentifierSigners",
});
});
/** @internal */
export type ConstructionParseResponse$Outbound = {
operations: Array<Operation$Outbound>;
signers?: Array<string> | undefined;
account_identifier_signers?: Array<AccountIdentifier$Outbound> | undefined;
metadata?: ConstructionParseResponseMetadata$Outbound | undefined;
};
/** @internal */
export const ConstructionParseResponse$outboundSchema: z.ZodType<
ConstructionParseResponse$Outbound,
z.ZodTypeDef,
ConstructionParseResponse
> = z.object({
operations: z.array(Operation$outboundSchema),
signers: z.array(z.string()).optional(),
accountIdentifierSigners: z.array(AccountIdentifier$outboundSchema)
.optional(),
metadata: z.lazy(() => ConstructionParseResponseMetadata$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
accountIdentifierSigners: "account_identifier_signers",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ConstructionParseResponse$ {
/** @deprecated use `ConstructionParseResponse$inboundSchema` instead. */
export const inboundSchema = ConstructionParseResponse$inboundSchema;
/** @deprecated use `ConstructionParseResponse$outboundSchema` instead. */
export const outboundSchema = ConstructionParseResponse$outboundSchema;
/** @deprecated use `ConstructionParseResponse$Outbound` instead. */
export type Outbound = ConstructionParseResponse$Outbound;
}
export function constructionParseResponseToJSON(
constructionParseResponse: ConstructionParseResponse,
): string {
return JSON.stringify(
ConstructionParseResponse$outboundSchema.parse(constructionParseResponse),
);
}
export function constructionParseResponseFromJSON(
jsonString: string,
): SafeParseResult<ConstructionParseResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionParseResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionParseResponse' from JSON`,
);
}