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