viem 2.44.2 → 2.44.4

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 (101) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_cjs/actions/wallet/sendTransaction.js +6 -5
  3. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  4. package/_cjs/actions/wallet/sendTransactionSync.js +6 -5
  5. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  6. package/_cjs/errors/version.js +1 -1
  7. package/_cjs/tempo/Abis.js +2 -2
  8. package/_cjs/tempo/Abis.js.map +1 -1
  9. package/_cjs/tempo/Addresses.js +2 -1
  10. package/_cjs/tempo/Addresses.js.map +1 -1
  11. package/_cjs/tempo/Decorator.js +19 -0
  12. package/_cjs/tempo/Decorator.js.map +1 -1
  13. package/_cjs/tempo/Transport.js +1 -1
  14. package/_cjs/tempo/Transport.js.map +1 -1
  15. package/_cjs/tempo/actions/fee.js +91 -0
  16. package/_cjs/tempo/actions/fee.js.map +1 -1
  17. package/_cjs/tempo/actions/index.js +2 -1
  18. package/_cjs/tempo/actions/index.js.map +1 -1
  19. package/_cjs/tempo/actions/validator.js +308 -0
  20. package/_cjs/tempo/actions/validator.js.map +1 -0
  21. package/_cjs/utils/abi/decodeEventLog.js +29 -12
  22. package/_cjs/utils/abi/decodeEventLog.js.map +1 -1
  23. package/_esm/actions/wallet/sendTransaction.js +6 -5
  24. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  25. package/_esm/actions/wallet/sendTransactionSync.js +6 -5
  26. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  27. package/_esm/errors/version.js +1 -1
  28. package/_esm/tempo/Abis.js +1 -1
  29. package/_esm/tempo/Abis.js.map +1 -1
  30. package/_esm/tempo/Account.js +6 -6
  31. package/_esm/tempo/Addresses.js +1 -0
  32. package/_esm/tempo/Addresses.js.map +1 -1
  33. package/_esm/tempo/Decorator.js +19 -0
  34. package/_esm/tempo/Decorator.js.map +1 -1
  35. package/_esm/tempo/Transport.js +1 -1
  36. package/_esm/tempo/Transport.js.map +1 -1
  37. package/_esm/tempo/WebAuthnP256.js +2 -2
  38. package/_esm/tempo/actions/amm.js +28 -28
  39. package/_esm/tempo/actions/dex.js +68 -68
  40. package/_esm/tempo/actions/faucet.js +4 -4
  41. package/_esm/tempo/actions/fee.js +236 -10
  42. package/_esm/tempo/actions/fee.js.map +1 -1
  43. package/_esm/tempo/actions/index.js +1 -0
  44. package/_esm/tempo/actions/index.js.map +1 -1
  45. package/_esm/tempo/actions/nonce.js +4 -4
  46. package/_esm/tempo/actions/policy.js +36 -36
  47. package/_esm/tempo/actions/reward.js +28 -28
  48. package/_esm/tempo/actions/token.js +122 -122
  49. package/_esm/tempo/actions/validator.js +1017 -0
  50. package/_esm/tempo/actions/validator.js.map +1 -0
  51. package/_esm/utils/abi/decodeEventLog.js +34 -13
  52. package/_esm/utils/abi/decodeEventLog.js.map +1 -1
  53. package/_types/actions/wallet/sendTransaction.d.ts +4 -1
  54. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  55. package/_types/actions/wallet/sendTransactionSync.d.ts +2 -0
  56. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  57. package/_types/errors/version.d.ts +1 -1
  58. package/_types/tempo/Abis.d.ts +1 -1
  59. package/_types/tempo/Abis.d.ts.map +1 -1
  60. package/_types/tempo/Account.d.ts +6 -6
  61. package/_types/tempo/Addresses.d.ts +1 -0
  62. package/_types/tempo/Addresses.d.ts.map +1 -1
  63. package/_types/tempo/Decorator.d.ts +607 -208
  64. package/_types/tempo/Decorator.d.ts.map +1 -1
  65. package/_types/tempo/Transport.d.ts.map +1 -1
  66. package/_types/tempo/WebAuthnP256.d.ts +2 -2
  67. package/_types/tempo/actions/amm.d.ts +28 -28
  68. package/_types/tempo/actions/dex.d.ts +68 -68
  69. package/_types/tempo/actions/faucet.d.ts +4 -4
  70. package/_types/tempo/actions/fee.d.ts +380 -10
  71. package/_types/tempo/actions/fee.d.ts.map +1 -1
  72. package/_types/tempo/actions/index.d.ts +1 -0
  73. package/_types/tempo/actions/index.d.ts.map +1 -1
  74. package/_types/tempo/actions/nonce.d.ts +4 -4
  75. package/_types/tempo/actions/policy.d.ts +36 -36
  76. package/_types/tempo/actions/reward.d.ts +28 -28
  77. package/_types/tempo/actions/token.d.ts +122 -122
  78. package/_types/tempo/actions/validator.d.ts +1174 -0
  79. package/_types/tempo/actions/validator.d.ts.map +1 -0
  80. package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
  81. package/actions/wallet/sendTransaction.ts +10 -5
  82. package/actions/wallet/sendTransactionSync.ts +8 -4
  83. package/errors/version.ts +1 -1
  84. package/package.json +1 -1
  85. package/tempo/Abis.ts +1 -1
  86. package/tempo/Account.ts +6 -6
  87. package/tempo/Addresses.ts +1 -0
  88. package/tempo/Decorator.ts +672 -208
  89. package/tempo/Transport.ts +4 -1
  90. package/tempo/WebAuthnP256.ts +2 -2
  91. package/tempo/actions/amm.ts +28 -28
  92. package/tempo/actions/dex.ts +68 -68
  93. package/tempo/actions/faucet.ts +4 -4
  94. package/tempo/actions/fee.ts +346 -10
  95. package/tempo/actions/index.ts +1 -0
  96. package/tempo/actions/nonce.ts +4 -4
  97. package/tempo/actions/policy.ts +36 -36
  98. package/tempo/actions/reward.ts +28 -28
  99. package/tempo/actions/token.ts +122 -122
  100. package/tempo/actions/validator.ts +1417 -0
  101. package/utils/abi/decodeEventLog.ts +38 -14
@@ -0,0 +1,1417 @@
1
+ import type { Address } from 'abitype'
2
+ import type { Hex } from 'ox/Hex'
3
+ import type { Account } from '../../accounts/types.js'
4
+ import type { ReadContractReturnType } from '../../actions/public/readContract.js'
5
+ import { readContract } from '../../actions/public/readContract.js'
6
+ import type { WriteContractReturnType } from '../../actions/wallet/writeContract.js'
7
+ import { writeContract } from '../../actions/wallet/writeContract.js'
8
+ import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
9
+ import type { Client } from '../../clients/createClient.js'
10
+ import type { Transport } from '../../clients/transports/createTransport.js'
11
+ import type { BaseErrorType } from '../../errors/base.js'
12
+ import type { Chain } from '../../types/chain.js'
13
+ import type { TransactionReceipt } from '../../types/transaction.js'
14
+ import * as Abis from '../Abis.js'
15
+ import * as Addresses from '../Addresses.js'
16
+ import type { ReadParameters, WriteParameters } from '../internal/types.js'
17
+ import { defineCall } from '../internal/utils.js'
18
+
19
+ /**
20
+ * Adds a new validator (owner only).
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createClient, http } from 'viem'
25
+ * import { tempo } from 'viem/chains'
26
+ * import { Actions } from 'viem/tempo'
27
+ * import { privateKeyToAccount } from 'viem/accounts'
28
+ *
29
+ * const client = createClient({
30
+ * account: privateKeyToAccount('0x...'),
31
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
32
+ * transport: http(),
33
+ * })
34
+ *
35
+ * const hash = await Actions.validator.add(client, {
36
+ * newValidatorAddress: '0x...',
37
+ * publicKey: '0x...',
38
+ * active: true,
39
+ * inboundAddress: '192.168.1.1:8080',
40
+ * outboundAddress: '192.168.1.1:8080',
41
+ * })
42
+ * ```
43
+ *
44
+ * @param client - Client.
45
+ * @param parameters - Parameters.
46
+ * @returns The transaction hash.
47
+ */
48
+ export async function add<
49
+ chain extends Chain | undefined,
50
+ account extends Account | undefined,
51
+ >(
52
+ client: Client<Transport, chain, account>,
53
+ parameters: add.Parameters<chain, account>,
54
+ ): Promise<add.ReturnValue> {
55
+ return add.inner(writeContract, client, parameters)
56
+ }
57
+
58
+ export namespace add {
59
+ export type Parameters<
60
+ chain extends Chain | undefined = Chain | undefined,
61
+ account extends Account | undefined = Account | undefined,
62
+ > = WriteParameters<chain, account> & Args
63
+
64
+ export type Args = {
65
+ /** The address of the new validator. */
66
+ newValidatorAddress: Address
67
+ /** The validator's communication public key. */
68
+ publicKey: Hex
69
+ /** Whether the validator should be active. */
70
+ active: boolean
71
+ /** The validator's inbound address `<hostname|ip>:<port>` for incoming connections. */
72
+ inboundAddress: string
73
+ /** The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames). */
74
+ outboundAddress: string
75
+ }
76
+
77
+ export type ReturnValue = WriteContractReturnType
78
+
79
+ // TODO: exhaustive error type
80
+ export type ErrorType = BaseErrorType
81
+
82
+ /** @internal */
83
+ export async function inner<
84
+ action extends typeof writeContract | typeof writeContractSync,
85
+ chain extends Chain | undefined,
86
+ account extends Account | undefined,
87
+ >(
88
+ action: action,
89
+ client: Client<Transport, chain, account>,
90
+ parameters: Parameters<chain, account>,
91
+ ): Promise<ReturnType<action>> {
92
+ const {
93
+ newValidatorAddress,
94
+ publicKey,
95
+ active,
96
+ inboundAddress,
97
+ outboundAddress,
98
+ ...rest
99
+ } = parameters
100
+ const callData = add.call({
101
+ newValidatorAddress,
102
+ publicKey,
103
+ active,
104
+ inboundAddress,
105
+ outboundAddress,
106
+ })
107
+ return (await action(client, {
108
+ ...rest,
109
+ ...callData,
110
+ } as never)) as never
111
+ }
112
+
113
+ /**
114
+ * Defines a call to the `addValidator` function.
115
+ *
116
+ * Can be passed as a parameter to:
117
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
118
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
119
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { createClient, http, walletActions } from 'viem'
124
+ * import { tempo } from 'viem/chains'
125
+ * import { Actions } from 'viem/tempo'
126
+ *
127
+ * const client = createClient({
128
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
129
+ * transport: http(),
130
+ * }).extend(walletActions)
131
+ *
132
+ * const { result } = await client.sendCalls({
133
+ * calls: [
134
+ * Actions.validator.add.call({
135
+ * newValidatorAddress: '0x...',
136
+ * publicKey: '0x...',
137
+ * active: true,
138
+ * inboundAddress: '192.168.1.1:8080',
139
+ * outboundAddress: '192.168.1.1:8080',
140
+ * }),
141
+ * ],
142
+ * })
143
+ * ```
144
+ *
145
+ * @param args - Arguments.
146
+ * @returns The call.
147
+ */
148
+ export function call(args: Args) {
149
+ const {
150
+ newValidatorAddress,
151
+ publicKey,
152
+ active,
153
+ inboundAddress,
154
+ outboundAddress,
155
+ } = args
156
+ return defineCall({
157
+ address: Addresses.validator,
158
+ abi: Abis.validator,
159
+ args: [
160
+ newValidatorAddress,
161
+ publicKey,
162
+ active,
163
+ inboundAddress,
164
+ outboundAddress,
165
+ ],
166
+ functionName: 'addValidator',
167
+ })
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Adds a new validator (owner only) and waits for the transaction receipt.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * import { createClient, http } from 'viem'
177
+ * import { tempo } from 'viem/chains'
178
+ * import { Actions } from 'viem/tempo'
179
+ * import { privateKeyToAccount } from 'viem/accounts'
180
+ *
181
+ * const client = createClient({
182
+ * account: privateKeyToAccount('0x...'),
183
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
184
+ * transport: http(),
185
+ * })
186
+ *
187
+ * const { receipt } = await Actions.validator.addSync(client, {
188
+ * newValidatorAddress: '0x...',
189
+ * publicKey: '0x...',
190
+ * active: true,
191
+ * inboundAddress: '192.168.1.1:8080',
192
+ * outboundAddress: '192.168.1.1:8080',
193
+ * })
194
+ * ```
195
+ *
196
+ * @param client - Client.
197
+ * @param parameters - Parameters.
198
+ * @returns The transaction receipt.
199
+ */
200
+ export async function addSync<
201
+ chain extends Chain | undefined,
202
+ account extends Account | undefined,
203
+ >(
204
+ client: Client<Transport, chain, account>,
205
+ parameters: addSync.Parameters<chain, account>,
206
+ ): Promise<addSync.ReturnValue> {
207
+ const { throwOnReceiptRevert = true, ...rest } = parameters
208
+ const receipt = await add.inner(writeContractSync, client, {
209
+ ...rest,
210
+ throwOnReceiptRevert,
211
+ } as never)
212
+ return { receipt }
213
+ }
214
+
215
+ export namespace addSync {
216
+ export type Parameters<
217
+ chain extends Chain | undefined = Chain | undefined,
218
+ account extends Account | undefined = Account | undefined,
219
+ > = add.Parameters<chain, account>
220
+
221
+ export type Args = add.Args
222
+
223
+ export type ReturnValue = {
224
+ receipt: TransactionReceipt
225
+ }
226
+ }
227
+
228
+ /**
229
+ * Changes the owner of the validator config precompile.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * import { createClient, http } from 'viem'
234
+ * import { tempo } from 'viem/chains'
235
+ * import { Actions } from 'viem/tempo'
236
+ * import { privateKeyToAccount } from 'viem/accounts'
237
+ *
238
+ * const client = createClient({
239
+ * account: privateKeyToAccount('0x...'),
240
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
241
+ * transport: http(),
242
+ * })
243
+ *
244
+ * const hash = await Actions.validator.changeOwner(client, {
245
+ * newOwner: '0x...',
246
+ * })
247
+ * ```
248
+ *
249
+ * @param client - Client.
250
+ * @param parameters - Parameters.
251
+ * @returns The transaction hash.
252
+ */
253
+ export async function changeOwner<
254
+ chain extends Chain | undefined,
255
+ account extends Account | undefined,
256
+ >(
257
+ client: Client<Transport, chain, account>,
258
+ parameters: changeOwner.Parameters<chain, account>,
259
+ ): Promise<changeOwner.ReturnValue> {
260
+ return changeOwner.inner(writeContract, client, parameters)
261
+ }
262
+
263
+ export namespace changeOwner {
264
+ export type Parameters<
265
+ chain extends Chain | undefined = Chain | undefined,
266
+ account extends Account | undefined = Account | undefined,
267
+ > = WriteParameters<chain, account> & Args
268
+
269
+ export type Args = {
270
+ /** The new owner address. */
271
+ newOwner: Address
272
+ }
273
+
274
+ export type ReturnValue = WriteContractReturnType
275
+
276
+ // TODO: exhaustive error type
277
+ export type ErrorType = BaseErrorType
278
+
279
+ /** @internal */
280
+ export async function inner<
281
+ action extends typeof writeContract | typeof writeContractSync,
282
+ chain extends Chain | undefined,
283
+ account extends Account | undefined,
284
+ >(
285
+ action: action,
286
+ client: Client<Transport, chain, account>,
287
+ parameters: Parameters<chain, account>,
288
+ ): Promise<ReturnType<action>> {
289
+ const { newOwner, ...rest } = parameters
290
+ const callData = changeOwner.call({ newOwner })
291
+ return (await action(client, {
292
+ ...rest,
293
+ ...callData,
294
+ } as never)) as never
295
+ }
296
+
297
+ /**
298
+ * Defines a call to the `changeOwner` function.
299
+ *
300
+ * Can be passed as a parameter to:
301
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
302
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
303
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * import { createClient, http, walletActions } from 'viem'
308
+ * import { tempo } from 'viem/chains'
309
+ * import { Actions } from 'viem/tempo'
310
+ *
311
+ * const client = createClient({
312
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
313
+ * transport: http(),
314
+ * }).extend(walletActions)
315
+ *
316
+ * const { result } = await client.sendCalls({
317
+ * calls: [
318
+ * Actions.validator.changeOwner.call({
319
+ * newOwner: '0x...',
320
+ * }),
321
+ * ],
322
+ * })
323
+ * ```
324
+ *
325
+ * @param args - Arguments.
326
+ * @returns The call.
327
+ */
328
+ export function call(args: Args) {
329
+ const { newOwner } = args
330
+ return defineCall({
331
+ address: Addresses.validator,
332
+ abi: Abis.validator,
333
+ args: [newOwner],
334
+ functionName: 'changeOwner',
335
+ })
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Changes the owner and waits for the transaction receipt.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * import { createClient, http } from 'viem'
345
+ * import { tempo } from 'viem/chains'
346
+ * import { Actions } from 'viem/tempo'
347
+ * import { privateKeyToAccount } from 'viem/accounts'
348
+ *
349
+ * const client = createClient({
350
+ * account: privateKeyToAccount('0x...'),
351
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
352
+ * transport: http(),
353
+ * })
354
+ *
355
+ * const { receipt } = await Actions.validator.changeOwnerSync(client, {
356
+ * newOwner: '0x...',
357
+ * })
358
+ * ```
359
+ *
360
+ * @param client - Client.
361
+ * @param parameters - Parameters.
362
+ * @returns The transaction receipt.
363
+ */
364
+ export async function changeOwnerSync<
365
+ chain extends Chain | undefined,
366
+ account extends Account | undefined,
367
+ >(
368
+ client: Client<Transport, chain, account>,
369
+ parameters: changeOwnerSync.Parameters<chain, account>,
370
+ ): Promise<changeOwnerSync.ReturnValue> {
371
+ const { throwOnReceiptRevert = true, ...rest } = parameters
372
+ const receipt = await changeOwner.inner(writeContractSync, client, {
373
+ ...rest,
374
+ throwOnReceiptRevert,
375
+ } as never)
376
+ return { receipt }
377
+ }
378
+
379
+ export namespace changeOwnerSync {
380
+ export type Parameters<
381
+ chain extends Chain | undefined = Chain | undefined,
382
+ account extends Account | undefined = Account | undefined,
383
+ > = changeOwner.Parameters<chain, account>
384
+
385
+ export type Args = changeOwner.Args
386
+
387
+ export type ReturnValue = {
388
+ receipt: TransactionReceipt
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Changes validator active status (owner only).
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * import { createClient, http } from 'viem'
398
+ * import { tempo } from 'viem/chains'
399
+ * import { Actions } from 'viem/tempo'
400
+ * import { privateKeyToAccount } from 'viem/accounts'
401
+ *
402
+ * const client = createClient({
403
+ * account: privateKeyToAccount('0x...'),
404
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
405
+ * transport: http(),
406
+ * })
407
+ *
408
+ * const hash = await Actions.validator.changeStatus(client, {
409
+ * validator: '0x...',
410
+ * active: false,
411
+ * })
412
+ * ```
413
+ *
414
+ * @param client - Client.
415
+ * @param parameters - Parameters.
416
+ * @returns The transaction hash.
417
+ */
418
+ export async function changeStatus<
419
+ chain extends Chain | undefined,
420
+ account extends Account | undefined,
421
+ >(
422
+ client: Client<Transport, chain, account>,
423
+ parameters: changeStatus.Parameters<chain, account>,
424
+ ): Promise<changeStatus.ReturnValue> {
425
+ return changeStatus.inner(writeContract, client, parameters)
426
+ }
427
+
428
+ export namespace changeStatus {
429
+ export type Parameters<
430
+ chain extends Chain | undefined = Chain | undefined,
431
+ account extends Account | undefined = Account | undefined,
432
+ > = WriteParameters<chain, account> & Args
433
+
434
+ export type Args = {
435
+ /** The validator address. */
436
+ validator: Address
437
+ /** Whether the validator should be active. */
438
+ active: boolean
439
+ }
440
+
441
+ export type ReturnValue = WriteContractReturnType
442
+
443
+ // TODO: exhaustive error type
444
+ export type ErrorType = BaseErrorType
445
+
446
+ /** @internal */
447
+ export async function inner<
448
+ action extends typeof writeContract | typeof writeContractSync,
449
+ chain extends Chain | undefined,
450
+ account extends Account | undefined,
451
+ >(
452
+ action: action,
453
+ client: Client<Transport, chain, account>,
454
+ parameters: Parameters<chain, account>,
455
+ ): Promise<ReturnType<action>> {
456
+ const { validator, active, ...rest } = parameters
457
+ const callData = changeStatus.call({ validator, active })
458
+ return (await action(client, {
459
+ ...rest,
460
+ ...callData,
461
+ } as never)) as never
462
+ }
463
+
464
+ /**
465
+ * Defines a call to the `changeValidatorStatus` function.
466
+ *
467
+ * Can be passed as a parameter to:
468
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
469
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
470
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * import { createClient, http, walletActions } from 'viem'
475
+ * import { tempo } from 'viem/chains'
476
+ * import { Actions } from 'viem/tempo'
477
+ *
478
+ * const client = createClient({
479
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
480
+ * transport: http(),
481
+ * }).extend(walletActions)
482
+ *
483
+ * const { result } = await client.sendCalls({
484
+ * calls: [
485
+ * Actions.validator.changeStatus.call({
486
+ * validator: '0x...',
487
+ * active: false,
488
+ * }),
489
+ * ],
490
+ * })
491
+ * ```
492
+ *
493
+ * @param args - Arguments.
494
+ * @returns The call.
495
+ */
496
+ export function call(args: Args) {
497
+ const { validator, active } = args
498
+ return defineCall({
499
+ address: Addresses.validator,
500
+ abi: Abis.validator,
501
+ args: [validator, active],
502
+ functionName: 'changeValidatorStatus',
503
+ })
504
+ }
505
+ }
506
+
507
+ /**
508
+ * Changes validator active status and waits for the transaction receipt.
509
+ *
510
+ * @example
511
+ * ```ts
512
+ * import { createClient, http } from 'viem'
513
+ * import { tempo } from 'viem/chains'
514
+ * import { Actions } from 'viem/tempo'
515
+ * import { privateKeyToAccount } from 'viem/accounts'
516
+ *
517
+ * const client = createClient({
518
+ * account: privateKeyToAccount('0x...'),
519
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
520
+ * transport: http(),
521
+ * })
522
+ *
523
+ * const { receipt } = await Actions.validator.changeStatusSync(client, {
524
+ * validator: '0x...',
525
+ * active: false,
526
+ * })
527
+ * ```
528
+ *
529
+ * @param client - Client.
530
+ * @param parameters - Parameters.
531
+ * @returns The transaction receipt.
532
+ */
533
+ export async function changeStatusSync<
534
+ chain extends Chain | undefined,
535
+ account extends Account | undefined,
536
+ >(
537
+ client: Client<Transport, chain, account>,
538
+ parameters: changeStatusSync.Parameters<chain, account>,
539
+ ): Promise<changeStatusSync.ReturnValue> {
540
+ const { throwOnReceiptRevert = true, ...rest } = parameters
541
+ const receipt = await changeStatus.inner(writeContractSync, client, {
542
+ ...rest,
543
+ throwOnReceiptRevert,
544
+ } as never)
545
+ return { receipt }
546
+ }
547
+
548
+ export namespace changeStatusSync {
549
+ export type Parameters<
550
+ chain extends Chain | undefined = Chain | undefined,
551
+ account extends Account | undefined = Account | undefined,
552
+ > = changeStatus.Parameters<chain, account>
553
+
554
+ export type Args = changeStatus.Args
555
+
556
+ export type ReturnValue = {
557
+ receipt: TransactionReceipt
558
+ }
559
+ }
560
+
561
+ /**
562
+ * Gets the next epoch for a full DKG ceremony.
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * import { createClient, http } from 'viem'
567
+ * import { tempo } from 'viem/chains'
568
+ * import { Actions } from 'viem/tempo'
569
+ *
570
+ * const client = createClient({
571
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
572
+ * transport: http(),
573
+ * })
574
+ *
575
+ * const epoch = await Actions.validator.getNextFullDkgCeremony(client)
576
+ * ```
577
+ *
578
+ * @param client - Client.
579
+ * @param parameters - Parameters.
580
+ * @returns The epoch number for the next full DKG ceremony.
581
+ */
582
+ export async function getNextFullDkgCeremony<
583
+ chain extends Chain | undefined,
584
+ account extends Account | undefined,
585
+ >(
586
+ client: Client<Transport, chain, account>,
587
+ parameters: getNextFullDkgCeremony.Parameters = {},
588
+ ): Promise<getNextFullDkgCeremony.ReturnValue> {
589
+ return readContract(client, {
590
+ ...parameters,
591
+ ...getNextFullDkgCeremony.call(),
592
+ })
593
+ }
594
+
595
+ export namespace getNextFullDkgCeremony {
596
+ export type Parameters = ReadParameters
597
+
598
+ export type ReturnValue = ReadContractReturnType<
599
+ typeof Abis.validator,
600
+ 'getNextFullDkgCeremony',
601
+ never
602
+ >
603
+
604
+ /**
605
+ * Defines a call to the `getNextFullDkgCeremony` function.
606
+ *
607
+ * Can be passed as a parameter to:
608
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
609
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
610
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
611
+ *
612
+ * @example
613
+ * ```ts
614
+ * import { createClient, http } from 'viem'
615
+ * import { tempo } from 'viem/chains'
616
+ * import { Actions } from 'viem/tempo'
617
+ *
618
+ * const client = createClient({
619
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
620
+ * transport: http(),
621
+ * })
622
+ *
623
+ * const result = await client.multicall({
624
+ * contracts: [Actions.validator.getNextFullDkgCeremony.call()],
625
+ * })
626
+ * ```
627
+ *
628
+ * @returns The call.
629
+ */
630
+ export function call() {
631
+ return defineCall({
632
+ address: Addresses.validator,
633
+ abi: Abis.validator,
634
+ args: [],
635
+ functionName: 'getNextFullDkgCeremony',
636
+ })
637
+ }
638
+ }
639
+
640
+ /**
641
+ * Gets the contract owner.
642
+ *
643
+ * @example
644
+ * ```ts
645
+ * import { createClient, http } from 'viem'
646
+ * import { tempo } from 'viem/chains'
647
+ * import { Actions } from 'viem/tempo'
648
+ *
649
+ * const client = createClient({
650
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
651
+ * transport: http(),
652
+ * })
653
+ *
654
+ * const owner = await Actions.validator.getOwner(client)
655
+ * ```
656
+ *
657
+ * @param client - Client.
658
+ * @param parameters - Parameters.
659
+ * @returns The owner address.
660
+ */
661
+ export async function getOwner<
662
+ chain extends Chain | undefined,
663
+ account extends Account | undefined,
664
+ >(
665
+ client: Client<Transport, chain, account>,
666
+ parameters: getOwner.Parameters = {},
667
+ ): Promise<getOwner.ReturnValue> {
668
+ return readContract(client, {
669
+ ...parameters,
670
+ ...getOwner.call(),
671
+ })
672
+ }
673
+
674
+ export namespace getOwner {
675
+ export type Parameters = ReadParameters
676
+
677
+ export type ReturnValue = ReadContractReturnType<
678
+ typeof Abis.validator,
679
+ 'owner',
680
+ never
681
+ >
682
+
683
+ /**
684
+ * Defines a call to the `owner` function.
685
+ *
686
+ * Can be passed as a parameter to:
687
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
688
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
689
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
690
+ *
691
+ * @example
692
+ * ```ts
693
+ * import { createClient, http } from 'viem'
694
+ * import { tempo } from 'viem/chains'
695
+ * import { Actions } from 'viem/tempo'
696
+ *
697
+ * const client = createClient({
698
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
699
+ * transport: http(),
700
+ * })
701
+ *
702
+ * const result = await client.multicall({
703
+ * contracts: [Actions.validator.getOwner.call()],
704
+ * })
705
+ * ```
706
+ *
707
+ * @returns The call.
708
+ */
709
+ export function call() {
710
+ return defineCall({
711
+ address: Addresses.validator,
712
+ abi: Abis.validator,
713
+ args: [],
714
+ functionName: 'owner',
715
+ })
716
+ }
717
+ }
718
+
719
+ /**
720
+ * Gets validator information by address.
721
+ *
722
+ * @example
723
+ * ```ts
724
+ * import { createClient, http } from 'viem'
725
+ * import { tempo } from 'viem/chains'
726
+ * import { Actions } from 'viem/tempo'
727
+ *
728
+ * const client = createClient({
729
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
730
+ * transport: http(),
731
+ * })
732
+ *
733
+ * const validator = await Actions.validator.get(client, {
734
+ * validator: '0x...',
735
+ * })
736
+ * ```
737
+ *
738
+ * @param client - Client.
739
+ * @param parameters - Parameters.
740
+ * @returns The validator information.
741
+ */
742
+ export async function get<
743
+ chain extends Chain | undefined,
744
+ account extends Account | undefined,
745
+ >(
746
+ client: Client<Transport, chain, account>,
747
+ parameters: get.Parameters,
748
+ ): Promise<get.ReturnValue> {
749
+ const { validator, ...rest } = parameters
750
+ return readContract(client, {
751
+ ...rest,
752
+ ...get.call({ validator }),
753
+ })
754
+ }
755
+
756
+ export namespace get {
757
+ export type Parameters = ReadParameters & Args
758
+
759
+ export type Args = {
760
+ /** Validator address. */
761
+ validator: Address
762
+ }
763
+
764
+ export type ReturnValue = ReadContractReturnType<
765
+ typeof Abis.validator,
766
+ 'validators',
767
+ never
768
+ >
769
+
770
+ /**
771
+ * Defines a call to the `validators` function.
772
+ *
773
+ * Can be passed as a parameter to:
774
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
775
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
776
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
777
+ *
778
+ * @example
779
+ * ```ts
780
+ * import { createClient, http } from 'viem'
781
+ * import { tempo } from 'viem/chains'
782
+ * import { Actions } from 'viem/tempo'
783
+ *
784
+ * const client = createClient({
785
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
786
+ * transport: http(),
787
+ * })
788
+ *
789
+ * const result = await client.multicall({
790
+ * contracts: [
791
+ * Actions.validator.get.call({ validator: '0x...' }),
792
+ * ],
793
+ * })
794
+ * ```
795
+ *
796
+ * @param args - Arguments.
797
+ * @returns The call.
798
+ */
799
+ export function call(args: Args) {
800
+ const { validator } = args
801
+ return defineCall({
802
+ address: Addresses.validator,
803
+ abi: Abis.validator,
804
+ args: [validator],
805
+ functionName: 'validators',
806
+ })
807
+ }
808
+ }
809
+
810
+ /**
811
+ * Gets validator address by index.
812
+ *
813
+ * @example
814
+ * ```ts
815
+ * import { createClient, http } from 'viem'
816
+ * import { tempo } from 'viem/chains'
817
+ * import { Actions } from 'viem/tempo'
818
+ *
819
+ * const client = createClient({
820
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
821
+ * transport: http(),
822
+ * })
823
+ *
824
+ * const validatorAddress = await Actions.validator.getByIndex(client, {
825
+ * index: 0n,
826
+ * })
827
+ * ```
828
+ *
829
+ * @param client - Client.
830
+ * @param parameters - Parameters.
831
+ * @returns The validator address at the given index.
832
+ */
833
+ export async function getByIndex<
834
+ chain extends Chain | undefined,
835
+ account extends Account | undefined,
836
+ >(
837
+ client: Client<Transport, chain, account>,
838
+ parameters: getByIndex.Parameters,
839
+ ): Promise<getByIndex.ReturnValue> {
840
+ const { index, ...rest } = parameters
841
+ return readContract(client, {
842
+ ...rest,
843
+ ...getByIndex.call({ index }),
844
+ })
845
+ }
846
+
847
+ export namespace getByIndex {
848
+ export type Parameters = ReadParameters & Args
849
+
850
+ export type Args = {
851
+ /** Validator index. */
852
+ index: bigint
853
+ }
854
+
855
+ export type ReturnValue = ReadContractReturnType<
856
+ typeof Abis.validator,
857
+ 'validatorsArray',
858
+ never
859
+ >
860
+
861
+ /**
862
+ * Defines a call to the `validatorsArray` function.
863
+ *
864
+ * Can be passed as a parameter to:
865
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
866
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
867
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
868
+ *
869
+ * @example
870
+ * ```ts
871
+ * import { createClient, http } from 'viem'
872
+ * import { tempo } from 'viem/chains'
873
+ * import { Actions } from 'viem/tempo'
874
+ *
875
+ * const client = createClient({
876
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
877
+ * transport: http(),
878
+ * })
879
+ *
880
+ * const result = await client.multicall({
881
+ * contracts: [
882
+ * Actions.validator.getByIndex.call({ index: 0n }),
883
+ * Actions.validator.getByIndex.call({ index: 1n }),
884
+ * ],
885
+ * })
886
+ * ```
887
+ *
888
+ * @param args - Arguments.
889
+ * @returns The call.
890
+ */
891
+ export function call(args: Args) {
892
+ const { index } = args
893
+ return defineCall({
894
+ address: Addresses.validator,
895
+ abi: Abis.validator,
896
+ args: [index],
897
+ functionName: 'validatorsArray',
898
+ })
899
+ }
900
+ }
901
+
902
+ /**
903
+ * Gets the total number of validators.
904
+ *
905
+ * @example
906
+ * ```ts
907
+ * import { createClient, http } from 'viem'
908
+ * import { tempo } from 'viem/chains'
909
+ * import { Actions } from 'viem/tempo'
910
+ *
911
+ * const client = createClient({
912
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
913
+ * transport: http(),
914
+ * })
915
+ *
916
+ * const count = await Actions.validator.getCount(client)
917
+ * ```
918
+ *
919
+ * @param client - Client.
920
+ * @param parameters - Parameters.
921
+ * @returns The total number of validators.
922
+ */
923
+ export async function getCount<
924
+ chain extends Chain | undefined,
925
+ account extends Account | undefined,
926
+ >(
927
+ client: Client<Transport, chain, account>,
928
+ parameters: getCount.Parameters = {},
929
+ ): Promise<getCount.ReturnValue> {
930
+ return readContract(client, {
931
+ ...parameters,
932
+ ...getCount.call(),
933
+ })
934
+ }
935
+
936
+ export namespace getCount {
937
+ export type Parameters = ReadParameters
938
+
939
+ export type ReturnValue = ReadContractReturnType<
940
+ typeof Abis.validator,
941
+ 'validatorCount',
942
+ never
943
+ >
944
+
945
+ /**
946
+ * Defines a call to the `validatorCount` function.
947
+ *
948
+ * Can be passed as a parameter to:
949
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
950
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
951
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
952
+ *
953
+ * @example
954
+ * ```ts
955
+ * import { createClient, http } from 'viem'
956
+ * import { tempo } from 'viem/chains'
957
+ * import { Actions } from 'viem/tempo'
958
+ *
959
+ * const client = createClient({
960
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
961
+ * transport: http(),
962
+ * })
963
+ *
964
+ * const result = await client.multicall({
965
+ * contracts: [Actions.validator.getCount.call()],
966
+ * })
967
+ * ```
968
+ *
969
+ * @returns The call.
970
+ */
971
+ export function call() {
972
+ return defineCall({
973
+ address: Addresses.validator,
974
+ abi: Abis.validator,
975
+ args: [],
976
+ functionName: 'validatorCount',
977
+ })
978
+ }
979
+ }
980
+
981
+ /**
982
+ * Gets the complete set of validators.
983
+ *
984
+ * @example
985
+ * ```ts
986
+ * import { createClient, http } from 'viem'
987
+ * import { tempo } from 'viem/chains'
988
+ * import { Actions } from 'viem/tempo'
989
+ *
990
+ * const client = createClient({
991
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
992
+ * transport: http(),
993
+ * })
994
+ *
995
+ * const validators = await Actions.validator.list(client)
996
+ * ```
997
+ *
998
+ * @param client - Client.
999
+ * @param parameters - Parameters.
1000
+ * @returns Array of all validators with their information.
1001
+ */
1002
+ export async function list<
1003
+ chain extends Chain | undefined,
1004
+ account extends Account | undefined,
1005
+ >(
1006
+ client: Client<Transport, chain, account>,
1007
+ parameters: list.Parameters = {},
1008
+ ): Promise<list.ReturnValue> {
1009
+ return readContract(client, {
1010
+ ...parameters,
1011
+ ...list.call(),
1012
+ })
1013
+ }
1014
+
1015
+ export namespace list {
1016
+ export type Parameters = ReadParameters
1017
+
1018
+ export type ReturnValue = ReadContractReturnType<
1019
+ typeof Abis.validator,
1020
+ 'getValidators',
1021
+ never
1022
+ >
1023
+
1024
+ /**
1025
+ * Defines a call to the `getValidators` function.
1026
+ *
1027
+ * Can be passed as a parameter to:
1028
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
1029
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
1030
+ * - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
1031
+ *
1032
+ * @example
1033
+ * ```ts
1034
+ * import { createClient, http } from 'viem'
1035
+ * import { tempo } from 'viem/chains'
1036
+ * import { Actions } from 'viem/tempo'
1037
+ *
1038
+ * const client = createClient({
1039
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1040
+ * transport: http(),
1041
+ * })
1042
+ *
1043
+ * const result = await client.multicall({
1044
+ * contracts: [Actions.validator.list.call()],
1045
+ * })
1046
+ * ```
1047
+ *
1048
+ * @returns The call.
1049
+ */
1050
+ export function call() {
1051
+ return defineCall({
1052
+ address: Addresses.validator,
1053
+ abi: Abis.validator,
1054
+ args: [],
1055
+ functionName: 'getValidators',
1056
+ })
1057
+ }
1058
+ }
1059
+
1060
+ /**
1061
+ * Sets the next epoch for a full DKG ceremony.
1062
+ *
1063
+ * @example
1064
+ * ```ts
1065
+ * import { createClient, http } from 'viem'
1066
+ * import { tempo } from 'viem/chains'
1067
+ * import { Actions } from 'viem/tempo'
1068
+ * import { privateKeyToAccount } from 'viem/accounts'
1069
+ *
1070
+ * const client = createClient({
1071
+ * account: privateKeyToAccount('0x...'),
1072
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1073
+ * transport: http(),
1074
+ * })
1075
+ *
1076
+ * const hash = await Actions.validator.setNextFullDkgCeremony(client, {
1077
+ * epoch: 100n,
1078
+ * })
1079
+ * ```
1080
+ *
1081
+ * @param client - Client.
1082
+ * @param parameters - Parameters.
1083
+ * @returns The transaction hash.
1084
+ */
1085
+ export async function setNextFullDkgCeremony<
1086
+ chain extends Chain | undefined,
1087
+ account extends Account | undefined,
1088
+ >(
1089
+ client: Client<Transport, chain, account>,
1090
+ parameters: setNextFullDkgCeremony.Parameters<chain, account>,
1091
+ ): Promise<setNextFullDkgCeremony.ReturnValue> {
1092
+ return setNextFullDkgCeremony.inner(writeContract, client, parameters)
1093
+ }
1094
+
1095
+ export namespace setNextFullDkgCeremony {
1096
+ export type Parameters<
1097
+ chain extends Chain | undefined = Chain | undefined,
1098
+ account extends Account | undefined = Account | undefined,
1099
+ > = WriteParameters<chain, account> & Args
1100
+
1101
+ export type Args = {
1102
+ /** The epoch number for the next full DKG ceremony. */
1103
+ epoch: bigint
1104
+ }
1105
+
1106
+ export type ReturnValue = WriteContractReturnType
1107
+
1108
+ // TODO: exhaustive error type
1109
+ export type ErrorType = BaseErrorType
1110
+
1111
+ /** @internal */
1112
+ export async function inner<
1113
+ action extends typeof writeContract | typeof writeContractSync,
1114
+ chain extends Chain | undefined,
1115
+ account extends Account | undefined,
1116
+ >(
1117
+ action: action,
1118
+ client: Client<Transport, chain, account>,
1119
+ parameters: Parameters<chain, account>,
1120
+ ): Promise<ReturnType<action>> {
1121
+ const { epoch, ...rest } = parameters
1122
+ const callData = setNextFullDkgCeremony.call({ epoch })
1123
+ return (await action(client, {
1124
+ ...rest,
1125
+ ...callData,
1126
+ } as never)) as never
1127
+ }
1128
+
1129
+ /**
1130
+ * Defines a call to the `setNextFullDkgCeremony` function.
1131
+ *
1132
+ * Can be passed as a parameter to:
1133
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
1134
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
1135
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
1136
+ *
1137
+ * @example
1138
+ * ```ts
1139
+ * import { createClient, http, walletActions } from 'viem'
1140
+ * import { tempo } from 'viem/chains'
1141
+ * import { Actions } from 'viem/tempo'
1142
+ *
1143
+ * const client = createClient({
1144
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1145
+ * transport: http(),
1146
+ * }).extend(walletActions)
1147
+ *
1148
+ * const { result } = await client.sendCalls({
1149
+ * calls: [
1150
+ * Actions.validator.setNextFullDkgCeremony.call({
1151
+ * epoch: 100n,
1152
+ * }),
1153
+ * ],
1154
+ * })
1155
+ * ```
1156
+ *
1157
+ * @param args - Arguments.
1158
+ * @returns The call.
1159
+ */
1160
+ export function call(args: Args) {
1161
+ const { epoch } = args
1162
+ return defineCall({
1163
+ address: Addresses.validator,
1164
+ abi: Abis.validator,
1165
+ args: [epoch],
1166
+ functionName: 'setNextFullDkgCeremony',
1167
+ })
1168
+ }
1169
+ }
1170
+
1171
+ /**
1172
+ * Sets the next epoch for a full DKG ceremony and waits for the transaction receipt.
1173
+ *
1174
+ * @example
1175
+ * ```ts
1176
+ * import { createClient, http } from 'viem'
1177
+ * import { tempo } from 'viem/chains'
1178
+ * import { Actions } from 'viem/tempo'
1179
+ * import { privateKeyToAccount } from 'viem/accounts'
1180
+ *
1181
+ * const client = createClient({
1182
+ * account: privateKeyToAccount('0x...'),
1183
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1184
+ * transport: http(),
1185
+ * })
1186
+ *
1187
+ * const { receipt } = await Actions.validator.setNextFullDkgCeremonySync(client, {
1188
+ * epoch: 100n,
1189
+ * })
1190
+ * ```
1191
+ *
1192
+ * @param client - Client.
1193
+ * @param parameters - Parameters.
1194
+ * @returns The transaction receipt.
1195
+ */
1196
+ export async function setNextFullDkgCeremonySync<
1197
+ chain extends Chain | undefined,
1198
+ account extends Account | undefined,
1199
+ >(
1200
+ client: Client<Transport, chain, account>,
1201
+ parameters: setNextFullDkgCeremonySync.Parameters<chain, account>,
1202
+ ): Promise<setNextFullDkgCeremonySync.ReturnValue> {
1203
+ const { throwOnReceiptRevert = true, ...rest } = parameters
1204
+ const receipt = await setNextFullDkgCeremony.inner(
1205
+ writeContractSync,
1206
+ client,
1207
+ {
1208
+ ...rest,
1209
+ throwOnReceiptRevert,
1210
+ } as never,
1211
+ )
1212
+ return { receipt }
1213
+ }
1214
+
1215
+ export namespace setNextFullDkgCeremonySync {
1216
+ export type Parameters<
1217
+ chain extends Chain | undefined = Chain | undefined,
1218
+ account extends Account | undefined = Account | undefined,
1219
+ > = setNextFullDkgCeremony.Parameters<chain, account>
1220
+
1221
+ export type Args = setNextFullDkgCeremony.Args
1222
+
1223
+ export type ReturnValue = {
1224
+ receipt: TransactionReceipt
1225
+ }
1226
+ }
1227
+
1228
+ /**
1229
+ * Updates validator information (only callable by the validator themselves).
1230
+ *
1231
+ * @example
1232
+ * ```ts
1233
+ * import { createClient, http } from 'viem'
1234
+ * import { tempo } from 'viem/chains'
1235
+ * import { Actions } from 'viem/tempo'
1236
+ * import { privateKeyToAccount } from 'viem/accounts'
1237
+ *
1238
+ * const client = createClient({
1239
+ * account: privateKeyToAccount('0x...'),
1240
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1241
+ * transport: http(),
1242
+ * })
1243
+ *
1244
+ * const hash = await Actions.validator.update(client, {
1245
+ * newValidatorAddress: '0x...',
1246
+ * publicKey: '0x...',
1247
+ * inboundAddress: '192.168.1.1:8080',
1248
+ * outboundAddress: '192.168.1.1:8080',
1249
+ * })
1250
+ * ```
1251
+ *
1252
+ * @param client - Client.
1253
+ * @param parameters - Parameters.
1254
+ * @returns The transaction hash.
1255
+ */
1256
+ export async function update<
1257
+ chain extends Chain | undefined,
1258
+ account extends Account | undefined,
1259
+ >(
1260
+ client: Client<Transport, chain, account>,
1261
+ parameters: update.Parameters<chain, account>,
1262
+ ): Promise<update.ReturnValue> {
1263
+ return update.inner(writeContract, client, parameters)
1264
+ }
1265
+
1266
+ export namespace update {
1267
+ export type Parameters<
1268
+ chain extends Chain | undefined = Chain | undefined,
1269
+ account extends Account | undefined = Account | undefined,
1270
+ > = WriteParameters<chain, account> & Args
1271
+
1272
+ export type Args = {
1273
+ /** The new address for this validator. */
1274
+ newValidatorAddress: Address
1275
+ /** The validator's new communication public key. */
1276
+ publicKey: Hex
1277
+ /** The validator's inbound address `<hostname|ip>:<port>` for incoming connections. */
1278
+ inboundAddress: string
1279
+ /** The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames). */
1280
+ outboundAddress: string
1281
+ }
1282
+
1283
+ export type ReturnValue = WriteContractReturnType
1284
+
1285
+ // TODO: exhaustive error type
1286
+ export type ErrorType = BaseErrorType
1287
+
1288
+ /** @internal */
1289
+ export async function inner<
1290
+ action extends typeof writeContract | typeof writeContractSync,
1291
+ chain extends Chain | undefined,
1292
+ account extends Account | undefined,
1293
+ >(
1294
+ action: action,
1295
+ client: Client<Transport, chain, account>,
1296
+ parameters: Parameters<chain, account>,
1297
+ ): Promise<ReturnType<action>> {
1298
+ const {
1299
+ newValidatorAddress,
1300
+ publicKey,
1301
+ inboundAddress,
1302
+ outboundAddress,
1303
+ ...rest
1304
+ } = parameters
1305
+ const callData = update.call({
1306
+ newValidatorAddress,
1307
+ publicKey,
1308
+ inboundAddress,
1309
+ outboundAddress,
1310
+ })
1311
+ return (await action(client, {
1312
+ ...rest,
1313
+ ...callData,
1314
+ } as never)) as never
1315
+ }
1316
+
1317
+ /**
1318
+ * Defines a call to the `updateValidator` function.
1319
+ *
1320
+ * Can be passed as a parameter to:
1321
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
1322
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
1323
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
1324
+ *
1325
+ * @example
1326
+ * ```ts
1327
+ * import { createClient, http, walletActions } from 'viem'
1328
+ * import { tempo } from 'viem/chains'
1329
+ * import { Actions } from 'viem/tempo'
1330
+ *
1331
+ * const client = createClient({
1332
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1333
+ * transport: http(),
1334
+ * }).extend(walletActions)
1335
+ *
1336
+ * const { result } = await client.sendCalls({
1337
+ * calls: [
1338
+ * Actions.validator.update.call({
1339
+ * newValidatorAddress: '0x...',
1340
+ * publicKey: '0x...',
1341
+ * inboundAddress: '192.168.1.1:8080',
1342
+ * outboundAddress: '192.168.1.1:8080',
1343
+ * }),
1344
+ * ],
1345
+ * })
1346
+ * ```
1347
+ *
1348
+ * @param args - Arguments.
1349
+ * @returns The call.
1350
+ */
1351
+ export function call(args: Args) {
1352
+ const { newValidatorAddress, publicKey, inboundAddress, outboundAddress } =
1353
+ args
1354
+ return defineCall({
1355
+ address: Addresses.validator,
1356
+ abi: Abis.validator,
1357
+ args: [newValidatorAddress, publicKey, inboundAddress, outboundAddress],
1358
+ functionName: 'updateValidator',
1359
+ })
1360
+ }
1361
+ }
1362
+
1363
+ /**
1364
+ * Updates validator information and waits for the transaction receipt.
1365
+ *
1366
+ * @example
1367
+ * ```ts
1368
+ * import { createClient, http } from 'viem'
1369
+ * import { tempo } from 'viem/chains'
1370
+ * import { Actions } from 'viem/tempo'
1371
+ * import { privateKeyToAccount } from 'viem/accounts'
1372
+ *
1373
+ * const client = createClient({
1374
+ * account: privateKeyToAccount('0x...'),
1375
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
1376
+ * transport: http(),
1377
+ * })
1378
+ *
1379
+ * const { receipt } = await Actions.validator.updateSync(client, {
1380
+ * newValidatorAddress: '0x...',
1381
+ * publicKey: '0x...',
1382
+ * inboundAddress: '192.168.1.1:8080',
1383
+ * outboundAddress: '192.168.1.1:8080',
1384
+ * })
1385
+ * ```
1386
+ *
1387
+ * @param client - Client.
1388
+ * @param parameters - Parameters.
1389
+ * @returns The transaction receipt.
1390
+ */
1391
+ export async function updateSync<
1392
+ chain extends Chain | undefined,
1393
+ account extends Account | undefined,
1394
+ >(
1395
+ client: Client<Transport, chain, account>,
1396
+ parameters: updateSync.Parameters<chain, account>,
1397
+ ): Promise<updateSync.ReturnValue> {
1398
+ const { throwOnReceiptRevert = true, ...rest } = parameters
1399
+ const receipt = await update.inner(writeContractSync, client, {
1400
+ ...rest,
1401
+ throwOnReceiptRevert,
1402
+ } as never)
1403
+ return { receipt }
1404
+ }
1405
+
1406
+ export namespace updateSync {
1407
+ export type Parameters<
1408
+ chain extends Chain | undefined = Chain | undefined,
1409
+ account extends Account | undefined = Account | undefined,
1410
+ > = update.Parameters<chain, account>
1411
+
1412
+ export type Args = update.Args
1413
+
1414
+ export type ReturnValue = {
1415
+ receipt: TransactionReceipt
1416
+ }
1417
+ }