/*
* 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 { SDKValidationError } from "./errors/sdkvalidationerror.js";
/**
* The transaction_identifier uniquely identifies a transaction in a particular network and block or in the mempool.
*/
export type TransactionIdentifier = {
/**
* Any transactions that are attributable only to a block (ex: a block event) should use the hash of the block as the identifier. This should be normalized according to the case specified in the transaction_hash_case in network options.
*/
hash: string;
};
/** @internal */
export const TransactionIdentifier$inboundSchema: z.ZodType<
TransactionIdentifier,
z.ZodTypeDef,
unknown
> = z.object({
hash: z.string(),
});
/** @internal */
export type TransactionIdentifier$Outbound = {
hash: string;
};
/** @internal */
export const TransactionIdentifier$outboundSchema: z.ZodType<
TransactionIdentifier$Outbound,
z.ZodTypeDef,
TransactionIdentifier
> = z.object({
hash: z.string(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace TransactionIdentifier$ {
/** @deprecated use `TransactionIdentifier$inboundSchema` instead. */
export const inboundSchema = TransactionIdentifier$inboundSchema;
/** @deprecated use `TransactionIdentifier$outboundSchema` instead. */
export const outboundSchema = TransactionIdentifier$outboundSchema;
/** @deprecated use `TransactionIdentifier$Outbound` instead. */
export type Outbound = TransactionIdentifier$Outbound;
}
export function transactionIdentifierToJSON(
transactionIdentifier: TransactionIdentifier,
): string {
return JSON.stringify(
TransactionIdentifier$outboundSchema.parse(transactionIdentifier),
);
}
export function transactionIdentifierFromJSON(
jsonString: string,
): SafeParseResult<TransactionIdentifier, SDKValidationError> {
return safeParse(
jsonString,
(x) => TransactionIdentifier$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'TransactionIdentifier' from JSON`,
);
}