/*
* 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";
export type ConstructionDeriveRequestMetadata = {};
/**
* ConstructionDeriveRequest is passed to the `/construction/derive` endpoint. Network is provided in the request because some blockchains have different address formats for different networks. Metadata is provided in the request because some blockchains allow for multiple address types (i.e. different address for validators vs normal accounts).
*/
export type ConstructionDeriveRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* PublicKey contains a public key byte array for a particular CurveType encoded in hex. Note that there is no PrivateKey struct as this is NEVER the concern of an implementation.
*/
publicKey: PublicKey;
metadata?: ConstructionDeriveRequestMetadata | undefined;
};
/** @internal */
export const ConstructionDeriveRequestMetadata$inboundSchema: z.ZodType<
ConstructionDeriveRequestMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ConstructionDeriveRequestMetadata$Outbound = {};
/** @internal */
export const ConstructionDeriveRequestMetadata$outboundSchema: z.ZodType<
ConstructionDeriveRequestMetadata$Outbound,
z.ZodTypeDef,
ConstructionDeriveRequestMetadata
> = 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 ConstructionDeriveRequestMetadata$ {
/** @deprecated use `ConstructionDeriveRequestMetadata$inboundSchema` instead. */
export const inboundSchema = ConstructionDeriveRequestMetadata$inboundSchema;
/** @deprecated use `ConstructionDeriveRequestMetadata$outboundSchema` instead. */
export const outboundSchema =
ConstructionDeriveRequestMetadata$outboundSchema;
/** @deprecated use `ConstructionDeriveRequestMetadata$Outbound` instead. */
export type Outbound = ConstructionDeriveRequestMetadata$Outbound;
}
export function constructionDeriveRequestMetadataToJSON(
constructionDeriveRequestMetadata: ConstructionDeriveRequestMetadata,
): string {
return JSON.stringify(
ConstructionDeriveRequestMetadata$outboundSchema.parse(
constructionDeriveRequestMetadata,
),
);
}
export function constructionDeriveRequestMetadataFromJSON(
jsonString: string,
): SafeParseResult<ConstructionDeriveRequestMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionDeriveRequestMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionDeriveRequestMetadata' from JSON`,
);
}
/** @internal */
export const ConstructionDeriveRequest$inboundSchema: z.ZodType<
ConstructionDeriveRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
public_key: PublicKey$inboundSchema,
metadata: z.lazy(() => ConstructionDeriveRequestMetadata$inboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
"public_key": "publicKey",
});
});
/** @internal */
export type ConstructionDeriveRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
public_key: PublicKey$Outbound;
metadata?: ConstructionDeriveRequestMetadata$Outbound | undefined;
};
/** @internal */
export const ConstructionDeriveRequest$outboundSchema: z.ZodType<
ConstructionDeriveRequest$Outbound,
z.ZodTypeDef,
ConstructionDeriveRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
publicKey: PublicKey$outboundSchema,
metadata: z.lazy(() => ConstructionDeriveRequestMetadata$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
publicKey: "public_key",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ConstructionDeriveRequest$ {
/** @deprecated use `ConstructionDeriveRequest$inboundSchema` instead. */
export const inboundSchema = ConstructionDeriveRequest$inboundSchema;
/** @deprecated use `ConstructionDeriveRequest$outboundSchema` instead. */
export const outboundSchema = ConstructionDeriveRequest$outboundSchema;
/** @deprecated use `ConstructionDeriveRequest$Outbound` instead. */
export type Outbound = ConstructionDeriveRequest$Outbound;
}
export function constructionDeriveRequestToJSON(
constructionDeriveRequest: ConstructionDeriveRequest,
): string {
return JSON.stringify(
ConstructionDeriveRequest$outboundSchema.parse(constructionDeriveRequest),
);
}
export function constructionDeriveRequestFromJSON(
jsonString: string,
): SafeParseResult<ConstructionDeriveRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConstructionDeriveRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConstructionDeriveRequest' from JSON`,
);
}