@agg-build/hooks 4.26.1 → 4.27.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 (45) hide show
  1. package/dist/deposit.d.mts +142 -138
  2. package/dist/deposit.d.mts.map +1 -0
  3. package/dist/deposit.d.ts +142 -138
  4. package/dist/deposit.d.ts.map +1 -0
  5. package/dist/deposit.js +751 -2414
  6. package/dist/deposit.mjs +744 -727
  7. package/dist/deposit.mjs.map +1 -0
  8. package/dist/index-CbNR3EIA.d.mts +341 -0
  9. package/dist/index-CbNR3EIA.d.mts.map +1 -0
  10. package/dist/index-CsP1jRMD.d.ts +341 -0
  11. package/dist/index-CsP1jRMD.d.ts.map +1 -0
  12. package/dist/index-D0fXU85a.d.mts +743 -0
  13. package/dist/index-D0fXU85a.d.mts.map +1 -0
  14. package/dist/index-D0fXU85a.d.ts +743 -0
  15. package/dist/index-D0fXU85a.d.ts.map +1 -0
  16. package/dist/index.d.mts +6458 -7515
  17. package/dist/index.d.mts.map +1 -0
  18. package/dist/index.d.ts +6458 -7515
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +7451 -11417
  21. package/dist/index.mjs +7154 -5221
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/use-ramp-session-7RAG9tvY.js +30 -0
  24. package/dist/use-ramp-session-BFWHCtuc.mjs +21 -0
  25. package/dist/use-ramp-session-BFWHCtuc.mjs.map +1 -0
  26. package/dist/use-sync-balances-BkcqInJh.mjs +1779 -0
  27. package/dist/use-sync-balances-BkcqInJh.mjs.map +1 -0
  28. package/dist/{use-sync-balances-CeD8qZWP.d.ts → use-sync-balances-CVEg__2V.d.mts} +7 -8
  29. package/dist/use-sync-balances-CVEg__2V.d.mts.map +1 -0
  30. package/dist/{use-sync-balances-CeD8qZWP.d.mts → use-sync-balances-CVEg__2V.d.ts} +7 -8
  31. package/dist/use-sync-balances-CVEg__2V.d.ts.map +1 -0
  32. package/dist/use-sync-balances-HryB8Q7F.js +1974 -0
  33. package/dist/withdraw--f5kYKJA.mjs +1474 -0
  34. package/dist/withdraw--f5kYKJA.mjs.map +1 -0
  35. package/dist/withdraw-BXWZYmJa.js +1591 -0
  36. package/dist/withdraw.d.mts +3 -351
  37. package/dist/withdraw.d.ts +3 -351
  38. package/dist/withdraw.js +10 -2229
  39. package/dist/withdraw.mjs +3 -20
  40. package/package.json +7 -6
  41. package/dist/chunk-JFJNW2PD.mjs +0 -5649
  42. package/dist/chunk-LNIAMJTZ.mjs +0 -505
  43. package/dist/chunk-OZQ3K47U.mjs +0 -31
  44. package/dist/use-deposit-addresses-B9ICS-3U.d.mts +0 -236
  45. package/dist/use-deposit-addresses-B9ICS-3U.d.ts +0 -236
@@ -1,351 +1,3 @@
1
- import * as _agg_build_sdk from '@agg-build/sdk';
2
- import { WsWithdrawalLifecycleStatus, WsWithdrawalLifecycleLeg, WithdrawPreviewResponse, WithdrawManagedResponse, WithdrawManagedParams } from '@agg-build/sdk';
3
- import * as _tanstack_react_query from '@tanstack/react-query';
4
- export { U as UseDepositAddressesOptions, u as useDepositAddresses } from './use-deposit-addresses-B9ICS-3U.mjs';
5
-
6
- type WithdrawSelectOption = {
7
- value: string;
8
- label: string;
9
- disabled?: boolean;
10
- };
11
- type WithdrawSummary = {
12
- /**
13
- * The amount the user submitted for withdrawal — NOT a confirmed payout
14
- * figure. A preflight quote can still fail or settle partially later, so
15
- * labeling this "received" was misleading.
16
- */
17
- amountReceived: string;
18
- network: string;
19
- toWallet: string;
20
- fees: string;
21
- };
22
- interface UseWithdrawFlowResult {
23
- open: boolean;
24
- onOpenChange: (open: boolean) => void;
25
- withdrawFlow: {
26
- balance: number;
27
- balanceDisplay: string;
28
- amount: string;
29
- destinationWallet: string;
30
- tokenOptions: WithdrawSelectOption[];
31
- networkOptions: WithdrawSelectOption[];
32
- selectedToken: string;
33
- selectedNetwork: string;
34
- purchaseSummary: WithdrawSummary;
35
- /**
36
- * The id returned by `POST /execution/withdraw-managed` once the user
37
- * has submitted the flow — used by the success step to subscribe to
38
- * `withdrawal_lifecycle` WS events. `null` until submission succeeds
39
- * and reset to `null` when the modal closes.
40
- */
41
- withdrawalId: string | null;
42
- /**
43
- * True when the user clicked Max — the backend should apply its own cap
44
- * rather than rejecting an over-balance request. Reset to false when the
45
- * user manually edits the amount field afterward.
46
- */
47
- isMax: boolean;
48
- };
49
- onWithdrawDestinationChange: (address: string) => void;
50
- onWithdrawAmountChange: (amount: string) => void;
51
- onWithdrawTokenChange: (token: string) => void;
52
- onWithdrawNetworkChange: (network: string) => void;
53
- onMaxClick: () => void;
54
- onSelectWithdrawProvider: (providerId: string) => Promise<void>;
55
- onDoneWithdraw: () => void;
56
- }
57
- interface UseWithdrawFlowOptions {
58
- open: boolean;
59
- onOpenChange: (open: boolean) => void;
60
- }
61
- declare function useWithdrawFlow(options: UseWithdrawFlowOptions): UseWithdrawFlowResult;
62
-
63
- interface WithdrawFeeEstimate {
64
- estimatedFees: string;
65
- networkReserve: string;
66
- youReceive: string;
67
- }
68
- interface UseWithdrawEstimateParams {
69
- amount: string;
70
- selectedToken: string;
71
- selectedNetwork: string;
72
- }
73
- /**
74
- * Natively estimates withdrawal fees, network reserves, and the expected net
75
- * amount to be received based on the selected token, destination network,
76
- * and transfer amount.
77
- */
78
- declare function useWithdrawEstimate({ amount, selectedToken, selectedNetwork, }: UseWithdrawEstimateParams): WithdrawFeeEstimate | null;
79
-
80
- /**
81
- * Latest lifecycle snapshot for a single withdrawal, materialized from the
82
- * most recent `WsWithdrawalLifecycleEvent` whose `withdrawalId` matches.
83
- *
84
- * The wire format is intentionally additive (legs may arrive partial), so
85
- * `legs` reflects the latest snapshot the server emitted — earlier per-leg
86
- * deltas are not re-merged on the client. Consumers should treat `legs` as
87
- * "last known truth" rather than a derived rollup.
88
- */
89
- interface WithdrawalLifecycleState {
90
- /** True until the first lifecycle event for this withdrawal arrives. */
91
- pending: boolean;
92
- /** Top-level status, or `null` until the first event arrives. */
93
- status: WsWithdrawalLifecycleStatus | null;
94
- /** Requested withdrawal amount in destination-token native decimals. */
95
- requestedAmountRaw: string | null;
96
- /** Terminal settled amount in destination-token native decimals. */
97
- completedAmountRaw: string | null;
98
- /** Realized platform fee in destination-token native decimals. Only present on terminal events; null until then. */
99
- feeRaw: string | null;
100
- /** Whether `status` is a terminal state (`completed` / `partial` / `failed`). */
101
- terminal: boolean;
102
- /** Last leg delta (the leg whose flip triggered the most recent event). */
103
- lastLeg: WsWithdrawalLifecycleLeg | null;
104
- /** All legs at the moment of the most recent event (server snapshot). */
105
- legs: WsWithdrawalLifecycleLeg[];
106
- /** Failure reason for terminal `failed` / `partial`. */
107
- errorMessage: string | null;
108
- /** Server timestamp (ms) of the most recent event. */
109
- timestamp: number | null;
110
- }
111
- interface UseWithdrawalLifecycleResult {
112
- /** Latest lifecycle snapshot for the watched `withdrawalId`. */
113
- state: WithdrawalLifecycleState;
114
- /** Reset to the initial pre-event state — call when the modal is closed or a new flow starts. */
115
- reset: () => void;
116
- }
117
- /**
118
- * Subscribes to `withdrawal_lifecycle` WS events for a single `withdrawalId`
119
- * and exposes the latest snapshot. Returns a stable `pending` initial state
120
- * until the first matching event arrives.
121
- *
122
- * Pass `null` for `withdrawalId` to disable the subscription (e.g. before
123
- * the user has submitted a withdrawal). Switching the `withdrawalId` resets
124
- * the state so a stale snapshot from a prior withdrawal can never bleed
125
- * across.
126
- *
127
- * **Backfill behavior**: on mount with a non-null `withdrawalId`, and again
128
- * whenever the WS connection re-opens, the hook calls
129
- * `GET /execution/withdrawals/:id` to recover any lifecycle events that fired
130
- * before the listener was attached or while the socket was disconnected. WS
131
- * events always win over REST snapshots (REST stamps as `timestamp: 0`), so a
132
- * race between the two never regresses to a stale state.
133
- */
134
- declare function useWithdrawalLifecycle(withdrawalId: string | null): UseWithdrawalLifecycleResult;
135
-
136
- interface UseWithdrawPreviewParams {
137
- amountRaw: string | null;
138
- tokenSymbol: string | null;
139
- destinationChainId: number | null;
140
- destinationAddress: string | null;
141
- /**
142
- * When `true`, the backend caps the withdrawal to the maximum deliverable amount.
143
- * Included in the query key so max vs non-max are distinct cache entries.
144
- */
145
- max?: boolean;
146
- }
147
- /**
148
- * Live withdrawal preview backed by the API (`POST /execution/withdraw/preview`).
149
- * Disabled until amount/token/chain/address are present and amount is non-zero.
150
- * The backend caches identical previews for 15s; FE debounce keeps Relay calls
151
- * bounded. Returns the real fee + receive amount, replacing the hardcoded
152
- * `useWithdrawEstimate`.
153
- */
154
- declare function useWithdrawPreview({ amountRaw, tokenSymbol, destinationChainId, destinationAddress, max, }: UseWithdrawPreviewParams): _tanstack_react_query.UseQueryResult<WithdrawPreviewResponse, Error>;
155
-
156
- interface UseWithdrawManagedOptions {
157
- onSuccess?: (data: WithdrawManagedResponse) => void;
158
- onError?: (error: Error) => void;
159
- }
160
- /**
161
- * Mutation hook for withdrawing funds from managed wallets. On submission
162
- * success the backend has already debited the managed-side balance and
163
- * recorded the activity row, so we invalidate the full money-state cache
164
- * surface (balances, positions, activity). Terminal lifecycle invalidation
165
- * is handled separately by `useWithdrawalLifecycle`.
166
- */
167
- declare function useWithdrawManaged(options?: UseWithdrawManagedOptions): _tanstack_react_query.UseMutationResult<WithdrawManagedResponse, Error, WithdrawManagedParams, unknown>;
168
-
169
- interface UseManagedBalancesOptions {
170
- enabled?: boolean;
171
- mode?: "live" | "paper";
172
- /**
173
- * `"self"` fetches the balances of the wallets linked to this account rather
174
- * than the managed wallet. Its own query key, so both can be held at once.
175
- */
176
- custody?: "managed" | "self";
177
- }
178
- /**
179
- * Query hook for fetching unified managed wallet balances across all chains.
180
- */
181
- declare function useManagedBalances(options?: UseManagedBalancesOptions): {
182
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
183
- data: _agg_build_sdk.UnifiedBalanceResponse;
184
- error: Error;
185
- isError: true;
186
- isPending: false;
187
- isLoading: false;
188
- isLoadingError: false;
189
- isRefetchError: true;
190
- isSuccess: false;
191
- isPlaceholderData: false;
192
- status: "error";
193
- dataUpdatedAt: number;
194
- errorUpdatedAt: number;
195
- failureCount: number;
196
- failureReason: Error | null;
197
- errorUpdateCount: number;
198
- isFetched: boolean;
199
- isFetchedAfterMount: boolean;
200
- isFetching: boolean;
201
- isInitialLoading: boolean;
202
- isPaused: boolean;
203
- isRefetching: boolean;
204
- isStale: boolean;
205
- isEnabled: boolean;
206
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
207
- fetchStatus: _tanstack_react_query.FetchStatus;
208
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
209
- } | {
210
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
211
- data: _agg_build_sdk.UnifiedBalanceResponse;
212
- error: null;
213
- isError: false;
214
- isPending: false;
215
- isLoading: false;
216
- isLoadingError: false;
217
- isRefetchError: false;
218
- isSuccess: true;
219
- isPlaceholderData: false;
220
- status: "success";
221
- dataUpdatedAt: number;
222
- errorUpdatedAt: number;
223
- failureCount: number;
224
- failureReason: Error | null;
225
- errorUpdateCount: number;
226
- isFetched: boolean;
227
- isFetchedAfterMount: boolean;
228
- isFetching: boolean;
229
- isInitialLoading: boolean;
230
- isPaused: boolean;
231
- isRefetching: boolean;
232
- isStale: boolean;
233
- isEnabled: boolean;
234
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
235
- fetchStatus: _tanstack_react_query.FetchStatus;
236
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
237
- } | {
238
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
239
- data: undefined;
240
- error: Error;
241
- isError: true;
242
- isPending: false;
243
- isLoading: false;
244
- isLoadingError: true;
245
- isRefetchError: false;
246
- isSuccess: false;
247
- isPlaceholderData: false;
248
- status: "error";
249
- dataUpdatedAt: number;
250
- errorUpdatedAt: number;
251
- failureCount: number;
252
- failureReason: Error | null;
253
- errorUpdateCount: number;
254
- isFetched: boolean;
255
- isFetchedAfterMount: boolean;
256
- isFetching: boolean;
257
- isInitialLoading: boolean;
258
- isPaused: boolean;
259
- isRefetching: boolean;
260
- isStale: boolean;
261
- isEnabled: boolean;
262
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
263
- fetchStatus: _tanstack_react_query.FetchStatus;
264
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
265
- } | {
266
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
267
- data: undefined;
268
- error: null;
269
- isError: false;
270
- isPending: true;
271
- isLoading: true;
272
- isLoadingError: false;
273
- isRefetchError: false;
274
- isSuccess: false;
275
- isPlaceholderData: false;
276
- status: "pending";
277
- dataUpdatedAt: number;
278
- errorUpdatedAt: number;
279
- failureCount: number;
280
- failureReason: Error | null;
281
- errorUpdateCount: number;
282
- isFetched: boolean;
283
- isFetchedAfterMount: boolean;
284
- isFetching: boolean;
285
- isInitialLoading: boolean;
286
- isPaused: boolean;
287
- isRefetching: boolean;
288
- isStale: boolean;
289
- isEnabled: boolean;
290
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
291
- fetchStatus: _tanstack_react_query.FetchStatus;
292
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
293
- } | {
294
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
295
- data: undefined;
296
- error: null;
297
- isError: false;
298
- isPending: true;
299
- isLoadingError: false;
300
- isRefetchError: false;
301
- isSuccess: false;
302
- isPlaceholderData: false;
303
- status: "pending";
304
- dataUpdatedAt: number;
305
- errorUpdatedAt: number;
306
- failureCount: number;
307
- failureReason: Error | null;
308
- errorUpdateCount: number;
309
- isFetched: boolean;
310
- isFetchedAfterMount: boolean;
311
- isFetching: boolean;
312
- isLoading: boolean;
313
- isInitialLoading: boolean;
314
- isPaused: boolean;
315
- isRefetching: boolean;
316
- isStale: boolean;
317
- isEnabled: boolean;
318
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
319
- fetchStatus: _tanstack_react_query.FetchStatus;
320
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
321
- } | {
322
- balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
323
- data: _agg_build_sdk.UnifiedBalanceResponse;
324
- isError: false;
325
- error: null;
326
- isPending: false;
327
- isLoading: false;
328
- isLoadingError: false;
329
- isRefetchError: false;
330
- isSuccess: true;
331
- isPlaceholderData: true;
332
- status: "success";
333
- dataUpdatedAt: number;
334
- errorUpdatedAt: number;
335
- failureCount: number;
336
- failureReason: Error | null;
337
- errorUpdateCount: number;
338
- isFetched: boolean;
339
- isFetchedAfterMount: boolean;
340
- isFetching: boolean;
341
- isInitialLoading: boolean;
342
- isPaused: boolean;
343
- isRefetching: boolean;
344
- isStale: boolean;
345
- isEnabled: boolean;
346
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
347
- fetchStatus: _tanstack_react_query.FetchStatus;
348
- promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
349
- };
350
-
351
- export { type UseManagedBalancesOptions, type UseWithdrawEstimateParams, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawPreviewParams, type UseWithdrawalLifecycleResult, type WithdrawFeeEstimate, type WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawPreview, useWithdrawalLifecycle };
1
+ import { S as useWithdrawManaged, g as UseDepositAddressesOptions, v as useDepositAddresses, x as UseWithdrawManagedOptions } from "./index-D0fXU85a.mjs";
2
+ import { a as useWithdrawalLifecycle, c as useWithdrawEstimate, d as useWithdrawFlow, f as UseManagedBalancesOptions, i as WithdrawalLifecycleState, l as UseWithdrawFlowOptions, n as useWithdrawPreview, o as UseWithdrawEstimateParams, p as useManagedBalances, r as UseWithdrawalLifecycleResult, s as WithdrawFeeEstimate, t as UseWithdrawPreviewParams, u as UseWithdrawFlowResult } from "./index-CbNR3EIA.mjs";
3
+ export { type UseDepositAddressesOptions, type UseManagedBalancesOptions, type UseWithdrawEstimateParams, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawPreviewParams, type UseWithdrawalLifecycleResult, type WithdrawFeeEstimate, type WithdrawalLifecycleState, useDepositAddresses, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawPreview, useWithdrawalLifecycle };