wagmi 3.1.4 → 3.3.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 +485 -0
- package/dist/esm/tempo/hooks/amm.js.map +1 -0
- package/dist/esm/tempo/hooks/dex.js +1020 -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 +85 -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 +384 -0
- package/dist/types/tempo/hooks/amm.d.ts.map +1 -0
- package/dist/types/tempo/hooks/dex.d.ts +841 -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 +60 -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 +776 -0
- package/src/tempo/hooks/dex.ts +1737 -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 +126 -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,668 @@
|
|
|
1
|
+
import type { UseMutationResult } from '@tanstack/react-query'
|
|
2
|
+
import type { Config, ResolvedRegister } from '@wagmi/core'
|
|
3
|
+
import type { ExactPartial, UnionCompute } from '@wagmi/core/internal'
|
|
4
|
+
import { Actions } from '@wagmi/core/tempo'
|
|
5
|
+
import { useEffect } from 'react'
|
|
6
|
+
|
|
7
|
+
import { useChainId } from '../../hooks/useChainId.js'
|
|
8
|
+
import { useConfig } from '../../hooks/useConfig.js'
|
|
9
|
+
import type { ConfigParameter, QueryParameter } from '../../types/properties.js'
|
|
10
|
+
import {
|
|
11
|
+
type UseMutationParameters,
|
|
12
|
+
type UseQueryReturnType,
|
|
13
|
+
useMutation,
|
|
14
|
+
useQuery,
|
|
15
|
+
} from '../../utils/query.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Hook for claiming accumulated rewards.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
23
|
+
*
|
|
24
|
+
* function App() {
|
|
25
|
+
* const { mutate: claim } = Hooks.reward.useClaim()
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <button onClick={() => claim({
|
|
29
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
30
|
+
* })}>
|
|
31
|
+
* Claim Rewards
|
|
32
|
+
* </button>
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param parameters - Parameters.
|
|
38
|
+
* @returns Mutation result.
|
|
39
|
+
*/
|
|
40
|
+
export function useClaim<
|
|
41
|
+
config extends Config = ResolvedRegister['config'],
|
|
42
|
+
context = unknown,
|
|
43
|
+
>(
|
|
44
|
+
parameters: useClaim.Parameters<config, context> = {},
|
|
45
|
+
): useClaim.ReturnType<config, context> {
|
|
46
|
+
const { mutation } = parameters
|
|
47
|
+
const config = useConfig(parameters)
|
|
48
|
+
return useMutation({
|
|
49
|
+
...mutation,
|
|
50
|
+
async mutationFn(variables) {
|
|
51
|
+
return Actions.reward.claim(config, variables as never)
|
|
52
|
+
},
|
|
53
|
+
mutationKey: ['claim'],
|
|
54
|
+
}) as never
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare namespace useClaim {
|
|
58
|
+
type Parameters<
|
|
59
|
+
config extends Config = Config,
|
|
60
|
+
context = unknown,
|
|
61
|
+
> = ConfigParameter<config> & {
|
|
62
|
+
mutation?:
|
|
63
|
+
| UseMutationParameters<
|
|
64
|
+
Actions.reward.claim.ReturnValue,
|
|
65
|
+
Actions.reward.claim.ErrorType,
|
|
66
|
+
Actions.reward.claim.Parameters<config>,
|
|
67
|
+
context
|
|
68
|
+
>
|
|
69
|
+
| undefined
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type ReturnType<
|
|
73
|
+
config extends Config = Config,
|
|
74
|
+
context = unknown,
|
|
75
|
+
> = UseMutationResult<
|
|
76
|
+
Actions.reward.claim.ReturnValue,
|
|
77
|
+
Actions.reward.claim.ErrorType,
|
|
78
|
+
Actions.reward.claim.Parameters<config>,
|
|
79
|
+
context
|
|
80
|
+
>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Hook for claiming accumulated rewards and waiting for confirmation.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
89
|
+
*
|
|
90
|
+
* function App() {
|
|
91
|
+
* const { mutate: claimSync } = Hooks.reward.useClaimSync()
|
|
92
|
+
*
|
|
93
|
+
* return (
|
|
94
|
+
* <button onClick={() => claimSync({
|
|
95
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
96
|
+
* })}>
|
|
97
|
+
* Claim Rewards
|
|
98
|
+
* </button>
|
|
99
|
+
* )
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param parameters - Parameters.
|
|
104
|
+
* @returns Mutation result.
|
|
105
|
+
*/
|
|
106
|
+
export function useClaimSync<
|
|
107
|
+
config extends Config = ResolvedRegister['config'],
|
|
108
|
+
context = unknown,
|
|
109
|
+
>(
|
|
110
|
+
parameters: useClaimSync.Parameters<config, context> = {},
|
|
111
|
+
): useClaimSync.ReturnType<config, context> {
|
|
112
|
+
const { mutation } = parameters
|
|
113
|
+
const config = useConfig(parameters)
|
|
114
|
+
return useMutation({
|
|
115
|
+
...mutation,
|
|
116
|
+
async mutationFn(variables) {
|
|
117
|
+
return Actions.reward.claimSync(config, variables as never)
|
|
118
|
+
},
|
|
119
|
+
mutationKey: ['claimSync'],
|
|
120
|
+
}) as never
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare namespace useClaimSync {
|
|
124
|
+
type Parameters<
|
|
125
|
+
config extends Config = Config,
|
|
126
|
+
context = unknown,
|
|
127
|
+
> = ConfigParameter<config> & {
|
|
128
|
+
mutation?:
|
|
129
|
+
| UseMutationParameters<
|
|
130
|
+
Actions.reward.claimSync.ReturnValue,
|
|
131
|
+
Actions.reward.claimSync.ErrorType,
|
|
132
|
+
Actions.reward.claimSync.Parameters<config>,
|
|
133
|
+
context
|
|
134
|
+
>
|
|
135
|
+
| undefined
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type ReturnType<
|
|
139
|
+
config extends Config = Config,
|
|
140
|
+
context = unknown,
|
|
141
|
+
> = UseMutationResult<
|
|
142
|
+
Actions.reward.claimSync.ReturnValue,
|
|
143
|
+
Actions.reward.claimSync.ErrorType,
|
|
144
|
+
Actions.reward.claimSync.Parameters<config>,
|
|
145
|
+
context
|
|
146
|
+
>
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook for getting the global reward per token value.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
155
|
+
*
|
|
156
|
+
* function App() {
|
|
157
|
+
* const { data, isLoading } = Hooks.reward.useGetGlobalRewardPerToken({
|
|
158
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
159
|
+
* })
|
|
160
|
+
*
|
|
161
|
+
* if (isLoading) return <div>Loading...</div>
|
|
162
|
+
* return <div>Value: {data?.toString()}</div>
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param parameters - Parameters.
|
|
167
|
+
* @returns Query result with global reward per token value.
|
|
168
|
+
*/
|
|
169
|
+
export function useGetGlobalRewardPerToken<
|
|
170
|
+
config extends Config = ResolvedRegister['config'],
|
|
171
|
+
selectData = Actions.reward.getGlobalRewardPerToken.ReturnValue,
|
|
172
|
+
>(
|
|
173
|
+
parameters: useGetGlobalRewardPerToken.Parameters<config, selectData> = {},
|
|
174
|
+
): useGetGlobalRewardPerToken.ReturnValue<selectData> {
|
|
175
|
+
const config = useConfig(parameters)
|
|
176
|
+
const chainId = useChainId({ config })
|
|
177
|
+
const options = Actions.reward.getGlobalRewardPerToken.queryOptions(config, {
|
|
178
|
+
...parameters,
|
|
179
|
+
chainId: parameters.chainId ?? chainId,
|
|
180
|
+
} as never)
|
|
181
|
+
return useQuery(options) as never
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export declare namespace useGetGlobalRewardPerToken {
|
|
185
|
+
export type Parameters<
|
|
186
|
+
config extends Config = ResolvedRegister['config'],
|
|
187
|
+
selectData = Actions.reward.getGlobalRewardPerToken.ReturnValue,
|
|
188
|
+
> = ConfigParameter<config> &
|
|
189
|
+
QueryParameter<
|
|
190
|
+
Actions.reward.getGlobalRewardPerToken.ReturnValue,
|
|
191
|
+
Actions.reward.getGlobalRewardPerToken.ErrorType,
|
|
192
|
+
selectData,
|
|
193
|
+
Actions.reward.getGlobalRewardPerToken.QueryKey<config>
|
|
194
|
+
> &
|
|
195
|
+
ExactPartial<
|
|
196
|
+
Omit<
|
|
197
|
+
Actions.reward.getGlobalRewardPerToken.queryOptions.Parameters<
|
|
198
|
+
config,
|
|
199
|
+
selectData
|
|
200
|
+
>,
|
|
201
|
+
'query'
|
|
202
|
+
>
|
|
203
|
+
>
|
|
204
|
+
|
|
205
|
+
export type ReturnValue<
|
|
206
|
+
selectData = Actions.reward.getGlobalRewardPerToken.ReturnValue,
|
|
207
|
+
> = UseQueryReturnType<selectData, Error>
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Hook for getting the reward information for a specific account.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```tsx
|
|
215
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
216
|
+
*
|
|
217
|
+
* function App() {
|
|
218
|
+
* const { data, isLoading } = Hooks.reward.useUserRewardInfo({
|
|
219
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
220
|
+
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
221
|
+
* })
|
|
222
|
+
*
|
|
223
|
+
* if (isLoading) return <div>Loading...</div>
|
|
224
|
+
* return (
|
|
225
|
+
* <div>
|
|
226
|
+
* <div>Recipient: {data?.rewardRecipient}</div>
|
|
227
|
+
* <div>Reward per token: {data?.rewardPerToken.toString()}</div>
|
|
228
|
+
* <div>Reward balance: {data?.rewardBalance.toString()}</div>
|
|
229
|
+
* </div>
|
|
230
|
+
* )
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @param parameters - Parameters.
|
|
235
|
+
* @returns Query result with reward information (recipient, rewardPerToken, rewardBalance).
|
|
236
|
+
*/
|
|
237
|
+
export function useUserRewardInfo<
|
|
238
|
+
config extends Config = ResolvedRegister['config'],
|
|
239
|
+
selectData = Actions.reward.getUserRewardInfo.ReturnValue,
|
|
240
|
+
>(
|
|
241
|
+
parameters: useUserRewardInfo.Parameters<config, selectData> = {},
|
|
242
|
+
): useUserRewardInfo.ReturnValue<selectData> {
|
|
243
|
+
const config = useConfig(parameters)
|
|
244
|
+
const chainId = useChainId({ config })
|
|
245
|
+
const options = Actions.reward.getUserRewardInfo.queryOptions(config, {
|
|
246
|
+
...parameters,
|
|
247
|
+
chainId: parameters.chainId ?? chainId,
|
|
248
|
+
} as never)
|
|
249
|
+
return useQuery(options) as never
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare namespace useUserRewardInfo {
|
|
253
|
+
export type Parameters<
|
|
254
|
+
config extends Config = ResolvedRegister['config'],
|
|
255
|
+
selectData = Actions.reward.getUserRewardInfo.ReturnValue,
|
|
256
|
+
> = ConfigParameter<config> &
|
|
257
|
+
QueryParameter<
|
|
258
|
+
Actions.reward.getUserRewardInfo.ReturnValue,
|
|
259
|
+
Actions.reward.getUserRewardInfo.ErrorType,
|
|
260
|
+
selectData,
|
|
261
|
+
Actions.reward.getUserRewardInfo.QueryKey<config>
|
|
262
|
+
> &
|
|
263
|
+
ExactPartial<
|
|
264
|
+
Omit<
|
|
265
|
+
Actions.reward.getUserRewardInfo.queryOptions.Parameters<
|
|
266
|
+
config,
|
|
267
|
+
selectData
|
|
268
|
+
>,
|
|
269
|
+
'query'
|
|
270
|
+
>
|
|
271
|
+
>
|
|
272
|
+
|
|
273
|
+
export type ReturnValue<
|
|
274
|
+
selectData = Actions.reward.getUserRewardInfo.ReturnValue,
|
|
275
|
+
> = UseQueryReturnType<selectData, Error>
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Hook for setting the reward recipient for a token holder.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```tsx
|
|
283
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
284
|
+
*
|
|
285
|
+
* function App() {
|
|
286
|
+
* const { mutate: setRecipient } = Hooks.reward.useSetRecipient()
|
|
287
|
+
*
|
|
288
|
+
* return (
|
|
289
|
+
* <button onClick={() => setRecipient({
|
|
290
|
+
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
291
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
292
|
+
* })}>
|
|
293
|
+
* Set Recipient
|
|
294
|
+
* </button>
|
|
295
|
+
* )
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param parameters - Parameters.
|
|
300
|
+
* @returns Mutation result.
|
|
301
|
+
*/
|
|
302
|
+
export function useSetRecipient<
|
|
303
|
+
config extends Config = ResolvedRegister['config'],
|
|
304
|
+
context = unknown,
|
|
305
|
+
>(
|
|
306
|
+
parameters: useSetRecipient.Parameters<config, context> = {},
|
|
307
|
+
): useSetRecipient.ReturnType<config, context> {
|
|
308
|
+
const { mutation } = parameters
|
|
309
|
+
const config = useConfig(parameters)
|
|
310
|
+
return useMutation({
|
|
311
|
+
...mutation,
|
|
312
|
+
async mutationFn(variables) {
|
|
313
|
+
return Actions.reward.setRecipient(config, variables as never)
|
|
314
|
+
},
|
|
315
|
+
mutationKey: ['setRecipient'],
|
|
316
|
+
}) as never
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export declare namespace useSetRecipient {
|
|
320
|
+
type Parameters<
|
|
321
|
+
config extends Config = Config,
|
|
322
|
+
context = unknown,
|
|
323
|
+
> = ConfigParameter<config> & {
|
|
324
|
+
mutation?:
|
|
325
|
+
| UseMutationParameters<
|
|
326
|
+
Actions.reward.setRecipient.ReturnValue,
|
|
327
|
+
Actions.reward.setRecipient.ErrorType,
|
|
328
|
+
Actions.reward.setRecipient.Parameters<config>,
|
|
329
|
+
context
|
|
330
|
+
>
|
|
331
|
+
| undefined
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
type ReturnType<
|
|
335
|
+
config extends Config = Config,
|
|
336
|
+
context = unknown,
|
|
337
|
+
> = UseMutationResult<
|
|
338
|
+
Actions.reward.setRecipient.ReturnValue,
|
|
339
|
+
Actions.reward.setRecipient.ErrorType,
|
|
340
|
+
Actions.reward.setRecipient.Parameters<config>,
|
|
341
|
+
context
|
|
342
|
+
>
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Hook for setting the reward recipient and waiting for confirmation.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
351
|
+
*
|
|
352
|
+
* function App() {
|
|
353
|
+
* const { mutate: setRecipientSync } = Hooks.reward.useSetRecipientSync()
|
|
354
|
+
*
|
|
355
|
+
* return (
|
|
356
|
+
* <button onClick={() => setRecipientSync({
|
|
357
|
+
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
358
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
359
|
+
* })}>
|
|
360
|
+
* Set Recipient
|
|
361
|
+
* </button>
|
|
362
|
+
* )
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @param parameters - Parameters.
|
|
367
|
+
* @returns Mutation result.
|
|
368
|
+
*/
|
|
369
|
+
export function useSetRecipientSync<
|
|
370
|
+
config extends Config = ResolvedRegister['config'],
|
|
371
|
+
context = unknown,
|
|
372
|
+
>(
|
|
373
|
+
parameters: useSetRecipientSync.Parameters<config, context> = {},
|
|
374
|
+
): useSetRecipientSync.ReturnType<config, context> {
|
|
375
|
+
const { mutation } = parameters
|
|
376
|
+
const config = useConfig(parameters)
|
|
377
|
+
return useMutation({
|
|
378
|
+
...mutation,
|
|
379
|
+
async mutationFn(variables) {
|
|
380
|
+
return Actions.reward.setRecipientSync(config, variables as never)
|
|
381
|
+
},
|
|
382
|
+
mutationKey: ['setRecipientSync'],
|
|
383
|
+
}) as never
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export declare namespace useSetRecipientSync {
|
|
387
|
+
type Parameters<
|
|
388
|
+
config extends Config = Config,
|
|
389
|
+
context = unknown,
|
|
390
|
+
> = ConfigParameter<config> & {
|
|
391
|
+
mutation?:
|
|
392
|
+
| UseMutationParameters<
|
|
393
|
+
Actions.reward.setRecipientSync.ReturnValue,
|
|
394
|
+
Actions.reward.setRecipientSync.ErrorType,
|
|
395
|
+
Actions.reward.setRecipientSync.Parameters<config>,
|
|
396
|
+
context
|
|
397
|
+
>
|
|
398
|
+
| undefined
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
type ReturnType<
|
|
402
|
+
config extends Config = Config,
|
|
403
|
+
context = unknown,
|
|
404
|
+
> = UseMutationResult<
|
|
405
|
+
Actions.reward.setRecipientSync.ReturnValue,
|
|
406
|
+
Actions.reward.setRecipientSync.ErrorType,
|
|
407
|
+
Actions.reward.setRecipientSync.Parameters<config>,
|
|
408
|
+
context
|
|
409
|
+
>
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Hook for distributing rewards.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```tsx
|
|
417
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
418
|
+
*
|
|
419
|
+
* function App() {
|
|
420
|
+
* const { mutate: distribute } = Hooks.reward.useDistribute()
|
|
421
|
+
*
|
|
422
|
+
* return (
|
|
423
|
+
* <button onClick={() => distribute({
|
|
424
|
+
* amount: 100000000000000000000n,
|
|
425
|
+
* seconds: 86400,
|
|
426
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
427
|
+
* })}>
|
|
428
|
+
* Start Reward
|
|
429
|
+
* </button>
|
|
430
|
+
* )
|
|
431
|
+
* }
|
|
432
|
+
* ```
|
|
433
|
+
*
|
|
434
|
+
* @param parameters - Parameters.
|
|
435
|
+
* @returns Mutation result.
|
|
436
|
+
*/
|
|
437
|
+
export function useDistribute<
|
|
438
|
+
config extends Config = ResolvedRegister['config'],
|
|
439
|
+
context = unknown,
|
|
440
|
+
>(
|
|
441
|
+
parameters: useDistribute.Parameters<config, context> = {},
|
|
442
|
+
): useDistribute.ReturnType<config, context> {
|
|
443
|
+
const { mutation } = parameters
|
|
444
|
+
const config = useConfig(parameters)
|
|
445
|
+
return useMutation({
|
|
446
|
+
...mutation,
|
|
447
|
+
async mutationFn(variables) {
|
|
448
|
+
return Actions.reward.distribute(config, variables as never)
|
|
449
|
+
},
|
|
450
|
+
mutationKey: ['distribute'],
|
|
451
|
+
}) as never
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export declare namespace useDistribute {
|
|
455
|
+
type Parameters<
|
|
456
|
+
config extends Config = Config,
|
|
457
|
+
context = unknown,
|
|
458
|
+
> = ConfigParameter<config> & {
|
|
459
|
+
mutation?:
|
|
460
|
+
| UseMutationParameters<
|
|
461
|
+
Actions.reward.distribute.ReturnValue,
|
|
462
|
+
Actions.reward.distribute.ErrorType,
|
|
463
|
+
Actions.reward.distribute.Parameters<config>,
|
|
464
|
+
context
|
|
465
|
+
>
|
|
466
|
+
| undefined
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
type ReturnType<
|
|
470
|
+
config extends Config = Config,
|
|
471
|
+
context = unknown,
|
|
472
|
+
> = UseMutationResult<
|
|
473
|
+
Actions.reward.distribute.ReturnValue,
|
|
474
|
+
Actions.reward.distribute.ErrorType,
|
|
475
|
+
Actions.reward.distribute.Parameters<config>,
|
|
476
|
+
context
|
|
477
|
+
>
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Hook for distributing rewards and waiting for confirmation.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```tsx
|
|
485
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
486
|
+
*
|
|
487
|
+
* function App() {
|
|
488
|
+
* const { mutate: distributeSync } = Hooks.reward.useDistributeSync()
|
|
489
|
+
*
|
|
490
|
+
* return (
|
|
491
|
+
* <button onClick={() => distributeSync({
|
|
492
|
+
* amount: 100000000000000000000n,
|
|
493
|
+
* seconds: 86400,
|
|
494
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
495
|
+
* })}>
|
|
496
|
+
* Start Reward
|
|
497
|
+
* </button>
|
|
498
|
+
* )
|
|
499
|
+
* }
|
|
500
|
+
* ```
|
|
501
|
+
*
|
|
502
|
+
* @param parameters - Parameters.
|
|
503
|
+
* @returns Mutation result.
|
|
504
|
+
*/
|
|
505
|
+
export function useDistributeSync<
|
|
506
|
+
config extends Config = ResolvedRegister['config'],
|
|
507
|
+
context = unknown,
|
|
508
|
+
>(
|
|
509
|
+
parameters: useDistributeSync.Parameters<config, context> = {},
|
|
510
|
+
): useDistributeSync.ReturnType<config, context> {
|
|
511
|
+
const { mutation } = parameters
|
|
512
|
+
const config = useConfig(parameters)
|
|
513
|
+
return useMutation({
|
|
514
|
+
...mutation,
|
|
515
|
+
async mutationFn(variables) {
|
|
516
|
+
return Actions.reward.distributeSync(config, variables as never)
|
|
517
|
+
},
|
|
518
|
+
mutationKey: ['distributeSync'],
|
|
519
|
+
}) as never
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export declare namespace useDistributeSync {
|
|
523
|
+
type Parameters<
|
|
524
|
+
config extends Config = Config,
|
|
525
|
+
context = unknown,
|
|
526
|
+
> = ConfigParameter<config> & {
|
|
527
|
+
mutation?:
|
|
528
|
+
| UseMutationParameters<
|
|
529
|
+
Actions.reward.distributeSync.ReturnValue,
|
|
530
|
+
Actions.reward.distributeSync.ErrorType,
|
|
531
|
+
Actions.reward.distributeSync.Parameters<config>,
|
|
532
|
+
context
|
|
533
|
+
>
|
|
534
|
+
| undefined
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
type ReturnType<
|
|
538
|
+
config extends Config = Config,
|
|
539
|
+
context = unknown,
|
|
540
|
+
> = UseMutationResult<
|
|
541
|
+
Actions.reward.distributeSync.ReturnValue,
|
|
542
|
+
Actions.reward.distributeSync.ErrorType,
|
|
543
|
+
Actions.reward.distributeSync.Parameters<config>,
|
|
544
|
+
context
|
|
545
|
+
>
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Hook for watching reward distributed events.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```tsx
|
|
553
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
554
|
+
*
|
|
555
|
+
* function App() {
|
|
556
|
+
* Hooks.reward.useWatchRewardDistributed({
|
|
557
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
558
|
+
* onRewardDistributed(args) {
|
|
559
|
+
* console.log('Reward distributed:', args)
|
|
560
|
+
* },
|
|
561
|
+
* })
|
|
562
|
+
*
|
|
563
|
+
* return <div>Watching for reward distributed events...</div>
|
|
564
|
+
* }
|
|
565
|
+
* ```
|
|
566
|
+
*
|
|
567
|
+
* @param parameters - Parameters.
|
|
568
|
+
*/
|
|
569
|
+
export function useWatchRewardDistributed<
|
|
570
|
+
config extends Config = ResolvedRegister['config'],
|
|
571
|
+
>(parameters: useWatchRewardDistributed.Parameters<config> = {}) {
|
|
572
|
+
const { enabled = true, onRewardDistributed, token, ...rest } = parameters
|
|
573
|
+
|
|
574
|
+
const config = useConfig({ config: parameters.config })
|
|
575
|
+
const configChainId = useChainId({ config })
|
|
576
|
+
const chainId = parameters.chainId ?? configChainId
|
|
577
|
+
|
|
578
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
if (!enabled) return
|
|
581
|
+
if (!onRewardDistributed) return
|
|
582
|
+
if (!token) return
|
|
583
|
+
return Actions.reward.watchRewardDistributed(config, {
|
|
584
|
+
...rest,
|
|
585
|
+
chainId,
|
|
586
|
+
onRewardDistributed,
|
|
587
|
+
token,
|
|
588
|
+
})
|
|
589
|
+
}, [
|
|
590
|
+
config,
|
|
591
|
+
enabled,
|
|
592
|
+
chainId,
|
|
593
|
+
token,
|
|
594
|
+
onRewardDistributed,
|
|
595
|
+
rest.fromBlock,
|
|
596
|
+
rest.onError,
|
|
597
|
+
rest.poll,
|
|
598
|
+
rest.pollingInterval,
|
|
599
|
+
])
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export declare namespace useWatchRewardDistributed {
|
|
603
|
+
type Parameters<config extends Config = Config> = UnionCompute<
|
|
604
|
+
ExactPartial<Actions.reward.watchRewardDistributed.Parameters<config>> &
|
|
605
|
+
ConfigParameter<config> & { enabled?: boolean | undefined }
|
|
606
|
+
>
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Hook for watching reward recipient set events.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```tsx
|
|
614
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
615
|
+
*
|
|
616
|
+
* function App() {
|
|
617
|
+
* Hooks.reward.useWatchRewardRecipientSet({
|
|
618
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
619
|
+
* onRewardRecipientSet(args) {
|
|
620
|
+
* console.log('Reward recipient set:', args)
|
|
621
|
+
* },
|
|
622
|
+
* })
|
|
623
|
+
*
|
|
624
|
+
* return <div>Watching for reward recipient set events...</div>
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
627
|
+
*
|
|
628
|
+
* @param parameters - Parameters.
|
|
629
|
+
*/
|
|
630
|
+
export function useWatchRewardRecipientSet<
|
|
631
|
+
config extends Config = ResolvedRegister['config'],
|
|
632
|
+
>(parameters: useWatchRewardRecipientSet.Parameters<config> = {}) {
|
|
633
|
+
const { enabled = true, onRewardRecipientSet, token, ...rest } = parameters
|
|
634
|
+
|
|
635
|
+
const config = useConfig({ config: parameters.config })
|
|
636
|
+
const configChainId = useChainId({ config })
|
|
637
|
+
const chainId = parameters.chainId ?? configChainId
|
|
638
|
+
|
|
639
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
640
|
+
useEffect(() => {
|
|
641
|
+
if (!enabled) return
|
|
642
|
+
if (!onRewardRecipientSet) return
|
|
643
|
+
if (!token) return
|
|
644
|
+
return Actions.reward.watchRewardRecipientSet(config, {
|
|
645
|
+
...rest,
|
|
646
|
+
chainId,
|
|
647
|
+
onRewardRecipientSet,
|
|
648
|
+
token,
|
|
649
|
+
})
|
|
650
|
+
}, [
|
|
651
|
+
config,
|
|
652
|
+
enabled,
|
|
653
|
+
chainId,
|
|
654
|
+
token,
|
|
655
|
+
onRewardRecipientSet,
|
|
656
|
+
rest.fromBlock,
|
|
657
|
+
rest.onError,
|
|
658
|
+
rest.poll,
|
|
659
|
+
rest.pollingInterval,
|
|
660
|
+
])
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export declare namespace useWatchRewardRecipientSet {
|
|
664
|
+
type Parameters<config extends Config = Config> = UnionCompute<
|
|
665
|
+
ExactPartial<Actions.reward.watchRewardRecipientSet.Parameters<config>> &
|
|
666
|
+
ConfigParameter<config> & { enabled?: boolean | undefined }
|
|
667
|
+
>
|
|
668
|
+
}
|