tempo.ts 0.1.2 → 0.1.3

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 (125) hide show
  1. package/dist/chains.d.ts +1180 -0
  2. package/dist/chains.d.ts.map +1 -0
  3. package/dist/chains.js +30 -0
  4. package/dist/chains.js.map +1 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +2 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/internal/types.d.ts +284 -0
  10. package/dist/internal/types.d.ts.map +1 -0
  11. package/dist/internal/types.js +2 -0
  12. package/dist/internal/types.js.map +1 -0
  13. package/dist/ox/SignatureEnvelope.d.ts +245 -0
  14. package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
  15. package/dist/ox/SignatureEnvelope.js +437 -0
  16. package/dist/ox/SignatureEnvelope.js.map +1 -0
  17. package/dist/ox/TokenId.d.ts +25 -0
  18. package/dist/ox/TokenId.d.ts.map +1 -0
  19. package/dist/ox/TokenId.js +41 -0
  20. package/dist/ox/TokenId.js.map +1 -0
  21. package/dist/ox/TokenRole.d.ts +11 -0
  22. package/dist/ox/TokenRole.d.ts.map +1 -0
  23. package/dist/ox/TokenRole.js +22 -0
  24. package/dist/ox/TokenRole.js.map +1 -0
  25. package/dist/ox/Transaction.d.ts +198 -0
  26. package/dist/ox/Transaction.d.ts.map +1 -0
  27. package/dist/ox/Transaction.js +162 -0
  28. package/dist/ox/Transaction.js.map +1 -0
  29. package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
  30. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
  31. package/dist/ox/TransactionEnvelopeAA.js +528 -0
  32. package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
  33. package/dist/ox/TransactionRequest.d.ts +64 -0
  34. package/dist/ox/TransactionRequest.d.ts.map +1 -0
  35. package/dist/ox/TransactionRequest.js +75 -0
  36. package/dist/ox/TransactionRequest.js.map +1 -0
  37. package/dist/ox/index.d.ts +6 -0
  38. package/dist/ox/index.d.ts.map +1 -0
  39. package/dist/ox/index.js +6 -0
  40. package/dist/ox/index.js.map +1 -0
  41. package/dist/prool/Instance.d.ts +88 -0
  42. package/dist/prool/Instance.d.ts.map +1 -0
  43. package/dist/prool/Instance.js +96 -0
  44. package/dist/prool/Instance.js.map +1 -0
  45. package/dist/prool/index.d.ts +2 -0
  46. package/dist/prool/index.d.ts.map +1 -0
  47. package/dist/prool/index.js +2 -0
  48. package/dist/prool/index.js.map +1 -0
  49. package/dist/viem/Abis.d.ts +1885 -0
  50. package/dist/viem/Abis.d.ts.map +1 -0
  51. package/dist/viem/Abis.js +1174 -0
  52. package/dist/viem/Abis.js.map +1 -0
  53. package/dist/viem/Actions/amm.d.ts +2006 -0
  54. package/dist/viem/Actions/amm.d.ts.map +1 -0
  55. package/dist/viem/Actions/amm.js +900 -0
  56. package/dist/viem/Actions/amm.js.map +1 -0
  57. package/dist/viem/Actions/dex.d.ts +3279 -0
  58. package/dist/viem/Actions/dex.d.ts.map +1 -0
  59. package/dist/viem/Actions/dex.js +1357 -0
  60. package/dist/viem/Actions/dex.js.map +1 -0
  61. package/dist/viem/Actions/fee.d.ts +374 -0
  62. package/dist/viem/Actions/fee.d.ts.map +1 -0
  63. package/dist/viem/Actions/fee.js +235 -0
  64. package/dist/viem/Actions/fee.js.map +1 -0
  65. package/dist/viem/Actions/index.d.ts +6 -0
  66. package/dist/viem/Actions/index.d.ts.map +1 -0
  67. package/dist/viem/Actions/index.js +6 -0
  68. package/dist/viem/Actions/index.js.map +1 -0
  69. package/dist/viem/Actions/policy.d.ts +1672 -0
  70. package/dist/viem/Actions/policy.d.ts.map +1 -0
  71. package/dist/viem/Actions/policy.js +875 -0
  72. package/dist/viem/Actions/policy.js.map +1 -0
  73. package/dist/viem/Actions/token.d.ts +13714 -0
  74. package/dist/viem/Actions/token.d.ts.map +1 -0
  75. package/dist/viem/Actions/token.js +3058 -0
  76. package/dist/viem/Actions/token.js.map +1 -0
  77. package/dist/viem/Addresses.d.ts +9 -0
  78. package/dist/viem/Addresses.d.ts.map +1 -0
  79. package/dist/viem/Addresses.js +9 -0
  80. package/dist/viem/Addresses.js.map +1 -0
  81. package/dist/viem/Chain.d.ts +365 -0
  82. package/dist/viem/Chain.d.ts.map +1 -0
  83. package/dist/viem/Chain.js +22 -0
  84. package/dist/viem/Chain.js.map +1 -0
  85. package/dist/viem/Client.d.ts +27 -0
  86. package/dist/viem/Client.d.ts.map +1 -0
  87. package/dist/viem/Client.js +28 -0
  88. package/dist/viem/Client.js.map +1 -0
  89. package/dist/viem/Decorator.d.ts +2161 -0
  90. package/dist/viem/Decorator.d.ts.map +1 -0
  91. package/dist/viem/Decorator.js +122 -0
  92. package/dist/viem/Decorator.js.map +1 -0
  93. package/dist/viem/Formatters.d.ts +4 -0
  94. package/dist/viem/Formatters.d.ts.map +1 -0
  95. package/dist/viem/Formatters.js +76 -0
  96. package/dist/viem/Formatters.js.map +1 -0
  97. package/dist/viem/Tick.d.ts +111 -0
  98. package/dist/viem/Tick.d.ts.map +1 -0
  99. package/dist/viem/Tick.js +127 -0
  100. package/dist/viem/Tick.js.map +1 -0
  101. package/dist/viem/TokenIds.d.ts +3 -0
  102. package/dist/viem/TokenIds.d.ts.map +1 -0
  103. package/dist/viem/TokenIds.js +3 -0
  104. package/dist/viem/TokenIds.js.map +1 -0
  105. package/dist/viem/Transaction.d.ts +57 -0
  106. package/dist/viem/Transaction.d.ts.map +1 -0
  107. package/dist/viem/Transaction.js +137 -0
  108. package/dist/viem/Transaction.js.map +1 -0
  109. package/dist/viem/Transport.d.ts +16 -0
  110. package/dist/viem/Transport.d.ts.map +1 -0
  111. package/dist/viem/Transport.js +33 -0
  112. package/dist/viem/Transport.js.map +1 -0
  113. package/dist/viem/index.d.ts +14 -0
  114. package/dist/viem/index.d.ts.map +1 -0
  115. package/dist/viem/index.js +14 -0
  116. package/dist/viem/index.js.map +1 -0
  117. package/dist/viem/internal/types.d.ts +10 -0
  118. package/dist/viem/internal/types.d.ts.map +1 -0
  119. package/dist/viem/internal/types.js +2 -0
  120. package/dist/viem/internal/types.js.map +1 -0
  121. package/dist/viem/internal/utils.d.ts +8 -0
  122. package/dist/viem/internal/utils.d.ts.map +1 -0
  123. package/dist/viem/internal/utils.js +9 -0
  124. package/dist/viem/internal/utils.js.map +1 -0
  125. package/package.json +2 -2
@@ -0,0 +1,875 @@
1
+ import { parseEventLogs, } from 'viem';
2
+ import { parseAccount } from 'viem/accounts';
3
+ import { readContract, watchContractEvent, writeContract, writeContractSync, } from 'viem/actions';
4
+ import * as Abis from '../Abis.js';
5
+ import * as Addresses from '../Addresses.js';
6
+ import { defineCall } from '../internal/utils.js';
7
+ const policyTypeMap = {
8
+ whitelist: 0,
9
+ blacklist: 1,
10
+ };
11
+ /**
12
+ * Creates a new policy.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { createClient, http } from 'viem'
17
+ * import { tempo } from 'tempo.ts/chains'
18
+ * import * as actions from 'tempo.ts/viem/actions'
19
+ * import { privateKeyToAccount } from 'viem/accounts'
20
+ *
21
+ * const client = createClient({
22
+ * account: privateKeyToAccount('0x...'),
23
+ * chain: tempo,
24
+ * transport: http(),
25
+ * })
26
+ *
27
+ * const { hash, policyId } = await actions.policy.create(client, {
28
+ * admin: '0x...',
29
+ * type: 'whitelist',
30
+ * })
31
+ * ```
32
+ *
33
+ * @param client - Client.
34
+ * @param parameters - Parameters.
35
+ * @returns The transaction hash and policy ID.
36
+ */
37
+ export async function create(client, parameters) {
38
+ return create.inner(writeContract, client, parameters);
39
+ }
40
+ (function (create) {
41
+ /** @internal */
42
+ async function inner(action, client, parameters) {
43
+ const { account = client.account, addresses, chain = client.chain, type, ...rest } = parameters;
44
+ if (!account)
45
+ throw new Error('`account` is required');
46
+ const admin = parseAccount(account).address;
47
+ const call = create.call({ admin, type, addresses });
48
+ return action(client, {
49
+ ...rest,
50
+ account,
51
+ chain,
52
+ ...call,
53
+ });
54
+ }
55
+ create.inner = inner;
56
+ /**
57
+ * Defines a call to the `createPolicy` function.
58
+ *
59
+ * Can be passed as a parameter to:
60
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
61
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
62
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { createClient, http, walletActions } from 'viem'
67
+ * import { tempo } from 'tempo.ts/chains'
68
+ * import * as actions from 'tempo.ts/viem/actions'
69
+ *
70
+ * const client = createClient({
71
+ * chain: tempo,
72
+ * transport: http(),
73
+ * }).extend(walletActions)
74
+ *
75
+ * const { result } = await client.sendCalls({
76
+ * calls: [
77
+ * actions.policy.create.call({
78
+ * admin: '0xfeed...fede',
79
+ * type: 'whitelist',
80
+ * }),
81
+ * actions.policy.create.call({
82
+ * admin: '0xfeed...fede',
83
+ * type: 'blacklist',
84
+ * addresses: ['0x20c0...beef', '0x20c0...babe'],
85
+ * }),
86
+ * ]
87
+ * })
88
+ * ```
89
+ *
90
+ * @param args - Arguments.
91
+ * @returns The call.
92
+ */
93
+ function call(args) {
94
+ const { admin, type, addresses } = args;
95
+ const config = (() => {
96
+ if (addresses)
97
+ return {
98
+ functionName: 'createPolicyWithAccounts',
99
+ args: [admin, policyTypeMap[type], addresses],
100
+ };
101
+ return {
102
+ functionName: 'createPolicy',
103
+ args: [admin, policyTypeMap[type]],
104
+ };
105
+ })();
106
+ return defineCall({
107
+ address: Addresses.tip403Registry,
108
+ abi: Abis.tip403Registry,
109
+ ...config,
110
+ });
111
+ }
112
+ create.call = call;
113
+ /**
114
+ * Extracts the `PolicyCreated` event from logs.
115
+ *
116
+ * @param logs - The logs.
117
+ * @returns The `PolicyCreated` event.
118
+ */
119
+ function extractEvent(logs) {
120
+ const [log] = parseEventLogs({
121
+ abi: Abis.tip403Registry,
122
+ logs,
123
+ eventName: 'PolicyCreated',
124
+ strict: true,
125
+ });
126
+ if (!log)
127
+ throw new Error('`PolicyCreated` event not found.');
128
+ return log;
129
+ }
130
+ create.extractEvent = extractEvent;
131
+ })(create || (create = {}));
132
+ /**
133
+ * Creates a new policy.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import { createClient, http } from 'viem'
138
+ * import { tempo } from 'tempo.ts/chains'
139
+ * import * as actions from 'tempo.ts/viem/actions'
140
+ * import { privateKeyToAccount } from 'viem/accounts'
141
+ *
142
+ * const client = createClient({
143
+ * account: privateKeyToAccount('0x...'),
144
+ * chain: tempo,
145
+ * transport: http(),
146
+ * })
147
+ *
148
+ * const result = await actions.policy.createSync(client, {
149
+ * admin: '0x...',
150
+ * type: 'whitelist',
151
+ * })
152
+ * ```
153
+ *
154
+ * @param client - Client.
155
+ * @param parameters - Parameters.
156
+ * @returns The transaction receipt and event data.
157
+ */
158
+ export async function createSync(client, parameters) {
159
+ const { throwOnReceiptRevert = true, ...rest } = parameters;
160
+ const receipt = await create.inner(writeContractSync, client, {
161
+ ...rest,
162
+ throwOnReceiptRevert,
163
+ });
164
+ const { args } = create.extractEvent(receipt.logs);
165
+ return {
166
+ ...args,
167
+ receipt,
168
+ };
169
+ }
170
+ /**
171
+ * Sets the admin for a policy.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * import { createClient, http } from 'viem'
176
+ * import { tempo } from 'tempo.ts/chains'
177
+ * import * as actions from 'tempo.ts/viem/actions'
178
+ * import { privateKeyToAccount } from 'viem/accounts'
179
+ *
180
+ * const client = createClient({
181
+ * account: privateKeyToAccount('0x...'),
182
+ * chain: tempo,
183
+ * transport: http(),
184
+ * })
185
+ *
186
+ * const hash = await actions.policy.setAdmin(client, {
187
+ * policyId: 2n,
188
+ * admin: '0x...',
189
+ * })
190
+ * ```
191
+ *
192
+ * @param client - Client.
193
+ * @param parameters - Parameters.
194
+ * @returns The transaction hash.
195
+ */
196
+ export async function setAdmin(client, parameters) {
197
+ return setAdmin.inner(writeContract, client, parameters);
198
+ }
199
+ (function (setAdmin) {
200
+ /** @internal */
201
+ async function inner(action, client, parameters) {
202
+ const { policyId, admin, ...rest } = parameters;
203
+ const call = setAdmin.call({ policyId, admin });
204
+ return (await action(client, {
205
+ ...rest,
206
+ ...call,
207
+ }));
208
+ }
209
+ setAdmin.inner = inner;
210
+ /**
211
+ * Defines a call to the `setPolicyAdmin` function.
212
+ *
213
+ * Can be passed as a parameter to:
214
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
215
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
216
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { createClient, http, walletActions } from 'viem'
221
+ * import { tempo } from 'tempo.ts/chains'
222
+ * import * as actions from 'tempo.ts/viem/actions'
223
+ *
224
+ * const client = createClient({
225
+ * chain: tempo,
226
+ * transport: http(),
227
+ * }).extend(walletActions)
228
+ *
229
+ * const { result } = await client.sendCalls({
230
+ * calls: [
231
+ * actions.policy.setAdmin.call({
232
+ * policyId: 2n,
233
+ * admin: '0xfeed...fede',
234
+ * }),
235
+ * actions.policy.setAdmin.call({
236
+ * policyId: 3n,
237
+ * admin: '0xfeed...babe',
238
+ * }),
239
+ * ]
240
+ * })
241
+ * ```
242
+ *
243
+ * @param args - Arguments.
244
+ * @returns The call.
245
+ */
246
+ function call(args) {
247
+ const { policyId, admin } = args;
248
+ return defineCall({
249
+ address: Addresses.tip403Registry,
250
+ abi: Abis.tip403Registry,
251
+ functionName: 'setPolicyAdmin',
252
+ args: [policyId, admin],
253
+ });
254
+ }
255
+ setAdmin.call = call;
256
+ /**
257
+ * Extracts the `PolicyAdminUpdated` event from logs.
258
+ *
259
+ * @param logs - The logs.
260
+ * @returns The `PolicyAdminUpdated` event.
261
+ */
262
+ function extractEvent(logs) {
263
+ const [log] = parseEventLogs({
264
+ abi: Abis.tip403Registry,
265
+ logs,
266
+ eventName: 'PolicyAdminUpdated',
267
+ strict: true,
268
+ });
269
+ if (!log)
270
+ throw new Error('`PolicyAdminUpdated` event not found.');
271
+ return log;
272
+ }
273
+ setAdmin.extractEvent = extractEvent;
274
+ })(setAdmin || (setAdmin = {}));
275
+ /**
276
+ * Sets the admin for a policy.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * import { createClient, http } from 'viem'
281
+ * import { tempo } from 'tempo.ts/chains'
282
+ * import * as actions from 'tempo.ts/viem/actions'
283
+ * import { privateKeyToAccount } from 'viem/accounts'
284
+ *
285
+ * const client = createClient({
286
+ * account: privateKeyToAccount('0x...'),
287
+ * chain: tempo,
288
+ * transport: http(),
289
+ * })
290
+ *
291
+ * const result = await actions.policy.setAdminSync(client, {
292
+ * policyId: 2n,
293
+ * admin: '0x...',
294
+ * })
295
+ * ```
296
+ *
297
+ * @param client - Client.
298
+ * @param parameters - Parameters.
299
+ * @returns The transaction receipt and event data.
300
+ */
301
+ export async function setAdminSync(client, parameters) {
302
+ const { throwOnReceiptRevert = true, ...rest } = parameters;
303
+ const receipt = await setAdmin.inner(writeContractSync, client, {
304
+ ...rest,
305
+ throwOnReceiptRevert,
306
+ });
307
+ const { args } = setAdmin.extractEvent(receipt.logs);
308
+ return {
309
+ ...args,
310
+ receipt,
311
+ };
312
+ }
313
+ /**
314
+ * Modifies a policy whitelist.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * import { createClient, http } from 'viem'
319
+ * import { tempo } from 'tempo.ts/chains'
320
+ * import * as actions from 'tempo.ts/viem/actions'
321
+ * import { privateKeyToAccount } from 'viem/accounts'
322
+ *
323
+ * const client = createClient({
324
+ * account: privateKeyToAccount('0x...'),
325
+ * chain: tempo,
326
+ * transport: http(),
327
+ * })
328
+ *
329
+ * const hash = await actions.policy.modifyWhitelist(client, {
330
+ * policyId: 2n,
331
+ * account: '0x...',
332
+ * allowed: true,
333
+ * })
334
+ * ```
335
+ *
336
+ * @param client - Client.
337
+ * @param parameters - Parameters.
338
+ * @returns The transaction hash.
339
+ */
340
+ export async function modifyWhitelist(client, parameters) {
341
+ return modifyWhitelist.inner(writeContract, client, parameters);
342
+ }
343
+ (function (modifyWhitelist) {
344
+ /** @internal */
345
+ async function inner(action, client, parameters) {
346
+ const { address: targetAccount, allowed, policyId, ...rest } = parameters;
347
+ const call = modifyWhitelist.call({
348
+ address: targetAccount,
349
+ allowed,
350
+ policyId,
351
+ });
352
+ return (await action(client, {
353
+ ...rest,
354
+ ...call,
355
+ }));
356
+ }
357
+ modifyWhitelist.inner = inner;
358
+ /**
359
+ * Defines a call to the `modifyPolicyWhitelist` function.
360
+ *
361
+ * Can be passed as a parameter to:
362
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
363
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
364
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * import { createClient, http, walletActions } from 'viem'
369
+ * import { tempo } from 'tempo.ts/chains'
370
+ * import * as actions from 'tempo.ts/viem/actions'
371
+ *
372
+ * const client = createClient({
373
+ * chain: tempo,
374
+ * transport: http(),
375
+ * }).extend(walletActions)
376
+ *
377
+ * const { result } = await client.sendCalls({
378
+ * calls: [
379
+ * actions.policy.modifyWhitelist.call({
380
+ * policyId: 2n,
381
+ * address: '0x20c0...beef',
382
+ * allowed: true,
383
+ * }),
384
+ * actions.policy.modifyWhitelist.call({
385
+ * policyId: 2n,
386
+ * address: '0x20c0...babe',
387
+ * allowed: false,
388
+ * }),
389
+ * ]
390
+ * })
391
+ * ```
392
+ *
393
+ * @param args - Arguments.
394
+ * @returns The call.
395
+ */
396
+ function call(args) {
397
+ const { policyId, address, allowed } = args;
398
+ return defineCall({
399
+ address: Addresses.tip403Registry,
400
+ abi: Abis.tip403Registry,
401
+ functionName: 'modifyPolicyWhitelist',
402
+ args: [policyId, address, allowed],
403
+ });
404
+ }
405
+ modifyWhitelist.call = call;
406
+ /**
407
+ * Extracts the `WhitelistUpdated` event from logs.
408
+ *
409
+ * @param logs - The logs.
410
+ * @returns The `WhitelistUpdated` event.
411
+ */
412
+ function extractEvent(logs) {
413
+ const [log] = parseEventLogs({
414
+ abi: Abis.tip403Registry,
415
+ logs,
416
+ eventName: 'WhitelistUpdated',
417
+ strict: true,
418
+ });
419
+ if (!log)
420
+ throw new Error('`WhitelistUpdated` event not found.');
421
+ return log;
422
+ }
423
+ modifyWhitelist.extractEvent = extractEvent;
424
+ })(modifyWhitelist || (modifyWhitelist = {}));
425
+ /**
426
+ * Modifies a policy whitelist.
427
+ *
428
+ * @example
429
+ * ```ts
430
+ * import { createClient, http } from 'viem'
431
+ * import { tempo } from 'tempo.ts/chains'
432
+ * import * as actions from 'tempo.ts/viem/actions'
433
+ * import { privateKeyToAccount } from 'viem/accounts'
434
+ *
435
+ * const client = createClient({
436
+ * account: privateKeyToAccount('0x...'),
437
+ * chain: tempo,
438
+ * transport: http(),
439
+ * })
440
+ *
441
+ * const result = await actions.policy.modifyWhitelistSync(client, {
442
+ * policyId: 2n,
443
+ * account: '0x...',
444
+ * allowed: true,
445
+ * })
446
+ * ```
447
+ *
448
+ * @param client - Client.
449
+ * @param parameters - Parameters.
450
+ * @returns The transaction receipt and event data.
451
+ */
452
+ export async function modifyWhitelistSync(client, parameters) {
453
+ const { throwOnReceiptRevert = true, ...rest } = parameters;
454
+ const receipt = await modifyWhitelist.inner(writeContractSync, client, {
455
+ ...rest,
456
+ throwOnReceiptRevert,
457
+ });
458
+ const { args } = modifyWhitelist.extractEvent(receipt.logs);
459
+ return {
460
+ ...args,
461
+ receipt,
462
+ };
463
+ }
464
+ /**
465
+ * Modifies a policy blacklist.
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * import { createClient, http } from 'viem'
470
+ * import { tempo } from 'tempo.ts/chains'
471
+ * import * as actions from 'tempo.ts/viem/actions'
472
+ * import { privateKeyToAccount } from 'viem/accounts'
473
+ *
474
+ * const client = createClient({
475
+ * account: privateKeyToAccount('0x...'),
476
+ * chain: tempo,
477
+ * transport: http(),
478
+ * })
479
+ *
480
+ * const hash = await actions.policy.modifyBlacklist(client, {
481
+ * policyId: 2n,
482
+ * account: '0x...',
483
+ * restricted: true,
484
+ * })
485
+ * ```
486
+ *
487
+ * @param client - Client.
488
+ * @param parameters - Parameters.
489
+ * @returns The transaction hash.
490
+ */
491
+ export async function modifyBlacklist(client, parameters) {
492
+ return modifyBlacklist.inner(writeContract, client, parameters);
493
+ }
494
+ (function (modifyBlacklist) {
495
+ /** @internal */
496
+ async function inner(action, client, parameters) {
497
+ const { address: targetAccount, policyId, restricted, ...rest } = parameters;
498
+ const call = modifyBlacklist.call({
499
+ address: targetAccount,
500
+ policyId,
501
+ restricted,
502
+ });
503
+ return (await action(client, {
504
+ ...rest,
505
+ ...call,
506
+ }));
507
+ }
508
+ modifyBlacklist.inner = inner;
509
+ /**
510
+ * Defines a call to the `modifyPolicyBlacklist` function.
511
+ *
512
+ * Can be passed as a parameter to:
513
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
514
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
515
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
516
+ *
517
+ * @example
518
+ * ```ts
519
+ * import { createClient, http, walletActions } from 'viem'
520
+ * import { tempo } from 'tempo.ts/chains'
521
+ * import * as actions from 'tempo.ts/viem/actions'
522
+ *
523
+ * const client = createClient({
524
+ * chain: tempo,
525
+ * transport: http(),
526
+ * }).extend(walletActions)
527
+ *
528
+ * const { result } = await client.sendCalls({
529
+ * calls: [
530
+ * actions.policy.modifyBlacklist.call({
531
+ * policyId: 2n,
532
+ * address: '0x20c0...beef',
533
+ * restricted: true,
534
+ * }),
535
+ * actions.policy.modifyBlacklist.call({
536
+ * policyId: 2n,
537
+ * address: '0x20c0...babe',
538
+ * restricted: false,
539
+ * }),
540
+ * ]
541
+ * })
542
+ * ```
543
+ *
544
+ * @param args - Arguments.
545
+ * @returns The call.
546
+ */
547
+ function call(args) {
548
+ const { policyId, address, restricted } = args;
549
+ return defineCall({
550
+ address: Addresses.tip403Registry,
551
+ abi: Abis.tip403Registry,
552
+ functionName: 'modifyPolicyBlacklist',
553
+ args: [policyId, address, restricted],
554
+ });
555
+ }
556
+ modifyBlacklist.call = call;
557
+ /**
558
+ * Extracts the `BlacklistUpdated` event from logs.
559
+ *
560
+ * @param logs - The logs.
561
+ * @returns The `BlacklistUpdated` event.
562
+ */
563
+ function extractEvent(logs) {
564
+ const [log] = parseEventLogs({
565
+ abi: Abis.tip403Registry,
566
+ logs,
567
+ eventName: 'BlacklistUpdated',
568
+ strict: true,
569
+ });
570
+ if (!log)
571
+ throw new Error('`BlacklistUpdated` event not found.');
572
+ return log;
573
+ }
574
+ modifyBlacklist.extractEvent = extractEvent;
575
+ })(modifyBlacklist || (modifyBlacklist = {}));
576
+ /**
577
+ * Modifies a policy blacklist.
578
+ *
579
+ * @example
580
+ * ```ts
581
+ * import { createClient, http } from 'viem'
582
+ * import { tempo } from 'tempo.ts/chains'
583
+ * import * as actions from 'tempo.ts/viem/actions'
584
+ * import { privateKeyToAccount } from 'viem/accounts'
585
+ *
586
+ * const client = createClient({
587
+ * account: privateKeyToAccount('0x...'),
588
+ * chain: tempo,
589
+ * transport: http(),
590
+ * })
591
+ *
592
+ * const result = await actions.policy.modifyBlacklistSync(client, {
593
+ * policyId: 2n,
594
+ * account: '0x...',
595
+ * restricted: true,
596
+ * })
597
+ * ```
598
+ *
599
+ * @param client - Client.
600
+ * @param parameters - Parameters.
601
+ * @returns The transaction receipt and event data.
602
+ */
603
+ export async function modifyBlacklistSync(client, parameters) {
604
+ const { throwOnReceiptRevert = true, ...rest } = parameters;
605
+ const receipt = await modifyBlacklist.inner(writeContractSync, client, {
606
+ ...rest,
607
+ throwOnReceiptRevert,
608
+ });
609
+ const { args } = modifyBlacklist.extractEvent(receipt.logs);
610
+ return {
611
+ ...args,
612
+ receipt,
613
+ };
614
+ }
615
+ /**
616
+ * Gets policy data.
617
+ *
618
+ * @example
619
+ * ```ts
620
+ * import { createClient, http } from 'viem'
621
+ * import { tempo } from 'tempo.ts/chains'
622
+ * import * as actions from 'tempo.ts/viem/actions'
623
+ *
624
+ * const client = createClient({
625
+ * chain: tempo,
626
+ * transport: http(),
627
+ * })
628
+ *
629
+ * const data = await actions.policy.getData(client, {
630
+ * policyId: 2n,
631
+ * })
632
+ * ```
633
+ *
634
+ * @param client - Client.
635
+ * @param parameters - Parameters.
636
+ * @returns The policy data.
637
+ */
638
+ export async function getData(client, parameters) {
639
+ const { policyId, ...rest } = parameters;
640
+ const result = await readContract(client, {
641
+ ...rest,
642
+ ...getData.call({ policyId }),
643
+ });
644
+ return {
645
+ admin: result[1],
646
+ type: result[0] === 0 ? 'whitelist' : 'blacklist',
647
+ };
648
+ }
649
+ (function (getData) {
650
+ /**
651
+ * Defines a call to the `policyData` function.
652
+ *
653
+ * @param args - Arguments.
654
+ * @returns The call.
655
+ */
656
+ function call(args) {
657
+ const { policyId } = args;
658
+ return defineCall({
659
+ address: Addresses.tip403Registry,
660
+ abi: Abis.tip403Registry,
661
+ args: [policyId],
662
+ functionName: 'policyData',
663
+ });
664
+ }
665
+ getData.call = call;
666
+ })(getData || (getData = {}));
667
+ /**
668
+ * Checks if a user is authorized by a policy.
669
+ *
670
+ * @example
671
+ * ```ts
672
+ * import { createClient, http } from 'viem'
673
+ * import { tempo } from 'tempo.ts/chains'
674
+ * import * as actions from 'tempo.ts/viem/actions'
675
+ *
676
+ * const client = createClient({
677
+ * chain: tempo,
678
+ * transport: http(),
679
+ * })
680
+ *
681
+ * const authorized = await actions.policy.isAuthorized(client, {
682
+ * policyId: 2n,
683
+ * user: '0x...',
684
+ * })
685
+ * ```
686
+ *
687
+ * @param client - Client.
688
+ * @param parameters - Parameters.
689
+ * @returns Whether the user is authorized.
690
+ */
691
+ export async function isAuthorized(client, parameters) {
692
+ const { policyId, user, ...rest } = parameters;
693
+ return readContract(client, {
694
+ ...rest,
695
+ ...isAuthorized.call({ policyId, user }),
696
+ });
697
+ }
698
+ (function (isAuthorized) {
699
+ /**
700
+ * Defines a call to the `isAuthorized` function.
701
+ *
702
+ * @param args - Arguments.
703
+ * @returns The call.
704
+ */
705
+ function call(args) {
706
+ const { policyId, user } = args;
707
+ return defineCall({
708
+ address: Addresses.tip403Registry,
709
+ abi: Abis.tip403Registry,
710
+ args: [policyId, user],
711
+ functionName: 'isAuthorized',
712
+ });
713
+ }
714
+ isAuthorized.call = call;
715
+ })(isAuthorized || (isAuthorized = {}));
716
+ /**
717
+ * Watches for policy creation events.
718
+ *
719
+ * @example
720
+ * ```ts
721
+ * import { createClient, http } from 'viem'
722
+ * import { tempo } from 'tempo.ts/chains'
723
+ * import * as actions from 'tempo.ts/viem/actions'
724
+ *
725
+ * const client = createClient({
726
+ * chain: tempo,
727
+ * transport: http(),
728
+ * })
729
+ *
730
+ * const unwatch = actions.policy.watchCreate(client, {
731
+ * onPolicyCreated: (args, log) => {
732
+ * console.log('Policy created:', args)
733
+ * },
734
+ * })
735
+ * ```
736
+ *
737
+ * @param client - Client.
738
+ * @param parameters - Parameters.
739
+ * @returns A function to unsubscribe from the event.
740
+ */
741
+ export function watchCreate(client, parameters) {
742
+ const { onPolicyCreated, ...rest } = parameters;
743
+ return watchContractEvent(client, {
744
+ ...rest,
745
+ address: Addresses.tip403Registry,
746
+ abi: Abis.tip403Registry,
747
+ eventName: 'PolicyCreated',
748
+ onLogs: (logs) => {
749
+ for (const log of logs)
750
+ onPolicyCreated({
751
+ ...log.args,
752
+ type: log.args.policyType === 0 ? 'whitelist' : 'blacklist',
753
+ }, log);
754
+ },
755
+ strict: true,
756
+ });
757
+ }
758
+ /**
759
+ * Watches for policy admin update events.
760
+ *
761
+ * @example
762
+ * ```ts
763
+ * import { createClient, http } from 'viem'
764
+ * import { tempo } from 'tempo.ts/chains'
765
+ * import * as actions from 'tempo.ts/viem/actions'
766
+ *
767
+ * const client = createClient({
768
+ * chain: tempo,
769
+ * transport: http(),
770
+ * })
771
+ *
772
+ * const unwatch = actions.policy.watchAdminUpdated(client, {
773
+ * onAdminUpdated: (args, log) => {
774
+ * console.log('Policy admin updated:', args)
775
+ * },
776
+ * })
777
+ * ```
778
+ *
779
+ * @param client - Client.
780
+ * @param parameters - Parameters.
781
+ * @returns A function to unsubscribe from the event.
782
+ */
783
+ export function watchAdminUpdated(client, parameters) {
784
+ const { onAdminUpdated, ...rest } = parameters;
785
+ return watchContractEvent(client, {
786
+ ...rest,
787
+ address: Addresses.tip403Registry,
788
+ abi: Abis.tip403Registry,
789
+ eventName: 'PolicyAdminUpdated',
790
+ onLogs: (logs) => {
791
+ for (const log of logs)
792
+ onAdminUpdated(log.args, log);
793
+ },
794
+ strict: true,
795
+ });
796
+ }
797
+ /**
798
+ * Watches for whitelist update events.
799
+ *
800
+ * @example
801
+ * ```ts
802
+ * import { createClient, http } from 'viem'
803
+ * import { tempo } from 'tempo.ts/chains'
804
+ * import * as actions from 'tempo.ts/viem/actions'
805
+ *
806
+ * const client = createClient({
807
+ * chain: tempo,
808
+ * transport: http(),
809
+ * })
810
+ *
811
+ * const unwatch = actions.policy.watchWhitelistUpdated(client, {
812
+ * onWhitelistUpdated: (args, log) => {
813
+ * console.log('Whitelist updated:', args)
814
+ * },
815
+ * })
816
+ * ```
817
+ *
818
+ * @param client - Client.
819
+ * @param parameters - Parameters.
820
+ * @returns A function to unsubscribe from the event.
821
+ */
822
+ export function watchWhitelistUpdated(client, parameters) {
823
+ const { onWhitelistUpdated, ...rest } = parameters;
824
+ return watchContractEvent(client, {
825
+ ...rest,
826
+ address: Addresses.tip403Registry,
827
+ abi: Abis.tip403Registry,
828
+ eventName: 'WhitelistUpdated',
829
+ onLogs: (logs) => {
830
+ for (const log of logs)
831
+ onWhitelistUpdated(log.args, log);
832
+ },
833
+ strict: true,
834
+ });
835
+ }
836
+ /**
837
+ * Watches for blacklist update events.
838
+ *
839
+ * @example
840
+ * ```ts
841
+ * import { createClient, http } from 'viem'
842
+ * import { tempo } from 'tempo.ts/chains'
843
+ * import * as actions from 'tempo.ts/viem/actions'
844
+ *
845
+ * const client = createClient({
846
+ * chain: tempo,
847
+ * transport: http(),
848
+ * })
849
+ *
850
+ * const unwatch = actions.policy.watchBlacklistUpdated(client, {
851
+ * onBlacklistUpdated: (args, log) => {
852
+ * console.log('Blacklist updated:', args)
853
+ * },
854
+ * })
855
+ * ```
856
+ *
857
+ * @param client - Client.
858
+ * @param parameters - Parameters.
859
+ * @returns A function to unsubscribe from the event.
860
+ */
861
+ export function watchBlacklistUpdated(client, parameters) {
862
+ const { onBlacklistUpdated, ...rest } = parameters;
863
+ return watchContractEvent(client, {
864
+ ...rest,
865
+ address: Addresses.tip403Registry,
866
+ abi: Abis.tip403Registry,
867
+ eventName: 'BlacklistUpdated',
868
+ onLogs: (logs) => {
869
+ for (const log of logs)
870
+ onBlacklistUpdated(log.args, log);
871
+ },
872
+ strict: true,
873
+ });
874
+ }
875
+ //# sourceMappingURL=policy.js.map