@agg-build/hooks 4.26.1 → 4.27.3

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