wagmi 3.1.3 → 3.2.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 (56) hide show
  1. package/dist/esm/exports/tempo.js +9 -0
  2. package/dist/esm/exports/tempo.js.map +1 -0
  3. package/dist/esm/tempo/Hooks/amm.js +534 -0
  4. package/dist/esm/tempo/Hooks/amm.js.map +1 -0
  5. package/dist/esm/tempo/Hooks/dex.js +944 -0
  6. package/dist/esm/tempo/Hooks/dex.js.map +1 -0
  7. package/dist/esm/tempo/Hooks/faucet.js +76 -0
  8. package/dist/esm/tempo/Hooks/faucet.js.map +1 -0
  9. package/dist/esm/tempo/Hooks/fee.js +155 -0
  10. package/dist/esm/tempo/Hooks/fee.js.map +1 -0
  11. package/dist/esm/tempo/Hooks/index.js +11 -0
  12. package/dist/esm/tempo/Hooks/index.js.map +1 -0
  13. package/dist/esm/tempo/Hooks/nonce.js +165 -0
  14. package/dist/esm/tempo/Hooks/nonce.js.map +1 -0
  15. package/dist/esm/tempo/Hooks/policy.js +545 -0
  16. package/dist/esm/tempo/Hooks/policy.js.map +1 -0
  17. package/dist/esm/tempo/Hooks/reward.js +385 -0
  18. package/dist/esm/tempo/Hooks/reward.js.map +1 -0
  19. package/dist/esm/tempo/Hooks/token.js +1730 -0
  20. package/dist/esm/tempo/Hooks/token.js.map +1 -0
  21. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  22. package/dist/esm/version.js +1 -1
  23. package/dist/types/exports/tempo.d.ts +4 -0
  24. package/dist/types/exports/tempo.d.ts.map +1 -0
  25. package/dist/types/tempo/Hooks/amm.d.ts +410 -0
  26. package/dist/types/tempo/Hooks/amm.d.ts.map +1 -0
  27. package/dist/types/tempo/Hooks/dex.d.ts +773 -0
  28. package/dist/types/tempo/Hooks/dex.d.ts.map +1 -0
  29. package/dist/types/tempo/Hooks/faucet.d.ts +70 -0
  30. package/dist/types/tempo/Hooks/faucet.d.ts.map +1 -0
  31. package/dist/types/tempo/Hooks/fee.d.ts +123 -0
  32. package/dist/types/tempo/Hooks/fee.d.ts.map +1 -0
  33. package/dist/types/tempo/Hooks/index.d.ts +10 -0
  34. package/dist/types/tempo/Hooks/index.d.ts.map +1 -0
  35. package/dist/types/tempo/Hooks/nonce.d.ts +115 -0
  36. package/dist/types/tempo/Hooks/nonce.d.ts.map +1 -0
  37. package/dist/types/tempo/Hooks/policy.d.ts +422 -0
  38. package/dist/types/tempo/Hooks/policy.d.ts.map +1 -0
  39. package/dist/types/tempo/Hooks/reward.d.ts +304 -0
  40. package/dist/types/tempo/Hooks/reward.d.ts.map +1 -0
  41. package/dist/types/tempo/Hooks/token.d.ts +1387 -0
  42. package/dist/types/tempo/Hooks/token.d.ts.map +1 -0
  43. package/dist/types/version.d.ts +1 -1
  44. package/package.json +12 -4
  45. package/src/exports/tempo.ts +17 -0
  46. package/src/tempo/Hooks/amm.ts +835 -0
  47. package/src/tempo/Hooks/dex.ts +1597 -0
  48. package/src/tempo/Hooks/faucet.ts +142 -0
  49. package/src/tempo/Hooks/fee.ts +264 -0
  50. package/src/tempo/Hooks/index.ts +10 -0
  51. package/src/tempo/Hooks/nonce.ts +248 -0
  52. package/src/tempo/Hooks/policy.ts +907 -0
  53. package/src/tempo/Hooks/reward.ts +668 -0
  54. package/src/tempo/Hooks/token.ts +2979 -0
  55. package/src/version.ts +1 -1
  56. package/tempo/package.json +5 -0
@@ -0,0 +1,907 @@
1
+ import type { UseMutationResult } from '@tanstack/react-query'
2
+ import type { Config, ResolvedRegister } from '@wagmi/core'
3
+ import type { ExactPartial, UnionCompute } from '@wagmi/core/internal'
4
+ import { Actions } from '@wagmi/core/tempo'
5
+ import { useEffect } from 'react'
6
+
7
+ import { useChainId } from '../../hooks/useChainId.js'
8
+ import { useConfig } from '../../hooks/useConfig.js'
9
+ import type { ConfigParameter, QueryParameter } from '../../types/properties.js'
10
+ import {
11
+ type UseMutationParameters,
12
+ type UseQueryReturnType,
13
+ useMutation,
14
+ useQuery,
15
+ } from '../../utils/query.js'
16
+
17
+ /**
18
+ * Hook for creating a new policy.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { Hooks } from 'wagmi/tempo'
23
+ *
24
+ * function App() {
25
+ * const { mutate, isPending } = Hooks.policy.useCreate()
26
+ *
27
+ * return (
28
+ * <button
29
+ * onClick={() => mutate({ type: 'whitelist' })}
30
+ * disabled={isPending}
31
+ * >
32
+ * Create Policy
33
+ * </button>
34
+ * )
35
+ * }
36
+ * ```
37
+ *
38
+ * @param parameters - Parameters.
39
+ * @returns Mutation result.
40
+ */
41
+ export function useCreate<
42
+ config extends Config = ResolvedRegister['config'],
43
+ context = unknown,
44
+ >(
45
+ parameters: useCreate.Parameters<config, context> = {},
46
+ ): useCreate.ReturnType<config, context> {
47
+ const { mutation } = parameters
48
+ const config = useConfig(parameters)
49
+ return useMutation({
50
+ ...mutation,
51
+ async mutationFn(variables) {
52
+ return Actions.policy.create(config, variables as never)
53
+ },
54
+ mutationKey: ['create'],
55
+ }) as never
56
+ }
57
+
58
+ export declare namespace useCreate {
59
+ type Parameters<
60
+ config extends Config = Config,
61
+ context = unknown,
62
+ > = ConfigParameter<config> & {
63
+ mutation?:
64
+ | UseMutationParameters<
65
+ Actions.policy.create.ReturnValue,
66
+ Actions.policy.create.ErrorType,
67
+ Actions.policy.create.Parameters<config>,
68
+ context
69
+ >
70
+ | undefined
71
+ }
72
+
73
+ type ReturnType<
74
+ config extends Config = Config,
75
+ context = unknown,
76
+ > = UseMutationResult<
77
+ Actions.policy.create.ReturnValue,
78
+ Actions.policy.create.ErrorType,
79
+ Actions.policy.create.Parameters<config>,
80
+ context
81
+ >
82
+ }
83
+
84
+ /**
85
+ * Hook for creating a new policy.
86
+ *
87
+ * Note: This is a synchronous hook that waits for the transaction
88
+ * to be included on a block before returning a response.
89
+ *
90
+ * @example
91
+ * ```tsx
92
+ * import { Hooks } from 'wagmi/tempo'
93
+ *
94
+ * function App() {
95
+ * const { mutate, isPending } = Hooks.policy.useCreateSync()
96
+ *
97
+ * return (
98
+ * <button
99
+ * onClick={() => mutate({ type: 'whitelist' })}
100
+ * disabled={isPending}
101
+ * >
102
+ * Create Policy
103
+ * </button>
104
+ * )
105
+ * }
106
+ * ```
107
+ *
108
+ * @param parameters - Parameters.
109
+ * @returns Mutation result.
110
+ */
111
+ export function useCreateSync<
112
+ config extends Config = ResolvedRegister['config'],
113
+ context = unknown,
114
+ >(
115
+ parameters: useCreateSync.Parameters<config, context> = {},
116
+ ): useCreateSync.ReturnType<config, context> {
117
+ const { mutation } = parameters
118
+ const config = useConfig(parameters)
119
+ return useMutation({
120
+ ...mutation,
121
+ async mutationFn(variables) {
122
+ return Actions.policy.createSync(config, variables as never)
123
+ },
124
+ mutationKey: ['createSync'],
125
+ }) as never
126
+ }
127
+
128
+ export declare namespace useCreateSync {
129
+ type Parameters<
130
+ config extends Config = Config,
131
+ context = unknown,
132
+ > = ConfigParameter<config> & {
133
+ mutation?:
134
+ | UseMutationParameters<
135
+ Actions.policy.createSync.ReturnValue,
136
+ Actions.policy.createSync.ErrorType,
137
+ Actions.policy.createSync.Parameters<config>,
138
+ context
139
+ >
140
+ | undefined
141
+ }
142
+
143
+ type ReturnType<
144
+ config extends Config = Config,
145
+ context = unknown,
146
+ > = UseMutationResult<
147
+ Actions.policy.createSync.ReturnValue,
148
+ Actions.policy.createSync.ErrorType,
149
+ Actions.policy.createSync.Parameters<config>,
150
+ context
151
+ >
152
+ }
153
+
154
+ /**
155
+ * Hook for setting the admin for a policy.
156
+ *
157
+ * @example
158
+ * ```tsx
159
+ * import { Hooks } from 'wagmi/tempo'
160
+ *
161
+ * function App() {
162
+ * const { mutate, isPending } = Hooks.policy.useSetAdmin()
163
+ *
164
+ * return (
165
+ * <button
166
+ * onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
167
+ * disabled={isPending}
168
+ * >
169
+ * Set Admin
170
+ * </button>
171
+ * )
172
+ * }
173
+ * ```
174
+ *
175
+ * @param parameters - Parameters.
176
+ * @returns Mutation result.
177
+ */
178
+ export function useSetAdmin<
179
+ config extends Config = ResolvedRegister['config'],
180
+ context = unknown,
181
+ >(
182
+ parameters: useSetAdmin.Parameters<config, context> = {},
183
+ ): useSetAdmin.ReturnType<config, context> {
184
+ const { mutation } = parameters
185
+ const config = useConfig(parameters)
186
+ return useMutation({
187
+ ...mutation,
188
+ async mutationFn(variables) {
189
+ return Actions.policy.setAdmin(config, variables as never)
190
+ },
191
+ mutationKey: ['setAdmin'],
192
+ }) as never
193
+ }
194
+
195
+ export declare namespace useSetAdmin {
196
+ type Parameters<
197
+ config extends Config = Config,
198
+ context = unknown,
199
+ > = ConfigParameter<config> & {
200
+ mutation?:
201
+ | UseMutationParameters<
202
+ Actions.policy.setAdmin.ReturnValue,
203
+ Actions.policy.setAdmin.ErrorType,
204
+ Actions.policy.setAdmin.Parameters<config>,
205
+ context
206
+ >
207
+ | undefined
208
+ }
209
+
210
+ type ReturnType<
211
+ config extends Config = Config,
212
+ context = unknown,
213
+ > = UseMutationResult<
214
+ Actions.policy.setAdmin.ReturnValue,
215
+ Actions.policy.setAdmin.ErrorType,
216
+ Actions.policy.setAdmin.Parameters<config>,
217
+ context
218
+ >
219
+ }
220
+
221
+ /**
222
+ * Hook for setting the admin for a policy.
223
+ *
224
+ * Note: This is a synchronous hook that waits for the transaction
225
+ * to be included on a block before returning a response.
226
+ *
227
+ * @example
228
+ * ```tsx
229
+ * import { Hooks } from 'wagmi/tempo'
230
+ *
231
+ * function App() {
232
+ * const { mutate, isPending } = Hooks.policy.useSetAdminSync()
233
+ *
234
+ * return (
235
+ * <button
236
+ * onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
237
+ * disabled={isPending}
238
+ * >
239
+ * Set Admin
240
+ * </button>
241
+ * )
242
+ * }
243
+ * ```
244
+ *
245
+ * @param parameters - Parameters.
246
+ * @returns Mutation result.
247
+ */
248
+ export function useSetAdminSync<
249
+ config extends Config = ResolvedRegister['config'],
250
+ context = unknown,
251
+ >(
252
+ parameters: useSetAdminSync.Parameters<config, context> = {},
253
+ ): useSetAdminSync.ReturnType<config, context> {
254
+ const { mutation } = parameters
255
+ const config = useConfig(parameters)
256
+ return useMutation({
257
+ ...mutation,
258
+ async mutationFn(variables) {
259
+ return Actions.policy.setAdminSync(config, variables as never)
260
+ },
261
+ mutationKey: ['setAdminSync'],
262
+ }) as never
263
+ }
264
+
265
+ export declare namespace useSetAdminSync {
266
+ type Parameters<
267
+ config extends Config = Config,
268
+ context = unknown,
269
+ > = ConfigParameter<config> & {
270
+ mutation?:
271
+ | UseMutationParameters<
272
+ Actions.policy.setAdminSync.ReturnValue,
273
+ Actions.policy.setAdminSync.ErrorType,
274
+ Actions.policy.setAdminSync.Parameters<config>,
275
+ context
276
+ >
277
+ | undefined
278
+ }
279
+
280
+ type ReturnType<
281
+ config extends Config = Config,
282
+ context = unknown,
283
+ > = UseMutationResult<
284
+ Actions.policy.setAdminSync.ReturnValue,
285
+ Actions.policy.setAdminSync.ErrorType,
286
+ Actions.policy.setAdminSync.Parameters<config>,
287
+ context
288
+ >
289
+ }
290
+
291
+ /**
292
+ * Hook for modifying a policy whitelist.
293
+ *
294
+ * @example
295
+ * ```tsx
296
+ * import { Hooks } from 'wagmi/tempo'
297
+ *
298
+ * function App() {
299
+ * const { mutate, isPending } = Hooks.policy.useModifyWhitelist()
300
+ *
301
+ * return (
302
+ * <button
303
+ * onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
304
+ * disabled={isPending}
305
+ * >
306
+ * Add to Whitelist
307
+ * </button>
308
+ * )
309
+ * }
310
+ * ```
311
+ *
312
+ * @param parameters - Parameters.
313
+ * @returns Mutation result.
314
+ */
315
+ export function useModifyWhitelist<
316
+ config extends Config = ResolvedRegister['config'],
317
+ context = unknown,
318
+ >(
319
+ parameters: useModifyWhitelist.Parameters<config, context> = {},
320
+ ): useModifyWhitelist.ReturnType<config, context> {
321
+ const { mutation } = parameters
322
+ const config = useConfig(parameters)
323
+ return useMutation({
324
+ ...mutation,
325
+ async mutationFn(variables) {
326
+ return Actions.policy.modifyWhitelist(config, variables as never)
327
+ },
328
+ mutationKey: ['modifyWhitelist'],
329
+ }) as never
330
+ }
331
+
332
+ export declare namespace useModifyWhitelist {
333
+ type Parameters<
334
+ config extends Config = Config,
335
+ context = unknown,
336
+ > = ConfigParameter<config> & {
337
+ mutation?:
338
+ | UseMutationParameters<
339
+ Actions.policy.modifyWhitelist.ReturnValue,
340
+ Actions.policy.modifyWhitelist.ErrorType,
341
+ Actions.policy.modifyWhitelist.Parameters<config>,
342
+ context
343
+ >
344
+ | undefined
345
+ }
346
+
347
+ type ReturnType<
348
+ config extends Config = Config,
349
+ context = unknown,
350
+ > = UseMutationResult<
351
+ Actions.policy.modifyWhitelist.ReturnValue,
352
+ Actions.policy.modifyWhitelist.ErrorType,
353
+ Actions.policy.modifyWhitelist.Parameters<config>,
354
+ context
355
+ >
356
+ }
357
+
358
+ /**
359
+ * Hook for modifying a policy whitelist.
360
+ *
361
+ * Note: This is a synchronous hook that waits for the transaction
362
+ * to be included on a block before returning a response.
363
+ *
364
+ * @example
365
+ * ```tsx
366
+ * import { Hooks } from 'wagmi/tempo'
367
+ *
368
+ * function App() {
369
+ * const { mutate, isPending } = Hooks.policy.useModifyWhitelistSync()
370
+ *
371
+ * return (
372
+ * <button
373
+ * onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
374
+ * disabled={isPending}
375
+ * >
376
+ * Add to Whitelist
377
+ * </button>
378
+ * )
379
+ * }
380
+ * ```
381
+ *
382
+ * @param parameters - Parameters.
383
+ * @returns Mutation result.
384
+ */
385
+ export function useModifyWhitelistSync<
386
+ config extends Config = ResolvedRegister['config'],
387
+ context = unknown,
388
+ >(
389
+ parameters: useModifyWhitelistSync.Parameters<config, context> = {},
390
+ ): useModifyWhitelistSync.ReturnType<config, context> {
391
+ const { mutation } = parameters
392
+ const config = useConfig(parameters)
393
+ return useMutation({
394
+ ...mutation,
395
+ async mutationFn(variables) {
396
+ return Actions.policy.modifyWhitelistSync(config, variables as never)
397
+ },
398
+ mutationKey: ['modifyWhitelistSync'],
399
+ }) as never
400
+ }
401
+
402
+ export declare namespace useModifyWhitelistSync {
403
+ type Parameters<
404
+ config extends Config = Config,
405
+ context = unknown,
406
+ > = ConfigParameter<config> & {
407
+ mutation?:
408
+ | UseMutationParameters<
409
+ Actions.policy.modifyWhitelistSync.ReturnValue,
410
+ Actions.policy.modifyWhitelistSync.ErrorType,
411
+ Actions.policy.modifyWhitelistSync.Parameters<config>,
412
+ context
413
+ >
414
+ | undefined
415
+ }
416
+
417
+ type ReturnType<
418
+ config extends Config = Config,
419
+ context = unknown,
420
+ > = UseMutationResult<
421
+ Actions.policy.modifyWhitelistSync.ReturnValue,
422
+ Actions.policy.modifyWhitelistSync.ErrorType,
423
+ Actions.policy.modifyWhitelistSync.Parameters<config>,
424
+ context
425
+ >
426
+ }
427
+
428
+ /**
429
+ * Hook for modifying a policy blacklist.
430
+ *
431
+ * @example
432
+ * ```tsx
433
+ * import { Hooks } from 'wagmi/tempo'
434
+ *
435
+ * function App() {
436
+ * const { mutate, isPending } = Hooks.policy.useModifyBlacklist()
437
+ *
438
+ * return (
439
+ * <button
440
+ * onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
441
+ * disabled={isPending}
442
+ * >
443
+ * Add to Blacklist
444
+ * </button>
445
+ * )
446
+ * }
447
+ * ```
448
+ *
449
+ * @param parameters - Parameters.
450
+ * @returns Mutation result.
451
+ */
452
+ export function useModifyBlacklist<
453
+ config extends Config = ResolvedRegister['config'],
454
+ context = unknown,
455
+ >(
456
+ parameters: useModifyBlacklist.Parameters<config, context> = {},
457
+ ): useModifyBlacklist.ReturnType<config, context> {
458
+ const { mutation } = parameters
459
+ const config = useConfig(parameters)
460
+ return useMutation({
461
+ ...mutation,
462
+ async mutationFn(variables) {
463
+ return Actions.policy.modifyBlacklist(config, variables as never)
464
+ },
465
+ mutationKey: ['modifyBlacklist'],
466
+ }) as never
467
+ }
468
+
469
+ export declare namespace useModifyBlacklist {
470
+ type Parameters<
471
+ config extends Config = Config,
472
+ context = unknown,
473
+ > = ConfigParameter<config> & {
474
+ mutation?:
475
+ | UseMutationParameters<
476
+ Actions.policy.modifyBlacklist.ReturnValue,
477
+ Actions.policy.modifyBlacklist.ErrorType,
478
+ Actions.policy.modifyBlacklist.Parameters<config>,
479
+ context
480
+ >
481
+ | undefined
482
+ }
483
+
484
+ type ReturnType<
485
+ config extends Config = Config,
486
+ context = unknown,
487
+ > = UseMutationResult<
488
+ Actions.policy.modifyBlacklist.ReturnValue,
489
+ Actions.policy.modifyBlacklist.ErrorType,
490
+ Actions.policy.modifyBlacklist.Parameters<config>,
491
+ context
492
+ >
493
+ }
494
+
495
+ /**
496
+ * Hook for modifying a policy blacklist.
497
+ *
498
+ * Note: This is a synchronous hook that waits for the transaction
499
+ * to be included on a block before returning a response.
500
+ *
501
+ * @example
502
+ * ```tsx
503
+ * import { Hooks } from 'wagmi/tempo'
504
+ *
505
+ * function App() {
506
+ * const { mutate, isPending } = Hooks.policy.useModifyBlacklistSync()
507
+ *
508
+ * return (
509
+ * <button
510
+ * onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
511
+ * disabled={isPending}
512
+ * >
513
+ * Add to Blacklist
514
+ * </button>
515
+ * )
516
+ * }
517
+ * ```
518
+ *
519
+ * @param parameters - Parameters.
520
+ * @returns Mutation result.
521
+ */
522
+ export function useModifyBlacklistSync<
523
+ config extends Config = ResolvedRegister['config'],
524
+ context = unknown,
525
+ >(
526
+ parameters: useModifyBlacklistSync.Parameters<config, context> = {},
527
+ ): useModifyBlacklistSync.ReturnType<config, context> {
528
+ const { mutation } = parameters
529
+ const config = useConfig(parameters)
530
+ return useMutation({
531
+ ...mutation,
532
+ async mutationFn(variables) {
533
+ return Actions.policy.modifyBlacklistSync(config, variables as never)
534
+ },
535
+ mutationKey: ['modifyBlacklistSync'],
536
+ }) as never
537
+ }
538
+
539
+ export declare namespace useModifyBlacklistSync {
540
+ type Parameters<
541
+ config extends Config = Config,
542
+ context = unknown,
543
+ > = ConfigParameter<config> & {
544
+ mutation?:
545
+ | UseMutationParameters<
546
+ Actions.policy.modifyBlacklistSync.ReturnValue,
547
+ Actions.policy.modifyBlacklistSync.ErrorType,
548
+ Actions.policy.modifyBlacklistSync.Parameters<config>,
549
+ context
550
+ >
551
+ | undefined
552
+ }
553
+
554
+ type ReturnType<
555
+ config extends Config = Config,
556
+ context = unknown,
557
+ > = UseMutationResult<
558
+ Actions.policy.modifyBlacklistSync.ReturnValue,
559
+ Actions.policy.modifyBlacklistSync.ErrorType,
560
+ Actions.policy.modifyBlacklistSync.Parameters<config>,
561
+ context
562
+ >
563
+ }
564
+
565
+ /**
566
+ * Hook for getting policy data.
567
+ *
568
+ * @example
569
+ * ```tsx
570
+ * import { Hooks } from 'wagmi/tempo'
571
+ *
572
+ * function App() {
573
+ * const { data, isLoading } = Hooks.policy.useData({
574
+ * policyId: 2n,
575
+ * })
576
+ *
577
+ * if (isLoading) return <div>Loading...</div>
578
+ * return <div>Admin: {data?.admin}</div>
579
+ * }
580
+ * ```
581
+ *
582
+ * @param parameters - Parameters.
583
+ * @returns Query result with policy data.
584
+ */
585
+ export function useData<
586
+ config extends Config = ResolvedRegister['config'],
587
+ selectData = Actions.policy.getData.ReturnValue,
588
+ >(
589
+ parameters: useData.Parameters<config, selectData> = {},
590
+ ): useData.ReturnValue<selectData> {
591
+ const config = useConfig(parameters)
592
+ const chainId = useChainId({ config })
593
+ const options = Actions.policy.getData.queryOptions(config, {
594
+ ...parameters,
595
+ chainId: parameters.chainId ?? chainId,
596
+ } as never)
597
+ return useQuery(options) as never
598
+ }
599
+
600
+ export declare namespace useData {
601
+ export type Parameters<
602
+ config extends Config = ResolvedRegister['config'],
603
+ selectData = Actions.policy.getData.ReturnValue,
604
+ > = ConfigParameter<config> &
605
+ QueryParameter<
606
+ Actions.policy.getData.ReturnValue,
607
+ Actions.policy.getData.ErrorType,
608
+ selectData,
609
+ Actions.policy.getData.QueryKey<config>
610
+ > &
611
+ ExactPartial<
612
+ Omit<
613
+ Actions.policy.getData.queryOptions.Parameters<config, selectData>,
614
+ 'query'
615
+ >
616
+ >
617
+
618
+ export type ReturnValue<selectData = Actions.policy.getData.ReturnValue> =
619
+ UseQueryReturnType<selectData, Error>
620
+ }
621
+
622
+ /**
623
+ * Hook for checking if a user is authorized by a policy.
624
+ *
625
+ * @example
626
+ * ```tsx
627
+ * import { Hooks } from 'wagmi/tempo'
628
+ *
629
+ * function App() {
630
+ * const { data, isLoading } = Hooks.policy.useIsAuthorized({
631
+ * policyId: 2n,
632
+ * user: '0x...',
633
+ * })
634
+ *
635
+ * if (isLoading) return <div>Loading...</div>
636
+ * return <div>Authorized: {data ? 'Yes' : 'No'}</div>
637
+ * }
638
+ * ```
639
+ *
640
+ * @param parameters - Parameters.
641
+ * @returns Query result with authorization status.
642
+ */
643
+ export function useIsAuthorized<
644
+ config extends Config = ResolvedRegister['config'],
645
+ selectData = Actions.policy.isAuthorized.ReturnValue,
646
+ >(
647
+ parameters: useIsAuthorized.Parameters<config, selectData> = {},
648
+ ): useIsAuthorized.ReturnValue<selectData> {
649
+ const config = useConfig(parameters)
650
+ const chainId = useChainId({ config })
651
+ const options = Actions.policy.isAuthorized.queryOptions(config, {
652
+ ...parameters,
653
+ chainId: parameters.chainId ?? chainId,
654
+ } as never)
655
+ return useQuery(options) as never
656
+ }
657
+
658
+ export declare namespace useIsAuthorized {
659
+ export type Parameters<
660
+ config extends Config = ResolvedRegister['config'],
661
+ selectData = Actions.policy.isAuthorized.ReturnValue,
662
+ > = ConfigParameter<config> &
663
+ QueryParameter<
664
+ Actions.policy.isAuthorized.ReturnValue,
665
+ Actions.policy.isAuthorized.ErrorType,
666
+ selectData,
667
+ Actions.policy.isAuthorized.QueryKey<config>
668
+ > &
669
+ ExactPartial<
670
+ Omit<
671
+ Actions.policy.isAuthorized.queryOptions.Parameters<config, selectData>,
672
+ 'query'
673
+ >
674
+ >
675
+
676
+ export type ReturnValue<
677
+ selectData = Actions.policy.isAuthorized.ReturnValue,
678
+ > = UseQueryReturnType<selectData, Error>
679
+ }
680
+
681
+ /**
682
+ * Hook for watching policy creation events.
683
+ *
684
+ * @example
685
+ * ```tsx
686
+ * import { Hooks } from 'wagmi/tempo'
687
+ *
688
+ * function App() {
689
+ * Hooks.policy.useWatchCreate({
690
+ * onPolicyCreated(args) {
691
+ * console.log('Policy created:', args)
692
+ * },
693
+ * })
694
+ *
695
+ * return <div>Watching for policy creation...</div>
696
+ * }
697
+ * ```
698
+ *
699
+ * @param parameters - Parameters.
700
+ */
701
+ export function useWatchCreate<
702
+ config extends Config = ResolvedRegister['config'],
703
+ >(parameters: useWatchCreate.Parameters<config> = {}) {
704
+ const { enabled = true, onPolicyCreated, ...rest } = parameters
705
+
706
+ const config = useConfig({ config: parameters.config })
707
+ const configChainId = useChainId({ config })
708
+ const chainId = parameters.chainId ?? configChainId
709
+
710
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
711
+ useEffect(() => {
712
+ if (!enabled) return
713
+ if (!onPolicyCreated) return
714
+ return Actions.policy.watchCreate(config, {
715
+ ...rest,
716
+ chainId,
717
+ onPolicyCreated,
718
+ })
719
+ }, [
720
+ config,
721
+ enabled,
722
+ chainId,
723
+ onPolicyCreated,
724
+ rest.fromBlock,
725
+ rest.onError,
726
+ rest.poll,
727
+ rest.pollingInterval,
728
+ ])
729
+ }
730
+
731
+ export declare namespace useWatchCreate {
732
+ type Parameters<config extends Config = Config> = UnionCompute<
733
+ ExactPartial<Actions.policy.watchCreate.Parameters<config>> &
734
+ ConfigParameter<config> & { enabled?: boolean | undefined }
735
+ >
736
+ }
737
+
738
+ /**
739
+ * Hook for watching policy admin update events.
740
+ *
741
+ * @example
742
+ * ```tsx
743
+ * import { Hooks } from 'wagmi/tempo'
744
+ *
745
+ * function App() {
746
+ * Hooks.policy.useWatchAdminUpdated({
747
+ * onAdminUpdated(args) {
748
+ * console.log('Policy admin updated:', args)
749
+ * },
750
+ * })
751
+ *
752
+ * return <div>Watching for admin updates...</div>
753
+ * }
754
+ * ```
755
+ *
756
+ * @param parameters - Parameters.
757
+ */
758
+ export function useWatchAdminUpdated<
759
+ config extends Config = ResolvedRegister['config'],
760
+ >(parameters: useWatchAdminUpdated.Parameters<config> = {}) {
761
+ const { enabled = true, onAdminUpdated, ...rest } = parameters
762
+
763
+ const config = useConfig({ config: parameters.config })
764
+ const configChainId = useChainId({ config })
765
+ const chainId = parameters.chainId ?? configChainId
766
+
767
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
768
+ useEffect(() => {
769
+ if (!enabled) return
770
+ if (!onAdminUpdated) return
771
+ return Actions.policy.watchAdminUpdated(config, {
772
+ ...rest,
773
+ chainId,
774
+ onAdminUpdated,
775
+ })
776
+ }, [
777
+ config,
778
+ enabled,
779
+ chainId,
780
+ onAdminUpdated,
781
+ rest.fromBlock,
782
+ rest.onError,
783
+ rest.poll,
784
+ rest.pollingInterval,
785
+ ])
786
+ }
787
+
788
+ export declare namespace useWatchAdminUpdated {
789
+ type Parameters<config extends Config = Config> = UnionCompute<
790
+ ExactPartial<Actions.policy.watchAdminUpdated.Parameters<config>> &
791
+ ConfigParameter<config> & { enabled?: boolean | undefined }
792
+ >
793
+ }
794
+
795
+ /**
796
+ * Hook for watching whitelist update events.
797
+ *
798
+ * @example
799
+ * ```tsx
800
+ * import { Hooks } from 'wagmi/tempo'
801
+ *
802
+ * function App() {
803
+ * Hooks.policy.useWatchWhitelistUpdated({
804
+ * onWhitelistUpdated(args) {
805
+ * console.log('Whitelist updated:', args)
806
+ * },
807
+ * })
808
+ *
809
+ * return <div>Watching for whitelist updates...</div>
810
+ * }
811
+ * ```
812
+ *
813
+ * @param parameters - Parameters.
814
+ */
815
+ export function useWatchWhitelistUpdated<
816
+ config extends Config = ResolvedRegister['config'],
817
+ >(parameters: useWatchWhitelistUpdated.Parameters<config> = {}) {
818
+ const { enabled = true, onWhitelistUpdated, ...rest } = parameters
819
+
820
+ const config = useConfig({ config: parameters.config })
821
+ const configChainId = useChainId({ config })
822
+ const chainId = parameters.chainId ?? configChainId
823
+
824
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
825
+ useEffect(() => {
826
+ if (!enabled) return
827
+ if (!onWhitelistUpdated) return
828
+ return Actions.policy.watchWhitelistUpdated(config, {
829
+ ...rest,
830
+ chainId,
831
+ onWhitelistUpdated,
832
+ })
833
+ }, [
834
+ config,
835
+ enabled,
836
+ chainId,
837
+ onWhitelistUpdated,
838
+ rest.fromBlock,
839
+ rest.onError,
840
+ rest.poll,
841
+ rest.pollingInterval,
842
+ ])
843
+ }
844
+
845
+ export declare namespace useWatchWhitelistUpdated {
846
+ type Parameters<config extends Config = Config> = UnionCompute<
847
+ ExactPartial<Actions.policy.watchWhitelistUpdated.Parameters<config>> &
848
+ ConfigParameter<config> & { enabled?: boolean | undefined }
849
+ >
850
+ }
851
+
852
+ /**
853
+ * Hook for watching blacklist update events.
854
+ *
855
+ * @example
856
+ * ```tsx
857
+ * import { Hooks } from 'wagmi/tempo'
858
+ *
859
+ * function App() {
860
+ * Hooks.policy.useWatchBlacklistUpdated({
861
+ * onBlacklistUpdated(args) {
862
+ * console.log('Blacklist updated:', args)
863
+ * },
864
+ * })
865
+ *
866
+ * return <div>Watching for blacklist updates...</div>
867
+ * }
868
+ * ```
869
+ *
870
+ * @param parameters - Parameters.
871
+ */
872
+ export function useWatchBlacklistUpdated<
873
+ config extends Config = ResolvedRegister['config'],
874
+ >(parameters: useWatchBlacklistUpdated.Parameters<config> = {}) {
875
+ const { enabled = true, onBlacklistUpdated, ...rest } = parameters
876
+
877
+ const config = useConfig({ config: parameters.config })
878
+ const configChainId = useChainId({ config })
879
+ const chainId = parameters.chainId ?? configChainId
880
+
881
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
882
+ useEffect(() => {
883
+ if (!enabled) return
884
+ if (!onBlacklistUpdated) return
885
+ return Actions.policy.watchBlacklistUpdated(config, {
886
+ ...rest,
887
+ chainId,
888
+ onBlacklistUpdated,
889
+ })
890
+ }, [
891
+ config,
892
+ enabled,
893
+ chainId,
894
+ onBlacklistUpdated,
895
+ rest.fromBlock,
896
+ rest.onError,
897
+ rest.poll,
898
+ rest.pollingInterval,
899
+ ])
900
+ }
901
+
902
+ export declare namespace useWatchBlacklistUpdated {
903
+ type Parameters<config extends Config = Config> = UnionCompute<
904
+ ExactPartial<Actions.policy.watchBlacklistUpdated.Parameters<config>> &
905
+ ConfigParameter<config> & { enabled?: boolean | undefined }
906
+ >
907
+ }