import { z } from "zod"; import type { FiatCurrency } from "../currency/currencies"; import type { zPayOrderMetadata, zPayOrderSettings } from "../schemas/pay-order"; import { ChainId, PaymentRail, PayOrderMode, PayOrderStatus, StepKind } from "./enums"; export type PayOrder = { id: string; organization_id: string; mode: PayOrderMode; status: PayOrderStatus; metadata?: ParsedPayOrderMetadata; settings?: ParsedPayOrderSettings; fulfillment: FulfillmentData; payment?: PaymentData; hosted_url: string; created_at: Date; updated_at: Date; }; type MetadataExtraFields = Record; type SettingsExtraFields = Record; export type ParsedPayOrderMetadata = z.output & MetadataExtraFields; export type PayOrderMetadata = z.infer; export type ParsedPayOrderSettings = z.output & SettingsExtraFields; export type PayOrderSettings = z.infer & SettingsExtraFields; export type OrganizationSettings = ParsedPayOrderSettings; export interface Currency extends CurrencyBase { id: string; name: string; ticker: string; decimals: number; image_uri?: string; price_usd?: number; } export interface CurrencyBase { chain_id: ChainId; address?: string; } export declare function currencyID(currency: CurrencyBase): string; export interface CurrencyWithAmount extends Currency { currency_amount: CurrencyAmount; } export interface QuoteWithCurrency extends CurrencyWithAmount { total: CurrencyAmount; base: CurrencyAmount; fees?: FeeBreakdown; gas?: CurrencyAmount; } export interface CurrencyWithBalance extends CurrencyWithAmount { owner?: string; balance: CurrencyAmount; } export interface CurrencyAmount { ui_amount: number; ui_amount_display: string; raw_amount: BigIntStr; value_usd: number; } export interface FeeBreakdown { total_fee: CurrencyAmount; protocol_fee?: CurrencyAmount; custom_fee?: CurrencyAmount; } export interface FeeCurrencyBreakdown { currency: Currency; total_fee: CurrencyAmount; protocol_fee?: CurrencyAmount; custom_fee?: CurrencyAmount; } export type OnrampDestinationCurrency = "btc" | "eth" | "pol" | "sol" | "usdc"; export type OnrampDestinationNetwork = "base" | "ethereum" | "optimism" | "polygon" | "solana"; export interface OnrampQuote { source_currency?: string; source_amount?: string; source_total_amount?: string; destination_currency: OnrampDestinationCurrency; destination_network: OnrampDestinationNetwork; destination_amount: string; exchange_rate?: string; network_fee_amount?: string; transaction_fee_amount?: string; } export type FiatQuoteData = OnrampQuote; export interface OnrampPaymentData { session_id: string; stripe_publishable_key: string; client_secret: string; status: string; hosted_url?: string; source_currency?: string; destination_currency: OnrampDestinationCurrency; destination_network: OnrampDestinationNetwork; destination_amount: string; wallet_address: string; quote?: OnrampQuote; } export type FiatPaymentData = OnrampPaymentData; export type SerializedSuiTransaction = unknown; export type SerializedSolanaTransaction = unknown; export interface CryptoPaymentData { evm?: EVMPaymentData; bitcoin?: BitcoinPaymentData; solana?: SolanaPaymentData; sui?: SuiPaymentData; } export interface SuiPaymentData { transaction: SerializedSuiTransaction; } export interface SolanaPaymentData { transaction: SerializedSolanaTransaction; } export interface BitcoinPaymentData { psbt: string; } export interface EVMPaymentData { from: string; to: string; data: string; value: string; chainId: ChainId; maxFeePerGas?: string; maxPriorityFeePerGas?: string; } export type TokenAmount = { ui_amount: number; raw_amount: BigIntStr; }; export type FiatAmount = { amount: number; unit: FiatCurrency; }; export type RequestData = { currency: Currency | null; amount: { token?: TokenAmount; fiat?: FiatAmount; }; receiving_address: string | null; }; export type FulfillmentData = { asset?: Currency; fiat?: FiatCurrency; amount: CurrencyAmount; rate_usd?: string; receiving_address?: string; custom_fee_bps?: number; swap?: SwapContext; }; export type SwapContext = { requested_destination_currency?: CurrencyBase; requested_source_currency?: CurrencyBase; }; export type DepositStepData = { deposit_address: string; currency: CurrencyBase; amount: BigIntStr; }; export type PaymentDataBase = { payment_rail?: PaymentRail; src: QuoteWithCurrency; dst: CurrencyWithAmount; receiving_address: string; refund_address?: string; steps: PaymentStep[]; expires_at: string; }; export type PaymentData = PaymentDataBase & { source_tx_hash?: string; destination_tx_hash?: string; refund_tx_hash?: string; fee_tx_hash?: string; }; export type PaymentStep = { rail: PaymentRail; kind: StepKind; data: DepositStepData | CryptoPaymentData | FiatPaymentData; }; export type PaymentStepData = { crypto?: CryptoPaymentData; fiat?: FiatPaymentData; }; export type BigIntStr = `${bigint}`; export {};