/*
* 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 {
NetworkIdentifier,
NetworkIdentifier$inboundSchema,
NetworkIdentifier$Outbound,
NetworkIdentifier$outboundSchema,
} from "./networkidentifier.js";
import {
TransactionIdentifier,
TransactionIdentifier$inboundSchema,
TransactionIdentifier$Outbound,
TransactionIdentifier$outboundSchema,
} from "./transactionidentifier.js";
/**
* A BlockTransactionRequest is used to fetch a Transaction included in a block that is not returned in a BlockResponse.
*/
export type BlockTransactionRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* The block_identifier uniquely identifies a block in a particular network.
*/
blockIdentifier: BlockIdentifier;
/**
* The transaction_identifier uniquely identifies a transaction in a particular network and block or in the mempool.
*/
transactionIdentifier: TransactionIdentifier;
};
/** @internal */
export const BlockTransactionRequest$inboundSchema: z.ZodType<
BlockTransactionRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
block_identifier: BlockIdentifier$inboundSchema,
transaction_identifier: TransactionIdentifier$inboundSchema,
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
"block_identifier": "blockIdentifier",
"transaction_identifier": "transactionIdentifier",
});
});
/** @internal */
export type BlockTransactionRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
block_identifier: BlockIdentifier$Outbound;
transaction_identifier: TransactionIdentifier$Outbound;
};
/** @internal */
export const BlockTransactionRequest$outboundSchema: z.ZodType<
BlockTransactionRequest$Outbound,
z.ZodTypeDef,
BlockTransactionRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
blockIdentifier: BlockIdentifier$outboundSchema,
transactionIdentifier: TransactionIdentifier$outboundSchema,
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
blockIdentifier: "block_identifier",
transactionIdentifier: "transaction_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace BlockTransactionRequest$ {
/** @deprecated use `BlockTransactionRequest$inboundSchema` instead. */
export const inboundSchema = BlockTransactionRequest$inboundSchema;
/** @deprecated use `BlockTransactionRequest$outboundSchema` instead. */
export const outboundSchema = BlockTransactionRequest$outboundSchema;
/** @deprecated use `BlockTransactionRequest$Outbound` instead. */
export type Outbound = BlockTransactionRequest$Outbound;
}
export function blockTransactionRequestToJSON(
blockTransactionRequest: BlockTransactionRequest,
): string {
return JSON.stringify(
BlockTransactionRequest$outboundSchema.parse(blockTransactionRequest),
);
}
export function blockTransactionRequestFromJSON(
jsonString: string,
): SafeParseResult<BlockTransactionRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => BlockTransactionRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'BlockTransactionRequest' from JSON`,
);
}