@funkit/connect 10.3.0 → 10.5.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 (107) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/clients/chunk-2YWQL3AO.js +46 -0
  3. package/dist/clients/chunk-A4WQS6QG.js +207 -0
  4. package/dist/clients/chunk-BNMZM23Q.js +42 -0
  5. package/dist/clients/{chunk-HOORQPSY.js → chunk-F6P4CN27.js} +24 -8
  6. package/dist/clients/chunk-FJ6GCMJ4.js +29 -0
  7. package/dist/clients/chunk-II5CZTBC.js +18 -0
  8. package/dist/clients/chunk-L2KSNS7H.js +112 -0
  9. package/dist/clients/chunk-OZ3KD24N.js +107 -0
  10. package/dist/clients/{chunk-3STGJU6Z.js → chunk-QHS5N7GP.js} +2 -2
  11. package/dist/clients/{chunk-RWCJ4XGX.js → chunk-WRS7AFM2.js} +31 -2
  12. package/dist/clients/fanatics.js +1 -1
  13. package/dist/clients/internal/nado/consts.d.ts +16 -0
  14. package/dist/clients/internal/nado/consts.js +13 -0
  15. package/dist/clients/internal/nado/encoding.d.ts +22 -0
  16. package/dist/clients/internal/nado/encoding.js +32 -0
  17. package/dist/clients/internal/nado/errors.d.ts +55 -0
  18. package/dist/clients/internal/nado/errors.js +15 -0
  19. package/dist/clients/internal/nado/fetch.d.ts +15 -0
  20. package/dist/clients/internal/nado/fetch.js +9 -0
  21. package/dist/clients/internal/nado/gateway.d.ts +83 -0
  22. package/dist/clients/internal/nado/gateway.js +23 -0
  23. package/dist/clients/internal/nado/hooks.d.ts +360 -0
  24. package/dist/clients/internal/nado/hooks.js +132 -0
  25. package/dist/clients/internal/nado/indexer.d.ts +43 -0
  26. package/dist/clients/internal/nado/indexer.js +13 -0
  27. package/dist/clients/internal/nado/products.d.ts +36 -0
  28. package/dist/clients/internal/nado/products.js +19 -0
  29. package/dist/clients/internal/nado/typedData.d.ts +80 -0
  30. package/dist/clients/internal/nado/typedData.js +43 -0
  31. package/dist/clients/internal/nado/withdrawalConfig.d.ts +11 -0
  32. package/dist/clients/internal/nado/withdrawalConfig.js +17 -0
  33. package/dist/clients/internal/nado/withdrawalTypes.d.ts +30 -0
  34. package/dist/clients/internal/nado/withdrawalTypes.js +1 -0
  35. package/dist/clients/lighter.d.ts +1 -0
  36. package/dist/clients/lighter.js +202 -57
  37. package/dist/clients/mallard.js +9 -24
  38. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  39. package/dist/clients/polymarket/index.js +3 -3
  40. package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
  41. package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
  42. package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
  43. package/dist/hooks/useChainMetadata.d.ts +11 -0
  44. package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +2 -1
  45. package/dist/hooks/usePaymentMethodTabs.d.ts +8 -2
  46. package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
  47. package/dist/hooks/useSwappedPreload.d.ts +7 -11
  48. package/dist/hooks/useUserIpInfo.d.ts +1 -19
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +3700 -3299
  51. package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +3 -0
  52. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframe.d.ts +4 -1
  53. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +3 -0
  54. package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +3 -2
  55. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +46 -2
  56. package/dist/modals/WithdrawalModal/useFiatWithdrawal.d.ts +1 -1
  57. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -15
  58. package/dist/providers/FunkitCheckoutContext/types.d.ts +73 -14
  59. package/dist/providers/FunkitConfigContext.d.ts +11 -0
  60. package/dist/providers/GeneralWalletProvider.d.ts +1 -4
  61. package/dist/providers/SwappedProvider.d.ts +5 -3
  62. package/dist/utils/lighter.d.ts +68 -1
  63. package/dist/utils/purifyCheckoutHistoryItem.d.ts +2 -41
  64. package/dist/utils/swapped.d.ts +1 -1
  65. package/dist/utils/tokenIconUrl.d.ts +5 -0
  66. package/dist/utils/userInfo.d.ts +8 -0
  67. package/dist/utils/withdrawal.d.ts +2 -1
  68. package/dist/wagmi/actions.d.ts +1 -1
  69. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  70. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  71. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  72. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  73. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  74. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  75. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  76. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  77. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  78. package/dist/wallets/walletConnectors/index.js +33 -33
  79. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  80. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  81. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  82. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  83. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  84. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  85. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  86. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  87. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  88. package/package.json +3 -2
  89. package/dist/hooks/useSkipSwappedPreload.d.ts +0 -7
  90. package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
  91. package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
  92. package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
  93. package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
  94. package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
  95. package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
  96. package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
  97. package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
  98. package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
  99. package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
  100. package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
  101. package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
  102. package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
  103. package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
  104. package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
  105. package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
  106. package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
  107. package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import {
3
+ INK_CHAIN_ID,
4
+ NADO_EIP712_VERIFYING_CONTRACT_ADDRESS
5
+ } from "../../chunk-II5CZTBC.js";
6
+
7
+ // src/clients/internal/nado/typedData.ts
8
+ var WITHDRAW_COLLATERAL_V2_TYPES = {
9
+ WithdrawCollateralV2: [
10
+ { name: "sender", type: "bytes32" },
11
+ { name: "productId", type: "uint32" },
12
+ { name: "amount", type: "uint128" },
13
+ { name: "nonce", type: "uint64" },
14
+ { name: "sendTo", type: "address" },
15
+ // Reserved by Nado — must be signed as 0
16
+ { name: "appendix", type: "uint128" }
17
+ ]
18
+ };
19
+ function buildWithdrawCollateralV2TypedData(params) {
20
+ return {
21
+ domain: {
22
+ name: "Nado",
23
+ version: "0.0.1",
24
+ chainId: INK_CHAIN_ID,
25
+ verifyingContract: NADO_EIP712_VERIFYING_CONTRACT_ADDRESS
26
+ },
27
+ types: WITHDRAW_COLLATERAL_V2_TYPES,
28
+ primaryType: "WithdrawCollateralV2",
29
+ message: {
30
+ sender: params.sender,
31
+ productId: params.productId,
32
+ amount: params.amount,
33
+ nonce: params.nonce,
34
+ sendTo: params.sendTo,
35
+ appendix: 0n
36
+ // set to 0, Nado reserved
37
+ }
38
+ };
39
+ }
40
+ export {
41
+ WITHDRAW_COLLATERAL_V2_TYPES,
42
+ buildWithdrawCollateralV2TypedData
43
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Nado withdrawal config type + guard. SDK-private — the `clients/internal/*`
3
+ * exports map blocks consumer imports; the public `clients/nado.tsx` module
4
+ * re-exports `NadoWithdrawalConfig` for integrators.
5
+ */
6
+ import type { CustomWithdrawalConfig, FunkitWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
7
+ import type { NadoWithdrawalCustomerConfig } from './withdrawalTypes';
8
+ export interface NadoWithdrawalConfig extends CustomWithdrawalConfig {
9
+ customerConfig: NadoWithdrawalCustomerConfig;
10
+ }
11
+ export declare function isNadoWithdrawalConfig(config: FunkitWithdrawalConfig | null | undefined): config is NadoWithdrawalConfig;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../chunk-AHYOV7AV.js";
3
+
4
+ // src/utils/withdrawal.ts
5
+ import { isEVMAddressEquivalent, isTokenEquivalent } from "@funkit/utils";
6
+ import { parseUnits } from "viem";
7
+ function isCustomWithdrawalConfig(config) {
8
+ return "withdrawCallback" in config;
9
+ }
10
+
11
+ // src/clients/internal/nado/withdrawalConfig.ts
12
+ function isNadoWithdrawalConfig(config) {
13
+ return !!config && isCustomWithdrawalConfig(config) && config.customerConfig?.customerName === "nado";
14
+ }
15
+ export {
16
+ isNadoWithdrawalConfig
17
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Nado-specific members of the shared withdrawal discriminated unions. Kept in
3
+ * `clients/internal/nado/` (customer-isolated) and imported by the shared
4
+ * `WithdrawalCustomerData` / `WithdrawalCustomerConfig` aliases in
5
+ * `providers/FunkitCheckoutContext`. viem-only imports — no provider deps — so
6
+ * the shared→customer reference stays cycle-free.
7
+ */
8
+ import type { Address, Hex } from 'viem';
9
+ /**
10
+ * Nado per-submission form selections threaded to the withdrawal callback (the
11
+ * static config can't know them). `spotLeverage` must be explicit — Nado treats
12
+ * an absent value as borrowing, so `false` fails instead of opening a borrow.
13
+ */
14
+ export interface NadoWithdrawalCustomerData {
15
+ customerName: 'nado';
16
+ productId: number;
17
+ spotLeverage: boolean;
18
+ }
19
+ /**
20
+ * Nado config-level identity — the hook's **output**, not integrator input.
21
+ * `useNadoWithdrawalConfig` takes a `subaccountName` string and packs it into
22
+ * `subaccount` (Hex); consumers never author this.
23
+ */
24
+ export interface NadoWithdrawalCustomerConfig {
25
+ customerName: 'nado';
26
+ /** Connected wallet — must be the signer (Nado rejects linked signers). */
27
+ owner: Address;
28
+ /** Packed id of the active subaccount (`buildNadoSubaccountId`); the EIP-712/execute `sender`. */
29
+ subaccount: Hex;
30
+ }
@@ -0,0 +1 @@
1
+ "use client";
@@ -17,6 +17,7 @@ import { type Address } from 'viem';
17
17
  import type { CustomWithdrawalConfig, LighterRouteType, MultiMethodWithdrawalConfig } from '../providers/FunkitCheckoutContext/types';
18
18
  export { LIGHTER_ROUTE_TYPE } from '../modals/WithdrawalModal/LighterWithdrawal';
19
19
  export type { LighterRouteType } from '../providers/FunkitCheckoutContext/types';
20
+ export { LIGHTER_WITHDRAW_ABI, buildLighterL1WithdrawTransaction, isLighterWithdrawalRateLimitError, lighterWithdrawBaseUnits, } from '../utils/lighter';
20
21
  export type LighterTransferParams = {
21
22
  toAccountIndex: number;
22
23
  assetIndex: number;
@@ -2,39 +2,132 @@
2
2
  import {
3
3
  AsyncImage
4
4
  } from "./chunk-2NBYHUIW.js";
5
+ import "./chunk-FJ6GCMJ4.js";
5
6
  import {
6
- useFunkitConfig
7
- } from "./chunk-RWCJ4XGX.js";
7
+ chainMetadataById,
8
+ useFunkitConfig,
9
+ useFunkitConnectChainsById
10
+ } from "./chunk-WRS7AFM2.js";
8
11
  import {
9
12
  Box
10
13
  } from "./chunk-LUHEVXPD.js";
11
14
  import "./chunk-UPZNKPYU.js";
12
15
  import {
13
16
  useFunkitTranslation
14
- } from "./chunk-HOORQPSY.js";
17
+ } from "./chunk-F6P4CN27.js";
15
18
  import {
16
19
  logger
17
20
  } from "./chunk-AHYOV7AV.js";
18
21
 
19
22
  // src/clients/lighter.tsx
20
23
  import {
21
- DirectExecutionType,
24
+ DirectExecutionType as DirectExecutionType2,
22
25
  LIGHTERXYZ_API_KEY as LIGHTERXYZ_API_KEY2,
23
- createDirectExecution
26
+ createDirectExecution as createDirectExecution2
24
27
  } from "@funkit/api-base";
25
28
  import { LIGHTER_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
26
29
  import { RELAY_LIGHTER_CHAIN_ID as RELAY_LIGHTER_CHAIN_ID2 } from "@funkit/fun-relay";
27
30
  import { retry } from "@lifeomic/attempt";
28
- import { useQuery as useQuery2 } from "@tanstack/react-query";
31
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
29
32
  import i18next from "i18next";
30
- import React3, { useMemo as useMemo2 } from "react";
31
- import { v4 as uuid } from "uuid";
32
- import { pad, parseUnits, toHex } from "viem";
33
+ import React4, { useMemo as useMemo2 } from "react";
34
+ import { v4 as uuid2 } from "uuid";
35
+ import { pad, parseUnits as parseUnits3, toHex } from "viem";
33
36
  import { arbitrum, base, bsc, mainnet as mainnet3, optimism } from "viem/chains";
34
37
 
35
- // src/components/Icons/EvmWallet.tsx
38
+ // src/components/ChainIcon/ChainIcon.tsx
36
39
  import React from "react";
37
- var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React.createElement(
40
+
41
+ // src/consts/assets.ts
42
+ import {
43
+ ASSET_LOGO_SRCS,
44
+ FALLBACK_ASSET,
45
+ getAssetLogoSrc
46
+ } from "@funkit/fun-relay";
47
+
48
+ // src/hooks/useChainMetadata.ts
49
+ import { getChainIconUrl } from "@funkit/connect-core";
50
+ import { useCallback } from "react";
51
+
52
+ // src/hooks/useSupportedAssets.ts
53
+ import {
54
+ getSupportedAssets
55
+ } from "@funkit/api-base";
56
+ import { useQuery } from "@tanstack/react-query";
57
+ function useSupportedAssets(options) {
58
+ const { apiKey } = useFunkitConfig();
59
+ return useQuery({
60
+ queryKey: ["getSupportedAssets", apiKey],
61
+ queryFn: () => getSupportedAssets({ apiKey, logger }),
62
+ refetchOnMount: false,
63
+ refetchOnReconnect: false,
64
+ refetchOnWindowFocus: false,
65
+ staleTime: 5 * 60 * 1e3,
66
+ gcTime: Number.POSITIVE_INFINITY,
67
+ enabled: !!apiKey && (options?.enabled ?? true)
68
+ });
69
+ }
70
+
71
+ // src/hooks/useChainMetadata.ts
72
+ function useChainMetadata() {
73
+ const { data: supportedAssets } = useSupportedAssets();
74
+ const enabledChainsById = useFunkitConnectChainsById();
75
+ return useCallback(
76
+ (chainId) => {
77
+ if (!Number.isFinite(chainId)) {
78
+ return null;
79
+ }
80
+ const chainMetadata = chainMetadataById[chainId];
81
+ const enabledChain = enabledChainsById[chainId];
82
+ const supportedAssetsChainName = Object.values(
83
+ supportedAssets?.[chainId] ?? {}
84
+ )[0]?.chainName;
85
+ const chainName = chainMetadata?.name ?? supportedAssetsChainName ?? enabledChain?.name;
86
+ if (!chainName) {
87
+ return null;
88
+ }
89
+ return {
90
+ name: chainName,
91
+ iconUrl: chainMetadata?.iconUrl ?? enabledChain?.iconUrl ?? getChainIconUrl(chainName),
92
+ iconBackground: chainMetadata?.iconBackground ?? enabledChain?.iconBackground
93
+ };
94
+ },
95
+ [supportedAssets, enabledChainsById]
96
+ );
97
+ }
98
+
99
+ // src/components/ChainIcon/ChainIcon.tsx
100
+ function ChainIcon({
101
+ chainId,
102
+ size,
103
+ borderColor,
104
+ withIconBackground = false,
105
+ testId
106
+ }) {
107
+ const getChainMetadata = useChainMetadata();
108
+ const chainMetadata = getChainMetadata(chainId);
109
+ if (!chainMetadata) {
110
+ return null;
111
+ }
112
+ return /* @__PURE__ */ React.createElement(
113
+ AsyncImage,
114
+ {
115
+ alt: chainMetadata.name,
116
+ background: withIconBackground ? chainMetadata.iconBackground : void 0,
117
+ borderColor,
118
+ borderRadius: "full",
119
+ fallbackSrc: FALLBACK_ASSET,
120
+ height: size,
121
+ src: chainMetadata.iconUrl,
122
+ testId,
123
+ width: size
124
+ }
125
+ );
126
+ }
127
+
128
+ // src/components/Icons/EvmWallet.tsx
129
+ import React2 from "react";
130
+ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React2.createElement(
38
131
  "svg",
39
132
  {
40
133
  width: size,
@@ -43,7 +136,7 @@ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React.createElement(
43
136
  fill: "none",
44
137
  xmlns: "http://www.w3.org/2000/svg"
45
138
  },
46
- /* @__PURE__ */ React.createElement(
139
+ /* @__PURE__ */ React2.createElement(
47
140
  "path",
48
141
  {
49
142
  d: "M13.3333 6.66628V3.75016C13.3333 3.05704 13.3333 2.71048 13.1873 2.49751C13.0598 2.31143 12.8622 2.18503 12.6398 2.14718C12.3852 2.10386 12.0706 2.24909 11.4413 2.53955L4.04918 5.95127C3.48792 6.21031 3.20729 6.33984 3.00175 6.54071C2.82005 6.71829 2.68135 6.93507 2.59625 7.17447C2.5 7.44527 2.5 7.75435 2.5 8.3725V12.4996M13.75 12.0829H13.7583M2.5 9.33295L2.5 14.8329C2.5 15.7664 2.5 16.2331 2.68166 16.5896C2.84144 16.9032 3.09641 17.1582 3.41002 17.318C3.76654 17.4996 4.23325 17.4996 5.16667 17.4996H14.8333C15.7668 17.4996 16.2335 17.4996 16.59 17.318C16.9036 17.1582 17.1586 16.9032 17.3183 16.5896C17.5 16.2331 17.5 15.7664 17.5 14.8329V9.33295C17.5 8.39953 17.5 7.93282 17.3183 7.5763C17.1586 7.26269 16.9036 7.00773 16.59 6.84794C16.2335 6.66628 15.7668 6.66628 14.8333 6.66628L5.16667 6.66628C4.23325 6.66628 3.76654 6.66628 3.41002 6.84793C3.09641 7.00772 2.84144 7.26269 2.68166 7.57629C2.5 7.93281 2.5 8.39952 2.5 9.33295ZM14.1667 12.0829C14.1667 12.3131 13.9801 12.4996 13.75 12.4996C13.5199 12.4996 13.3333 12.3131 13.3333 12.0829C13.3333 11.8528 13.5199 11.6663 13.75 11.6663C13.9801 11.6663 14.1667 11.8528 14.1667 12.0829Z",
@@ -56,16 +149,28 @@ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React.createElement(
56
149
  );
57
150
 
58
151
  // src/modals/WithdrawalModal/LighterWithdrawal.tsx
152
+ import {
153
+ DirectExecutionType,
154
+ createDirectExecution
155
+ } from "@funkit/api-base";
59
156
  import { RELAY_LIGHTER_CHAIN_ID } from "@funkit/fun-relay";
60
157
  import { formatAddress, formatCryptoAndStringify } from "@funkit/utils";
61
158
  import * as dnum from "dnum";
62
- import React2, { useEffect, useMemo } from "react";
159
+ import { v4 as uuid } from "uuid";
160
+ import React3, {
161
+ useCallback as useCallback3,
162
+ useEffect,
163
+ useMemo,
164
+ useRef,
165
+ useState
166
+ } from "react";
63
167
  import { createPortal } from "react-dom";
168
+ import { parseUnits as parseUnits2 } from "viem";
64
169
  import { mainnet as mainnet2 } from "viem/chains";
65
170
 
66
171
  // src/utils/customer.ts
67
- import { useQuery, useQueryClient } from "@tanstack/react-query";
68
- import { useCallback } from "react";
172
+ import { useQuery as useQuery2, useQueryClient } from "@tanstack/react-query";
173
+ import { useCallback as useCallback2 } from "react";
69
174
 
70
175
  // src/consts/customers.ts
71
176
  import {
@@ -113,7 +218,7 @@ function useLighterAccounts({
113
218
  const { apiKey } = useFunkitConfig();
114
219
  const isLighter = isLighterxyzCustomer(apiKey);
115
220
  const enabled = !!address && address !== "0x" && isLighter;
116
- const query = useQuery({
221
+ const query = useQuery2({
117
222
  queryKey: ["lighterAccounts", address],
118
223
  queryFn: () => getLighterAccountsByL1Address(address),
119
224
  enabled,
@@ -137,8 +242,64 @@ function useLighterAccounts({
137
242
  };
138
243
  }
139
244
 
140
- // src/providers/provideFunkitConnectChains.ts
141
- import { chainMetadataById } from "@funkit/chains";
245
+ // src/utils/lighter.ts
246
+ import {
247
+ encodeFunctionData,
248
+ getAddress,
249
+ parseUnits
250
+ } from "viem";
251
+ var LIGHTER_DEPOSIT_ADDRESS = getAddress(
252
+ "0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7"
253
+ );
254
+ var LIGHTER_SLOW_DEPOSIT_TIME_ESTIMATE_SECONDS = 60 * 2;
255
+ var LIGHTER_DELAYED_AUTO_TRIGGER_CUTOFF = 60 * 5;
256
+ var LIGHTER_USDC_ASSET_INDEX = 3;
257
+ var LIGHTER_WITHDRAW_ABI = [
258
+ {
259
+ type: "function",
260
+ name: "withdraw",
261
+ stateMutability: "nonpayable",
262
+ inputs: [
263
+ { name: "accountIndex", type: "uint48" },
264
+ { name: "assetIndex", type: "uint16" },
265
+ { name: "routeType", type: "uint8" },
266
+ { name: "amount", type: "uint64" }
267
+ ],
268
+ outputs: []
269
+ }
270
+ ];
271
+ function truncateToDecimals(amount, decimals) {
272
+ const [whole = "0", frac = ""] = amount.split(".");
273
+ if (frac.length <= decimals) {
274
+ return amount;
275
+ }
276
+ const truncated = frac.slice(0, decimals);
277
+ return truncated ? `${whole}.${truncated}` : whole;
278
+ }
279
+ function lighterWithdrawBaseUnits(assetIndex, amountTokenUnits) {
280
+ const decimals = assetIndex === LIGHTER_USDC_ASSET_INDEX ? 6 : 8;
281
+ return parseUnits(truncateToDecimals(amountTokenUnits, decimals), decimals);
282
+ }
283
+ function buildLighterL1WithdrawTransaction(params) {
284
+ const { accountIndex, assetIndex, routeType, amountBaseUnit } = params;
285
+ const data = encodeFunctionData({
286
+ abi: LIGHTER_WITHDRAW_ABI,
287
+ functionName: "withdraw",
288
+ args: [accountIndex, assetIndex, routeType, amountBaseUnit]
289
+ });
290
+ return { to: LIGHTER_DEPOSIT_ADDRESS, data, value: 0n };
291
+ }
292
+ function isLighterWithdrawalRateLimitError(error) {
293
+ if (error && typeof error === "object" && "code" in error) {
294
+ const code = error.code;
295
+ if (code === 23004 || code === 23005) {
296
+ return true;
297
+ }
298
+ }
299
+ const raw = error instanceof Error ? error.message : typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : "";
300
+ const message = raw.toLowerCase();
301
+ return message.includes("23004") || message.includes("23005") || message.includes("rate limit") || message.includes("ratelimit");
302
+ }
142
303
 
143
304
  // src/utils/timeFormat.ts
144
305
  import { formatSecondsToReadableForm } from "@funkit/utils";
@@ -190,7 +351,7 @@ async function getLighterWithdrawalDelay() {
190
351
  }
191
352
  function useLighterSecureDelayText() {
192
353
  const { t } = useFunkitTranslation();
193
- const query = useQuery2({
354
+ const query = useQuery3({
194
355
  queryKey: ["lighterWithdrawalDelay"],
195
356
  queryFn: getLighterWithdrawalDelay,
196
357
  staleTime: 6e4,
@@ -343,14 +504,6 @@ var LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS = {
343
504
  LDO: 2,
344
505
  AZTEC: 100
345
506
  };
346
- function truncateAmountToDecimals(amount, decimals) {
347
- const [whole = "0", frac = ""] = amount.split(".");
348
- if (frac.length <= decimals) {
349
- return amount;
350
- }
351
- const truncated = frac.slice(0, decimals);
352
- return truncated ? `${whole}.${truncated}` : whole;
353
- }
354
507
  async function trackLighterSecureWithdrawal({
355
508
  apiKey,
356
509
  userId,
@@ -372,17 +525,17 @@ async function trackLighterSecureWithdrawal({
372
525
  }
373
526
  const { symbol, decimals } = assetMeta;
374
527
  const estTotalUsd = Number(withdrawalUSD);
375
- const safeAmount = truncateAmountToDecimals(amountTokenUnits, decimals);
376
- const baseUnitAmount = parseUnits(safeAmount, decimals).toString();
528
+ const safeAmount = truncateToDecimals(amountTokenUnits, decimals);
529
+ const baseUnitAmount = parseUnits3(safeAmount, decimals).toString();
377
530
  const fromTokenAddress = pad(toHex(assetIndex), { size: 20 });
378
- await createDirectExecution({
531
+ await createDirectExecution2({
379
532
  apiKey,
380
533
  logger,
381
534
  // Lighter L2 tx hashes are not 0x-prefixed EVM hashes — they're the L2's
382
535
  // own format. We cast here for convenience to satisfy the DE row type;
383
536
  // the backend stores the literal string and we never use it as an EVM hash.
384
537
  txHash,
385
- type: DirectExecutionType.EXTERNALLY_FULFILLED,
538
+ type: DirectExecutionType2.EXTERNALLY_FULFILLED,
386
539
  userId,
387
540
  recipientAddr,
388
541
  fromChainId: LIGHTER_CHAIN_ID.toString(),
@@ -396,7 +549,7 @@ async function trackLighterSecureWithdrawal({
396
549
  // L1 owner of that account is the recipient (Secure locks to connected wallet).
397
550
  sourceOfFund: `balance|lighter-secure|${recipientAddr}`,
398
551
  clientMetadata: {
399
- id: uuid(),
552
+ id: uuid2(),
400
553
  startTimestampMs: Date.now(),
401
554
  finalDollarValue: estTotalUsd,
402
555
  latestQuote: null,
@@ -547,27 +700,15 @@ function buildLighterFastWalletWithdrawalConfig({
547
700
  };
548
701
  }
549
702
  function ChainIconStack({ chainIds }) {
550
- return /* @__PURE__ */ React3.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "flex-end" }, chainIds.map((chainId, index) => {
551
- const metadata = chainMetadataById[chainId];
552
- return /* @__PURE__ */ React3.createElement(
553
- Box,
554
- {
555
- key: chainId,
556
- position: "relative",
557
- style: { right: `${(chainIds.length - index - 1) * -2}px` }
558
- },
559
- /* @__PURE__ */ React3.createElement(
560
- AsyncImage,
561
- {
562
- alt: metadata?.name ?? "",
563
- borderRadius: "full",
564
- src: metadata?.iconUrl ?? "",
565
- height: 16,
566
- width: 16
567
- }
568
- )
569
- );
570
- }));
703
+ return /* @__PURE__ */ React4.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "flex-end" }, chainIds.map((chainId, index) => /* @__PURE__ */ React4.createElement(
704
+ Box,
705
+ {
706
+ key: chainId,
707
+ position: "relative",
708
+ style: { right: `${(chainIds.length - index - 1) * -2}px` }
709
+ },
710
+ /* @__PURE__ */ React4.createElement(ChainIcon, { chainId, size: 16 })
711
+ )));
571
712
  }
572
713
  var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
573
714
  arbitrum.id,
@@ -613,8 +754,8 @@ function buildLighterMultiMethodConfig({
613
754
  subtitleText: t(
614
755
  isUnifiedTradingMode ? "withdrawal.fastDisclaimerUnified" : "withdrawal.fastDisclaimer"
615
756
  ),
616
- icon: /* @__PURE__ */ React3.createElement(EvmWallet, { size: 20 }),
617
- valueIcon: /* @__PURE__ */ React3.createElement(ChainIconStack, { chainIds: LIGHTER_FAST_PREVIEW_CHAIN_IDS }),
757
+ icon: /* @__PURE__ */ React4.createElement(EvmWallet, { size: 20 }),
758
+ valueIcon: /* @__PURE__ */ React4.createElement(ChainIconStack, { chainIds: LIGHTER_FAST_PREVIEW_CHAIN_IDS }),
618
759
  config: fastConfig
619
760
  };
620
761
  const secure = {
@@ -626,8 +767,8 @@ function buildLighterMultiMethodConfig({
626
767
  // so it doesn't bleed into live values, which are exact.
627
768
  delay: secureDelayText ?? t("withdrawal.secureFallbackDelay")
628
769
  }),
629
- icon: /* @__PURE__ */ React3.createElement(EvmWallet, { size: 20 }),
630
- valueIcon: /* @__PURE__ */ React3.createElement(ChainIconStack, { chainIds: LIGHTER_SECURE_PREVIEW_CHAIN_IDS }),
770
+ icon: /* @__PURE__ */ React4.createElement(EvmWallet, { size: 20 }),
771
+ valueIcon: /* @__PURE__ */ React4.createElement(ChainIconStack, { chainIds: LIGHTER_SECURE_PREVIEW_CHAIN_IDS }),
631
772
  config: secureConfig
632
773
  };
633
774
  return {
@@ -659,7 +800,11 @@ function useLighterWithdrawalConfig(config) {
659
800
  export {
660
801
  LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS,
661
802
  LIGHTER_ROUTE_TYPE,
803
+ LIGHTER_WITHDRAW_ABI,
804
+ buildLighterL1WithdrawTransaction,
662
805
  createLighterSecureWithdrawalConfig,
806
+ isLighterWithdrawalRateLimitError,
807
+ lighterWithdrawBaseUnits,
663
808
  trackLighterSecureWithdrawal,
664
809
  useLighterWithdrawalConfig
665
810
  };
@@ -1,11 +1,17 @@
1
1
  "use client";
2
+ import {
3
+ getAccount,
4
+ sendTransaction,
5
+ switchChain,
6
+ waitForTransactionReceipt
7
+ } from "./chunk-FJ6GCMJ4.js";
2
8
  import {
3
9
  useAccount,
4
10
  useConfig
5
11
  } from "./chunk-UPZNKPYU.js";
6
12
  import {
7
13
  useFunkitTranslation
8
- } from "./chunk-HOORQPSY.js";
14
+ } from "./chunk-F6P4CN27.js";
9
15
  import {
10
16
  logger
11
17
  } from "./chunk-AHYOV7AV.js";
@@ -16,31 +22,10 @@ import { VAULT_DEPOSITOR_ABI } from "@funkit/fun-relay";
16
22
  import { useMemo } from "react";
17
23
  import {
18
24
  encodeFunctionData,
19
- erc20Abi as erc20Abi2,
25
+ erc20Abi,
20
26
  getAddress,
21
27
  maxUint256
22
28
  } from "viem";
23
-
24
- // src/wagmi/actions.ts
25
- import { erc20Abi, formatUnits } from "viem";
26
- import {
27
- getBalance as getBalanceCore,
28
- multicall as multicallCore
29
- } from "wagmi/actions";
30
- import {
31
- estimateGas,
32
- getAccount,
33
- getGasPrice,
34
- getTransaction,
35
- getWalletClient,
36
- multicall,
37
- readContract,
38
- sendTransaction,
39
- switchChain,
40
- waitForTransactionReceipt
41
- } from "wagmi/actions";
42
-
43
- // src/clients/mallard.tsx
44
29
  var MALLARD_DEPOSIT_ADDRESS = getAddress(
45
30
  "0xD42c46c7BaD6A54b38395F846b09981CE75fb8e2"
46
31
  );
@@ -95,7 +80,7 @@ function createMallardDepositActions(config) {
95
80
  // that's only needed for USDT-style tokens that require zeroing allowance first; USDG
96
81
  // is standard ERC-20.
97
82
  {
98
- contractAbi: erc20Abi2,
83
+ contractAbi: erc20Abi,
99
84
  contractAddress: token,
100
85
  functionName: "approve",
101
86
  functionArgs: [vaultDepositorAddress, maxUint256]
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  PolymarketDepositAccountDropdown
4
- } from "../chunk-3STGJU6Z.js";
5
- import "../chunk-RWCJ4XGX.js";
4
+ } from "../chunk-QHS5N7GP.js";
5
+ import "../chunk-WRS7AFM2.js";
6
6
  import "../chunk-LUHEVXPD.js";
7
7
  import "../chunk-UPZNKPYU.js";
8
- import "../chunk-HOORQPSY.js";
8
+ import "../chunk-F6P4CN27.js";
9
9
  import "../chunk-YFHTV7DT.js";
10
10
  import "../chunk-6PIIYPQK.js";
11
11
  import "../chunk-AHYOV7AV.js";
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  PolymarketDepositAccountDropdown
4
- } from "../chunk-3STGJU6Z.js";
5
- import "../chunk-RWCJ4XGX.js";
4
+ } from "../chunk-QHS5N7GP.js";
5
+ import "../chunk-WRS7AFM2.js";
6
6
  import "../chunk-LUHEVXPD.js";
7
7
  import "../chunk-UPZNKPYU.js";
8
- import "../chunk-HOORQPSY.js";
8
+ import "../chunk-F6P4CN27.js";
9
9
  import {
10
10
  POLYMARKET_PERPS_ROUTING_ID,
11
11
  POLYMARKET_PREDICTIONS_ROUTING_ID,
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { BoxProps } from '../Box/Box';
3
+ interface ChainIconProps {
4
+ chainId: number;
5
+ size: (BoxProps['height'] & BoxProps['width']) | number;
6
+ borderColor?: BoxProps['borderColor'];
7
+ /** Renders the chain's brand background color behind transparent icons. */
8
+ withIconBackground?: boolean;
9
+ testId?: string;
10
+ }
11
+ /**
12
+ * Round chain icon resolved via useChainMetadata, degrading to FALLBACK_ASSET on
13
+ * load failure. Renders nothing for chains unknown to every source.
14
+ */
15
+ export declare function ChainIcon({ chainId, size, borderColor, withIconBackground, testId, }: ChainIconProps): React.JSX.Element | null;
16
+ export {};
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  import { type BoxProps } from '../Box/Box';
3
3
  export declare const FreeUsdcBanner: ({ marginBottom, type, }: Pick<BoxProps, "marginBottom"> & {
4
4
  type: "deposit" | "withdrawal";
5
- }) => React.JSX.Element;
5
+ }) => React.JSX.Element | null;
@@ -7,9 +7,8 @@ interface FunAssetAvatarProps {
7
7
  assetIconSize?: BoxProps['height'] & BoxProps['width'];
8
8
  chainId?: string | number;
9
9
  prioritizeDefaults?: boolean;
10
- hideIfUnknown?: boolean;
11
10
  largeChainIcon?: boolean;
12
11
  isChainIconHidden?: boolean;
13
12
  }
14
- export declare function FunAssetAvatar({ assetSrc, assetTicker, assetName, assetIconSize, chainId, prioritizeDefaults, hideIfUnknown, largeChainIcon, isChainIconHidden, }: FunAssetAvatarProps): React.JSX.Element | null;
13
+ export declare function FunAssetAvatar({ assetSrc, assetTicker, assetName, assetIconSize, chainId, prioritizeDefaults, largeChainIcon, isChainIconHidden, }: FunAssetAvatarProps): React.JSX.Element;
15
14
  export {};
@@ -0,0 +1,11 @@
1
+ export interface ChainMetadata {
2
+ name: string;
3
+ iconUrl: string | (() => Promise<string>);
4
+ iconBackground?: string;
5
+ }
6
+ /**
7
+ * Resolves a chain's display name and icon. Name priority: curated metadata,
8
+ * then the supported-assets API, then customer-supplied chains.
9
+ * Returns null for chains unknown to every source.
10
+ */
11
+ export declare function useChainMetadata(): (chainId: number) => ChainMetadata | null;
@@ -1,6 +1,7 @@
1
1
  import { CheckoutRefundState, CheckoutState, type DirectExecution, RelayExecutionStatus } from '@funkit/api-base';
2
+ import { mapRelayExecutionStatusToCheckoutState } from '@funkit/connect-core';
2
3
  import type { MergedMultiStepDirectExecution } from '../domains/checkoutNotifications';
3
- export declare function mapRelayExecutionStatusToCheckoutState(status: RelayExecutionStatus): CheckoutState;
4
+ export { mapRelayExecutionStatusToCheckoutState };
4
5
  export declare function mapRelayExecutionStatusToRefundState(status: RelayExecutionStatus): CheckoutRefundState | undefined;
5
6
  export declare function useCheckoutDirectExecutionHistory({ initDirectExecution, disabled, }: {
6
7
  initDirectExecution?: DirectExecution;
@@ -1,6 +1,12 @@
1
1
  import { type PaymentMethodType } from '../hooks/usePaymentSources';
2
- export declare function usePaymentMethodTabs({ hasWithdrawalConfig, }: {
3
- hasWithdrawalConfig: boolean;
2
+ export declare function usePaymentMethodTabs({ isCashier, }: {
3
+ /**
4
+ * Explicit cashier intent (`props.formFactor === 'cashier'`), which the props
5
+ * union guarantees carries a `withdrawalConfig`. Gated further by the
6
+ * `enablecashierformfactor` Statsig config so the cashier can roll out per
7
+ * customer on top of the integrator's opt-in.
8
+ */
9
+ isCashier: boolean;
4
10
  }): {
5
11
  defaultTab: PaymentMethodType;
6
12
  isWithdrawalTabEnabled: boolean;