/*
* 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 {
Currency,
Currency$inboundSchema,
Currency$Outbound,
Currency$outboundSchema,
} from "./currency.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
export type AmountMetadata = {};
/**
* Amount is some Value of a Currency. It is considered invalid to specify a Value without a Currency.
*/
export type Amount = {
/**
* Value of the transaction in atomic units represented as an arbitrary-sized signed integer. For example, 1 BTC would be represented by a value of 100000000.
*/
value: string;
/**
* 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).
*/
currency: Currency;
metadata?: AmountMetadata | undefined;
};
/** @internal */
export const AmountMetadata$inboundSchema: z.ZodType<
AmountMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type AmountMetadata$Outbound = {};
/** @internal */
export const AmountMetadata$outboundSchema: z.ZodType<
AmountMetadata$Outbound,
z.ZodTypeDef,
AmountMetadata
> = 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 AmountMetadata$ {
/** @deprecated use `AmountMetadata$inboundSchema` instead. */
export const inboundSchema = AmountMetadata$inboundSchema;
/** @deprecated use `AmountMetadata$outboundSchema` instead. */
export const outboundSchema = AmountMetadata$outboundSchema;
/** @deprecated use `AmountMetadata$Outbound` instead. */
export type Outbound = AmountMetadata$Outbound;
}
export function amountMetadataToJSON(amountMetadata: AmountMetadata): string {
return JSON.stringify(AmountMetadata$outboundSchema.parse(amountMetadata));
}
export function amountMetadataFromJSON(
jsonString: string,
): SafeParseResult<AmountMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => AmountMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AmountMetadata' from JSON`,
);
}
/** @internal */
export const Amount$inboundSchema: z.ZodType<Amount, z.ZodTypeDef, unknown> = z
.object({
value: z.string(),
currency: Currency$inboundSchema,
metadata: z.lazy(() => AmountMetadata$inboundSchema).optional(),
});
/** @internal */
export type Amount$Outbound = {
value: string;
currency: Currency$Outbound;
metadata?: AmountMetadata$Outbound | undefined;
};
/** @internal */
export const Amount$outboundSchema: z.ZodType<
Amount$Outbound,
z.ZodTypeDef,
Amount
> = z.object({
value: z.string(),
currency: Currency$outboundSchema,
metadata: z.lazy(() => AmountMetadata$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 Amount$ {
/** @deprecated use `Amount$inboundSchema` instead. */
export const inboundSchema = Amount$inboundSchema;
/** @deprecated use `Amount$outboundSchema` instead. */
export const outboundSchema = Amount$outboundSchema;
/** @deprecated use `Amount$Outbound` instead. */
export type Outbound = Amount$Outbound;
}
export function amountToJSON(amount: Amount): string {
return JSON.stringify(Amount$outboundSchema.parse(amount));
}
export function amountFromJSON(
jsonString: string,
): SafeParseResult<Amount, SDKValidationError> {
return safeParse(
jsonString,
(x) => Amount$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Amount' from JSON`,
);
}