/*
* 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 {
BlockTransaction,
BlockTransaction$inboundSchema,
BlockTransaction$Outbound,
BlockTransaction$outboundSchema,
} from "./blocktransaction.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* SearchTransactionsResponse contains an ordered collection of BlockTransactions that match the query in SearchTransactionsRequest. These BlockTransactions are sorted from most recent block to oldest block.
*/
export type SearchTransactionsResponse = {
/**
* transactions is an array of BlockTransactions sorted by most recent BlockIdentifier (meaning that transactions in recent blocks appear first). If there are many transactions for a particular search, transactions may not contain all matching transactions. It is up to the caller to paginate these transactions using the max_block field.
*/
transactions: Array<BlockTransaction>;
/**
* total_count is the number of results for a given search. Callers typically use this value to concurrently fetch results by offset or to display a virtual page number associated with results.
*/
totalCount: number;
/**
* next_offset is the next offset to use when paginating through transaction results. If this field is not populated, there are no more transactions to query.
*/
nextOffset?: number | undefined;
};
/** @internal */
export const SearchTransactionsResponse$inboundSchema: z.ZodType<
SearchTransactionsResponse,
z.ZodTypeDef,
unknown
> = z.object({
transactions: z.array(BlockTransaction$inboundSchema),
total_count: z.number().int(),
next_offset: z.number().int().optional(),
}).transform((v) => {
return remap$(v, {
"total_count": "totalCount",
"next_offset": "nextOffset",
});
});
/** @internal */
export type SearchTransactionsResponse$Outbound = {
transactions: Array<BlockTransaction$Outbound>;
total_count: number;
next_offset?: number | undefined;
};
/** @internal */
export const SearchTransactionsResponse$outboundSchema: z.ZodType<
SearchTransactionsResponse$Outbound,
z.ZodTypeDef,
SearchTransactionsResponse
> = z.object({
transactions: z.array(BlockTransaction$outboundSchema),
totalCount: z.number().int(),
nextOffset: z.number().int().optional(),
}).transform((v) => {
return remap$(v, {
totalCount: "total_count",
nextOffset: "next_offset",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace SearchTransactionsResponse$ {
/** @deprecated use `SearchTransactionsResponse$inboundSchema` instead. */
export const inboundSchema = SearchTransactionsResponse$inboundSchema;
/** @deprecated use `SearchTransactionsResponse$outboundSchema` instead. */
export const outboundSchema = SearchTransactionsResponse$outboundSchema;
/** @deprecated use `SearchTransactionsResponse$Outbound` instead. */
export type Outbound = SearchTransactionsResponse$Outbound;
}
export function searchTransactionsResponseToJSON(
searchTransactionsResponse: SearchTransactionsResponse,
): string {
return JSON.stringify(
SearchTransactionsResponse$outboundSchema.parse(searchTransactionsResponse),
);
}
export function searchTransactionsResponseFromJSON(
jsonString: string,
): SafeParseResult<SearchTransactionsResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => SearchTransactionsResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SearchTransactionsResponse' from JSON`,
);
}