/*
* 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 {
BlockIdentifier,
BlockIdentifier$inboundSchema,
BlockIdentifier$Outbound,
BlockIdentifier$outboundSchema,
} from "./blockidentifier.js";
import {
Coin,
Coin$inboundSchema,
Coin$Outbound,
Coin$outboundSchema,
} from "./coin.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 AccountCoinsResponseMetadata = {};
/**
* AccountCoinsResponse is returned on the /account/coins endpoint and includes all unspent Coins owned by an AccountIdentifier.
*/
export type AccountCoinsResponse = {
/**
* The block_identifier uniquely identifies a block in a particular network.
*/
blockIdentifier: BlockIdentifier;
/**
* If a blockchain is UTXO-based, all unspent Coins owned by an account_identifier should be returned alongside the balance. It is highly recommended to populate this field so that users of the Rosetta API implementation don't need to maintain their own indexer to track their UTXOs.
*/
coins: Array<Coin>;
/**
* 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?: AccountCoinsResponseMetadata | undefined;
};
/** @internal */
export const AccountCoinsResponseMetadata$inboundSchema: z.ZodType<
AccountCoinsResponseMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type AccountCoinsResponseMetadata$Outbound = {};
/** @internal */
export const AccountCoinsResponseMetadata$outboundSchema: z.ZodType<
AccountCoinsResponseMetadata$Outbound,
z.ZodTypeDef,
AccountCoinsResponseMetadata
> = 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 AccountCoinsResponseMetadata$ {
/** @deprecated use `AccountCoinsResponseMetadata$inboundSchema` instead. */
export const inboundSchema = AccountCoinsResponseMetadata$inboundSchema;
/** @deprecated use `AccountCoinsResponseMetadata$outboundSchema` instead. */
export const outboundSchema = AccountCoinsResponseMetadata$outboundSchema;
/** @deprecated use `AccountCoinsResponseMetadata$Outbound` instead. */
export type Outbound = AccountCoinsResponseMetadata$Outbound;
}
export function accountCoinsResponseMetadataToJSON(
accountCoinsResponseMetadata: AccountCoinsResponseMetadata,
): string {
return JSON.stringify(
AccountCoinsResponseMetadata$outboundSchema.parse(
accountCoinsResponseMetadata,
),
);
}
export function accountCoinsResponseMetadataFromJSON(
jsonString: string,
): SafeParseResult<AccountCoinsResponseMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountCoinsResponseMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountCoinsResponseMetadata' from JSON`,
);
}
/** @internal */
export const AccountCoinsResponse$inboundSchema: z.ZodType<
AccountCoinsResponse,
z.ZodTypeDef,
unknown
> = z.object({
block_identifier: BlockIdentifier$inboundSchema,
coins: z.array(Coin$inboundSchema),
metadata: z.lazy(() => AccountCoinsResponseMetadata$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"block_identifier": "blockIdentifier",
});
});
/** @internal */
export type AccountCoinsResponse$Outbound = {
block_identifier: BlockIdentifier$Outbound;
coins: Array<Coin$Outbound>;
metadata?: AccountCoinsResponseMetadata$Outbound | undefined;
};
/** @internal */
export const AccountCoinsResponse$outboundSchema: z.ZodType<
AccountCoinsResponse$Outbound,
z.ZodTypeDef,
AccountCoinsResponse
> = z.object({
blockIdentifier: BlockIdentifier$outboundSchema,
coins: z.array(Coin$outboundSchema),
metadata: z.lazy(() => AccountCoinsResponseMetadata$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 AccountCoinsResponse$ {
/** @deprecated use `AccountCoinsResponse$inboundSchema` instead. */
export const inboundSchema = AccountCoinsResponse$inboundSchema;
/** @deprecated use `AccountCoinsResponse$outboundSchema` instead. */
export const outboundSchema = AccountCoinsResponse$outboundSchema;
/** @deprecated use `AccountCoinsResponse$Outbound` instead. */
export type Outbound = AccountCoinsResponse$Outbound;
}
export function accountCoinsResponseToJSON(
accountCoinsResponse: AccountCoinsResponse,
): string {
return JSON.stringify(
AccountCoinsResponse$outboundSchema.parse(accountCoinsResponse),
);
}
export function accountCoinsResponseFromJSON(
jsonString: string,
): SafeParseResult<AccountCoinsResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountCoinsResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountCoinsResponse' from JSON`,
);
}