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,1657 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { useChainId, useConfig } from 'wagmi';
3
- import { useMutation, useQuery, } from 'wagmi/query';
4
- import * as Actions from '../Actions/token.js';
5
- /**
6
- * Hook for approving a spender to transfer TIP20 tokens.
7
- *
8
- * @example
9
- * ```tsx
10
- * import { Hooks } from 'tempo.ts/wagmi'
11
- *
12
- * function App() {
13
- * const { mutate, isPending } = Hooks.token.useApprove()
14
- *
15
- * return (
16
- * <button
17
- * onClick={() => mutate({ spender: '0x...', amount: 100n })}
18
- * disabled={isPending}
19
- * >
20
- * Approve
21
- * </button>
22
- * )
23
- * }
24
- * ```
25
- *
26
- * @param parameters - Parameters.
27
- * @returns Mutation result.
28
- */
29
- export function useApprove(parameters = {}) {
30
- const { mutation } = parameters;
31
- const config = useConfig(parameters);
32
- return useMutation({
33
- ...mutation,
34
- async mutationFn(variables) {
35
- return Actions.approve(config, variables);
36
- },
37
- mutationKey: ['approve'],
38
- });
39
- }
40
- /**
41
- * Hook for approving a spender to transfer TIP20 tokens.
42
- *
43
- * Note: This is a synchronous hook that waits for the transaction
44
- * to be included on a block before returning a response.
45
- *
46
- * @example
47
- * ```tsx
48
- * import { Hooks } from 'tempo.ts/wagmi'
49
- *
50
- * function App() {
51
- * const { mutate, isPending } = Hooks.token.useApproveSync()
52
- *
53
- * return (
54
- * <button
55
- * onClick={() => mutate({ spender: '0x...', amount: 100n })}
56
- * disabled={isPending}
57
- * >
58
- * Approve
59
- * </button>
60
- * )
61
- * }
62
- * ```
63
- *
64
- * @param parameters - Parameters.
65
- * @returns Mutation result.
66
- */
67
- export function useApproveSync(parameters = {}) {
68
- const { mutation } = parameters;
69
- const config = useConfig(parameters);
70
- return useMutation({
71
- ...mutation,
72
- async mutationFn(variables) {
73
- return Actions.approveSync(config, variables);
74
- },
75
- mutationKey: ['approveSync'],
76
- });
77
- }
78
- /**
79
- * Hook for burning TIP20 tokens from the caller's balance.
80
- *
81
- * @example
82
- * ```tsx
83
- * import { Hooks } from 'tempo.ts/wagmi'
84
- *
85
- * function App() {
86
- * const { mutate, isPending } = Hooks.token.useBurn()
87
- *
88
- * return (
89
- * <button
90
- * onClick={() => mutate({ amount: 100n, token: '0x...' })}
91
- * disabled={isPending}
92
- * >
93
- * Burn
94
- * </button>
95
- * )
96
- * }
97
- * ```
98
- *
99
- * @param parameters - Parameters.
100
- * @returns Mutation result.
101
- */
102
- export function useBurn(parameters = {}) {
103
- const { mutation } = parameters;
104
- const config = useConfig(parameters);
105
- return useMutation({
106
- ...mutation,
107
- async mutationFn(variables) {
108
- return Actions.burn(config, variables);
109
- },
110
- mutationKey: ['burn'],
111
- });
112
- }
113
- /**
114
- * Hook for burning TIP20 tokens from the caller's balance.
115
- *
116
- * Note: This is a synchronous hook that waits for the transaction
117
- * to be included on a block before returning a response.
118
- *
119
- * @example
120
- * ```tsx
121
- * import { Hooks } from 'tempo.ts/wagmi'
122
- *
123
- * function App() {
124
- * const { mutate, isPending } = Hooks.token.useBurnSync()
125
- *
126
- * return (
127
- * <button
128
- * onClick={() => mutate({ amount: 100n, token: '0x...' })}
129
- * disabled={isPending}
130
- * >
131
- * Burn
132
- * </button>
133
- * )
134
- * }
135
- * ```
136
- *
137
- * @param parameters - Parameters.
138
- * @returns Mutation result.
139
- */
140
- export function useBurnSync(parameters = {}) {
141
- const { mutation } = parameters;
142
- const config = useConfig(parameters);
143
- return useMutation({
144
- ...mutation,
145
- async mutationFn(variables) {
146
- return Actions.burnSync(config, variables);
147
- },
148
- mutationKey: ['burnSync'],
149
- });
150
- }
151
- /**
152
- * Hook for burning TIP20 tokens from a blocked address.
153
- *
154
- * @example
155
- * ```tsx
156
- * import { Hooks } from 'tempo.ts/wagmi'
157
- *
158
- * function App() {
159
- * const { mutate, isPending } = Hooks.token.useBurnBlocked()
160
- *
161
- * return (
162
- * <button
163
- * onClick={() => mutate({ from: '0x...', amount: 100n, token: '0x...' })}
164
- * disabled={isPending}
165
- * >
166
- * Burn Blocked
167
- * </button>
168
- * )
169
- * }
170
- * ```
171
- *
172
- * @param parameters - Parameters.
173
- * @returns Mutation result.
174
- */
175
- export function useBurnBlocked(parameters = {}) {
176
- const { mutation } = parameters;
177
- const config = useConfig(parameters);
178
- return useMutation({
179
- ...mutation,
180
- async mutationFn(variables) {
181
- return Actions.burnBlocked(config, variables);
182
- },
183
- mutationKey: ['burnBlocked'],
184
- });
185
- }
186
- /**
187
- * Hook for burning TIP20 tokens from a blocked address.
188
- *
189
- * Note: This is a synchronous hook that waits for the transaction
190
- * to be included on a block before returning a response.
191
- *
192
- * @example
193
- * ```tsx
194
- * import { Hooks } from 'tempo.ts/wagmi'
195
- *
196
- * function App() {
197
- * const { mutate, isPending } = Hooks.token.useBurnBlockedSync()
198
- *
199
- * return (
200
- * <button
201
- * onClick={() => mutate({ from: '0x...', amount: 100n, token: '0x...' })}
202
- * disabled={isPending}
203
- * >
204
- * Burn Blocked
205
- * </button>
206
- * )
207
- * }
208
- * ```
209
- *
210
- * @param parameters - Parameters.
211
- * @returns Mutation result.
212
- */
213
- export function useBurnBlockedSync(parameters = {}) {
214
- const { mutation } = parameters;
215
- const config = useConfig(parameters);
216
- return useMutation({
217
- ...mutation,
218
- async mutationFn(variables) {
219
- return Actions.burnBlockedSync(config, variables);
220
- },
221
- mutationKey: ['burnBlockedSync'],
222
- });
223
- }
224
- /**
225
- * Hook for changing the transfer policy ID for a TIP20 token.
226
- *
227
- * @example
228
- * ```tsx
229
- * import { Hooks } from 'tempo.ts/wagmi'
230
- *
231
- * function App() {
232
- * const { mutate, isPending } = Hooks.token.useChangeTransferPolicy()
233
- *
234
- * return (
235
- * <button
236
- * onClick={() => mutate({ token: '0x...', policyId: 1n })}
237
- * disabled={isPending}
238
- * >
239
- * Change Policy
240
- * </button>
241
- * )
242
- * }
243
- * ```
244
- *
245
- * @param parameters - Parameters.
246
- * @returns Mutation result.
247
- */
248
- export function useChangeTransferPolicy(parameters = {}) {
249
- const { mutation } = parameters;
250
- const config = useConfig(parameters);
251
- return useMutation({
252
- ...mutation,
253
- async mutationFn(variables) {
254
- return Actions.changeTransferPolicy(config, variables);
255
- },
256
- mutationKey: ['changeTransferPolicy'],
257
- });
258
- }
259
- /**
260
- * Hook for changing the transfer policy ID for a TIP20 token.
261
- *
262
- * Note: This is a synchronous hook that waits for the transaction
263
- * to be included on a block before returning a response.
264
- *
265
- * @example
266
- * ```tsx
267
- * import { Hooks } from 'tempo.ts/wagmi'
268
- *
269
- * function App() {
270
- * const { mutate, isPending } = Hooks.token.useChangeTransferPolicySync()
271
- *
272
- * return (
273
- * <button
274
- * onClick={() => mutate({ token: '0x...', policyId: 1n })}
275
- * disabled={isPending}
276
- * >
277
- * Change Policy
278
- * </button>
279
- * )
280
- * }
281
- * ```
282
- *
283
- * @param parameters - Parameters.
284
- * @returns Mutation result.
285
- */
286
- export function useChangeTransferPolicySync(parameters = {}) {
287
- const { mutation } = parameters;
288
- const config = useConfig(parameters);
289
- return useMutation({
290
- ...mutation,
291
- async mutationFn(variables) {
292
- return Actions.changeTransferPolicySync(config, variables);
293
- },
294
- mutationKey: ['changeTransferPolicySync'],
295
- });
296
- }
297
- /**
298
- * Hook for creating a new TIP20 token.
299
- *
300
- * @example
301
- * ```tsx
302
- * import { Hooks } from 'tempo.ts/wagmi'
303
- *
304
- * function App() {
305
- * const { mutate, isPending } = Hooks.token.useCreate()
306
- *
307
- * return (
308
- * <button
309
- * onClick={() => mutate({ name: 'My Token', symbol: 'MTK', currency: 'USD' })}
310
- * disabled={isPending}
311
- * >
312
- * Create Token
313
- * </button>
314
- * )
315
- * }
316
- * ```
317
- *
318
- * @param parameters - Parameters.
319
- * @returns Mutation result.
320
- */
321
- export function useCreate(parameters = {}) {
322
- const { mutation } = parameters;
323
- const config = useConfig(parameters);
324
- return useMutation({
325
- ...mutation,
326
- async mutationFn(variables) {
327
- return Actions.create(config, variables);
328
- },
329
- mutationKey: ['create'],
330
- });
331
- }
332
- /**
333
- * Hook for creating a new TIP20 token.
334
- *
335
- * Note: This is a synchronous hook that waits for the transaction
336
- * to be included on a block before returning a response.
337
- *
338
- * @example
339
- * ```tsx
340
- * import { Hooks } from 'tempo.ts/wagmi'
341
- *
342
- * function App() {
343
- * const { mutate, isPending } = Hooks.token.useCreateSync()
344
- *
345
- * return (
346
- * <button
347
- * onClick={() => mutate({ name: 'My Token', symbol: 'MTK', currency: 'USD' })}
348
- * disabled={isPending}
349
- * >
350
- * Create Token
351
- * </button>
352
- * )
353
- * }
354
- * ```
355
- *
356
- * @param parameters - Parameters.
357
- * @returns Mutation result.
358
- */
359
- export function useCreateSync(parameters = {}) {
360
- const { mutation } = parameters;
361
- const config = useConfig(parameters);
362
- return useMutation({
363
- ...mutation,
364
- async mutationFn(variables) {
365
- return Actions.createSync(config, variables);
366
- },
367
- mutationKey: ['createSync'],
368
- });
369
- }
370
- /**
371
- * Hook for updating the quote token for a TIP20 token.
372
- *
373
- * @example
374
- * ```tsx
375
- * import { Hooks } from 'tempo.ts/wagmi'
376
- *
377
- * function App() {
378
- * const { mutate, isPending } = Hooks.token.useUpdateQuoteToken()
379
- *
380
- * return (
381
- * <button
382
- * onClick={() => mutate({ token: '0x...' })}
383
- * disabled={isPending}
384
- * >
385
- * Update Quote Token
386
- * </button>
387
- * )
388
- * }
389
- * ```
390
- *
391
- * @param parameters - Parameters.
392
- * @returns Mutation result.
393
- */
394
- export function useUpdateQuoteToken(parameters = {}) {
395
- const { mutation } = parameters;
396
- const config = useConfig(parameters);
397
- return useMutation({
398
- ...mutation,
399
- async mutationFn(variables) {
400
- return Actions.updateQuoteToken(config, variables);
401
- },
402
- mutationKey: ['updateQuoteToken'],
403
- });
404
- }
405
- /**
406
- * Hook for updating the quote token for a TIP20 token.
407
- *
408
- * Note: This is a synchronous hook that waits for the transaction
409
- * to be included on a block before returning a response.
410
- *
411
- * @example
412
- * ```tsx
413
- * import { Hooks } from 'tempo.ts/wagmi'
414
- *
415
- * function App() {
416
- * const { mutate, isPending } = Hooks.token.useUpdateQuoteTokenSync()
417
- *
418
- * return (
419
- * <button
420
- * onClick={() => mutate({ token: '0x...' })}
421
- * disabled={isPending}
422
- * >
423
- * Update Quote Token
424
- * </button>
425
- * )
426
- * }
427
- * ```
428
- *
429
- * @param parameters - Parameters.
430
- * @returns Mutation result.
431
- */
432
- export function useUpdateQuoteTokenSync(parameters = {}) {
433
- const { mutation } = parameters;
434
- const config = useConfig(parameters);
435
- return useMutation({
436
- ...mutation,
437
- async mutationFn(variables) {
438
- return Actions.updateQuoteTokenSync(config, variables);
439
- },
440
- mutationKey: ['updateQuoteTokenSync'],
441
- });
442
- }
443
- /**
444
- * Hook for getting TIP20 token allowance.
445
- *
446
- * @example
447
- * ```tsx
448
- * import { Hooks } from 'tempo.ts/wagmi'
449
- *
450
- * function App() {
451
- * const { data, isLoading } = Hooks.token.useGetAllowance({
452
- * account: '0x...',
453
- * spender: '0x...',
454
- * })
455
- *
456
- * if (isLoading) return <div>Loading...</div>
457
- * return <div>Allowance: {data?.toString()}</div>
458
- * }
459
- * ```
460
- *
461
- * @param parameters - Parameters.
462
- * @returns Query result with token allowance.
463
- */
464
- export function useGetAllowance(parameters = {}) {
465
- const { account, spender, query = {} } = parameters;
466
- const config = useConfig(parameters);
467
- const chainId = useChainId({ config });
468
- const options = Actions.getAllowance.queryOptions(config, {
469
- ...parameters,
470
- chainId: parameters.chainId ?? chainId,
471
- query: undefined,
472
- });
473
- const enabled = Boolean(account && spender && (query.enabled ?? true));
474
- return useQuery({ ...query, ...options, enabled });
475
- }
476
- /**
477
- * Hook for getting TIP20 token balance for an address.
478
- *
479
- * @example
480
- * ```tsx
481
- * import { Hooks } from 'tempo.ts/wagmi'
482
- *
483
- * function App() {
484
- * const { data, isLoading } = Hooks.token.useGetBalance({
485
- * account: '0x...',
486
- * })
487
- *
488
- * if (isLoading) return <div>Loading...</div>
489
- * return <div>Balance: {data?.toString()}</div>
490
- * }
491
- * ```
492
- *
493
- * @param parameters - Parameters.
494
- * @returns Query result with token balance.
495
- */
496
- export function useGetBalance(parameters = {}) {
497
- const { account, query = {} } = parameters;
498
- const config = useConfig(parameters);
499
- const chainId = useChainId({ config });
500
- const options = Actions.getBalance.queryOptions(config, {
501
- ...parameters,
502
- chainId: parameters.chainId ?? chainId,
503
- query: undefined,
504
- });
505
- const enabled = Boolean(account && (query.enabled ?? true));
506
- return useQuery({ ...query, ...options, enabled });
507
- }
508
- /**
509
- * Hook for getting TIP20 token metadata.
510
- *
511
- * @example
512
- * ```tsx
513
- * import { Hooks } from 'tempo.ts/wagmi'
514
- *
515
- * function App() {
516
- * const { data, isLoading } = Hooks.token.useGetMetadata({
517
- * token: '0x...',
518
- * })
519
- *
520
- * if (isLoading) return <div>Loading...</div>
521
- * return <div>{data?.name} ({data?.symbol})</div>
522
- * }
523
- * ```
524
- *
525
- * @param parameters - Parameters.
526
- * @returns Query result with token metadata.
527
- */
528
- export function useGetMetadata(parameters = {}) {
529
- const { query = {}, token } = parameters;
530
- const config = useConfig(parameters);
531
- const chainId = useChainId({ config });
532
- const options = Actions.getMetadata.queryOptions(config, {
533
- ...parameters,
534
- chainId: parameters.chainId ?? chainId,
535
- query: undefined,
536
- token: token,
537
- });
538
- const enabled = Boolean(token && (query.enabled ?? true));
539
- return useQuery({ ...query, ...options, enabled });
540
- }
541
- /**
542
- * Hook for getting the admin role for a specific role in a TIP20 token.
543
- *
544
- * @example
545
- * ```tsx
546
- * import { Hooks } from 'tempo.ts/wagmi'
547
- *
548
- * function App() {
549
- * const { data, isLoading } = Hooks.token.useGetRoleAdmin({
550
- * role: 'issuer',
551
- * token: '0x...',
552
- * })
553
- *
554
- * if (isLoading) return <div>Loading...</div>
555
- * return <div>Admin Role: {data}</div>
556
- * }
557
- * ```
558
- *
559
- * @param parameters - Parameters.
560
- * @returns Query result with admin role hash.
561
- */
562
- export function useGetRoleAdmin(parameters) {
563
- const { query = {} } = parameters;
564
- const config = useConfig(parameters);
565
- const chainId = useChainId({ config });
566
- const options = Actions.getRoleAdmin.queryOptions(config, {
567
- ...parameters,
568
- chainId: parameters.chainId ?? chainId,
569
- query: undefined,
570
- });
571
- return useQuery({ ...query, ...options });
572
- }
573
- /**
574
- * Hook for granting roles for a TIP20 token.
575
- *
576
- * @example
577
- * ```tsx
578
- * import { Hooks } from 'tempo.ts/wagmi'
579
- *
580
- * function App() {
581
- * const { mutate, isPending } = Hooks.token.useGrantRoles()
582
- *
583
- * return (
584
- * <button
585
- * onClick={() => mutate({ token: '0x...', to: '0x...', roles: ['issuer'] })}
586
- * disabled={isPending}
587
- * >
588
- * Grant Roles
589
- * </button>
590
- * )
591
- * }
592
- * ```
593
- *
594
- * @param parameters - Parameters.
595
- * @returns Mutation result.
596
- */
597
- export function useGrantRoles(parameters = {}) {
598
- const { mutation } = parameters;
599
- const config = useConfig(parameters);
600
- return useMutation({
601
- ...mutation,
602
- async mutationFn(variables) {
603
- return Actions.grantRoles(config, variables);
604
- },
605
- mutationKey: ['grantRoles'],
606
- });
607
- }
608
- /**
609
- * Hook for granting roles for a TIP20 token.
610
- *
611
- * Note: This is a synchronous hook that waits for the transaction
612
- * to be included on a block before returning a response.
613
- *
614
- * @example
615
- * ```tsx
616
- * import { Hooks } from 'tempo.ts/wagmi'
617
- *
618
- * function App() {
619
- * const { mutate, isPending } = Hooks.token.useGrantRolesSync()
620
- *
621
- * return (
622
- * <button
623
- * onClick={() => mutate({ token: '0x...', to: '0x...', roles: ['issuer'] })}
624
- * disabled={isPending}
625
- * >
626
- * Grant Roles
627
- * </button>
628
- * )
629
- * }
630
- * ```
631
- *
632
- * @param parameters - Parameters.
633
- * @returns Mutation result.
634
- */
635
- export function useGrantRolesSync(parameters = {}) {
636
- const { mutation } = parameters;
637
- const config = useConfig(parameters);
638
- return useMutation({
639
- ...mutation,
640
- async mutationFn(variables) {
641
- return Actions.grantRolesSync(config, variables);
642
- },
643
- mutationKey: ['grantRolesSync'],
644
- });
645
- }
646
- /**
647
- * Hook for checking if an account has a specific role for a TIP20 token.
648
- *
649
- * @example
650
- * ```tsx
651
- * import { Hooks } from 'tempo.ts/wagmi'
652
- *
653
- * function App() {
654
- * const { data, isLoading } = Hooks.token.useHasRole({
655
- * account: '0x...',
656
- * role: 'issuer',
657
- * token: '0x...',
658
- * })
659
- *
660
- * if (isLoading) return <div>Loading...</div>
661
- * return <div>Has Role: {data ? 'Yes' : 'No'}</div>
662
- * }
663
- * ```
664
- *
665
- * @param parameters - Parameters.
666
- * @returns Query result with boolean indicating if account has role.
667
- */
668
- export function useHasRole(parameters) {
669
- const { account, query = {} } = parameters;
670
- const config = useConfig(parameters);
671
- const chainId = useChainId({ config });
672
- const options = Actions.hasRole.queryOptions(config, {
673
- ...parameters,
674
- chainId: parameters.chainId ?? chainId,
675
- query: undefined,
676
- });
677
- const enabled = Boolean(account && (query.enabled ?? true));
678
- return useQuery({ ...query, ...options, enabled });
679
- }
680
- /**
681
- * Hook for minting TIP20 tokens to an address.
682
- *
683
- * @example
684
- * ```tsx
685
- * import { Hooks } from 'tempo.ts/wagmi'
686
- *
687
- * function App() {
688
- * const { mutate, isPending } = Hooks.token.useMint()
689
- *
690
- * return (
691
- * <button
692
- * onClick={() => mutate({ to: '0x...', amount: 100n, token: '0x...' })}
693
- * disabled={isPending}
694
- * >
695
- * Mint
696
- * </button>
697
- * )
698
- * }
699
- * ```
700
- *
701
- * @param parameters - Parameters.
702
- * @returns Mutation result.
703
- */
704
- export function useMint(parameters = {}) {
705
- const { mutation } = parameters;
706
- const config = useConfig(parameters);
707
- return useMutation({
708
- ...mutation,
709
- async mutationFn(variables) {
710
- return Actions.mint(config, variables);
711
- },
712
- mutationKey: ['mint'],
713
- });
714
- }
715
- /**
716
- * Hook for minting TIP20 tokens to an address.
717
- *
718
- * Note: This is a synchronous hook that waits for the transaction
719
- * to be included on a block before returning a response.
720
- *
721
- * @example
722
- * ```tsx
723
- * import { Hooks } from 'tempo.ts/wagmi'
724
- *
725
- * function App() {
726
- * const { mutate, isPending } = Hooks.token.useMintSync()
727
- *
728
- * return (
729
- * <button
730
- * onClick={() => mutate({ to: '0x...', amount: 100n, token: '0x...' })}
731
- * disabled={isPending}
732
- * >
733
- * Mint
734
- * </button>
735
- * )
736
- * }
737
- * ```
738
- *
739
- * @param parameters - Parameters.
740
- * @returns Mutation result.
741
- */
742
- export function useMintSync(parameters = {}) {
743
- const { mutation } = parameters;
744
- const config = useConfig(parameters);
745
- return useMutation({
746
- ...mutation,
747
- async mutationFn(variables) {
748
- return Actions.mintSync(config, variables);
749
- },
750
- mutationKey: ['mintSync'],
751
- });
752
- }
753
- /**
754
- * Hook for pausing a TIP20 token.
755
- *
756
- * @example
757
- * ```tsx
758
- * import { Hooks } from 'tempo.ts/wagmi'
759
- *
760
- * function App() {
761
- * const { mutate, isPending } = Hooks.token.usePause()
762
- *
763
- * return (
764
- * <button
765
- * onClick={() => mutate({ token: '0x...' })}
766
- * disabled={isPending}
767
- * >
768
- * Pause
769
- * </button>
770
- * )
771
- * }
772
- * ```
773
- *
774
- * @param parameters - Parameters.
775
- * @returns Mutation result.
776
- */
777
- export function usePause(parameters = {}) {
778
- const { mutation } = parameters;
779
- const config = useConfig(parameters);
780
- return useMutation({
781
- ...mutation,
782
- async mutationFn(variables) {
783
- return Actions.pause(config, variables);
784
- },
785
- mutationKey: ['pause'],
786
- });
787
- }
788
- /**
789
- * Hook for pausing a TIP20 token.
790
- *
791
- * Note: This is a synchronous hook that waits for the transaction
792
- * to be included on a block before returning a response.
793
- *
794
- * @example
795
- * ```tsx
796
- * import { Hooks } from 'tempo.ts/wagmi'
797
- *
798
- * function App() {
799
- * const { mutate, isPending } = Hooks.token.usePauseSync()
800
- *
801
- * return (
802
- * <button
803
- * onClick={() => mutate({ token: '0x...' })}
804
- * disabled={isPending}
805
- * >
806
- * Pause
807
- * </button>
808
- * )
809
- * }
810
- * ```
811
- *
812
- * @param parameters - Parameters.
813
- * @returns Mutation result.
814
- */
815
- export function usePauseSync(parameters = {}) {
816
- const { mutation } = parameters;
817
- const config = useConfig(parameters);
818
- return useMutation({
819
- ...mutation,
820
- async mutationFn(variables) {
821
- return Actions.pauseSync(config, variables);
822
- },
823
- mutationKey: ['pauseSync'],
824
- });
825
- }
826
- /**
827
- * Hook for renouncing roles for a TIP20 token.
828
- *
829
- * @example
830
- * ```tsx
831
- * import { Hooks } from 'tempo.ts/wagmi'
832
- *
833
- * function App() {
834
- * const { mutate, isPending } = Hooks.token.useRenounceRoles()
835
- *
836
- * return (
837
- * <button
838
- * onClick={() => mutate({ token: '0x...', roles: ['issuer'] })}
839
- * disabled={isPending}
840
- * >
841
- * Renounce Roles
842
- * </button>
843
- * )
844
- * }
845
- * ```
846
- *
847
- * @param parameters - Parameters.
848
- * @returns Mutation result.
849
- */
850
- export function useRenounceRoles(parameters = {}) {
851
- const { mutation } = parameters;
852
- const config = useConfig(parameters);
853
- return useMutation({
854
- ...mutation,
855
- async mutationFn(variables) {
856
- return Actions.renounceRoles(config, variables);
857
- },
858
- mutationKey: ['renounceRoles'],
859
- });
860
- }
861
- /**
862
- * Hook for renouncing roles for a TIP20 token.
863
- *
864
- * Note: This is a synchronous hook that waits for the transaction
865
- * to be included on a block before returning a response.
866
- *
867
- * @example
868
- * ```tsx
869
- * import { Hooks } from 'tempo.ts/wagmi'
870
- *
871
- * function App() {
872
- * const { mutate, isPending } = Hooks.token.useRenounceRolesSync()
873
- *
874
- * return (
875
- * <button
876
- * onClick={() => mutate({ token: '0x...', roles: ['issuer'] })}
877
- * disabled={isPending}
878
- * >
879
- * Renounce Roles
880
- * </button>
881
- * )
882
- * }
883
- * ```
884
- *
885
- * @param parameters - Parameters.
886
- * @returns Mutation result.
887
- */
888
- export function useRenounceRolesSync(parameters = {}) {
889
- const { mutation } = parameters;
890
- const config = useConfig(parameters);
891
- return useMutation({
892
- ...mutation,
893
- async mutationFn(variables) {
894
- return Actions.renounceRolesSync(config, variables);
895
- },
896
- mutationKey: ['renounceRolesSync'],
897
- });
898
- }
899
- /**
900
- * Hook for revoking roles for a TIP20 token.
901
- *
902
- * @example
903
- * ```tsx
904
- * import { Hooks } from 'tempo.ts/wagmi'
905
- *
906
- * function App() {
907
- * const { mutate, isPending } = Hooks.token.useRevokeRoles()
908
- *
909
- * return (
910
- * <button
911
- * onClick={() => mutate({ token: '0x...', from: '0x...', roles: ['issuer'] })}
912
- * disabled={isPending}
913
- * >
914
- * Revoke Roles
915
- * </button>
916
- * )
917
- * }
918
- * ```
919
- *
920
- * @param parameters - Parameters.
921
- * @returns Mutation result.
922
- */
923
- export function useRevokeRoles(parameters = {}) {
924
- const { mutation } = parameters;
925
- const config = useConfig(parameters);
926
- return useMutation({
927
- ...mutation,
928
- async mutationFn(variables) {
929
- return Actions.revokeRoles(config, variables);
930
- },
931
- mutationKey: ['revokeRoles'],
932
- });
933
- }
934
- /**
935
- * Hook for revoking roles for a TIP20 token.
936
- *
937
- * Note: This is a synchronous hook that waits for the transaction
938
- * to be included on a block before returning a response.
939
- *
940
- * @example
941
- * ```tsx
942
- * import { Hooks } from 'tempo.ts/wagmi'
943
- *
944
- * function App() {
945
- * const { mutate, isPending } = Hooks.token.useRevokeRolesSync()
946
- *
947
- * return (
948
- * <button
949
- * onClick={() => mutate({ token: '0x...', from: '0x...', roles: ['issuer'] })}
950
- * disabled={isPending}
951
- * >
952
- * Revoke Roles
953
- * </button>
954
- * )
955
- * }
956
- * ```
957
- *
958
- * @param parameters - Parameters.
959
- * @returns Mutation result.
960
- */
961
- export function useRevokeRolesSync(parameters = {}) {
962
- const { mutation } = parameters;
963
- const config = useConfig(parameters);
964
- return useMutation({
965
- ...mutation,
966
- async mutationFn(variables) {
967
- return Actions.revokeRolesSync(config, variables);
968
- },
969
- mutationKey: ['revokeRolesSync'],
970
- });
971
- }
972
- /**
973
- * Hook for setting the admin role for a specific role in a TIP20 token.
974
- *
975
- * @example
976
- * ```tsx
977
- * import { Hooks } from 'tempo.ts/wagmi'
978
- *
979
- * function App() {
980
- * const { mutate, isPending } = Hooks.token.useSetRoleAdmin()
981
- *
982
- * return (
983
- * <button
984
- * onClick={() => mutate({ token: '0x...', role: 'issuer', adminRole: 'pause' })}
985
- * disabled={isPending}
986
- * >
987
- * Set Role Admin
988
- * </button>
989
- * )
990
- * }
991
- * ```
992
- *
993
- * @param parameters - Parameters.
994
- * @returns Mutation result.
995
- */
996
- export function useSetRoleAdmin(parameters = {}) {
997
- const { mutation } = parameters;
998
- const config = useConfig(parameters);
999
- return useMutation({
1000
- ...mutation,
1001
- async mutationFn(variables) {
1002
- return Actions.setRoleAdmin(config, variables);
1003
- },
1004
- mutationKey: ['setRoleAdmin'],
1005
- });
1006
- }
1007
- /**
1008
- * Hook for setting the admin role for a specific role in a TIP20 token.
1009
- *
1010
- * Note: This is a synchronous hook that waits for the transaction
1011
- * to be included on a block before returning a response.
1012
- *
1013
- * @example
1014
- * ```tsx
1015
- * import { Hooks } from 'tempo.ts/wagmi'
1016
- *
1017
- * function App() {
1018
- * const { mutate, isPending } = Hooks.token.useSetRoleAdminSync()
1019
- *
1020
- * return (
1021
- * <button
1022
- * onClick={() => mutate({ token: '0x...', role: 'issuer', adminRole: 'pause' })}
1023
- * disabled={isPending}
1024
- * >
1025
- * Set Role Admin
1026
- * </button>
1027
- * )
1028
- * }
1029
- * ```
1030
- *
1031
- * @param parameters - Parameters.
1032
- * @returns Mutation result.
1033
- */
1034
- export function useSetRoleAdminSync(parameters = {}) {
1035
- const { mutation } = parameters;
1036
- const config = useConfig(parameters);
1037
- return useMutation({
1038
- ...mutation,
1039
- async mutationFn(variables) {
1040
- return Actions.setRoleAdminSync(config, variables);
1041
- },
1042
- mutationKey: ['setRoleAdminSync'],
1043
- });
1044
- }
1045
- /**
1046
- * Hook for setting the supply cap for a TIP20 token.
1047
- *
1048
- * @example
1049
- * ```tsx
1050
- * import { Hooks } from 'tempo.ts/wagmi'
1051
- *
1052
- * function App() {
1053
- * const { mutate, isPending } = Hooks.token.useSetSupplyCap()
1054
- *
1055
- * return (
1056
- * <button
1057
- * onClick={() => mutate({ token: '0x...', supplyCap: 1000000n })}
1058
- * disabled={isPending}
1059
- * >
1060
- * Set Supply Cap
1061
- * </button>
1062
- * )
1063
- * }
1064
- * ```
1065
- *
1066
- * @param parameters - Parameters.
1067
- * @returns Mutation result.
1068
- */
1069
- export function useSetSupplyCap(parameters = {}) {
1070
- const { mutation } = parameters;
1071
- const config = useConfig(parameters);
1072
- return useMutation({
1073
- ...mutation,
1074
- async mutationFn(variables) {
1075
- return Actions.setSupplyCap(config, variables);
1076
- },
1077
- mutationKey: ['setSupplyCap'],
1078
- });
1079
- }
1080
- /**
1081
- * Hook for setting the supply cap for a TIP20 token.
1082
- *
1083
- * Note: This is a synchronous hook that waits for the transaction
1084
- * to be included on a block before returning a response.
1085
- *
1086
- * @example
1087
- * ```tsx
1088
- * import { Hooks } from 'tempo.ts/wagmi'
1089
- *
1090
- * function App() {
1091
- * const { mutate, isPending } = Hooks.token.useSetSupplyCapSync()
1092
- *
1093
- * return (
1094
- * <button
1095
- * onClick={() => mutate({ token: '0x...', supplyCap: 1000000n })}
1096
- * disabled={isPending}
1097
- * >
1098
- * Set Supply Cap
1099
- * </button>
1100
- * )
1101
- * }
1102
- * ```
1103
- *
1104
- * @param parameters - Parameters.
1105
- * @returns Mutation result.
1106
- */
1107
- export function useSetSupplyCapSync(parameters = {}) {
1108
- const { mutation } = parameters;
1109
- const config = useConfig(parameters);
1110
- return useMutation({
1111
- ...mutation,
1112
- async mutationFn(variables) {
1113
- return Actions.setSupplyCapSync(config, variables);
1114
- },
1115
- mutationKey: ['setSupplyCapSync'],
1116
- });
1117
- }
1118
- /**
1119
- * Hook for transferring TIP20 tokens to another address.
1120
- *
1121
- * @example
1122
- * ```tsx
1123
- * import { Hooks } from 'tempo.ts/wagmi'
1124
- *
1125
- * function App() {
1126
- * const { mutate, isPending } = Hooks.token.useTransfer()
1127
- *
1128
- * return (
1129
- * <button
1130
- * onClick={() => mutate({ to: '0x...', amount: 100n })}
1131
- * disabled={isPending}
1132
- * >
1133
- * Transfer
1134
- * </button>
1135
- * )
1136
- * }
1137
- * ```
1138
- *
1139
- * @param parameters - Parameters.
1140
- * @returns Mutation result.
1141
- */
1142
- export function useTransfer(parameters = {}) {
1143
- const { mutation } = parameters;
1144
- const config = useConfig(parameters);
1145
- return useMutation({
1146
- ...mutation,
1147
- async mutationFn(variables) {
1148
- return Actions.transfer(config, variables);
1149
- },
1150
- mutationKey: ['transfer'],
1151
- });
1152
- }
1153
- /**
1154
- * Hook for transferring TIP20 tokens to another address.
1155
- *
1156
- * Note: This is a synchronous hook that waits for the transaction
1157
- * to be included on a block before returning a response.
1158
- *
1159
- * @example
1160
- * ```tsx
1161
- * import { Hooks } from 'tempo.ts/wagmi'
1162
- *
1163
- * function App() {
1164
- * const { mutate, isPending } = Hooks.token.useTransferSync()
1165
- *
1166
- * return (
1167
- * <button
1168
- * onClick={() => mutate({ to: '0x...', amount: 100n })}
1169
- * disabled={isPending}
1170
- * >
1171
- * Transfer
1172
- * </button>
1173
- * )
1174
- * }
1175
- * ```
1176
- *
1177
- * @param parameters - Parameters.
1178
- * @returns Mutation result.
1179
- */
1180
- export function useTransferSync(parameters = {}) {
1181
- const { mutation } = parameters;
1182
- const config = useConfig(parameters);
1183
- return useMutation({
1184
- ...mutation,
1185
- async mutationFn(variables) {
1186
- return Actions.transferSync(config, variables);
1187
- },
1188
- mutationKey: ['transferSync'],
1189
- });
1190
- }
1191
- /**
1192
- * Hook for unpausing a TIP20 token.
1193
- *
1194
- * @example
1195
- * ```tsx
1196
- * import { Hooks } from 'tempo.ts/wagmi'
1197
- *
1198
- * function App() {
1199
- * const { mutate, isPending } = Hooks.token.useUnpause()
1200
- *
1201
- * return (
1202
- * <button
1203
- * onClick={() => mutate({ token: '0x...' })}
1204
- * disabled={isPending}
1205
- * >
1206
- * Unpause
1207
- * </button>
1208
- * )
1209
- * }
1210
- * ```
1211
- *
1212
- * @param parameters - Parameters.
1213
- * @returns Mutation result.
1214
- */
1215
- export function useUnpause(parameters = {}) {
1216
- const { mutation } = parameters;
1217
- const config = useConfig(parameters);
1218
- return useMutation({
1219
- ...mutation,
1220
- async mutationFn(variables) {
1221
- return Actions.unpause(config, variables);
1222
- },
1223
- mutationKey: ['unpause'],
1224
- });
1225
- }
1226
- /**
1227
- * Hook for unpausing a TIP20 token.
1228
- *
1229
- * Note: This is a synchronous hook that waits for the transaction
1230
- * to be included on a block before returning a response.
1231
- *
1232
- * @example
1233
- * ```tsx
1234
- * import { Hooks } from 'tempo.ts/wagmi'
1235
- *
1236
- * function App() {
1237
- * const { mutate, isPending } = Hooks.token.useUnpauseSync()
1238
- *
1239
- * return (
1240
- * <button
1241
- * onClick={() => mutate({ token: '0x...' })}
1242
- * disabled={isPending}
1243
- * >
1244
- * Unpause
1245
- * </button>
1246
- * )
1247
- * }
1248
- * ```
1249
- *
1250
- * @param parameters - Parameters.
1251
- * @returns Mutation result.
1252
- */
1253
- export function useUnpauseSync(parameters = {}) {
1254
- const { mutation } = parameters;
1255
- const config = useConfig(parameters);
1256
- return useMutation({
1257
- ...mutation,
1258
- async mutationFn(variables) {
1259
- return Actions.unpauseSync(config, variables);
1260
- },
1261
- mutationKey: ['unpauseSync'],
1262
- });
1263
- }
1264
- /**
1265
- * Hook for preparing the quote token update for a TIP20 token.
1266
- *
1267
- * @example
1268
- * ```tsx
1269
- * import { Hooks } from 'tempo.ts/wagmi'
1270
- *
1271
- * function App() {
1272
- * const { mutate, isPending } = Hooks.token.usePrepareUpdateQuoteToken()
1273
- *
1274
- * return (
1275
- * <button
1276
- * onClick={() => mutate({ token: '0x...', quoteToken: '0x...' })}
1277
- * disabled={isPending}
1278
- * >
1279
- * Prepare Update Quote Token
1280
- * </button>
1281
- * )
1282
- * }
1283
- * ```
1284
- *
1285
- * @param parameters - Parameters.
1286
- * @returns Mutation result.
1287
- */
1288
- export function usePrepareUpdateQuoteToken(parameters = {}) {
1289
- const { mutation } = parameters;
1290
- const config = useConfig(parameters);
1291
- return useMutation({
1292
- ...mutation,
1293
- async mutationFn(variables) {
1294
- return Actions.prepareUpdateQuoteToken(config, variables);
1295
- },
1296
- mutationKey: ['prepareUpdateQuoteToken'],
1297
- });
1298
- }
1299
- /**
1300
- * Hook for preparing the quote token update for a TIP20 token.
1301
- *
1302
- * Note: This is a synchronous hook that waits for the transaction
1303
- * to be included on a block before returning a response.
1304
- *
1305
- * @example
1306
- * ```tsx
1307
- * import { Hooks } from 'tempo.ts/wagmi'
1308
- *
1309
- * function App() {
1310
- * const { mutate, isPending } = Hooks.token.usePrepareUpdateQuoteTokenSync()
1311
- *
1312
- * return (
1313
- * <button
1314
- * onClick={() => mutate({ token: '0x...', quoteToken: '0x...' })}
1315
- * disabled={isPending}
1316
- * >
1317
- * Prepare Update Quote Token
1318
- * </button>
1319
- * )
1320
- * }
1321
- * ```
1322
- *
1323
- * @param parameters - Parameters.
1324
- * @returns Mutation result.
1325
- */
1326
- export function usePrepareUpdateQuoteTokenSync(parameters = {}) {
1327
- const { mutation } = parameters;
1328
- const config = useConfig(parameters);
1329
- return useMutation({
1330
- ...mutation,
1331
- async mutationFn(variables) {
1332
- return Actions.prepareUpdateQuoteTokenSync(config, variables);
1333
- },
1334
- mutationKey: ['prepareUpdateQuoteTokenSync'],
1335
- });
1336
- }
1337
- /**
1338
- * Hook for watching TIP20 token role admin updates.
1339
- *
1340
- * @example
1341
- * ```tsx
1342
- * import { Hooks } from 'tempo.ts/wagmi'
1343
- *
1344
- * function App() {
1345
- * Hooks.token.useWatchAdminRole({
1346
- * onRoleAdminUpdated(args) {
1347
- * console.log('Role admin updated:', args)
1348
- * },
1349
- * })
1350
- *
1351
- * return <div>Watching for role admin updates...</div>
1352
- * }
1353
- * ```
1354
- *
1355
- * @param parameters - Parameters.
1356
- */
1357
- export function useWatchAdminRole(parameters = {}) {
1358
- const { enabled = true, onRoleAdminUpdated, token, ...rest } = parameters;
1359
- const config = useConfig({ config: parameters.config });
1360
- const configChainId = useChainId({ config });
1361
- const chainId = parameters.chainId ?? configChainId;
1362
- useEffect(() => {
1363
- if (!enabled)
1364
- return;
1365
- if (!onRoleAdminUpdated)
1366
- return;
1367
- if (!token)
1368
- return;
1369
- return Actions.watchAdminRole(config, {
1370
- ...rest,
1371
- chainId,
1372
- onRoleAdminUpdated,
1373
- token,
1374
- });
1375
- }, [config, enabled, onRoleAdminUpdated, rest]);
1376
- }
1377
- /**
1378
- * Hook for watching TIP20 token approval events.
1379
- *
1380
- * @example
1381
- * ```tsx
1382
- * import { Hooks } from 'tempo.ts/wagmi'
1383
- *
1384
- * function App() {
1385
- * Hooks.token.useWatchApprove({
1386
- * onApproval(args) {
1387
- * console.log('Approval:', args)
1388
- * },
1389
- * })
1390
- *
1391
- * return <div>Watching for approvals...</div>
1392
- * }
1393
- * ```
1394
- *
1395
- * @param parameters - Parameters.
1396
- */
1397
- export function useWatchApprove(parameters = {}) {
1398
- const { enabled = true, onApproval, token, ...rest } = parameters;
1399
- const config = useConfig({ config: parameters.config });
1400
- const configChainId = useChainId({ config });
1401
- const chainId = parameters.chainId ?? configChainId;
1402
- useEffect(() => {
1403
- if (!enabled)
1404
- return;
1405
- if (!onApproval)
1406
- return;
1407
- if (!token)
1408
- return;
1409
- return Actions.watchApprove(config, {
1410
- ...rest,
1411
- chainId,
1412
- onApproval,
1413
- token,
1414
- });
1415
- }, [config, enabled, onApproval, rest]);
1416
- }
1417
- /**
1418
- * Hook for watching TIP20 token burn events.
1419
- *
1420
- * @example
1421
- * ```tsx
1422
- * import { Hooks } from 'tempo.ts/wagmi'
1423
- *
1424
- * function App() {
1425
- * Hooks.token.useWatchBurn({
1426
- * onBurn(args) {
1427
- * console.log('Burn:', args)
1428
- * },
1429
- * })
1430
- *
1431
- * return <div>Watching for burns...</div>
1432
- * }
1433
- * ```
1434
- *
1435
- * @param parameters - Parameters.
1436
- */
1437
- export function useWatchBurn(parameters = {}) {
1438
- const { enabled = true, onBurn, token, ...rest } = parameters;
1439
- const config = useConfig({ config: parameters.config });
1440
- const configChainId = useChainId({ config });
1441
- const chainId = parameters.chainId ?? configChainId;
1442
- useEffect(() => {
1443
- if (!enabled)
1444
- return;
1445
- if (!onBurn)
1446
- return;
1447
- if (!token)
1448
- return;
1449
- return Actions.watchBurn(config, {
1450
- ...rest,
1451
- chainId,
1452
- onBurn,
1453
- token,
1454
- });
1455
- }, [config, enabled, onBurn, rest, token]);
1456
- }
1457
- /**
1458
- * Hook for watching new TIP20 tokens created.
1459
- *
1460
- * @example
1461
- * ```tsx
1462
- * import { Hooks } from 'tempo.ts/wagmi'
1463
- *
1464
- * function App() {
1465
- * Hooks.token.useWatchCreate({
1466
- * onTokenCreated(args) {
1467
- * console.log('Token created:', args)
1468
- * },
1469
- * })
1470
- *
1471
- * return <div>Watching for token creations...</div>
1472
- * }
1473
- * ```
1474
- *
1475
- * @param parameters - Parameters.
1476
- */
1477
- export function useWatchCreate(parameters = {}) {
1478
- const { enabled = true, onTokenCreated, ...rest } = parameters;
1479
- const config = useConfig({ config: parameters.config });
1480
- const configChainId = useChainId({ config });
1481
- const chainId = parameters.chainId ?? configChainId;
1482
- useEffect(() => {
1483
- if (!enabled)
1484
- return;
1485
- if (!onTokenCreated)
1486
- return;
1487
- return Actions.watchCreate(config, {
1488
- ...rest,
1489
- chainId,
1490
- onTokenCreated,
1491
- });
1492
- }, [config, enabled, onTokenCreated, rest]);
1493
- }
1494
- /**
1495
- * Hook for watching TIP20 token mint events.
1496
- *
1497
- * @example
1498
- * ```tsx
1499
- * import { Hooks } from 'tempo.ts/wagmi'
1500
- *
1501
- * function App() {
1502
- * Hooks.token.useWatchMint({
1503
- * onMint(args) {
1504
- * console.log('Mint:', args)
1505
- * },
1506
- * })
1507
- *
1508
- * return <div>Watching for mints...</div>
1509
- * }
1510
- * ```
1511
- *
1512
- * @param parameters - Parameters.
1513
- */
1514
- export function useWatchMint(parameters = {}) {
1515
- const { enabled = true, onMint, token, ...rest } = parameters;
1516
- const config = useConfig({ config: parameters.config });
1517
- const configChainId = useChainId({ config });
1518
- const chainId = parameters.chainId ?? configChainId;
1519
- useEffect(() => {
1520
- if (!enabled)
1521
- return;
1522
- if (!onMint)
1523
- return;
1524
- if (!token)
1525
- return;
1526
- return Actions.watchMint(config, {
1527
- ...rest,
1528
- chainId,
1529
- onMint,
1530
- token,
1531
- });
1532
- }, [config, enabled, onMint, rest, token]);
1533
- }
1534
- /**
1535
- * Hook for watching TIP20 token role membership updates.
1536
- *
1537
- * @example
1538
- * ```tsx
1539
- * import { Hooks } from 'tempo.ts/wagmi'
1540
- *
1541
- * function App() {
1542
- * Hooks.token.useWatchRole({
1543
- * onRoleUpdated(args) {
1544
- * console.log('Role updated:', args)
1545
- * },
1546
- * })
1547
- *
1548
- * return <div>Watching for role updates...</div>
1549
- * }
1550
- * ```
1551
- *
1552
- * @param parameters - Parameters.
1553
- */
1554
- export function useWatchRole(parameters = {}) {
1555
- const { enabled = true, onRoleUpdated, token, ...rest } = parameters;
1556
- const config = useConfig({ config: parameters.config });
1557
- const configChainId = useChainId({ config });
1558
- const chainId = parameters.chainId ?? configChainId;
1559
- useEffect(() => {
1560
- if (!enabled)
1561
- return;
1562
- if (!onRoleUpdated)
1563
- return;
1564
- if (!token)
1565
- return;
1566
- return Actions.watchRole(config, {
1567
- ...rest,
1568
- chainId,
1569
- onRoleUpdated,
1570
- token,
1571
- });
1572
- }, [config, enabled, onRoleUpdated, rest, token]);
1573
- }
1574
- /**
1575
- * Hook for watching TIP20 token transfer events.
1576
- *
1577
- * @example
1578
- * ```tsx
1579
- * import { Hooks } from 'tempo.ts/wagmi'
1580
- *
1581
- * function App() {
1582
- * Hooks.token.useWatchTransfer({
1583
- * onTransfer(args) {
1584
- * console.log('Transfer:', args)
1585
- * },
1586
- * })
1587
- *
1588
- * return <div>Watching for transfers...</div>
1589
- * }
1590
- * ```
1591
- *
1592
- * @param parameters - Parameters.
1593
- */
1594
- export function useWatchTransfer(parameters = {}) {
1595
- const { enabled = true, onTransfer, token, ...rest } = parameters;
1596
- const config = useConfig({ config: parameters.config });
1597
- const configChainId = useChainId({ config });
1598
- const chainId = parameters.chainId ?? configChainId;
1599
- useEffect(() => {
1600
- if (!enabled)
1601
- return;
1602
- if (!onTransfer)
1603
- return;
1604
- if (!token)
1605
- return;
1606
- return Actions.watchTransfer(config, {
1607
- ...rest,
1608
- chainId,
1609
- onTransfer,
1610
- token,
1611
- });
1612
- }, [config, enabled, onTransfer, rest]);
1613
- }
1614
- /**
1615
- * Hook for watching TIP20 token quote token update events.
1616
- *
1617
- * @example
1618
- * ```tsx
1619
- * import { Hooks } from 'tempo.ts/wagmi'
1620
- *
1621
- * function App() {
1622
- * Hooks.token.useWatchUpdateQuoteToken({
1623
- * onUpdateQuoteToken(args) {
1624
- * if (args.completed)
1625
- * console.log('quote token update completed:', args.newQuoteToken)
1626
- * else
1627
- * console.log('quote token update proposed:', args.newQuoteToken)
1628
- * },
1629
- * })
1630
- *
1631
- * return <div>Watching for quote token updates...</div>
1632
- * }
1633
- * ```
1634
- *
1635
- * @param parameters - Parameters.
1636
- */
1637
- export function useWatchUpdateQuoteToken(parameters = {}) {
1638
- const { enabled = true, onUpdateQuoteToken, token, ...rest } = parameters;
1639
- const config = useConfig({ config: parameters.config });
1640
- const configChainId = useChainId({ config });
1641
- const chainId = parameters.chainId ?? configChainId;
1642
- useEffect(() => {
1643
- if (!enabled)
1644
- return;
1645
- if (!onUpdateQuoteToken)
1646
- return;
1647
- if (!token)
1648
- return;
1649
- return Actions.watchUpdateQuoteToken(config, {
1650
- ...rest,
1651
- chainId,
1652
- onUpdateQuoteToken,
1653
- token,
1654
- });
1655
- }, [config, enabled, onUpdateQuoteToken, rest, token]);
1656
- }
1657
- //# sourceMappingURL=token.js.map