@funkit/connect 11.0.0 → 11.1.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 (70) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/clients/{chunk-JD2J5K6S.js → chunk-2QYQNTOI.js} +153 -18
  3. package/dist/clients/chunk-63XTVHO3.js +19 -0
  4. package/dist/clients/{chunk-6CYZKITE.js → chunk-6T6URLBM.js} +1 -1
  5. package/dist/clients/chunk-A44M6EAG.js +160 -0
  6. package/dist/clients/chunk-A6OXZWCN.js +40 -0
  7. package/dist/clients/{chunk-LT4EWLDA.js → chunk-BPDLF2R6.js} +1 -0
  8. package/dist/clients/{chunk-2FSEE3AW.js → chunk-C53FRCUM.js} +2 -89
  9. package/dist/clients/{chunk-6PIIYPQK.js → chunk-EJKHMZW3.js} +4 -327
  10. package/dist/clients/chunk-FAYBQQNB.js +15 -0
  11. package/dist/clients/chunk-NAVU6W7V.js +89 -0
  12. package/dist/clients/{chunk-BNMZM23Q.js → chunk-OJZNF6EM.js} +2 -2
  13. package/dist/clients/chunk-PENJ5JGH.js +331 -0
  14. package/dist/clients/{chunk-C4SHJFOV.js → chunk-QIMCURVA.js} +9 -9
  15. package/dist/clients/{chunk-YFHTV7DT.js → chunk-SH3MHRHX.js} +1 -1
  16. package/dist/clients/chunk-SO756ELD.js +35 -0
  17. package/dist/clients/{chunk-MGQLVTSH.js → chunk-SYFHMTUO.js} +27 -21
  18. package/dist/clients/chunk-WVM4ZJD2.js +61 -0
  19. package/dist/clients/{chunk-L2KSNS7H.js → chunk-WZRW6WUM.js} +1 -1
  20. package/dist/clients/chunk-YMGRBJAS.js +302 -0
  21. package/dist/clients/chunk-YZSO4EMO.js +44 -0
  22. package/dist/clients/{chunk-2YWQL3AO.js → chunk-Z7HTQFEO.js} +26 -3
  23. package/dist/clients/fanatics.js +2 -1
  24. package/dist/clients/internal/nado/encoding.d.ts +5 -2
  25. package/dist/clients/internal/nado/encoding.js +1 -1
  26. package/dist/clients/internal/nado/errors.d.ts +14 -1
  27. package/dist/clients/internal/nado/errors.js +7 -3
  28. package/dist/clients/internal/nado/fetch.js +2 -2
  29. package/dist/clients/internal/nado/gateway.d.ts +19 -20
  30. package/dist/clients/internal/nado/gateway.js +3 -5
  31. package/dist/clients/internal/nado/hooks.d.ts +8 -2
  32. package/dist/clients/internal/nado/hooks.js +9 -9
  33. package/dist/clients/internal/nado/indexer.js +3 -3
  34. package/dist/clients/internal/nado/typedData.js +4 -37
  35. package/dist/clients/internal/nado/withdrawalCallback.d.ts +20 -0
  36. package/dist/clients/internal/nado/withdrawalCallback.js +20 -0
  37. package/dist/clients/internal/nado/withdrawalConfig.d.ts +8 -3
  38. package/dist/clients/internal/nado/withdrawalConfig.js +7 -3
  39. package/dist/clients/internal/nado/withdrawalErrors.d.ts +14 -0
  40. package/dist/clients/internal/nado/withdrawalErrors.js +11 -0
  41. package/dist/clients/internal/nado/withdrawalForm.d.ts +6 -7
  42. package/dist/clients/internal/nado/withdrawalForm.js +75 -96
  43. package/dist/clients/internal/nado/withdrawalStatus.d.ts +41 -0
  44. package/dist/clients/internal/nado/withdrawalStatus.js +231 -0
  45. package/dist/clients/internal/nado/withdrawalTypes.d.ts +21 -7
  46. package/dist/clients/lighter.css +18 -18
  47. package/dist/clients/lighter.js +7 -4
  48. package/dist/clients/mallard.js +4 -3
  49. package/dist/clients/nado.d.ts +67 -0
  50. package/dist/clients/nado.js +73 -0
  51. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +60 -60
  52. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +9 -6
  53. package/dist/clients/polymarket/createPolymarketDepositConfig.js +3 -2
  54. package/dist/clients/polymarket/index.css +60 -60
  55. package/dist/clients/polymarket/index.js +9 -6
  56. package/dist/clients/polymarket/polymarket.js +2 -1
  57. package/dist/consts/customers.d.ts +1 -1
  58. package/dist/hooks/track/analytics/events.d.ts +57 -0
  59. package/dist/hooks/track/analytics/mappers.d.ts +6 -0
  60. package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +20 -0
  61. package/dist/hooks/track/useTrack.d.ts +2 -1
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +3044 -2602
  64. package/dist/modals/WithdrawalModal/NadoWithdrawalSuccess.d.ts +20 -0
  65. package/dist/providers/FunkitCheckoutContext/types.d.ts +0 -1
  66. package/dist/providers/GeneralWalletProvider.d.ts +1 -0
  67. package/dist/wallets/walletConnectors/index.js +41 -41
  68. package/package.json +3 -3
  69. package/dist/clients/chunk-SFDEST63.js +0 -18
  70. package/dist/clients/chunk-ZCCLJW6F.js +0 -99
@@ -0,0 +1,231 @@
1
+ "use client";
2
+ import {
3
+ useFunkitConfig
4
+ } from "../../chunk-C53FRCUM.js";
5
+ import "../../chunk-FAYBQQNB.js";
6
+ import {
7
+ useAccount
8
+ } from "../../chunk-UPZNKPYU.js";
9
+ import "../../chunk-2QYQNTOI.js";
10
+ import {
11
+ logger
12
+ } from "../../chunk-AHYOV7AV.js";
13
+
14
+ // src/clients/internal/nado/withdrawalStatus.ts
15
+ import {
16
+ getCompletionTxInfo,
17
+ processRecentDepositsForNotifications,
18
+ useRecentDepositsApiQuery
19
+ } from "@funkit/connect-core";
20
+ import { isEVMAddressEquivalent } from "@funkit/utils";
21
+ import { useEffect, useMemo, useRef, useState } from "react";
22
+ import { zeroHash } from "viem";
23
+
24
+ // src/hooks/useCheckoutDirectExecutionHistory.ts
25
+ import {
26
+ CheckoutRefundState,
27
+ CheckoutState,
28
+ RelayExecutionStatus
29
+ } from "@funkit/api-base";
30
+ import { mapRelayExecutionStatusToCheckoutState } from "@funkit/connect-core";
31
+
32
+ // src/utils/across.ts
33
+ var ACROSS_DELAYED_AUTO_TRIGGER_CUTOFF = 60 * 5;
34
+ function isAcrossRoute(metadata) {
35
+ return !!metadata?.across?.enabled;
36
+ }
37
+
38
+ // src/hooks/useDirectExecutionInfoPolling.ts
39
+ import {
40
+ getDirectExecutionByTxHash
41
+ } from "@funkit/api-base";
42
+ import { RELAY_TERMINAL_STATUSES } from "@funkit/fun-relay";
43
+ import { useQuery } from "@tanstack/react-query";
44
+ var RELAY_FETCH_INTERVAL = 1500;
45
+ var logPrefix = "useDirectExecutionInfoPolling";
46
+ function useDirectExecutionInfoPolling({
47
+ initDirectExecution,
48
+ disabled = false
49
+ }) {
50
+ const { apiKey } = useFunkitConfig();
51
+ const { data: directExecution, isLoading } = useQuery({
52
+ queryKey: [logPrefix, initDirectExecution?.txHash],
53
+ queryFn: async () => {
54
+ try {
55
+ const data = await getDirectExecutionByTxHash({
56
+ apiKey,
57
+ logger,
58
+ txHash: initDirectExecution?.txHash
59
+ // query is disabled if txHash not present
60
+ });
61
+ logger.log(`${logPrefix}:response`, data);
62
+ return data;
63
+ } catch (error) {
64
+ logger.error(`${logPrefix}:error`, error);
65
+ throw error;
66
+ }
67
+ },
68
+ refetchOnWindowFocus: false,
69
+ refetchInterval: (query) => {
70
+ const latestData = query.state.data;
71
+ if (latestData) {
72
+ const status = latestData.listenerInfo?.status || null;
73
+ if (status && RELAY_TERMINAL_STATUSES.includes(status)) {
74
+ return 0;
75
+ }
76
+ }
77
+ return RELAY_FETCH_INTERVAL;
78
+ },
79
+ initialData: initDirectExecution,
80
+ enabled: !disabled && !!initDirectExecution?.txHash && initDirectExecution.txHash !== "0x"
81
+ });
82
+ return {
83
+ directExecution,
84
+ isLoading
85
+ };
86
+ }
87
+
88
+ // src/hooks/useCheckoutDirectExecutionHistory.ts
89
+ function mapRelayExecutionStatusToRefundState(status) {
90
+ switch (status) {
91
+ case RelayExecutionStatus.REFUND:
92
+ return CheckoutRefundState.REFUNDED;
93
+ default:
94
+ return void 0;
95
+ }
96
+ }
97
+ function useCheckoutDirectExecutionHistory({
98
+ initDirectExecution,
99
+ disabled = false
100
+ }) {
101
+ const { directExecution } = useDirectExecutionInfoPolling({
102
+ initDirectExecution,
103
+ disabled
104
+ });
105
+ const status = directExecution?.listenerInfo?.status ?? RelayExecutionStatus.PENDING;
106
+ const latestQuote = directExecution?.clientMetadata.latestQuote;
107
+ const state = mapRelayExecutionStatusToCheckoutState(status);
108
+ const refundState = mapRelayExecutionStatusToRefundState(status);
109
+ const isDelayed = status === RelayExecutionStatus.DELAYED;
110
+ return {
111
+ state,
112
+ refundState,
113
+ isAcross: isAcrossRoute(latestQuote?.baseQuote.metadata),
114
+ isLayerZero: latestQuote && !!latestQuote.baseQuote.metadata?.oftEnabled,
115
+ isRefunded: refundState === CheckoutRefundState.REFUNDED,
116
+ isCompleted: state === CheckoutState.COMPLETED,
117
+ isFailed: state === CheckoutState.CHECKOUT_ERROR,
118
+ isDelayed,
119
+ isProcessing: state === CheckoutState.PENDING_RECEIVAL,
120
+ directExecution
121
+ };
122
+ }
123
+
124
+ // src/clients/internal/nado/withdrawalStatus.ts
125
+ var RECENT_DIRECT_EXECUTION_SCAN_SIZE = 5;
126
+ function useNadoWithdrawalStatus({
127
+ depositAddress,
128
+ pollIntervalMs
129
+ }) {
130
+ const { apiKey } = useFunkitConfig();
131
+ const { address: walletAddress } = useAccount();
132
+ const [hasSettled, setHasSettled] = useState(false);
133
+ const { data: recentDirectExecutions } = useRecentDepositsApiQuery({
134
+ isVisible: !hasSettled && !!depositAddress,
135
+ fetchSize: RECENT_DIRECT_EXECUTION_SCAN_SIZE,
136
+ apiKey,
137
+ userId: walletAddress ?? "",
138
+ refreshIntervalMs: pollIntervalMs,
139
+ logger
140
+ });
141
+ const mergedDirectExecutions = useMemo(
142
+ () => processRecentDepositsForNotifications(recentDirectExecutions),
143
+ [recentDirectExecutions]
144
+ );
145
+ const [knownTxHashes, setKnownTxHashes] = useState();
146
+ useEffect(() => {
147
+ if (!knownTxHashes && mergedDirectExecutions) {
148
+ setKnownTxHashes(
149
+ new Set(mergedDirectExecutions.map(({ txHash }) => txHash))
150
+ );
151
+ }
152
+ }, [knownTxHashes, mergedDirectExecutions]);
153
+ const ourDirectExecution = knownTxHashes ? findDirectExecutionForDepositAddress(
154
+ mergedDirectExecutions,
155
+ depositAddress,
156
+ knownTxHashes
157
+ ) : void 0;
158
+ const latestStep = ourDirectExecution?.latestStep ?? ourDirectExecution;
159
+ const isFinalStep = !!latestStep && !latestStep.isIntermediaryPhase;
160
+ const { isCompleted, isFailed } = useCheckoutDirectExecutionHistory({
161
+ initDirectExecution: latestStep,
162
+ disabled: !latestStep
163
+ });
164
+ const status = toNadoWithdrawalStatus({
165
+ isCompleted: isCompleted && isFinalStep,
166
+ isFailed
167
+ });
168
+ useEffect(() => {
169
+ if (status !== "pending") {
170
+ setHasSettled(true);
171
+ }
172
+ }, [status]);
173
+ const loggedStatusRef = useRef(void 0);
174
+ useEffect(() => {
175
+ if (status === "pending" || loggedStatusRef.current === status) {
176
+ return;
177
+ }
178
+ loggedStatusRef.current = status;
179
+ logger.info("nado:withdrawal:settled", {
180
+ depositAddress,
181
+ status,
182
+ txHash: latestStep?.txHash,
183
+ relayStatus: latestStep?.listenerInfo?.status
184
+ });
185
+ }, [status, depositAddress, latestStep]);
186
+ const completionTx = useMemo(() => {
187
+ if (status !== "completed" || !latestStep) {
188
+ return void 0;
189
+ }
190
+ const { chainId, txHash, customRedirectUrl } = getCompletionTxInfo(latestStep);
191
+ const onChainTxHash = resolveOnChainCompletionTxHash(latestStep, txHash);
192
+ return onChainTxHash ? { chainId, txHash: onChainTxHash, customRedirectUrl } : void 0;
193
+ }, [status, latestStep]);
194
+ return { status, completionTx };
195
+ }
196
+ function resolveOnChainCompletionTxHash(directExecution, completionTxHash) {
197
+ const hasDestinationTx = !!completionTxHash && completionTxHash !== directExecution.txHash && completionTxHash !== zeroHash;
198
+ if (directExecution.fromChainId !== directExecution.toChainId) {
199
+ return hasDestinationTx ? completionTxHash : void 0;
200
+ }
201
+ return hasDestinationTx ? completionTxHash : directExecution.onChainTxHash ?? directExecution.txHash;
202
+ }
203
+ function findDirectExecutionForDepositAddress(directExecutions, depositAddress, knownTxHashes) {
204
+ if (!depositAddress) {
205
+ return void 0;
206
+ }
207
+ return directExecutions?.find((directExecution) => {
208
+ if (knownTxHashes.has(directExecution.txHash)) {
209
+ return false;
210
+ }
211
+ const sourceSegments = directExecution.sourceOfFund?.split("|") ?? [];
212
+ const sourceAddress = sourceSegments[sourceSegments.length - 1];
213
+ return !!sourceAddress && isEVMAddressEquivalent({
214
+ firstAddress: sourceAddress,
215
+ secondAddress: depositAddress
216
+ });
217
+ });
218
+ }
219
+ function toNadoWithdrawalStatus({
220
+ isCompleted,
221
+ isFailed
222
+ }) {
223
+ if (isCompleted) {
224
+ return "completed";
225
+ }
226
+ return isFailed ? "failed" : "pending";
227
+ }
228
+ export {
229
+ findDirectExecutionForDepositAddress,
230
+ useNadoWithdrawalStatus
231
+ };
@@ -6,6 +6,21 @@
6
6
  * the shared→customer reference stays cycle-free.
7
7
  */
8
8
  import type { Address, Hex } from 'viem';
9
+ /**
10
+ * The dropdown pick, flattened out of the config's `sourceTokens`. Travels whole
11
+ * so identity, decimals, and product id can't be resolved from disagreeing
12
+ * sources — two lookups that disagree would sign against the wrong asset or off
13
+ * by a power of ten.
14
+ */
15
+ export interface NadoWithdrawalSourceOption {
16
+ /** Nado's own key for the asset — every subaccount query is keyed on it. */
17
+ productId: number;
18
+ symbol: string;
19
+ decimals: number;
20
+ tokenAddress: Address;
21
+ tokenChainId: string;
22
+ iconSrc: string | undefined;
23
+ }
9
24
  /**
10
25
  * Nado per-submission form selections threaded to the withdrawal callback (the
11
26
  * static config can't know them).
@@ -13,23 +28,22 @@ import type { Address, Hex } from 'viem';
13
28
  * so `false` fails instead of opening a borrow.
14
29
  * - `sequencerFeeTokenAmount` pins the fee the screen displayed, so the callback
15
30
  * signs the same net amount instead of re-reading a possibly-refreshed cache.
31
+ * - `selectedSourceToken` is the live dropdown pick. The shared form data carries
32
+ * the config's static `sourceTokenSymbol` instead, which is stale for a
33
+ * multi-source flow.
16
34
  */
17
35
  export interface NadoWithdrawalCustomerData {
18
36
  customerName: 'nado';
19
- productId: number;
20
37
  spotLeverage: boolean;
21
38
  /** Sequencer fee in the product's token units, as shown at submit. */
22
39
  sequencerFeeTokenAmount: number;
40
+ selectedSourceToken: NadoWithdrawalSourceOption;
23
41
  }
24
- /**
25
- * Nado config-level identity — the hook's **output**, not integrator input.
26
- * `useNadoWithdrawalConfig` takes a `subaccountName` string and packs it into
27
- * `subaccount` (Hex); consumers never author this.
28
- */
42
+ /** Nado config-level identity, supplied by the integrator on the withdrawal config. */
29
43
  export interface NadoWithdrawalCustomerConfig {
30
44
  customerName: 'nado';
31
45
  /** Connected wallet — must be the signer (Nado rejects linked signers). */
32
- owner: Address;
46
+ walletAddress: Address;
33
47
  /** Packed id of the active subaccount (`buildNadoSubaccountId`); the EIP-712/execute `sender`. */
34
48
  subaccount: Hex;
35
49
  }
@@ -16527,6 +16527,24 @@
16527
16527
  flex: 1;
16528
16528
  }
16529
16529
 
16530
+ /* vanilla-extract-css-ns:src/components/FunTransactionSummary/PaymentFeesSummary.css.ts.vanilla.css?source=LnZrd3ZlMzIgewogIGN1cnNvcjogcG9pbnRlcjsKfQoudmt3dmUzMjpmb2N1cy12aXNpYmxlIHsKICBvdXRsaW5lOiAxcHggc29saWQ7CiAgb3V0bGluZS1jb2xvcjogdmFyKC0tcmstY29sb3JzLXRlcnRpYXJ5VGV4dCk7Cn0KLnZrd3ZlMzMgewogIHRyYW5zaXRpb246IGFsbCAwLjJzIGxpbmVhcjsKICB0cmFuc2l0aW9uLWRlbGF5OiAwLjJzOwogIG9wYWNpdHk6IDE7Cn0KLnZrd3ZlMzQgewogIHRyYW5zaXRpb246IGFsbCAwLjJzIGxpbmVhcjsKICBvcGFjaXR5OiAwOwp9 */
16531
+ [data-rk] .vkwve32 {
16532
+ cursor: pointer;
16533
+ }
16534
+ [data-rk] .vkwve32:focus-visible {
16535
+ outline: 1px solid;
16536
+ outline-color: var(--rk-colors-tertiaryText);
16537
+ }
16538
+ [data-rk] .vkwve33 {
16539
+ transition: all 0.2s linear;
16540
+ transition-delay: 0.2s;
16541
+ opacity: 1;
16542
+ }
16543
+ [data-rk] .vkwve34 {
16544
+ transition: all 0.2s linear;
16545
+ opacity: 0;
16546
+ }
16547
+
16530
16548
  /* vanilla-extract-css-ns:src/components/FunAssetAvatar/FunAssetAvatar.css.ts.vanilla.css?source=LnV3cmRjMjAgewogIHBvc2l0aW9uOiByZWxhdGl2ZTsKfQoudXdyZGMyMiB7CiAgcG9zaXRpb246IGFic29sdXRlOwp9 */
16531
16549
  [data-rk] .uwrdc20 {
16532
16550
  position: relative;
@@ -16881,24 +16899,6 @@
16881
16899
  overflow: hidden;
16882
16900
  }
16883
16901
 
16884
- /* vanilla-extract-css-ns:src/components/FunTransactionSummary/PaymentFeesSummary.css.ts.vanilla.css?source=LnZrd3ZlMzIgewogIGN1cnNvcjogcG9pbnRlcjsKfQoudmt3dmUzMjpmb2N1cy12aXNpYmxlIHsKICBvdXRsaW5lOiAxcHggc29saWQ7CiAgb3V0bGluZS1jb2xvcjogdmFyKC0tcmstY29sb3JzLXRlcnRpYXJ5VGV4dCk7Cn0KLnZrd3ZlMzMgewogIHRyYW5zaXRpb246IGFsbCAwLjJzIGxpbmVhcjsKICB0cmFuc2l0aW9uLWRlbGF5OiAwLjJzOwogIG9wYWNpdHk6IDE7Cn0KLnZrd3ZlMzQgewogIHRyYW5zaXRpb246IGFsbCAwLjJzIGxpbmVhcjsKICBvcGFjaXR5OiAwOwp9 */
16885
- [data-rk] .vkwve32 {
16886
- cursor: pointer;
16887
- }
16888
- [data-rk] .vkwve32:focus-visible {
16889
- outline: 1px solid;
16890
- outline-color: var(--rk-colors-tertiaryText);
16891
- }
16892
- [data-rk] .vkwve33 {
16893
- transition: all 0.2s linear;
16894
- transition-delay: 0.2s;
16895
- opacity: 1;
16896
- }
16897
- [data-rk] .vkwve34 {
16898
- transition: all 0.2s linear;
16899
- opacity: 0;
16900
- }
16901
-
16902
16902
  /* vanilla-extract-css-ns:src/components/PaddedScrollableArea/paddedScrollableArea.css.ts.vanilla.css?source=Ll8xczAzMWEwMCB7CiAgZmxleDogMTsKICBtaW4taGVpZ2h0OiAwOwogIG92ZXJmbG93LXg6IGhpZGRlbjsKICBvdmVyZmxvdy15OiBhdXRvOwogIHBvc2l0aW9uOiByZWxhdGl2ZTsKICBzY3JvbGxiYXItZ3V0dGVyOiBzdGFibGU7CiAgc2Nyb2xsYmFyLXdpZHRoOiB1bnNldDsKfQouXzFzMDMxYTAwOjotd2Via2l0LXNjcm9sbGJhciB7CiAgZGlzcGxheTogdW5zZXQ7CiAgd2lkdGg6IDZweDsKICBiYWNrZ3JvdW5kLWNvbG9yOiB2YXIoLS1yay1jb2xvcnMtbW9kYWxCYWNrZ3JvdW5kKTsKfQouXzFzMDMxYTAwOjotd2Via2l0LXNjcm9sbGJhci10aHVtYiB7CiAgYm9yZGVyLXJhZGl1czogdmFyKC0tcmstcmFkaWktbW9kYWwpOwogIGJhY2tncm91bmQtY29sb3I6IHZhcigtLXJrLWNvbG9ycy10ZXJ0aWFyeVRleHQpOwp9Ci5fMXMwMzFhMDA6Oi13ZWJraXQtc2Nyb2xsYmFyLXRyYWNrIHsKICBiYWNrZ3JvdW5kLWNvbG9yOiB2YXIoLS1yay1jb2xvcnMtbW9kYWxCYWNrZ3JvdW5kKTsKfQouXzFzMDMxYTAxOjotd2Via2l0LXNjcm9sbGJhci10aHVtYiB7CiAgYmFja2dyb3VuZC1jb2xvcjogdmFyKC0tcmstY29sb3JzLW1vZGFsQmFja2dyb3VuZCk7Cn0KLl8xczAzMWEwMTo6LXdlYmtpdC1zY3JvbGxiYXItdGh1bWI6aG92ZXIgewogIGJhY2tncm91bmQtY29sb3I6IHZhcigtLXJrLWNvbG9ycy1zZWNvbmRhcnlUZXh0KTsKfQ */
16903
16903
  [data-rk] ._1s031a00 {
16904
16904
  flex: 1;
@@ -9,17 +9,20 @@ import {
9
9
  useFunkitConnectChainsById
10
10
  } from "./chunk-FNB7OPJI.js";
11
11
  import {
12
- useFunkitConfig,
13
12
  useLighterAccountQuery,
14
13
  useLighterAccountsQuery
15
- } from "./chunk-2FSEE3AW.js";
14
+ } from "./chunk-NAVU6W7V.js";
15
+ import {
16
+ useFunkitConfig
17
+ } from "./chunk-C53FRCUM.js";
16
18
  import {
17
19
  Box
18
20
  } from "./chunk-LUHEVXPD.js";
19
- import "./chunk-UPZNKPYU.js";
20
21
  import {
21
22
  useFunkitTranslation
22
- } from "./chunk-JD2J5K6S.js";
23
+ } from "./chunk-FAYBQQNB.js";
24
+ import "./chunk-UPZNKPYU.js";
25
+ import "./chunk-2QYQNTOI.js";
23
26
  import {
24
27
  logger
25
28
  } from "./chunk-AHYOV7AV.js";
@@ -7,13 +7,14 @@ import {
7
7
  switchChain,
8
8
  waitForTransactionReceipt
9
9
  } from "./chunk-OODIKHYE.js";
10
+ import {
11
+ useFunkitTranslation
12
+ } from "./chunk-FAYBQQNB.js";
10
13
  import {
11
14
  useAccount,
12
15
  useConfig
13
16
  } from "./chunk-UPZNKPYU.js";
14
- import {
15
- useFunkitTranslation
16
- } from "./chunk-JD2J5K6S.js";
17
+ import "./chunk-2QYQNTOI.js";
17
18
  import {
18
19
  logger
19
20
  } from "./chunk-AHYOV7AV.js";
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Nado withdrawals — the public integration surface.
3
+ *
4
+ * Pass the returned config to the withdrawal modal; the SDK renders the Nado
5
+ * enter-amount screen, signs Nado's gasless `withdraw_collateral_v2` against a
6
+ * Fun deposit address, and routes the settled funds to the user's destination.
7
+ *
8
+ * Everything an integrator touches is exported from this file and nowhere else —
9
+ * not the root entry. Anything they don't stays in `clients/internal/nado/`.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const nado = useNadoWithdrawalConfig(
14
+ * isConnected
15
+ * ? { sourceTokens: NADO_SOURCE_TOKENS, sourceTokenSymbol: 'USDT0' }
16
+ * : null,
17
+ * )
18
+ * ```
19
+ */
20
+ import type { SourceTokenOption, TokenInfo } from '../providers/FunkitCheckoutContext/types';
21
+ import { type NadoWithdrawalConfig } from './internal/nado/withdrawalConfig';
22
+ export interface NadoWithdrawalOptions {
23
+ /**
24
+ * Nado's withdrawable assets. Each option must carry
25
+ * `customData: { type: 'nado', productId }` and `asset.decimals` — the product
26
+ * id addresses the subaccount balance and the decimals scale the signed
27
+ * amount, so an option missing either is skipped.
28
+ */
29
+ sourceTokens: SourceTokenOption[];
30
+ /** Symbol of the initially selected option; must match one in {@link sourceTokens}. */
31
+ sourceTokenSymbol: string;
32
+ /**
33
+ * Active subaccount's name as your subaccount state holds it (`default`,
34
+ * `default_1`, …) — not the profile label the user sees, and not a decoded
35
+ * engine value. The SDK packs it with the connected wallet. Defaults to
36
+ * `default`; `''` is a different subaccount, and over 12 bytes disables the
37
+ * config.
38
+ */
39
+ subaccountName?: string;
40
+ modalTitle?: string;
41
+ iconSrc?: null | string;
42
+ disableConnectedWallet?: boolean;
43
+ /** Token pre-selected in the receive dropdown. Defaults to the source token. */
44
+ defaultReceiveToken?: string;
45
+ /** Awaited after the user commits, before any nonce fetch or signature. Throw to abort. */
46
+ onBeforeSign?: () => Promise<void> | void;
47
+ getMinWithdrawalUSD?: (asset: TokenInfo) => number;
48
+ getMaxWithdrawalUSD?: (asset: TokenInfo) => number;
49
+ /**
50
+ * Minimum withdrawal in token units per source symbol. Preferred over
51
+ * {@link NadoWithdrawalOptions.getMinWithdrawalUSD} here — the floor is the
52
+ * sequencer fee, which Nado charges per asset, not per dollar.
53
+ */
54
+ getMinWithdrawalAmount?: (symbol: string) => number;
55
+ }
56
+ /**
57
+ * Withdrawal config for a Nado subaccount, or `null` while one can't be built —
58
+ * keep the withdraw entry point disabled until it resolves.
59
+ *
60
+ * Null means the wallet is disconnected, `options` is null, or
61
+ * `sourceTokenSymbol` names no entry in `sourceTokens` that carries an `asset`.
62
+ * The last is a wiring bug and is not logged, so check it first if the button
63
+ * never enables.
64
+ */
65
+ export declare function useNadoWithdrawalConfig(options: NadoWithdrawalOptions | null): NadoWithdrawalConfig | null;
66
+ export type { NadoWithdrawalConfig } from './internal/nado/withdrawalConfig';
67
+ export type { NadoWithdrawalCustomerConfig, NadoWithdrawalCustomerData, } from './internal/nado/withdrawalTypes';
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import {
3
+ createNadoWithdrawalCallback
4
+ } from "./chunk-YMGRBJAS.js";
5
+ import "./chunk-YZSO4EMO.js";
6
+ import "./chunk-WVM4ZJD2.js";
7
+ import "./chunk-63XTVHO3.js";
8
+ import {
9
+ resolveNadoSubaccount
10
+ } from "./chunk-A6OXZWCN.js";
11
+ import "./chunk-SO756ELD.js";
12
+ import "./chunk-6T6URLBM.js";
13
+ import "./chunk-A44M6EAG.js";
14
+ import {
15
+ INK_CHAIN_ID
16
+ } from "./chunk-II5CZTBC.js";
17
+ import "./chunk-WZRW6WUM.js";
18
+ import "./chunk-Z7HTQFEO.js";
19
+ import "./chunk-OODIKHYE.js";
20
+ import {
21
+ useAccount,
22
+ useConfig
23
+ } from "./chunk-UPZNKPYU.js";
24
+ import {
25
+ i18n_default
26
+ } from "./chunk-2QYQNTOI.js";
27
+ import "./chunk-PENJ5JGH.js";
28
+ import "./chunk-AHYOV7AV.js";
29
+
30
+ // src/clients/nado.tsx
31
+ import { useMemo } from "react";
32
+ function useNadoWithdrawalConfig(options) {
33
+ const { address: walletAddress } = useAccount();
34
+ const wagmiConfig = useConfig();
35
+ const subaccountName = options?.subaccountName;
36
+ const subaccount = useMemo(
37
+ () => resolveNadoSubaccount(walletAddress, subaccountName),
38
+ [walletAddress, subaccountName]
39
+ );
40
+ const withdrawCallback = useMemo(
41
+ () => walletAddress && subaccount ? createNadoWithdrawalCallback({
42
+ walletAddress,
43
+ subaccount,
44
+ wagmiConfig
45
+ }) : void 0,
46
+ [walletAddress, subaccount, wagmiConfig]
47
+ );
48
+ const sourceTokenAddress = options?.sourceTokens?.find(
49
+ (option) => option.symbol === options.sourceTokenSymbol
50
+ )?.asset?.tokenAddress;
51
+ if (!options || !walletAddress || !subaccount || !withdrawCallback || !sourceTokenAddress) {
52
+ return null;
53
+ }
54
+ return {
55
+ modalTitle: options.modalTitle ?? i18n_default.t("withdrawal.withdraw"),
56
+ iconSrc: options.iconSrc,
57
+ disableConnectedWallet: options.disableConnectedWallet,
58
+ onBeforeSign: options.onBeforeSign,
59
+ sourceChainId: INK_CHAIN_ID.toString(),
60
+ sourceTokens: options.sourceTokens,
61
+ sourceTokenSymbol: options.sourceTokenSymbol,
62
+ sourceTokenAddress,
63
+ defaultReceiveToken: options.defaultReceiveToken ?? options.sourceTokenSymbol,
64
+ getMinWithdrawalUSD: options.getMinWithdrawalUSD,
65
+ getMaxWithdrawalUSD: options.getMaxWithdrawalUSD,
66
+ getMinWithdrawalAmount: options.getMinWithdrawalAmount,
67
+ withdrawCallback,
68
+ customerConfig: { customerName: "nado", walletAddress, subaccount }
69
+ };
70
+ }
71
+ export {
72
+ useNadoWithdrawalConfig
73
+ };
@@ -16826,6 +16826,66 @@
16826
16826
  overflow: hidden;
16827
16827
  }
16828
16828
 
16829
+ /* vanilla-extract-css-ns:src/components/Dropdown/BaseDropdown.css.ts.vanilla.css?source=#H4sIAAAAAAAAA9WTwW7bMAyG73kKIqcEsAIb3YpBxi5r36IYBtqiYyGqKFB03HTouw92mjQZVmAodtmNBPX_Ij9Kmx9VjPn2kEv4uQDgPUkXeDQHCzgo1wuA3AqH0KCY0TvtLUSOVC9eFpuz1lozUrPzas6HZzvncwp4-IOkmuuJs1fP0YJQQPV7qi-asNB75yheC61tqGOh2aDlqBTVwnJZX_lhkzkMOvspJwvlFAXq9DUUv-1PcU_H5NOX9DTlDba7rfAQnYXgI6GYraDzFHWlDA2r8mMBe5SVMbIzLQeWbDhRvBdOjsf47WxxNxXXBahgzAmFoq6PvfqoJIb2FDWfEAFwwtbr4bW1WXWaKQSoPpePGdqh8a1p6NmTrMrNTQFlAeWmvC2gms2fjY-OnixUv8PDTkn-nt1x1n-KTzn9l-weHCqaDh0Z5fR1qTLQ8vvVczzf_770CPRN_baPd8Q3c_FDs1y62B7z6gHFo3E-YxPInZpY2376cvM9l7vz0avHMDFpB8ksE2g1GAKP5OrFyy9ESovqPQQAAA */
16830
+ [data-rk] ._1nns6ys0 {
16831
+ overflow-y: auto;
16832
+ scrollbar-width: none;
16833
+ }
16834
+ [data-rk] ._1nns6ys0::-webkit-scrollbar {
16835
+ display: none;
16836
+ }
16837
+ [data-rk] ._1nns6ys1 {
16838
+ position: relative;
16839
+ overflow: hidden;
16840
+ }
16841
+ [data-rk] ._1nns6ys1::before {
16842
+ content: "";
16843
+ position: absolute;
16844
+ top: 0;
16845
+ left: 0;
16846
+ right: 0;
16847
+ height: 48px;
16848
+ background:
16849
+ linear-gradient(
16850
+ to bottom,
16851
+ var(--rk-colors-openDropdownBackgroundColor),
16852
+ transparent);
16853
+ pointer-events: none;
16854
+ opacity: 0;
16855
+ transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
16856
+ z-index: 1;
16857
+ }
16858
+ [data-rk] ._1nns6ys1::after {
16859
+ content: "";
16860
+ position: absolute;
16861
+ bottom: 0;
16862
+ left: 0;
16863
+ right: 0;
16864
+ height: 48px;
16865
+ background:
16866
+ linear-gradient(
16867
+ to top,
16868
+ var(--rk-colors-openDropdownBackgroundColor),
16869
+ transparent);
16870
+ pointer-events: none;
16871
+ opacity: 0;
16872
+ transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
16873
+ z-index: 1;
16874
+ }
16875
+ [data-rk] ._1nns6ys1[data-fade-top=true]::before {
16876
+ opacity: 1;
16877
+ }
16878
+ [data-rk] ._1nns6ys1[data-fade-bottom=true]::after {
16879
+ opacity: 1;
16880
+ }
16881
+ [data-rk] ._1nns6ys3 {
16882
+ transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
16883
+ }
16884
+ [data-rk] ._1nns6ys3:has([aria-disabled=true]):hover {
16885
+ background: initial;
16886
+ cursor: not-allowed;
16887
+ }
16888
+
16829
16889
  /* vanilla-extract-css-ns:src/components/Icons/CaretDownIcon.css.ts.vanilla.css?source=QGtleWZyYW1lcyBfMWdqZGYxaTAgewogIDAlIHsKICAgIHRyYW5zZm9ybTogcm90YXRlM2QoMSwwLDAsMGRlZyk7CiAgfQogIDEwMCUgewogICAgdHJhbnNmb3JtOiByb3RhdGUzZCgxLDAsMCwxODBkZWcpOwogIH0KfQpAa2V5ZnJhbWVzIF8xZ2pkZjFpMSB7CiAgMCUgewogICAgdHJhbnNmb3JtOiByb3RhdGUzZCgxLDAsMCwxODBkZWcpOwogIH0KICAxMDAlIHsKICAgIHRyYW5zZm9ybTogcm90YXRlM2QoMSwwLDAsMGRlZyk7CiAgfQp9Ci5fMWdqZGYxaTIgewogIGFuaW1hdGlvbjogXzFnamRmMWkwIDI1MG1zIGN1YmljLWJlemllcigwLjI5LCAtMC4wMSwgMCwgMSkgZm9yd2FyZHM7Cn0KLl8xZ2pkZjFpMyB7CiAgYW5pbWF0aW9uOiBfMWdqZGYxaTEgMjUwbXMgY3ViaWMtYmV6aWVyKDAuMjksIC0wLjAxLCAwLCAxKSBmb3J3YXJkczsKfQ */
16830
16890
  @keyframes _1gjdf1i0 {
16831
16891
  0% {
@@ -17439,66 +17499,6 @@
17439
17499
  transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
17440
17500
  }
17441
17501
 
17442
- /* vanilla-extract-css-ns:src/components/Dropdown/BaseDropdown.css.ts.vanilla.css?source=#H4sIAAAAAAAAA9WTwW7bMAyG73kKIqcEsAIb3YpBxi5r36IYBtqiYyGqKFB03HTouw92mjQZVmAodtmNBPX_Ij9Kmx9VjPn2kEv4uQDgPUkXeDQHCzgo1wuA3AqH0KCY0TvtLUSOVC9eFpuz1lozUrPzas6HZzvncwp4-IOkmuuJs1fP0YJQQPV7qi-asNB75yheC61tqGOh2aDlqBTVwnJZX_lhkzkMOvspJwvlFAXq9DUUv-1PcU_H5NOX9DTlDba7rfAQnYXgI6GYraDzFHWlDA2r8mMBe5SVMbIzLQeWbDhRvBdOjsf47WxxNxXXBahgzAmFoq6PvfqoJIb2FDWfEAFwwtbr4bW1WXWaKQSoPpePGdqh8a1p6NmTrMrNTQFlAeWmvC2gms2fjY-OnixUv8PDTkn-nt1x1n-KTzn9l-weHCqaDh0Z5fR1qTLQ8vvVczzf_770CPRN_baPd8Q3c_FDs1y62B7z6gHFo3E-YxPInZpY2376cvM9l7vz0avHMDFpB8ksE2g1GAKP5OrFyy9ESovqPQQAAA */
17443
- [data-rk] ._1nns6ys0 {
17444
- overflow-y: auto;
17445
- scrollbar-width: none;
17446
- }
17447
- [data-rk] ._1nns6ys0::-webkit-scrollbar {
17448
- display: none;
17449
- }
17450
- [data-rk] ._1nns6ys1 {
17451
- position: relative;
17452
- overflow: hidden;
17453
- }
17454
- [data-rk] ._1nns6ys1::before {
17455
- content: "";
17456
- position: absolute;
17457
- top: 0;
17458
- left: 0;
17459
- right: 0;
17460
- height: 48px;
17461
- background:
17462
- linear-gradient(
17463
- to bottom,
17464
- var(--rk-colors-openDropdownBackgroundColor),
17465
- transparent);
17466
- pointer-events: none;
17467
- opacity: 0;
17468
- transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
17469
- z-index: 1;
17470
- }
17471
- [data-rk] ._1nns6ys1::after {
17472
- content: "";
17473
- position: absolute;
17474
- bottom: 0;
17475
- left: 0;
17476
- right: 0;
17477
- height: 48px;
17478
- background:
17479
- linear-gradient(
17480
- to top,
17481
- var(--rk-colors-openDropdownBackgroundColor),
17482
- transparent);
17483
- pointer-events: none;
17484
- opacity: 0;
17485
- transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
17486
- z-index: 1;
17487
- }
17488
- [data-rk] ._1nns6ys1[data-fade-top=true]::before {
17489
- opacity: 1;
17490
- }
17491
- [data-rk] ._1nns6ys1[data-fade-bottom=true]::after {
17492
- opacity: 1;
17493
- }
17494
- [data-rk] ._1nns6ys3 {
17495
- transition: all 150ms cubic-bezier(0.3, 0, 0.06, 1);
17496
- }
17497
- [data-rk] ._1nns6ys3:has([aria-disabled=true]):hover {
17498
- background: initial;
17499
- cursor: not-allowed;
17500
- }
17501
-
17502
17502
  /* src/components/Dropdown/BaseDropdownAnimation.css */
17503
17503
  @keyframes funkit-dropdown-fade-in {
17504
17504
  0% {
@@ -1,16 +1,19 @@
1
1
  "use client";
2
2
  import {
3
3
  PolymarketDepositAccountDropdown
4
- } from "../chunk-C4SHJFOV.js";
5
- import "../chunk-LT4EWLDA.js";
4
+ } from "../chunk-QIMCURVA.js";
5
+ import "../chunk-BPDLF2R6.js";
6
6
  import "../chunk-5MY7WMEJ.js";
7
7
  import "../chunk-FNB7OPJI.js";
8
- import "../chunk-2FSEE3AW.js";
8
+ import "../chunk-NAVU6W7V.js";
9
+ import "../chunk-C53FRCUM.js";
9
10
  import "../chunk-LUHEVXPD.js";
11
+ import "../chunk-FAYBQQNB.js";
10
12
  import "../chunk-UPZNKPYU.js";
11
- import "../chunk-JD2J5K6S.js";
12
- import "../chunk-YFHTV7DT.js";
13
- import "../chunk-6PIIYPQK.js";
13
+ import "../chunk-2QYQNTOI.js";
14
+ import "../chunk-SH3MHRHX.js";
15
+ import "../chunk-EJKHMZW3.js";
16
+ import "../chunk-PENJ5JGH.js";
14
17
  import "../chunk-AHYOV7AV.js";
15
18
  export {
16
19
  PolymarketDepositAccountDropdown