/*
* 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 {
Amount,
Amount$inboundSchema,
Amount$Outbound,
Amount$outboundSchema,
} from "./amount.js";
import {
BlockIdentifier,
BlockIdentifier$inboundSchema,
BlockIdentifier$Outbound,
BlockIdentifier$outboundSchema,
} from "./blockidentifier.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* Account-based blockchains that utilize a nonce or sequence number should include that number in the metadata. This number could be unique to the identifier or global across the account address.
*/
export type AccountBalanceResponseMetadata = {};
/**
* An AccountBalanceResponse is returned on the /account/balance endpoint. If an account has a balance for each AccountIdentifier describing it (ex: an ERC-20 token balance on a few smart contracts), an account balance request must be made with each AccountIdentifier. The `coins` field was removed and replaced by by `/account/coins` in `v1.4.7`.
*/
export type AccountBalanceResponse = {
/**
* The block_identifier uniquely identifies a block in a particular network.
*/
blockIdentifier: BlockIdentifier;
/**
* A single account may have a balance in multiple currencies.
*/
balances: Array<Amount>;
/**
* Account-based blockchains that utilize a nonce or sequence number should include that number in the metadata. This number could be unique to the identifier or global across the account address.
*/
metadata?: AccountBalanceResponseMetadata | undefined;
};
/** @internal */
export const AccountBalanceResponseMetadata$inboundSchema: z.ZodType<
AccountBalanceResponseMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type AccountBalanceResponseMetadata$Outbound = {};
/** @internal */
export const AccountBalanceResponseMetadata$outboundSchema: z.ZodType<
AccountBalanceResponseMetadata$Outbound,
z.ZodTypeDef,
AccountBalanceResponseMetadata
> = 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 AccountBalanceResponseMetadata$ {
/** @deprecated use `AccountBalanceResponseMetadata$inboundSchema` instead. */
export const inboundSchema = AccountBalanceResponseMetadata$inboundSchema;
/** @deprecated use `AccountBalanceResponseMetadata$outboundSchema` instead. */
export const outboundSchema = AccountBalanceResponseMetadata$outboundSchema;
/** @deprecated use `AccountBalanceResponseMetadata$Outbound` instead. */
export type Outbound = AccountBalanceResponseMetadata$Outbound;
}
export function accountBalanceResponseMetadataToJSON(
accountBalanceResponseMetadata: AccountBalanceResponseMetadata,
): string {
return JSON.stringify(
AccountBalanceResponseMetadata$outboundSchema.parse(
accountBalanceResponseMetadata,
),
);
}
export function accountBalanceResponseMetadataFromJSON(
jsonString: string,
): SafeParseResult<AccountBalanceResponseMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountBalanceResponseMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountBalanceResponseMetadata' from JSON`,
);
}
/** @internal */
export const AccountBalanceResponse$inboundSchema: z.ZodType<
AccountBalanceResponse,
z.ZodTypeDef,
unknown
> = z.object({
block_identifier: BlockIdentifier$inboundSchema,
balances: z.array(Amount$inboundSchema),
metadata: z.lazy(() => AccountBalanceResponseMetadata$inboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
"block_identifier": "blockIdentifier",
});
});
/** @internal */
export type AccountBalanceResponse$Outbound = {
block_identifier: BlockIdentifier$Outbound;
balances: Array<Amount$Outbound>;
metadata?: AccountBalanceResponseMetadata$Outbound | undefined;
};
/** @internal */
export const AccountBalanceResponse$outboundSchema: z.ZodType<
AccountBalanceResponse$Outbound,
z.ZodTypeDef,
AccountBalanceResponse
> = z.object({
blockIdentifier: BlockIdentifier$outboundSchema,
balances: z.array(Amount$outboundSchema),
metadata: z.lazy(() => AccountBalanceResponseMetadata$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
blockIdentifier: "block_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AccountBalanceResponse$ {
/** @deprecated use `AccountBalanceResponse$inboundSchema` instead. */
export const inboundSchema = AccountBalanceResponse$inboundSchema;
/** @deprecated use `AccountBalanceResponse$outboundSchema` instead. */
export const outboundSchema = AccountBalanceResponse$outboundSchema;
/** @deprecated use `AccountBalanceResponse$Outbound` instead. */
export type Outbound = AccountBalanceResponse$Outbound;
}
export function accountBalanceResponseToJSON(
accountBalanceResponse: AccountBalanceResponse,
): string {
return JSON.stringify(
AccountBalanceResponse$outboundSchema.parse(accountBalanceResponse),
);
}
export function accountBalanceResponseFromJSON(
jsonString: string,
): SafeParseResult<AccountBalanceResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountBalanceResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountBalanceResponse' from JSON`,
);
}