@funkit/connect 11.4.0 → 11.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 (80) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/clients/{chunk-5MY7WMEJ.js → chunk-3U55HYGJ.js} +2 -2
  3. package/dist/clients/{chunk-BPDLF2R6.js → chunk-DSZHYQPX.js} +1 -1
  4. package/dist/clients/chunk-MSLPLXR2.js +30 -0
  5. package/dist/clients/{chunk-3Y5EIONT.js → chunk-UMU5S2WF.js} +30 -39
  6. package/dist/clients/chunk-WCQ6HJ27.js +13 -0
  7. package/dist/clients/{chunk-XJTRLB7W.js → chunk-ZEDRWRYA.js} +15 -13
  8. package/dist/clients/fanatics.js +4 -4
  9. package/dist/clients/internal/nado/withdrawalCallback.js +2 -9
  10. package/dist/clients/internal/nado/withdrawalConfig.d.ts +4 -9
  11. package/dist/clients/internal/nado/withdrawalConfig.js +3 -7
  12. package/dist/clients/internal/nado/withdrawalErrors.d.ts +6 -10
  13. package/dist/clients/internal/nado/withdrawalErrors.js +1 -2
  14. package/dist/clients/internal/nado/withdrawalForm.css +82 -74
  15. package/dist/clients/internal/nado/withdrawalForm.d.ts +1 -1
  16. package/dist/clients/internal/nado/withdrawalForm.js +12 -45
  17. package/dist/clients/internal/nado/withdrawalStatus.d.ts +1 -15
  18. package/dist/clients/internal/nado/withdrawalStatus.js +11 -61
  19. package/dist/clients/lighter.css +260 -252
  20. package/dist/clients/lighter.js +6 -9
  21. package/dist/clients/nado.d.ts +2 -2
  22. package/dist/clients/nado.js +10 -16
  23. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +263 -255
  24. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  25. package/dist/clients/polymarket/index.css +263 -255
  26. package/dist/clients/polymarket/index.js +3 -3
  27. package/dist/components/Dropdown/BaseDropdown.css.d.ts +1 -0
  28. package/dist/components/Dropdown/BaseDropdown.d.ts +0 -1
  29. package/dist/consts/funkit.d.ts +2 -0
  30. package/dist/hooks/track/analytics/events.d.ts +35 -3
  31. package/dist/hooks/track/analytics/resolveExecutionProgressContext.d.ts +1 -0
  32. package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +11 -3
  33. package/dist/hooks/track/analytics/useTrackExecutionProgressEvents.d.ts +1 -0
  34. package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +24 -1
  35. package/dist/hooks/useBluvo.d.ts +7 -2
  36. package/dist/hooks/useSwappedTheme.d.ts +3 -0
  37. package/dist/index.css +93 -85
  38. package/dist/index.js +12822 -12797
  39. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +5 -11
  40. package/dist/modals/WithdrawalModal/RecipientAddress.d.ts +3 -1
  41. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
  42. package/dist/providers/FunkitCheckoutContext/types.d.ts +1 -1
  43. package/dist/providers/FunkitProvider.d.ts +1 -0
  44. package/dist/shadow/adoptStyles.d.ts +5 -0
  45. package/dist/shadow-css.d.ts +1 -0
  46. package/dist/shadow-css.js +2 -0
  47. package/dist/utils/swapped.d.ts +8 -6
  48. package/dist/wallets/walletConnectors/index.js +9 -9
  49. package/package.json +11 -6
  50. package/shadow-css/package.json +3 -0
  51. package/dist/clients/chunk-2576N7PQ.js +0 -44
  52. package/dist/clients/chunk-3P2C436B.js +0 -20
  53. package/dist/clients/chunk-63XTVHO3.js +0 -19
  54. package/dist/clients/chunk-6T6URLBM.js +0 -33
  55. package/dist/clients/chunk-EQFVPSR2.js +0 -40
  56. package/dist/clients/chunk-FM7SFGAV.js +0 -106
  57. package/dist/clients/chunk-JFDRLSYM.js +0 -42
  58. package/dist/clients/chunk-TZGKB6WY.js +0 -160
  59. package/dist/clients/chunk-VIAEAD75.js +0 -61
  60. package/dist/clients/chunk-WZRW6WUM.js +0 -112
  61. package/dist/clients/chunk-Z7HTQFEO.js +0 -69
  62. package/dist/clients/internal/nado/consts.d.ts +0 -22
  63. package/dist/clients/internal/nado/consts.js +0 -15
  64. package/dist/clients/internal/nado/encoding.d.ts +0 -25
  65. package/dist/clients/internal/nado/encoding.js +0 -11
  66. package/dist/clients/internal/nado/errors.d.ts +0 -68
  67. package/dist/clients/internal/nado/errors.js +0 -19
  68. package/dist/clients/internal/nado/fetch.d.ts +0 -15
  69. package/dist/clients/internal/nado/fetch.js +0 -9
  70. package/dist/clients/internal/nado/gateway.d.ts +0 -61
  71. package/dist/clients/internal/nado/gateway.js +0 -17
  72. package/dist/clients/internal/nado/hooks.d.ts +0 -208
  73. package/dist/clients/internal/nado/hooks.js +0 -21
  74. package/dist/clients/internal/nado/indexer.d.ts +0 -43
  75. package/dist/clients/internal/nado/indexer.js +0 -13
  76. package/dist/clients/internal/nado/typedData.d.ts +0 -80
  77. package/dist/clients/internal/nado/typedData.js +0 -10
  78. package/dist/clients/internal/nado/withdrawalTypes.d.ts +0 -49
  79. package/dist/clients/internal/nado/withdrawalTypes.js +0 -1
  80. package/dist/utils/safeBigInt.d.ts +0 -5
@@ -1,28 +1,12 @@
1
1
  "use client";
2
- import {
3
- useNadoFeeRates,
4
- useNadoMaxWithdrawable
5
- } from "../../chunk-FM7SFGAV.js";
6
- import "../../chunk-JFDRLSYM.js";
7
- import {
8
- safeBigInt
9
- } from "../../chunk-63XTVHO3.js";
10
2
  import {
11
3
  isNadoWithdrawalConfig
12
- } from "../../chunk-EQFVPSR2.js";
4
+ } from "../../chunk-WCQ6HJ27.js";
13
5
  import "../../chunk-B7UU2ETA.js";
14
- import {
15
- x18ToRawBaseUnit,
16
- x18ToTokenUnits
17
- } from "../../chunk-6T6URLBM.js";
18
- import "../../chunk-TZGKB6WY.js";
19
- import "../../chunk-3P2C436B.js";
20
- import "../../chunk-WZRW6WUM.js";
21
- import "../../chunk-Z7HTQFEO.js";
22
6
  import {
23
7
  useGeneralWallet
24
- } from "../../chunk-BPDLF2R6.js";
25
- import "../../chunk-5MY7WMEJ.js";
8
+ } from "../../chunk-DSZHYQPX.js";
9
+ import "../../chunk-3U55HYGJ.js";
26
10
  import "../../chunk-6EU6CXNH.js";
27
11
  import {
28
12
  useFunkitConfig
@@ -37,8 +21,13 @@ import {
37
21
  } from "../../chunk-AHYOV7AV.js";
38
22
 
39
23
  // src/clients/internal/nado/withdrawalForm.ts
24
+ import {
25
+ getMaxEnterableAmount,
26
+ getSequencerFee,
27
+ useNadoFeeRates,
28
+ useNadoMaxWithdrawable
29
+ } from "@funkit/connect-core/clients/nado";
40
30
  import { useEffect, useMemo, useState } from "react";
41
- import { formatUnits } from "viem";
42
31
 
43
32
  // src/hooks/useAssetPrice.ts
44
33
  import { getAssetPriceInfoWithFallback } from "@funkit/connect-core";
@@ -115,29 +104,6 @@ function isNadoSourceToken(option) {
115
104
  const decimals = option.asset?.decimals;
116
105
  return option.customData?.type === "nado" && typeof decimals === "number" && Number.isInteger(decimals) && decimals >= 0;
117
106
  }
118
- function getMaxEnterableAmount({
119
- maxWithdrawableX18,
120
- sequencerFee,
121
- decimals
122
- }) {
123
- const max = safeBigInt(maxWithdrawableX18, 0n);
124
- if (max <= 0n || decimals === void 0) {
125
- return "0";
126
- }
127
- const maxRaw = x18ToRawBaseUnit(max, decimals);
128
- const feeRaw = x18ToRawBaseUnit(sequencerFee, decimals);
129
- return formatUnits(maxRaw + feeRaw, decimals);
130
- }
131
- function getSequencerFee(feeRates, option) {
132
- if (!option) {
133
- return { x18: 0n, tokenAmount: 0 };
134
- }
135
- const x18 = safeBigInt(
136
- feeRates?.withdraw_sequencer_fees?.[option.productId],
137
- 0n
138
- );
139
- return { x18, tokenAmount: Number(x18ToTokenUnits(x18, option.decimals)) };
140
- }
141
107
  function useNadoWithdrawalForm(config, selectedSourceToken) {
142
108
  const nadoConfig = isNadoWithdrawalConfig(config) ? config : void 0;
143
109
  const isNado = !!nadoConfig;
@@ -146,7 +112,7 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
146
112
  const [spotLeverage, setSpotLeverage] = useState(
147
113
  () => nadoConfig?.defaultSpotLeverage ?? false
148
114
  );
149
- const { data: feeRates } = useNadoFeeRates(subaccount);
115
+ const { data: feeRates } = useNadoFeeRates({ sender: subaccount, logger });
150
116
  useEffect(() => {
151
117
  setSpotLeverage(nadoConfig?.defaultSpotLeverage ?? false);
152
118
  }, [subaccount, nadoConfig?.defaultSpotLeverage]);
@@ -180,7 +146,8 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
180
146
  const { data: maxWithdrawableX18 } = useNadoMaxWithdrawable({
181
147
  productId: selectedOption?.productId,
182
148
  sender: subaccount,
183
- spotLeverage
149
+ spotLeverage,
150
+ logger
184
151
  });
185
152
  const sequencerFee = getSequencerFee(feeRates, selectedOption);
186
153
  const withdrawableBalanceTokenUnits = getMaxEnterableAmount({
@@ -6,8 +6,7 @@
6
6
  * address, so this finds that DE in the wallet's recent list and follows its
7
7
  * relay status.
8
8
  */
9
- import { type MergedMultiStepDirectExecution } from '@funkit/connect-core';
10
- import { type Address } from 'viem';
9
+ import type { Address } from 'viem';
11
10
  export type NadoWithdrawalStatus = 'pending' | 'completed' | 'failed';
12
11
  /** The destination-chain transaction that delivered the funds. */
13
12
  export interface NadoWithdrawalCompletionTx {
@@ -26,16 +25,3 @@ export declare function useNadoWithdrawalStatus({ depositAddress, pollIntervalMs
26
25
  depositAddress: Address | undefined;
27
26
  pollIntervalMs: number;
28
27
  }): NadoWithdrawalTracking;
29
- /**
30
- * Ours is the direct execution at this UDA that appeared after we started
31
- * watching.
32
- *
33
- * - The scanner stamps the address it saw the transfer at into `sourceOfFund`
34
- * (`eoa_scanner|eoa|0x…`), the only field on a DE carrying the full UDA —
35
- * `clientMetadata.depositAddress` comes back null.
36
- * - `knownTxHashes` excludes earlier withdrawals that reused the same UDA. With
37
- * one withdrawal in flight per destination that identifies ours exactly; two
38
- * concurrent ones to the same destination can't be told apart by any field a
39
- * DE carries.
40
- */
41
- export declare function findDirectExecutionForDepositAddress(directExecutions: MergedMultiStepDirectExecution[] | undefined, depositAddress: Address | undefined, knownTxHashes: ReadonlySet<string>): MergedMultiStepDirectExecution | undefined;
@@ -14,12 +14,11 @@ import {
14
14
  // src/clients/internal/nado/withdrawalStatus.ts
15
15
  import {
16
16
  getCompletionTxInfo,
17
- processRecentDepositsForNotifications,
18
- useRecentDepositsApiQuery
17
+ resolveOnChainCompletionTxHash,
18
+ useDirectExecutionForDepositAddress,
19
+ useLogOnce
19
20
  } from "@funkit/connect-core";
20
- import { isEVMAddressEquivalent } from "@funkit/utils";
21
- import { useEffect, useMemo, useRef, useState } from "react";
22
- import { zeroHash } from "viem";
21
+ import { useEffect, useMemo, useState } from "react";
23
22
 
24
23
  // src/hooks/useCheckoutDirectExecutionHistory.ts
25
24
  import {
@@ -122,7 +121,6 @@ function useCheckoutDirectExecutionHistory({
122
121
  }
123
122
 
124
123
  // src/clients/internal/nado/withdrawalStatus.ts
125
- var RECENT_DIRECT_EXECUTION_SCAN_SIZE = 5;
126
124
  function useNadoWithdrawalStatus({
127
125
  depositAddress,
128
126
  pollIntervalMs
@@ -130,33 +128,14 @@ function useNadoWithdrawalStatus({
130
128
  const { apiKey } = useFunkitConfig();
131
129
  const { address: walletAddress } = useAccount();
132
130
  const [hasSettled, setHasSettled] = useState(false);
133
- const { data: recentDirectExecutions } = useRecentDepositsApiQuery({
134
- isVisible: !hasSettled && !!depositAddress,
135
- fetchSize: RECENT_DIRECT_EXECUTION_SCAN_SIZE,
131
+ const { latestStep, isFinalStep } = useDirectExecutionForDepositAddress({
132
+ depositAddress,
136
133
  apiKey,
137
- userId: walletAddress ?? "",
138
- refreshIntervalMs: pollIntervalMs,
134
+ walletAddress: walletAddress ?? "",
135
+ pollIntervalMs,
136
+ hasSettled,
139
137
  logger
140
138
  });
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
139
  const { isCompleted, isFailed } = useCheckoutDirectExecutionHistory({
161
140
  initDirectExecution: latestStep,
162
141
  disabled: !latestStep
@@ -170,19 +149,14 @@ function useNadoWithdrawalStatus({
170
149
  setHasSettled(true);
171
150
  }
172
151
  }, [status]);
173
- const loggedStatusRef = useRef(void 0);
174
- useEffect(() => {
175
- if (status === "pending" || loggedStatusRef.current === status) {
176
- return;
177
- }
178
- loggedStatusRef.current = status;
152
+ useLogOnce(status === "pending" ? void 0 : status, () => {
179
153
  logger.info("nado:withdrawal:settled", {
180
154
  depositAddress,
181
155
  status,
182
156
  txHash: latestStep?.txHash,
183
157
  relayStatus: latestStep?.listenerInfo?.status
184
158
  });
185
- }, [status, depositAddress, latestStep]);
159
+ });
186
160
  const completionTx = useMemo(() => {
187
161
  if (status !== "completed" || !latestStep) {
188
162
  return void 0;
@@ -193,29 +167,6 @@ function useNadoWithdrawalStatus({
193
167
  }, [status, latestStep]);
194
168
  return { status, completionTx };
195
169
  }
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
170
  function toNadoWithdrawalStatus({
220
171
  isCompleted,
221
172
  isFailed
@@ -226,6 +177,5 @@ function toNadoWithdrawalStatus({
226
177
  return isFailed ? "failed" : "pending";
227
178
  }
228
179
  export {
229
- findDirectExecutionForDepositAddress,
230
180
  useNadoWithdrawalStatus
231
181
  };