import type { SolanaAddress } from '@funkit/api-base'; import type { CheckoutTokenTransferConfig, DynamicTargetAssetCandidate, FiatRoutingOverrides, MinDepositTarget } from '@funkit/connect-core'; import type { ReactNode } from 'react'; import type { Address } from 'viem'; import type { SupportedToken, TokenChainFilter } from '../transfer/supportedTokens'; import type { FunkitFlowError } from './flowError'; export type { DynamicTargetAssetCandidate } from '@funkit/connect-core'; /** * Host-supplied payment identifiers and optional deposit cap, forwarded to * `POST /eoa` alongside the SDK's `checkoutId`. Invalid identifiers are * dropped with a warning; an invalid supplied cap rejects `beginDeposit`. */ export interface DepositClientMetadata { /** Must be a non-empty string. */ externalUserId?: string; /** Must be a string representation of a positive, safe integer. */ clientTransactionId?: `${number}`; /** * Maximum gross deposit in the resolved target chain/asset's base units, before fees; * separate from `initialAmount` (fiat input) and not guaranteed net credit. * Positive integer string, at most 30 digits, without leading zeros. */ authorizedAmountBaseUnit?: string; } /** * Destination chain/asset for a deposit, plus the customer `getMinDepositUSD` * closure that feeds the transfer minimums and the fiat (Swapped) buy floor. * The web `FunkitCheckoutConfig` satisfies this structurally. Named once here so * the flow provider and `useFops` share exactly one shape. */ export type DepositCheckoutConfig = DepositTargetConfig & Pick; /** * The connect-core transfer config with `targetAsset` also taking a Solana * mint: the fiat rail buys it directly, so hosts targeting Solana USDC pass the * base58 mint without a cast. Widened here rather than in connect-core so web's * EVM-only typing is untouched; RN hooks narrow back at the core boundary. */ export type DepositTargetConfig = Omit & { targetAsset: Address | SolanaAddress; }; /** * Resolve the active target-asset candidate from a list + routing id (RN-only). * * This is intentionally NOT a drop-in equivalent of web's * `getDefaultDynamicTargetAsset` (`packages/connect/src/utils/assets.ts`), which * takes the whole checkout config (synthesizing a guaranteed fallback) and adds * a `tokenSymbol === targetAssetTicker` match step. The RN flow only needs to * pick a candidate from the configured list: * * 1. Match `dynamicRoutingId` * 2. Match `isDefault` * 3. First candidate */ export declare function getDefaultDynamicTargetAsset(candidates: DynamicTargetAssetCandidate[] | undefined, dynamicRoutingId: string | undefined): DynamicTargetAssetCandidate | undefined; /** * @deprecated Unused — the deposit chain is chosen on the Select chain screen, * which lists every curated chain individually instead of network segments. */ export interface ChainOption { /** Stable id used for selection (e.g. the network id). */ id: string; label: string; /** * CDN chain keys for the segment glyph: one → a single logo, several → a 2×2 * cluster (e.g. the EVM group). */ iconKeys?: string[]; /** * Numeric chain id this network selects — drives which generated deposit * address + QR (EVM / Solana / Bitcoin / Tron) the flow shows. */ chainId?: number; } /** * The V2 amount-first deposit surface (Fun Mobile MVP). Present on * {@link DepositFlowConfig.amountEntry}, it opens the flow on the full-screen * amount screen instead of the Add money method list. Without {@link fiat}, * the payment rail behind the submit is not wired — submission lands on * {@link DepositFlowCallbacks.onSubmitAmount}. */ export interface DepositAmountEntryConfig { /** * @deprecated The rail quotes its own fee. Fee charged on the entered * amount, as a fraction (0.005 = 0.5%), shown only while no rail is wired. */ feeRate?: number; /** * @deprecated The SDK names the rail from {@link DepositFlowConfig.methods}. * Overrides how the fee-details drawer names it. */ methodName?: string; /** Header title; defaults to the SDK's own translated "Deposit". */ title?: string; /** * @deprecated The SDK words the submit from {@link DepositFlowConfig.methods} * in the user's locale. Overrides that label. */ submitLabel?: string; /** Quick-amount presets in whole dollars; defaults to 10/20/50/100. */ quickAmountsUsd?: string[]; /** * Hard input cap in dollars. With {@link fiat} configured it defaults to * $2,500; without `fiat` an omitted cap means no limit. */ limitUsd?: string; /** * Smallest amount the source will take, in dollars. Below it the CTA names * the floor instead of submitting; omit when the source defines none. */ minLimitUsd?: string; /** Brand glyph beside the title; the title stands alone without one. */ brandIcon?: ReactNode; /** * @deprecated The SDK draws the rail's mark from * {@link DepositFlowConfig.methods}. Overrides the fee line's badge. */ methodBadge?: ReactNode; /** Host account context in the header (label + balance + avatar). */ accountContext?: DepositAccountContext; /** * @deprecated Name the rail in {@link DepositFlowConfig.methods}; it delivers * to `checkoutConfig`, so the destination is not repeated here. */ fiat?: FiatRailConfig; } /** * The host's balance beside the title. The SDK formats it like every other * amount on the screen, so give it the number, not the words. */ export type DepositAccountContext = { label: string; avatar?: ReactNode; /** Links back out to the host context (e.g. the profile page). */ onPress?: () => void; } & ({ /** Decimal string in dollars, e.g. `"366715.12"`. */ amountUsd: string; value?: undefined; } | { /** @deprecated Pass {@link amountUsd}; the SDK formats it. */ value: string; amountUsd?: undefined; }); /** * A fixed fiat amount to prefill the deposit amount screen with — the value * the user pays, not a crypto amount. Distinct from any provider's approved * output amount (e.g. an authorized USDC amount elsewhere in a payment * provider's contract): this is fiat input, never derived from or converted * into that figure. */ export interface DepositInitialAmount { /** Decimal string, e.g. `"150.00"`. Must be a valid positive amount. */ value: string; /** ISO 4217 currency code, e.g. `"USD"`. */ currency: string; } /** What a fiat method needs beyond its type to be quoted. */ export interface FiatDepositMethodOptions { /** Ticker the onramp quote API uses for the checkout target. */ fiatTargetAssetTicker?: string; /** * Test tooling for exercising one provider integration at a time. Sandbox * and local backends only; production refuses a quote carrying it. The * prefix keeps it out of a host's tab-completion for that reason. */ unstable_routingOverrides?: FiatRoutingOverrides; } /** A way to fund the deposit. */ export type DepositMethod = ({ type: 'apple_pay'; } & FiatDepositMethodOptions) | ({ type: 'card'; } & FiatDepositMethodOptions) | { type: 'crypto'; }; /** * The fiat onramp rail behind the V2 amount screen. Derived from * {@link DepositFlowConfig.methods} and the active checkout chain; hosts no * longer write one directly. */ export interface FiatRailConfig { /** The rail quoted and fired, e.g. `apple_pay`. */ paymentMethod: string; /** Token the fiat buys, as its ticker (e.g. `USDC`) — quotes are priced in it. */ cryptoCurrencyCode: string; /** * That same token's address, or SPL mint. What decides where an order * delivers: matching `checkoutConfig.targetAsset` leaves nothing to swap, so * the crypto goes to the recipient and no deposit address is minted. */ cryptoCurrencyAddress: string; /** Destination chain id used for the quote. */ chainId: string; /** See {@link FiatDepositMethodOptions.unstable_routingOverrides}. */ unstable_routingOverrides?: FiatRoutingOverrides; } /** * Data the managed deposit flow renders. * * The deposit address + QR are now SDK-generated: given `checkoutConfig` (the * destination chain/asset) and the identity on ``, the flow * resolves the Universal Deposit Address and EIP-681 QR URI via the transfer * hooks. `depositAddress`/`qrCode` remain as optional host overrides / fallbacks * (shown while generation is loading or when no identity is configured). * * TODO(connect-rn): source the remaining lists internally too — payment methods * from config/Statsig, supported tokens from `@funkit/api-base` — so * `beginDeposit` ultimately takes just a target, like the web `beginCheckout`. */ export interface DepositFlowConfig { /** * What the deposit offers. Order is a hint; Fun ranks per user. With * `amountEntry`, the first fiat entry is the rail behind submit and needs a * ticker for the active checkout target. * Without `amountEntry`, a list omitting `crypto` drops the Crypto row from * Add money. Omitted, the V1 method list stands. */ methods?: DepositMethod[]; /** * Opt into the V2 amount-first deposit surface: the flow opens on the * full-screen amount screen instead of the Add money method list. */ amountEntry?: DepositAmountEntryConfig; /** * Candidate target assets for the "Deposit to" row, following web's * `FunkitCheckoutConfig.dynamicTargetAssetCandidates`. The active candidate is * resolved via {@link getDefaultDynamicTargetAsset} using `dynamicRoutingId`. * Omit to hide the deposit-target row. */ dynamicTargetAssetCandidates?: DynamicTargetAssetCandidate[]; /** * Destination of the deposit (target chain + asset). Drives deposit-address * generation via the transfer hooks, and its optional `getMinDepositUSD` * feeds the per-chain transfer minimums and the fiat (Swapped) sell floor. * The web `FunkitCheckoutConfig` satisfies this structurally. */ checkoutConfig?: DepositCheckoutConfig; /** * @deprecated Ignored — the user picks the source chain on the Select chain * screen, which drives the generated address and QR type. */ sourceChain?: string; /** Dynamic-routing id used to resolve UDA params for `checkoutConfig`. */ dynamicRoutingId?: string; /** * Deposit address fallback/override. The flow prefers the SDK-generated * address; this is shown while it loads or when generation is unavailable * (no identity). Display formatting (truncation) is applied by the flow. */ depositAddress?: string; /** * @deprecated Ignored — the supported-tokens screen lists the curated * tokens the SDK resolves itself. */ supportedTokens?: SupportedToken[]; tokenChainFilters?: TokenChainFilter[]; /** * QR code override. By default the flow renders the generated EIP-681 URI * with `react-native-qrcode-svg`; supply a node only to override. */ qrCode?: ReactNode; /** See {@link DepositClientMetadata}. */ clientMetadata?: DepositClientMetadata; /** * Prefills the amount screen with a fixed fiat value + currency. Validated * in `beginDeposit` — an invalid value is dropped (logged, not thrown). */ initialAmount?: DepositInitialAmount; /** * Locks the prefilled amount for the life of the attempt: typing, * quick-amount taps, back navigation, and remounts all leave it unchanged. * On Transfer Crypto, shows a periodically refreshed source-token estimate of * {@link initialAmount} with asset selection followed by its supported networks. * This display estimate does not authorize or enforce a backend deposit cap. * Requires {@link initialAmount} — validated in `beginDeposit` and dropped * (logged, not thrown) if set without it. */ lockAmount?: boolean; } /** Lifecycle callbacks passed to `useFunkitCheckout`. */ export interface DepositFlowCallbacks { onOpen?: () => void; onClose?: () => void; onCheckoutBlocked?: () => void; /** * The deposit is on its way and the SDK is finished with it: the flow has * closed and its confirmation is up. `orderId` is the provider's; `method` * is the rail's {@link DepositMethod} type. Fires only where the rail pays * the recipient directly — an order the backend still has to sweep has not * arrived, so nothing is claimed for it. */ onDepositSubmitted?: (orderId: string, method: DepositMethod['type']) => void; /** * The deposit ended short of an order, or the order failed. `cancelled` * is the user leaving; see {@link FunkitFlowError} for the rest. */ onDepositError?: (error: FunkitFlowError) => void; /** * @deprecated Name a rail in {@link DepositFlowConfig.methods}; it owns the * submit. Fires only while no rail is wired. */ onSubmitAmount?: (amountUsd: string) => void; } //# sourceMappingURL=depositFlowConfig.d.ts.map