/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* Any additional information related to the currency itself. For example, it would be useful to populate this object with the contract address of an ERC-20 token.
*/
export type CurrencyMetadata = {};
/**
* Currency is composed of a canonical Symbol and Decimals. This Decimals value is used to convert an Amount.Value from atomic units (Satoshis) to standard units (Bitcoins).
*/
export type Currency = {
/**
* Canonical symbol associated with a currency.
*/
symbol: string;
/**
* Number of decimal places in the standard unit representation of the amount. For example, BTC has 8 decimals. Note that it is not possible to represent the value of some currency in atomic units that is not base 10.
*/
decimals: number;
/**
* Any additional information related to the currency itself. For example, it would be useful to populate this object with the contract address of an ERC-20 token.
*/
metadata?: CurrencyMetadata | undefined;
};
/** @internal */
export const CurrencyMetadata$inboundSchema: z.ZodType<
CurrencyMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type CurrencyMetadata$Outbound = {};
/** @internal */
export const CurrencyMetadata$outboundSchema: z.ZodType<
CurrencyMetadata$Outbound,
z.ZodTypeDef,
CurrencyMetadata
> = 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 CurrencyMetadata$ {
/** @deprecated use `CurrencyMetadata$inboundSchema` instead. */
export const inboundSchema = CurrencyMetadata$inboundSchema;
/** @deprecated use `CurrencyMetadata$outboundSchema` instead. */
export const outboundSchema = CurrencyMetadata$outboundSchema;
/** @deprecated use `CurrencyMetadata$Outbound` instead. */
export type Outbound = CurrencyMetadata$Outbound;
}
export function currencyMetadataToJSON(
currencyMetadata: CurrencyMetadata,
): string {
return JSON.stringify(
CurrencyMetadata$outboundSchema.parse(currencyMetadata),
);
}
export function currencyMetadataFromJSON(
jsonString: string,
): SafeParseResult<CurrencyMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => CurrencyMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CurrencyMetadata' from JSON`,
);
}
/** @internal */
export const Currency$inboundSchema: z.ZodType<
Currency,
z.ZodTypeDef,
unknown
> = z.object({
symbol: z.string(),
decimals: z.number().int(),
metadata: z.lazy(() => CurrencyMetadata$inboundSchema).optional(),
});
/** @internal */
export type Currency$Outbound = {
symbol: string;
decimals: number;
metadata?: CurrencyMetadata$Outbound | undefined;
};
/** @internal */
export const Currency$outboundSchema: z.ZodType<
Currency$Outbound,
z.ZodTypeDef,
Currency
> = z.object({
symbol: z.string(),
decimals: z.number().int(),
metadata: z.lazy(() => CurrencyMetadata$outboundSchema).optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Currency$ {
/** @deprecated use `Currency$inboundSchema` instead. */
export const inboundSchema = Currency$inboundSchema;
/** @deprecated use `Currency$outboundSchema` instead. */
export const outboundSchema = Currency$outboundSchema;
/** @deprecated use `Currency$Outbound` instead. */
export type Outbound = Currency$Outbound;
}
export function currencyToJSON(currency: Currency): string {
return JSON.stringify(Currency$outboundSchema.parse(currency));
}
export function currencyFromJSON(
jsonString: string,
): SafeParseResult<Currency, SDKValidationError> {
return safeParse(
jsonString,
(x) => Currency$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Currency' from JSON`,
);
}