/* * 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 Transaction = { index: number; ledgerCanisterId: string; kind: string; amount: string; fromOwner?: string | undefined; fromSubaccount?: string | undefined; fromAccount?: string | undefined; toOwner?: string | undefined; toSubaccount?: string | undefined; toAccount?: string | undefined; spenderOwner?: string | undefined; spenderSubaccount?: string | undefined; spenderAccount?: string | undefined; memo?: string | undefined; fee?: string | undefined; expectedAllowance?: string | undefined; expiresAt?: string | undefined; createdAtTime?: string | undefined; timestamp?: string | undefined; feeCollectorBlock?: number | undefined; updatedAt: Date; }; /** @internal */ export const Transaction$inboundSchema: z.ZodType< Transaction, z.ZodTypeDef, unknown > = z.object({ index: z.number().int(), ledger_canister_id: z.string(), kind: z.string(), amount: z.string(), 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(), spender_owner: z.string().optional(), spender_subaccount: z.string().optional(), spender_account: z.string().optional(), memo: z.string().optional(), fee: z.string().optional(), expected_allowance: z.string().optional(), expires_at: z.string().optional(), created_at_time: z.string().optional(), timestamp: z.string().optional(), fee_collector_block: z.number().int().optional(), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "ledger_canister_id": "ledgerCanisterId", "from_owner": "fromOwner", "from_subaccount": "fromSubaccount", "from_account": "fromAccount", "to_owner": "toOwner", "to_subaccount": "toSubaccount", "to_account": "toAccount", "spender_owner": "spenderOwner", "spender_subaccount": "spenderSubaccount", "spender_account": "spenderAccount", "expected_allowance": "expectedAllowance", "expires_at": "expiresAt", "created_at_time": "createdAtTime", "fee_collector_block": "feeCollectorBlock", "updated_at": "updatedAt", }); }); /** @internal */ export type Transaction$Outbound = { index: number; ledger_canister_id: string; kind: string; amount: string; from_owner?: string | undefined; from_subaccount?: string | undefined; from_account?: string | undefined; to_owner?: string | undefined; to_subaccount?: string | undefined; to_account?: string | undefined; spender_owner?: string | undefined; spender_subaccount?: string | undefined; spender_account?: string | undefined; memo?: string | undefined; fee?: string | undefined; expected_allowance?: string | undefined; expires_at?: string | undefined; created_at_time?: string | undefined; timestamp?: string | undefined; fee_collector_block?: number | undefined; updated_at: string; }; /** @internal */ export const Transaction$outboundSchema: z.ZodType< Transaction$Outbound, z.ZodTypeDef, Transaction > = z.object({ index: z.number().int(), ledgerCanisterId: z.string(), kind: z.string(), amount: z.string(), fromOwner: z.string().optional(), fromSubaccount: z.string().optional(), fromAccount: z.string().optional(), toOwner: z.string().optional(), toSubaccount: z.string().optional(), toAccount: z.string().optional(), spenderOwner: z.string().optional(), spenderSubaccount: z.string().optional(), spenderAccount: z.string().optional(), memo: z.string().optional(), fee: z.string().optional(), expectedAllowance: z.string().optional(), expiresAt: z.string().optional(), createdAtTime: z.string().optional(), timestamp: z.string().optional(), feeCollectorBlock: z.number().int().optional(), updatedAt: z.date().transform(v => v.toISOString()), }).transform((v) => { return remap$(v, { ledgerCanisterId: "ledger_canister_id", fromOwner: "from_owner", fromSubaccount: "from_subaccount", fromAccount: "from_account", toOwner: "to_owner", toSubaccount: "to_subaccount", toAccount: "to_account", spenderOwner: "spender_owner", spenderSubaccount: "spender_subaccount", spenderAccount: "spender_account", expectedAllowance: "expected_allowance", expiresAt: "expires_at", createdAtTime: "created_at_time", feeCollectorBlock: "fee_collector_block", 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 Transaction$ { /** @deprecated use `Transaction$inboundSchema` instead. */ export const inboundSchema = Transaction$inboundSchema; /** @deprecated use `Transaction$outboundSchema` instead. */ export const outboundSchema = Transaction$outboundSchema; /** @deprecated use `Transaction$Outbound` instead. */ export type Outbound = Transaction$Outbound; } export function transactionToJSON(transaction: Transaction): string { return JSON.stringify(Transaction$outboundSchema.parse(transaction)); } export function transactionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Transaction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Transaction' from JSON`, ); }