viem 2.47.19 → 2.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/errors/version.js +1 -1
  3. package/_cjs/errors/version.js.map +1 -1
  4. package/_cjs/tempo/Addresses.js +2 -1
  5. package/_cjs/tempo/Addresses.js.map +1 -1
  6. package/_cjs/tempo/Decorator.js +16 -0
  7. package/_cjs/tempo/Decorator.js.map +1 -1
  8. package/_cjs/tempo/Storage.js +77 -0
  9. package/_cjs/tempo/Storage.js.map +1 -0
  10. package/_cjs/tempo/actions/index.js +2 -1
  11. package/_cjs/tempo/actions/index.js.map +1 -1
  12. package/_cjs/tempo/actions/zone.js +432 -0
  13. package/_cjs/tempo/actions/zone.js.map +1 -0
  14. package/_cjs/tempo/index.js +2 -1
  15. package/_cjs/tempo/index.js.map +1 -1
  16. package/_cjs/tempo/zones/Abis.js +82 -0
  17. package/_cjs/tempo/zones/Abis.js.map +1 -0
  18. package/_cjs/tempo/zones/index.js +13 -0
  19. package/_cjs/tempo/zones/index.js.map +1 -0
  20. package/_cjs/tempo/zones/transport.js +24 -0
  21. package/_cjs/tempo/zones/transport.js.map +1 -0
  22. package/_cjs/tempo/zones/zone.js +53 -0
  23. package/_cjs/tempo/zones/zone.js.map +1 -0
  24. package/_esm/errors/version.js +1 -1
  25. package/_esm/errors/version.js.map +1 -1
  26. package/_esm/tempo/Addresses.js +1 -0
  27. package/_esm/tempo/Addresses.js.map +1 -1
  28. package/_esm/tempo/Decorator.js +16 -0
  29. package/_esm/tempo/Decorator.js.map +1 -1
  30. package/_esm/tempo/Storage.js +96 -0
  31. package/_esm/tempo/Storage.js.map +1 -0
  32. package/_esm/tempo/actions/index.js +1 -0
  33. package/_esm/tempo/actions/index.js.map +1 -1
  34. package/_esm/tempo/actions/zone.js +786 -0
  35. package/_esm/tempo/actions/zone.js.map +1 -0
  36. package/_esm/tempo/index.js +1 -0
  37. package/_esm/tempo/index.js.map +1 -1
  38. package/_esm/tempo/zones/Abis.js +79 -0
  39. package/_esm/tempo/zones/Abis.js.map +1 -0
  40. package/_esm/tempo/zones/index.js +5 -0
  41. package/_esm/tempo/zones/index.js.map +1 -0
  42. package/_esm/tempo/zones/transport.js +39 -0
  43. package/_esm/tempo/zones/transport.js.map +1 -0
  44. package/_esm/tempo/zones/zone.js +49 -0
  45. package/_esm/tempo/zones/zone.js.map +1 -0
  46. package/_types/errors/version.d.ts +1 -1
  47. package/_types/errors/version.d.ts.map +1 -1
  48. package/_types/tempo/Addresses.d.ts +1 -0
  49. package/_types/tempo/Addresses.d.ts.map +1 -1
  50. package/_types/tempo/Decorator.d.ts +283 -0
  51. package/_types/tempo/Decorator.d.ts.map +1 -1
  52. package/_types/tempo/Storage.d.ts +42 -0
  53. package/_types/tempo/Storage.d.ts.map +1 -0
  54. package/_types/tempo/actions/index.d.ts +1 -0
  55. package/_types/tempo/actions/index.d.ts.map +1 -1
  56. package/_types/tempo/actions/zone.d.ts +874 -0
  57. package/_types/tempo/actions/zone.d.ts.map +1 -0
  58. package/_types/tempo/index.d.ts +1 -0
  59. package/_types/tempo/index.d.ts.map +1 -1
  60. package/_types/tempo/zones/Abis.d.ts +124 -0
  61. package/_types/tempo/zones/Abis.d.ts.map +1 -0
  62. package/_types/tempo/zones/index.d.ts +4 -0
  63. package/_types/tempo/zones/index.d.ts.map +1 -0
  64. package/_types/tempo/zones/transport.d.ts +26 -0
  65. package/_types/tempo/zones/transport.d.ts.map +1 -0
  66. package/_types/tempo/zones/zone.d.ts +2775 -0
  67. package/_types/tempo/zones/zone.d.ts.map +1 -0
  68. package/errors/version.ts +1 -1
  69. package/package.json +7 -2
  70. package/tempo/Addresses.ts +1 -0
  71. package/tempo/Decorator.ts +337 -0
  72. package/tempo/Storage.ts +118 -0
  73. package/tempo/actions/index.ts +1 -0
  74. package/tempo/actions/zone.ts +1317 -0
  75. package/tempo/index.ts +1 -0
  76. package/tempo/zones/Abis.ts +79 -0
  77. package/tempo/zones/index.ts +10 -0
  78. package/tempo/zones/package.json +6 -0
  79. package/tempo/zones/transport.ts +58 -0
  80. package/tempo/zones/zone.ts +70 -0
@@ -0,0 +1,874 @@
1
+ import type { Address } from 'abitype';
2
+ import * as Hex from 'ox/Hex';
3
+ import { TokenId, ZoneRpcAuthentication } from 'ox/tempo';
4
+ import type { Account } from '../../accounts/types.js';
5
+ import { type SendTransactionReturnType } from '../../actions/wallet/sendTransaction.js';
6
+ import type { Client } from '../../clients/createClient.js';
7
+ import type { Transport } from '../../clients/transports/createTransport.js';
8
+ import type { BaseErrorType } from '../../errors/base.js';
9
+ import type { Chain } from '../../types/chain.js';
10
+ import type { Compute } from '../../types/utils.js';
11
+ import type { RequestErrorType } from '../../utils/buildRequest.js';
12
+ import type { GetAccountParameter, ReadParameters, WriteParameters } from '../internal/types.js';
13
+ import * as Storage from '../Storage.js';
14
+ import type { TransactionReceipt } from '../Transaction.js';
15
+ export type EncryptedPayload = {
16
+ ciphertext: Hex.Hex;
17
+ ephemeralPubkeyX: Hex.Hex;
18
+ ephemeralPubkeyYParity: number;
19
+ nonce: Hex.Hex;
20
+ tag: Hex.Hex;
21
+ };
22
+ /**
23
+ * Deposits tokens into a zone on the parent Tempo chain.
24
+ * Batches approve and deposit into a single transaction.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createClient, http } from 'viem'
29
+ * import { privateKeyToAccount } from 'viem/accounts'
30
+ * import { tempoModerato } from 'viem/chains'
31
+ * import { Actions } from 'viem/tempo'
32
+ *
33
+ * const client = createClient({
34
+ * account: privateKeyToAccount('0x...'),
35
+ * chain: tempoModerato,
36
+ * transport: http(),
37
+ * })
38
+ *
39
+ * const hash = await Actions.zone.deposit(client, {
40
+ * token: '0x20c0...0001',
41
+ * amount: 1_000_000n,
42
+ * zoneId: 7,
43
+ * })
44
+ * ```
45
+ *
46
+ * @param client - Wallet client connected to the parent Tempo chain.
47
+ * @param parameters - Deposit parameters.
48
+ * @returns The transaction hash.
49
+ */
50
+ export declare function deposit<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: deposit.Parameters<chain, account>): Promise<deposit.ReturnValue>;
51
+ export declare namespace deposit {
52
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Omit<Args, 'chainId' | 'recipient'> & {
53
+ /** Recipient address in the zone. @default `account.address` */
54
+ recipient?: Address | undefined;
55
+ };
56
+ type Args = {
57
+ /** Amount of tokens to deposit. */
58
+ amount: bigint;
59
+ /** Parent chain ID (e.g. `42431` for moderato). */
60
+ chainId: number;
61
+ /** Optional deposit memo. @default `0x00...00` */
62
+ memo?: Hex.Hex | undefined;
63
+ /** Recipient address in the zone. */
64
+ recipient: Address;
65
+ /** Token address or ID to deposit. */
66
+ token: TokenId.TokenIdOrAddress;
67
+ /** Zone ID (e.g. `7`). */
68
+ zoneId: number;
69
+ };
70
+ type ReturnValue = SendTransactionReturnType;
71
+ type ErrorType = BaseErrorType;
72
+ /**
73
+ * Defines the calls to approve and deposit tokens into a zone.
74
+ *
75
+ * @param args - Arguments.
76
+ * @returns The calls.
77
+ */
78
+ function calls(args: Args): (({
79
+ abi: [{
80
+ readonly name: "approve";
81
+ readonly type: "function";
82
+ readonly stateMutability: "nonpayable";
83
+ readonly inputs: readonly [{
84
+ readonly type: "address";
85
+ readonly name: "spender";
86
+ }, {
87
+ readonly type: "uint256";
88
+ readonly name: "amount";
89
+ }];
90
+ readonly outputs: readonly [{
91
+ readonly type: "bool";
92
+ }];
93
+ }];
94
+ functionName: "approve";
95
+ } & {
96
+ args: readonly [spender: `0x${string}`, amount: bigint];
97
+ } & {
98
+ address: Address;
99
+ } & {
100
+ data: import("../../index.js").Hex;
101
+ to: Address;
102
+ }) | ({
103
+ abi: [{
104
+ readonly name: "deposit";
105
+ readonly type: "function";
106
+ readonly stateMutability: "nonpayable";
107
+ readonly inputs: readonly [{
108
+ readonly name: "_token";
109
+ readonly type: "address";
110
+ }, {
111
+ readonly name: "to";
112
+ readonly type: "address";
113
+ }, {
114
+ readonly name: "amount";
115
+ readonly type: "uint128";
116
+ }, {
117
+ readonly name: "memo";
118
+ readonly type: "bytes32";
119
+ }];
120
+ readonly outputs: readonly [{
121
+ readonly name: "";
122
+ readonly type: "bytes32";
123
+ }];
124
+ }];
125
+ functionName: "deposit";
126
+ } & {
127
+ args: readonly [_token: `0x${string}`, to: `0x${string}`, amount: bigint, memo: `0x${string}`];
128
+ } & {
129
+ address: Address;
130
+ } & {
131
+ data: import("../../index.js").Hex;
132
+ to: Address;
133
+ }))[];
134
+ }
135
+ /**
136
+ * Deposits tokens into a zone on the parent Tempo chain and waits for the
137
+ * transaction receipt.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { createClient, http } from 'viem'
142
+ * import { privateKeyToAccount } from 'viem/accounts'
143
+ * import { tempoModerato } from 'viem/chains'
144
+ * import { Actions } from 'viem/tempo'
145
+ *
146
+ * const client = createClient({
147
+ * account: privateKeyToAccount('0x...'),
148
+ * chain: tempoModerato,
149
+ * transport: http(),
150
+ * })
151
+ *
152
+ * const result = await Actions.zone.depositSync(client, {
153
+ * token: '0x20c0...0001',
154
+ * amount: 1_000_000n,
155
+ * zoneId: 7,
156
+ * })
157
+ * ```
158
+ *
159
+ * @param client - Wallet client connected to the parent Tempo chain.
160
+ * @param parameters - Deposit parameters.
161
+ * @returns The transaction receipt.
162
+ */
163
+ export declare function depositSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: depositSync.Parameters<chain, account>): Promise<depositSync.ReturnValue>;
164
+ export declare namespace depositSync {
165
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = deposit.Parameters<chain, account>;
166
+ type Args = deposit.Args;
167
+ type ReturnValue = Compute<{
168
+ /** Transaction receipt. */
169
+ receipt: TransactionReceipt;
170
+ }>;
171
+ type ErrorType = BaseErrorType;
172
+ }
173
+ /**
174
+ * Deposits tokens into a zone on the parent Tempo chain with encrypted
175
+ * recipient and memo. Batches approve and depositEncrypted into a single
176
+ * transaction.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * import { createClient, http } from 'viem'
181
+ * import { privateKeyToAccount } from 'viem/accounts'
182
+ * import { tempoModerato } from 'viem/chains'
183
+ * import { Actions } from 'viem/tempo'
184
+ *
185
+ * const client = createClient({
186
+ * account: privateKeyToAccount('0x...'),
187
+ * chain: tempoModerato,
188
+ * transport: http(),
189
+ * })
190
+ *
191
+ * const hash = await Actions.zone.encryptedDeposit(client, {
192
+ * token: '0x20c0...0001',
193
+ * amount: 1_000_000n,
194
+ * zoneId: 7,
195
+ * })
196
+ * ```
197
+ *
198
+ * @param client - Wallet client connected to the parent Tempo chain.
199
+ * @param parameters - Encrypted deposit parameters.
200
+ * @returns The transaction hash.
201
+ */
202
+ export declare function encryptedDeposit<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: encryptedDeposit.Parameters<chain, account>): Promise<encryptedDeposit.ReturnValue>;
203
+ export declare namespace encryptedDeposit {
204
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Omit<Args, 'chainId' | 'encrypted' | 'keyIndex' | 'recipient'> & {
205
+ /** Recipient address in the zone. @default `account.address` */
206
+ recipient?: Address | undefined;
207
+ };
208
+ type Args = {
209
+ /** Amount of tokens to deposit. */
210
+ amount: bigint;
211
+ /** Parent chain ID (e.g. `42431` for moderato). */
212
+ chainId: number;
213
+ /** Encrypted deposit payload. */
214
+ encrypted: EncryptedPayload;
215
+ /** Encryption key index from the portal contract. */
216
+ keyIndex: bigint;
217
+ /** Optional deposit memo. @default `0x00...00` */
218
+ memo?: Hex.Hex | undefined;
219
+ /** Recipient address in the zone. */
220
+ recipient: Address;
221
+ /** Token address or ID to deposit. */
222
+ token: TokenId.TokenIdOrAddress;
223
+ /** Zone ID (e.g. `7`). */
224
+ zoneId: number;
225
+ };
226
+ type ReturnValue = SendTransactionReturnType;
227
+ type ErrorType = BaseErrorType;
228
+ /**
229
+ * Defines the calls to approve and deposit tokens into a zone (encrypted).
230
+ *
231
+ * @param args - Arguments.
232
+ * @returns The calls.
233
+ */
234
+ function calls(args: Args): (({
235
+ abi: [{
236
+ readonly name: "approve";
237
+ readonly type: "function";
238
+ readonly stateMutability: "nonpayable";
239
+ readonly inputs: readonly [{
240
+ readonly type: "address";
241
+ readonly name: "spender";
242
+ }, {
243
+ readonly type: "uint256";
244
+ readonly name: "amount";
245
+ }];
246
+ readonly outputs: readonly [{
247
+ readonly type: "bool";
248
+ }];
249
+ }];
250
+ functionName: "approve";
251
+ } & {
252
+ args: readonly [spender: `0x${string}`, amount: bigint];
253
+ } & {
254
+ address: Address;
255
+ } & {
256
+ data: import("../../index.js").Hex;
257
+ to: Address;
258
+ }) | ({
259
+ abi: [{
260
+ readonly name: "depositEncrypted";
261
+ readonly type: "function";
262
+ readonly stateMutability: "nonpayable";
263
+ readonly inputs: readonly [{
264
+ readonly name: "token";
265
+ readonly type: "address";
266
+ }, {
267
+ readonly name: "amount";
268
+ readonly type: "uint128";
269
+ }, {
270
+ readonly name: "keyIndex";
271
+ readonly type: "uint256";
272
+ }, {
273
+ readonly name: "encrypted";
274
+ readonly type: "tuple";
275
+ readonly components: readonly [{
276
+ readonly name: "ephemeralPubkeyX";
277
+ readonly type: "bytes32";
278
+ }, {
279
+ readonly name: "ephemeralPubkeyYParity";
280
+ readonly type: "uint8";
281
+ }, {
282
+ readonly name: "ciphertext";
283
+ readonly type: "bytes";
284
+ }, {
285
+ readonly name: "nonce";
286
+ readonly type: "bytes12";
287
+ }, {
288
+ readonly name: "tag";
289
+ readonly type: "bytes16";
290
+ }];
291
+ }];
292
+ readonly outputs: readonly [{
293
+ readonly name: "";
294
+ readonly type: "bytes32";
295
+ }];
296
+ }];
297
+ functionName: "depositEncrypted";
298
+ } & {
299
+ args: readonly [token: `0x${string}`, amount: bigint, bigint, {
300
+ ephemeralPubkeyX: `0x${string}`;
301
+ ephemeralPubkeyYParity: number;
302
+ ciphertext: `0x${string}`;
303
+ nonce: `0x${string}`;
304
+ tag: `0x${string}`;
305
+ }];
306
+ } & {
307
+ address: Address;
308
+ } & {
309
+ data: import("../../index.js").Hex;
310
+ to: Address;
311
+ }))[];
312
+ }
313
+ /**
314
+ * Deposits tokens into a zone on the parent Tempo chain with encrypted
315
+ * recipient and memo, and waits for the transaction receipt.
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * import { createClient, http } from 'viem'
320
+ * import { privateKeyToAccount } from 'viem/accounts'
321
+ * import { tempoModerato } from 'viem/chains'
322
+ * import { Actions } from 'viem/tempo'
323
+ *
324
+ * const client = createClient({
325
+ * account: privateKeyToAccount('0x...'),
326
+ * chain: tempoModerato,
327
+ * transport: http(),
328
+ * })
329
+ *
330
+ * const result = await Actions.zone.encryptedDepositSync(client, {
331
+ * token: '0x20c0...0001',
332
+ * amount: 1_000_000n,
333
+ * zoneId: 7,
334
+ * })
335
+ * ```
336
+ *
337
+ * @param client - Wallet client connected to the parent Tempo chain.
338
+ * @param parameters - Encrypted deposit parameters.
339
+ * @returns The transaction receipt.
340
+ */
341
+ export declare function encryptedDepositSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: encryptedDepositSync.Parameters<chain, account>): Promise<encryptedDepositSync.ReturnValue>;
342
+ export declare namespace encryptedDepositSync {
343
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = encryptedDeposit.Parameters<chain, account>;
344
+ type Args = encryptedDeposit.Args;
345
+ type ReturnValue = Compute<{
346
+ /** Transaction receipt. */
347
+ receipt: TransactionReceipt;
348
+ }>;
349
+ type ErrorType = BaseErrorType;
350
+ }
351
+ /**
352
+ * Returns the authenticated account address and authorization token expiry.
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * import { createClient } from 'viem'
357
+ * import { http, zoneModerato } from 'viem/tempo/zones'
358
+ * import { Actions } from 'viem/tempo'
359
+ *
360
+ * const client = createClient({
361
+ * chain: zoneModerato(7),
362
+ * transport: http(),
363
+ * })
364
+ *
365
+ * const info = await Actions.zone.getAuthorizationTokenInfo(client)
366
+ * ```
367
+ *
368
+ * @param client - Zone client.
369
+ * @returns Authorization token info.
370
+ */
371
+ export declare function getAuthorizationTokenInfo<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>): Promise<getAuthorizationTokenInfo.ReturnType>;
372
+ export declare namespace getAuthorizationTokenInfo {
373
+ type RpcReturnType = {
374
+ account: Address;
375
+ expiresAt: Hex.Hex;
376
+ };
377
+ type ReturnType = {
378
+ account: Address;
379
+ expiresAt: bigint;
380
+ };
381
+ type ErrorType = RequestErrorType | BaseErrorType;
382
+ }
383
+ /**
384
+ * Returns deposit processing status for a given Tempo block number.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * import { createClient } from 'viem'
389
+ * import { http, zoneModerato } from 'viem/tempo/zones'
390
+ * import { Actions } from 'viem/tempo'
391
+ *
392
+ * const client = createClient({
393
+ * chain: zoneModerato(7),
394
+ * transport: http(),
395
+ * })
396
+ *
397
+ * const status = await Actions.zone.getDepositStatus(client, {
398
+ * tempoBlockNumber: 42n,
399
+ * })
400
+ * ```
401
+ *
402
+ * @param client - Zone client.
403
+ * @param parameters - Parameters including the Tempo block number.
404
+ * @returns Deposit status.
405
+ */
406
+ export declare function getDepositStatus<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: getDepositStatus.Parameters): Promise<getDepositStatus.ReturnType>;
407
+ export declare namespace getDepositStatus {
408
+ type DepositStatus = 'failed' | 'pending' | 'processed';
409
+ type DepositKind = 'encrypted' | 'regular';
410
+ type DepositRpc = {
411
+ amount: Hex.Hex;
412
+ depositHash: Hex.Hex;
413
+ kind: DepositKind;
414
+ memo: Hex.Hex | null;
415
+ recipient: Address | null;
416
+ sender: Address;
417
+ status: DepositStatus;
418
+ token: Address;
419
+ };
420
+ type Deposit = {
421
+ amount: bigint;
422
+ depositHash: Hex.Hex;
423
+ kind: DepositKind;
424
+ memo: Hex.Hex | null;
425
+ recipient: Address | null;
426
+ sender: Address;
427
+ status: DepositStatus;
428
+ token: Address;
429
+ };
430
+ type RpcReturnType = {
431
+ deposits: readonly DepositRpc[];
432
+ processed: boolean;
433
+ tempoBlockNumber: Hex.Hex;
434
+ zoneProcessedThrough: Hex.Hex;
435
+ };
436
+ type Parameters = {
437
+ tempoBlockNumber: bigint;
438
+ };
439
+ type ReturnType = {
440
+ deposits: readonly Deposit[];
441
+ processed: boolean;
442
+ tempoBlockNumber: bigint;
443
+ zoneProcessedThrough: bigint;
444
+ };
445
+ type ErrorType = RequestErrorType | BaseErrorType;
446
+ }
447
+ /**
448
+ * Returns the fee required for a withdrawal from a zone, given a gas limit.
449
+ *
450
+ * The client must be connected to the **zone chain**.
451
+ *
452
+ * @example
453
+ * ```ts
454
+ * import { createClient } from 'viem'
455
+ * import { http, zoneModerato } from 'viem/tempo/zones'
456
+ * import { Actions } from 'viem/tempo'
457
+ *
458
+ * const client = createClient({
459
+ * chain: zoneModerato(7),
460
+ * transport: http(),
461
+ * })
462
+ *
463
+ * const fee = await Actions.zone.getWithdrawalFee(client)
464
+ * ```
465
+ *
466
+ * @param client - Zone client.
467
+ * @param parameters - Optional gas limit parameter.
468
+ * @returns The withdrawal fee as a bigint.
469
+ */
470
+ export declare function getWithdrawalFee<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters?: getWithdrawalFee.Parameters): Promise<getWithdrawalFee.ReturnType>;
471
+ export declare namespace getWithdrawalFee {
472
+ type Parameters = ReadParameters & {
473
+ /** Gas limit for the withdrawal callback. @default `0n` */
474
+ gas?: bigint | undefined;
475
+ };
476
+ type ReturnType = bigint;
477
+ type ErrorType = RequestErrorType | BaseErrorType;
478
+ }
479
+ /**
480
+ * Returns the current zone metadata.
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * import { createClient } from 'viem'
485
+ * import { http, zoneModerato } from 'viem/tempo/zones'
486
+ * import { Actions } from 'viem/tempo'
487
+ *
488
+ * const client = createClient({
489
+ * chain: zoneModerato(7),
490
+ * transport: http(),
491
+ * })
492
+ *
493
+ * const info = await Actions.zone.getZoneInfo(client)
494
+ * ```
495
+ *
496
+ * @param client - Zone client.
497
+ * @returns Zone metadata.
498
+ */
499
+ export declare function getZoneInfo<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>): Promise<getZoneInfo.ReturnType>;
500
+ export declare namespace getZoneInfo {
501
+ type RpcReturnType = {
502
+ chainId: Hex.Hex;
503
+ sequencer: Address;
504
+ zoneId: Hex.Hex;
505
+ zoneTokens: readonly Address[];
506
+ };
507
+ type ReturnType = {
508
+ chainId: number;
509
+ sequencer: Address;
510
+ zoneId: number;
511
+ zoneTokens: readonly Address[];
512
+ };
513
+ type ErrorType = RequestErrorType | BaseErrorType;
514
+ }
515
+ /**
516
+ * Requests a withdrawal from a zone to the parent Tempo chain via the
517
+ * ZoneOutbox contract.
518
+ *
519
+ * The client must be connected to the **zone chain**.
520
+ *
521
+ * @example
522
+ * ```ts
523
+ * import { createClient } from 'viem'
524
+ * import { privateKeyToAccount } from 'viem/accounts'
525
+ * import { http, zoneModerato } from 'viem/tempo/zones'
526
+ * import { Actions } from 'viem/tempo'
527
+ *
528
+ * const client = createClient({
529
+ * account: privateKeyToAccount('0x...'),
530
+ * chain: zoneModerato(7),
531
+ * transport: http(),
532
+ * })
533
+ *
534
+ * const hash = await Actions.zone.requestWithdrawal(client, {
535
+ * token: '0x20c0...0001',
536
+ * amount: 1_000_000n,
537
+ * })
538
+ * ```
539
+ *
540
+ * @param client - Wallet client connected to the zone chain.
541
+ * @param parameters - Withdrawal parameters.
542
+ * @returns The transaction hash.
543
+ */
544
+ export declare function requestWithdrawal<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: requestWithdrawal.Parameters<chain, account>): Promise<requestWithdrawal.ReturnValue>;
545
+ export declare namespace requestWithdrawal {
546
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Omit<Args, 'to'> & {
547
+ /** Recipient address on the parent Tempo chain. @default `account.address` */
548
+ to?: Address | undefined;
549
+ };
550
+ type Args = {
551
+ /** Amount of tokens to withdraw. */
552
+ amount: bigint;
553
+ /** Optional callback data for the recipient. @default `'0x'` */
554
+ data?: Hex.Hex | undefined;
555
+ /** Fallback address if callback fails. @default `to` */
556
+ fallbackRecipient?: Address | undefined;
557
+ /** Gas limit reserved for the withdrawal callback on the parent chain. @default `0n` */
558
+ gas?: bigint | undefined;
559
+ /** Optional withdrawal memo. @default `0x00...00` */
560
+ memo?: Hex.Hex | undefined;
561
+ /** Recipient address on the parent Tempo chain. */
562
+ to: Address;
563
+ /** Token address or ID to withdraw. */
564
+ token: TokenId.TokenIdOrAddress;
565
+ };
566
+ type ReturnValue = SendTransactionReturnType;
567
+ type ErrorType = BaseErrorType;
568
+ /**
569
+ * Defines the calls to approve and request a withdrawal from a zone.
570
+ *
571
+ * @param args - Arguments.
572
+ * @returns The calls.
573
+ */
574
+ function calls(args: Args): (({
575
+ abi: [{
576
+ readonly name: "approve";
577
+ readonly type: "function";
578
+ readonly stateMutability: "nonpayable";
579
+ readonly inputs: readonly [{
580
+ readonly type: "address";
581
+ readonly name: "spender";
582
+ }, {
583
+ readonly type: "uint256";
584
+ readonly name: "amount";
585
+ }];
586
+ readonly outputs: readonly [{
587
+ readonly type: "bool";
588
+ }];
589
+ }];
590
+ functionName: "approve";
591
+ } & {
592
+ args: readonly [spender: `0x${string}`, amount: bigint];
593
+ } & {
594
+ address: Address;
595
+ } & {
596
+ data: import("../../index.js").Hex;
597
+ to: Address;
598
+ }) | ({
599
+ abi: [{
600
+ readonly name: "requestWithdrawal";
601
+ readonly type: "function";
602
+ readonly stateMutability: "nonpayable";
603
+ readonly inputs: readonly [{
604
+ readonly name: "token";
605
+ readonly type: "address";
606
+ }, {
607
+ readonly name: "to";
608
+ readonly type: "address";
609
+ }, {
610
+ readonly name: "amount";
611
+ readonly type: "uint128";
612
+ }, {
613
+ readonly name: "memo";
614
+ readonly type: "bytes32";
615
+ }, {
616
+ readonly name: "gasLimit";
617
+ readonly type: "uint64";
618
+ }, {
619
+ readonly name: "fallbackRecipient";
620
+ readonly type: "address";
621
+ }, {
622
+ readonly name: "data";
623
+ readonly type: "bytes";
624
+ }, {
625
+ readonly name: "revealTo";
626
+ readonly type: "bytes";
627
+ }];
628
+ readonly outputs: readonly [];
629
+ }];
630
+ functionName: "requestWithdrawal";
631
+ } & {
632
+ args: readonly [token: `0x${string}`, to: `0x${string}`, amount: bigint, memo: `0x${string}`, gasLimit: bigint, `0x${string}`, data: `0x${string}`, `0x${string}`];
633
+ } & {
634
+ address: Address;
635
+ } & {
636
+ data: import("../../index.js").Hex;
637
+ to: Address;
638
+ }))[];
639
+ }
640
+ /**
641
+ * Requests a withdrawal from a zone to the parent Tempo chain and waits for
642
+ * the transaction receipt.
643
+ *
644
+ * @example
645
+ * ```ts
646
+ * import { createClient } from 'viem'
647
+ * import { privateKeyToAccount } from 'viem/accounts'
648
+ * import { http, zoneModerato } from 'viem/tempo/zones'
649
+ * import { Actions } from 'viem/tempo'
650
+ *
651
+ * const client = createClient({
652
+ * account: privateKeyToAccount('0x...'),
653
+ * chain: zoneModerato(7),
654
+ * transport: http(),
655
+ * })
656
+ *
657
+ * const result = await Actions.zone.requestWithdrawalSync(client, {
658
+ * token: '0x20c0...0001',
659
+ * amount: 1_000_000n,
660
+ * })
661
+ * ```
662
+ *
663
+ * @param client - Wallet client connected to the zone chain.
664
+ * @param parameters - Withdrawal parameters.
665
+ * @returns The transaction receipt.
666
+ */
667
+ export declare function requestWithdrawalSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: requestWithdrawalSync.Parameters<chain, account>): Promise<requestWithdrawalSync.ReturnValue>;
668
+ export declare namespace requestWithdrawalSync {
669
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = requestWithdrawal.Parameters<chain, account>;
670
+ type Args = requestWithdrawal.Args;
671
+ type ReturnValue = Compute<{
672
+ /** Transaction receipt. */
673
+ receipt: TransactionReceipt;
674
+ }>;
675
+ type ErrorType = BaseErrorType;
676
+ }
677
+ /**
678
+ * Requests a verifiable withdrawal from a zone to the parent Tempo chain via
679
+ * the ZoneOutbox contract. Includes a `revealTo` public key so the sequencer
680
+ * can encrypt the withdrawal details.
681
+ *
682
+ * The client must be connected to the **zone chain**.
683
+ *
684
+ * @example
685
+ * ```ts
686
+ * import { createClient } from 'viem'
687
+ * import { privateKeyToAccount } from 'viem/accounts'
688
+ * import { http, zoneModerato } from 'viem/tempo/zones'
689
+ * import { Actions } from 'viem/tempo'
690
+ *
691
+ * const client = createClient({
692
+ * account: privateKeyToAccount('0x...'),
693
+ * chain: zoneModerato(7),
694
+ * transport: http(),
695
+ * })
696
+ *
697
+ * const hash = await Actions.zone.requestVerifiableWithdrawal(client, {
698
+ * token: '0x20c0...0001',
699
+ * amount: 1_000_000n,
700
+ * revealTo: '0x02abc...def',
701
+ * })
702
+ * ```
703
+ *
704
+ * @param client - Wallet client connected to the zone chain.
705
+ * @param parameters - Verifiable withdrawal parameters.
706
+ * @returns The transaction hash.
707
+ */
708
+ export declare function requestVerifiableWithdrawal<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: requestVerifiableWithdrawal.Parameters<chain, account>): Promise<requestVerifiableWithdrawal.ReturnValue>;
709
+ export declare namespace requestVerifiableWithdrawal {
710
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Omit<Args, 'to'> & {
711
+ /** Recipient address on the parent Tempo chain. @default `account.address` */
712
+ to?: Address | undefined;
713
+ };
714
+ type Args = requestWithdrawal.Args & {
715
+ /** 33-byte compressed secp256k1 public key for encrypted reveal. */
716
+ revealTo: Hex.Hex;
717
+ };
718
+ type ReturnValue = SendTransactionReturnType;
719
+ type ErrorType = BaseErrorType;
720
+ /**
721
+ * Defines the calls to approve and request a verifiable withdrawal from a zone.
722
+ *
723
+ * @param args - Arguments.
724
+ * @returns The calls.
725
+ */
726
+ function calls(args: Args): (({
727
+ abi: [{
728
+ readonly name: "approve";
729
+ readonly type: "function";
730
+ readonly stateMutability: "nonpayable";
731
+ readonly inputs: readonly [{
732
+ readonly type: "address";
733
+ readonly name: "spender";
734
+ }, {
735
+ readonly type: "uint256";
736
+ readonly name: "amount";
737
+ }];
738
+ readonly outputs: readonly [{
739
+ readonly type: "bool";
740
+ }];
741
+ }];
742
+ functionName: "approve";
743
+ } & {
744
+ args: readonly [spender: `0x${string}`, amount: bigint];
745
+ } & {
746
+ address: Address;
747
+ } & {
748
+ data: import("../../index.js").Hex;
749
+ to: Address;
750
+ }) | ({
751
+ abi: [{
752
+ readonly name: "requestWithdrawal";
753
+ readonly type: "function";
754
+ readonly stateMutability: "nonpayable";
755
+ readonly inputs: readonly [{
756
+ readonly name: "token";
757
+ readonly type: "address";
758
+ }, {
759
+ readonly name: "to";
760
+ readonly type: "address";
761
+ }, {
762
+ readonly name: "amount";
763
+ readonly type: "uint128";
764
+ }, {
765
+ readonly name: "memo";
766
+ readonly type: "bytes32";
767
+ }, {
768
+ readonly name: "gasLimit";
769
+ readonly type: "uint64";
770
+ }, {
771
+ readonly name: "fallbackRecipient";
772
+ readonly type: "address";
773
+ }, {
774
+ readonly name: "data";
775
+ readonly type: "bytes";
776
+ }, {
777
+ readonly name: "revealTo";
778
+ readonly type: "bytes";
779
+ }];
780
+ readonly outputs: readonly [];
781
+ }];
782
+ functionName: "requestWithdrawal";
783
+ } & {
784
+ args: readonly [token: `0x${string}`, to: `0x${string}`, amount: bigint, memo: `0x${string}`, gasLimit: bigint, `0x${string}`, data: `0x${string}`, `0x${string}`];
785
+ } & {
786
+ address: Address;
787
+ } & {
788
+ data: import("../../index.js").Hex;
789
+ to: Address;
790
+ }))[];
791
+ }
792
+ /**
793
+ * Requests a verifiable withdrawal from a zone to the parent Tempo chain and
794
+ * waits for the transaction receipt.
795
+ *
796
+ * @example
797
+ * ```ts
798
+ * import { createClient } from 'viem'
799
+ * import { privateKeyToAccount } from 'viem/accounts'
800
+ * import { http, zoneModerato } from 'viem/tempo/zones'
801
+ * import { Actions } from 'viem/tempo'
802
+ *
803
+ * const client = createClient({
804
+ * account: privateKeyToAccount('0x...'),
805
+ * chain: zoneModerato(7),
806
+ * transport: http(),
807
+ * })
808
+ *
809
+ * const result = await Actions.zone.requestVerifiableWithdrawalSync(client, {
810
+ * token: '0x20c0...0001',
811
+ * amount: 1_000_000n,
812
+ * revealTo: '0x02abc...def',
813
+ * })
814
+ * ```
815
+ *
816
+ * @param client - Wallet client connected to the zone chain.
817
+ * @param parameters - Verifiable withdrawal parameters.
818
+ * @returns The transaction receipt.
819
+ */
820
+ export declare function requestVerifiableWithdrawalSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: requestVerifiableWithdrawalSync.Parameters<chain, account>): Promise<requestVerifiableWithdrawalSync.ReturnValue>;
821
+ export declare namespace requestVerifiableWithdrawalSync {
822
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = requestVerifiableWithdrawal.Parameters<chain, account>;
823
+ type Args = requestVerifiableWithdrawal.Args;
824
+ type ReturnValue = Compute<{
825
+ /** Transaction receipt. */
826
+ receipt: TransactionReceipt;
827
+ }>;
828
+ type ErrorType = BaseErrorType;
829
+ }
830
+ /**
831
+ * Signs a zone authorization token and stores it for the zone HTTP transport.
832
+ *
833
+ * Zone chains should define `contracts.zonePortal` with the portal address.
834
+ * The `zoneId` is derived from `ZoneId.fromChainId(chain.id)` and can be overridden.
835
+ *
836
+ * @example
837
+ * ```ts
838
+ * import { createClient } from 'viem'
839
+ * import { privateKeyToAccount } from 'viem/accounts'
840
+ * import { http, zoneModerato } from 'viem/tempo/zones'
841
+ * import { Actions } from 'viem/tempo'
842
+ *
843
+ * const client = createClient({
844
+ * account: privateKeyToAccount('0x...'),
845
+ * chain: zoneModerato(7),
846
+ * transport: http(),
847
+ * })
848
+ *
849
+ * const result = await Actions.zone.signAuthorizationToken(client)
850
+ * ```
851
+ *
852
+ * @param client - Zone wallet client.
853
+ * @param parameters - Options including optional storage override.
854
+ * @returns The authentication object and serialized token.
855
+ */
856
+ export declare function signAuthorizationToken<chain extends Chain | undefined, account extends Account | undefined, accountOverride extends Account | Address | undefined = undefined>(client: Client<Transport, chain, account>, parameters?: signAuthorizationToken.Parameters<account, accountOverride>): Promise<signAuthorizationToken.ReturnType>;
857
+ export declare namespace signAuthorizationToken {
858
+ type Parameters<account extends Account | undefined = Account | undefined, accountOverride extends Account | Address | undefined = Account | Address | undefined> = GetAccountParameter<account, accountOverride> & {
859
+ /** Chain override. @default `client.chain`. */
860
+ chain?: Chain | undefined;
861
+ /** Token expiry as a unix timestamp (seconds). @default `issuedAt + 86_400`. */
862
+ expiresAt?: number | undefined;
863
+ /** Token issue time as a unix timestamp (seconds). @default `Date.now() / 1000`. */
864
+ issuedAt?: number | undefined;
865
+ /** Storage to persist the token. @default sessionStorage (web) or memory (server). */
866
+ storage?: Storage.Storage | undefined;
867
+ };
868
+ type ReturnType = {
869
+ authentication: ZoneRpcAuthentication.ZoneRpcAuthentication;
870
+ token: Hex.Hex;
871
+ };
872
+ type ErrorType = BaseErrorType;
873
+ }
874
+ //# sourceMappingURL=zone.d.ts.map