/*
* 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 {
PublicKey,
PublicKey$inboundSchema,
PublicKey$Outbound,
PublicKey$outboundSchema,
} from "./publickey.js";
/**
* Some blockchains require different metadata for different types of transaction construction (ex: delegation versus a transfer). Instead of requiring a blockchain node to return all possible types of metadata for construction (which may require multiple node fetches), the client can populate an options object to limit the metadata returned to only the subset required.
*/
export type ConstructionMetadataRequestOptions = {};
/**
* A ConstructionMetadataRequest is utilized to get information required to construct a transaction. The Options object used to specify which metadata to return is left purposely unstructured to allow flexibility for implementers. Options is not required in the case that there is network-wide metadata of interest. Optionally, the request can also include an array of PublicKeys associated with the AccountIdentifiers returned in ConstructionPreprocessResponse.
*/
export type ConstructionMetadataRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* Some blockchains require different metadata for different types of transaction construction (ex: delegation versus a transfer). Instead of requiring a blockchain node to return all possible types of metadata for construction (which may require multiple node fetches), the client can populate an options object to limit the metadata returned to only the subset required.
*/
options?: ConstructionMetadataRequestOptions | undefined;
publicKeys?: Array<PublicKey> | undefined;
};
/** @internal */
export const ConstructionMetadataRequestOptions$inboundSchema: z.ZodType<
ConstructionMetadataRequestOptions,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ConstructionMetadataRequestOptions$Outbound = {};
/** @internal */
export const ConstructionMetadataRequestOptions$outboundSchema: z.ZodType<
ConstructionMetadataRequestOptions$Outbound,
z.ZodTypeDef,
ConstructionMetadataRequestOptions
> = 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 ConstructionMetadataRequestOptions$ {
/** @deprecated use `ConstructionMetadataRequestOptions$inboundSchema` instead. */
export const inboundSchema = ConstructionMetadataRequestOptions$inboundSchema;
/** @deprecated use `ConstructionMetadataRequestOptions$outboundSchema` instead. */
export const outboundSchema =
ConstructionMetadataRequestOptions$outboundSchema;
/** @deprecated use `ConstructionMetadataRequestOptions$Outbound` instead. */
export type Outbound = ConstructionMetadataRequestOptions$Outbound;
}
export function constructionMetadataRequestOptionsToJSON(
constructionMetadataRequestOptions: ConstructionMetadataRequestOptions,
): string {
return JSON.stringify(
ConstructionMetadataRequestOptions$outboundSchema.parse(
constructionMetadataRequestOptions,
),
);
}
export function constructionMetadataRequestOptionsFromJSON(
jsonString: string,
): SafeParseResult<ConstructionMetadataRequestOptions, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConstructionMetadataRequestOptions$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionMetadataRequestOptions' from JSON`,
);
}
/** @internal */
export const ConstructionMetadataRequest$inboundSchema: z.ZodType<
ConstructionMetadataRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
options: z.lazy(() => ConstructionMetadataRequestOptions$inboundSchema)
.optional(),
public_keys: z.array(PublicKey$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
"public_keys": "publicKeys",
});
});
/** @internal */
export type ConstructionMetadataRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
options?: ConstructionMetadataRequestOptions$Outbound | undefined;
public_keys?: Array<PublicKey$Outbound> | undefined;
};
/** @internal */
export const ConstructionMetadataRequest$outboundSchema: z.ZodType<
ConstructionMetadataRequest$Outbound,
z.ZodTypeDef,
ConstructionMetadataRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
options: z.lazy(() => ConstructionMetadataRequestOptions$outboundSchema)
.optional(),
publicKeys: z.array(PublicKey$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
publicKeys: "public_keys",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ConstructionMetadataRequest$ {
/** @deprecated use `ConstructionMetadataRequest$inboundSchema` instead. */
export const inboundSchema = ConstructionMetadataRequest$inboundSchema;
/** @deprecated use `ConstructionMetadataRequest$outboundSchema` instead. */
export const outboundSchema = ConstructionMetadataRequest$outboundSchema;
/** @deprecated use `ConstructionMetadataRequest$Outbound` instead. */
export type Outbound = ConstructionMetadataRequest$Outbound;
}
export function constructionMetadataRequestToJSON(
constructionMetadataRequest: ConstructionMetadataRequest,
): string {
return JSON.stringify(
ConstructionMetadataRequest$outboundSchema.parse(
constructionMetadataRequest,
),
);
}
export function constructionMetadataRequestFromJSON(
jsonString: string,
): SafeParseResult<ConstructionMetadataRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionMetadataRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionMetadataRequest' from JSON`,
);
}