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,545 @@
|
|
|
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 creating a new policy.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
12
|
+
*
|
|
13
|
+
* function App() {
|
|
14
|
+
* const { mutate, isPending } = Hooks.policy.useCreate()
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <button
|
|
18
|
+
* onClick={() => mutate({ type: 'whitelist' })}
|
|
19
|
+
* disabled={isPending}
|
|
20
|
+
* >
|
|
21
|
+
* Create Policy
|
|
22
|
+
* </button>
|
|
23
|
+
* )
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param parameters - Parameters.
|
|
28
|
+
* @returns Mutation result.
|
|
29
|
+
*/
|
|
30
|
+
export function useCreate(parameters = {}) {
|
|
31
|
+
const { mutation } = parameters;
|
|
32
|
+
const config = useConfig(parameters);
|
|
33
|
+
return useMutation({
|
|
34
|
+
...mutation,
|
|
35
|
+
async mutationFn(variables) {
|
|
36
|
+
return Actions.policy.create(config, variables);
|
|
37
|
+
},
|
|
38
|
+
mutationKey: ['create'],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook for creating a new policy.
|
|
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.policy.useCreateSync()
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <button
|
|
56
|
+
* onClick={() => mutate({ type: 'whitelist' })}
|
|
57
|
+
* disabled={isPending}
|
|
58
|
+
* >
|
|
59
|
+
* Create Policy
|
|
60
|
+
* </button>
|
|
61
|
+
* )
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param parameters - Parameters.
|
|
66
|
+
* @returns Mutation result.
|
|
67
|
+
*/
|
|
68
|
+
export function useCreateSync(parameters = {}) {
|
|
69
|
+
const { mutation } = parameters;
|
|
70
|
+
const config = useConfig(parameters);
|
|
71
|
+
return useMutation({
|
|
72
|
+
...mutation,
|
|
73
|
+
async mutationFn(variables) {
|
|
74
|
+
return Actions.policy.createSync(config, variables);
|
|
75
|
+
},
|
|
76
|
+
mutationKey: ['createSync'],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Hook for setting the admin for a policy.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
85
|
+
*
|
|
86
|
+
* function App() {
|
|
87
|
+
* const { mutate, isPending } = Hooks.policy.useSetAdmin()
|
|
88
|
+
*
|
|
89
|
+
* return (
|
|
90
|
+
* <button
|
|
91
|
+
* onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
|
|
92
|
+
* disabled={isPending}
|
|
93
|
+
* >
|
|
94
|
+
* Set Admin
|
|
95
|
+
* </button>
|
|
96
|
+
* )
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param parameters - Parameters.
|
|
101
|
+
* @returns Mutation result.
|
|
102
|
+
*/
|
|
103
|
+
export function useSetAdmin(parameters = {}) {
|
|
104
|
+
const { mutation } = parameters;
|
|
105
|
+
const config = useConfig(parameters);
|
|
106
|
+
return useMutation({
|
|
107
|
+
...mutation,
|
|
108
|
+
async mutationFn(variables) {
|
|
109
|
+
return Actions.policy.setAdmin(config, variables);
|
|
110
|
+
},
|
|
111
|
+
mutationKey: ['setAdmin'],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Hook for setting the admin for a policy.
|
|
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.policy.useSetAdminSync()
|
|
126
|
+
*
|
|
127
|
+
* return (
|
|
128
|
+
* <button
|
|
129
|
+
* onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
|
|
130
|
+
* disabled={isPending}
|
|
131
|
+
* >
|
|
132
|
+
* Set Admin
|
|
133
|
+
* </button>
|
|
134
|
+
* )
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @param parameters - Parameters.
|
|
139
|
+
* @returns Mutation result.
|
|
140
|
+
*/
|
|
141
|
+
export function useSetAdminSync(parameters = {}) {
|
|
142
|
+
const { mutation } = parameters;
|
|
143
|
+
const config = useConfig(parameters);
|
|
144
|
+
return useMutation({
|
|
145
|
+
...mutation,
|
|
146
|
+
async mutationFn(variables) {
|
|
147
|
+
return Actions.policy.setAdminSync(config, variables);
|
|
148
|
+
},
|
|
149
|
+
mutationKey: ['setAdminSync'],
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Hook for modifying a policy whitelist.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
158
|
+
*
|
|
159
|
+
* function App() {
|
|
160
|
+
* const { mutate, isPending } = Hooks.policy.useModifyWhitelist()
|
|
161
|
+
*
|
|
162
|
+
* return (
|
|
163
|
+
* <button
|
|
164
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
|
|
165
|
+
* disabled={isPending}
|
|
166
|
+
* >
|
|
167
|
+
* Add to Whitelist
|
|
168
|
+
* </button>
|
|
169
|
+
* )
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @param parameters - Parameters.
|
|
174
|
+
* @returns Mutation result.
|
|
175
|
+
*/
|
|
176
|
+
export function useModifyWhitelist(parameters = {}) {
|
|
177
|
+
const { mutation } = parameters;
|
|
178
|
+
const config = useConfig(parameters);
|
|
179
|
+
return useMutation({
|
|
180
|
+
...mutation,
|
|
181
|
+
async mutationFn(variables) {
|
|
182
|
+
return Actions.policy.modifyWhitelist(config, variables);
|
|
183
|
+
},
|
|
184
|
+
mutationKey: ['modifyWhitelist'],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Hook for modifying a policy whitelist.
|
|
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.policy.useModifyWhitelistSync()
|
|
199
|
+
*
|
|
200
|
+
* return (
|
|
201
|
+
* <button
|
|
202
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
|
|
203
|
+
* disabled={isPending}
|
|
204
|
+
* >
|
|
205
|
+
* Add to Whitelist
|
|
206
|
+
* </button>
|
|
207
|
+
* )
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @param parameters - Parameters.
|
|
212
|
+
* @returns Mutation result.
|
|
213
|
+
*/
|
|
214
|
+
export function useModifyWhitelistSync(parameters = {}) {
|
|
215
|
+
const { mutation } = parameters;
|
|
216
|
+
const config = useConfig(parameters);
|
|
217
|
+
return useMutation({
|
|
218
|
+
...mutation,
|
|
219
|
+
async mutationFn(variables) {
|
|
220
|
+
return Actions.policy.modifyWhitelistSync(config, variables);
|
|
221
|
+
},
|
|
222
|
+
mutationKey: ['modifyWhitelistSync'],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Hook for modifying a policy blacklist.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```tsx
|
|
230
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
231
|
+
*
|
|
232
|
+
* function App() {
|
|
233
|
+
* const { mutate, isPending } = Hooks.policy.useModifyBlacklist()
|
|
234
|
+
*
|
|
235
|
+
* return (
|
|
236
|
+
* <button
|
|
237
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
|
|
238
|
+
* disabled={isPending}
|
|
239
|
+
* >
|
|
240
|
+
* Add to Blacklist
|
|
241
|
+
* </button>
|
|
242
|
+
* )
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @param parameters - Parameters.
|
|
247
|
+
* @returns Mutation result.
|
|
248
|
+
*/
|
|
249
|
+
export function useModifyBlacklist(parameters = {}) {
|
|
250
|
+
const { mutation } = parameters;
|
|
251
|
+
const config = useConfig(parameters);
|
|
252
|
+
return useMutation({
|
|
253
|
+
...mutation,
|
|
254
|
+
async mutationFn(variables) {
|
|
255
|
+
return Actions.policy.modifyBlacklist(config, variables);
|
|
256
|
+
},
|
|
257
|
+
mutationKey: ['modifyBlacklist'],
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Hook for modifying a policy blacklist.
|
|
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.policy.useModifyBlacklistSync()
|
|
272
|
+
*
|
|
273
|
+
* return (
|
|
274
|
+
* <button
|
|
275
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
|
|
276
|
+
* disabled={isPending}
|
|
277
|
+
* >
|
|
278
|
+
* Add to Blacklist
|
|
279
|
+
* </button>
|
|
280
|
+
* )
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @param parameters - Parameters.
|
|
285
|
+
* @returns Mutation result.
|
|
286
|
+
*/
|
|
287
|
+
export function useModifyBlacklistSync(parameters = {}) {
|
|
288
|
+
const { mutation } = parameters;
|
|
289
|
+
const config = useConfig(parameters);
|
|
290
|
+
return useMutation({
|
|
291
|
+
...mutation,
|
|
292
|
+
async mutationFn(variables) {
|
|
293
|
+
return Actions.policy.modifyBlacklistSync(config, variables);
|
|
294
|
+
},
|
|
295
|
+
mutationKey: ['modifyBlacklistSync'],
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Hook for getting policy data.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
304
|
+
*
|
|
305
|
+
* function App() {
|
|
306
|
+
* const { data, isLoading } = Hooks.policy.useData({
|
|
307
|
+
* policyId: 2n,
|
|
308
|
+
* })
|
|
309
|
+
*
|
|
310
|
+
* if (isLoading) return <div>Loading...</div>
|
|
311
|
+
* return <div>Admin: {data?.admin}</div>
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @param parameters - Parameters.
|
|
316
|
+
* @returns Query result with policy data.
|
|
317
|
+
*/
|
|
318
|
+
export function useData(parameters = {}) {
|
|
319
|
+
const config = useConfig(parameters);
|
|
320
|
+
const chainId = useChainId({ config });
|
|
321
|
+
const options = Actions.policy.getData.queryOptions(config, {
|
|
322
|
+
...parameters,
|
|
323
|
+
chainId: parameters.chainId ?? chainId,
|
|
324
|
+
});
|
|
325
|
+
return useQuery(options);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Hook for checking if a user is authorized by a policy.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```tsx
|
|
332
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
333
|
+
*
|
|
334
|
+
* function App() {
|
|
335
|
+
* const { data, isLoading } = Hooks.policy.useIsAuthorized({
|
|
336
|
+
* policyId: 2n,
|
|
337
|
+
* user: '0x...',
|
|
338
|
+
* })
|
|
339
|
+
*
|
|
340
|
+
* if (isLoading) return <div>Loading...</div>
|
|
341
|
+
* return <div>Authorized: {data ? 'Yes' : 'No'}</div>
|
|
342
|
+
* }
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @param parameters - Parameters.
|
|
346
|
+
* @returns Query result with authorization status.
|
|
347
|
+
*/
|
|
348
|
+
export function useIsAuthorized(parameters = {}) {
|
|
349
|
+
const config = useConfig(parameters);
|
|
350
|
+
const chainId = useChainId({ config });
|
|
351
|
+
const options = Actions.policy.isAuthorized.queryOptions(config, {
|
|
352
|
+
...parameters,
|
|
353
|
+
chainId: parameters.chainId ?? chainId,
|
|
354
|
+
});
|
|
355
|
+
return useQuery(options);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Hook for watching policy creation events.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```tsx
|
|
362
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
363
|
+
*
|
|
364
|
+
* function App() {
|
|
365
|
+
* Hooks.policy.useWatchCreate({
|
|
366
|
+
* onPolicyCreated(args) {
|
|
367
|
+
* console.log('Policy created:', args)
|
|
368
|
+
* },
|
|
369
|
+
* })
|
|
370
|
+
*
|
|
371
|
+
* return <div>Watching for policy creation...</div>
|
|
372
|
+
* }
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @param parameters - Parameters.
|
|
376
|
+
*/
|
|
377
|
+
export function useWatchCreate(parameters = {}) {
|
|
378
|
+
const { enabled = true, onPolicyCreated, ...rest } = parameters;
|
|
379
|
+
const config = useConfig({ config: parameters.config });
|
|
380
|
+
const configChainId = useChainId({ config });
|
|
381
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
382
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
if (!enabled)
|
|
385
|
+
return;
|
|
386
|
+
if (!onPolicyCreated)
|
|
387
|
+
return;
|
|
388
|
+
return Actions.policy.watchCreate(config, {
|
|
389
|
+
...rest,
|
|
390
|
+
chainId,
|
|
391
|
+
onPolicyCreated,
|
|
392
|
+
});
|
|
393
|
+
}, [
|
|
394
|
+
config,
|
|
395
|
+
enabled,
|
|
396
|
+
chainId,
|
|
397
|
+
onPolicyCreated,
|
|
398
|
+
rest.fromBlock,
|
|
399
|
+
rest.onError,
|
|
400
|
+
rest.poll,
|
|
401
|
+
rest.pollingInterval,
|
|
402
|
+
]);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Hook for watching policy admin update events.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```tsx
|
|
409
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
410
|
+
*
|
|
411
|
+
* function App() {
|
|
412
|
+
* Hooks.policy.useWatchAdminUpdated({
|
|
413
|
+
* onAdminUpdated(args) {
|
|
414
|
+
* console.log('Policy admin updated:', args)
|
|
415
|
+
* },
|
|
416
|
+
* })
|
|
417
|
+
*
|
|
418
|
+
* return <div>Watching for admin updates...</div>
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
421
|
+
*
|
|
422
|
+
* @param parameters - Parameters.
|
|
423
|
+
*/
|
|
424
|
+
export function useWatchAdminUpdated(parameters = {}) {
|
|
425
|
+
const { enabled = true, onAdminUpdated, ...rest } = parameters;
|
|
426
|
+
const config = useConfig({ config: parameters.config });
|
|
427
|
+
const configChainId = useChainId({ config });
|
|
428
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
429
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
430
|
+
useEffect(() => {
|
|
431
|
+
if (!enabled)
|
|
432
|
+
return;
|
|
433
|
+
if (!onAdminUpdated)
|
|
434
|
+
return;
|
|
435
|
+
return Actions.policy.watchAdminUpdated(config, {
|
|
436
|
+
...rest,
|
|
437
|
+
chainId,
|
|
438
|
+
onAdminUpdated,
|
|
439
|
+
});
|
|
440
|
+
}, [
|
|
441
|
+
config,
|
|
442
|
+
enabled,
|
|
443
|
+
chainId,
|
|
444
|
+
onAdminUpdated,
|
|
445
|
+
rest.fromBlock,
|
|
446
|
+
rest.onError,
|
|
447
|
+
rest.poll,
|
|
448
|
+
rest.pollingInterval,
|
|
449
|
+
]);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Hook for watching whitelist update events.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```tsx
|
|
456
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
457
|
+
*
|
|
458
|
+
* function App() {
|
|
459
|
+
* Hooks.policy.useWatchWhitelistUpdated({
|
|
460
|
+
* onWhitelistUpdated(args) {
|
|
461
|
+
* console.log('Whitelist updated:', args)
|
|
462
|
+
* },
|
|
463
|
+
* })
|
|
464
|
+
*
|
|
465
|
+
* return <div>Watching for whitelist updates...</div>
|
|
466
|
+
* }
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* @param parameters - Parameters.
|
|
470
|
+
*/
|
|
471
|
+
export function useWatchWhitelistUpdated(parameters = {}) {
|
|
472
|
+
const { enabled = true, onWhitelistUpdated, ...rest } = parameters;
|
|
473
|
+
const config = useConfig({ config: parameters.config });
|
|
474
|
+
const configChainId = useChainId({ config });
|
|
475
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
476
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
477
|
+
useEffect(() => {
|
|
478
|
+
if (!enabled)
|
|
479
|
+
return;
|
|
480
|
+
if (!onWhitelistUpdated)
|
|
481
|
+
return;
|
|
482
|
+
return Actions.policy.watchWhitelistUpdated(config, {
|
|
483
|
+
...rest,
|
|
484
|
+
chainId,
|
|
485
|
+
onWhitelistUpdated,
|
|
486
|
+
});
|
|
487
|
+
}, [
|
|
488
|
+
config,
|
|
489
|
+
enabled,
|
|
490
|
+
chainId,
|
|
491
|
+
onWhitelistUpdated,
|
|
492
|
+
rest.fromBlock,
|
|
493
|
+
rest.onError,
|
|
494
|
+
rest.poll,
|
|
495
|
+
rest.pollingInterval,
|
|
496
|
+
]);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Hook for watching blacklist update events.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```tsx
|
|
503
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
504
|
+
*
|
|
505
|
+
* function App() {
|
|
506
|
+
* Hooks.policy.useWatchBlacklistUpdated({
|
|
507
|
+
* onBlacklistUpdated(args) {
|
|
508
|
+
* console.log('Blacklist updated:', args)
|
|
509
|
+
* },
|
|
510
|
+
* })
|
|
511
|
+
*
|
|
512
|
+
* return <div>Watching for blacklist updates...</div>
|
|
513
|
+
* }
|
|
514
|
+
* ```
|
|
515
|
+
*
|
|
516
|
+
* @param parameters - Parameters.
|
|
517
|
+
*/
|
|
518
|
+
export function useWatchBlacklistUpdated(parameters = {}) {
|
|
519
|
+
const { enabled = true, onBlacklistUpdated, ...rest } = parameters;
|
|
520
|
+
const config = useConfig({ config: parameters.config });
|
|
521
|
+
const configChainId = useChainId({ config });
|
|
522
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
523
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
524
|
+
useEffect(() => {
|
|
525
|
+
if (!enabled)
|
|
526
|
+
return;
|
|
527
|
+
if (!onBlacklistUpdated)
|
|
528
|
+
return;
|
|
529
|
+
return Actions.policy.watchBlacklistUpdated(config, {
|
|
530
|
+
...rest,
|
|
531
|
+
chainId,
|
|
532
|
+
onBlacklistUpdated,
|
|
533
|
+
});
|
|
534
|
+
}, [
|
|
535
|
+
config,
|
|
536
|
+
enabled,
|
|
537
|
+
chainId,
|
|
538
|
+
onBlacklistUpdated,
|
|
539
|
+
rest.fromBlock,
|
|
540
|
+
rest.onError,
|
|
541
|
+
rest.poll,
|
|
542
|
+
rest.pollingInterval,
|
|
543
|
+
]);
|
|
544
|
+
}
|
|
545
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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