tempo.ts 0.12.1 → 0.13.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 (123) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +28 -34
  3. package/package.json +2 -28
  4. package/dist/wagmi/Actions/amm.d.ts +0 -418
  5. package/dist/wagmi/Actions/amm.d.ts.map +0 -1
  6. package/dist/wagmi/Actions/amm.js +0 -462
  7. package/dist/wagmi/Actions/amm.js.map +0 -1
  8. package/dist/wagmi/Actions/dex.d.ts +0 -864
  9. package/dist/wagmi/Actions/dex.d.ts.map +0 -1
  10. package/dist/wagmi/Actions/dex.js +0 -968
  11. package/dist/wagmi/Actions/dex.js.map +0 -1
  12. package/dist/wagmi/Actions/faucet.d.ts +0 -66
  13. package/dist/wagmi/Actions/faucet.d.ts.map +0 -1
  14. package/dist/wagmi/Actions/faucet.js +0 -64
  15. package/dist/wagmi/Actions/faucet.js.map +0 -1
  16. package/dist/wagmi/Actions/fee.d.ts +0 -111
  17. package/dist/wagmi/Actions/fee.d.ts.map +0 -1
  18. package/dist/wagmi/Actions/fee.js +0 -126
  19. package/dist/wagmi/Actions/fee.js.map +0 -1
  20. package/dist/wagmi/Actions/index.d.ts +0 -9
  21. package/dist/wagmi/Actions/index.d.ts.map +0 -1
  22. package/dist/wagmi/Actions/index.js +0 -9
  23. package/dist/wagmi/Actions/index.js.map +0 -1
  24. package/dist/wagmi/Actions/nonce.d.ts +0 -77
  25. package/dist/wagmi/Actions/nonce.d.ts.map +0 -1
  26. package/dist/wagmi/Actions/nonce.js +0 -87
  27. package/dist/wagmi/Actions/nonce.js.map +0 -1
  28. package/dist/wagmi/Actions/policy.d.ts +0 -480
  29. package/dist/wagmi/Actions/policy.d.ts.map +0 -1
  30. package/dist/wagmi/Actions/policy.js +0 -530
  31. package/dist/wagmi/Actions/policy.js.map +0 -1
  32. package/dist/wagmi/Actions/reward.d.ts +0 -346
  33. package/dist/wagmi/Actions/reward.d.ts.map +0 -1
  34. package/dist/wagmi/Actions/reward.js +0 -382
  35. package/dist/wagmi/Actions/reward.js.map +0 -1
  36. package/dist/wagmi/Actions/token.d.ts +0 -1546
  37. package/dist/wagmi/Actions/token.d.ts.map +0 -1
  38. package/dist/wagmi/Actions/token.js +0 -1712
  39. package/dist/wagmi/Actions/token.js.map +0 -1
  40. package/dist/wagmi/Connector.d.ts +0 -91
  41. package/dist/wagmi/Connector.d.ts.map +0 -1
  42. package/dist/wagmi/Connector.js +0 -473
  43. package/dist/wagmi/Connector.js.map +0 -1
  44. package/dist/wagmi/Hooks/amm.d.ts +0 -411
  45. package/dist/wagmi/Hooks/amm.d.ts.map +0 -1
  46. package/dist/wagmi/Hooks/amm.js +0 -494
  47. package/dist/wagmi/Hooks/amm.js.map +0 -1
  48. package/dist/wagmi/Hooks/dex.d.ts +0 -773
  49. package/dist/wagmi/Hooks/dex.d.ts.map +0 -1
  50. package/dist/wagmi/Hooks/dex.js +0 -921
  51. package/dist/wagmi/Hooks/dex.js.map +0 -1
  52. package/dist/wagmi/Hooks/faucet.d.ts +0 -71
  53. package/dist/wagmi/Hooks/faucet.d.ts.map +0 -1
  54. package/dist/wagmi/Hooks/faucet.js +0 -76
  55. package/dist/wagmi/Hooks/faucet.js.map +0 -1
  56. package/dist/wagmi/Hooks/fee.d.ts +0 -97
  57. package/dist/wagmi/Hooks/fee.d.ts.map +0 -1
  58. package/dist/wagmi/Hooks/fee.js +0 -109
  59. package/dist/wagmi/Hooks/fee.js.map +0 -1
  60. package/dist/wagmi/Hooks/index.d.ts +0 -9
  61. package/dist/wagmi/Hooks/index.d.ts.map +0 -1
  62. package/dist/wagmi/Hooks/index.js +0 -9
  63. package/dist/wagmi/Hooks/index.js.map +0 -1
  64. package/dist/wagmi/Hooks/nonce.d.ts +0 -59
  65. package/dist/wagmi/Hooks/nonce.d.ts.map +0 -1
  66. package/dist/wagmi/Hooks/nonce.js +0 -75
  67. package/dist/wagmi/Hooks/nonce.js.map +0 -1
  68. package/dist/wagmi/Hooks/policy.d.ts +0 -423
  69. package/dist/wagmi/Hooks/policy.d.ts.map +0 -1
  70. package/dist/wagmi/Hooks/policy.js +0 -510
  71. package/dist/wagmi/Hooks/policy.js.map +0 -1
  72. package/dist/wagmi/Hooks/reward.d.ts +0 -305
  73. package/dist/wagmi/Hooks/reward.d.ts.map +0 -1
  74. package/dist/wagmi/Hooks/reward.js +0 -368
  75. package/dist/wagmi/Hooks/reward.js.map +0 -1
  76. package/dist/wagmi/Hooks/token.d.ts +0 -1388
  77. package/dist/wagmi/Hooks/token.d.ts.map +0 -1
  78. package/dist/wagmi/Hooks/token.js +0 -1657
  79. package/dist/wagmi/Hooks/token.js.map +0 -1
  80. package/dist/wagmi/KeyManager.d.ts +0 -60
  81. package/dist/wagmi/KeyManager.d.ts.map +0 -1
  82. package/dist/wagmi/KeyManager.js +0 -106
  83. package/dist/wagmi/KeyManager.js.map +0 -1
  84. package/dist/wagmi/index.d.ts +0 -5
  85. package/dist/wagmi/index.d.ts.map +0 -1
  86. package/dist/wagmi/index.js +0 -5
  87. package/dist/wagmi/index.js.map +0 -1
  88. package/src/wagmi/Actions/amm.test.ts +0 -208
  89. package/src/wagmi/Actions/amm.ts +0 -690
  90. package/src/wagmi/Actions/dex.test.ts +0 -1482
  91. package/src/wagmi/Actions/dex.ts +0 -1540
  92. package/src/wagmi/Actions/faucet.ts +0 -89
  93. package/src/wagmi/Actions/fee.test.ts +0 -63
  94. package/src/wagmi/Actions/fee.ts +0 -211
  95. package/src/wagmi/Actions/index.ts +0 -8
  96. package/src/wagmi/Actions/nonce.test.ts +0 -82
  97. package/src/wagmi/Actions/nonce.ts +0 -139
  98. package/src/wagmi/Actions/policy.test.ts +0 -461
  99. package/src/wagmi/Actions/policy.ts +0 -817
  100. package/src/wagmi/Actions/reward.test.ts +0 -216
  101. package/src/wagmi/Actions/reward.ts +0 -613
  102. package/src/wagmi/Actions/token.test.ts +0 -1309
  103. package/src/wagmi/Actions/token.ts +0 -2644
  104. package/src/wagmi/Connector.test.ts +0 -56
  105. package/src/wagmi/Connector.ts +0 -670
  106. package/src/wagmi/Hooks/amm.test.ts +0 -564
  107. package/src/wagmi/Hooks/amm.ts +0 -796
  108. package/src/wagmi/Hooks/dex.test.ts +0 -992
  109. package/src/wagmi/Hooks/dex.ts +0 -1598
  110. package/src/wagmi/Hooks/faucet.ts +0 -144
  111. package/src/wagmi/Hooks/fee.test.ts +0 -166
  112. package/src/wagmi/Hooks/fee.ts +0 -206
  113. package/src/wagmi/Hooks/index.ts +0 -8
  114. package/src/wagmi/Hooks/nonce.test.ts +0 -142
  115. package/src/wagmi/Hooks/nonce.ts +0 -117
  116. package/src/wagmi/Hooks/policy.test.ts +0 -665
  117. package/src/wagmi/Hooks/policy.ts +0 -873
  118. package/src/wagmi/Hooks/reward.test.ts +0 -249
  119. package/src/wagmi/Hooks/reward.ts +0 -645
  120. package/src/wagmi/Hooks/token.test.ts +0 -1183
  121. package/src/wagmi/Hooks/token.ts +0 -2906
  122. package/src/wagmi/KeyManager.ts +0 -172
  123. package/src/wagmi/index.ts +0 -7
@@ -1,873 +0,0 @@
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
- /**
18
- * Hook for creating a new policy.
19
- *
20
- * @example
21
- * ```tsx
22
- * import { Hooks } from 'tempo.ts/wagmi'
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.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.create.ReturnValue,
66
- Actions.create.ErrorType,
67
- Actions.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.create.ReturnValue,
78
- Actions.create.ErrorType,
79
- Actions.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 'tempo.ts/wagmi'
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.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.createSync.ReturnValue,
136
- Actions.createSync.ErrorType,
137
- Actions.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.createSync.ReturnValue,
148
- Actions.createSync.ErrorType,
149
- Actions.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 'tempo.ts/wagmi'
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.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.setAdmin.ReturnValue,
203
- Actions.setAdmin.ErrorType,
204
- Actions.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.setAdmin.ReturnValue,
215
- Actions.setAdmin.ErrorType,
216
- Actions.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 'tempo.ts/wagmi'
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.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.setAdminSync.ReturnValue,
273
- Actions.setAdminSync.ErrorType,
274
- Actions.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.setAdminSync.ReturnValue,
285
- Actions.setAdminSync.ErrorType,
286
- Actions.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 'tempo.ts/wagmi'
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.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.modifyWhitelist.ReturnValue,
340
- Actions.modifyWhitelist.ErrorType,
341
- Actions.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.modifyWhitelist.ReturnValue,
352
- Actions.modifyWhitelist.ErrorType,
353
- Actions.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 'tempo.ts/wagmi'
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.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.modifyWhitelistSync.ReturnValue,
410
- Actions.modifyWhitelistSync.ErrorType,
411
- Actions.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.modifyWhitelistSync.ReturnValue,
422
- Actions.modifyWhitelistSync.ErrorType,
423
- Actions.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 'tempo.ts/wagmi'
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.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.modifyBlacklist.ReturnValue,
477
- Actions.modifyBlacklist.ErrorType,
478
- Actions.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.modifyBlacklist.ReturnValue,
489
- Actions.modifyBlacklist.ErrorType,
490
- Actions.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 'tempo.ts/wagmi'
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.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.modifyBlacklistSync.ReturnValue,
547
- Actions.modifyBlacklistSync.ErrorType,
548
- Actions.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.modifyBlacklistSync.ReturnValue,
559
- Actions.modifyBlacklistSync.ErrorType,
560
- Actions.modifyBlacklistSync.Parameters<config>,
561
- context
562
- >
563
- }
564
-
565
- /**
566
- * Hook for getting policy data.
567
- *
568
- * @example
569
- * ```tsx
570
- * import { Hooks } from 'tempo.ts/wagmi'
571
- *
572
- * function App() {
573
- * const { data, isLoading } = Hooks.policy.useGetData({
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 useGetData<
586
- config extends Config = ResolvedRegister['config'],
587
- selectData = Actions.getData.ReturnValue,
588
- >(parameters: useGetData.Parameters<config, selectData> = {}) {
589
- const { policyId, query = {} } = parameters
590
-
591
- const config = useConfig(parameters)
592
- const chainId = useChainId({ config })
593
-
594
- const options = Actions.getData.queryOptions(config, {
595
- ...parameters,
596
- chainId: parameters.chainId ?? chainId,
597
- query: undefined,
598
- } as never)
599
- const enabled = Boolean(policyId !== undefined && (query.enabled ?? true))
600
-
601
- return useQuery({ ...query, ...options, enabled })
602
- }
603
-
604
- export declare namespace useGetData {
605
- export type Parameters<
606
- config extends Config = ResolvedRegister['config'],
607
- selectData = Actions.getData.ReturnValue,
608
- > = ConfigParameter<config> &
609
- QueryParameter<
610
- Actions.getData.ReturnValue,
611
- DefaultError,
612
- selectData,
613
- Actions.getData.QueryKey<config>
614
- > &
615
- ExactPartial<
616
- Omit<Actions.getData.queryOptions.Parameters<config, selectData>, 'query'>
617
- >
618
-
619
- export type ReturnValue<selectData = Actions.getData.ReturnValue> =
620
- UseQueryReturnType<selectData, Error>
621
- }
622
-
623
- /**
624
- * Hook for checking if a user is authorized by a policy.
625
- *
626
- * @example
627
- * ```tsx
628
- * import { Hooks } from 'tempo.ts/wagmi'
629
- *
630
- * function App() {
631
- * const { data, isLoading } = Hooks.policy.useIsAuthorized({
632
- * policyId: 2n,
633
- * user: '0x...',
634
- * })
635
- *
636
- * if (isLoading) return <div>Loading...</div>
637
- * return <div>Authorized: {data ? 'Yes' : 'No'}</div>
638
- * }
639
- * ```
640
- *
641
- * @param parameters - Parameters.
642
- * @returns Query result with authorization status.
643
- */
644
- export function useIsAuthorized<
645
- config extends Config = ResolvedRegister['config'],
646
- selectData = Actions.isAuthorized.ReturnValue,
647
- >(parameters: useIsAuthorized.Parameters<config, selectData> = {}) {
648
- const { policyId, user, query = {} } = parameters
649
-
650
- const config = useConfig(parameters)
651
- const chainId = useChainId({ config })
652
-
653
- const options = Actions.isAuthorized.queryOptions(config, {
654
- ...parameters,
655
- chainId: parameters.chainId ?? chainId,
656
- query: undefined,
657
- } as never)
658
- const enabled = Boolean(
659
- policyId !== undefined && user && (query.enabled ?? true),
660
- )
661
-
662
- return useQuery({ ...query, ...options, enabled })
663
- }
664
-
665
- export declare namespace useIsAuthorized {
666
- export type Parameters<
667
- config extends Config = ResolvedRegister['config'],
668
- selectData = Actions.isAuthorized.ReturnValue,
669
- > = ConfigParameter<config> &
670
- QueryParameter<
671
- Actions.isAuthorized.ReturnValue,
672
- DefaultError,
673
- selectData,
674
- Actions.isAuthorized.QueryKey<config>
675
- > &
676
- ExactPartial<
677
- Omit<
678
- Actions.isAuthorized.queryOptions.Parameters<config, selectData>,
679
- 'query'
680
- >
681
- >
682
-
683
- export type ReturnValue<selectData = Actions.isAuthorized.ReturnValue> =
684
- UseQueryReturnType<selectData, Error>
685
- }
686
-
687
- /**
688
- * Hook for watching policy creation events.
689
- *
690
- * @example
691
- * ```tsx
692
- * import { Hooks } from 'tempo.ts/wagmi'
693
- *
694
- * function App() {
695
- * Hooks.policy.useWatchCreate({
696
- * onPolicyCreated(args) {
697
- * console.log('Policy created:', args)
698
- * },
699
- * })
700
- *
701
- * return <div>Watching for policy creation...</div>
702
- * }
703
- * ```
704
- *
705
- * @param parameters - Parameters.
706
- */
707
- export function useWatchCreate<
708
- config extends Config = ResolvedRegister['config'],
709
- >(parameters: useWatchCreate.Parameters<config> = {}) {
710
- const { enabled = true, onPolicyCreated, ...rest } = parameters
711
-
712
- const config = useConfig({ config: parameters.config })
713
- const configChainId = useChainId({ config })
714
- const chainId = parameters.chainId ?? configChainId
715
-
716
- useEffect(() => {
717
- if (!enabled) return
718
- if (!onPolicyCreated) return
719
- return Actions.watchCreate(config, {
720
- ...rest,
721
- chainId,
722
- onPolicyCreated,
723
- })
724
- }, [config, enabled, onPolicyCreated, rest, chainId])
725
- }
726
-
727
- export declare namespace useWatchCreate {
728
- type Parameters<config extends Config = Config> = UnionCompute<
729
- ExactPartial<Actions.watchCreate.Parameters<config>> &
730
- ConfigParameter<config> & { enabled?: boolean | undefined }
731
- >
732
- }
733
-
734
- /**
735
- * Hook for watching policy admin update events.
736
- *
737
- * @example
738
- * ```tsx
739
- * import { Hooks } from 'tempo.ts/wagmi'
740
- *
741
- * function App() {
742
- * Hooks.policy.useWatchAdminUpdated({
743
- * onAdminUpdated(args) {
744
- * console.log('Policy admin updated:', args)
745
- * },
746
- * })
747
- *
748
- * return <div>Watching for admin updates...</div>
749
- * }
750
- * ```
751
- *
752
- * @param parameters - Parameters.
753
- */
754
- export function useWatchAdminUpdated<
755
- config extends Config = ResolvedRegister['config'],
756
- >(parameters: useWatchAdminUpdated.Parameters<config> = {}) {
757
- const { enabled = true, onAdminUpdated, ...rest } = parameters
758
-
759
- const config = useConfig({ config: parameters.config })
760
- const configChainId = useChainId({ config })
761
- const chainId = parameters.chainId ?? configChainId
762
-
763
- useEffect(() => {
764
- if (!enabled) return
765
- if (!onAdminUpdated) return
766
- return Actions.watchAdminUpdated(config, {
767
- ...rest,
768
- chainId,
769
- onAdminUpdated,
770
- })
771
- }, [config, enabled, onAdminUpdated, rest, chainId])
772
- }
773
-
774
- export declare namespace useWatchAdminUpdated {
775
- type Parameters<config extends Config = Config> = UnionCompute<
776
- ExactPartial<Actions.watchAdminUpdated.Parameters<config>> &
777
- ConfigParameter<config> & { enabled?: boolean | undefined }
778
- >
779
- }
780
-
781
- /**
782
- * Hook for watching whitelist update events.
783
- *
784
- * @example
785
- * ```tsx
786
- * import { Hooks } from 'tempo.ts/wagmi'
787
- *
788
- * function App() {
789
- * Hooks.policy.useWatchWhitelistUpdated({
790
- * onWhitelistUpdated(args) {
791
- * console.log('Whitelist updated:', args)
792
- * },
793
- * })
794
- *
795
- * return <div>Watching for whitelist updates...</div>
796
- * }
797
- * ```
798
- *
799
- * @param parameters - Parameters.
800
- */
801
- export function useWatchWhitelistUpdated<
802
- config extends Config = ResolvedRegister['config'],
803
- >(parameters: useWatchWhitelistUpdated.Parameters<config> = {}) {
804
- const { enabled = true, onWhitelistUpdated, ...rest } = parameters
805
-
806
- const config = useConfig({ config: parameters.config })
807
- const configChainId = useChainId({ config })
808
- const chainId = parameters.chainId ?? configChainId
809
-
810
- useEffect(() => {
811
- if (!enabled) return
812
- if (!onWhitelistUpdated) return
813
- return Actions.watchWhitelistUpdated(config, {
814
- ...rest,
815
- chainId,
816
- onWhitelistUpdated,
817
- })
818
- }, [config, enabled, onWhitelistUpdated, rest, chainId])
819
- }
820
-
821
- export declare namespace useWatchWhitelistUpdated {
822
- type Parameters<config extends Config = Config> = UnionCompute<
823
- ExactPartial<Actions.watchWhitelistUpdated.Parameters<config>> &
824
- ConfigParameter<config> & { enabled?: boolean | undefined }
825
- >
826
- }
827
-
828
- /**
829
- * Hook for watching blacklist update events.
830
- *
831
- * @example
832
- * ```tsx
833
- * import { Hooks } from 'tempo.ts/wagmi'
834
- *
835
- * function App() {
836
- * Hooks.policy.useWatchBlacklistUpdated({
837
- * onBlacklistUpdated(args) {
838
- * console.log('Blacklist updated:', args)
839
- * },
840
- * })
841
- *
842
- * return <div>Watching for blacklist updates...</div>
843
- * }
844
- * ```
845
- *
846
- * @param parameters - Parameters.
847
- */
848
- export function useWatchBlacklistUpdated<
849
- config extends Config = ResolvedRegister['config'],
850
- >(parameters: useWatchBlacklistUpdated.Parameters<config> = {}) {
851
- const { enabled = true, onBlacklistUpdated, ...rest } = parameters
852
-
853
- const config = useConfig({ config: parameters.config })
854
- const configChainId = useChainId({ config })
855
- const chainId = parameters.chainId ?? configChainId
856
-
857
- useEffect(() => {
858
- if (!enabled) return
859
- if (!onBlacklistUpdated) return
860
- return Actions.watchBlacklistUpdated(config, {
861
- ...rest,
862
- chainId,
863
- onBlacklistUpdated,
864
- })
865
- }, [config, enabled, onBlacklistUpdated, rest, chainId])
866
- }
867
-
868
- export declare namespace useWatchBlacklistUpdated {
869
- type Parameters<config extends Config = Config> = UnionCompute<
870
- ExactPartial<Actions.watchBlacklistUpdated.Parameters<config>> &
871
- ConfigParameter<config> & { enabled?: boolean | undefined }
872
- >
873
- }