tempo.ts 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/README.md +92 -0
  2. package/dist/chains.d.ts +1477 -0
  3. package/dist/chains.d.ts.map +1 -0
  4. package/dist/chains.js +43 -0
  5. package/dist/chains.js.map +1 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/internal/types.d.ts +284 -0
  11. package/dist/internal/types.d.ts.map +1 -0
  12. package/dist/internal/types.js +2 -0
  13. package/dist/internal/types.js.map +1 -0
  14. package/dist/ox/TokenId.d.ts +18 -0
  15. package/dist/ox/TokenId.d.ts.map +1 -0
  16. package/dist/ox/TokenId.js +29 -0
  17. package/dist/ox/TokenId.js.map +1 -0
  18. package/dist/ox/TokenRole.d.ts +11 -0
  19. package/dist/ox/TokenRole.d.ts.map +1 -0
  20. package/dist/ox/TokenRole.js +22 -0
  21. package/dist/ox/TokenRole.js.map +1 -0
  22. package/dist/ox/Transaction.d.ts +161 -0
  23. package/dist/ox/Transaction.d.ts.map +1 -0
  24. package/dist/ox/Transaction.js +117 -0
  25. package/dist/ox/Transaction.js.map +1 -0
  26. package/dist/ox/TransactionEnvelopeFeeToken.d.ts +393 -0
  27. package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +1 -0
  28. package/dist/ox/TransactionEnvelopeFeeToken.js +452 -0
  29. package/dist/ox/TransactionEnvelopeFeeToken.js.map +1 -0
  30. package/dist/ox/TransactionRequest.d.ts +62 -0
  31. package/dist/ox/TransactionRequest.d.ts.map +1 -0
  32. package/dist/ox/TransactionRequest.js +66 -0
  33. package/dist/ox/TransactionRequest.js.map +1 -0
  34. package/dist/ox/index.d.ts +5 -0
  35. package/dist/ox/index.d.ts.map +1 -0
  36. package/dist/ox/index.js +5 -0
  37. package/dist/ox/index.js.map +1 -0
  38. package/dist/prool/Instance.d.ts +92 -0
  39. package/dist/prool/Instance.d.ts.map +1 -0
  40. package/dist/prool/Instance.js +96 -0
  41. package/dist/prool/Instance.js.map +1 -0
  42. package/dist/prool/index.d.ts +2 -0
  43. package/dist/prool/index.d.ts.map +1 -0
  44. package/dist/prool/index.js +2 -0
  45. package/dist/prool/index.js.map +1 -0
  46. package/dist/viem/abis.d.ts +2058 -0
  47. package/dist/viem/abis.d.ts.map +1 -0
  48. package/dist/viem/abis.js +1599 -0
  49. package/dist/viem/abis.js.map +1 -0
  50. package/dist/viem/actions/amm.d.ts +2091 -0
  51. package/dist/viem/actions/amm.d.ts.map +1 -0
  52. package/dist/viem/actions/amm.js +876 -0
  53. package/dist/viem/actions/amm.js.map +1 -0
  54. package/dist/viem/actions/fee.d.ts +727 -0
  55. package/dist/viem/actions/fee.d.ts.map +1 -0
  56. package/dist/viem/actions/fee.js +230 -0
  57. package/dist/viem/actions/fee.js.map +1 -0
  58. package/dist/viem/actions/index.d.ts +5 -0
  59. package/dist/viem/actions/index.d.ts.map +1 -0
  60. package/dist/viem/actions/index.js +5 -0
  61. package/dist/viem/actions/index.js.map +1 -0
  62. package/dist/viem/actions/policy.d.ts +1900 -0
  63. package/dist/viem/actions/policy.d.ts.map +1 -0
  64. package/dist/viem/actions/policy.js +841 -0
  65. package/dist/viem/actions/policy.js.map +1 -0
  66. package/dist/viem/actions/token.d.ts +13759 -0
  67. package/dist/viem/actions/token.d.ts.map +1 -0
  68. package/dist/viem/actions/token.js +2579 -0
  69. package/dist/viem/actions/token.js.map +1 -0
  70. package/dist/viem/addresses.d.ts +8 -0
  71. package/dist/viem/addresses.d.ts.map +1 -0
  72. package/dist/viem/addresses.js +8 -0
  73. package/dist/viem/addresses.js.map +1 -0
  74. package/dist/viem/chain.d.ts +341 -0
  75. package/dist/viem/chain.d.ts.map +1 -0
  76. package/dist/viem/chain.js +22 -0
  77. package/dist/viem/chain.js.map +1 -0
  78. package/dist/viem/client.d.ts +27 -0
  79. package/dist/viem/client.d.ts.map +1 -0
  80. package/dist/viem/client.js +28 -0
  81. package/dist/viem/client.js.map +1 -0
  82. package/dist/viem/decorator.d.ts +1636 -0
  83. package/dist/viem/decorator.d.ts.map +1 -0
  84. package/dist/viem/decorator.js +95 -0
  85. package/dist/viem/decorator.js.map +1 -0
  86. package/dist/viem/formatters.d.ts +4 -0
  87. package/dist/viem/formatters.d.ts.map +1 -0
  88. package/dist/viem/formatters.js +69 -0
  89. package/dist/viem/formatters.js.map +1 -0
  90. package/dist/viem/index.d.ts +9 -0
  91. package/dist/viem/index.d.ts.map +1 -0
  92. package/dist/viem/index.js +9 -0
  93. package/dist/viem/index.js.map +1 -0
  94. package/dist/viem/transaction.d.ts +54 -0
  95. package/dist/viem/transaction.d.ts.map +1 -0
  96. package/dist/viem/transaction.js +108 -0
  97. package/dist/viem/transaction.js.map +1 -0
  98. package/dist/viem/transport.d.ts +16 -0
  99. package/dist/viem/transport.d.ts.map +1 -0
  100. package/dist/viem/transport.js +33 -0
  101. package/dist/viem/transport.js.map +1 -0
  102. package/dist/viem/types.d.ts +10 -0
  103. package/dist/viem/types.d.ts.map +1 -0
  104. package/dist/viem/types.js +2 -0
  105. package/dist/viem/types.js.map +1 -0
  106. package/dist/viem/utils.d.ts +8 -0
  107. package/dist/viem/utils.d.ts.map +1 -0
  108. package/dist/viem/utils.js +9 -0
  109. package/dist/viem/utils.js.map +1 -0
  110. package/package.json +100 -2
  111. package/src/chains.ts +46 -0
  112. package/src/index.ts +1 -0
  113. package/src/internal/types.ts +414 -0
  114. package/src/ox/TokenId.test.ts +29 -0
  115. package/src/ox/TokenId.ts +35 -0
  116. package/src/ox/TokenRole.test.ts +20 -0
  117. package/src/ox/TokenRole.ts +27 -0
  118. package/src/ox/Transaction.test.ts +257 -0
  119. package/src/ox/Transaction.ts +247 -0
  120. package/src/ox/TransactionEnvelopeFeeToken.test.ts +1215 -0
  121. package/src/ox/TransactionEnvelopeFeeToken.ts +717 -0
  122. package/src/ox/TransactionRequest.ts +100 -0
  123. package/src/ox/index.ts +4 -0
  124. package/src/prool/Instance.test.ts +43 -0
  125. package/src/prool/Instance.ts +190 -0
  126. package/src/prool/index.ts +1 -0
  127. package/src/prool/internal/chain.json +106 -0
  128. package/src/prool/internal/consensus.toml +32 -0
  129. package/src/viem/abis.ts +1606 -0
  130. package/src/viem/actions/amm.test.ts +425 -0
  131. package/src/viem/actions/amm.ts +1308 -0
  132. package/src/viem/actions/fee.test.ts +281 -0
  133. package/src/viem/actions/fee.ts +362 -0
  134. package/src/viem/actions/index.ts +4 -0
  135. package/src/viem/actions/policy.test.ts +514 -0
  136. package/src/viem/actions/policy.ts +1284 -0
  137. package/src/viem/actions/token.test.ts +2172 -0
  138. package/src/viem/actions/token.ts +3830 -0
  139. package/src/viem/addresses.ts +10 -0
  140. package/src/viem/chain.ts +27 -0
  141. package/src/viem/client.bench-d.ts +8 -0
  142. package/src/viem/client.test.ts +152 -0
  143. package/src/viem/client.ts +91 -0
  144. package/src/viem/decorator.bench-d.ts +11 -0
  145. package/src/viem/decorator.test.ts +35 -0
  146. package/src/viem/decorator.ts +1914 -0
  147. package/src/viem/e2e.test.ts +410 -0
  148. package/src/viem/formatters.ts +100 -0
  149. package/src/viem/index.ts +8 -0
  150. package/src/viem/transaction.ts +253 -0
  151. package/src/viem/transport.ts +47 -0
  152. package/src/viem/types.ts +55 -0
  153. package/src/viem/utils.ts +37 -0
@@ -0,0 +1,1284 @@
1
+ import {
2
+ type Account,
3
+ type Address,
4
+ type Chain,
5
+ type Client,
6
+ type ExtractAbiItem,
7
+ type GetEventArgs,
8
+ type Log,
9
+ parseEventLogs,
10
+ type ReadContractReturnType,
11
+ type TransactionReceipt,
12
+ type Transport,
13
+ type Log as viem_Log,
14
+ type WatchContractEventParameters,
15
+ type WriteContractReturnType,
16
+ } from 'viem'
17
+ import { parseAccount } from 'viem/accounts'
18
+ import {
19
+ readContract,
20
+ watchContractEvent,
21
+ writeContract,
22
+ writeContractSync,
23
+ } from 'viem/actions'
24
+ import type { Compute, UnionOmit } from '../../internal/types.js'
25
+ import { tip403RegistryAbi } from '../abis.js'
26
+ import { tip403RegistryAddress } from '../addresses.js'
27
+ import type { ReadParameters, WriteParameters } from '../types.js'
28
+ import { defineCall } from '../utils.js'
29
+
30
+ export type PolicyType = 'whitelist' | 'blacklist'
31
+
32
+ const policyTypeMap = {
33
+ whitelist: 0,
34
+ blacklist: 1,
35
+ } as const
36
+
37
+ /**
38
+ * Creates a new policy.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { createClient, http } from 'viem'
43
+ * import { tempo } from 'tempo.ts/chains'
44
+ * import * as actions from 'tempo.ts/viem/actions'
45
+ * import { privateKeyToAccount } from 'viem/accounts'
46
+ *
47
+ * const client = createClient({
48
+ * account: privateKeyToAccount('0x...'),
49
+ * chain: tempo,
50
+ * transport: http(),
51
+ * })
52
+ *
53
+ * const { hash, policyId } = await actions.policy.create(client, {
54
+ * admin: '0x...',
55
+ * type: 'whitelist',
56
+ * })
57
+ * ```
58
+ *
59
+ * @param client - Client.
60
+ * @param parameters - Parameters.
61
+ * @returns The transaction hash and policy ID.
62
+ */
63
+ export async function create<
64
+ chain extends Chain | undefined,
65
+ account extends Account | undefined,
66
+ >(
67
+ client: Client<Transport, chain, account>,
68
+ parameters: create.Parameters<chain, account>,
69
+ ): Promise<create.ReturnValue> {
70
+ return create.inner(writeContract, client, parameters)
71
+ }
72
+
73
+ export namespace create {
74
+ export type Parameters<
75
+ chain extends Chain | undefined = Chain | undefined,
76
+ account extends Account | undefined = Account | undefined,
77
+ > = WriteParameters<chain, account> &
78
+ Omit<Args, 'admin'> & {
79
+ /** Address of the policy admin. */
80
+ admin?: Address | undefined
81
+ }
82
+
83
+ export type Args = {
84
+ /** Optional array of accounts to initialize the policy with. */
85
+ addresses?: readonly Address[] | undefined
86
+ /** Address of the policy admin. */
87
+ admin: Address
88
+ /** Type of policy to create. */
89
+ type: PolicyType
90
+ }
91
+
92
+ export type ReturnValue = WriteContractReturnType
93
+
94
+ /** @internal */
95
+ export async function inner<
96
+ action extends typeof writeContract | typeof writeContractSync,
97
+ chain extends Chain | undefined,
98
+ account extends Account | undefined,
99
+ >(
100
+ action: action,
101
+ client: Client<Transport, chain, account>,
102
+ parameters: Parameters<chain, account>,
103
+ ): Promise<ReturnType<action>> {
104
+ const {
105
+ account = client.account,
106
+ addresses,
107
+ chain = client.chain,
108
+ type,
109
+ ...rest
110
+ } = parameters
111
+
112
+ if (!account) throw new Error('`account` is required')
113
+
114
+ const admin = parseAccount(account).address!
115
+
116
+ const call = create.call({ admin, type, addresses })
117
+ return action(client, {
118
+ ...rest,
119
+ account,
120
+ chain,
121
+ ...call,
122
+ } as never) as never
123
+ }
124
+
125
+ /**
126
+ * Defines a call to the `createPolicy` function.
127
+ *
128
+ * Can be passed as a parameter to:
129
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
130
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
131
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { createClient, http, walletActions } from 'viem'
136
+ * import { tempo } from 'tempo.ts/chains'
137
+ * import * as actions from 'tempo.ts/viem/actions'
138
+ *
139
+ * const client = createClient({
140
+ * chain: tempo,
141
+ * transport: http(),
142
+ * }).extend(walletActions)
143
+ *
144
+ * const { result } = await client.sendCalls({
145
+ * calls: [
146
+ * actions.policy.create.call({
147
+ * admin: '0xfeed...fede',
148
+ * type: 'whitelist',
149
+ * }),
150
+ * actions.policy.create.call({
151
+ * admin: '0xfeed...fede',
152
+ * type: 'blacklist',
153
+ * addresses: ['0x20c0...beef', '0x20c0...babe'],
154
+ * }),
155
+ * ]
156
+ * })
157
+ * ```
158
+ *
159
+ * @param args - Arguments.
160
+ * @returns The call.
161
+ */
162
+ export function call(args: Args) {
163
+ const { admin, type, addresses } = args
164
+ const callArgs = addresses
165
+ ? ([admin, policyTypeMap[type], addresses] as const)
166
+ : ([admin, policyTypeMap[type]] as const)
167
+ return defineCall({
168
+ address: tip403RegistryAddress,
169
+ abi: tip403RegistryAbi,
170
+ functionName: 'createPolicy',
171
+ args: callArgs,
172
+ })
173
+ }
174
+
175
+ /**
176
+ * Extracts the `PolicyCreated` event from logs.
177
+ *
178
+ * @param logs - The logs.
179
+ * @returns The `PolicyCreated` event.
180
+ */
181
+ export function extractEvent(logs: Log[]) {
182
+ const [log] = parseEventLogs({
183
+ abi: tip403RegistryAbi,
184
+ logs,
185
+ eventName: 'PolicyCreated',
186
+ strict: true,
187
+ })
188
+ if (!log) throw new Error('`PolicyCreated` event not found.')
189
+ return log
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Creates a new policy.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { createClient, http } from 'viem'
199
+ * import { tempo } from 'tempo.ts/chains'
200
+ * import * as actions from 'tempo.ts/viem/actions'
201
+ * import { privateKeyToAccount } from 'viem/accounts'
202
+ *
203
+ * const client = createClient({
204
+ * account: privateKeyToAccount('0x...'),
205
+ * chain: tempo,
206
+ * transport: http(),
207
+ * })
208
+ *
209
+ * const result = await actions.policy.createSync(client, {
210
+ * admin: '0x...',
211
+ * type: 'whitelist',
212
+ * })
213
+ * ```
214
+ *
215
+ * @param client - Client.
216
+ * @param parameters - Parameters.
217
+ * @returns The transaction receipt and event data.
218
+ */
219
+ export async function createSync<
220
+ chain extends Chain | undefined,
221
+ account extends Account | undefined,
222
+ >(
223
+ client: Client<Transport, chain, account>,
224
+ parameters: createSync.Parameters<chain, account>,
225
+ ): Promise<createSync.ReturnValue> {
226
+ const receipt = await create.inner(writeContractSync, client, parameters)
227
+ const { args } = create.extractEvent(receipt.logs)
228
+ return {
229
+ ...args,
230
+ receipt,
231
+ } as never
232
+ }
233
+
234
+ export namespace createSync {
235
+ export type Parameters<
236
+ chain extends Chain | undefined = Chain | undefined,
237
+ account extends Account | undefined = Account | undefined,
238
+ > = create.Parameters<chain, account>
239
+
240
+ export type Args = create.Args
241
+
242
+ export type ReturnValue = Compute<
243
+ GetEventArgs<
244
+ typeof tip403RegistryAbi,
245
+ 'PolicyCreated',
246
+ { IndexedOnly: false; Required: true }
247
+ > & {
248
+ receipt: TransactionReceipt
249
+ }
250
+ >
251
+ }
252
+
253
+ /**
254
+ * Sets the admin for a policy.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * import { createClient, http } from 'viem'
259
+ * import { tempo } from 'tempo.ts/chains'
260
+ * import * as actions from 'tempo.ts/viem/actions'
261
+ * import { privateKeyToAccount } from 'viem/accounts'
262
+ *
263
+ * const client = createClient({
264
+ * account: privateKeyToAccount('0x...'),
265
+ * chain: tempo,
266
+ * transport: http(),
267
+ * })
268
+ *
269
+ * const hash = await actions.policy.setAdmin(client, {
270
+ * policyId: 2n,
271
+ * admin: '0x...',
272
+ * })
273
+ * ```
274
+ *
275
+ * @param client - Client.
276
+ * @param parameters - Parameters.
277
+ * @returns The transaction hash.
278
+ */
279
+ export async function setAdmin<
280
+ chain extends Chain | undefined,
281
+ account extends Account | undefined,
282
+ >(
283
+ client: Client<Transport, chain, account>,
284
+ parameters: setAdmin.Parameters<chain, account>,
285
+ ): Promise<setAdmin.ReturnValue> {
286
+ return setAdmin.inner(writeContract, client, parameters)
287
+ }
288
+
289
+ export namespace setAdmin {
290
+ export type Parameters<
291
+ chain extends Chain | undefined = Chain | undefined,
292
+ account extends Account | undefined = Account | undefined,
293
+ > = WriteParameters<chain, account> & Args
294
+
295
+ export type Args = {
296
+ /** New admin address. */
297
+ admin: Address
298
+ /** Policy ID. */
299
+ policyId: bigint
300
+ }
301
+
302
+ export type ReturnValue = WriteContractReturnType
303
+
304
+ /** @internal */
305
+ export async function inner<
306
+ action extends typeof writeContract | typeof writeContractSync,
307
+ chain extends Chain | undefined,
308
+ account extends Account | undefined,
309
+ >(
310
+ action: action,
311
+ client: Client<Transport, chain, account>,
312
+ parameters: setAdmin.Parameters<chain, account>,
313
+ ): Promise<ReturnType<action>> {
314
+ const call = setAdmin.call(parameters)
315
+ return (await action(client, {
316
+ ...parameters,
317
+ ...call,
318
+ } as never)) as never
319
+ }
320
+
321
+ /**
322
+ * Defines a call to the `setPolicyAdmin` function.
323
+ *
324
+ * Can be passed as a parameter to:
325
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
326
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
327
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * import { createClient, http, walletActions } from 'viem'
332
+ * import { tempo } from 'tempo.ts/chains'
333
+ * import * as actions from 'tempo.ts/viem/actions'
334
+ *
335
+ * const client = createClient({
336
+ * chain: tempo,
337
+ * transport: http(),
338
+ * }).extend(walletActions)
339
+ *
340
+ * const { result } = await client.sendCalls({
341
+ * calls: [
342
+ * actions.policy.setAdmin.call({
343
+ * policyId: 2n,
344
+ * admin: '0xfeed...fede',
345
+ * }),
346
+ * actions.policy.setAdmin.call({
347
+ * policyId: 3n,
348
+ * admin: '0xfeed...babe',
349
+ * }),
350
+ * ]
351
+ * })
352
+ * ```
353
+ *
354
+ * @param args - Arguments.
355
+ * @returns The call.
356
+ */
357
+ export function call(args: Args) {
358
+ const { policyId, admin } = args
359
+ return defineCall({
360
+ address: tip403RegistryAddress,
361
+ abi: tip403RegistryAbi,
362
+ functionName: 'setPolicyAdmin',
363
+ args: [policyId, admin],
364
+ })
365
+ }
366
+
367
+ /**
368
+ * Extracts the `PolicyAdminUpdated` event from logs.
369
+ *
370
+ * @param logs - The logs.
371
+ * @returns The `PolicyAdminUpdated` event.
372
+ */
373
+ export function extractEvent(logs: Log[]) {
374
+ const [log] = parseEventLogs({
375
+ abi: tip403RegistryAbi,
376
+ logs,
377
+ eventName: 'PolicyAdminUpdated',
378
+ strict: true,
379
+ })
380
+ if (!log) throw new Error('`PolicyAdminUpdated` event not found.')
381
+ return log
382
+ }
383
+ }
384
+
385
+ /**
386
+ * Sets the admin for a policy.
387
+ *
388
+ * @example
389
+ * ```ts
390
+ * import { createClient, http } from 'viem'
391
+ * import { tempo } from 'tempo.ts/chains'
392
+ * import * as actions from 'tempo.ts/viem/actions'
393
+ * import { privateKeyToAccount } from 'viem/accounts'
394
+ *
395
+ * const client = createClient({
396
+ * account: privateKeyToAccount('0x...'),
397
+ * chain: tempo,
398
+ * transport: http(),
399
+ * })
400
+ *
401
+ * const result = await actions.policy.setAdminSync(client, {
402
+ * policyId: 2n,
403
+ * admin: '0x...',
404
+ * })
405
+ * ```
406
+ *
407
+ * @param client - Client.
408
+ * @param parameters - Parameters.
409
+ * @returns The transaction receipt and event data.
410
+ */
411
+ export async function setAdminSync<
412
+ chain extends Chain | undefined,
413
+ account extends Account | undefined,
414
+ >(
415
+ client: Client<Transport, chain, account>,
416
+ parameters: setAdminSync.Parameters<chain, account>,
417
+ ): Promise<setAdminSync.ReturnValue> {
418
+ const receipt = await setAdmin.inner(writeContractSync, client, parameters)
419
+ const { args } = setAdmin.extractEvent(receipt.logs)
420
+ return {
421
+ ...args,
422
+ receipt,
423
+ } as never
424
+ }
425
+
426
+ export namespace setAdminSync {
427
+ export type Parameters<
428
+ chain extends Chain | undefined = Chain | undefined,
429
+ account extends Account | undefined = Account | undefined,
430
+ > = setAdmin.Parameters<chain, account>
431
+
432
+ export type Args = setAdmin.Args
433
+
434
+ export type ReturnValue = Compute<
435
+ GetEventArgs<
436
+ typeof tip403RegistryAbi,
437
+ 'PolicyAdminUpdated',
438
+ { IndexedOnly: false; Required: true }
439
+ > & {
440
+ receipt: TransactionReceipt
441
+ }
442
+ >
443
+ }
444
+
445
+ /**
446
+ * Modifies a policy whitelist.
447
+ *
448
+ * @example
449
+ * ```ts
450
+ * import { createClient, http } from 'viem'
451
+ * import { tempo } from 'tempo.ts/chains'
452
+ * import * as actions from 'tempo.ts/viem/actions'
453
+ * import { privateKeyToAccount } from 'viem/accounts'
454
+ *
455
+ * const client = createClient({
456
+ * account: privateKeyToAccount('0x...'),
457
+ * chain: tempo,
458
+ * transport: http(),
459
+ * })
460
+ *
461
+ * const hash = await actions.policy.modifyWhitelist(client, {
462
+ * policyId: 2n,
463
+ * account: '0x...',
464
+ * allowed: true,
465
+ * })
466
+ * ```
467
+ *
468
+ * @param client - Client.
469
+ * @param parameters - Parameters.
470
+ * @returns The transaction hash.
471
+ */
472
+ export async function modifyWhitelist<
473
+ chain extends Chain | undefined,
474
+ account extends Account | undefined,
475
+ >(
476
+ client: Client<Transport, chain, account>,
477
+ parameters: modifyWhitelist.Parameters<chain, account>,
478
+ ): Promise<modifyWhitelist.ReturnValue> {
479
+ return modifyWhitelist.inner(writeContract, client, parameters)
480
+ }
481
+
482
+ export namespace modifyWhitelist {
483
+ export type Parameters<
484
+ chain extends Chain | undefined = Chain | undefined,
485
+ account extends Account | undefined = Account | undefined,
486
+ > = WriteParameters<chain, account> & Args
487
+
488
+ export type Args = {
489
+ /** Target account address. */
490
+ address: Address
491
+ /** Whether the account is allowed. */
492
+ allowed: boolean
493
+ /** Policy ID. */
494
+ policyId: bigint
495
+ }
496
+
497
+ export type ReturnValue = WriteContractReturnType
498
+
499
+ /** @internal */
500
+ export async function inner<
501
+ action extends typeof writeContract | typeof writeContractSync,
502
+ chain extends Chain | undefined,
503
+ account extends Account | undefined,
504
+ >(
505
+ action: action,
506
+ client: Client<Transport, chain, account>,
507
+ parameters: modifyWhitelist.Parameters<chain, account>,
508
+ ): Promise<ReturnType<action>> {
509
+ const { address: targetAccount, ...rest } = parameters
510
+ const call = modifyWhitelist.call({ ...rest, address: targetAccount })
511
+ return (await action(client, {
512
+ ...parameters,
513
+ ...call,
514
+ } as never)) as never
515
+ }
516
+
517
+ /**
518
+ * Defines a call to the `modifyPolicyWhitelist` function.
519
+ *
520
+ * Can be passed as a parameter to:
521
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
522
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
523
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * import { createClient, http, walletActions } from 'viem'
528
+ * import { tempo } from 'tempo.ts/chains'
529
+ * import * as actions from 'tempo.ts/viem/actions'
530
+ *
531
+ * const client = createClient({
532
+ * chain: tempo,
533
+ * transport: http(),
534
+ * }).extend(walletActions)
535
+ *
536
+ * const { result } = await client.sendCalls({
537
+ * calls: [
538
+ * actions.policy.modifyWhitelist.call({
539
+ * policyId: 2n,
540
+ * address: '0x20c0...beef',
541
+ * allowed: true,
542
+ * }),
543
+ * actions.policy.modifyWhitelist.call({
544
+ * policyId: 2n,
545
+ * address: '0x20c0...babe',
546
+ * allowed: false,
547
+ * }),
548
+ * ]
549
+ * })
550
+ * ```
551
+ *
552
+ * @param args - Arguments.
553
+ * @returns The call.
554
+ */
555
+ export function call(args: Args) {
556
+ const { policyId, address, allowed } = args
557
+ return defineCall({
558
+ address: tip403RegistryAddress,
559
+ abi: tip403RegistryAbi,
560
+ functionName: 'modifyPolicyWhitelist',
561
+ args: [policyId, address, allowed],
562
+ })
563
+ }
564
+
565
+ /**
566
+ * Extracts the `WhitelistUpdated` event from logs.
567
+ *
568
+ * @param logs - The logs.
569
+ * @returns The `WhitelistUpdated` event.
570
+ */
571
+ export function extractEvent(logs: Log[]) {
572
+ const [log] = parseEventLogs({
573
+ abi: tip403RegistryAbi,
574
+ logs,
575
+ eventName: 'WhitelistUpdated',
576
+ strict: true,
577
+ })
578
+ if (!log) throw new Error('`WhitelistUpdated` event not found.')
579
+ return log
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Modifies a policy whitelist.
585
+ *
586
+ * @example
587
+ * ```ts
588
+ * import { createClient, http } from 'viem'
589
+ * import { tempo } from 'tempo.ts/chains'
590
+ * import * as actions from 'tempo.ts/viem/actions'
591
+ * import { privateKeyToAccount } from 'viem/accounts'
592
+ *
593
+ * const client = createClient({
594
+ * account: privateKeyToAccount('0x...'),
595
+ * chain: tempo,
596
+ * transport: http(),
597
+ * })
598
+ *
599
+ * const result = await actions.policy.modifyWhitelistSync(client, {
600
+ * policyId: 2n,
601
+ * account: '0x...',
602
+ * allowed: true,
603
+ * })
604
+ * ```
605
+ *
606
+ * @param client - Client.
607
+ * @param parameters - Parameters.
608
+ * @returns The transaction receipt and event data.
609
+ */
610
+ export async function modifyWhitelistSync<
611
+ chain extends Chain | undefined,
612
+ account extends Account | undefined,
613
+ >(
614
+ client: Client<Transport, chain, account>,
615
+ parameters: modifyWhitelistSync.Parameters<chain, account>,
616
+ ): Promise<modifyWhitelistSync.ReturnValue> {
617
+ const receipt = await modifyWhitelist.inner(
618
+ writeContractSync,
619
+ client,
620
+ parameters,
621
+ )
622
+ const { args } = modifyWhitelist.extractEvent(receipt.logs)
623
+ return {
624
+ ...args,
625
+ receipt,
626
+ } as never
627
+ }
628
+
629
+ export namespace modifyWhitelistSync {
630
+ export type Parameters<
631
+ chain extends Chain | undefined = Chain | undefined,
632
+ account extends Account | undefined = Account | undefined,
633
+ > = modifyWhitelist.Parameters<chain, account>
634
+
635
+ export type Args = modifyWhitelist.Args
636
+
637
+ export type ReturnValue = Compute<
638
+ GetEventArgs<
639
+ typeof tip403RegistryAbi,
640
+ 'WhitelistUpdated',
641
+ { IndexedOnly: false; Required: true }
642
+ > & {
643
+ receipt: TransactionReceipt
644
+ }
645
+ >
646
+ }
647
+
648
+ /**
649
+ * Modifies a policy blacklist.
650
+ *
651
+ * @example
652
+ * ```ts
653
+ * import { createClient, http } from 'viem'
654
+ * import { tempo } from 'tempo.ts/chains'
655
+ * import * as actions from 'tempo.ts/viem/actions'
656
+ * import { privateKeyToAccount } from 'viem/accounts'
657
+ *
658
+ * const client = createClient({
659
+ * account: privateKeyToAccount('0x...'),
660
+ * chain: tempo,
661
+ * transport: http(),
662
+ * })
663
+ *
664
+ * const hash = await actions.policy.modifyBlacklist(client, {
665
+ * policyId: 2n,
666
+ * account: '0x...',
667
+ * restricted: true,
668
+ * })
669
+ * ```
670
+ *
671
+ * @param client - Client.
672
+ * @param parameters - Parameters.
673
+ * @returns The transaction hash.
674
+ */
675
+ export async function modifyBlacklist<
676
+ chain extends Chain | undefined,
677
+ account extends Account | undefined,
678
+ >(
679
+ client: Client<Transport, chain, account>,
680
+ parameters: modifyBlacklist.Parameters<chain, account>,
681
+ ): Promise<modifyBlacklist.ReturnValue> {
682
+ return modifyBlacklist.inner(writeContract, client, parameters)
683
+ }
684
+
685
+ export namespace modifyBlacklist {
686
+ export type Parameters<
687
+ chain extends Chain | undefined = Chain | undefined,
688
+ account extends Account | undefined = Account | undefined,
689
+ > = WriteParameters<chain, account> & Args
690
+
691
+ export type Args = {
692
+ /** Target account address. */
693
+ address: Address
694
+ /** Policy ID. */
695
+ policyId: bigint
696
+ /** Whether the account is restricted. */
697
+ restricted: boolean
698
+ }
699
+
700
+ export type ReturnValue = WriteContractReturnType
701
+
702
+ /** @internal */
703
+ export async function inner<
704
+ action extends typeof writeContract | typeof writeContractSync,
705
+ chain extends Chain | undefined,
706
+ account extends Account | undefined,
707
+ >(
708
+ action: action,
709
+ client: Client<Transport, chain, account>,
710
+ parameters: modifyBlacklist.Parameters<chain, account>,
711
+ ): Promise<ReturnType<action>> {
712
+ const { address: targetAccount, ...rest } = parameters
713
+ const call = modifyBlacklist.call({ ...rest, address: targetAccount })
714
+ return (await action(client, {
715
+ ...parameters,
716
+ ...call,
717
+ } as never)) as never
718
+ }
719
+
720
+ /**
721
+ * Defines a call to the `modifyPolicyBlacklist` function.
722
+ *
723
+ * Can be passed as a parameter to:
724
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
725
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
726
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
727
+ *
728
+ * @example
729
+ * ```ts
730
+ * import { createClient, http, walletActions } from 'viem'
731
+ * import { tempo } from 'tempo.ts/chains'
732
+ * import * as actions from 'tempo.ts/viem/actions'
733
+ *
734
+ * const client = createClient({
735
+ * chain: tempo,
736
+ * transport: http(),
737
+ * }).extend(walletActions)
738
+ *
739
+ * const { result } = await client.sendCalls({
740
+ * calls: [
741
+ * actions.policy.modifyBlacklist.call({
742
+ * policyId: 2n,
743
+ * address: '0x20c0...beef',
744
+ * restricted: true,
745
+ * }),
746
+ * actions.policy.modifyBlacklist.call({
747
+ * policyId: 2n,
748
+ * address: '0x20c0...babe',
749
+ * restricted: false,
750
+ * }),
751
+ * ]
752
+ * })
753
+ * ```
754
+ *
755
+ * @param args - Arguments.
756
+ * @returns The call.
757
+ */
758
+ export function call(args: Args) {
759
+ const { policyId, address, restricted } = args
760
+ return defineCall({
761
+ address: tip403RegistryAddress,
762
+ abi: tip403RegistryAbi,
763
+ functionName: 'modifyPolicyBlacklist',
764
+ args: [policyId, address, restricted],
765
+ })
766
+ }
767
+
768
+ /**
769
+ * Extracts the `BlacklistUpdated` event from logs.
770
+ *
771
+ * @param logs - The logs.
772
+ * @returns The `BlacklistUpdated` event.
773
+ */
774
+ export function extractEvent(logs: Log[]) {
775
+ const [log] = parseEventLogs({
776
+ abi: tip403RegistryAbi,
777
+ logs,
778
+ eventName: 'BlacklistUpdated',
779
+ strict: true,
780
+ })
781
+ if (!log) throw new Error('`BlacklistUpdated` event not found.')
782
+ return log
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Modifies a policy blacklist.
788
+ *
789
+ * @example
790
+ * ```ts
791
+ * import { createClient, http } from 'viem'
792
+ * import { tempo } from 'tempo.ts/chains'
793
+ * import * as actions from 'tempo.ts/viem/actions'
794
+ * import { privateKeyToAccount } from 'viem/accounts'
795
+ *
796
+ * const client = createClient({
797
+ * account: privateKeyToAccount('0x...'),
798
+ * chain: tempo,
799
+ * transport: http(),
800
+ * })
801
+ *
802
+ * const result = await actions.policy.modifyBlacklistSync(client, {
803
+ * policyId: 2n,
804
+ * account: '0x...',
805
+ * restricted: true,
806
+ * })
807
+ * ```
808
+ *
809
+ * @param client - Client.
810
+ * @param parameters - Parameters.
811
+ * @returns The transaction receipt and event data.
812
+ */
813
+ export async function modifyBlacklistSync<
814
+ chain extends Chain | undefined,
815
+ account extends Account | undefined,
816
+ >(
817
+ client: Client<Transport, chain, account>,
818
+ parameters: modifyBlacklistSync.Parameters<chain, account>,
819
+ ): Promise<modifyBlacklistSync.ReturnValue> {
820
+ const receipt = await modifyBlacklist.inner(
821
+ writeContractSync,
822
+ client,
823
+ parameters,
824
+ )
825
+ const { args } = modifyBlacklist.extractEvent(receipt.logs)
826
+ return {
827
+ ...args,
828
+ receipt,
829
+ } as never
830
+ }
831
+
832
+ export namespace modifyBlacklistSync {
833
+ export type Parameters<
834
+ chain extends Chain | undefined = Chain | undefined,
835
+ account extends Account | undefined = Account | undefined,
836
+ > = modifyBlacklist.Parameters<chain, account>
837
+
838
+ export type Args = modifyBlacklist.Args
839
+
840
+ export type ReturnValue = Compute<
841
+ GetEventArgs<
842
+ typeof tip403RegistryAbi,
843
+ 'BlacklistUpdated',
844
+ { IndexedOnly: false; Required: true }
845
+ > & {
846
+ receipt: TransactionReceipt
847
+ }
848
+ >
849
+ }
850
+
851
+ /**
852
+ * Gets policy data.
853
+ *
854
+ * @example
855
+ * ```ts
856
+ * import { createClient, http } from 'viem'
857
+ * import { tempo } from 'tempo.ts/chains'
858
+ * import * as actions from 'tempo.ts/viem/actions'
859
+ *
860
+ * const client = createClient({
861
+ * chain: tempo,
862
+ * transport: http(),
863
+ * })
864
+ *
865
+ * const data = await actions.policy.getData(client, {
866
+ * policyId: 2n,
867
+ * })
868
+ * ```
869
+ *
870
+ * @param client - Client.
871
+ * @param parameters - Parameters.
872
+ * @returns The policy data.
873
+ */
874
+ export async function getData<chain extends Chain | undefined>(
875
+ client: Client<Transport, chain>,
876
+ parameters: getData.Parameters,
877
+ ): Promise<getData.ReturnValue> {
878
+ const result = await readContract(client, {
879
+ ...parameters,
880
+ ...getData.call(parameters),
881
+ })
882
+ return {
883
+ admin: result[1],
884
+ type: result[0] === 0 ? 'whitelist' : 'blacklist',
885
+ }
886
+ }
887
+
888
+ export namespace getData {
889
+ export type Parameters = ReadParameters & Args
890
+
891
+ export type Args = {
892
+ /** Policy ID. */
893
+ policyId: bigint
894
+ }
895
+
896
+ export type ReturnValue = Compute<{
897
+ /** Admin address. */
898
+ admin: Address
899
+ /** Policy type. */
900
+ type: PolicyType
901
+ }>
902
+
903
+ /**
904
+ * Defines a call to the `policyData` function.
905
+ *
906
+ * @param args - Arguments.
907
+ * @returns The call.
908
+ */
909
+ export function call(args: Args) {
910
+ const { policyId } = args
911
+ return defineCall({
912
+ address: tip403RegistryAddress,
913
+ abi: tip403RegistryAbi,
914
+ args: [policyId],
915
+ functionName: 'policyData',
916
+ })
917
+ }
918
+ }
919
+
920
+ /**
921
+ * Checks if a user is authorized by a policy.
922
+ *
923
+ * @example
924
+ * ```ts
925
+ * import { createClient, http } from 'viem'
926
+ * import { tempo } from 'tempo.ts/chains'
927
+ * import * as actions from 'tempo.ts/viem/actions'
928
+ *
929
+ * const client = createClient({
930
+ * chain: tempo,
931
+ * transport: http(),
932
+ * })
933
+ *
934
+ * const authorized = await actions.policy.isAuthorized(client, {
935
+ * policyId: 2n,
936
+ * user: '0x...',
937
+ * })
938
+ * ```
939
+ *
940
+ * @param client - Client.
941
+ * @param parameters - Parameters.
942
+ * @returns Whether the user is authorized.
943
+ */
944
+ export async function isAuthorized<chain extends Chain | undefined>(
945
+ client: Client<Transport, chain>,
946
+ parameters: isAuthorized.Parameters,
947
+ ): Promise<isAuthorized.ReturnValue> {
948
+ return readContract(client, {
949
+ ...parameters,
950
+ ...isAuthorized.call(parameters),
951
+ })
952
+ }
953
+
954
+ export namespace isAuthorized {
955
+ export type Parameters = ReadParameters & Args
956
+
957
+ export type Args = {
958
+ /** Policy ID. */
959
+ policyId: bigint
960
+ /** User address to check. */
961
+ user: Address
962
+ }
963
+
964
+ export type ReturnValue = ReadContractReturnType<
965
+ typeof tip403RegistryAbi,
966
+ 'isAuthorized',
967
+ never
968
+ >
969
+
970
+ /**
971
+ * Defines a call to the `isAuthorized` function.
972
+ *
973
+ * @param args - Arguments.
974
+ * @returns The call.
975
+ */
976
+ export function call(args: Args) {
977
+ const { policyId, user } = args
978
+ return defineCall({
979
+ address: tip403RegistryAddress,
980
+ abi: tip403RegistryAbi,
981
+ args: [policyId, user],
982
+ functionName: 'isAuthorized',
983
+ })
984
+ }
985
+ }
986
+
987
+ /**
988
+ * Watches for policy creation events.
989
+ *
990
+ * @example
991
+ * ```ts
992
+ * import { createClient, http } from 'viem'
993
+ * import { tempo } from 'tempo.ts/chains'
994
+ * import * as actions from 'tempo.ts/viem/actions'
995
+ *
996
+ * const client = createClient({
997
+ * chain: tempo,
998
+ * transport: http(),
999
+ * })
1000
+ *
1001
+ * const unwatch = actions.policy.watchCreate(client, {
1002
+ * onPolicyCreated: (args, log) => {
1003
+ * console.log('Policy created:', args)
1004
+ * },
1005
+ * })
1006
+ * ```
1007
+ *
1008
+ * @param client - Client.
1009
+ * @param parameters - Parameters.
1010
+ * @returns A function to unsubscribe from the event.
1011
+ */
1012
+ export function watchCreate<
1013
+ chain extends Chain | undefined,
1014
+ account extends Account | undefined,
1015
+ >(
1016
+ client: Client<Transport, chain, account>,
1017
+ parameters: watchCreate.Parameters,
1018
+ ) {
1019
+ const { onPolicyCreated, ...rest } = parameters
1020
+ return watchContractEvent(client, {
1021
+ ...rest,
1022
+ address: tip403RegistryAddress,
1023
+ abi: tip403RegistryAbi,
1024
+ eventName: 'PolicyCreated',
1025
+ onLogs: (logs) => {
1026
+ for (const log of logs)
1027
+ onPolicyCreated(
1028
+ {
1029
+ ...log.args,
1030
+ type: log.args.policyType === 0 ? 'whitelist' : 'blacklist',
1031
+ },
1032
+ log,
1033
+ )
1034
+ },
1035
+ strict: true,
1036
+ })
1037
+ }
1038
+
1039
+ export declare namespace watchCreate {
1040
+ export type Args = Compute<{
1041
+ policyId: bigint
1042
+ updater: Address
1043
+ type: PolicyType
1044
+ }>
1045
+
1046
+ export type Log = viem_Log<
1047
+ bigint,
1048
+ number,
1049
+ false,
1050
+ ExtractAbiItem<typeof tip403RegistryAbi, 'PolicyCreated'>,
1051
+ true
1052
+ >
1053
+
1054
+ export type Parameters = UnionOmit<
1055
+ WatchContractEventParameters<
1056
+ typeof tip403RegistryAbi,
1057
+ 'PolicyCreated',
1058
+ true
1059
+ >,
1060
+ 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
1061
+ > & {
1062
+ /** Callback to invoke when a policy is created. */
1063
+ onPolicyCreated: (args: Args, log: Log) => void
1064
+ }
1065
+ }
1066
+
1067
+ /**
1068
+ * Watches for policy admin update events.
1069
+ *
1070
+ * @example
1071
+ * ```ts
1072
+ * import { createClient, http } from 'viem'
1073
+ * import { tempo } from 'tempo.ts/chains'
1074
+ * import * as actions from 'tempo.ts/viem/actions'
1075
+ *
1076
+ * const client = createClient({
1077
+ * chain: tempo,
1078
+ * transport: http(),
1079
+ * })
1080
+ *
1081
+ * const unwatch = actions.policy.watchAdminUpdated(client, {
1082
+ * onAdminUpdated: (args, log) => {
1083
+ * console.log('Policy admin updated:', args)
1084
+ * },
1085
+ * })
1086
+ * ```
1087
+ *
1088
+ * @param client - Client.
1089
+ * @param parameters - Parameters.
1090
+ * @returns A function to unsubscribe from the event.
1091
+ */
1092
+ export function watchAdminUpdated<
1093
+ chain extends Chain | undefined,
1094
+ account extends Account | undefined,
1095
+ >(
1096
+ client: Client<Transport, chain, account>,
1097
+ parameters: watchAdminUpdated.Parameters,
1098
+ ) {
1099
+ const { onAdminUpdated, ...rest } = parameters
1100
+ return watchContractEvent(client, {
1101
+ ...rest,
1102
+ address: tip403RegistryAddress,
1103
+ abi: tip403RegistryAbi,
1104
+ eventName: 'PolicyAdminUpdated',
1105
+ onLogs: (logs) => {
1106
+ for (const log of logs) onAdminUpdated(log.args, log)
1107
+ },
1108
+ strict: true,
1109
+ })
1110
+ }
1111
+
1112
+ export declare namespace watchAdminUpdated {
1113
+ export type Args = GetEventArgs<
1114
+ typeof tip403RegistryAbi,
1115
+ 'PolicyAdminUpdated',
1116
+ { IndexedOnly: false; Required: true }
1117
+ >
1118
+
1119
+ export type Log = viem_Log<
1120
+ bigint,
1121
+ number,
1122
+ false,
1123
+ ExtractAbiItem<typeof tip403RegistryAbi, 'PolicyAdminUpdated'>,
1124
+ true
1125
+ >
1126
+
1127
+ export type Parameters = UnionOmit<
1128
+ WatchContractEventParameters<
1129
+ typeof tip403RegistryAbi,
1130
+ 'PolicyAdminUpdated',
1131
+ true
1132
+ >,
1133
+ 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
1134
+ > & {
1135
+ /** Callback to invoke when a policy admin is updated. */
1136
+ onAdminUpdated: (args: Args, log: Log) => void
1137
+ }
1138
+ }
1139
+
1140
+ /**
1141
+ * Watches for whitelist update events.
1142
+ *
1143
+ * @example
1144
+ * ```ts
1145
+ * import { createClient, http } from 'viem'
1146
+ * import { tempo } from 'tempo.ts/chains'
1147
+ * import * as actions from 'tempo.ts/viem/actions'
1148
+ *
1149
+ * const client = createClient({
1150
+ * chain: tempo,
1151
+ * transport: http(),
1152
+ * })
1153
+ *
1154
+ * const unwatch = actions.policy.watchWhitelistUpdated(client, {
1155
+ * onWhitelistUpdated: (args, log) => {
1156
+ * console.log('Whitelist updated:', args)
1157
+ * },
1158
+ * })
1159
+ * ```
1160
+ *
1161
+ * @param client - Client.
1162
+ * @param parameters - Parameters.
1163
+ * @returns A function to unsubscribe from the event.
1164
+ */
1165
+ export function watchWhitelistUpdated<
1166
+ chain extends Chain | undefined,
1167
+ account extends Account | undefined,
1168
+ >(
1169
+ client: Client<Transport, chain, account>,
1170
+ parameters: watchWhitelistUpdated.Parameters,
1171
+ ) {
1172
+ const { onWhitelistUpdated, ...rest } = parameters
1173
+ return watchContractEvent(client, {
1174
+ ...rest,
1175
+ address: tip403RegistryAddress,
1176
+ abi: tip403RegistryAbi,
1177
+ eventName: 'WhitelistUpdated',
1178
+ onLogs: (logs) => {
1179
+ for (const log of logs) onWhitelistUpdated(log.args, log)
1180
+ },
1181
+ strict: true,
1182
+ })
1183
+ }
1184
+
1185
+ export declare namespace watchWhitelistUpdated {
1186
+ export type Args = GetEventArgs<
1187
+ typeof tip403RegistryAbi,
1188
+ 'WhitelistUpdated',
1189
+ { IndexedOnly: false; Required: true }
1190
+ >
1191
+
1192
+ export type Log = viem_Log<
1193
+ bigint,
1194
+ number,
1195
+ false,
1196
+ ExtractAbiItem<typeof tip403RegistryAbi, 'WhitelistUpdated'>,
1197
+ true
1198
+ >
1199
+
1200
+ export type Parameters = UnionOmit<
1201
+ WatchContractEventParameters<
1202
+ typeof tip403RegistryAbi,
1203
+ 'WhitelistUpdated',
1204
+ true
1205
+ >,
1206
+ 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
1207
+ > & {
1208
+ /** Callback to invoke when a whitelist is updated. */
1209
+ onWhitelistUpdated: (args: Args, log: Log) => void
1210
+ }
1211
+ }
1212
+
1213
+ /**
1214
+ * Watches for blacklist update events.
1215
+ *
1216
+ * @example
1217
+ * ```ts
1218
+ * import { createClient, http } from 'viem'
1219
+ * import { tempo } from 'tempo.ts/chains'
1220
+ * import * as actions from 'tempo.ts/viem/actions'
1221
+ *
1222
+ * const client = createClient({
1223
+ * chain: tempo,
1224
+ * transport: http(),
1225
+ * })
1226
+ *
1227
+ * const unwatch = actions.policy.watchBlacklistUpdated(client, {
1228
+ * onBlacklistUpdated: (args, log) => {
1229
+ * console.log('Blacklist updated:', args)
1230
+ * },
1231
+ * })
1232
+ * ```
1233
+ *
1234
+ * @param client - Client.
1235
+ * @param parameters - Parameters.
1236
+ * @returns A function to unsubscribe from the event.
1237
+ */
1238
+ export function watchBlacklistUpdated<
1239
+ chain extends Chain | undefined,
1240
+ account extends Account | undefined,
1241
+ >(
1242
+ client: Client<Transport, chain, account>,
1243
+ parameters: watchBlacklistUpdated.Parameters,
1244
+ ) {
1245
+ const { onBlacklistUpdated, ...rest } = parameters
1246
+ return watchContractEvent(client, {
1247
+ ...rest,
1248
+ address: tip403RegistryAddress,
1249
+ abi: tip403RegistryAbi,
1250
+ eventName: 'BlacklistUpdated',
1251
+ onLogs: (logs) => {
1252
+ for (const log of logs) onBlacklistUpdated(log.args, log)
1253
+ },
1254
+ strict: true,
1255
+ })
1256
+ }
1257
+
1258
+ export declare namespace watchBlacklistUpdated {
1259
+ export type Args = GetEventArgs<
1260
+ typeof tip403RegistryAbi,
1261
+ 'BlacklistUpdated',
1262
+ { IndexedOnly: false; Required: true }
1263
+ >
1264
+
1265
+ export type Log = viem_Log<
1266
+ bigint,
1267
+ number,
1268
+ false,
1269
+ ExtractAbiItem<typeof tip403RegistryAbi, 'BlacklistUpdated'>,
1270
+ true
1271
+ >
1272
+
1273
+ export type Parameters = UnionOmit<
1274
+ WatchContractEventParameters<
1275
+ typeof tip403RegistryAbi,
1276
+ 'BlacklistUpdated',
1277
+ true
1278
+ >,
1279
+ 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
1280
+ > & {
1281
+ /** Callback to invoke when a blacklist is updated. */
1282
+ onBlacklistUpdated: (args: Args, log: Log) => void
1283
+ }
1284
+ }