UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

46 lines (45 loc) 2.4 kB
import type { CustomWithdrawalConfig, FunkitWithdrawalConfig, MultiMethodWithdrawalConfig, WalletWithdrawalConfig } from '../providers/FunkitCheckoutContext'; /** * Evaluates the integrator's `withdrawalSourceTokenBalance` callback to a safe * numeric string. Returns `'0'` (with a warn) for missing/empty/NaN/negative * values. Shared by the withdrawal amount screen and the Swapped cash cap. */ export declare function safeEvaluateWithdrawalSourceTokenBalance(fn: (() => string | number) | undefined): string; /** * Type guard to check if withdrawal config uses wallet-based flow */ export declare function isWalletWithdrawalConfig(config: FunkitWithdrawalConfig): config is WalletWithdrawalConfig; /** * True when a wallet withdrawal would be a no-op self-transfer that Relay * rejects with a generic `QuoteError`: same chain, same token, and recipient == * the source wallet. Cross-chain or cross-token withdrawals to your own address * are valid and return false. Non-wallet configs and empty recipients are false. */ export declare function isNoOpSelfWithdrawal({ config, recipientAddress, selectedChainId, destinationTokenAddress, }: { config: FunkitWithdrawalConfig; recipientAddress: string; selectedChainId: number | undefined; destinationTokenAddress: string | undefined; }): boolean; /** * Type guard to check if withdrawal config uses custom callback flow */ export declare function isCustomWithdrawalConfig(config: FunkitWithdrawalConfig): config is CustomWithdrawalConfig; /** * Type guard to check if withdrawal config wraps multiple methods the user * must pick between (e.g. "Fast" vs "Secure"). */ export declare function isMultiMethodWithdrawalConfig(config: FunkitWithdrawalConfig): config is MultiMethodWithdrawalConfig; /** * Converts a human-readable token amount to base units using string arithmetic * to avoid floating-point precision loss. * * The precision is preserved because the original user-input string is passed * directly — it is never coerced to a JS Number/float first. * * e.g. passing the already-truncated float string '8.967660226710157' would * still produce 8967660226710157000n (lossy). * But keeping the original full-precision string '8.967660226710157512' * produces 8967660226710157512n (exact). */ export declare function toWithdrawalAmountBaseUnit(amount: string, decimals: number): bigint;