tempo.ts 0.5.1 → 0.5.2
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/viem/Actions/policy.d.ts +9 -1
- package/dist/viem/Actions/policy.d.ts.map +1 -1
- package/dist/viem/Actions/policy.js.map +1 -1
- package/dist/viem/Transport.d.ts +8 -0
- package/dist/viem/Transport.d.ts.map +1 -1
- package/dist/viem/Transport.js +87 -1
- package/dist/viem/Transport.js.map +1 -1
- package/dist/wagmi/Actions/index.d.ts +1 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -1
- package/dist/wagmi/Actions/index.js +1 -0
- package/dist/wagmi/Actions/index.js.map +1 -1
- package/dist/wagmi/Actions/policy.d.ts +481 -0
- package/dist/wagmi/Actions/policy.d.ts.map +1 -0
- package/dist/wagmi/Actions/policy.js +530 -0
- package/dist/wagmi/Actions/policy.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +1 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +3 -85
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/index.d.ts +1 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -1
- package/dist/wagmi/Hooks/index.js +1 -0
- package/dist/wagmi/Hooks/index.js.map +1 -1
- package/dist/wagmi/Hooks/policy.d.ts +424 -0
- package/dist/wagmi/Hooks/policy.d.ts.map +1 -0
- package/dist/wagmi/Hooks/policy.js +510 -0
- package/dist/wagmi/Hooks/policy.js.map +1 -0
- package/package.json +2 -2
- package/src/viem/Actions/policy.ts +25 -0
- package/src/viem/Transport.ts +107 -1
- package/src/wagmi/Actions/index.ts +1 -0
- package/src/wagmi/Actions/policy.test.ts +461 -0
- package/src/wagmi/Actions/policy.ts +819 -0
- package/src/wagmi/Connector.ts +4 -112
- package/src/wagmi/Hooks/index.ts +1 -0
- package/src/wagmi/Hooks/policy.test.ts +665 -0
- package/src/wagmi/Hooks/policy.ts +875 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useChainId, useConfig } from 'wagmi';
|
|
3
|
+
import { useMutation, useQuery, } from 'wagmi/query';
|
|
4
|
+
import * as Actions from '../Actions/policy.js';
|
|
5
|
+
/**
|
|
6
|
+
* Hook for creating a new policy.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
11
|
+
*
|
|
12
|
+
* function App() {
|
|
13
|
+
* const { mutate, isPending } = Hooks.policy.useCreate()
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <button
|
|
17
|
+
* onClick={() => mutate({ type: 'whitelist' })}
|
|
18
|
+
* disabled={isPending}
|
|
19
|
+
* >
|
|
20
|
+
* Create Policy
|
|
21
|
+
* </button>
|
|
22
|
+
* )
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param parameters - Parameters.
|
|
27
|
+
* @returns Mutation result.
|
|
28
|
+
*/
|
|
29
|
+
export function useCreate(parameters = {}) {
|
|
30
|
+
const { mutation } = parameters;
|
|
31
|
+
const config = useConfig(parameters);
|
|
32
|
+
return useMutation({
|
|
33
|
+
...mutation,
|
|
34
|
+
async mutationFn(variables) {
|
|
35
|
+
return Actions.create(config, variables);
|
|
36
|
+
},
|
|
37
|
+
mutationKey: ['create'],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hook for creating a new policy.
|
|
42
|
+
*
|
|
43
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
44
|
+
* to be included on a block before returning a response.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
49
|
+
*
|
|
50
|
+
* function App() {
|
|
51
|
+
* const { mutate, isPending } = Hooks.policy.useCreateSync()
|
|
52
|
+
*
|
|
53
|
+
* return (
|
|
54
|
+
* <button
|
|
55
|
+
* onClick={() => mutate({ type: 'whitelist' })}
|
|
56
|
+
* disabled={isPending}
|
|
57
|
+
* >
|
|
58
|
+
* Create Policy
|
|
59
|
+
* </button>
|
|
60
|
+
* )
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param parameters - Parameters.
|
|
65
|
+
* @returns Mutation result.
|
|
66
|
+
*/
|
|
67
|
+
export function useCreateSync(parameters = {}) {
|
|
68
|
+
const { mutation } = parameters;
|
|
69
|
+
const config = useConfig(parameters);
|
|
70
|
+
return useMutation({
|
|
71
|
+
...mutation,
|
|
72
|
+
async mutationFn(variables) {
|
|
73
|
+
return Actions.createSync(config, variables);
|
|
74
|
+
},
|
|
75
|
+
mutationKey: ['createSync'],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Hook for setting the admin for a policy.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
84
|
+
*
|
|
85
|
+
* function App() {
|
|
86
|
+
* const { mutate, isPending } = Hooks.policy.useSetAdmin()
|
|
87
|
+
*
|
|
88
|
+
* return (
|
|
89
|
+
* <button
|
|
90
|
+
* onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
|
|
91
|
+
* disabled={isPending}
|
|
92
|
+
* >
|
|
93
|
+
* Set Admin
|
|
94
|
+
* </button>
|
|
95
|
+
* )
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param parameters - Parameters.
|
|
100
|
+
* @returns Mutation result.
|
|
101
|
+
*/
|
|
102
|
+
export function useSetAdmin(parameters = {}) {
|
|
103
|
+
const { mutation } = parameters;
|
|
104
|
+
const config = useConfig(parameters);
|
|
105
|
+
return useMutation({
|
|
106
|
+
...mutation,
|
|
107
|
+
async mutationFn(variables) {
|
|
108
|
+
return Actions.setAdmin(config, variables);
|
|
109
|
+
},
|
|
110
|
+
mutationKey: ['setAdmin'],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Hook for setting the admin for a policy.
|
|
115
|
+
*
|
|
116
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
117
|
+
* to be included on a block before returning a response.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
122
|
+
*
|
|
123
|
+
* function App() {
|
|
124
|
+
* const { mutate, isPending } = Hooks.policy.useSetAdminSync()
|
|
125
|
+
*
|
|
126
|
+
* return (
|
|
127
|
+
* <button
|
|
128
|
+
* onClick={() => mutate({ policyId: 2n, admin: '0x...' })}
|
|
129
|
+
* disabled={isPending}
|
|
130
|
+
* >
|
|
131
|
+
* Set Admin
|
|
132
|
+
* </button>
|
|
133
|
+
* )
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @param parameters - Parameters.
|
|
138
|
+
* @returns Mutation result.
|
|
139
|
+
*/
|
|
140
|
+
export function useSetAdminSync(parameters = {}) {
|
|
141
|
+
const { mutation } = parameters;
|
|
142
|
+
const config = useConfig(parameters);
|
|
143
|
+
return useMutation({
|
|
144
|
+
...mutation,
|
|
145
|
+
async mutationFn(variables) {
|
|
146
|
+
return Actions.setAdminSync(config, variables);
|
|
147
|
+
},
|
|
148
|
+
mutationKey: ['setAdminSync'],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Hook for modifying a policy whitelist.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
157
|
+
*
|
|
158
|
+
* function App() {
|
|
159
|
+
* const { mutate, isPending } = Hooks.policy.useModifyWhitelist()
|
|
160
|
+
*
|
|
161
|
+
* return (
|
|
162
|
+
* <button
|
|
163
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
|
|
164
|
+
* disabled={isPending}
|
|
165
|
+
* >
|
|
166
|
+
* Add to Whitelist
|
|
167
|
+
* </button>
|
|
168
|
+
* )
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @param parameters - Parameters.
|
|
173
|
+
* @returns Mutation result.
|
|
174
|
+
*/
|
|
175
|
+
export function useModifyWhitelist(parameters = {}) {
|
|
176
|
+
const { mutation } = parameters;
|
|
177
|
+
const config = useConfig(parameters);
|
|
178
|
+
return useMutation({
|
|
179
|
+
...mutation,
|
|
180
|
+
async mutationFn(variables) {
|
|
181
|
+
return Actions.modifyWhitelist(config, variables);
|
|
182
|
+
},
|
|
183
|
+
mutationKey: ['modifyWhitelist'],
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Hook for modifying a policy whitelist.
|
|
188
|
+
*
|
|
189
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
190
|
+
* to be included on a block before returning a response.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```tsx
|
|
194
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
195
|
+
*
|
|
196
|
+
* function App() {
|
|
197
|
+
* const { mutate, isPending } = Hooks.policy.useModifyWhitelistSync()
|
|
198
|
+
*
|
|
199
|
+
* return (
|
|
200
|
+
* <button
|
|
201
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', allowed: true })}
|
|
202
|
+
* disabled={isPending}
|
|
203
|
+
* >
|
|
204
|
+
* Add to Whitelist
|
|
205
|
+
* </button>
|
|
206
|
+
* )
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @param parameters - Parameters.
|
|
211
|
+
* @returns Mutation result.
|
|
212
|
+
*/
|
|
213
|
+
export function useModifyWhitelistSync(parameters = {}) {
|
|
214
|
+
const { mutation } = parameters;
|
|
215
|
+
const config = useConfig(parameters);
|
|
216
|
+
return useMutation({
|
|
217
|
+
...mutation,
|
|
218
|
+
async mutationFn(variables) {
|
|
219
|
+
return Actions.modifyWhitelistSync(config, variables);
|
|
220
|
+
},
|
|
221
|
+
mutationKey: ['modifyWhitelistSync'],
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Hook for modifying a policy blacklist.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```tsx
|
|
229
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
230
|
+
*
|
|
231
|
+
* function App() {
|
|
232
|
+
* const { mutate, isPending } = Hooks.policy.useModifyBlacklist()
|
|
233
|
+
*
|
|
234
|
+
* return (
|
|
235
|
+
* <button
|
|
236
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
|
|
237
|
+
* disabled={isPending}
|
|
238
|
+
* >
|
|
239
|
+
* Add to Blacklist
|
|
240
|
+
* </button>
|
|
241
|
+
* )
|
|
242
|
+
* }
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @param parameters - Parameters.
|
|
246
|
+
* @returns Mutation result.
|
|
247
|
+
*/
|
|
248
|
+
export function useModifyBlacklist(parameters = {}) {
|
|
249
|
+
const { mutation } = parameters;
|
|
250
|
+
const config = useConfig(parameters);
|
|
251
|
+
return useMutation({
|
|
252
|
+
...mutation,
|
|
253
|
+
async mutationFn(variables) {
|
|
254
|
+
return Actions.modifyBlacklist(config, variables);
|
|
255
|
+
},
|
|
256
|
+
mutationKey: ['modifyBlacklist'],
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Hook for modifying a policy blacklist.
|
|
261
|
+
*
|
|
262
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
263
|
+
* to be included on a block before returning a response.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```tsx
|
|
267
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
268
|
+
*
|
|
269
|
+
* function App() {
|
|
270
|
+
* const { mutate, isPending } = Hooks.policy.useModifyBlacklistSync()
|
|
271
|
+
*
|
|
272
|
+
* return (
|
|
273
|
+
* <button
|
|
274
|
+
* onClick={() => mutate({ policyId: 2n, address: '0x...', restricted: true })}
|
|
275
|
+
* disabled={isPending}
|
|
276
|
+
* >
|
|
277
|
+
* Add to Blacklist
|
|
278
|
+
* </button>
|
|
279
|
+
* )
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @param parameters - Parameters.
|
|
284
|
+
* @returns Mutation result.
|
|
285
|
+
*/
|
|
286
|
+
export function useModifyBlacklistSync(parameters = {}) {
|
|
287
|
+
const { mutation } = parameters;
|
|
288
|
+
const config = useConfig(parameters);
|
|
289
|
+
return useMutation({
|
|
290
|
+
...mutation,
|
|
291
|
+
async mutationFn(variables) {
|
|
292
|
+
return Actions.modifyBlacklistSync(config, variables);
|
|
293
|
+
},
|
|
294
|
+
mutationKey: ['modifyBlacklistSync'],
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Hook for getting policy data.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```tsx
|
|
302
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
303
|
+
*
|
|
304
|
+
* function App() {
|
|
305
|
+
* const { data, isLoading } = Hooks.policy.useGetData({
|
|
306
|
+
* policyId: 2n,
|
|
307
|
+
* })
|
|
308
|
+
*
|
|
309
|
+
* if (isLoading) return <div>Loading...</div>
|
|
310
|
+
* return <div>Admin: {data?.admin}</div>
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @param parameters - Parameters.
|
|
315
|
+
* @returns Query result with policy data.
|
|
316
|
+
*/
|
|
317
|
+
export function useGetData(parameters = {}) {
|
|
318
|
+
const { policyId, query = {} } = parameters;
|
|
319
|
+
const config = useConfig(parameters);
|
|
320
|
+
const chainId = useChainId({ config });
|
|
321
|
+
const options = Actions.getData.queryOptions(config, {
|
|
322
|
+
...parameters,
|
|
323
|
+
chainId: parameters.chainId ?? chainId,
|
|
324
|
+
query: undefined,
|
|
325
|
+
});
|
|
326
|
+
const enabled = Boolean(policyId !== undefined && (query.enabled ?? true));
|
|
327
|
+
return useQuery({ ...query, ...options, enabled });
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Hook for checking if a user is authorized by a policy.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```tsx
|
|
334
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
335
|
+
*
|
|
336
|
+
* function App() {
|
|
337
|
+
* const { data, isLoading } = Hooks.policy.useIsAuthorized({
|
|
338
|
+
* policyId: 2n,
|
|
339
|
+
* user: '0x...',
|
|
340
|
+
* })
|
|
341
|
+
*
|
|
342
|
+
* if (isLoading) return <div>Loading...</div>
|
|
343
|
+
* return <div>Authorized: {data ? 'Yes' : 'No'}</div>
|
|
344
|
+
* }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @param parameters - Parameters.
|
|
348
|
+
* @returns Query result with authorization status.
|
|
349
|
+
*/
|
|
350
|
+
export function useIsAuthorized(parameters = {}) {
|
|
351
|
+
const { policyId, user, query = {} } = parameters;
|
|
352
|
+
const config = useConfig(parameters);
|
|
353
|
+
const chainId = useChainId({ config });
|
|
354
|
+
const options = Actions.isAuthorized.queryOptions(config, {
|
|
355
|
+
...parameters,
|
|
356
|
+
chainId: parameters.chainId ?? chainId,
|
|
357
|
+
query: undefined,
|
|
358
|
+
});
|
|
359
|
+
const enabled = Boolean(policyId !== undefined && user && (query.enabled ?? true));
|
|
360
|
+
return useQuery({ ...query, ...options, enabled });
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Hook for watching policy creation events.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
368
|
+
*
|
|
369
|
+
* function App() {
|
|
370
|
+
* Hooks.policy.useWatchCreate({
|
|
371
|
+
* onPolicyCreated(args) {
|
|
372
|
+
* console.log('Policy created:', args)
|
|
373
|
+
* },
|
|
374
|
+
* })
|
|
375
|
+
*
|
|
376
|
+
* return <div>Watching for policy creation...</div>
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @param parameters - Parameters.
|
|
381
|
+
*/
|
|
382
|
+
export function useWatchCreate(parameters = {}) {
|
|
383
|
+
const { enabled = true, onPolicyCreated, ...rest } = parameters;
|
|
384
|
+
const config = useConfig({ config: parameters.config });
|
|
385
|
+
const configChainId = useChainId({ config });
|
|
386
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
if (!enabled)
|
|
389
|
+
return;
|
|
390
|
+
if (!onPolicyCreated)
|
|
391
|
+
return;
|
|
392
|
+
return Actions.watchCreate(config, {
|
|
393
|
+
...rest,
|
|
394
|
+
chainId,
|
|
395
|
+
onPolicyCreated,
|
|
396
|
+
});
|
|
397
|
+
}, [config, enabled, onPolicyCreated, rest, chainId]);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Hook for watching policy admin update events.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
405
|
+
*
|
|
406
|
+
* function App() {
|
|
407
|
+
* Hooks.policy.useWatchAdminUpdated({
|
|
408
|
+
* onAdminUpdated(args) {
|
|
409
|
+
* console.log('Policy admin updated:', args)
|
|
410
|
+
* },
|
|
411
|
+
* })
|
|
412
|
+
*
|
|
413
|
+
* return <div>Watching for admin updates...</div>
|
|
414
|
+
* }
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* @param parameters - Parameters.
|
|
418
|
+
*/
|
|
419
|
+
export function useWatchAdminUpdated(parameters = {}) {
|
|
420
|
+
const { enabled = true, onAdminUpdated, ...rest } = parameters;
|
|
421
|
+
const config = useConfig({ config: parameters.config });
|
|
422
|
+
const configChainId = useChainId({ config });
|
|
423
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
424
|
+
useEffect(() => {
|
|
425
|
+
if (!enabled)
|
|
426
|
+
return;
|
|
427
|
+
if (!onAdminUpdated)
|
|
428
|
+
return;
|
|
429
|
+
return Actions.watchAdminUpdated(config, {
|
|
430
|
+
...rest,
|
|
431
|
+
chainId,
|
|
432
|
+
onAdminUpdated,
|
|
433
|
+
});
|
|
434
|
+
}, [config, enabled, onAdminUpdated, rest, chainId]);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Hook for watching whitelist update events.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```tsx
|
|
441
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
442
|
+
*
|
|
443
|
+
* function App() {
|
|
444
|
+
* Hooks.policy.useWatchWhitelistUpdated({
|
|
445
|
+
* onWhitelistUpdated(args) {
|
|
446
|
+
* console.log('Whitelist updated:', args)
|
|
447
|
+
* },
|
|
448
|
+
* })
|
|
449
|
+
*
|
|
450
|
+
* return <div>Watching for whitelist updates...</div>
|
|
451
|
+
* }
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* @param parameters - Parameters.
|
|
455
|
+
*/
|
|
456
|
+
export function useWatchWhitelistUpdated(parameters = {}) {
|
|
457
|
+
const { enabled = true, onWhitelistUpdated, ...rest } = parameters;
|
|
458
|
+
const config = useConfig({ config: parameters.config });
|
|
459
|
+
const configChainId = useChainId({ config });
|
|
460
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
461
|
+
useEffect(() => {
|
|
462
|
+
if (!enabled)
|
|
463
|
+
return;
|
|
464
|
+
if (!onWhitelistUpdated)
|
|
465
|
+
return;
|
|
466
|
+
return Actions.watchWhitelistUpdated(config, {
|
|
467
|
+
...rest,
|
|
468
|
+
chainId,
|
|
469
|
+
onWhitelistUpdated,
|
|
470
|
+
});
|
|
471
|
+
}, [config, enabled, onWhitelistUpdated, rest, chainId]);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Hook for watching blacklist update events.
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```tsx
|
|
478
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
479
|
+
*
|
|
480
|
+
* function App() {
|
|
481
|
+
* Hooks.policy.useWatchBlacklistUpdated({
|
|
482
|
+
* onBlacklistUpdated(args) {
|
|
483
|
+
* console.log('Blacklist updated:', args)
|
|
484
|
+
* },
|
|
485
|
+
* })
|
|
486
|
+
*
|
|
487
|
+
* return <div>Watching for blacklist updates...</div>
|
|
488
|
+
* }
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* @param parameters - Parameters.
|
|
492
|
+
*/
|
|
493
|
+
export function useWatchBlacklistUpdated(parameters = {}) {
|
|
494
|
+
const { enabled = true, onBlacklistUpdated, ...rest } = parameters;
|
|
495
|
+
const config = useConfig({ config: parameters.config });
|
|
496
|
+
const configChainId = useChainId({ config });
|
|
497
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
if (!enabled)
|
|
500
|
+
return;
|
|
501
|
+
if (!onBlacklistUpdated)
|
|
502
|
+
return;
|
|
503
|
+
return Actions.watchBlacklistUpdated(config, {
|
|
504
|
+
...rest,
|
|
505
|
+
chainId,
|
|
506
|
+
onBlacklistUpdated,
|
|
507
|
+
});
|
|
508
|
+
}, [config, enabled, onBlacklistUpdated, rest, chainId]);
|
|
509
|
+
}
|
|
510
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/wagmi/Hooks/policy.ts"],"names":[],"mappings":"AAGA,OAAO,E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GAAG,UAAU,CAAC,OAAO,IAAI,aAAa,CAAA;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAM;QACpB,IAAI,CAAC,kBAAkB;YAAE,OAAM;QAC/B,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,EAAE;YAC3C,GAAG,IAAI;YACP,OAAO;YACP,kBAAkB;SACnB,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempo.ts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"ox": "~0.9.9"
|
|
7
7
|
},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@tanstack/react-query": ">=5.0.0",
|
|
11
11
|
"@wagmi/core": ">=2.18",
|
|
12
12
|
"prool": "^0",
|
|
13
|
-
"viem": ">=2.
|
|
13
|
+
"viem": ">=2.39.2",
|
|
14
14
|
"wagmi": ">=2.19"
|
|
15
15
|
},
|
|
16
16
|
"peerDependenciesMeta": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Account,
|
|
3
3
|
type Address,
|
|
4
|
+
type BaseErrorType,
|
|
4
5
|
type Chain,
|
|
5
6
|
type Client,
|
|
6
7
|
type ExtractAbiItem,
|
|
@@ -91,6 +92,9 @@ export namespace create {
|
|
|
91
92
|
|
|
92
93
|
export type ReturnValue = WriteContractReturnType
|
|
93
94
|
|
|
95
|
+
// TODO: exhaustive error type
|
|
96
|
+
export type ErrorType = BaseErrorType
|
|
97
|
+
|
|
94
98
|
/** @internal */
|
|
95
99
|
export async function inner<
|
|
96
100
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -259,6 +263,9 @@ export namespace createSync {
|
|
|
259
263
|
receipt: TransactionReceipt
|
|
260
264
|
}
|
|
261
265
|
>
|
|
266
|
+
|
|
267
|
+
// TODO: exhaustive error type
|
|
268
|
+
export type ErrorType = BaseErrorType
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
/**
|
|
@@ -312,6 +319,9 @@ export namespace setAdmin {
|
|
|
312
319
|
|
|
313
320
|
export type ReturnValue = WriteContractReturnType
|
|
314
321
|
|
|
322
|
+
// TODO: exhaustive error type
|
|
323
|
+
export type ErrorType = BaseErrorType
|
|
324
|
+
|
|
315
325
|
/** @internal */
|
|
316
326
|
export async function inner<
|
|
317
327
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -456,6 +466,9 @@ export namespace setAdminSync {
|
|
|
456
466
|
receipt: TransactionReceipt
|
|
457
467
|
}
|
|
458
468
|
>
|
|
469
|
+
|
|
470
|
+
// TODO: exhaustive error type
|
|
471
|
+
export type ErrorType = BaseErrorType
|
|
459
472
|
}
|
|
460
473
|
|
|
461
474
|
/**
|
|
@@ -512,6 +525,9 @@ export namespace modifyWhitelist {
|
|
|
512
525
|
|
|
513
526
|
export type ReturnValue = WriteContractReturnType
|
|
514
527
|
|
|
528
|
+
// TODO: exhaustive error type
|
|
529
|
+
export type ErrorType = BaseErrorType
|
|
530
|
+
|
|
515
531
|
/** @internal */
|
|
516
532
|
export async function inner<
|
|
517
533
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -663,6 +679,9 @@ export namespace modifyWhitelistSync {
|
|
|
663
679
|
receipt: TransactionReceipt
|
|
664
680
|
}
|
|
665
681
|
>
|
|
682
|
+
|
|
683
|
+
// TODO: exhaustive error type
|
|
684
|
+
export type ErrorType = BaseErrorType
|
|
666
685
|
}
|
|
667
686
|
|
|
668
687
|
/**
|
|
@@ -719,6 +738,9 @@ export namespace modifyBlacklist {
|
|
|
719
738
|
|
|
720
739
|
export type ReturnValue = WriteContractReturnType
|
|
721
740
|
|
|
741
|
+
// TODO: exhaustive error type
|
|
742
|
+
export type ErrorType = BaseErrorType
|
|
743
|
+
|
|
722
744
|
/** @internal */
|
|
723
745
|
export async function inner<
|
|
724
746
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -870,6 +892,9 @@ export namespace modifyBlacklistSync {
|
|
|
870
892
|
receipt: TransactionReceipt
|
|
871
893
|
}
|
|
872
894
|
>
|
|
895
|
+
|
|
896
|
+
// TODO: exhaustive error type
|
|
897
|
+
export type ErrorType = BaseErrorType
|
|
873
898
|
}
|
|
874
899
|
|
|
875
900
|
/**
|