@funkit/connect 11.2.0 → 11.3.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/clients/{chunk-SU3YSNMB.js → chunk-46L2KJJ4.js} +4 -10
  3. package/dist/clients/chunk-6EU6CXNH.js +20 -0
  4. package/dist/clients/internal/nado/withdrawalCallback.js +2 -2
  5. package/dist/clients/internal/nado/withdrawalForm.js +4 -4
  6. package/dist/clients/lighter.d.ts +4 -30
  7. package/dist/clients/lighter.js +70 -254
  8. package/dist/clients/nado.js +5 -5
  9. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +5 -5
  10. package/dist/clients/polymarket/createPolymarketDepositConfig.d.ts +6 -0
  11. package/dist/clients/polymarket/index.js +9 -9
  12. package/dist/components/FunCheckoutHistory/FunCheckoutHistoryContent.d.ts +3 -1
  13. package/dist/components/FunCheckoutHistory/PendingSuccessScreen.d.ts +3 -1
  14. package/dist/domains/checkout.d.ts +2 -1
  15. package/dist/hooks/track/analytics/claimAnalyticsEvent.d.ts +5 -0
  16. package/dist/hooks/track/analytics/events.d.ts +171 -3
  17. package/dist/hooks/track/analytics/mappers.d.ts +15 -0
  18. package/dist/hooks/track/analytics/quote.d.ts +12 -0
  19. package/dist/hooks/track/analytics/resolveExecutionProgressContext.d.ts +40 -0
  20. package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +71 -3
  21. package/dist/hooks/track/analytics/useTrackExecutionProgressEvents.d.ts +48 -0
  22. package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +18 -0
  23. package/dist/hooks/useIsBlacklistedWithdrawalAddress.d.ts +4 -1
  24. package/dist/index.js +2245 -965
  25. package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutConfirmation.d.ts +2 -1
  26. package/dist/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.d.ts +5 -1
  27. package/dist/modals/CheckoutModal/ConfirmationStep/useTrackDepositQuoteEvents.d.ts +20 -0
  28. package/dist/modals/CheckoutModal/MeldQuotes/useMeldQuotes.d.ts +1 -1
  29. package/dist/modals/CheckoutModal/SourceChange/useTrackSourceChangeEvents.d.ts +10 -0
  30. package/dist/modals/CheckoutModal/TransferToken/useTrackDepositNotificationEvents.d.ts +6 -0
  31. package/dist/modals/CheckoutModal/TransferToken/useTransferTokenTracking.d.ts +9 -3
  32. package/dist/modals/PolymarketPerpsTransfer/recordPerpsTransfer.d.ts +40 -0
  33. package/dist/modals/PolymarketPerpsTransfer/useRecordPerpsTransfer.d.ts +24 -0
  34. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +14 -92
  35. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
  36. package/dist/modals/WithdrawalModal/useTrackWithdrawalEvents.d.ts +1 -0
  37. package/dist/providers/FunkitCheckoutContext/index.d.ts +10 -2
  38. package/dist/providers/FunkitCheckoutContext/types.d.ts +17 -2
  39. package/dist/utils/customer.d.ts +24 -276
  40. package/dist/utils/lighter.d.ts +1 -83
  41. package/dist/utils/signature.d.ts +1 -2
  42. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  43. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  44. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  45. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  46. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  47. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  48. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  49. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  50. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  51. package/dist/wallets/walletConnectors/index.js +47 -47
  52. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  53. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  54. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  55. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  56. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  57. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  58. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  59. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  60. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  61. package/package.json +3 -4
  62. package/dist/clients/chunk-6QCAWEAT.js +0 -53
  63. package/dist/clients/{chunk-XJTRLB7W.js → chunk-L2XMI4EX.js} +8 -8
  64. package/dist/wallets/walletConnectors/{chunk-RB3HR4R2.js → chunk-4NV5BYRP.js} +3 -3
  65. package/dist/wallets/walletConnectors/{chunk-YEZM4CK4.js → chunk-AVDUNQUW.js} +3 -3
  66. package/dist/wallets/walletConnectors/{chunk-MIQTHJ6X.js → chunk-GUQM4QSL.js} +3 -3
  67. package/dist/wallets/walletConnectors/{chunk-4T6ZSRJF.js → chunk-IULPZP2Q.js} +3 -3
  68. package/dist/wallets/walletConnectors/{chunk-HNRB7KJU.js → chunk-JPN6TWIT.js} +3 -3
  69. package/dist/wallets/walletConnectors/{chunk-ZNX4EMPB.js → chunk-KCRO2AGO.js} +3 -3
  70. package/dist/wallets/walletConnectors/{chunk-STVVP43G.js → chunk-KI5Y2BBF.js} +3 -3
  71. package/dist/wallets/walletConnectors/{chunk-X6CGV36L.js → chunk-NR2OGDHQ.js} +3 -3
  72. package/dist/wallets/walletConnectors/{chunk-UK7C2JXW.js → chunk-OEEGYENV.js} +3 -3
  73. package/dist/wallets/walletConnectors/{chunk-F5XEEVG6.js → chunk-OX37G4YT.js} +3 -3
  74. package/dist/wallets/walletConnectors/{chunk-RVOY537T.js → chunk-SWFF3TWJ.js} +3 -3
  75. package/dist/wallets/walletConnectors/{chunk-CPI4TD43.js → chunk-TKB2OY6G.js} +3 -3
  76. package/dist/wallets/walletConnectors/{chunk-2VP2F6EK.js → chunk-W2LCLDPX.js} +3 -3
  77. package/dist/wallets/walletConnectors/{chunk-6BW3HLBG.js → chunk-WAHGI5L7.js} +3 -3
  78. package/dist/wallets/walletConnectors/{chunk-HTHAK6XB.js → chunk-WKNQMP4A.js} +3 -3
  79. package/dist/wallets/walletConnectors/{chunk-VTM6EECM.js → chunk-XCNHV3HS.js} +3 -3
  80. package/dist/wallets/walletConnectors/{chunk-CCQV2ZET.js → chunk-YO2K4MBH.js} +3 -3
  81. package/dist/wallets/walletConnectors/{chunk-VAPGUPHO.js → chunk-YQFGVZGR.js} +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 11.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 86b10f0: Polymarket perps ⇄ predictions transfers are now recorded, so transfer volume appears alongside deposits and withdrawals.
8
+ - 25ed52b: Polymarket transfer handles may now return the rail's identifier, which is then used to key the transfer record.
9
+
10
+ ### Patch Changes
11
+
12
+ - e5d96c1: Centralize submitted execution analytics in a shared progress tracker.
13
+ - 34dced8: Improves checkout confirmation handling for wallet-balance transactions.
14
+ - 2863fb5: Prepares analytics to avoid duplicate progress and settlement events.
15
+ - e2c119b: Add `trackDepositMethodSelected` to the internal deposit analytics hook (not yet wired to any component).
16
+ - 3192b6c: Report brokerage selections consistently across connected and new exchange flows.
17
+ - 7f67517: Report payment-method selections consistently across checkout funding flows.
18
+ - 47f4452: Records wallet-balance deposit transaction submissions in analytics.
19
+ - f0b7d38: Records analytics when a deposit transaction is submitted.
20
+ - 9f4c677: Adds analytics when a displayed deposit quote is confirmed.
21
+ - 93bf78c: Adds analytics when a deposit quote is displayed.
22
+ - 057e064: Preserve deposit quote amounts and fee details in checkout analytics events.
23
+ - 37958f8: Model submitted executions with persisted analytics snapshots.
24
+ - b361db0: Export the Lighter account-by-index query and unstaked-fee helpers from `@funkit/connect-core`.
25
+ - 332d186: Support Lighter withdrawals from the new `@funkit/connect-core/clients/lighter` entry on both web and React Native.
26
+ - aafdbba: Lighter constants and helpers move to the `@funkit/connect-core/clients/lighter` entry.
27
+ - c68c3d6: Share Lighter withdrawal support from `@funkit/connect-core`.
28
+ - d2336bb: Lighter's bridge delay is now a shared `useLighterWithdrawalDelaySeconds` hook, and a main-account index that isn't numeric resolves as unset.
29
+ - faec499: Fire `fc_deposit_method_selected` when entering the Bitcoin Lightning deposit flow, and `fc_deposit_asset_selected` when it's entered by selecting BTC-on-Lightning from the Transfer Crypto chain dropdown.
30
+ - a5c5bed: feat(connect-core): share one Chainalysis address screen across web and React Native — withdrawals now proceed when screening returns no risk level
31
+ - 1b5c4b0: Keep payment-method metadata consistent across deposit analytics events.
32
+ - f0ae438: Persist deposit/withdrawal analytics event dedup across browser sessions instead of resetting each session.
33
+ - bfcfd1e: Resolve submitted execution analytics from persisted checkout history.
34
+ - fb189e7: Route confirmed wallet submissions through shared execution progress tracking.
35
+ - d21e54e: Keep withdrawal recipient screening consistent across web and React Native
36
+ - a6cc332: Renamed `toWithdrawalExecutionErrorCode` to `toWalletExecutionErrorCode` and its `WithdrawalExecutionErrorCode` type to `WalletExecutionErrorCode`.
37
+
38
+ Migration: rename the import — the codes (`insufficient-gas`, `switch-chain`, `generic`) and behavior are unchanged.
39
+
40
+ - 8ac640d: Tracks displayed deposit quotes during checkout.
41
+ - c13b6a7: Prepare nullable quote-fee analytics for polling and notification events wired in follow-up changes.
42
+ - f39b525: Track when deposit notifications are displayed, dismissed, or expanded.
43
+ - 7363b9a: Track Transfer Crypto token, chain, and address-copy interactions.
44
+ - ed08150: Track failed executions from persisted progress updates.
45
+ - 5796c54: Track the best available Meld quote across deposit amount and provider screens.
46
+ - 3e83583: Add `fc_modal_opened` analytics tracking.
47
+ - a38347e: Track submitted executions from checkout history polling.
48
+ - 6ab0890: Track submitted executions from displayed checkout notifications.
49
+ - d6caeb8: Track successful executions from persisted progress updates.
50
+ - 2ae5b72: Add `fc_tab_switched` analytics tracking.
51
+ - b1941d4: Track submitted, successful, and failed withdrawals from progress updates.
52
+ - 225add6: Track amount selection when users confirm a withdrawal.
53
+ - bfb445d: Track when users confirm a withdrawal amount.
54
+ - bd76c6c: Track when users open the withdrawal modal.
55
+ - Updated dependencies [856057c]
56
+ - Updated dependencies [b361db0]
57
+ - Updated dependencies [332d186]
58
+ - Updated dependencies [aafdbba]
59
+ - Updated dependencies [c68c3d6]
60
+ - Updated dependencies [d2336bb]
61
+ - Updated dependencies [35b64db]
62
+ - Updated dependencies [a5c5bed]
63
+ - Updated dependencies [86b10f0]
64
+ - Updated dependencies [a6cc332]
65
+ - Updated dependencies [3a6351a]
66
+ - @funkit/fun-relay@2.11.0
67
+ - @funkit/connect-core@3.0.0
68
+
3
69
  ## 11.2.0
4
70
 
5
71
  ### Minor Changes
@@ -34,12 +34,12 @@ import {
34
34
  signTypedData,
35
35
  switchChain
36
36
  } from "./chunk-OODIKHYE.js";
37
- import {
38
- i18n_default
39
- } from "./chunk-C45VNQXY.js";
40
37
  import {
41
38
  generateClientMetadataForTokenTransfer
42
39
  } from "./chunk-PENJ5JGH.js";
40
+ import {
41
+ i18n_default
42
+ } from "./chunk-C45VNQXY.js";
43
43
  import {
44
44
  logger
45
45
  } from "./chunk-AHYOV7AV.js";
@@ -52,13 +52,7 @@ import {
52
52
  import { isEVMAddressEquivalent } from "@funkit/utils";
53
53
 
54
54
  // src/utils/signature.ts
55
- function isUserRejectedError(error) {
56
- if (!(error instanceof Error)) {
57
- return false;
58
- }
59
- const regex = /user\s?rejected/gi;
60
- return regex.test(error.name) || regex.test(error.message);
61
- }
55
+ import { isSwitchChainError, isUserRejectedError } from "@funkit/connect-core";
62
56
 
63
57
  // src/clients/internal/nado/withdrawalCallback.ts
64
58
  var NadoWithdrawalInputError = class extends Error {
@@ -0,0 +1,20 @@
1
+ "use client";
2
+
3
+ // src/utils/customer.ts
4
+ import {
5
+ useLighterAccountQuery,
6
+ useLighterAccountsQuery
7
+ } from "@funkit/connect-core";
8
+ import {
9
+ LIGHTER_TRADING_MODE,
10
+ getLighterAccount,
11
+ getLighterAccountsByL1Address,
12
+ useInvalidateLighterAccount,
13
+ useLighterAccountQuery as useLighterAccountQuery2,
14
+ useLighterAccountsQuery as useLighterAccountsQuery2
15
+ } from "@funkit/connect-core";
16
+
17
+ export {
18
+ useLighterAccountQuery2 as useLighterAccountQuery,
19
+ useLighterAccountsQuery2 as useLighterAccountsQuery
20
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createNadoWithdrawalCallback
4
- } from "../../chunk-SU3YSNMB.js";
4
+ } from "../../chunk-46L2KJJ4.js";
5
5
  import "../../chunk-2576N7PQ.js";
6
6
  import "../../chunk-VIAEAD75.js";
7
7
  import "../../chunk-63XTVHO3.js";
@@ -12,8 +12,8 @@ import "../../chunk-3P2C436B.js";
12
12
  import "../../chunk-WZRW6WUM.js";
13
13
  import "../../chunk-Z7HTQFEO.js";
14
14
  import "../../chunk-OODIKHYE.js";
15
- import "../../chunk-C45VNQXY.js";
16
15
  import "../../chunk-PENJ5JGH.js";
16
+ import "../../chunk-C45VNQXY.js";
17
17
  import "../../chunk-AHYOV7AV.js";
18
18
  export {
19
19
  createNadoWithdrawalCallback
@@ -4,12 +4,12 @@ import {
4
4
  useNadoMaxWithdrawable
5
5
  } from "../../chunk-FM7SFGAV.js";
6
6
  import "../../chunk-JFDRLSYM.js";
7
- import {
8
- isNadoWithdrawalConfig
9
- } from "../../chunk-QQEGNLGD.js";
10
7
  import {
11
8
  safeBigInt
12
9
  } from "../../chunk-63XTVHO3.js";
10
+ import {
11
+ isNadoWithdrawalConfig
12
+ } from "../../chunk-QQEGNLGD.js";
13
13
  import "../../chunk-DGBIV3ZS.js";
14
14
  import {
15
15
  x18ToRawBaseUnit,
@@ -23,7 +23,7 @@ import {
23
23
  useGeneralWallet
24
24
  } from "../../chunk-BPDLF2R6.js";
25
25
  import "../../chunk-5MY7WMEJ.js";
26
- import "../../chunk-6QCAWEAT.js";
26
+ import "../../chunk-6EU6CXNH.js";
27
27
  import {
28
28
  useFunkitConfig
29
29
  } from "../../chunk-UK64SY6N.js";
@@ -14,32 +14,12 @@
14
14
  * caller provides the actual on-chain implementation.
15
15
  */
16
16
  import { type Address } from 'viem';
17
+ import { type LighterSigner } from '@funkit/connect-core/clients/lighter';
17
18
  import type { CustomWithdrawalConfig, LighterRouteType, MultiMethodWithdrawalConfig, SourceTokenOption, WithdrawalSourceTokenBalanceParams } from '../providers/FunkitCheckoutContext/types';
18
- export { LIGHTER_ROUTE_TYPE } from '../modals/WithdrawalModal/LighterWithdrawal';
19
+ export { LIGHTER_ROUTE_TYPE } from '@funkit/connect-core/clients/lighter';
19
20
  export type { LighterRouteType } from '../providers/FunkitCheckoutContext/types';
20
- export { LIGHTER_WITHDRAW_ABI, buildLighterL1WithdrawTransaction, isLighterWithdrawalRateLimitError, lighterWithdrawBaseUnits, } from '../utils/lighter';
21
- export type LighterTransferParams = {
22
- toAccountIndex: number;
23
- assetIndex: number;
24
- fromRouteType: number;
25
- toRouteType: number;
26
- amount: number;
27
- usdcFee: number;
28
- memo: string;
29
- ethSigner?: {
30
- signMessage: (message: string) => Promise<string>;
31
- };
32
- nonce?: number;
33
- };
34
- export type LighterTransaction = {
35
- hash: string;
36
- status: number | 'pending' | 'confirmed' | 'failed';
37
- block_height?: number;
38
- message?: string;
39
- };
40
- export type LighterSigner = {
41
- transfer: (params: LighterTransferParams) => Promise<[unknown, string, string | null]>;
42
- };
21
+ export type { LighterSigner, LighterTransaction, LighterTransferParams, } from '@funkit/connect-core/clients/lighter';
22
+ export { LIGHTER_WITHDRAW_ABI, buildLighterL1WithdrawTransaction, isLighterWithdrawalRateLimitError, lighterWithdrawBaseUnits, } from '@funkit/connect-core/clients/lighter';
43
23
  export interface LighterWithdrawalConfig {
44
24
  /**
45
25
  * The connected user's L1 address. The hook resolves the Lighter account
@@ -85,12 +65,6 @@ export interface LighterWithdrawalConfig {
85
65
  */
86
66
  onBeforeSign?: () => Promise<void> | void;
87
67
  }
88
- /**
89
- * Default minimum Secure-withdrawal amounts (token units) for known Lighter
90
- * assets. Used as a fallback when `LighterWithdrawalConfig.getSecureMinWithdrawalAmount`
91
- * is omitted or returns `undefined` for a symbol.
92
- */
93
- export declare const LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS: Record<string, number>;
94
68
  export interface LighterSecureWithdrawalCallbackParams {
95
69
  /** Withdrawal amount in token units (e.g. "1.5" for 1.5 ETH). */
96
70
  amountTokenUnits: string;
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  useLighterAccountQuery,
13
13
  useLighterAccountsQuery
14
- } from "./chunk-6QCAWEAT.js";
14
+ } from "./chunk-6EU6CXNH.js";
15
15
  import {
16
16
  useFunkitConfig
17
17
  } from "./chunk-UK64SY6N.js";
@@ -35,12 +35,10 @@ import {
35
35
  } from "@funkit/api-base";
36
36
  import { LIGHTER_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
37
37
  import { RELAY_LIGHTER_CHAIN_ID as RELAY_LIGHTER_CHAIN_ID2 } from "@funkit/fun-relay";
38
- import { retry } from "@lifeomic/attempt";
39
- import { useQuery as useQuery2 } from "@tanstack/react-query";
40
38
  import i18next from "i18next";
41
39
  import React4, { useMemo as useMemo2 } from "react";
42
40
  import { v4 as uuid2 } from "uuid";
43
- import { pad as pad2, parseUnits as parseUnits3, toHex } from "viem";
41
+ import { pad as pad2, parseUnits as parseUnits2, toHex } from "viem";
44
42
  import { arbitrum, base, bsc, mainnet as mainnet2, optimism } from "viem/chains";
45
43
 
46
44
  // src/components/ChainIcon/ChainIcon.tsx
@@ -156,6 +154,19 @@ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React2.createElement(
156
154
  )
157
155
  );
158
156
 
157
+ // src/clients/lighter.tsx
158
+ import {
159
+ LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS as LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2,
160
+ LIGHTER_FAST_MAX_WITHDRAWAL_USD as LIGHTER_FAST_MAX_WITHDRAWAL_USD2,
161
+ LIGHTER_SECURE_ASSETS_BY_INDEX as LIGHTER_SECURE_ASSETS_BY_INDEX2,
162
+ LIGHTER_USDC_SPOT_SYMBOL as LIGHTER_USDC_SPOT_SYMBOL2,
163
+ getLighterBaseSymbol as getLighterBaseSymbol3
164
+ } from "@funkit/connect-core/clients/lighter";
165
+ import {
166
+ createLighterAdaptedWallet,
167
+ useLighterWithdrawalDelaySeconds
168
+ } from "@funkit/connect-core/clients/lighter";
169
+
159
170
  // src/modals/WithdrawalModal/LighterWithdrawal.tsx
160
171
  import {
161
172
  DirectExecutionType,
@@ -172,68 +183,9 @@ import React3, {
172
183
  useState
173
184
  } from "react";
174
185
  import { createPortal } from "react-dom";
175
- import { numberToHex, pad, parseUnits as parseUnits2 } from "viem";
186
+ import { numberToHex, pad, parseUnits } from "viem";
176
187
  import { mainnet } from "viem/chains";
177
188
 
178
- // src/utils/lighter.ts
179
- import {
180
- encodeFunctionData,
181
- getAddress,
182
- parseUnits
183
- } from "viem";
184
- var LIGHTER_DEPOSIT_ADDRESS = getAddress(
185
- "0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7"
186
- );
187
- var LIGHTER_SLOW_DEPOSIT_TIME_ESTIMATE_SECONDS = 60 * 2;
188
- var LIGHTER_DELAYED_AUTO_TRIGGER_CUTOFF = 60 * 5;
189
- var LIGHTER_USDC_ASSET_INDEX = 3;
190
- var LIGHTER_WITHDRAW_ABI = [
191
- {
192
- type: "function",
193
- name: "withdraw",
194
- stateMutability: "nonpayable",
195
- inputs: [
196
- { name: "accountIndex", type: "uint48" },
197
- { name: "assetIndex", type: "uint16" },
198
- { name: "routeType", type: "uint8" },
199
- { name: "amount", type: "uint64" }
200
- ],
201
- outputs: []
202
- }
203
- ];
204
- function truncateToDecimals(amount, decimals) {
205
- const [whole = "0", frac = ""] = amount.split(".");
206
- if (frac.length <= decimals) {
207
- return amount;
208
- }
209
- const truncated = frac.slice(0, decimals);
210
- return truncated ? `${whole}.${truncated}` : whole;
211
- }
212
- function lighterWithdrawBaseUnits(assetIndex, amountTokenUnits) {
213
- const decimals = assetIndex === LIGHTER_USDC_ASSET_INDEX ? 6 : 8;
214
- return parseUnits(truncateToDecimals(amountTokenUnits, decimals), decimals);
215
- }
216
- function buildLighterL1WithdrawTransaction(params) {
217
- const { accountIndex, assetIndex, routeType, amountBaseUnit } = params;
218
- const data = encodeFunctionData({
219
- abi: LIGHTER_WITHDRAW_ABI,
220
- functionName: "withdraw",
221
- args: [accountIndex, assetIndex, routeType, amountBaseUnit]
222
- });
223
- return { to: LIGHTER_DEPOSIT_ADDRESS, data, value: 0n };
224
- }
225
- function isLighterWithdrawalRateLimitError(error) {
226
- if (error && typeof error === "object" && "code" in error) {
227
- const code = error.code;
228
- if (code === 23004 || code === 23005) {
229
- return true;
230
- }
231
- }
232
- const raw = error instanceof Error ? error.message : typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : "";
233
- const message = raw.toLowerCase();
234
- return message.includes("23004") || message.includes("23005") || message.includes("rate limit") || message.includes("ratelimit");
235
- }
236
-
237
189
  // src/utils/tokenIconUrl.ts
238
190
  var getLocalTokenIconUrl = (symbol) => {
239
191
  return ASSET_LOGO_SRCS[symbol.toUpperCase()] || `https://sdk-cdn.fun.xyz/images/${encodeURIComponent(symbol.toLowerCase())}.svg`;
@@ -264,52 +216,53 @@ function formatSecondsTranslated(seconds, t, specifyUnderMinute = false, omitSec
264
216
  }
265
217
 
266
218
  // src/modals/WithdrawalModal/LighterWithdrawal.tsx
219
+ import {
220
+ LIGHTER_ROUTE_TYPE,
221
+ LIGHTER_STAKING_POOL_INDEX,
222
+ buildLighterL1WithdrawTransaction,
223
+ findLighterStakingShare,
224
+ getLighterBaseSymbol,
225
+ isLighterWithdrawalRateLimitError,
226
+ lighterWithdrawBaseUnits,
227
+ resolveLighterSharePrice,
228
+ resolveLighterUnstakedFeeTokens,
229
+ resolveLighterWithdrawalExplorerUrl,
230
+ truncateToDecimals
231
+ } from "@funkit/connect-core/clients/lighter";
232
+ import {
233
+ LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS,
234
+ LIGHTER_FAST_MAX_WITHDRAWAL_USD,
235
+ LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE2,
236
+ LIGHTER_SECURE_ASSETS_BY_INDEX,
237
+ LIGHTER_STAKING_POOL_INDEX as LIGHTER_STAKING_POOL_INDEX2,
238
+ LIGHTER_STAKING_THRESHOLD_LIT,
239
+ LIGHTER_UNSTAKED_FEE_TOKENS,
240
+ LIGHTER_USDC_SPOT_SYMBOL,
241
+ getLighterBaseSymbol as getLighterBaseSymbol2,
242
+ getLighterSecureMainnetAddress,
243
+ resolveLighterAssetIndex,
244
+ resolveLighterSecureRouteType,
245
+ resolveLighterSharePrice as resolveLighterSharePrice2,
246
+ resolveLighterUnstakedFeeTokens as resolveLighterUnstakedFeeTokens2
247
+ } from "@funkit/connect-core/clients/lighter";
267
248
  var LIGHTER_FAST_METHOD_ID = "lighter-fast";
268
249
  var LIGHTER_SECURE_METHOD_ID = "lighter-secure";
269
- var LIGHTER_USDC_SPOT_SYMBOL = "USDC (Spot)";
270
- var LIGHTER_ROUTE_TYPE = {
271
- PERPS: 0,
272
- SPOT: 1
273
- };
274
- function getLighterBaseSymbol(symbol) {
275
- return symbol.replace(/\s*\((?:spot|perps)\)\s*$/i, "");
276
- }
277
- var LIGHTER_FAST_MAX_WITHDRAWAL_USD = 3e6;
278
250
 
279
251
  // src/clients/lighter.tsx
252
+ import { truncateToDecimals as truncateToDecimals2 } from "@funkit/connect-core/clients/lighter";
253
+ import { LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE3 } from "@funkit/connect-core/clients/lighter";
254
+ import {
255
+ LIGHTER_WITHDRAW_ABI,
256
+ buildLighterL1WithdrawTransaction as buildLighterL1WithdrawTransaction2,
257
+ isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2,
258
+ lighterWithdrawBaseUnits as lighterWithdrawBaseUnits2
259
+ } from "@funkit/connect-core/clients/lighter";
280
260
  var LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
281
261
  var MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
282
- var LIGHTER_SECURE_ASSETS_BY_INDEX = {
283
- 1: { symbol: "ETH", decimals: 18 },
284
- 2: { symbol: "LIT", decimals: 18 },
285
- 3: { symbol: "USDC", decimals: 6 },
286
- 5: { symbol: "LINK", decimals: 18 },
287
- 6: { symbol: "UNI", decimals: 18 },
288
- 7: { symbol: "AAVE", decimals: 18 },
289
- 8: { symbol: "SKY", decimals: 18 },
290
- 9: { symbol: "LDO", decimals: 18 },
291
- 10: { symbol: "AZTEC", decimals: 18 }
292
- };
293
- var LIGHTER_API_BASE = "https://mainnet.zklighter.elliot.ai";
294
- async function getLighterWithdrawalDelay() {
295
- const response = await fetch(`${LIGHTER_API_BASE}/api/v1/withdrawalDelay`);
296
- if (!response.ok) {
297
- throw new Error(
298
- `Failed to fetch Lighter withdrawal delay: ${response.statusText}`
299
- );
300
- }
301
- return response.json();
302
- }
303
262
  function useLighterSecureDelayText() {
304
263
  const { t } = useFunkitTranslation();
305
- const query = useQuery2({
306
- queryKey: ["lighterWithdrawalDelay"],
307
- queryFn: getLighterWithdrawalDelay,
308
- staleTime: 6e4,
309
- retry: 2
310
- });
311
- const seconds = query.data?.seconds;
312
- if (seconds === void 0 || !Number.isFinite(seconds) || seconds <= 0) {
264
+ const seconds = useLighterWithdrawalDelaySeconds();
265
+ if (seconds === void 0) {
313
266
  return void 0;
314
267
  }
315
268
  return formatSecondsTranslated(
@@ -321,140 +274,6 @@ function useLighterSecureDelayText() {
321
274
  true
322
275
  );
323
276
  }
324
- var LIGHTER_TX_STATUS = {
325
- PENDING: 0,
326
- QUEUED: 1,
327
- COMMITTED: 2,
328
- EXECUTED: 3,
329
- FAILED: 4,
330
- REJECTED: 5
331
- };
332
- function coerceLighterStatus(status) {
333
- if (typeof status === "number") {
334
- return status;
335
- }
336
- switch (status) {
337
- case "confirmed":
338
- return LIGHTER_TX_STATUS.EXECUTED;
339
- case "failed":
340
- return LIGHTER_TX_STATUS.FAILED;
341
- default:
342
- return LIGHTER_TX_STATUS.PENDING;
343
- }
344
- }
345
- var LighterTerminalError = class extends Error {
346
- };
347
- async function pollLighterTransaction(txHash, options) {
348
- const { pollIntervalMs, maxAttempts, waitFor } = options;
349
- return retry(
350
- async () => {
351
- const resp = await fetch(
352
- `${LIGHTER_API_BASE}/api/v1/tx?by=hash&value=${txHash}`
353
- );
354
- if (!resp.ok) {
355
- throw new Error(`Lighter API error ${resp.status} for tx ${txHash}`);
356
- }
357
- const tx = await resp.json();
358
- if (!tx.hash) {
359
- throw new Error(`Lighter tx ${txHash} not found yet`);
360
- }
361
- const status = coerceLighterStatus(tx.status ?? LIGHTER_TX_STATUS.PENDING);
362
- if (status === LIGHTER_TX_STATUS.FAILED || status === LIGHTER_TX_STATUS.REJECTED) {
363
- const label = status === LIGHTER_TX_STATUS.FAILED ? "failed" : "rejected";
364
- throw new LighterTerminalError(
365
- `Lighter transaction ${label}: ${tx.message ?? "unknown error"}`
366
- );
367
- }
368
- if (waitFor === "findable") {
369
- return tx;
370
- }
371
- if (status === LIGHTER_TX_STATUS.COMMITTED || status === LIGHTER_TX_STATUS.EXECUTED) {
372
- return tx;
373
- }
374
- throw new Error(
375
- `Lighter transaction ${txHash} did not reach '${waitFor}' after ${maxAttempts} attempts`
376
- );
377
- },
378
- {
379
- maxAttempts,
380
- delay: pollIntervalMs,
381
- factor: 1,
382
- jitter: false,
383
- handleError: (err, context) => {
384
- if (err instanceof LighterTerminalError) {
385
- context.abort();
386
- }
387
- }
388
- }
389
- );
390
- }
391
- function createLighterAdaptedWallet({
392
- signerClient,
393
- accountIndex
394
- }) {
395
- async function handleSendTransactionStep(_chainId, stepItem) {
396
- const action = stepItem.data?.action;
397
- if (!action || action.type !== "transfer") {
398
- throw new Error(
399
- `Unsupported Lighter action: ${action?.type ?? "undefined"}`
400
- );
401
- }
402
- const p = action.parameters;
403
- logger.info("lighter:wallet:transfer", p);
404
- const [, txHash, error] = await signerClient.transfer({
405
- toAccountIndex: p.toAccountIndex,
406
- assetIndex: p.assetIndex,
407
- fromRouteType: p.fromRouteType,
408
- toRouteType: p.toRouteType,
409
- amount: p.amount,
410
- usdcFee: p.usdcFee,
411
- memo: p.memo
412
- });
413
- if (error) {
414
- throw new Error(`Lighter transfer failed: ${error}`);
415
- }
416
- if (!txHash) {
417
- throw new Error("Lighter transfer returned no transaction hash");
418
- }
419
- logger.info("lighter:wallet:transfer:done", { txHash });
420
- return txHash;
421
- }
422
- return {
423
- vmType: "lvm",
424
- getChainId: async () => Number(RELAY_LIGHTER_CHAIN_ID2),
425
- address: async () => accountIndex.toString(),
426
- handleSignMessageStep: async () => {
427
- throw new Error("Message signing not implemented for Lighter");
428
- },
429
- handleSendTransactionStep,
430
- handleConfirmTransactionStep: async (txHash) => {
431
- const tx = await pollLighterTransaction(txHash, {
432
- pollIntervalMs: 2e3,
433
- maxAttempts: 60,
434
- waitFor: "findable"
435
- });
436
- return {
437
- txHash: tx.hash,
438
- blockHeight: tx.block_height ?? 0,
439
- status: tx.status
440
- };
441
- },
442
- // biome-ignore lint/suspicious/noEmptyBlockStatements: Lighter is single-chain — no switching needed
443
- switchChain: async () => {
444
- }
445
- };
446
- }
447
- var LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS = {
448
- USDC: 1,
449
- ETH: 1e-3,
450
- LIT: 1,
451
- LINK: 0.1,
452
- UNI: 0.2,
453
- AAVE: 0.01,
454
- SKY: 20,
455
- LDO: 2,
456
- AZTEC: 100
457
- };
458
277
  async function trackLighterSecureWithdrawal({
459
278
  apiKey,
460
279
  userId,
@@ -465,7 +284,7 @@ async function trackLighterSecureWithdrawal({
465
284
  amountTokenUnits,
466
285
  withdrawalUSD
467
286
  }) {
468
- const assetMeta = LIGHTER_SECURE_ASSETS_BY_INDEX[assetIndex];
287
+ const assetMeta = LIGHTER_SECURE_ASSETS_BY_INDEX2[assetIndex];
469
288
  if (!assetMeta) {
470
289
  logger.error(
471
290
  "lighter:withdrawal:secure:tracking:unknownAssetIndex",
@@ -476,8 +295,8 @@ async function trackLighterSecureWithdrawal({
476
295
  }
477
296
  const { symbol, decimals } = assetMeta;
478
297
  const estTotalUsd = Number(withdrawalUSD);
479
- const safeAmount = truncateToDecimals(amountTokenUnits, decimals);
480
- const baseUnitAmount = parseUnits3(safeAmount, decimals).toString();
298
+ const safeAmount = truncateToDecimals2(amountTokenUnits, decimals);
299
+ const baseUnitAmount = parseUnits2(safeAmount, decimals).toString();
481
300
  const fromTokenAddress = pad2(toHex(assetIndex), { size: 20 });
482
301
  await createDirectExecution2({
483
302
  apiKey,
@@ -629,8 +448,8 @@ function buildLighterSourceTokenOptions({
629
448
  ).map((asset) => {
630
449
  if (asset.symbol.toUpperCase() === "USDC") {
631
450
  return {
632
- symbol: LIGHTER_USDC_SPOT_SYMBOL,
633
- label: LIGHTER_USDC_SPOT_SYMBOL,
451
+ symbol: LIGHTER_USDC_SPOT_SYMBOL2,
452
+ label: LIGHTER_USDC_SPOT_SYMBOL2,
634
453
  iconSrc: getTokenIconUrl("USDC")
635
454
  };
636
455
  }
@@ -654,7 +473,8 @@ function buildLighterFastWalletWithdrawalConfig({
654
473
  }) {
655
474
  const adaptedWallet = createLighterAdaptedWallet({
656
475
  signerClient,
657
- accountIndex
476
+ accountIndex,
477
+ logger
658
478
  });
659
479
  const wallet = {
660
480
  _type: "lighter",
@@ -688,7 +508,7 @@ function buildLighterFastWalletWithdrawalConfig({
688
508
  sourceTokenAddress: LIGHTER_USDC_PERPS_ADDRESS,
689
509
  iconSrc: iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
690
510
  getMinWithdrawalUSD: () => 4,
691
- getMaxWithdrawalUSD: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD
511
+ getMaxWithdrawalUSD: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD2
692
512
  };
693
513
  }
694
514
  function ChainIconStack({ chainIds }) {
@@ -746,7 +566,7 @@ function buildLighterMultiMethodConfig({
746
566
  if (userMin !== void 0) {
747
567
  return userMin;
748
568
  }
749
- return LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS[getLighterBaseSymbol(symbol).toUpperCase()] ?? 0;
569
+ return LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2[getLighterBaseSymbol3(symbol).toUpperCase()] ?? 0;
750
570
  }
751
571
  });
752
572
  const fast = {
@@ -778,13 +598,10 @@ function buildLighterMultiMethodConfig({
778
598
  }
779
599
  function useLighterWithdrawalConfig(config) {
780
600
  const { t } = useFunkitTranslation();
781
- const { mainAccountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({
782
- address: config?.l1Address
783
- });
784
- const accountIndex = mainAccountIndex && /^\d+$/.test(mainAccountIndex) ? mainAccountIndex : void 0;
601
+ const { mainAccountIndex: accountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({ address: config?.l1Address });
785
602
  const secureDelayText = useLighterSecureDelayText();
786
603
  const { account } = useLighterAccountQuery(
787
- // Validated numeric above, so the template-literal narrowing is safe.
604
+ // The query validates it as numeric, so the template-literal narrowing holds.
788
605
  accountIndex ? { by: "index", value: accountIndex } : null
789
606
  );
790
607
  const assets = useMemo2(() => account?.assets ?? [], [account]);
@@ -803,14 +620,13 @@ function useLighterWithdrawalConfig(config) {
803
620
  }, [config, accountIndex, t, secureDelayText, isUnifiedTradingMode, assets]);
804
621
  }
805
622
  export {
806
- LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS,
807
- LIGHTER_ROUTE_TYPE,
623
+ LIGHTER_ROUTE_TYPE3 as LIGHTER_ROUTE_TYPE,
808
624
  LIGHTER_WITHDRAW_ABI,
809
- buildLighterL1WithdrawTransaction,
625
+ buildLighterL1WithdrawTransaction2 as buildLighterL1WithdrawTransaction,
810
626
  buildLighterSourceTokenOptions,
811
627
  createLighterSecureWithdrawalConfig,
812
- isLighterWithdrawalRateLimitError,
813
- lighterWithdrawBaseUnits,
628
+ isLighterWithdrawalRateLimitError2 as isLighterWithdrawalRateLimitError,
629
+ lighterWithdrawBaseUnits2 as lighterWithdrawBaseUnits,
814
630
  trackLighterSecureWithdrawal,
815
631
  useLighterWithdrawalConfig
816
632
  };
@@ -1,13 +1,13 @@
1
1
  "use client";
2
- import {
3
- resolveNadoSubaccount
4
- } from "./chunk-QQEGNLGD.js";
5
2
  import {
6
3
  createNadoWithdrawalCallback
7
- } from "./chunk-SU3YSNMB.js";
4
+ } from "./chunk-46L2KJJ4.js";
8
5
  import "./chunk-2576N7PQ.js";
9
6
  import "./chunk-VIAEAD75.js";
10
7
  import "./chunk-63XTVHO3.js";
8
+ import {
9
+ resolveNadoSubaccount
10
+ } from "./chunk-QQEGNLGD.js";
11
11
  import "./chunk-DGBIV3ZS.js";
12
12
  import "./chunk-6T6URLBM.js";
13
13
  import "./chunk-TZGKB6WY.js";
@@ -17,6 +17,7 @@ import {
17
17
  import "./chunk-WZRW6WUM.js";
18
18
  import "./chunk-Z7HTQFEO.js";
19
19
  import "./chunk-OODIKHYE.js";
20
+ import "./chunk-PENJ5JGH.js";
20
21
  import {
21
22
  useAccount,
22
23
  useConfig
@@ -24,7 +25,6 @@ import {
24
25
  import {
25
26
  i18n_default
26
27
  } from "./chunk-C45VNQXY.js";
27
- import "./chunk-PENJ5JGH.js";
28
28
  import "./chunk-AHYOV7AV.js";
29
29
 
30
30
  // src/clients/nado.tsx