@aave/react 4.0.0-next.5 → 4.0.0-next.51

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 -3
  2. package/dist/chunk-4LHXPD6N.js +2 -0
  3. package/dist/chunk-4LHXPD6N.js.map +1 -0
  4. package/dist/chunk-4NA4FB6K.js +2 -0
  5. package/dist/chunk-4NA4FB6K.js.map +1 -0
  6. package/dist/chunk-V6Q6TCNV.js +2 -0
  7. package/dist/chunk-V6Q6TCNV.js.map +1 -0
  8. package/dist/ethers.cjs +1 -1
  9. package/dist/ethers.cjs.map +1 -1
  10. package/dist/ethers.d.cts +10 -66
  11. package/dist/ethers.d.ts +10 -66
  12. package/dist/ethers.js +1 -1
  13. package/dist/ethers.js.map +1 -1
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +1571 -707
  17. package/dist/index.d.ts +1571 -707
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/{misc-gmAnSdm5.d.ts → misc-CLtLR-vZ.d.cts} +101 -24
  21. package/dist/{misc-BkG5G4yl.d.cts → misc-CfqYr0kO.d.ts} +101 -24
  22. package/dist/privy.cjs +1 -1
  23. package/dist/privy.cjs.map +1 -1
  24. package/dist/privy.d.cts +9 -54
  25. package/dist/privy.d.ts +9 -54
  26. package/dist/privy.js +1 -1
  27. package/dist/privy.js.map +1 -1
  28. package/dist/thirdweb.cjs +1 -1
  29. package/dist/thirdweb.cjs.map +1 -1
  30. package/dist/thirdweb.d.cts +9 -54
  31. package/dist/thirdweb.d.ts +9 -54
  32. package/dist/thirdweb.js +1 -1
  33. package/dist/thirdweb.js.map +1 -1
  34. package/dist/viem/index.cjs +1 -1
  35. package/dist/viem/index.cjs.map +1 -1
  36. package/dist/viem/index.d.cts +12 -56
  37. package/dist/viem/index.d.ts +12 -56
  38. package/dist/viem/index.js +1 -1
  39. package/dist/viem/index.js.map +1 -1
  40. package/dist/{writes-BXnwYgAQ.d.cts → writes-sBt0thuG.d.cts} +17 -6
  41. package/dist/{writes-BXnwYgAQ.d.ts → writes-sBt0thuG.d.ts} +17 -6
  42. package/package.json +9 -8
  43. package/dist/chunk-GTUQRT5Q.js +0 -2
  44. package/dist/chunk-GTUQRT5Q.js.map +0 -1
  45. package/dist/chunk-YJ6HF5HO.js +0 -2
  46. package/dist/chunk-YJ6HF5HO.js.map +0 -1
@@ -1,32 +1,59 @@
1
1
  import { UnexpectedError, CurrencyQueryOptions } from '@aave/client';
2
2
  import { UnexpectedError as UnexpectedError$1 } from '@aave/core';
3
- import { ChainRequest, Chain, ChainsFilter, ExchangeRateRequest, FiatAmount, ActivityItem, PreviewAction, NativeAmount } from '@aave/graphql';
3
+ import { ChainRequest, Chain, ChainsRequest, ExchangeRateRequest, ExchangeAmount, ActivityItem, PreviewAction, NativeAmount } from '@aave/graphql';
4
4
  import { NullishDeep, Prettify } from '@aave/types';
5
- import { a as UseAsyncTask } from './writes-BXnwYgAQ.js';
5
+ import { a as UseAsyncTask } from './writes-sBt0thuG.cjs';
6
6
 
7
+ /**
8
+ * @internal
9
+ */
10
+ type QueryMetadata = {
11
+ operationKey: number;
12
+ resultOperationKey: number | undefined;
13
+ };
7
14
  /**
8
15
  * A read hook result that supports pausing.
9
16
  */
10
- type PausableReadResult<T, E extends UnexpectedError = UnexpectedError> = {
17
+ type PausableReadResult<T, E = UnexpectedError> = {
11
18
  data: T | undefined;
12
19
  error: E | undefined;
13
20
  loading: false;
14
21
  paused: true;
22
+ reloading: false;
23
+ /**
24
+ * @internal
25
+ */
26
+ metadata: QueryMetadata;
15
27
  } | {
16
28
  data: undefined;
17
29
  error: undefined;
18
30
  loading: true;
19
31
  paused: false;
32
+ reloading: false;
33
+ /**
34
+ * @internal
35
+ */
36
+ metadata: QueryMetadata;
20
37
  } | {
21
38
  data: T;
22
39
  error: undefined;
23
40
  loading: false;
24
41
  paused: false;
42
+ reloading: boolean;
43
+ /**
44
+ * @internal
45
+ */
46
+ metadata: QueryMetadata;
25
47
  } | {
26
48
  data: undefined;
27
49
  error: E;
28
50
  loading: false;
29
51
  paused: false;
52
+ reloading: boolean;
53
+ /**
54
+ * @internal
55
+ */
56
+ metadata: QueryMetadata;
30
57
  };
31
58
  /**
32
59
  * A read hook result.
@@ -35,33 +62,52 @@ type PausableReadResult<T, E extends UnexpectedError = UnexpectedError> = {
35
62
  * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.
36
63
  * - If `error` is `undefined`, then `data` value will be available.
37
64
  */
38
- type ReadResult<T, E extends UnexpectedError = UnexpectedError> = {
65
+ type ReadResult<T, E = UnexpectedError> = {
39
66
  data: undefined;
40
67
  error: undefined;
41
68
  loading: true;
69
+ reloading: false;
70
+ /**
71
+ * @internal
72
+ */
73
+ metadata: QueryMetadata;
42
74
  } | {
43
75
  data: T;
44
76
  error: undefined;
45
77
  loading: false;
78
+ reloading: boolean;
79
+ /**
80
+ * @internal
81
+ */
82
+ metadata: QueryMetadata;
46
83
  } | {
47
84
  data: undefined;
48
85
  error: E;
49
86
  loading: false;
87
+ reloading: boolean;
88
+ /**
89
+ * @internal
90
+ */
91
+ metadata: QueryMetadata;
50
92
  };
51
93
  /**
52
94
  * @internal
53
95
  */
54
96
  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>;
97
+ Loading: <T, E = UnexpectedError>(metadata: QueryMetadata) => PausableReadResult<T, E>;
98
+ Success: <T, E = UnexpectedError>(data: T, metadata: QueryMetadata, reloading?: boolean) => PausableReadResult<T, E>;
99
+ Failure: <T, E = UnexpectedError>(error: E, metadata: QueryMetadata, reloading?: boolean) => PausableReadResult<T, E>;
100
+ Paused: <T, E = UnexpectedError>(data: T | undefined, error: E | undefined, metadata: QueryMetadata) => PausableReadResult<T, E>;
59
101
  };
60
102
  /**
61
103
  * A read hook result that supports React Suspense.
62
104
  */
63
105
  type SuspenseResult<T> = {
64
106
  data: T;
107
+ /**
108
+ * @internal
109
+ */
110
+ metadata: QueryMetadata;
65
111
  };
66
112
  /**
67
113
  * A read hook result that supports React Suspense and can be paused.
@@ -69,12 +115,19 @@ type SuspenseResult<T> = {
69
115
  type PausableSuspenseResult<T> = {
70
116
  paused: true;
71
117
  data: undefined;
118
+ /**
119
+ * @internal
120
+ */
121
+ metadata: QueryMetadata;
72
122
  } | {
73
123
  paused: false;
74
124
  data: T;
125
+ /**
126
+ * @internal
127
+ */
128
+ metadata: QueryMetadata;
75
129
  };
76
130
 
77
- type Selector<T, V> = (data: T) => V;
78
131
  type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<WhenPaused & {
79
132
  /**
80
133
  * Prevents the hook from automatically executing GraphQL query operations.
@@ -83,8 +136,8 @@ type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<WhenPaused & {
83
136
  *
84
137
  * @remarks
85
138
  * `pause` may be set to `true` to stop the query operation from executing
86
- * automatically. The hook will stop receiving updates and wont execute the query
87
- * operation until its set to `false`.
139
+ * automatically. The hook will stop receiving updates and won't execute the query
140
+ * operation until it's set to `false`.
88
141
  */
89
142
  pause: boolean;
90
143
  }>;
@@ -145,9 +198,33 @@ declare function useChain(args: UseChainArgs): ReadResult<Chain | null>;
145
198
  * ```
146
199
  */
147
200
  declare function useChain(args: Pausable<UseChainArgs>): PausableReadResult<Chain | null>;
148
- type UseChainsArgs = {
149
- filter: ChainsFilter;
150
- };
201
+ /**
202
+ * Low-level hook to execute a {@link chain} action directly.
203
+ *
204
+ * @experimental This hook is experimental and may be subject to breaking changes.
205
+ * @remarks
206
+ * This hook **does not** actively watch for updated data on the chain.
207
+ * Use this hook to retrieve data on demand as part of a larger workflow
208
+ * (e.g., in an event handler in order to move to the next step).
209
+ *
210
+ * ```ts
211
+ * const [execute, { called, data, error, loading }] = useChainAction();
212
+ *
213
+ * // …
214
+ *
215
+ * const result = await execute({
216
+ * chainId: chainId(1),
217
+ * });
218
+ *
219
+ * if (result.isOk()) {
220
+ * console.log(result.value); // Chain | null
221
+ * } else {
222
+ * console.error(result.error);
223
+ * }
224
+ * ```
225
+ */
226
+ declare function useChainAction(): UseAsyncTask<ChainRequest, Chain | null, UnexpectedError$1>;
227
+ type UseChainsArgs = ChainsRequest;
151
228
  /**
152
229
  * Fetches the list of supported chains.
153
230
  *
@@ -155,7 +232,7 @@ type UseChainsArgs = {
155
232
  *
156
233
  * ```tsx
157
234
  * const { data } = useChains({
158
- * filter: ChainsFilter.ALL,
235
+ * query: { filter: ChainsFilter.ALL },
159
236
  * suspense: true,
160
237
  * });
161
238
  * ```
@@ -168,7 +245,7 @@ declare function useChains(args: UseChainsArgs & Suspendable): SuspenseResult<Ch
168
245
  *
169
246
  * ```tsx
170
247
  * const { data } = useChains({
171
- * filter: ChainsFilter.ALL,
248
+ * query: { filter: ChainsFilter.ALL },
172
249
  * suspense: true,
173
250
  * pause: true,
174
251
  * });
@@ -180,7 +257,7 @@ declare function useChains(args: Pausable<UseChainsArgs> & Suspendable): Pausabl
180
257
  *
181
258
  * ```tsx
182
259
  * const { data, error, loading } = useChains({
183
- * filter: ChainsFilter.ALL,
260
+ * query: { filter: ChainsFilter.ALL },
184
261
  * });
185
262
  * ```
186
263
  */
@@ -192,7 +269,7 @@ declare function useChains(args?: UseChainsArgs): ReadResult<Chain[]>;
192
269
  *
193
270
  * ```tsx
194
271
  * const { data, error, loading, paused } = useChains({
195
- * filter: ChainsFilter.ALL,
272
+ * query: { filter: ChainsFilter.ALL },
196
273
  * pause: true,
197
274
  * });
198
275
  * ```
@@ -222,7 +299,7 @@ declare function useChains(args?: Pausable<UseChainsArgs>): PausableReadResult<C
222
299
  * console.log('Exchange rate:', result.value);
223
300
  * ```
224
301
  */
225
- declare function useExchangeRateAction(): UseAsyncTask<ExchangeRateRequest, FiatAmount, UnexpectedError$1>;
302
+ declare function useExchangeRateAction(): UseAsyncTask<ExchangeRateRequest, ExchangeAmount, UnexpectedError$1>;
226
303
  type UseExchangeRateArgs = ExchangeRateRequest;
227
304
  /**
228
305
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
@@ -242,7 +319,7 @@ type UseExchangeRateArgs = ExchangeRateRequest;
242
319
  * });
243
320
  * ```
244
321
  */
245
- declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): SuspenseResult<FiatAmount>;
322
+ declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): SuspenseResult<ExchangeAmount>;
246
323
  /**
247
324
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
248
325
  *
@@ -262,7 +339,7 @@ declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): Suspe
262
339
  * });
263
340
  * ```
264
341
  */
265
- declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendable): PausableSuspenseResult<FiatAmount>;
342
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendable): PausableSuspenseResult<ExchangeAmount>;
266
343
  /**
267
344
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
268
345
  *
@@ -280,7 +357,7 @@ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendab
280
357
  * <Component value={somewhere} fxRate={data} />
281
358
  * ```
282
359
  */
283
- declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<FiatAmount>;
360
+ declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<ExchangeAmount>;
284
361
  /**
285
362
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
286
363
  *
@@ -299,7 +376,7 @@ declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<FiatAmou
299
376
  * });
300
377
  * ```
301
378
  */
302
- declare function useExchangeRate(args: Pausable<UseExchangeRateArgs>): PausableReadResult<FiatAmount>;
379
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs>): PausableReadResult<ExchangeAmount>;
303
380
  type UseNetworkFeeRequestQuery = {
304
381
  activity: ActivityItem;
305
382
  } | {
@@ -374,4 +451,4 @@ type UseNetworkFee<T extends NativeAmount = NativeAmount> =
374
451
  */
375
452
  ((args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs>) => PausableReadResult<T>);
376
453
 
377
- 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 };
454
+ 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 UseChainArgs as d, useChainAction 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 };
@@ -1,32 +1,59 @@
1
1
  import { UnexpectedError, CurrencyQueryOptions } from '@aave/client';
2
2
  import { UnexpectedError as UnexpectedError$1 } from '@aave/core';
3
- import { ChainRequest, Chain, ChainsFilter, ExchangeRateRequest, FiatAmount, ActivityItem, PreviewAction, NativeAmount } from '@aave/graphql';
3
+ import { ChainRequest, Chain, ChainsRequest, ExchangeRateRequest, ExchangeAmount, ActivityItem, PreviewAction, NativeAmount } from '@aave/graphql';
4
4
  import { NullishDeep, Prettify } from '@aave/types';
5
- import { a as UseAsyncTask } from './writes-BXnwYgAQ.cjs';
5
+ import { a as UseAsyncTask } from './writes-sBt0thuG.js';
6
6
 
7
+ /**
8
+ * @internal
9
+ */
10
+ type QueryMetadata = {
11
+ operationKey: number;
12
+ resultOperationKey: number | undefined;
13
+ };
7
14
  /**
8
15
  * A read hook result that supports pausing.
9
16
  */
10
- type PausableReadResult<T, E extends UnexpectedError = UnexpectedError> = {
17
+ type PausableReadResult<T, E = UnexpectedError> = {
11
18
  data: T | undefined;
12
19
  error: E | undefined;
13
20
  loading: false;
14
21
  paused: true;
22
+ reloading: false;
23
+ /**
24
+ * @internal
25
+ */
26
+ metadata: QueryMetadata;
15
27
  } | {
16
28
  data: undefined;
17
29
  error: undefined;
18
30
  loading: true;
19
31
  paused: false;
32
+ reloading: false;
33
+ /**
34
+ * @internal
35
+ */
36
+ metadata: QueryMetadata;
20
37
  } | {
21
38
  data: T;
22
39
  error: undefined;
23
40
  loading: false;
24
41
  paused: false;
42
+ reloading: boolean;
43
+ /**
44
+ * @internal
45
+ */
46
+ metadata: QueryMetadata;
25
47
  } | {
26
48
  data: undefined;
27
49
  error: E;
28
50
  loading: false;
29
51
  paused: false;
52
+ reloading: boolean;
53
+ /**
54
+ * @internal
55
+ */
56
+ metadata: QueryMetadata;
30
57
  };
31
58
  /**
32
59
  * A read hook result.
@@ -35,33 +62,52 @@ type PausableReadResult<T, E extends UnexpectedError = UnexpectedError> = {
35
62
  * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.
36
63
  * - If `error` is `undefined`, then `data` value will be available.
37
64
  */
38
- type ReadResult<T, E extends UnexpectedError = UnexpectedError> = {
65
+ type ReadResult<T, E = UnexpectedError> = {
39
66
  data: undefined;
40
67
  error: undefined;
41
68
  loading: true;
69
+ reloading: false;
70
+ /**
71
+ * @internal
72
+ */
73
+ metadata: QueryMetadata;
42
74
  } | {
43
75
  data: T;
44
76
  error: undefined;
45
77
  loading: false;
78
+ reloading: boolean;
79
+ /**
80
+ * @internal
81
+ */
82
+ metadata: QueryMetadata;
46
83
  } | {
47
84
  data: undefined;
48
85
  error: E;
49
86
  loading: false;
87
+ reloading: boolean;
88
+ /**
89
+ * @internal
90
+ */
91
+ metadata: QueryMetadata;
50
92
  };
51
93
  /**
52
94
  * @internal
53
95
  */
54
96
  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>;
97
+ Loading: <T, E = UnexpectedError>(metadata: QueryMetadata) => PausableReadResult<T, E>;
98
+ Success: <T, E = UnexpectedError>(data: T, metadata: QueryMetadata, reloading?: boolean) => PausableReadResult<T, E>;
99
+ Failure: <T, E = UnexpectedError>(error: E, metadata: QueryMetadata, reloading?: boolean) => PausableReadResult<T, E>;
100
+ Paused: <T, E = UnexpectedError>(data: T | undefined, error: E | undefined, metadata: QueryMetadata) => PausableReadResult<T, E>;
59
101
  };
60
102
  /**
61
103
  * A read hook result that supports React Suspense.
62
104
  */
63
105
  type SuspenseResult<T> = {
64
106
  data: T;
107
+ /**
108
+ * @internal
109
+ */
110
+ metadata: QueryMetadata;
65
111
  };
66
112
  /**
67
113
  * A read hook result that supports React Suspense and can be paused.
@@ -69,12 +115,19 @@ type SuspenseResult<T> = {
69
115
  type PausableSuspenseResult<T> = {
70
116
  paused: true;
71
117
  data: undefined;
118
+ /**
119
+ * @internal
120
+ */
121
+ metadata: QueryMetadata;
72
122
  } | {
73
123
  paused: false;
74
124
  data: T;
125
+ /**
126
+ * @internal
127
+ */
128
+ metadata: QueryMetadata;
75
129
  };
76
130
 
77
- type Selector<T, V> = (data: T) => V;
78
131
  type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<WhenPaused & {
79
132
  /**
80
133
  * Prevents the hook from automatically executing GraphQL query operations.
@@ -83,8 +136,8 @@ type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<WhenPaused & {
83
136
  *
84
137
  * @remarks
85
138
  * `pause` may be set to `true` to stop the query operation from executing
86
- * automatically. The hook will stop receiving updates and wont execute the query
87
- * operation until its set to `false`.
139
+ * automatically. The hook will stop receiving updates and won't execute the query
140
+ * operation until it's set to `false`.
88
141
  */
89
142
  pause: boolean;
90
143
  }>;
@@ -145,9 +198,33 @@ declare function useChain(args: UseChainArgs): ReadResult<Chain | null>;
145
198
  * ```
146
199
  */
147
200
  declare function useChain(args: Pausable<UseChainArgs>): PausableReadResult<Chain | null>;
148
- type UseChainsArgs = {
149
- filter: ChainsFilter;
150
- };
201
+ /**
202
+ * Low-level hook to execute a {@link chain} action directly.
203
+ *
204
+ * @experimental This hook is experimental and may be subject to breaking changes.
205
+ * @remarks
206
+ * This hook **does not** actively watch for updated data on the chain.
207
+ * Use this hook to retrieve data on demand as part of a larger workflow
208
+ * (e.g., in an event handler in order to move to the next step).
209
+ *
210
+ * ```ts
211
+ * const [execute, { called, data, error, loading }] = useChainAction();
212
+ *
213
+ * // …
214
+ *
215
+ * const result = await execute({
216
+ * chainId: chainId(1),
217
+ * });
218
+ *
219
+ * if (result.isOk()) {
220
+ * console.log(result.value); // Chain | null
221
+ * } else {
222
+ * console.error(result.error);
223
+ * }
224
+ * ```
225
+ */
226
+ declare function useChainAction(): UseAsyncTask<ChainRequest, Chain | null, UnexpectedError$1>;
227
+ type UseChainsArgs = ChainsRequest;
151
228
  /**
152
229
  * Fetches the list of supported chains.
153
230
  *
@@ -155,7 +232,7 @@ type UseChainsArgs = {
155
232
  *
156
233
  * ```tsx
157
234
  * const { data } = useChains({
158
- * filter: ChainsFilter.ALL,
235
+ * query: { filter: ChainsFilter.ALL },
159
236
  * suspense: true,
160
237
  * });
161
238
  * ```
@@ -168,7 +245,7 @@ declare function useChains(args: UseChainsArgs & Suspendable): SuspenseResult<Ch
168
245
  *
169
246
  * ```tsx
170
247
  * const { data } = useChains({
171
- * filter: ChainsFilter.ALL,
248
+ * query: { filter: ChainsFilter.ALL },
172
249
  * suspense: true,
173
250
  * pause: true,
174
251
  * });
@@ -180,7 +257,7 @@ declare function useChains(args: Pausable<UseChainsArgs> & Suspendable): Pausabl
180
257
  *
181
258
  * ```tsx
182
259
  * const { data, error, loading } = useChains({
183
- * filter: ChainsFilter.ALL,
260
+ * query: { filter: ChainsFilter.ALL },
184
261
  * });
185
262
  * ```
186
263
  */
@@ -192,7 +269,7 @@ declare function useChains(args?: UseChainsArgs): ReadResult<Chain[]>;
192
269
  *
193
270
  * ```tsx
194
271
  * const { data, error, loading, paused } = useChains({
195
- * filter: ChainsFilter.ALL,
272
+ * query: { filter: ChainsFilter.ALL },
196
273
  * pause: true,
197
274
  * });
198
275
  * ```
@@ -222,7 +299,7 @@ declare function useChains(args?: Pausable<UseChainsArgs>): PausableReadResult<C
222
299
  * console.log('Exchange rate:', result.value);
223
300
  * ```
224
301
  */
225
- declare function useExchangeRateAction(): UseAsyncTask<ExchangeRateRequest, FiatAmount, UnexpectedError$1>;
302
+ declare function useExchangeRateAction(): UseAsyncTask<ExchangeRateRequest, ExchangeAmount, UnexpectedError$1>;
226
303
  type UseExchangeRateArgs = ExchangeRateRequest;
227
304
  /**
228
305
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
@@ -242,7 +319,7 @@ type UseExchangeRateArgs = ExchangeRateRequest;
242
319
  * });
243
320
  * ```
244
321
  */
245
- declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): SuspenseResult<FiatAmount>;
322
+ declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): SuspenseResult<ExchangeAmount>;
246
323
  /**
247
324
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
248
325
  *
@@ -262,7 +339,7 @@ declare function useExchangeRate(args: UseExchangeRateArgs & Suspendable): Suspe
262
339
  * });
263
340
  * ```
264
341
  */
265
- declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendable): PausableSuspenseResult<FiatAmount>;
342
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendable): PausableSuspenseResult<ExchangeAmount>;
266
343
  /**
267
344
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
268
345
  *
@@ -280,7 +357,7 @@ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs> & Suspendab
280
357
  * <Component value={somewhere} fxRate={data} />
281
358
  * ```
282
359
  */
283
- declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<FiatAmount>;
360
+ declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<ExchangeAmount>;
284
361
  /**
285
362
  * Fetches exchange rates between tokens and fiat currencies with automatic polling.
286
363
  *
@@ -299,7 +376,7 @@ declare function useExchangeRate(args: UseExchangeRateArgs): ReadResult<FiatAmou
299
376
  * });
300
377
  * ```
301
378
  */
302
- declare function useExchangeRate(args: Pausable<UseExchangeRateArgs>): PausableReadResult<FiatAmount>;
379
+ declare function useExchangeRate(args: Pausable<UseExchangeRateArgs>): PausableReadResult<ExchangeAmount>;
303
380
  type UseNetworkFeeRequestQuery = {
304
381
  activity: ActivityItem;
305
382
  } | {
@@ -374,4 +451,4 @@ type UseNetworkFee<T extends NativeAmount = NativeAmount> =
374
451
  */
375
452
  ((args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs>) => PausableReadResult<T>);
376
453
 
377
- 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 };
454
+ 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 UseChainArgs as d, useChainAction 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 };
package/dist/privy.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var client=require('@aave/client'),viem$1=require('@aave/client/viem'),types=require('@aave/types'),reactAuth=require('@privy-io/react-auth'),viem=require('viem'),P=require('react');require('@aave/core');var actions=require('@aave/client/actions');require('urql');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var P__default=/*#__PURE__*/_interopDefault(P);var c={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function o(e,r){let[n,t]=P.useState(c.Idle()),a=P.useRef(false),d=P.useCallback(e,r);return [P.useCallback(A=>{types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true,t(({data:s})=>({called:true,loading:true,data:s,error:void 0}));let T=d(A);return T.match(s=>{a.current=false,t(c.Success(s));},s=>{a.current=false,t(c.Failed(s));}),T},[d]),n]}var i=class e{constructor(r){this.wait=r;}static ensure(r){return types.invariant(r instanceof e,"Expected PendingTransaction"),r}};var k=P__default.default.createContext(null);function l(){let e=P.useContext(k);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function y(){let e=l();return o(r=>actions.permitTypedData(e,r),[e])}function se(){let{wallets:e}=reactAuth.useWallets();return o(r=>{let n=e.find(t=>t.address===r.from);return types.invariant(n,`Expected a connected wallet with address ${r.from} to be found.`),types.ResultAsync.fromPromise(n.switchChain(r.chainId),t=>client.UnexpectedError.from(t)).map(()=>n.getEthereumProvider()).map(t=>viem.createWalletClient({account:r.from,chain:viem$1.supportedChains[r.chainId],transport:viem.custom(t)})).andThen(t=>viem$1.sendTransaction(t,r).map(a=>new i(()=>viem$1.waitForTransactionResult(t,r,a))))},[e])}function ie(){let[e]=y(),{signTypedData:r}=reactAuth.useSignTypedData();return o(n=>e(n).andThen(t=>types.ResultAsync.fromPromise(r({types:t.types,primaryType:t.primaryType,domain:t.domain,message:t.message}),a=>client.SigningError.from(a)).map(({signature:a})=>({deadline:t.message.deadline,value:types.signatureFrom(a)}))),[e,r])}function ce(){let{signTypedData:e}=reactAuth.useSignTypedData();return o(r=>{let n=JSON.parse(r.message);return types.ResultAsync.fromPromise(e({types:r.types,primaryType:r.primaryType,domain:r.domain,message:n}),t=>client.SigningError.from(t)).map(({signature:t})=>({deadline:n.deadline,value:types.signatureFrom(t)}))},[e])}exports.useERC20Permit=ie;exports.useSendTransaction=se;exports.useSignSwapTypedDataWith=ce;//# sourceMappingURL=privy.cjs.map
1
+ 'use strict';var client=require('@aave/client'),viem=require('@aave/client/viem'),types=require('@aave/types'),reactAuth=require('@privy-io/react-auth'),viem$1=require('viem'),k=require('react'),core=require('@aave/core'),actions=require('@aave/client/actions');require('@aave/graphql'),require('urql');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var k__default=/*#__PURE__*/_interopDefault(k);var d={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function u(e,t){let[n,s]=k.useState(d.Idle()),r=k.useRef(false),a=k.useRef(true);k.useEffect(()=>()=>{a.current=false;},[]);let i=k.useCallback(e,t);return [k.useCallback(A=>{types.invariant(a.current,"Cannot execute a task on an unmounted component."),types.invariant(!r.current,"Cannot execute a task while another is in progress."),r.current=true;let l;s(o=>(l=o,{called:true,loading:true,data:o.data,error:void 0}));try{let o=i(A);return o.match(p=>{r.current=!1,s(d.Success(p));},p=>{r.current=!1,s(d.Failed(p));}),o}catch(o){throw r.current=false,l&&s(l),o}},[i]),n]}var c=class e{constructor(t){this.wait=t;}static isInstanceOf(t){return t instanceof e}static tryFrom(t){return e.isInstanceOf(t)?types.okAsync(t):core.UnexpectedError.from(t).asResultAsync()}};var v=k__default.default.createContext(null);function f(){let e=k.useContext(v);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function m(){let e=f();return u(t=>actions.chain(e,t,{batch:false,requestPolicy:"cache-first"}),[e])}function H(e){if(e&&typeof e=="object"){if("code"in e&&e.code===4001)return true;if("message"in e&&typeof e.message=="string"){let t=e.message.toLowerCase();return t.includes("user rejected")||t.includes("user denied")||t.includes("rejected the request")}}return false}function xe(){let{wallets:e}=reactAuth.useWallets(),[t]=m();return u(n=>{let s=e.find(r=>r.address===n.from);return types.invariant(s,`Expected a connected wallet with address ${n.from} to be found.`),t({chainId:n.chainId}).map(r=>(types.invariant(r,`Chain ${n.chainId} is not supported`),viem.toViemChain(r))).andThen(r=>types.ResultAsync.fromPromise(s.switchChain(n.chainId),a=>client.UnexpectedError.from(a)).map(()=>s.getEthereumProvider()).map(a=>viem$1.createWalletClient({account:n.from,chain:r,transport:viem$1.custom(a)})).andThen(a=>viem.sendTransaction(a,n).map(i=>new c(()=>viem.waitForTransactionResult(a,n,i)))))},[e,t])}function Ae(){let{signTypedData:e}=reactAuth.useSignTypedData();return u(t=>types.ResultAsync.fromPromise(e({domain:t.domain,types:t.types,primaryType:t.primaryType,message:t.message}),n=>H(n)?client.CancelError.from(n):client.SigningError.from(n)).map(({signature:n})=>types.signatureFrom(n)),[e])}exports.useSendTransaction=xe;exports.useSignTypedData=Ae;//# sourceMappingURL=privy.cjs.map
2
2
  //# sourceMappingURL=privy.cjs.map