import type { TFunction } from 'i18next'; import type { ErrorNotification } from '../../components/FunNotification/FunNotification'; import { type ConvertAssetListStatus } from './assets'; import { type ConvertBalanceState, type ConvertBalances } from './balances'; import { type ConvertAmount } from './inputAmount'; import type { ConvertQuote } from './quote'; import type { ConvertDraft, ConvertSnapshot, ConvertSubmission } from './reducer'; import type { ConvertRecipientSelection } from './recipient'; import { type ConvertActionButton, type ConvertPhase, type ConvertScreenIssue, getConvertReceiveAmounts } from './screen'; import type { ConvertSourceWalletSelection } from './sourceWallet'; import type { ConvertResolvedAsset } from './types'; /** The live reads the draft is checked against, before any quote. */ export interface ConvertLiveInputs { status: ConvertAssetListStatus; assets: ConvertResolvedAsset[]; balances: ConvertBalances | undefined; isBalancesFetching: boolean; sourceWallet: ConvertSourceWalletSelection | undefined; isSourceWalletFetching: boolean; recipient: ConvertRecipientSelection | undefined; isRecipientFetching: boolean; /** The source's Max; `null` while unknown. */ maxBaseUnits: bigint | null; } export interface ConvertLiveQuote { /** The amount last sent to the quote, after the typing pause. */ amountBaseUnits: bigint | undefined; quote: ConvertQuote | undefined; isLoading: boolean; isFetching: boolean; isError: boolean; error: Error | null; refreshesAtMs: number | undefined; } export interface ConvertLive extends ConvertLiveInputs { quote: ConvertLiveQuote; } /** The draft read against live data: what's picked, the amount, and what to quote. */ export interface ConvertDraftReading { sourceAsset: ConvertResolvedAsset | undefined; destinationAsset: ConvertResolvedAsset | undefined; sourceBalance: ConvertBalanceState | undefined; amount: ConvertAmount; amountIssue: ConvertScreenIssue | undefined; /** `undefined` while the amount has an issue, so nothing is quoted. */ quoteAmountBaseUnits: bigint | undefined; userAddress: string | undefined; recipientAddress: string | undefined; } /** What Retry asks again for; `balances` reloads the asset list too, if that failed. */ export type ConvertRetryTarget = 'balances' | 'sourceWallet' | 'recipient' | 'quote'; /** Everything the Convert screens render. */ export interface ConvertView { status: ConvertAssetListStatus; assets: ConvertResolvedAsset[]; balances: ConvertBalances | undefined; sourceAsset: ConvertResolvedAsset | undefined; destinationAsset: ConvertResolvedAsset | undefined; /** The first balance read is out, so there's no source to show yet. */ isAwaitingBalances: boolean; /** Token units; `undefined` while unknown, so it never reads as 0. */ sourceTokenBalance: number | undefined; destinationTokenBalance: number | undefined; amount: ConvertAmount; /** The source's Max; `null` while unknown or locked. */ maxBaseUnits: bigint | null; /** Shows the percentage presets: the source has a balance to take a share of. */ canSelectPercent: boolean; /** Shows the unit switch; off without a price to convert with. Locked, the widget disables it. */ canToggleUnit: boolean; quote: ConvertQuote | undefined; isQuoteLoading: boolean; /** `undefined` hides the countdown: no quote, or one being converted. */ refreshesAtMs: number | undefined; receiveAmounts: ReturnType; notification: ErrorNotification | undefined; actionButton: ConvertActionButton; phase: ConvertPhase | undefined; /** Nothing on screen can change from the submission until it settles, and after `untrackable`. */ isLocked: boolean; /** Nothing to convert from; the source card offers Deposit instead. */ isDepositRequired: boolean; retryTargets: ConvertRetryTarget[]; } /** * The draft against live data. The provider quotes `quoteAmountBaseUnits` * with it, and {@link deriveConvertView} reads it again for the screen. */ export declare function readConvertDraft({ draft, live, }: { draft: ConvertDraft; live: ConvertLiveInputs; }): ConvertDraftReading; /** * What a press converts, frozen for the locked view. `undefined` without * everything signing needs; Convert is disabled then anyway. */ export declare function getConvertSnapshot({ reading, sourceWallet, amountBaseUnits, quote, }: { reading: ConvertDraftReading; sourceWallet: ConvertSourceWalletSelection | undefined; /** The amount the quote was requested for, after the typing pause. */ amountBaseUnits: bigint | undefined; /** The quote on screen, unless it's already been signed. */ quote: ConvertQuote | undefined; }): ConvertSnapshot | undefined; /** * Everything the Convert screens render. While a submission is locked it reads * the snapshot; otherwise the draft against live data, with a failed * submission's issue until the next edit ends it. */ export declare function deriveConvertView({ draft, live, submission, t, }: { draft: ConvertDraft; live: ConvertLive; submission: ConvertSubmission | undefined; t: TFunction; }): ConvertView;