/*
* 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 { SDKValidationError } from "./errors/sdkvalidationerror.js";
import {
Transaction,
Transaction$inboundSchema,
Transaction$Outbound,
Transaction$outboundSchema,
} from "./transaction.js";
/**
* BlockTransaction contains a populated Transaction and the BlockIdentifier that contains it.
*/
export type BlockTransaction = {
/**
* The block_identifier uniquely identifies a block in a particular network.
*/
blockIdentifier: BlockIdentifier;
/**
* Transactions contain an array of Operations that are attributable to the same TransactionIdentifier.
*/
transaction: Transaction;
};
/** @internal */
export const BlockTransaction$inboundSchema: z.ZodType<
BlockTransaction,
z.ZodTypeDef,
unknown
> = z.object({
block_identifier: BlockIdentifier$inboundSchema,
transaction: Transaction$inboundSchema,
}).transform((v) => {
return remap$(v, {
"block_identifier": "blockIdentifier",
});
});
/** @internal */
export type BlockTransaction$Outbound = {
block_identifier: BlockIdentifier$Outbound;
transaction: Transaction$Outbound;
};
/** @internal */
export const BlockTransaction$outboundSchema: z.ZodType<
BlockTransaction$Outbound,
z.ZodTypeDef,
BlockTransaction
> = z.object({
blockIdentifier: BlockIdentifier$outboundSchema,
transaction: Transaction$outboundSchema,
}).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 BlockTransaction$ {
/** @deprecated use `BlockTransaction$inboundSchema` instead. */
export const inboundSchema = BlockTransaction$inboundSchema;
/** @deprecated use `BlockTransaction$outboundSchema` instead. */
export const outboundSchema = BlockTransaction$outboundSchema;
/** @deprecated use `BlockTransaction$Outbound` instead. */
export type Outbound = BlockTransaction$Outbound;
}
export function blockTransactionToJSON(
blockTransaction: BlockTransaction,
): string {
return JSON.stringify(
BlockTransaction$outboundSchema.parse(blockTransaction),
);
}
export function blockTransactionFromJSON(
jsonString: string,
): SafeParseResult<BlockTransaction, SDKValidationError> {
return safeParse(
jsonString,
(x) => BlockTransaction$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'BlockTransaction' from JSON`,
);
}