@funkit/connect-rn 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +81 -0
- package/dist/{chunk-BNWA4HKO.js → chunk-VDKAH5Y5.js} +327 -111
- package/dist/chunk-VDKAH5Y5.js.map +7 -0
- package/dist/clients/lighter/index.d.ts +2 -0
- package/dist/clients/lighter/index.d.ts.map +1 -1
- package/dist/clients/lighter/useLighterSecureWithdrawal.d.ts +42 -0
- package/dist/clients/lighter/useLighterSecureWithdrawal.d.ts.map +1 -0
- package/dist/clients/lighter.js +126 -1
- package/dist/clients/lighter.js.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3388 -1693
- package/dist/index.js.map +4 -4
- package/dist/src/components/AmountDisplay.d.ts +18 -0
- package/dist/src/components/AmountDisplay.d.ts.map +1 -0
- package/dist/src/components/AssetGrid.d.ts +39 -0
- package/dist/src/components/AssetGrid.d.ts.map +1 -0
- package/dist/src/components/NumPad.d.ts +14 -0
- package/dist/src/components/NumPad.d.ts.map +1 -0
- package/dist/src/components/PillButton.d.ts +25 -0
- package/dist/src/components/PillButton.d.ts.map +1 -0
- package/dist/src/components/ReceiveAmountSummary.d.ts +27 -0
- package/dist/src/components/ReceiveAmountSummary.d.ts.map +1 -0
- package/dist/src/components/ReceiveAsRow.d.ts +14 -0
- package/dist/src/components/ReceiveAsRow.d.ts.map +1 -0
- package/dist/src/components/SearchInput.d.ts +15 -0
- package/dist/src/components/SearchInput.d.ts.map +1 -0
- package/dist/src/components/SelectableAssetRow.d.ts +14 -0
- package/dist/src/components/SelectableAssetRow.d.ts.map +1 -0
- package/dist/src/components/SheetContent.d.ts +25 -0
- package/dist/src/components/SheetContent.d.ts.map +1 -0
- package/dist/src/components/SkeletonBar.d.ts +10 -0
- package/dist/src/components/SkeletonBar.d.ts.map +1 -0
- package/dist/src/components/TopBar.d.ts +12 -0
- package/dist/src/components/TopBar.d.ts.map +1 -0
- package/dist/src/components/WalletAddressInput.d.ts +35 -0
- package/dist/src/components/WalletAddressInput.d.ts.map +1 -0
- package/dist/src/components/WithdrawSourceCard.d.ts +23 -0
- package/dist/src/components/WithdrawSourceCard.d.ts.map +1 -0
- package/dist/src/flow/DepositFlowContent.d.ts.map +1 -1
- package/dist/src/flow/FlowSheet.d.ts +3 -1
- package/dist/src/flow/FlowSheet.d.ts.map +1 -1
- package/dist/src/flow/FunkitFlowProvider.d.ts +11 -3
- package/dist/src/flow/FunkitFlowProvider.d.ts.map +1 -1
- package/dist/src/flow/WithdrawalFlowContent.d.ts +4 -1
- package/dist/src/flow/WithdrawalFlowContent.d.ts.map +1 -1
- package/dist/src/haptics/HapticsContext.d.ts +21 -0
- package/dist/src/haptics/HapticsContext.d.ts.map +1 -0
- package/dist/src/haptics/hapticTap.d.ts +13 -0
- package/dist/src/haptics/hapticTap.d.ts.map +1 -0
- package/dist/src/hooks/useIsStablecoin.d.ts +3 -0
- package/dist/src/hooks/useIsStablecoin.d.ts.map +1 -0
- package/dist/src/hooks/useNestedSheet.d.ts +17 -0
- package/dist/src/hooks/useNestedSheet.d.ts.map +1 -0
- package/dist/src/hooks/useNestedSheetHeight.d.ts +7 -0
- package/dist/src/hooks/useNestedSheetHeight.d.ts.map +1 -0
- package/dist/src/hooks/usePulse.d.ts +7 -0
- package/dist/src/hooks/usePulse.d.ts.map +1 -0
- package/dist/src/icons/FigmaSystemIcons.d.ts +2 -0
- package/dist/src/icons/FigmaSystemIcons.d.ts.map +1 -1
- package/dist/src/icons/FunIcon.d.ts +5 -2
- package/dist/src/icons/FunIcon.d.ts.map +1 -1
- package/dist/src/icons/TokenChainIcon.d.ts +6 -1
- package/dist/src/icons/TokenChainIcon.d.ts.map +1 -1
- package/dist/src/providers/FunkitProvider.d.ts +17 -2
- package/dist/src/providers/FunkitProvider.d.ts.map +1 -1
- package/dist/src/screens/SelectChainScreen.d.ts.map +1 -1
- package/dist/src/screens/SelectMethodScreen.d.ts.map +1 -1
- package/dist/src/screens/SelectReceiveTokenAndChainScreen.d.ts +18 -0
- package/dist/src/screens/SelectReceiveTokenAndChainScreen.d.ts.map +1 -0
- package/dist/src/screens/SelectReceiveTokenScreen.d.ts +13 -0
- package/dist/src/screens/SelectReceiveTokenScreen.d.ts.map +1 -0
- package/dist/src/screens/SelectSourceTokenScreen.d.ts.map +1 -1
- package/dist/src/screens/TransactionBreakdownScreen.d.ts +12 -0
- package/dist/src/screens/TransactionBreakdownScreen.d.ts.map +1 -0
- package/dist/src/screens/WithdrawAddressScreen.d.ts +48 -0
- package/dist/src/screens/WithdrawAddressScreen.d.ts.map +1 -0
- package/dist/src/screens/WithdrawAmountScreen.d.ts +53 -0
- package/dist/src/screens/WithdrawAmountScreen.d.ts.map +1 -0
- package/dist/src/screens/WithdrawCompleteScreen.d.ts +15 -4
- package/dist/src/screens/WithdrawCompleteScreen.d.ts.map +1 -1
- package/dist/src/screens/WithdrawCryptoComplete.d.ts +8 -1
- package/dist/src/screens/WithdrawCryptoComplete.d.ts.map +1 -1
- package/dist/src/screens/WithdrawCryptoSteps.d.ts +39 -0
- package/dist/src/screens/WithdrawCryptoSteps.d.ts.map +1 -0
- package/dist/src/transfer/clipboard.d.ts +22 -0
- package/dist/src/transfer/clipboard.d.ts.map +1 -1
- package/dist/src/utils/amountGlyphs.d.ts +15 -0
- package/dist/src/utils/amountGlyphs.d.ts.map +1 -0
- package/dist/src/utils/assetGrid.d.ts +20 -0
- package/dist/src/utils/assetGrid.d.ts.map +1 -0
- package/dist/src/utils/executionErrorMessage.d.ts +13 -0
- package/dist/src/utils/executionErrorMessage.d.ts.map +1 -0
- package/dist/src/utils/formatAmount.d.ts +21 -0
- package/dist/src/utils/formatAmount.d.ts.map +1 -0
- package/dist/src/utils/motion.d.ts +3 -0
- package/dist/src/utils/motion.d.ts.map +1 -0
- package/dist/src/utils/numpadInput.d.ts +14 -0
- package/dist/src/utils/numpadInput.d.ts.map +1 -0
- package/dist/src/utils/safeArea.d.ts +3 -0
- package/dist/src/utils/safeArea.d.ts.map +1 -0
- package/dist/src/withdrawal/receiveDestination.d.ts +11 -0
- package/dist/src/withdrawal/receiveDestination.d.ts.map +1 -0
- package/dist/src/withdrawal/sourceToken.d.ts +4 -11
- package/dist/src/withdrawal/sourceToken.d.ts.map +1 -1
- package/dist/src/withdrawal/useCryptoWithdrawalExecution.d.ts +6 -0
- package/dist/src/withdrawal/useCryptoWithdrawalExecution.d.ts.map +1 -1
- package/dist/src/withdrawal/useCryptoWithdrawalForm.d.ts +89 -0
- package/dist/src/withdrawal/useCryptoWithdrawalForm.d.ts.map +1 -0
- package/dist/src/withdrawal/useCryptoWithdrawalSubmit.d.ts +37 -0
- package/dist/src/withdrawal/useCryptoWithdrawalSubmit.d.ts.map +1 -0
- package/dist/src/withdrawal/useCryptoWithdrawalValidation.d.ts.map +1 -1
- package/dist/src/withdrawal/useSourceTokenUsdPrice.d.ts +20 -0
- package/dist/src/withdrawal/useSourceTokenUsdPrice.d.ts.map +1 -0
- package/dist/src/withdrawal/useWithdrawalAmountInput.d.ts +38 -0
- package/dist/src/withdrawal/useWithdrawalAmountInput.d.ts.map +1 -0
- package/dist/src/withdrawal/useWithdrawalRisk.d.ts +2 -2
- package/dist/src/withdrawal/useWithdrawalRisk.d.ts.map +1 -1
- package/dist/src/withdrawal/useWithdrawalStatus.d.ts +6 -2
- package/dist/src/withdrawal/useWithdrawalStatus.d.ts.map +1 -1
- package/dist/src/withdrawal/validation.d.ts +23 -5
- package/dist/src/withdrawal/validation.d.ts.map +1 -1
- package/package.json +8 -3
- package/dist/chunk-BNWA4HKO.js.map +0 -7
- package/dist/src/components/AmountInput.d.ts +0 -40
- package/dist/src/components/AmountInput.d.ts.map +0 -1
- package/dist/src/components/WithdrawFeeSummary.d.ts +0 -23
- package/dist/src/components/WithdrawFeeSummary.d.ts.map +0 -1
- package/dist/src/screens/SelectDestinationScreen.d.ts +0 -19
- package/dist/src/screens/SelectDestinationScreen.d.ts.map +0 -1
- package/dist/src/screens/WithdrawCryptoCta.d.ts +0 -20
- package/dist/src/screens/WithdrawCryptoCta.d.ts.map +0 -1
- package/dist/src/screens/WithdrawCryptoForm.d.ts +0 -28
- package/dist/src/screens/WithdrawCryptoForm.d.ts.map +0 -1
- package/dist/src/screens/WithdrawCryptoScreen.d.ts +0 -17
- package/dist/src/screens/WithdrawCryptoScreen.d.ts.map +0 -1
- package/dist/src/withdrawal/flatFee.d.ts +0 -9
- package/dist/src/withdrawal/flatFee.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../clients/lighter/useLighterWithdrawalMethods.ts", "../../clients/lighter/lighterWithdrawalConfig.ts", "../../clients/lighter/lighterFastWithdrawal.ts", "../../clients/lighter/useLighterUnstakedFee.ts", "../../clients/lighter/useLighterWithdrawal.ts"],
|
|
4
|
-
"sourcesContent": ["import { useLighterAccountsQuery } from '@funkit/connect-core'\nimport { getLighterWithdrawalDelay } from '@funkit/connect-core/clients/lighter'\nimport { useQuery } from '@tanstack/react-query'\nimport type { TFunction } from 'i18next'\nimport { useEffect, useRef } from 'react'\n\nimport { logger } from '../../src/logging/logger'\nimport { useFunkitTranslation } from '../../src/providers/FunkitI18nProvider'\nimport {\n LIGHTER_FAST_METHOD_ID,\n LIGHTER_SECURE_METHOD_ID,\n type LighterWithdrawalFlowConfig,\n} from './lighterWithdrawalConfig'\n\n/** One row on the withdrawal method screen, before icons are attached. */\nexport interface LighterWithdrawalMethod {\n id: typeof LIGHTER_FAST_METHOD_ID | typeof LIGHTER_SECURE_METHOD_ID\n title: string\n subtitle: string\n}\n\nexport interface UseLighterWithdrawalMethodsResult {\n /** Fast then Secure, in web's order. Empty until the account resolves. */\n methods: LighterWithdrawalMethod[]\n /**\n * The user's Lighter L2 main-account index. Both rails address the account\n * by index, so neither can run before this resolves.\n */\n accountIndex: string | undefined\n /** Unified accounts hold one USDC balance \u2014 no spot/perps split. */\n isUnifiedTradingMode: boolean\n /** The account lookup is in flight; rows are expected to be empty. */\n isLoading: boolean\n}\n\nconst SECONDS_PER_MINUTE = 60\nconst MINUTES_PER_HOUR = 60\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR\n\n/**\n * Formats Lighter's live L2\u2192L1 delay for the Secure row (e.g. \"1 h 50 min\").\n * - Reproduces web's `formatSecondsToReadableForm(seconds, false, true)` output\n * for every input, including its two oddities: a sub-minute delay reads in\n * seconds, and exactly one hour reads \"60 min\". The two SDKs quote the same\n * bridge, so they must not disagree on the wait.\n * - Rounds up otherwise: an estimate must not promise finality early.\n * - One literal `t` key per shape \u2014 never a computed key.\n */\nfunction formatDelay(t: TFunction, seconds: number): string {\n const normalized = Math.ceil(seconds)\n if (normalized === 1) {\n return t('withdrawLighter.delaySecond')\n }\n if (normalized <= SECONDS_PER_MINUTE) {\n return t('withdrawLighter.delaySeconds', { seconds: normalized })\n }\n // Round to minutes first: rounding the remainder alone can yield \"1 h 60 min\".\n const minutes = Math.ceil(normalized / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR\n const hours = Math.ceil(\n (normalized - minutes * SECONDS_PER_MINUTE) / SECONDS_PER_HOUR,\n )\n if (hours === 1 && minutes === 0) {\n return t('withdrawLighter.delayMinutes', { minutes: MINUTES_PER_HOUR })\n }\n if (hours > 0 && minutes > 0) {\n return t('withdrawLighter.delayHoursMinutes', { hours, minutes })\n }\n if (hours > 0) {\n return t('withdrawLighter.delayHours', { hours })\n }\n return t('withdrawLighter.delayMinutes', { minutes })\n}\n\n/**\n * Secure-withdrawal delay as display copy. Shown live because it tracks L2\u2192L1\n * batch cadence; `undefined` until it loads.\n */\nfunction useLighterSecureDelayText(enabled: boolean): string | undefined {\n const { t } = useFunkitTranslation()\n const { data } = useQuery({\n queryKey: ['lighterWithdrawalDelay'],\n queryFn: getLighterWithdrawalDelay,\n // This hook runs for every withdrawal flow, Lighter or not \u2014 a host with no\n // Lighter config must never reach Lighter's API.\n enabled,\n staleTime: 60_000,\n retry: 2,\n })\n const seconds = data?.seconds\n if (seconds === undefined || !Number.isFinite(seconds) || seconds <= 0) {\n return undefined\n }\n return formatDelay(t, seconds)\n}\n\ntype RailOutcome = 'not_configured' | 'loading' | 'offered' | 'no_account_index'\n\n/**\n * Whether Lighter's rails replace the generic crypto row, and why not when they\n * don't.\n * - `isFetched`, not `isLoading`: the latter is false on the first render,\n * before the query starts, which would record a premature \"no account\".\n */\nfunction resolveRailOutcome({\n isConfigured,\n isFetched,\n hasAccountIndex,\n}: {\n isConfigured: boolean\n isFetched: boolean\n hasAccountIndex: boolean\n}): RailOutcome {\n if (!isConfigured) return 'not_configured'\n if (!isFetched) return 'loading'\n if (!hasAccountIndex) return 'no_account_index'\n return 'offered'\n}\n\n/**\n * The Fast / Secure rows plus the account state both rails need. Port of the\n * row-building half of web's `useLighterWithdrawalConfig`.\n *\n * Pass `undefined` when the host configured no Lighter: the inner hooks still\n * run (Rules of Hooks) but every query stays disabled.\n */\nexport function useLighterWithdrawalMethods(\n config: LighterWithdrawalFlowConfig | undefined,\n): UseLighterWithdrawalMethodsResult {\n const { t } = useFunkitTranslation()\n const { mainAccountIndex, isUnifiedTradingMode, isLoading, isFetched } =\n useLighterAccountsQuery({ address: config?.l1Address })\n const secureDelayText = useLighterSecureDelayText(!!config)\n\n // Lighter addresses accounts by a numeric index; anything else means the\n // lookup returned something unusable and neither rail can address the user.\n const accountIndex =\n mainAccountIndex && /^\\d+$/.test(mainAccountIndex)\n ? mainAccountIndex\n : undefined\n\n const outcome = resolveRailOutcome({\n isConfigured: !!config,\n isFetched,\n hasAccountIndex: !!accountIndex,\n })\n // Rail-availability decision point, recorded once per outcome so a re-render\n // or a background refetch doesn't re-emit the same one.\n const loggedOutcome = useRef<RailOutcome | undefined>(undefined)\n useEffect(() => {\n if (outcome === 'loading' || loggedOutcome.current === outcome) return\n loggedOutcome.current = outcome\n if (outcome === 'not_configured') return\n const payload = {\n outcome,\n isUnifiedTradingMode,\n hasAccountIndex: !!accountIndex,\n }\n if (outcome === 'no_account_index') {\n // Recovered, but the user loses Lighter's rails for this session \u2014 that\n // is a visible capability change, so it belongs above INFO.\n logger.warn('lighter:withdrawal:rails', payload)\n return\n }\n logger.info('lighter:withdrawal:rails', payload)\n }, [outcome, isUnifiedTradingMode, accountIndex])\n\n const methods: LighterWithdrawalMethod[] =\n config && accountIndex\n ? [\n {\n id: LIGHTER_FAST_METHOD_ID,\n title: t('withdrawLighter.methodFast'),\n subtitle: isUnifiedTradingMode\n ? t('withdrawLighter.fastDisclaimerUnified')\n : t('withdrawLighter.fastDisclaimer'),\n },\n {\n id: LIGHTER_SECURE_METHOD_ID,\n title: t('withdrawLighter.methodSecure'),\n subtitle: t('withdrawLighter.secureDisclaimer', {\n // Until the live value loads, show the localized \"60+ minutes\"\n // historical estimate. The \"+\" lives in the per-locale fallback\n // string so it doesn't bleed into live values, which are exact.\n delay:\n secureDelayText ?? t('withdrawLighter.secureFallbackDelay'),\n }),\n },\n ]\n : []\n\n return {\n methods,\n accountIndex,\n isUnifiedTradingMode,\n isLoading: !!config && isLoading,\n }\n}\n", "import type { LighterRouteType } from '@funkit/connect-core/clients/lighter'\nimport type { LighterSigner } from '@funkit/connect-core/clients/lighter'\nimport type { Address } from 'viem'\n\nimport type { WithdrawalSourceTokenParams } from '../../src/flow/withdrawalFlowConfig'\n\n/** Stable ids for the two rails \u2014 used for row identity, routing and logs. */\nexport const LIGHTER_FAST_METHOD_ID = 'lighter-fast'\nexport const LIGHTER_SECURE_METHOD_ID = 'lighter-secure'\n\n/** What the host must implement to submit a Secure withdrawal on Lighter's L2. */\nexport interface LighterSecureWithdrawalParams {\n /** Withdrawal amount in token units (e.g. \"1.5\" for 1.5 ETH). */\n amountTokenUnits: string\n /** The Lighter asset index (e.g. 1 for ETH, 3 for USDC). */\n assetIndex: number\n /**\n * 0 = perps / USDC collateral, 1 = spot. USDC shares asset index 3 across\n * both routes, so the route type is what selects Perps vs Spot.\n */\n routeType: LighterRouteType\n}\n\n/**\n * Lighter withdrawal, as the host configures it. Mirrors web's\n * `LighterWithdrawalConfig` (`@funkit/connect/clients/lighter`) so an\n * integrator's web and mobile wiring read the same.\n *\n * Passed on `WithdrawalFlowConfig.lighter`; its presence is what turns the\n * withdrawal flow's single crypto row into the Fast / Secure pair.\n */\nexport interface LighterWithdrawalFlowConfig {\n /**\n * The connected user's L1 address. The SDK resolves the L2 main-account\n * index from it \u2014 Lighter addresses accounts by index, not by address.\n */\n l1Address: Address\n /**\n * Host-built Lighter L2 signer, used by the Fast rail's relay adapter. The\n * SDK never holds L2 key material.\n */\n signerClient: LighterSigner\n /**\n * Submits the Secure withdrawal on Lighter's L2 and resolves with the L2 tx\n * hash. Funds bridge directly to Ethereum mainnet \u2014 no relay, no swap.\n */\n sendLighterSecureWithdrawal: (\n params: LighterSecureWithdrawalParams,\n ) => Promise<string>\n /**\n * Withdrawable balance for the selected source token, applied to both rails.\n * Lighter's own accounting \u2014 it must account for what the SDK cannot see\n * (margin requirements, locked collateral), so the integrator owns it.\n */\n withdrawalSourceTokenBalance?: (\n params: WithdrawalSourceTokenParams,\n ) => string | number\n /**\n * Minimum Secure withdrawal in token units. Takes the same\n * {@link WithdrawalSourceTokenParams} as every other source-token callback,\n * so the shape carries over to any venue rather than being symbol-only.\n * Perps and spot USDC stay distinguishable \u2014 they are separate source tokens\n * with their own addresses. Return `undefined` for the default.\n */\n getSecureMinWithdrawalAmount?: (\n params: WithdrawalSourceTokenParams,\n ) => number | undefined\n /**\n * Awaited after the user taps Withdraw but before either rail fetches a\n * nonce, prompts, or submits.\n *\n * Lighter strategies and withdrawals share one L2 signing account, so a\n * strategy still placing or cancelling orders bumps the nonce out from under\n * the withdrawal and the signed tx is rejected. Cancel in-flight strategies\n * here so the withdrawal signs against a stable nonce. Throw to abort \u2014 no\n * nonce is consumed.\n */\n onBeforeSign?: () => Promise<void> | void\n}\n", "import { type WithdrawalClient } from '@funkit/connect-core'\nimport { LIGHTER_FAST_MAX_WITHDRAWAL_USD } from '@funkit/connect-core/clients/lighter'\nimport { createLighterAdaptedWallet } from '@funkit/connect-core/clients/lighter'\nimport { LIGHTER_CHAIN_ID } from '@funkit/chains'\nimport type { Address } from 'viem'\n\nimport type { WithdrawalFlowConfig } from '../../src/flow/withdrawalFlowConfig'\nimport { logger } from '../../src/logging/logger'\nimport type { LighterWithdrawalFlowConfig } from './lighterWithdrawalConfig'\n\n/**\n * Lighter USDC Perps, addressed as relay does: the zero address maps to relay\n * asset '0' via `RELAY_LIGHTER_FUN_ADDRESS_MAP` in fun-relay.\n */\nconst LIGHTER_USDC_PERPS_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Address\n\n/** Same id relay calls `RELAY_LIGHTER_CHAIN_ID`; the config carries it as a string. */\nconst LIGHTER_SOURCE_CHAIN_ID = `${LIGHTER_CHAIN_ID}`\n\n/** Fast is USDC-only, so web's USD floor is also its token-unit floor. */\nconst LIGHTER_FAST_MIN_WITHDRAWAL_USD = 4\n\n/**\n * Wraps the host's signer so `onBeforeSign` is awaited before the first\n * transfer. Lighter strategies and withdrawals share one L2 signing account, so\n * an in-flight strategy would bump the nonce out from under a Fast withdrawal\n * exactly as it would a Secure one. Throwing aborts before any nonce is used.\n */\nfunction withPreSignHook(\n signerClient: LighterWithdrawalFlowConfig['signerClient'],\n onBeforeSign: LighterWithdrawalFlowConfig['onBeforeSign'],\n): LighterWithdrawalFlowConfig['signerClient'] {\n if (!onBeforeSign) return signerClient\n return {\n ...signerClient,\n transfer: async (params) => {\n await onBeforeSign()\n return signerClient.transfer(params)\n },\n }\n}\n\n/**\n * A {@link WithdrawalClient} for Lighter Fast. Relay drives `adaptedWallet`\n * directly \u2014 the EVM members exist to satisfy the interface and to throw\n * loudly if something ever routes an EVM leg through this client, which for\n * Fast would mean signing on the wrong rail.\n *\n * `address()` is the L2 account index, not an EVM address: Lighter addresses\n * accounts by index, and that is what relay and the tracking row record.\n */\nexport function createLighterFastWithdrawalClient({\n signerClient,\n accountIndex,\n onBeforeSign,\n}: {\n signerClient: LighterWithdrawalFlowConfig['signerClient']\n accountIndex: string\n /**\n * Host hook awaited before the first L2 signature. Relay drives the adapter,\n * so the only point Fast controls is the signer itself.\n */\n onBeforeSign?: LighterWithdrawalFlowConfig['onBeforeSign']\n // The adapter is narrowed to Lighter's own wallet: the interface field is\n // relay's per-VM union, and callers of this client know which vm they got.\n}): WithdrawalClient & {\n adaptedWallet: ReturnType<typeof createLighterAdaptedWallet>\n} {\n // Fail here rather than let a NaN account index reach relay, where it\n // surfaces much later as an unattributable signing failure.\n if (!/^\\d+$/.test(accountIndex)) {\n throw new Error(\n `Lighter Fast needs a numeric account index, got: ${accountIndex}`,\n )\n }\n return {\n adaptedWallet: createLighterAdaptedWallet({\n signerClient: withPreSignHook(signerClient, onBeforeSign),\n accountIndex: Number(accountIndex),\n logger,\n }),\n address: () => accountIndex,\n getChainId: async () => LIGHTER_CHAIN_ID,\n // Lighter is single-chain \u2014 nothing to switch to.\n switchChain: async () => undefined,\n sendTransaction: async () => {\n throw new Error('Lighter Fast executes through its relay adapter')\n },\n confirmTransaction: async () => {\n throw new Error('Lighter Fast executes through its relay adapter')\n },\n }\n}\n\n/**\n * The withdrawal the crypto rail runs for Lighter Fast: USDC Perps out of the\n * user's L2 account, quoted and executed through Fun + Relay to any supported\n * destination. Port of web's `buildLighterFastWalletWithdrawalConfig`.\n *\n * Limits are web's USD numbers expressed in token units. Fast is USDC-only, so\n * the two are the same number; RN has no price feed yet, and a USD limit\n * without one is inert (see `withdrawal/validation.ts`).\n */\nexport function buildLighterFastWithdrawalConfig({\n config,\n lighter,\n accountIndex,\n isUnifiedTradingMode,\n}: {\n /** The host's withdrawal config \u2014 title and callbacks carry over. */\n config: WithdrawalFlowConfig\n lighter: LighterWithdrawalFlowConfig\n accountIndex: string\n /** Unified accounts hold one USDC balance, so the label drops \"(Perps)\". */\n isUnifiedTradingMode: boolean\n}): WithdrawalFlowConfig {\n const sourceToken = {\n chainId: LIGHTER_SOURCE_CHAIN_ID,\n address: LIGHTER_USDC_PERPS_ADDRESS,\n symbol: 'USDC',\n decimals: 6,\n }\n return {\n ...config,\n sourceToken,\n sourceTokens: [\n {\n token: sourceToken,\n label: isUnifiedTradingMode ? 'USDC' : 'USDC (Perps)',\n },\n ],\n withdrawalSourceTokenBalance: lighter.withdrawalSourceTokenBalance,\n defaultReceiveToken: 'USDC',\n withdrawalWallet: createLighterFastWithdrawalClient({\n signerClient: lighter.signerClient,\n accountIndex,\n onBeforeSign: lighter.onBeforeSign,\n }),\n // Both in token units, not USD: the price API can't resolve Lighter's\n // source (an L2 balance behind a pseudo-address), and a USD bound with no\n // price silently goes unenforced. Fast is USDC-only, so the numbers match.\n getMinWithdrawalAmount: () => LIGHTER_FAST_MIN_WITHDRAWAL_USD,\n getMaxWithdrawalAmount: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD,\n }\n}\n", "import type { LighterAccountIndex } from '@funkit/api-base'\nimport { useLighterAccountQuery } from '@funkit/connect-core'\nimport {\n LIGHTER_STAKING_POOL_INDEX,\n findLighterStakingShare,\n resolveLighterSharePrice,\n resolveLighterUnstakedFeeTokens,\n} from '@funkit/connect-core/clients/lighter'\nimport { useEffect, useMemo, useRef } from 'react'\n\nimport { logger } from '../../src/logging/logger'\n\n/**\n * The Lighter Fast \"unstaked fee\": a flat deduction taken off the withdrawal\n * before quoting, waived for users staked at or above the threshold.\n *\n * Two accounts, two queries: the user's carries their `shares[]` (entry state\n * only), and the pool's carries the NAV needed to value them. Returns 0 while\n * either is in flight and for every non-Fast caller; once both settle the fee is\n * computed, failing closed if a lookup errored.\n */\nexport function useLighterUnstakedFee({\n accountIndex,\n enabled,\n}: {\n accountIndex: string | undefined\n /** Fast only \u2014 Secure charges no such fee. */\n enabled: boolean\n}): number {\n const active = enabled && !!accountIndex\n const {\n account: userAccount,\n isFetched: isUserAccountFetched,\n isError: isUserAccountError,\n } = useLighterAccountQuery(\n active ? { by: 'index', value: accountIndex as LighterAccountIndex } : null,\n )\n const { account: poolAccount, isFetched: isPoolFetched } =\n useLighterAccountQuery(\n active\n ? {\n by: 'index',\n value: `${LIGHTER_STAKING_POOL_INDEX}` as LighterAccountIndex,\n }\n : null,\n )\n\n // Stable references so the logging effect doesn't re-fire every render while\n // the accounts are still loading.\n const shares = useMemo(() => userAccount?.shares ?? [], [userAccount])\n const sharePrice = useMemo(\n () => resolveLighterSharePrice(poolAccount),\n [poolAccount],\n )\n // Both lookups, not just the user's: mid-flight, no shares is\n // indistinguishable from a non-staker and a missing NAV values a staker at\n // entry principal \u2014 either way the quote would price a fee that then moves.\n // A *failed* lookup is different: the venue charges the fee regardless of what\n // we can see, and quoting the gross amount would promise the user ~3 tokens\n // the transfer never delivers. So an error fails closed (`isFetched` is true\n // either way), matching web, which computes the fee unconditionally.\n const isSettled = active && isUserAccountFetched && isPoolFetched\n const feeTokens = isSettled\n ? resolveLighterUnstakedFeeTokens(shares, sharePrice)\n : 0\n\n // A background refetch hands back a fresh `shares` array every time; without\n // this the same verdict is recorded again on each one.\n const loggedVerdict = useRef<string | undefined>(undefined)\n const verdict = `${accountIndex}|${isSettled}|${isUserAccountError}|${feeTokens}|${sharePrice}`\n\n useEffect(() => {\n if (!active || loggedVerdict.current === verdict) {\n return\n }\n loggedVerdict.current = verdict\n if (!isSettled) {\n return\n }\n if (isUserAccountError) {\n // The fee is charged from the venue's own view of the stake, which we\n // could not read \u2014 so it is applied blind and worth surfacing.\n logger.warn('lighter:fast:unstaked-fee:account-unavailable', {\n accountIndex,\n unstakedFeeTokens: feeTokens,\n })\n }\n const stakingShare = findLighterStakingShare(shares)\n logger.info('lighter:fast:unstaked-fee:resolved', {\n accountIndex,\n sharesLength: shares.length,\n sharePrice,\n sharesAmount: stakingShare?.shares_amount,\n unstakedFeeTokens: feeTokens,\n })\n // Pool NAV missing for an actual staker \u2014 the gate silently degrades to the\n // entry principal, which under-counts accrued yield and can over-charge.\n if (stakingShare && sharePrice === undefined) {\n logger.warn('lighter:fast:share-price-unavailable', {\n accountIndex,\n stakingPoolIndex: LIGHTER_STAKING_POOL_INDEX,\n })\n }\n // We expect exactly one share \u2014 the staking pool. More than one, or a\n // missing staking-pool share, is unexpected: surface it for monitoring.\n if (shares.length > 1 || !stakingShare) {\n logger.warn('lighter:fast:unexpected-shares', {\n accountIndex,\n sharesLength: shares.length,\n publicPoolIndexes: shares.map((share) => share.public_pool_index),\n hasStakingShare: !!stakingShare,\n })\n }\n }, [\n active,\n verdict,\n accountIndex,\n shares,\n sharePrice,\n feeTokens,\n isSettled,\n isUserAccountError,\n ])\n\n return feeTokens\n}\n", "import type {\n WithdrawalFlowConfig,\n WithdrawalMethodOption,\n} from '../../src/flow/withdrawalFlowConfig'\nimport { buildLighterFastWithdrawalConfig } from './lighterFastWithdrawal'\nimport { LIGHTER_FAST_METHOD_ID } from './lighterWithdrawalConfig'\nimport type { LighterWithdrawalFlowConfig } from './lighterWithdrawalConfig'\nimport { useLighterUnstakedFee } from './useLighterUnstakedFee'\nimport { useLighterWithdrawalMethods } from './useLighterWithdrawalMethods'\n\n/**\n * The Lighter methods to hand `beginWithdrawal`, each carrying the config it\n * runs. Mirrors web's `useLighterWithdrawalConfig`: the host calls this and\n * passes the result on, so the SDK never holds Lighter config.\n *\n * Empty until the L2 account resolves \u2014 both rails address the account by\n * index, so there is nothing to offer before then, and the flow falls back to\n * its generic crypto row.\n */\nexport function useLighterWithdrawal({\n lighter,\n config,\n}: {\n lighter: LighterWithdrawalFlowConfig | undefined\n /**\n * The host's own withdrawal config; title and callbacks carry over. Absent\n * until the host has one \u2014 a hook can't be called conditionally, so there is\n * no placeholder worth inventing.\n */\n config: WithdrawalFlowConfig | undefined\n}): WithdrawalMethodOption[] {\n const { methods, accountIndex, isUnifiedTradingMode } =\n useLighterWithdrawalMethods(lighter)\n // Fast only; Secure charges no such fee. Keyed off the row actually being\n // offered, so the two account lookups stay off the wire when it isn't.\n const isFastOffered = methods.some(\n (method) => method.id === LIGHTER_FAST_METHOD_ID,\n )\n const quoteInputFeeTokens = useLighterUnstakedFee({\n accountIndex,\n enabled: isFastOffered,\n })\n\n if (!lighter || !config || !accountIndex) return []\n\n // Native Bridge is filtered out: its screens have not shipped, and a row\n // that fails on tap is worse than no row.\n return methods\n .filter((method) => method.id === LIGHTER_FAST_METHOD_ID)\n .map((method) => ({\n id: method.id,\n title: method.title,\n subtitle: method.subtitle,\n config: {\n ...buildLighterFastWithdrawalConfig({\n config,\n lighter,\n accountIndex,\n isUnifiedTradingMode,\n }),\n // Lighter takes this off the amount before it is quoted.\n quoteInputFeeTokens,\n },\n }))\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["useEffect", "useRef", "useRef", "useEffect"]
|
|
3
|
+
"sources": ["../../clients/lighter/useLighterWithdrawalMethods.ts", "../../clients/lighter/lighterWithdrawalConfig.ts", "../../clients/lighter/lighterFastWithdrawal.ts", "../../clients/lighter/useLighterUnstakedFee.ts", "../../clients/lighter/useLighterWithdrawal.ts", "../../clients/lighter/useLighterSecureWithdrawal.ts"],
|
|
4
|
+
"sourcesContent": ["import { useLighterAccountsQuery } from '@funkit/connect-core'\nimport { getLighterWithdrawalDelay } from '@funkit/connect-core/clients/lighter'\nimport { useQuery } from '@tanstack/react-query'\nimport type { TFunction } from 'i18next'\nimport { useEffect, useRef } from 'react'\n\nimport { logger } from '../../src/logging/logger'\nimport { useFunkitTranslation } from '../../src/providers/FunkitI18nProvider'\nimport {\n LIGHTER_FAST_METHOD_ID,\n LIGHTER_SECURE_METHOD_ID,\n type LighterWithdrawalFlowConfig,\n} from './lighterWithdrawalConfig'\n\n/** One row on the withdrawal method screen, before icons are attached. */\nexport interface LighterWithdrawalMethod {\n id: typeof LIGHTER_FAST_METHOD_ID | typeof LIGHTER_SECURE_METHOD_ID\n title: string\n subtitle: string\n}\n\nexport interface UseLighterWithdrawalMethodsResult {\n /** Fast then Secure, in web's order. Empty until the account resolves. */\n methods: LighterWithdrawalMethod[]\n /**\n * The user's Lighter L2 main-account index. Both rails address the account\n * by index, so neither can run before this resolves.\n */\n accountIndex: string | undefined\n /** Unified accounts hold one USDC balance \u2014 no spot/perps split. */\n isUnifiedTradingMode: boolean\n /** The account lookup is in flight; rows are expected to be empty. */\n isLoading: boolean\n}\n\nconst SECONDS_PER_MINUTE = 60\nconst MINUTES_PER_HOUR = 60\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR\n\n/**\n * Formats Lighter's live L2\u2192L1 delay for the Secure row (e.g. \"1 h 50 min\").\n * - Reproduces web's `formatSecondsToReadableForm(seconds, false, true)` output\n * for every input, including its two oddities: a sub-minute delay reads in\n * seconds, and exactly one hour reads \"60 min\". The two SDKs quote the same\n * bridge, so they must not disagree on the wait.\n * - Rounds up otherwise: an estimate must not promise finality early.\n * - One literal `t` key per shape \u2014 never a computed key.\n */\nfunction formatDelay(t: TFunction, seconds: number): string {\n const normalized = Math.ceil(seconds)\n if (normalized === 1) {\n return t('withdrawLighter.delaySecond')\n }\n if (normalized <= SECONDS_PER_MINUTE) {\n return t('withdrawLighter.delaySeconds', { seconds: normalized })\n }\n // Round to minutes first: rounding the remainder alone can yield \"1 h 60 min\".\n const minutes = Math.ceil(normalized / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR\n const hours = Math.ceil(\n (normalized - minutes * SECONDS_PER_MINUTE) / SECONDS_PER_HOUR,\n )\n if (hours === 1 && minutes === 0) {\n return t('withdrawLighter.delayMinutes', { minutes: MINUTES_PER_HOUR })\n }\n if (hours > 0 && minutes > 0) {\n return t('withdrawLighter.delayHoursMinutes', { hours, minutes })\n }\n if (hours > 0) {\n return t('withdrawLighter.delayHours', { hours })\n }\n return t('withdrawLighter.delayMinutes', { minutes })\n}\n\n/**\n * Secure-withdrawal delay as display copy. Shown live because it tracks L2\u2192L1\n * batch cadence; `undefined` until it loads.\n */\nfunction useLighterSecureDelayText(enabled: boolean): string | undefined {\n const { t } = useFunkitTranslation()\n const { data } = useQuery({\n queryKey: ['lighterWithdrawalDelay'],\n queryFn: getLighterWithdrawalDelay,\n // This hook runs for every withdrawal flow, Lighter or not \u2014 a host with no\n // Lighter config must never reach Lighter's API.\n enabled,\n staleTime: 60_000,\n retry: 2,\n })\n const seconds = data?.seconds\n if (seconds === undefined || !Number.isFinite(seconds) || seconds <= 0) {\n return undefined\n }\n return formatDelay(t, seconds)\n}\n\ntype RailOutcome = 'not_configured' | 'loading' | 'offered' | 'no_account_index'\n\n/**\n * Whether Lighter's rails replace the generic crypto row, and why not when they\n * don't.\n * - `isFetched`, not `isLoading`: the latter is false on the first render,\n * before the query starts, which would record a premature \"no account\".\n */\nfunction resolveRailOutcome({\n isConfigured,\n isFetched,\n hasAccountIndex,\n}: {\n isConfigured: boolean\n isFetched: boolean\n hasAccountIndex: boolean\n}): RailOutcome {\n if (!isConfigured) return 'not_configured'\n if (!isFetched) return 'loading'\n if (!hasAccountIndex) return 'no_account_index'\n return 'offered'\n}\n\n/**\n * The Fast / Secure rows plus the account state both rails need. Port of the\n * row-building half of web's `useLighterWithdrawalConfig`.\n *\n * Pass `undefined` when the host configured no Lighter: the inner hooks still\n * run (Rules of Hooks) but every query stays disabled.\n */\nexport function useLighterWithdrawalMethods(\n config: LighterWithdrawalFlowConfig | undefined,\n): UseLighterWithdrawalMethodsResult {\n const { t } = useFunkitTranslation()\n const { mainAccountIndex, isUnifiedTradingMode, isLoading, isFetched } =\n useLighterAccountsQuery({ address: config?.l1Address })\n const secureDelayText = useLighterSecureDelayText(!!config)\n\n // Lighter addresses accounts by a numeric index; anything else means the\n // lookup returned something unusable and neither rail can address the user.\n const accountIndex =\n mainAccountIndex && /^\\d+$/.test(mainAccountIndex)\n ? mainAccountIndex\n : undefined\n\n const outcome = resolveRailOutcome({\n isConfigured: !!config,\n isFetched,\n hasAccountIndex: !!accountIndex,\n })\n // Rail-availability decision point, recorded once per outcome so a re-render\n // or a background refetch doesn't re-emit the same one.\n const loggedOutcome = useRef<RailOutcome | undefined>(undefined)\n useEffect(() => {\n if (outcome === 'loading' || loggedOutcome.current === outcome) return\n loggedOutcome.current = outcome\n if (outcome === 'not_configured') return\n const payload = {\n outcome,\n isUnifiedTradingMode,\n hasAccountIndex: !!accountIndex,\n }\n if (outcome === 'no_account_index') {\n // Recovered, but the user loses Lighter's rails for this session \u2014 that\n // is a visible capability change, so it belongs above INFO.\n logger.warn('lighter:withdrawal:rails', payload)\n return\n }\n logger.info('lighter:withdrawal:rails', payload)\n }, [outcome, isUnifiedTradingMode, accountIndex])\n\n const methods: LighterWithdrawalMethod[] =\n config && accountIndex\n ? [\n {\n id: LIGHTER_FAST_METHOD_ID,\n title: t('withdrawLighter.methodFast'),\n subtitle: isUnifiedTradingMode\n ? t('withdrawLighter.fastDisclaimerUnified')\n : t('withdrawLighter.fastDisclaimer'),\n },\n {\n id: LIGHTER_SECURE_METHOD_ID,\n title: t('withdrawLighter.methodSecure'),\n subtitle: t('withdrawLighter.secureDisclaimer', {\n // Until the live value loads, show the localized \"60+ minutes\"\n // historical estimate. The \"+\" lives in the per-locale fallback\n // string so it doesn't bleed into live values, which are exact.\n delay:\n secureDelayText ?? t('withdrawLighter.secureFallbackDelay'),\n }),\n },\n ]\n : []\n\n return {\n methods,\n accountIndex,\n isUnifiedTradingMode,\n isLoading: !!config && isLoading,\n }\n}\n", "import type { LighterRouteType } from '@funkit/connect-core/clients/lighter'\nimport type { LighterSigner } from '@funkit/connect-core/clients/lighter'\nimport type { Address } from 'viem'\n\nimport type { WithdrawalSourceTokenParams } from '../../src/flow/withdrawalFlowConfig'\n\n/** Stable ids for the two rails \u2014 used for row identity, routing and logs. */\nexport const LIGHTER_FAST_METHOD_ID = 'lighter-fast'\nexport const LIGHTER_SECURE_METHOD_ID = 'lighter-secure'\n\n/** What the host must implement to submit a Secure withdrawal on Lighter's L2. */\nexport interface LighterSecureWithdrawalParams {\n /** Withdrawal amount in token units (e.g. \"1.5\" for 1.5 ETH). */\n amountTokenUnits: string\n /** The Lighter asset index (e.g. 1 for ETH, 3 for USDC). */\n assetIndex: number\n /**\n * 0 = perps / USDC collateral, 1 = spot. USDC shares asset index 3 across\n * both routes, so the route type is what selects Perps vs Spot.\n */\n routeType: LighterRouteType\n}\n\n/**\n * Lighter withdrawal, as the host configures it. Mirrors web's\n * `LighterWithdrawalConfig` (`@funkit/connect/clients/lighter`) so an\n * integrator's web and mobile wiring read the same.\n *\n * Passed on `WithdrawalFlowConfig.lighter`; its presence is what turns the\n * withdrawal flow's single crypto row into the Fast / Secure pair.\n */\nexport interface LighterWithdrawalFlowConfig {\n /**\n * The connected user's L1 address. The SDK resolves the L2 main-account\n * index from it \u2014 Lighter addresses accounts by index, not by address.\n */\n l1Address: Address\n /**\n * Host-built Lighter L2 signer, used by the Fast rail's relay adapter. The\n * SDK never holds L2 key material.\n */\n signerClient: LighterSigner\n /**\n * Submits the Secure withdrawal on Lighter's L2 and resolves with the L2 tx\n * hash. Funds bridge directly to Ethereum mainnet \u2014 no relay, no swap.\n */\n sendLighterSecureWithdrawal: (\n params: LighterSecureWithdrawalParams,\n ) => Promise<string>\n /**\n * Withdrawable balance for the selected source token, applied to both rails.\n * Lighter's own accounting \u2014 it must account for what the SDK cannot see\n * (margin requirements, locked collateral), so the integrator owns it.\n */\n withdrawalSourceTokenBalance?: (\n params: WithdrawalSourceTokenParams,\n ) => string | number\n /**\n * Minimum Secure withdrawal in token units. Takes the same\n * {@link WithdrawalSourceTokenParams} as every other source-token callback,\n * so the shape carries over to any venue rather than being symbol-only.\n * Perps and spot USDC stay distinguishable \u2014 they are separate source tokens\n * with their own addresses. Return `undefined` for the default.\n */\n getSecureMinWithdrawalAmount?: (\n params: WithdrawalSourceTokenParams,\n ) => number | undefined\n /**\n * Awaited after the user taps Withdraw but before either rail fetches a\n * nonce, prompts, or submits.\n *\n * Lighter strategies and withdrawals share one L2 signing account, so a\n * strategy still placing or cancelling orders bumps the nonce out from under\n * the withdrawal and the signed tx is rejected. Cancel in-flight strategies\n * here so the withdrawal signs against a stable nonce. Throw to abort \u2014 no\n * nonce is consumed.\n */\n onBeforeSign?: () => Promise<void> | void\n}\n", "import { type WithdrawalClient } from '@funkit/connect-core'\nimport { LIGHTER_FAST_MAX_WITHDRAWAL_USD } from '@funkit/connect-core/clients/lighter'\nimport { createLighterAdaptedWallet } from '@funkit/connect-core/clients/lighter'\nimport { LIGHTER_CHAIN_ID } from '@funkit/chains'\nimport type { Address } from 'viem'\n\nimport type { WithdrawalFlowConfig } from '../../src/flow/withdrawalFlowConfig'\nimport { logger } from '../../src/logging/logger'\nimport type { LighterWithdrawalFlowConfig } from './lighterWithdrawalConfig'\n\n/**\n * Lighter USDC Perps, addressed as relay does: the zero address maps to relay\n * asset '0' via `RELAY_LIGHTER_FUN_ADDRESS_MAP` in fun-relay.\n */\nconst LIGHTER_USDC_PERPS_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Address\n\n/** Same id relay calls `RELAY_LIGHTER_CHAIN_ID`; the config carries it as a string. */\nconst LIGHTER_SOURCE_CHAIN_ID = `${LIGHTER_CHAIN_ID}`\n\n/** Fast is USDC-only, so web's USD floor is also its token-unit floor. */\nconst LIGHTER_FAST_MIN_WITHDRAWAL_USD = 4\n\n/**\n * Wraps the host's signer so `onBeforeSign` is awaited before the first\n * transfer. Lighter strategies and withdrawals share one L2 signing account, so\n * an in-flight strategy would bump the nonce out from under a Fast withdrawal\n * exactly as it would a Secure one. Throwing aborts before any nonce is used.\n */\nfunction withPreSignHook(\n signerClient: LighterWithdrawalFlowConfig['signerClient'],\n onBeforeSign: LighterWithdrawalFlowConfig['onBeforeSign'],\n): LighterWithdrawalFlowConfig['signerClient'] {\n if (!onBeforeSign) return signerClient\n return {\n ...signerClient,\n transfer: async (params) => {\n await onBeforeSign()\n return signerClient.transfer(params)\n },\n }\n}\n\n/**\n * A {@link WithdrawalClient} for Lighter Fast. Relay drives `adaptedWallet`\n * directly \u2014 the EVM members exist to satisfy the interface and to throw\n * loudly if something ever routes an EVM leg through this client, which for\n * Fast would mean signing on the wrong rail.\n *\n * `address()` is the L2 account index, not an EVM address: Lighter addresses\n * accounts by index, and that is what relay and the tracking row record.\n */\nexport function createLighterFastWithdrawalClient({\n signerClient,\n accountIndex,\n onBeforeSign,\n}: {\n signerClient: LighterWithdrawalFlowConfig['signerClient']\n accountIndex: string\n /**\n * Host hook awaited before the first L2 signature. Relay drives the adapter,\n * so the only point Fast controls is the signer itself.\n */\n onBeforeSign?: LighterWithdrawalFlowConfig['onBeforeSign']\n // The adapter is narrowed to Lighter's own wallet: the interface field is\n // relay's per-VM union, and callers of this client know which vm they got.\n}): WithdrawalClient & {\n adaptedWallet: ReturnType<typeof createLighterAdaptedWallet>\n} {\n // Fail here rather than let a NaN account index reach relay, where it\n // surfaces much later as an unattributable signing failure.\n if (!/^\\d+$/.test(accountIndex)) {\n throw new Error(\n `Lighter Fast needs a numeric account index, got: ${accountIndex}`,\n )\n }\n return {\n adaptedWallet: createLighterAdaptedWallet({\n signerClient: withPreSignHook(signerClient, onBeforeSign),\n accountIndex: Number(accountIndex),\n logger,\n }),\n address: () => accountIndex,\n getChainId: async () => LIGHTER_CHAIN_ID,\n // Lighter is single-chain \u2014 nothing to switch to.\n switchChain: async () => undefined,\n sendTransaction: async () => {\n throw new Error('Lighter Fast executes through its relay adapter')\n },\n confirmTransaction: async () => {\n throw new Error('Lighter Fast executes through its relay adapter')\n },\n }\n}\n\n/**\n * The withdrawal the crypto rail runs for Lighter Fast: USDC Perps out of the\n * user's L2 account, quoted and executed through Fun + Relay to any supported\n * destination. Port of web's `buildLighterFastWalletWithdrawalConfig`.\n *\n * Limits are web's USD numbers expressed in token units. Fast is USDC-only, so\n * the two are the same number; RN has no price feed yet, and a USD limit\n * without one is inert (see `withdrawal/validation.ts`).\n */\nexport function buildLighterFastWithdrawalConfig({\n config,\n lighter,\n accountIndex,\n isUnifiedTradingMode,\n}: {\n /** The host's withdrawal config \u2014 title and callbacks carry over. */\n config: WithdrawalFlowConfig\n lighter: LighterWithdrawalFlowConfig\n accountIndex: string\n /** Unified accounts hold one USDC balance, so the label drops \"(Perps)\". */\n isUnifiedTradingMode: boolean\n}): WithdrawalFlowConfig {\n const sourceToken = {\n chainId: LIGHTER_SOURCE_CHAIN_ID,\n address: LIGHTER_USDC_PERPS_ADDRESS,\n symbol: 'USDC',\n decimals: 6,\n }\n return {\n ...config,\n sourceToken,\n sourceTokens: [\n {\n token: sourceToken,\n label: isUnifiedTradingMode ? 'USDC' : 'USDC (Perps)',\n },\n ],\n withdrawalSourceTokenBalance: lighter.withdrawalSourceTokenBalance,\n defaultReceiveToken: 'USDC',\n withdrawalWallet: createLighterFastWithdrawalClient({\n signerClient: lighter.signerClient,\n accountIndex,\n onBeforeSign: lighter.onBeforeSign,\n }),\n // Both in token units, not USD: the price API can't resolve Lighter's\n // source (an L2 balance behind a pseudo-address), and a USD bound with no\n // price silently goes unenforced. Fast is USDC-only, so the numbers match.\n getMinWithdrawalAmount: () => LIGHTER_FAST_MIN_WITHDRAWAL_USD,\n getMaxWithdrawalAmount: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD,\n }\n}\n", "import type { LighterAccountIndex } from '@funkit/api-base'\nimport { useLighterAccountQuery } from '@funkit/connect-core'\nimport {\n LIGHTER_STAKING_POOL_INDEX,\n findLighterStakingShare,\n resolveLighterSharePrice,\n resolveLighterUnstakedFeeTokens,\n} from '@funkit/connect-core/clients/lighter'\nimport { useEffect, useMemo, useRef } from 'react'\n\nimport { logger } from '../../src/logging/logger'\n\n/**\n * The Lighter Fast \"unstaked fee\": a flat deduction taken off the withdrawal\n * before quoting, waived for users staked at or above the threshold.\n *\n * Two accounts, two queries: the user's carries their `shares[]` (entry state\n * only), and the pool's carries the NAV needed to value them. Returns 0 while\n * either is in flight and for every non-Fast caller; once both settle the fee is\n * computed, failing closed if a lookup errored.\n */\nexport function useLighterUnstakedFee({\n accountIndex,\n enabled,\n}: {\n accountIndex: string | undefined\n /** Fast only \u2014 Secure charges no such fee. */\n enabled: boolean\n}): number {\n const active = enabled && !!accountIndex\n const {\n account: userAccount,\n isFetched: isUserAccountFetched,\n isError: isUserAccountError,\n } = useLighterAccountQuery(\n active ? { by: 'index', value: accountIndex as LighterAccountIndex } : null,\n )\n const { account: poolAccount, isFetched: isPoolFetched } =\n useLighterAccountQuery(\n active\n ? {\n by: 'index',\n value: `${LIGHTER_STAKING_POOL_INDEX}` as LighterAccountIndex,\n }\n : null,\n )\n\n // Stable references so the logging effect doesn't re-fire every render while\n // the accounts are still loading.\n const shares = useMemo(() => userAccount?.shares ?? [], [userAccount])\n const sharePrice = useMemo(\n () => resolveLighterSharePrice(poolAccount),\n [poolAccount],\n )\n // Both lookups, not just the user's: mid-flight, no shares is\n // indistinguishable from a non-staker and a missing NAV values a staker at\n // entry principal \u2014 either way the quote would price a fee that then moves.\n // A *failed* lookup is different: the venue charges the fee regardless of what\n // we can see, and quoting the gross amount would promise the user ~3 tokens\n // the transfer never delivers. So an error fails closed (`isFetched` is true\n // either way), matching web, which computes the fee unconditionally.\n const isSettled = active && isUserAccountFetched && isPoolFetched\n const feeTokens = isSettled\n ? resolveLighterUnstakedFeeTokens(shares, sharePrice)\n : 0\n\n // A background refetch hands back a fresh `shares` array every time; without\n // this the same verdict is recorded again on each one.\n const loggedVerdict = useRef<string | undefined>(undefined)\n const verdict = `${accountIndex}|${isSettled}|${isUserAccountError}|${feeTokens}|${sharePrice}`\n\n useEffect(() => {\n if (!active || loggedVerdict.current === verdict) {\n return\n }\n loggedVerdict.current = verdict\n if (!isSettled) {\n return\n }\n if (isUserAccountError) {\n // The fee is charged from the venue's own view of the stake, which we\n // could not read \u2014 so it is applied blind and worth surfacing.\n logger.warn('lighter:fast:unstaked-fee:account-unavailable', {\n accountIndex,\n unstakedFeeTokens: feeTokens,\n })\n }\n const stakingShare = findLighterStakingShare(shares)\n logger.info('lighter:fast:unstaked-fee:resolved', {\n accountIndex,\n sharesLength: shares.length,\n sharePrice,\n sharesAmount: stakingShare?.shares_amount,\n unstakedFeeTokens: feeTokens,\n })\n // Pool NAV missing for an actual staker \u2014 the gate silently degrades to the\n // entry principal, which under-counts accrued yield and can over-charge.\n if (stakingShare && sharePrice === undefined) {\n logger.warn('lighter:fast:share-price-unavailable', {\n accountIndex,\n stakingPoolIndex: LIGHTER_STAKING_POOL_INDEX,\n })\n }\n // We expect exactly one share \u2014 the staking pool. More than one, or a\n // missing staking-pool share, is unexpected: surface it for monitoring.\n if (shares.length > 1 || !stakingShare) {\n logger.warn('lighter:fast:unexpected-shares', {\n accountIndex,\n sharesLength: shares.length,\n publicPoolIndexes: shares.map((share) => share.public_pool_index),\n hasStakingShare: !!stakingShare,\n })\n }\n }, [\n active,\n verdict,\n accountIndex,\n shares,\n sharePrice,\n feeTokens,\n isSettled,\n isUserAccountError,\n ])\n\n return feeTokens\n}\n", "import type {\n WithdrawalFlowConfig,\n WithdrawalMethodOption,\n} from '../../src/flow/withdrawalFlowConfig'\nimport { buildLighterFastWithdrawalConfig } from './lighterFastWithdrawal'\nimport { LIGHTER_FAST_METHOD_ID } from './lighterWithdrawalConfig'\nimport type { LighterWithdrawalFlowConfig } from './lighterWithdrawalConfig'\nimport { useLighterUnstakedFee } from './useLighterUnstakedFee'\nimport { useLighterWithdrawalMethods } from './useLighterWithdrawalMethods'\n\n/**\n * The Lighter methods to hand `beginWithdrawal`, each carrying the config it\n * runs. Mirrors web's `useLighterWithdrawalConfig`: the host calls this and\n * passes the result on, so the SDK never holds Lighter config.\n *\n * Empty until the L2 account resolves \u2014 both rails address the account by\n * index, so there is nothing to offer before then, and the flow falls back to\n * its generic crypto row.\n */\nexport function useLighterWithdrawal({\n lighter,\n config,\n}: {\n lighter: LighterWithdrawalFlowConfig | undefined\n /**\n * The host's own withdrawal config; title and callbacks carry over. Absent\n * until the host has one \u2014 a hook can't be called conditionally, so there is\n * no placeholder worth inventing.\n */\n config: WithdrawalFlowConfig | undefined\n}): WithdrawalMethodOption[] {\n const { methods, accountIndex, isUnifiedTradingMode } =\n useLighterWithdrawalMethods(lighter)\n // Fast only; Secure charges no such fee. Keyed off the row actually being\n // offered, so the two account lookups stay off the wire when it isn't.\n const isFastOffered = methods.some(\n (method) => method.id === LIGHTER_FAST_METHOD_ID,\n )\n const quoteInputFeeTokens = useLighterUnstakedFee({\n accountIndex,\n enabled: isFastOffered,\n })\n\n if (!lighter || !config || !accountIndex) return []\n\n // Native Bridge is filtered out: its screens have not shipped, and a row\n // that fails on tap is worse than no row.\n return methods\n .filter((method) => method.id === LIGHTER_FAST_METHOD_ID)\n .map((method) => ({\n id: method.id,\n title: method.title,\n subtitle: method.subtitle,\n config: {\n ...buildLighterFastWithdrawalConfig({\n config,\n lighter,\n accountIndex,\n isUnifiedTradingMode,\n }),\n // Lighter takes this off the amount before it is quoted.\n quoteInputFeeTokens,\n },\n }))\n}\n", "import { isUserRejectedError } from '@funkit/connect-core'\nimport {\n type LighterRouteType,\n getLighterBaseSymbol,\n getLighterSecureMainnetAddress,\n trackLighterSecureWithdrawal,\n} from '@funkit/connect-core/clients/lighter'\nimport { useCallback, useRef, useState } from 'react'\nimport type { Address } from 'viem'\n\nimport { useFunkitIdentity } from '../../src/identity/IdentityContext'\nimport { logger } from '../../src/logging/logger'\nimport type { LighterWithdrawalFlowConfig } from './lighterWithdrawalConfig'\n\n// Module-scoped: closing the sheet mid-withdrawal unmounts the hook, and the\n// fresh one a reopen mounts would know nothing about the in-flight submission.\nconst inFlightSecureWithdrawals = new Set<string>()\n\n/** What makes two presses the same withdrawal rather than two of them. */\nfunction secureWithdrawalKey({\n accountIndex,\n assetIndex,\n routeType,\n amountTokenUnits,\n}: {\n accountIndex: string\n assetIndex: number\n routeType: LighterRouteType\n amountTokenUnits: string\n}): string {\n return [accountIndex, assetIndex, routeType, amountTokenUnits].join('|')\n}\n\n/**\n * @internal Test-only: clear the process-wide in-flight set so suites that\n * reuse withdrawal details stay isolated. Not part of the public API.\n */\nexport function __resetInFlightSecureWithdrawals(): void {\n inFlightSecureWithdrawals.clear()\n}\n\nexport type LighterSecureSubmission =\n | { status: 'idle' }\n | { status: 'submitting' }\n | { status: 'submitted'; txHash: string; amountTokenUnits: string }\n // Carries the message, not the error: Lighter's SDK surfaces rate limits and\n // nonce collisions as plain strings the screen classifies for itself.\n | { status: 'failed'; message: string }\n\nexport interface UseLighterSecureWithdrawalParams {\n lighter: LighterWithdrawalFlowConfig\n /** The user's L2 main-account index \u2014 also the tracking key. */\n accountIndex: string | undefined\n /** Connected wallet: Secure locks the destination to it. */\n recipientAddress: Address\n}\n\n/**\n * Submits a Lighter Secure withdrawal: the host's L2 signer bridges the asset\n * to Ethereum 1:1, with no relay and no quote in the path. Fun is not in that\n * path, so the direct-execution row is attribution only and fire-and-forget.\n */\nexport function useLighterSecureWithdrawal({\n lighter,\n accountIndex,\n recipientAddress,\n}: UseLighterSecureWithdrawalParams) {\n const { apiKey } = useFunkitIdentity()\n const isSubmittingRef = useRef(false)\n const [submission, setSubmission] = useState<LighterSecureSubmission>({\n status: 'idle',\n })\n\n const submit = useCallback(\n async ({\n amountTokenUnits,\n assetIndex,\n routeType,\n sourceSymbol,\n withdrawalUSD,\n }: {\n amountTokenUnits: string\n /** Resolved from the account's asset list; never guessed. */\n assetIndex: number\n routeType: LighterRouteType\n /** May carry a ` (Spot)` suffix \u2014 tracking wants the base symbol. */\n sourceSymbol: string\n /** Token amount \u00D7 spot price, for attribution. '0' when unpriced. */\n withdrawalUSD: string\n }) => {\n if (!accountIndex) {\n // Neither rail can address the user without it; the screen blocks the\n // CTA on the same condition, so this is a belt-and-braces guard.\n logger.warn('lighter:withdrawal:secure:noAccountIndex')\n return\n }\n if (isSubmittingRef.current) {\n logger.warn('lighter:withdrawal:secure:already_submitting')\n return\n }\n const key = secureWithdrawalKey({\n accountIndex,\n assetIndex,\n routeType,\n amountTokenUnits,\n })\n if (inFlightSecureWithdrawals.has(key)) {\n logger.warn('lighter:withdrawal:secure:already_in_flight')\n return\n }\n isSubmittingRef.current = true\n inFlightSecureWithdrawals.add(key)\n setSubmission({ status: 'submitting' })\n\n let txHash: string\n try {\n // Lighter strategies and withdrawals share one L2 signing account, so\n // an in-flight strategy would bump the nonce out from under this.\n await lighter.onBeforeSign?.()\n\n logger.info('lighter:withdrawal:secure:start', {\n assetIndex,\n routeType,\n amountTokenUnits,\n destinationAddress: recipientAddress,\n })\n txHash = await lighter.sendLighterSecureWithdrawal({\n amountTokenUnits,\n assetIndex,\n routeType,\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n if (isUserRejectedError(error)) {\n // Declining is recoverable \u2014 the form stays as it was.\n logger.warn('lighter:withdrawal:secure:user_rejected')\n setSubmission({ status: 'idle' })\n return\n }\n // Recovered: the screen offers the on-chain fallback for a rate limit,\n // and a retry otherwise. Not an alertable ERROR.\n logger.warn('lighter:withdrawal:secure:failed', {\n error: message,\n assetIndex,\n routeType,\n })\n setSubmission({ status: 'failed', message })\n return\n } finally {\n isSubmittingRef.current = false\n inFlightSecureWithdrawals.delete(key)\n }\n\n logger.info('lighter:withdrawal:secure:submitted', {\n amountTokenUnits,\n assetIndex,\n routeType,\n txHash,\n })\n\n const mainnetTokenAddress = getLighterSecureMainnetAddress(sourceSymbol)\n if (mainnetTokenAddress) {\n // Fire-and-forget \u2014 never block the success screen on tracking.\n void trackLighterSecureWithdrawal({\n apiKey,\n logger,\n // Secure locks the destination to the connected wallet, so the L1\n // recipient address doubles as the userId for tracking purposes.\n userId: recipientAddress,\n txHash,\n recipientAddr: recipientAddress,\n assetIndex,\n mainnetTokenAddress,\n amountTokenUnits,\n withdrawalUSD,\n })\n } else {\n // Attribution only, so a symbol we can't map is a monitoring problem,\n // not a user-facing one.\n logger.warn('lighter:withdrawal:secure:unknownMainnetToken', {\n sourceSymbol: getLighterBaseSymbol(sourceSymbol),\n txHash,\n })\n }\n\n setSubmission({ status: 'submitted', txHash, amountTokenUnits })\n },\n [apiKey, accountIndex, lighter, recipientAddress],\n )\n\n const reset = useCallback(() => setSubmission({ status: 'idle' }), [])\n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AAA,MACH;AAEA,oBAAc,EAAE,QAAQ,aAAa,QAAQ,iBAAiB,CAAC;AAAA,IACjE;AAAA,IACA,CAAC,QAAQ,cAAc,SAAS,gBAAgB;AAAA,EAClD;AAEA,QAAM,QAAQ,YAAY,MAAM,cAAc,EAAE,QAAQ,OAAO,CAAC,GAAG,CAAC,CAAC;AAErE,SAAO,EAAE,YAAY,QAAQ,MAAM;AACrC;",
|
|
6
|
+
"names": ["useEffect", "useRef", "useRef", "useEffect", "useRef", "useRef"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { FunkitThemeProviderProps } from './src/theme/FunkitThemeProvider';
|
|
|
16
16
|
export { FunkitProvider } from './src/providers/FunkitProvider';
|
|
17
17
|
export type { FunkitProviderProps } from './src/providers/FunkitProvider';
|
|
18
18
|
export type { BackdropBlurRenderer } from './src/flow/FlowSheet';
|
|
19
|
+
export type { HapticFeedback } from './src/haptics/HapticsContext';
|
|
19
20
|
export type { Locale } from './src/locales/i18n';
|
|
20
21
|
export type { FunkitConfig } from './src/identity/IdentityContext';
|
|
21
22
|
export { useFunkitCheckout } from './src/providers/useFunkitCheckout';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAkBA,YAAY,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,WAAW,GACZ,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,4BAA4B,CAAA;AACnC,YAAY,EAAE,WAAW,EAAE,M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