import * as z from 'zod/mini'; import type * as Db from '../../db/Db.js'; import * as FundingTransfers from '../../db/tables/fundingTransfers.js'; import type * as Webhooks from '../Webhooks.js'; import * as Action from './Action.js'; /** Public funding transfer statuses, in the order documented by the API. */ export declare const statuses: readonly ['awaiting-source', 'processing', 'refunding', 'completed', 'refunded', 'action-required', 'expired']; /** Lifecycle status of a funding transfer. */ export type Status = (typeof statuses)[number]; /** Statuses that never change again after verified chain evidence. */ export declare const terminalStatuses: readonly ["completed", "expired", "refunded"]; /** Funding methods a caller can select at creation. */ export declare const methods: readonly ['depositAddress', 'transaction']; /** Funding method selected at creation. */ export type Method = (typeof methods)[number]; /** Amount modes a caller can select at creation. */ export declare const modes: readonly ['exactDestination', 'exactSource']; /** Amount mode selected at creation. */ export type Mode = (typeof modes)[number]; /** Customer-safe codes explaining an `action-required` or refund outcome. */ export declare const statusReasonCodes: readonly ['destination_amount_below_minimum', 'destination_recovered', 'manual_recovery_required', 'refund_failed', 'source_amount_above_maximum', 'source_amount_below_minimum', 'source_chain_mismatch', 'source_token_mismatch']; /** Stable customer-safe status reason code. */ export type StatusReasonCode = (typeof statusReasonCodes)[number]; /** Returns whether a status is terminal. */ export declare function isTerminal(status: Status): boolean; /** Returns whether the lifecycle allows moving from one status to another. */ export declare function canTransition(from: Status, to: Status): boolean; /** Generates a funding transfer id (`ftr_…`, lexically time-ordered). */ export declare function generateId(now?: Date): string; /** Zod schemas owned by the funding transfer resource. */ export declare namespace schema { /** Funding transfer lifecycle status. */ const Status: z.ZodMiniEnum<{ "action-required": "action-required"; "awaiting-source": "awaiting-source"; completed: "completed"; expired: "expired"; processing: "processing"; refunded: "refunded"; refunding: "refunding"; }>; /** Customer-safe explanation of a status that needs context. */ const StatusReason: z.ZodMiniObject<{ code: z.ZodMiniEnum<{ destination_amount_below_minimum: "destination_amount_below_minimum"; destination_recovered: "destination_recovered"; manual_recovery_required: "manual_recovery_required"; refund_failed: "refund_failed"; source_amount_above_maximum: "source_amount_above_maximum"; source_amount_below_minimum: "source_amount_below_minimum"; source_chain_mismatch: "source_chain_mismatch"; source_token_mismatch: "source_token_mismatch"; }>; message: z.ZodMiniString; }, z.core.$strip>; /** Funding method selected at creation. */ const Method: z.ZodMiniEnum<{ depositAddress: "depositAddress"; transaction: "transaction"; }>; /** Amount mode selected at creation. */ const Mode: z.ZodMiniEnum<{ exactDestination: "exactDestination"; exactSource: "exactSource"; }>; /** One fee applied to the transfer. */ const Fee: z.ZodMiniObject<{ amount: z.ZodMiniObject<{ baseUnits: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; side: z.ZodMiniEnum<{ destination: "destination"; source: "source"; }>; token: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; type: z.ZodMiniEnum<{ provider: "provider"; }>; }, z.core.$strip>; /** Freshness and validity window of the selected quote. */ const Quote: z.ZodMiniObject<{ expiresAt: z.ZodMiniISODateTime; sampledAt: z.ZodMiniISODateTime; }, z.core.$strip>; /** * The stored public snapshot: every transfer field except lifecycle columns * (`id`, `status`, `statusReason`, `version`, `createdAt`, `updatedAt`), * which live in typed columns and merge in at serialization. */ const Snapshot: z.ZodMiniObject<{ destinationAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationAmountMin: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; destinationToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; destinationTransactionHashes: z.ZodMiniOptional>>; fees: z.ZodMiniArray; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; side: z.ZodMiniEnum<{ destination: "destination"; source: "source"; }>; token: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; type: z.ZodMiniEnum<{ provider: "provider"; }>; }, z.core.$strip>>; method: z.ZodMiniEnum<{ depositAddress: "depositAddress"; transaction: "transaction"; }>; mode: z.ZodMiniEnum<{ exactDestination: "exactDestination"; exactSource: "exactSource"; }>; provider: z.ZodMiniObject<{ id: z.ZodMiniString; name: z.ZodMiniString; }, z.core.$strip>; quote: z.ZodMiniObject<{ expiresAt: z.ZodMiniISODateTime; sampledAt: z.ZodMiniISODateTime; }, z.core.$strip>; recipient: z.ZodMiniString; refundAddress: z.ZodMiniOptional>; refundAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; refundTransactionHashes: z.ZodMiniOptional>>; sender: z.ZodMiniOptional>; sourceAmount: z.ZodMiniObject<{ baseUnits: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; sourceAmountMax: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; sourceChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; sourceToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; sourceTransactionHashes: z.ZodMiniOptional>>; }, z.core.$strip>; /** A funding transfer as returned by reads. Reads never include `action`. */ const FundingTransfer: z.ZodMiniObject<{ createdAt: z.ZodMiniISODateTime; destinationAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationAmountMin: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; destinationToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; destinationTransactionHashes: z.ZodMiniOptional>>; fees: z.ZodMiniArray; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; side: z.ZodMiniEnum<{ destination: "destination"; source: "source"; }>; token: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; type: z.ZodMiniEnum<{ provider: "provider"; }>; }, z.core.$strip>>; id: z.ZodMiniString; method: z.ZodMiniEnum<{ depositAddress: "depositAddress"; transaction: "transaction"; }>; mode: z.ZodMiniEnum<{ exactDestination: "exactDestination"; exactSource: "exactSource"; }>; provider: z.ZodMiniObject<{ id: z.ZodMiniString; name: z.ZodMiniString; }, z.core.$strip>; quote: z.ZodMiniObject<{ expiresAt: z.ZodMiniISODateTime; sampledAt: z.ZodMiniISODateTime; }, z.core.$strip>; recipient: z.ZodMiniString; refundAddress: z.ZodMiniOptional>; refundAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; refundTransactionHashes: z.ZodMiniOptional>>; sender: z.ZodMiniOptional>; sourceAmount: z.ZodMiniObject<{ baseUnits: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; sourceAmountMax: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; sourceChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; sourceToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; sourceTransactionHashes: z.ZodMiniOptional>>; status: z.ZodMiniEnum<{ "action-required": "action-required"; "awaiting-source": "awaiting-source"; completed: "completed"; expired: "expired"; processing: "processing"; refunded: "refunded"; refunding: "refunding"; }>; statusReason: z.ZodMiniOptional; message: z.ZodMiniString; }, z.core.$strip>>; updatedAt: z.ZodMiniISODateTime; version: z.ZodMiniNumber; }, z.core.$strip>; /** A created funding transfer: the read shape plus the executable action. */ const CreatedFundingTransfer: z.ZodMiniObject<{ createdAt: z.ZodMiniISODateTime; destinationAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationAmountMin: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; destinationToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; destinationTransactionHashes: z.ZodMiniOptional>>; fees: z.ZodMiniArray; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; side: z.ZodMiniEnum<{ destination: "destination"; source: "source"; }>; token: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; type: z.ZodMiniEnum<{ provider: "provider"; }>; }, z.core.$strip>>; id: z.ZodMiniString; method: z.ZodMiniEnum<{ depositAddress: "depositAddress"; transaction: "transaction"; }>; mode: z.ZodMiniEnum<{ exactDestination: "exactDestination"; exactSource: "exactSource"; }>; provider: z.ZodMiniObject<{ id: z.ZodMiniString; name: z.ZodMiniString; }, z.core.$strip>; quote: z.ZodMiniObject<{ expiresAt: z.ZodMiniISODateTime; sampledAt: z.ZodMiniISODateTime; }, z.core.$strip>; recipient: z.ZodMiniString; refundAddress: z.ZodMiniOptional>; refundAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; refundTransactionHashes: z.ZodMiniOptional>>; sender: z.ZodMiniOptional>; sourceAmount: z.ZodMiniObject<{ baseUnits: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>; sourceAmountMax: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; sourceChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; sourceToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; sourceTransactionHashes: z.ZodMiniOptional>>; status: z.ZodMiniEnum<{ "action-required": "action-required"; "awaiting-source": "awaiting-source"; completed: "completed"; expired: "expired"; processing: "processing"; refunded: "refunded"; refunding: "refunding"; }>; statusReason: z.ZodMiniOptional; message: z.ZodMiniString; }, z.core.$strip>>; updatedAt: z.ZodMiniISODateTime; version: z.ZodMiniNumber; action: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{ calls: z.ZodMiniArray; to: z.ZodMiniString; value: z.ZodMiniString; }, z.core.$strip>>; type: z.ZodMiniLiteral<"evm:calls">; }, z.core.$strip>], "type">; }, z.core.$strip>; /** Request body accepted by funding transfer creation. */ const CreateRequest: z.ZodMiniObject<{ amount: z.ZodMiniString; destinationToken: z.ZodMiniString; mode: z.ZodMiniEnum<{ exactDestination: "exactDestination"; exactSource: "exactSource"; }>; provider: z.ZodMiniOptional>; recipient: z.ZodMiniString; sender: z.ZodMiniString; slippageBps: z.ZodMiniOptional>; sourceChain: z.ZodMiniString; sourceToken: z.ZodMiniString; }, z.core.$strict>; } /** Stored public snapshot of a funding transfer (see {@link schema.Snapshot}). */ export type Snapshot = z.output; /** Customer-safe status reason (see {@link schema.StatusReason}). */ export type StatusReason = z.output; /** A funding transfer as returned by reads (see {@link schema.FundingTransfer}). */ export type Public = z.output; /** A created funding transfer (see {@link schema.CreatedFundingTransfer}). */ export type Created = z.output; /** A validated creation request (see {@link schema.CreateRequest}). */ export type CreateRequest = z.output; /** What an associated transaction reference evidences. */ export declare const transactionRoles: readonly ['destination', 'refund', 'source']; /** Role of a verified transaction reference on a transfer. */ export type TransactionRole = (typeof transactionRoles)[number]; /** Bounded private provider state retained for transfer reconciliation. */ export type ProviderState = Record; type Staged = { /** Funding transfer record committed with the webhook obligations. */ record: FundingTransfers.Record; /** Webhook queue references committed with the transfer. */ references: Webhooks.QueueReference[]; }; /** * Creates a durable funding transfer: the row plus its version-1 event commit * in one transaction, so every stored version has an immutable public record. */ export declare function create(db: Db.Db, input: create.Input): Promise; /** * Creates the transfer row and its version-1 event inside the caller's * transaction, for writes that must commit atomically with sibling state * (idempotency completion). */ export declare function createIn(tx: Db.Db, input: create.Input): Promise; export declare namespace createIn { /** Created transfer and webhook queue references committed with it. */ type Result = Staged; } export declare namespace create { /** Fields required to create a funding transfer. */ type Input = { /** API key that created the transfer. */ apiKeyId: string; /** Key environment the transfer belongs to. */ environment: 'production' | 'sandbox'; /** Transfer id override for deterministic tests. */ id?: string | undefined; /** Owning organization id (`org_…`). */ orgId: string; /** Attributed project id, when the creating key is project-attributed. */ projectId?: string | undefined; /** Private provider correlation retained for reconciliation. */ providerState?: ProviderState | undefined; /** The public snapshot captured from the selected quote. */ snapshot: Snapshot; }; } /** Atomically assigns one verified source transaction and starts reconciliation. */ export declare function registerSourceTransaction(db: Db.Db, options: registerSourceTransaction.Options): Promise; export declare namespace registerSourceTransaction { /** Verified source evidence and private provider correlation. */ type Options = { /** Source chain CAIP-2 id. */ chainId: string; /** Transfer id (`ftr_…`). */ id: string; /** Private state added for destination reconciliation. */ providerState: ProviderState; /** Verified source transaction hash. */ transactionHash: string; }; /** Source transaction registration outcome. */ type Result = { current: FundingTransfers.Record; type: 'conflict'; } | { current: FundingTransfers.Record; type: 'invalid'; } | (Staged & { type: 'registered'; }) | { record: FundingTransfers.Record; type: 'replayed'; } | { type: 'not_found'; }; } /** Atomically removes invalidated source evidence and accepts a replacement. */ export declare function reopenSourceTransaction(db: Db.Db, options: reopenSourceTransaction.Options): Promise; export declare namespace reopenSourceTransaction { /** Source evidence to remove after it disappears from the canonical chain. */ type Options = { /** Source chain CAIP-2 id. */ chainId: string; /** Transfer id (`ftr_…`). */ id: string; /** Private provider state retained while awaiting replacement evidence. */ providerState: ProviderState; /** Invalidated source transaction hash. */ transactionHash: string; }; /** Source transaction reopening outcome. */ type Result = { current: FundingTransfers.Record; type: 'invalid'; } | (Staged & { type: 'reopened'; }) | { type: 'not_found'; }; } /** Atomically records a verified destination transaction and completes a transfer. */ export declare function complete(db: Db.Db, options: complete.Options): Promise; export declare namespace complete { /** Verified destination evidence for one processing transfer. */ type Options = { /** Destination chain CAIP-2 id. */ chainId: string; /** Exact verified destination amount. */ destinationAmount: NonNullable; /** Transfer id (`ftr_…`). */ id: string; /** Verified destination transaction hash. */ transactionHash: string; }; /** Transfer completion outcome. */ type Result = { current: FundingTransfers.Record; type: 'invalid'; } | (Staged & { type: 'completed'; }) | { record: FundingTransfers.Record; type: 'replayed'; } | { type: 'not_found'; }; } /** * Applies a version-guarded material change: a status transition, a snapshot * update, or both. The row update and its immutable event commit in one * transaction; a stale `expectedVersion` or disallowed transition applies * nothing, so concurrent observations cannot overwrite newer evidence. */ export declare function transition(db: Db.Db, options: transition.Options): Promise; export declare namespace transition { /** Fields describing a material change to apply. */ type Options = { /** The version the change was computed against. */ expectedVersion: number; /** Transfer id (`ftr_…`). */ id: string; /** Replacement private provider state; omitted keeps the stored value. */ providerState?: ProviderState | null | undefined; /** Replacement public snapshot; omitted keeps the stored snapshot. */ snapshot?: Snapshot | undefined; /** New status; omitted keeps the current status (snapshot-only change). */ status?: Status | undefined; /** Customer-safe reason attached to the new status. */ statusReason?: StatusReason | undefined; }; /** Outcome of a guarded transition. */ type Result = (Staged & { type: 'applied'; }) | { current: FundingTransfers.Record; type: 'invalid'; } | { current: FundingTransfers.Record; type: 'stale'; } | { type: 'not_found'; }; } /** Serializes a created row with its one-time executable action. */ export declare function toCreated(record: FundingTransfers.Record, action: Action.Action): Created; /** Serializes a stored row to the public read shape. Never includes actions. */ export declare function toPublic(record: FundingTransfers.Record): Public; export {}; //# sourceMappingURL=Transfer.d.ts.map