@aave/react 4.0.0-next.1 → 4.0.0-next.10

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 (46) hide show
  1. package/README.md +8 -4
  2. package/dist/chunk-7FNJZJRF.js +2 -0
  3. package/dist/chunk-7FNJZJRF.js.map +1 -0
  4. package/dist/chunk-IESN2WLA.js +2 -0
  5. package/dist/chunk-IESN2WLA.js.map +1 -0
  6. package/dist/ethers.cjs +2 -0
  7. package/dist/ethers.cjs.map +1 -0
  8. package/dist/ethers.d.cts +93 -0
  9. package/dist/ethers.d.ts +93 -0
  10. package/dist/ethers.js +2 -0
  11. package/dist/ethers.js.map +1 -0
  12. package/dist/index.cjs +2 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +2912 -0
  15. package/dist/index.d.ts +2912 -0
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/misc-BUJSXsyz.d.ts +375 -0
  19. package/dist/misc-CB94S1RB.d.cts +375 -0
  20. package/dist/privy.cjs +2 -0
  21. package/dist/privy.cjs.map +1 -0
  22. package/dist/privy.d.cts +72 -0
  23. package/dist/privy.d.ts +72 -0
  24. package/dist/privy.js +2 -0
  25. package/dist/privy.js.map +1 -0
  26. package/dist/thirdweb.cjs +2 -0
  27. package/dist/thirdweb.cjs.map +1 -0
  28. package/dist/thirdweb.d.cts +69 -0
  29. package/dist/thirdweb.d.ts +69 -0
  30. package/dist/thirdweb.js +2 -0
  31. package/dist/thirdweb.js.map +1 -0
  32. package/dist/utils.cjs +2 -0
  33. package/dist/utils.cjs.map +1 -0
  34. package/dist/utils.d.cts +1 -0
  35. package/dist/utils.d.ts +1 -0
  36. package/dist/utils.js +2 -0
  37. package/dist/utils.js.map +1 -0
  38. package/dist/viem/index.cjs +2 -0
  39. package/dist/viem/index.cjs.map +1 -0
  40. package/dist/viem/index.d.cts +87 -0
  41. package/dist/viem/index.d.ts +87 -0
  42. package/dist/viem/index.js +2 -0
  43. package/dist/viem/index.js.map +1 -0
  44. package/dist/writes-BXnwYgAQ.d.cts +123 -0
  45. package/dist/writes-BXnwYgAQ.d.ts +123 -0
  46. package/package.json +7 -7
@@ -0,0 +1,375 @@
1
+ import { UnexpectedError, CurrencyQueryOptions } from '@aave/client';
2
+ import { UnexpectedError as UnexpectedError$1 } from '@aave/core';
3
+ import { ChainRequest, Chain, ChainsRequest, ExchangeRateRequest, ExchangeAmount, ActivityItem, PreviewAction, NativeAmount } from '@aave/graphql';
4
+ import { NullishDeep, Prettify } from '@aave/types';
5
+ import { a as UseAsyncTask } from './writes-BXnwYgAQ.js';
6
+
7
+ /**
8
+ * A read hook result that supports pausing.
9
+ */
10
+ type PausableReadResult<T, E extends UnexpectedError = UnexpectedError> = {
11
+ data: T | undefined;
12
+ error: E | undefined;
13
+ loading: false;
14
+ paused: true;
15
+ } | {
16
+ data: undefined;
17
+ error: undefined;
18
+ loading: true;
19
+ paused: false;
20
+ } | {
21
+ data: T;
22
+ error: undefined;
23
+ loading: false;
24
+ paused: false;
25
+ } | {
26
+ data: undefined;
27
+ error: E;
28
+ loading: false;
29
+ paused: false;
30
+ };
31
+ /**
32
+ * A read hook result.
33
+ *
34
+ * It's a discriminated union of the possible results of a read operation:
35
+ * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.
36
+ * - If `error` is `undefined`, then `data` value will be available.
37
+ */
38
+ type ReadResult<T, E extends UnexpectedError = UnexpectedError> = {
39
+ data: undefined;
40
+ error: undefined;
41
+ loading: true;
42
+ } | {
43
+ data: T;
44
+ error: undefined;
45
+ loading: false;
46
+ } | {
47
+ data: undefined;
48
+ error: E;
49
+ loading: false;
50
+ };
51
+ /**
52
+ * @internal
53
+ */
54
+ declare const ReadResult: {
55
+ Loading: <T, E extends UnexpectedError = UnexpectedError>() => PausableReadResult<T, E>;
56
+ Success: <T, E extends UnexpectedError = UnexpectedError>(data: T) => PausableReadResult<T, E>;
57
+ Failure: <T, E extends UnexpectedError = UnexpectedError>(error: E) => PausableReadResult<T, E>;
58
+ Paused: <T, E extends UnexpectedError = UnexpectedError>(data: T | undefined, error: E | undefined) => PausableReadResult<T, E>;
59
+ };
60
+ /**
61
+ * A read hook result that supports React Suspense.
62
+ */
63
+ type SuspenseResult<T> = {
64
+ data: T;
65
+ };
66
+ /**
67
+ * A read hook result that supports React Suspense and can be paused.
68
+ */
69
+ type PausableSuspenseResult<T> = {
70
+ paused: true;
71
+ data: undefined;
72
+ } | {
73
+ paused: false;
74
+ data: T;
75
+ };
76
+
77
+ type Selector<T, V> = (data: T) => V;
78
+ type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<WhenPaused & {
79
+ /**
80
+ * Prevents the hook from automatically executing GraphQL query operations.
81
+ *
82
+ * @experimental This is an experimental feature and may change in the future.
83
+ *
84
+ * @remarks
85
+ * `pause` may be set to `true` to stop the query operation from executing
86
+ * automatically. The hook will stop receiving updates and won’t execute the query
87
+ * operation until it’s set to `false`.
88
+ */
89
+ pause: boolean;
90
+ }>;
91
+ type Suspendable = {
92
+ suspense: true;
93
+ };
94
+
95
+ type UseChainArgs = ChainRequest;
96
+ /**
97
+ * Fetch a specific chain by chain ID.
98
+ *
99
+ * This signature supports React Suspense:
100
+ *
101
+ * ```tsx
102
+ * const { data } = useChain({
103
+ * chainId: chainId(1),
104
+ * suspense: true,
105
+ * });
106
+ * // data will be Chain | null
107
+ * ```
108
+ */
109
+ declare function useChain(args: UseChainArgs & Suspendable): SuspenseResult<Chain | null>;
110
+ /**
111
+ * Fetch a specific chain by chain ID.
112
+ *
113
+ * Pausable suspense mode.
114
+ *
115
+ * ```tsx
116
+ * const { data } = useChain({
117
+ * chainId: chainId(1),
118
+ * suspense: true,
119
+ * pause: true,
120
+ * });
121
+ * ```
122
+ */
123
+ declare function useChain(args: Pausable<UseChainArgs> & Suspendable): PausableSuspenseResult<Chain | null>;
124
+ /**
125
+ * Fetch a specific chain by chain ID.
126
+ *
127
+ * ```tsx
128
+ * const { data, error, loading } = useChain({
129
+ * chainId: chainId(1),
130
+ * });
131
+ * // data will be Chain | null
132
+ * ```
133
+ */
134
+ declare function useChain(args: UseChainArgs): ReadResult<Chain | null>;
135
+ /**
136
+ * Fetch a specific chain by chain ID.
137
+ *
138
+ * Pausable loading state mode.
139
+ *
140
+ * ```tsx
141
+ * const { data, error, loading, paused } = useChain({
142
+ * chainId: chainId(1),
143
+ * pause: true,
144
+ * });
145
+ * ```
146
+ */
147
+ declare function useChain(args: Pausable<UseChainArgs>): PausableReadResult<Chain | null>;
148
+ type UseChainsArgs = ChainsRequest;
149
+ /**
150
+ * Fetches the list of supported chains.
151
+ *
152
+ * This signature supports React Suspense:
153
+ *
154
+ * ```tsx
155
+ * const { data } = useChains({
156
+ * query: { filter: ChainsFilter.ALL },
157
+ * suspense: true,
158
+ * });
159
+ * ```
160
+ */
161
+ declare function useChains(args: UseChainsArgs & Suspendable): SuspenseResult<Chain[]>;
162
+ /**
163
+ * Fetches the list of supported chains.
164
+ *
165
+ * Pausable suspense mode.
166
+ *
167
+ * ```tsx
168
+ * const { data } = useChains({
169
+ * query: { filter: ChainsFilter.ALL },
170
+ * suspense: true,
171
+ * pause: true,
172
+ * });
173
+ * ```
174
+ */
175
+ declare function useChains(args: Pausable<UseChainsArgs> & Suspendable): PausableSuspenseResult<Chain[]>;
176
+ /**
177
+ * Fetches the list of supported chains.
178
+ *
179
+ * ```tsx
180
+ * const { data, error, loading } = useChains({
181
+ * query: { filter: ChainsFilter.ALL },
182
+ * });
183
+ * ```
184
+ */
185
+ declare function useChains(args?: UseChainsArgs): ReadResult<Chain[]>;
186
+ /**
187
+ * Fetches the list of supported chains.
188
+ *
189
+ * Pausable loading state mode.
190
+ *
191
+ * ```tsx
192
+ * const { data, error, loading, paused } = useChains({
193
+ * query: { filter: ChainsFilter.ALL },
194
+ * pause: true,
195
+ * });
196
+ * ```
197
+ */
198
+ declare function useChains(args?: Pausable<UseChainsArgs>): PausableReadResult<Chain[]>;
199
+ /**
200
+ * Fetches exchange rates between tokens and fiat currencies.
201
+ *
202
+ * ```tsx
203
+ * const [getExchangeRate, gettingRate] = useExchangeRateAction();
204
+ *
205
+ * const loading = gettingRate.loading;
206
+ * const error = gettingRate.error;
207
+ *
208
+ * // …
209
+ *
210
+ * const result = await getExchangeRate({
211
+ * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },
212
+ * to: Currency.Usd,
213
+ * });
214
+ *
215
+ * if (result.isErr()) {
216
+ * console.error(result.error);
217
+ * return;
218
+ * }
219
+ *
220
+ * console.log('Exchange rate:', result.value);
221
+ * ```
222
+ */
223
+ declare function useExchangeRateAction(): UseAsyncTask<ExchangeRateRequest, ExchangeAmount, UnexpectedError$1>;
224
+ type UseExchangeRateArgs = ExchangeRateRequest;
225
+ /**
226
+ * Fetches exchange rates between tokens and fiat currencies with automatic polling.
227
+ *
228
+ * This signature supports React Suspense:
229
+ *
230
+ * ```tsx
231
+ * const { data } = useExchangeRate({
232
+ * from: {
233
+ * erc20: {
234
+ * chainId: chainId(1),
235
+ * address: evmAddress('0xA0b86a33E6...')
236
+ * }
237
+ * },
238
+ * to: Currency.Usd,
239
+ * suspense: true,
240
+ * });
241
+ * ```
242
+ */
243
+ declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): SuspenseResult<ExchangeAmount>;
244
+ /**
245
+ * Fetches exchange rates between tokens and fiat currencies with automatic polling.
246
+ *
247
+ * Pausable suspense mode.
248
+ *
249
+ * ```tsx
250
+ * const { data } = useExchangeRate({
251
+ * from: {
252
+ * erc20: {
253
+ * chainId: chainId(1),
254
+ * address: evmAddress('0xA0b86a33E6...')
255
+ * }
256
+ * },
257
+ * to: Currency.Usd,
258
+ * suspense: true,
259
+ * pause: true,
260
+ * });
261
+ * ```
262
+ */
263
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendable): PausableSuspenseResult<ExchangeAmount>;
264
+ /**
265
+ * Fetches exchange rates between tokens and fiat currencies with automatic polling.
266
+ *
267
+ * ```tsx
268
+ * const { data, error, loading } = useExchangeRate({
269
+ * from: {
270
+ * erc20: {
271
+ * chainId: chainId(1),
272
+ * address: evmAddress('0xA0b86a33E6...')
273
+ * }
274
+ * },
275
+ * to: Currency.Usd,
276
+ * });
277
+ *
278
+ * <Component value={somewhere} fxRate={data} />
279
+ * ```
280
+ */
281
+ declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<ExchangeAmount>;
282
+ /**
283
+ * Fetches exchange rates between tokens and fiat currencies with automatic polling.
284
+ *
285
+ * Pausable loading state mode.
286
+ *
287
+ * ```tsx
288
+ * const { data, error, loading, paused } = useExchangeRate({
289
+ * from: {
290
+ * erc20: {
291
+ * chainId: chainId(1),
292
+ * address: evmAddress('0xA0b86a33E6...')
293
+ * }
294
+ * },
295
+ * to: Currency.Usd,
296
+ * pause: true,
297
+ * });
298
+ * ```
299
+ */
300
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs>): PausableReadResult<ExchangeAmount>;
301
+ type UseNetworkFeeRequestQuery = {
302
+ activity: ActivityItem;
303
+ } | {
304
+ estimate: PreviewAction;
305
+ };
306
+ type UseNetworkFeeArgs = Prettify<{
307
+ query: UseNetworkFeeRequestQuery;
308
+ } & CurrencyQueryOptions>;
309
+ type PausableUseNetworkFeeArgs = Partial<{
310
+ query: Partial<UseNetworkFeeRequestQuery>;
311
+ } & CurrencyQueryOptions>;
312
+ /**
313
+ * Fetch the network fee for an ActivityItem.
314
+ *
315
+ * @experimental This hook is experimental and may be subject to breaking changes.
316
+ */
317
+ type UseNetworkFee<T extends NativeAmount = NativeAmount> =
318
+ /**
319
+ * Fetches the network fee for a past ActivityItem.
320
+ *
321
+ * This signature supports React Suspense:
322
+ *
323
+ * ```tsx
324
+ * const { data } = useNetworkFee({
325
+ * query: { activity },
326
+ * suspense: true,
327
+ * });
328
+ *
329
+ * data: NativeAmount
330
+ * ```
331
+ */
332
+ ((args: UseNetworkFeeArgs & Suspendable) => SuspenseResult<T>) &
333
+ /**
334
+ * Fetches the network fee for a past ActivityItem.
335
+ *
336
+ * Pausable suspense mode.
337
+ *
338
+ * ```tsx
339
+ * const { data, paused } = useNetworkFee({
340
+ * query: { activity },
341
+ * suspense: true,
342
+ * pause: true,
343
+ * });
344
+ *
345
+ * data: NativeAmount | undefined
346
+ * ```
347
+ */
348
+ ((args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs> & Suspendable) => PausableSuspenseResult<T>) &
349
+ /**
350
+ * Fetches the network fee for a past ActivityItem.
351
+ *
352
+ * ```tsx
353
+ * const { data, error, loading } = useNetworkFee({
354
+ * query: { activity },
355
+ * });
356
+ * ```
357
+ */
358
+ ((args: UseNetworkFeeArgs) => ReadResult<T>) &
359
+ /**
360
+ * Fetches the network fee for a past ActivityItem.
361
+ *
362
+ * Pausable loading state mode.
363
+ *
364
+ * ```tsx
365
+ * const { data, error, loading, paused } = useNetworkFee({
366
+ * query: { activity },
367
+ * pause: true,
368
+ * });
369
+ *
370
+ * data: NativeAmount | undefined
371
+ * ```
372
+ */
373
+ ((args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs>) => PausableReadResult<T>);
374
+
375
+ export { type Pausable as P, ReadResult as R, type Suspendable as S, type UseNetworkFee as U, type SuspenseResult as a, type PausableSuspenseResult as b, type PausableReadResult as c, type Selector as d, type UseChainArgs as e, type UseChainsArgs as f, useChains as g, useExchangeRateAction as h, type UseExchangeRateArgs as i, useExchangeRate as j, type UseNetworkFeeRequestQuery as k, type UseNetworkFeeArgs as l, useChain as u };