/* * 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 { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type Block = { index: number; ledgerCanisterId: string; blockHash: string; blockPhash?: string | undefined; transactionHash: string; kind: string; amount: number; fromOwner?: string | undefined; fromSubaccount?: string | undefined; fromAccount?: string | undefined; toOwner?: string | undefined; toSubaccount?: string | undefined; toAccount?: string | undefined; memo: string; fee?: number | undefined; timestamp?: string | undefined; updatedAt: string; }; /** @internal */ export const Block$inboundSchema: z.ZodType = z .object({ index: z.number().int(), ledger_canister_id: z.string(), block_hash: z.string(), block_phash: z.string().optional(), transaction_hash: z.string(), kind: z.string(), amount: z.number().int(), from_owner: z.string().optional(), from_subaccount: z.string().optional(), from_account: z.string().optional(), to_owner: z.string().optional(), to_subaccount: z.string().optional(), to_account: z.string().optional(), memo: z.string(), fee: z.number().int().optional(), timestamp: z.string().optional(), updated_at: z.string(), }).transform((v) => { return remap$(v, { "ledger_canister_id": "ledgerCanisterId", "block_hash": "blockHash", "block_phash": "blockPhash", "transaction_hash": "transactionHash", "from_owner": "fromOwner", "from_subaccount": "fromSubaccount", "from_account": "fromAccount", "to_owner": "toOwner", "to_subaccount": "toSubaccount", "to_account": "toAccount", "updated_at": "updatedAt", }); }); /** @internal */ export type Block$Outbound = { index: number; ledger_canister_id: string; block_hash: string; block_phash?: string | undefined; transaction_hash: string; kind: string; amount: number; from_owner?: string | undefined; from_subaccount?: string | undefined; from_account?: string | undefined; to_owner?: string | undefined; to_subaccount?: string | undefined; to_account?: string | undefined; memo: string; fee?: number | undefined; timestamp?: string | undefined; updated_at: string; }; /** @internal */ export const Block$outboundSchema: z.ZodType< Block$Outbound, z.ZodTypeDef, Block > = z.object({ index: z.number().int(), ledgerCanisterId: z.string(), blockHash: z.string(), blockPhash: z.string().optional(), transactionHash: z.string(), kind: z.string(), amount: z.number().int(), fromOwner: z.string().optional(), fromSubaccount: z.string().optional(), fromAccount: z.string().optional(), toOwner: z.string().optional(), toSubaccount: z.string().optional(), toAccount: z.string().optional(), memo: z.string(), fee: z.number().int().optional(), timestamp: z.string().optional(), updatedAt: z.string(), }).transform((v) => { return remap$(v, { ledgerCanisterId: "ledger_canister_id", blockHash: "block_hash", blockPhash: "block_phash", transactionHash: "transaction_hash", fromOwner: "from_owner", fromSubaccount: "from_subaccount", fromAccount: "from_account", toOwner: "to_owner", toSubaccount: "to_subaccount", toAccount: "to_account", updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Block$ { /** @deprecated use `Block$inboundSchema` instead. */ export const inboundSchema = Block$inboundSchema; /** @deprecated use `Block$outboundSchema` instead. */ export const outboundSchema = Block$outboundSchema; /** @deprecated use `Block$Outbound` instead. */ export type Outbound = Block$Outbound; } export function blockToJSON(block: Block): string { return JSON.stringify(Block$outboundSchema.parse(block)); } export function blockFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Block$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Block' from JSON`, ); }