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