tempo.ts 0.5.0 → 0.5.2

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