/*
* 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";
export type ConstructionDeriveResponseMetadata = {};
/**
* ConstructionDeriveResponse is returned by the `/construction/derive` endpoint.
*/
export type ConstructionDeriveResponse = {
/**
* [DEPRECATED by `account_identifier` in `v1.4.4`] Address in network-specific format.
*/
address?: string | undefined;
/**
* The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).
*/
accountIdentifier?: AccountIdentifier | undefined;
metadata?: ConstructionDeriveResponseMetadata | undefined;
};
/** @internal */
export const ConstructionDeriveResponseMetadata$inboundSchema: z.ZodType<
ConstructionDeriveResponseMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ConstructionDeriveResponseMetadata$Outbound = {};
/** @internal */
export const ConstructionDeriveResponseMetadata$outboundSchema: z.ZodType<
ConstructionDeriveResponseMetadata$Outbound,
z.ZodTypeDef,
ConstructionDeriveResponseMetadata
> = 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 ConstructionDeriveResponseMetadata$ {
/** @deprecated use `ConstructionDeriveResponseMetadata$inboundSchema` instead. */
export const inboundSchema = ConstructionDeriveResponseMetadata$inboundSchema;
/** @deprecated use `ConstructionDeriveResponseMetadata$outboundSchema` instead. */
export const outboundSchema =
ConstructionDeriveResponseMetadata$outboundSchema;
/** @deprecated use `ConstructionDeriveResponseMetadata$Outbound` instead. */
export type Outbound = ConstructionDeriveResponseMetadata$Outbound;
}
export function constructionDeriveResponseMetadataToJSON(
constructionDeriveResponseMetadata: ConstructionDeriveResponseMetadata,
): string {
return JSON.stringify(
ConstructionDeriveResponseMetadata$outboundSchema.parse(
constructionDeriveResponseMetadata,
),
);
}
export function constructionDeriveResponseMetadataFromJSON(
jsonString: string,
): SafeParseResult<ConstructionDeriveResponseMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConstructionDeriveResponseMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionDeriveResponseMetadata' from JSON`,
);
}
/** @internal */
export const ConstructionDeriveResponse$inboundSchema: z.ZodType<
ConstructionDeriveResponse,
z.ZodTypeDef,
unknown
> = z.object({
address: z.string().optional(),
account_identifier: AccountIdentifier$inboundSchema.optional(),
metadata: z.lazy(() => ConstructionDeriveResponseMetadata$inboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
"account_identifier": "accountIdentifier",
});
});
/** @internal */
export type ConstructionDeriveResponse$Outbound = {
address?: string | undefined;
account_identifier?: AccountIdentifier$Outbound | undefined;
metadata?: ConstructionDeriveResponseMetadata$Outbound | undefined;
};
/** @internal */
export const ConstructionDeriveResponse$outboundSchema: z.ZodType<
ConstructionDeriveResponse$Outbound,
z.ZodTypeDef,
ConstructionDeriveResponse
> = z.object({
address: z.string().optional(),
accountIdentifier: AccountIdentifier$outboundSchema.optional(),
metadata: z.lazy(() => ConstructionDeriveResponseMetadata$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
accountIdentifier: "account_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ConstructionDeriveResponse$ {
/** @deprecated use `ConstructionDeriveResponse$inboundSchema` instead. */
export const inboundSchema = ConstructionDeriveResponse$inboundSchema;
/** @deprecated use `ConstructionDeriveResponse$outboundSchema` instead. */
export const outboundSchema = ConstructionDeriveResponse$outboundSchema;
/** @deprecated use `ConstructionDeriveResponse$Outbound` instead. */
export type Outbound = ConstructionDeriveResponse$Outbound;
}
export function constructionDeriveResponseToJSON(
constructionDeriveResponse: ConstructionDeriveResponse,
): string {
return JSON.stringify(
ConstructionDeriveResponse$outboundSchema.parse(constructionDeriveResponse),
);
}
export function constructionDeriveResponseFromJSON(
jsonString: string,
): SafeParseResult<ConstructionDeriveResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionDeriveResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionDeriveResponse' from JSON`,
);
}