/*
* 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 {
SubNetworkIdentifier,
SubNetworkIdentifier$inboundSchema,
SubNetworkIdentifier$Outbound,
SubNetworkIdentifier$outboundSchema,
} from "./subnetworkidentifier.js";
/**
* The network_identifier specifies which network a particular object is associated with.
*/
export type NetworkIdentifier = {
blockchain: string;
/**
* If a blockchain has a specific chain-id or network identifier, it should go in this field. It is up to the client to determine which network-specific identifier is mainnet or testnet.
*/
network: string;
/**
* In blockchains with sharded state, the SubNetworkIdentifier is required to query some object on a specific shard. This identifier is optional for all non-sharded blockchains.
*/
subNetworkIdentifier?: SubNetworkIdentifier | undefined;
};
/** @internal */
export const NetworkIdentifier$inboundSchema: z.ZodType<
NetworkIdentifier,
z.ZodTypeDef,
unknown
> = z.object({
blockchain: z.string(),
network: z.string(),
sub_network_identifier: SubNetworkIdentifier$inboundSchema.optional(),
}).transform((v) => {
return remap$(v, {
"sub_network_identifier": "subNetworkIdentifier",
});
});
/** @internal */
export type NetworkIdentifier$Outbound = {
blockchain: string;
network: string;
sub_network_identifier?: SubNetworkIdentifier$Outbound | undefined;
};
/** @internal */
export const NetworkIdentifier$outboundSchema: z.ZodType<
NetworkIdentifier$Outbound,
z.ZodTypeDef,
NetworkIdentifier
> = z.object({
blockchain: z.string(),
network: z.string(),
subNetworkIdentifier: SubNetworkIdentifier$outboundSchema.optional(),
}).transform((v) => {
return remap$(v, {
subNetworkIdentifier: "sub_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 NetworkIdentifier$ {
/** @deprecated use `NetworkIdentifier$inboundSchema` instead. */
export const inboundSchema = NetworkIdentifier$inboundSchema;
/** @deprecated use `NetworkIdentifier$outboundSchema` instead. */
export const outboundSchema = NetworkIdentifier$outboundSchema;
/** @deprecated use `NetworkIdentifier$Outbound` instead. */
export type Outbound = NetworkIdentifier$Outbound;
}
export function networkIdentifierToJSON(
networkIdentifier: NetworkIdentifier,
): string {
return JSON.stringify(
NetworkIdentifier$outboundSchema.parse(networkIdentifier),
);
}
export function networkIdentifierFromJSON(
jsonString: string,
): SafeParseResult<NetworkIdentifier, SDKValidationError> {
return safeParse(
jsonString,
(x) => NetworkIdentifier$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'NetworkIdentifier' from JSON`,
);
}