viem 2.55.18 → 2.56.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.
- package/CHANGELOG.md +67 -0
- package/_cjs/chains/definitions/berachainBepolia.js +1 -1
- package/_cjs/chains/definitions/morphTachyon.js +25 -0
- package/_cjs/chains/definitions/morphTachyon.js.map +1 -0
- package/_cjs/chains/definitions/morphTachyonTestnet.js +26 -0
- package/_cjs/chains/definitions/morphTachyonTestnet.js.map +1 -0
- package/_cjs/chains/definitions/ynxTestnet.js +26 -0
- package/_cjs/chains/definitions/ynxTestnet.js.map +1 -0
- package/_cjs/chains/index.js +13 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/tempo/Abis.js +5314 -2528
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +188 -16
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +32 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +11 -2
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Formatters.js +1 -1
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Selectors.js +203 -61
- package/_cjs/tempo/Selectors.js.map +1 -1
- package/_cjs/tempo/Storage.js +6 -6
- package/_cjs/tempo/Storage.js.map +1 -1
- package/_cjs/tempo/Transaction.js +31 -10
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/Transport.js +21 -0
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/Zone.js +51 -0
- package/_cjs/tempo/Zone.js.map +1 -0
- package/_cjs/tempo/actions/accessKey.js +49 -8
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +59 -21
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +2 -3
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/multisig.js +95 -0
- package/_cjs/tempo/actions/multisig.js.map +1 -0
- package/_cjs/tempo/actions/zone.js +65 -28
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +58 -29
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +3 -3
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/multisig.js +56 -0
- package/_cjs/tempo/internal/multisig.js.map +1 -0
- package/_esm/chains/definitions/berachainBepolia.js +1 -1
- package/_esm/chains/definitions/morphTachyon.js +22 -0
- package/_esm/chains/definitions/morphTachyon.js.map +1 -0
- package/_esm/chains/definitions/morphTachyonTestnet.js +23 -0
- package/_esm/chains/definitions/morphTachyonTestnet.js.map +1 -0
- package/_esm/chains/definitions/ynxTestnet.js +23 -0
- package/_esm/chains/definitions/ynxTestnet.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/tempo/Abis.js +5302 -2514
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +196 -66
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +37 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js +11 -2
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Formatters.js +3 -6
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Selectors.js +203 -61
- package/_esm/tempo/Selectors.js.map +1 -1
- package/_esm/tempo/Storage.js +7 -7
- package/_esm/tempo/Storage.js.map +1 -1
- package/_esm/tempo/Transaction.js +31 -10
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/Transport.js +37 -0
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/Zone.js +48 -0
- package/_esm/tempo/Zone.js.map +1 -0
- package/_esm/tempo/actions/accessKey.js +65 -23
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +66 -25
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +2 -3
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/multisig.js +245 -0
- package/_esm/tempo/actions/multisig.js.map +1 -0
- package/_esm/tempo/actions/zone.js +111 -66
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/chainConfig.js +65 -35
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +2 -2
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/multisig.js +56 -0
- package/_esm/tempo/internal/multisig.js.map +1 -0
- package/_types/chains/definitions/berachainBepolia.d.ts +1 -1
- package/_types/chains/definitions/morphTachyon.d.ts +51 -0
- package/_types/chains/definitions/morphTachyon.d.ts.map +1 -0
- package/_types/chains/definitions/morphTachyonTestnet.d.ts +51 -0
- package/_types/chains/definitions/morphTachyonTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +30 -2
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +30 -2
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +30 -2
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +30 -2
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/definitions/ynxTestnet.d.ts +51 -0
- package/_types/chains/definitions/ynxTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/tempo/Abis.d.ts +31485 -6119
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +42 -26
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +12 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +62 -22
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Selectors.d.ts +202 -60
- package/_types/tempo/Selectors.d.ts.map +1 -1
- package/_types/tempo/Storage.d.ts +1 -1
- package/_types/tempo/Storage.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +17 -2
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts +24 -0
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/Zone.d.ts +6824 -0
- package/_types/tempo/Zone.d.ts.map +1 -0
- package/_types/tempo/actions/accessKey.d.ts +35 -17
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +72 -0
- package/_types/tempo/actions/channel.d.ts.map +1 -1
- package/_types/tempo/actions/dex.d.ts +260 -0
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts +86 -278
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +540 -16
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/multisig.d.ts +472 -0
- package/_types/tempo/actions/multisig.d.ts.map +1 -0
- package/_types/tempo/actions/policy.d.ts +108 -0
- package/_types/tempo/actions/policy.d.ts.map +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts +27 -0
- package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +165 -82
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +15 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -2
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/multisig.d.ts +13 -0
- package/_types/tempo/internal/multisig.d.ts.map +1 -0
- package/chains/definitions/berachainBepolia.ts +1 -1
- package/chains/definitions/morphTachyon.ts +22 -0
- package/chains/definitions/morphTachyonTestnet.ts +23 -0
- package/chains/definitions/ynxTestnet.ts +23 -0
- package/chains/index.ts +3 -0
- package/errors/version.ts +1 -1
- package/package.json +2 -7
- package/tempo/Abis.ts +5337 -2537
- package/tempo/Account.ts +329 -51
- package/tempo/Addresses.ts +41 -0
- package/tempo/Decorator.ts +89 -28
- package/tempo/Formatters.ts +4 -5
- package/tempo/Selectors.ts +225 -71
- package/tempo/Storage.ts +5 -8
- package/tempo/Transaction.ts +52 -12
- package/tempo/Transport.ts +57 -0
- package/tempo/Zone.ts +60 -0
- package/tempo/actions/accessKey.ts +128 -32
- package/tempo/actions/earn/deployment.ts +74 -30
- package/tempo/actions/earn.ts +2 -3
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/multisig.ts +356 -0
- package/tempo/actions/zone.ts +188 -84
- package/tempo/chainConfig.ts +82 -35
- package/tempo/index.ts +12 -6
- package/tempo/internal/multisig.ts +72 -0
- package/_cjs/tempo/zones/Abis.js +0 -213
- package/_cjs/tempo/zones/Abis.js.map +0 -1
- package/_cjs/tempo/zones/Addresses.js +0 -17
- package/_cjs/tempo/zones/Addresses.js.map +0 -1
- package/_cjs/tempo/zones/index.js +0 -13
- package/_cjs/tempo/zones/index.js.map +0 -1
- package/_cjs/tempo/zones/transport.js +0 -24
- package/_cjs/tempo/zones/transport.js.map +0 -1
- package/_cjs/tempo/zones/zone.js +0 -82
- package/_cjs/tempo/zones/zone.js.map +0 -1
- package/_esm/tempo/zones/Abis.js +0 -210
- package/_esm/tempo/zones/Abis.js.map +0 -1
- package/_esm/tempo/zones/Addresses.js +0 -14
- package/_esm/tempo/zones/Addresses.js.map +0 -1
- package/_esm/tempo/zones/index.js +0 -6
- package/_esm/tempo/zones/index.js.map +0 -1
- package/_esm/tempo/zones/transport.js +0 -39
- package/_esm/tempo/zones/transport.js.map +0 -1
- package/_esm/tempo/zones/zone.js +0 -78
- package/_esm/tempo/zones/zone.js.map +0 -1
- package/_types/tempo/zones/Abis.d.ts +0 -383
- package/_types/tempo/zones/Abis.d.ts.map +0 -1
- package/_types/tempo/zones/Addresses.d.ts +0 -13
- package/_types/tempo/zones/Addresses.d.ts.map +0 -1
- package/_types/tempo/zones/index.d.ts +0 -5
- package/_types/tempo/zones/index.d.ts.map +0 -1
- package/_types/tempo/zones/transport.d.ts +0 -26
- package/_types/tempo/zones/transport.d.ts.map +0 -1
- package/_types/tempo/zones/zone.d.ts +0 -3092
- package/_types/tempo/zones/zone.d.ts.map +0 -1
- package/tempo/zones/Abis.ts +0 -211
- package/tempo/zones/Addresses.ts +0 -15
- package/tempo/zones/index.ts +0 -10
- package/tempo/zones/package.json +0 -6
- package/tempo/zones/transport.ts +0 -58
- package/tempo/zones/zone.ts +0 -113
package/tempo/actions/zone.ts
CHANGED
|
@@ -6,12 +6,19 @@ import * as Secp256k1 from 'ox/Secp256k1'
|
|
|
6
6
|
import { TokenId, ZoneId, ZoneRpcAuthentication } from 'ox/tempo'
|
|
7
7
|
import type { Account } from '../../accounts/types.js'
|
|
8
8
|
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
|
9
|
+
import {
|
|
10
|
+
type GetContractReturnType,
|
|
11
|
+
getContract,
|
|
12
|
+
} from '../../actions/getContract.js'
|
|
9
13
|
import {
|
|
10
14
|
type MulticallErrorType,
|
|
11
15
|
type MulticallParameters,
|
|
12
16
|
multicall,
|
|
13
17
|
} from '../../actions/public/multicall.js'
|
|
14
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
type ReadContractErrorType,
|
|
20
|
+
readContract,
|
|
21
|
+
} from '../../actions/public/readContract.js'
|
|
15
22
|
import {
|
|
16
23
|
type PrepareTransactionRequestErrorType,
|
|
17
24
|
type PrepareTransactionRequestRequest,
|
|
@@ -24,6 +31,7 @@ import {
|
|
|
24
31
|
} from '../../actions/wallet/sendTransaction.js'
|
|
25
32
|
import { sendTransactionSync } from '../../actions/wallet/sendTransactionSync.js'
|
|
26
33
|
import type { Client } from '../../clients/createClient.js'
|
|
34
|
+
import type { PublicClient } from '../../clients/createPublicClient.js'
|
|
27
35
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
28
36
|
import { zeroHash } from '../../constants/bytes.js'
|
|
29
37
|
import type { BaseErrorType } from '../../errors/base.js'
|
|
@@ -60,11 +68,24 @@ import {
|
|
|
60
68
|
import * as WithdrawalSenderTag from '../internal/WithdrawalSenderTag.js'
|
|
61
69
|
import * as Storage from '../Storage.js'
|
|
62
70
|
import type { TransactionReceipt } from '../Transaction.js'
|
|
63
|
-
import * as ZoneAbis from '../zones/Abis.js'
|
|
64
|
-
import { getPortalAddress } from '../zones/zone.js'
|
|
65
71
|
|
|
66
72
|
const defaultWithdrawalGas = 10_000_000n
|
|
67
73
|
|
|
74
|
+
// TODO: Remove this compatibility ABI when T10 support is retired.
|
|
75
|
+
// Later Zone deployments append the derived address to these two values.
|
|
76
|
+
const sequencerEncryptionKeyAbi = [
|
|
77
|
+
{
|
|
78
|
+
name: 'sequencerEncryptionKey',
|
|
79
|
+
type: 'function',
|
|
80
|
+
stateMutability: 'view',
|
|
81
|
+
inputs: [],
|
|
82
|
+
outputs: [
|
|
83
|
+
{ type: 'bytes32', name: 'x' },
|
|
84
|
+
{ type: 'uint8', name: 'yParity' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
] as const
|
|
88
|
+
|
|
68
89
|
export type EncryptedPayload = {
|
|
69
90
|
ciphertext: Hex.Hex
|
|
70
91
|
ephemeralPubkeyX: Hex.Hex
|
|
@@ -144,9 +165,6 @@ export async function deposit<
|
|
|
144
165
|
client: Client<Transport, chain, account>,
|
|
145
166
|
parameters: deposit.Parameters<chain, account>,
|
|
146
167
|
): Promise<deposit.ReturnValue> {
|
|
147
|
-
const chainId = client.chain?.id
|
|
148
|
-
if (!chainId) throw new Error('`chain` is required.')
|
|
149
|
-
|
|
150
168
|
const { account = client.account, ...rest } = parameters
|
|
151
169
|
|
|
152
170
|
const account_ = account ? parseAccount(account) : undefined
|
|
@@ -157,7 +175,6 @@ export async function deposit<
|
|
|
157
175
|
parameters.tempoRefundRecipient ?? account_.address
|
|
158
176
|
const args = {
|
|
159
177
|
...parameters,
|
|
160
|
-
chainId,
|
|
161
178
|
recipient,
|
|
162
179
|
tempoRefundRecipient,
|
|
163
180
|
}
|
|
@@ -173,7 +190,7 @@ export namespace deposit {
|
|
|
173
190
|
chain extends Chain | undefined = Chain | undefined,
|
|
174
191
|
account extends Account | undefined = Account | undefined,
|
|
175
192
|
> = WriteParameters<chain, account> &
|
|
176
|
-
Omit<Args, '
|
|
193
|
+
Omit<Args, 'recipient' | 'tempoRefundRecipient'> & {
|
|
177
194
|
/** Recipient address in the zone. @default `account.address` */
|
|
178
195
|
recipient?: Address | undefined
|
|
179
196
|
/** Refund recipient on the parent chain. @default `account.address` */
|
|
@@ -183,11 +200,9 @@ export namespace deposit {
|
|
|
183
200
|
export type Args = {
|
|
184
201
|
/** Amount of tokens to deposit. */
|
|
185
202
|
amount: bigint
|
|
186
|
-
/** Parent chain ID (e.g. `42431` for moderato). */
|
|
187
|
-
chainId: number
|
|
188
203
|
/** Optional deposit memo. @default `0x00...00` */
|
|
189
204
|
memo?: Hex.Hex | undefined
|
|
190
|
-
/** Zone portal address. @default
|
|
205
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
191
206
|
portalAddress?: Address | undefined
|
|
192
207
|
/** Recipient address in the zone. */
|
|
193
208
|
recipient: Address
|
|
@@ -213,15 +228,13 @@ export namespace deposit {
|
|
|
213
228
|
export function calls(args: Args) {
|
|
214
229
|
const {
|
|
215
230
|
amount,
|
|
216
|
-
chainId,
|
|
217
231
|
memo = zeroHash,
|
|
218
232
|
recipient,
|
|
219
233
|
tempoRefundRecipient,
|
|
220
234
|
token,
|
|
221
235
|
zoneId,
|
|
222
236
|
} = args
|
|
223
|
-
const portalAddress =
|
|
224
|
-
args.portalAddress ?? getPortalAddress(chainId, zoneId)
|
|
237
|
+
const portalAddress = args.portalAddress ?? Addresses.zonePortal(zoneId)
|
|
225
238
|
const tokenAddress = TokenId.toAddress(token)
|
|
226
239
|
const approveCall = defineCall({
|
|
227
240
|
address: tokenAddress,
|
|
@@ -231,7 +244,7 @@ export namespace deposit {
|
|
|
231
244
|
})
|
|
232
245
|
const depositCall = defineCall({
|
|
233
246
|
address: portalAddress,
|
|
234
|
-
abi:
|
|
247
|
+
abi: Abis.zonePortal,
|
|
235
248
|
functionName: 'deposit',
|
|
236
249
|
args: [tokenAddress, recipient, amount, memo, tempoRefundRecipient],
|
|
237
250
|
})
|
|
@@ -274,9 +287,6 @@ export async function depositSync<
|
|
|
274
287
|
client: Client<Transport, chain, account>,
|
|
275
288
|
parameters: depositSync.Parameters<chain, account>,
|
|
276
289
|
): Promise<depositSync.ReturnValue> {
|
|
277
|
-
const chainId = client.chain?.id
|
|
278
|
-
if (!chainId) throw new Error('`chain` is required.')
|
|
279
|
-
|
|
280
290
|
const {
|
|
281
291
|
account = client.account,
|
|
282
292
|
throwOnReceiptRevert = true,
|
|
@@ -291,7 +301,6 @@ export async function depositSync<
|
|
|
291
301
|
parameters.tempoRefundRecipient ?? account_.address
|
|
292
302
|
const args = {
|
|
293
303
|
...parameters,
|
|
294
|
-
chainId,
|
|
295
304
|
recipient,
|
|
296
305
|
tempoRefundRecipient,
|
|
297
306
|
}
|
|
@@ -348,11 +357,8 @@ export async function getEncryptionKey<chain extends Chain | undefined>(
|
|
|
348
357
|
client: Client<Transport, chain>,
|
|
349
358
|
parameters: getEncryptionKey.Parameters,
|
|
350
359
|
): Promise<getEncryptionKey.ReturnValue> {
|
|
351
|
-
const chainId = client.chain?.id
|
|
352
|
-
if (!chainId) throw new Error('`chain` is required.')
|
|
353
|
-
|
|
354
360
|
const { account, portalAddress: portalAddress_, zoneId, ...rest } = parameters
|
|
355
|
-
const portalAddress = portalAddress_ ??
|
|
361
|
+
const portalAddress = portalAddress_ ?? Addresses.zonePortal(zoneId)
|
|
356
362
|
const [keyCountResult, publicKeyResult] = await multicall(client, {
|
|
357
363
|
...rest,
|
|
358
364
|
account: account ? parseAccount(account).address : undefined,
|
|
@@ -392,7 +398,7 @@ export namespace getEncryptionKey {
|
|
|
392
398
|
}
|
|
393
399
|
|
|
394
400
|
export type Args = {
|
|
395
|
-
/** Zone portal address. @default
|
|
401
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
396
402
|
portalAddress?: Address | undefined
|
|
397
403
|
/** Zone ID (e.g. `7`). */
|
|
398
404
|
zoneId: number
|
|
@@ -424,18 +430,140 @@ export namespace getEncryptionKey {
|
|
|
424
430
|
return [
|
|
425
431
|
defineCall({
|
|
426
432
|
address: args.portalAddress,
|
|
427
|
-
abi:
|
|
433
|
+
abi: Abis.zonePortal,
|
|
428
434
|
functionName: 'encryptionKeyCount',
|
|
429
435
|
}),
|
|
430
436
|
defineCall({
|
|
431
437
|
address: args.portalAddress,
|
|
432
|
-
abi:
|
|
438
|
+
abi: sequencerEncryptionKeyAbi,
|
|
433
439
|
functionName: 'sequencerEncryptionKey',
|
|
434
440
|
}),
|
|
435
441
|
] as const
|
|
436
442
|
}
|
|
437
443
|
}
|
|
438
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Gets metadata and configuration for a zone portal.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* import { createClient, http } from 'viem'
|
|
451
|
+
* import { tempoModerato } from 'viem/chains'
|
|
452
|
+
* import { Actions } from 'viem/tempo'
|
|
453
|
+
*
|
|
454
|
+
* const client = createClient({
|
|
455
|
+
* chain: tempoModerato,
|
|
456
|
+
* transport: http(),
|
|
457
|
+
* })
|
|
458
|
+
*
|
|
459
|
+
* const info = await Actions.zone.getPortalInfo(client, {
|
|
460
|
+
* zoneId: 7,
|
|
461
|
+
* })
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* @param client - Public client connected to the parent Tempo chain.
|
|
465
|
+
* @param parameters - Zone portal parameters.
|
|
466
|
+
* @returns The portal metadata and configuration.
|
|
467
|
+
*/
|
|
468
|
+
export async function getPortalInfo<chain extends Chain | undefined>(
|
|
469
|
+
client: Client<Transport, chain>,
|
|
470
|
+
parameters: getPortalInfo.Parameters,
|
|
471
|
+
): Promise<getPortalInfo.ReturnValue> {
|
|
472
|
+
const { portalAddress: portalAddress_, zoneId, ...rest } = parameters
|
|
473
|
+
const portal = getContract({
|
|
474
|
+
abi: Abis.zonePortal,
|
|
475
|
+
address: portalAddress_ ?? Addresses.zonePortal(zoneId),
|
|
476
|
+
client,
|
|
477
|
+
}) as unknown as GetContractReturnType<
|
|
478
|
+
typeof Abis.zonePortal,
|
|
479
|
+
PublicClient<Transport, Chain>
|
|
480
|
+
>
|
|
481
|
+
const [
|
|
482
|
+
admin,
|
|
483
|
+
enabledTokenCount,
|
|
484
|
+
messenger,
|
|
485
|
+
pauseExpiry,
|
|
486
|
+
paused,
|
|
487
|
+
pendingAdmin,
|
|
488
|
+
sequencerCount,
|
|
489
|
+
sequencerSetVersion,
|
|
490
|
+
sequencerThreshold,
|
|
491
|
+
verifier,
|
|
492
|
+
] = await Promise.all([
|
|
493
|
+
portal.read.admin(rest),
|
|
494
|
+
portal.read.enabledTokenCount(rest),
|
|
495
|
+
portal.read.messenger(rest),
|
|
496
|
+
portal.read.pauseExpiry(rest),
|
|
497
|
+
portal.read.paused(rest),
|
|
498
|
+
portal.read.pendingAdmin(rest),
|
|
499
|
+
portal.read.sequencerCount(rest),
|
|
500
|
+
portal.read.sequencerSetVersion(rest),
|
|
501
|
+
portal.read.sequencerThreshold(rest),
|
|
502
|
+
portal.read.verifier(rest),
|
|
503
|
+
])
|
|
504
|
+
const [sequencers, enabledTokens] = await Promise.all([
|
|
505
|
+
Promise.all(
|
|
506
|
+
Array.from({ length: Number(sequencerCount) }, (_, index) =>
|
|
507
|
+
portal.read.sequencerAt([BigInt(index)], rest),
|
|
508
|
+
),
|
|
509
|
+
),
|
|
510
|
+
Promise.all(
|
|
511
|
+
Array.from({ length: Number(enabledTokenCount) }, (_, index) =>
|
|
512
|
+
portal.read.enabledTokenAt([BigInt(index)], rest),
|
|
513
|
+
),
|
|
514
|
+
),
|
|
515
|
+
])
|
|
516
|
+
|
|
517
|
+
return {
|
|
518
|
+
admin,
|
|
519
|
+
enabledTokens,
|
|
520
|
+
messenger,
|
|
521
|
+
pauseExpiry,
|
|
522
|
+
paused,
|
|
523
|
+
pendingAdmin,
|
|
524
|
+
sequencers,
|
|
525
|
+
sequencerSetVersion,
|
|
526
|
+
sequencerThreshold,
|
|
527
|
+
verifier,
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export namespace getPortalInfo {
|
|
532
|
+
export type Parameters = ReadParameters & Args
|
|
533
|
+
|
|
534
|
+
export type Args = {
|
|
535
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
536
|
+
portalAddress?: Address | undefined
|
|
537
|
+
/** Zone ID (e.g. `7`). */
|
|
538
|
+
zoneId: number
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
export type ReturnValue = Compute<{
|
|
542
|
+
/** Portal governance admin. */
|
|
543
|
+
admin: Address
|
|
544
|
+
/** Tokens enabled for deposits into the zone. */
|
|
545
|
+
enabledTokens: readonly Address[]
|
|
546
|
+
/** Zone messenger assigned to the portal. */
|
|
547
|
+
messenger: Address
|
|
548
|
+
/** Timestamp when the current emergency pause expires. */
|
|
549
|
+
pauseExpiry: bigint
|
|
550
|
+
/** Whether the portal is paused. */
|
|
551
|
+
paused: boolean
|
|
552
|
+
/** Pending governance admin. */
|
|
553
|
+
pendingAdmin: Address
|
|
554
|
+
/** Active sequencer addresses. */
|
|
555
|
+
sequencers: readonly Address[]
|
|
556
|
+
/** Version of the active sequencer set. */
|
|
557
|
+
sequencerSetVersion: bigint
|
|
558
|
+
/** Number of sequencers required to attest to a settlement. */
|
|
559
|
+
sequencerThreshold: number
|
|
560
|
+
/** Settlement verifier assigned to the portal. */
|
|
561
|
+
verifier: Address
|
|
562
|
+
}>
|
|
563
|
+
|
|
564
|
+
export type ErrorType = ReadContractErrorType | BaseErrorType
|
|
565
|
+
}
|
|
566
|
+
|
|
439
567
|
/**
|
|
440
568
|
* Deposits tokens into a zone on the parent Tempo chain with encrypted
|
|
441
569
|
* recipient and memo. Batches approve and depositEncrypted into a single
|
|
@@ -550,7 +678,7 @@ export namespace encryptedDeposit {
|
|
|
550
678
|
keyIndex: bigint
|
|
551
679
|
/** Optional deposit memo. @default `0x00...00` */
|
|
552
680
|
memo?: Hex.Hex | undefined
|
|
553
|
-
/** Zone portal address. @default
|
|
681
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
554
682
|
portalAddress?: Address | undefined
|
|
555
683
|
/** Recipient address in the zone. */
|
|
556
684
|
recipient: Address
|
|
@@ -618,7 +746,7 @@ export namespace encryptedDeposit {
|
|
|
618
746
|
} = parameters
|
|
619
747
|
if (!sender_) throw new Error('`sender` is required.')
|
|
620
748
|
const sender = sender_
|
|
621
|
-
const portalAddress = portalAddress_ ??
|
|
749
|
+
const portalAddress = portalAddress_ ?? Addresses.zonePortal(zoneId)
|
|
622
750
|
|
|
623
751
|
const { keyIndex, publicKey } = await getEncryptionKey(client, {
|
|
624
752
|
...rest,
|
|
@@ -666,7 +794,7 @@ export namespace encryptedDeposit {
|
|
|
666
794
|
amount: bigint
|
|
667
795
|
/** Optional deposit memo. @default `0x00...00` */
|
|
668
796
|
memo?: Hex.Hex | undefined
|
|
669
|
-
/** Zone portal address. @default
|
|
797
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
670
798
|
portalAddress?: Address | undefined
|
|
671
799
|
/** Recipient address in the zone. */
|
|
672
800
|
recipient: Address
|
|
@@ -734,7 +862,7 @@ export namespace encryptedDeposit {
|
|
|
734
862
|
} = parameters
|
|
735
863
|
if (!sender_) throw new Error('`sender` is required.')
|
|
736
864
|
const sender = sender_
|
|
737
|
-
const portalAddress = portalAddress_ ??
|
|
865
|
+
const portalAddress = portalAddress_ ?? Addresses.zonePortal(zoneId)
|
|
738
866
|
const { keyIndex, publicKey } = await getEncryptionKey(client, {
|
|
739
867
|
...rest,
|
|
740
868
|
portalAddress,
|
|
@@ -775,7 +903,7 @@ export namespace encryptedDeposit {
|
|
|
775
903
|
export type Args = {
|
|
776
904
|
/** Optional deposit memo. @default `0x00...00` */
|
|
777
905
|
memo?: Hex.Hex | undefined
|
|
778
|
-
/** Zone portal address. @default
|
|
906
|
+
/** Zone portal address. @default derived from `zoneId`. */
|
|
779
907
|
portalAddress?: Address | undefined
|
|
780
908
|
/** Recipient address in the zone. */
|
|
781
909
|
recipient: Address
|
|
@@ -797,17 +925,9 @@ export namespace encryptedDeposit {
|
|
|
797
925
|
* @returns The calls.
|
|
798
926
|
*/
|
|
799
927
|
export function calls(args: Args | PreparedEncryptedDeposit) {
|
|
800
|
-
const {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
encrypted,
|
|
804
|
-
keyIndex,
|
|
805
|
-
tempoRefundRecipient,
|
|
806
|
-
token,
|
|
807
|
-
zoneId,
|
|
808
|
-
} = args
|
|
809
|
-
const portalAddress =
|
|
810
|
-
args.portalAddress ?? getPortalAddress(chainId, zoneId)
|
|
928
|
+
const { amount, encrypted, keyIndex, tempoRefundRecipient, token, zoneId } =
|
|
929
|
+
args
|
|
930
|
+
const portalAddress = args.portalAddress ?? Addresses.zonePortal(zoneId)
|
|
811
931
|
const tokenAddress = TokenId.toAddress(token)
|
|
812
932
|
const encryptedPayload = {
|
|
813
933
|
ephemeralPubkeyX: encrypted.ephemeralPubkeyX,
|
|
@@ -824,7 +944,7 @@ export namespace encryptedDeposit {
|
|
|
824
944
|
})
|
|
825
945
|
const depositCall = defineCall({
|
|
826
946
|
address: portalAddress,
|
|
827
|
-
abi:
|
|
947
|
+
abi: Abis.zonePortal,
|
|
828
948
|
functionName: 'depositEncrypted',
|
|
829
949
|
args: [
|
|
830
950
|
tokenAddress,
|
|
@@ -951,11 +1071,10 @@ export namespace encryptedDepositSync {
|
|
|
951
1071
|
* @example
|
|
952
1072
|
* ```ts
|
|
953
1073
|
* import { createClient } from 'viem'
|
|
954
|
-
* import { http,
|
|
955
|
-
* import { Actions } from 'viem/tempo'
|
|
1074
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
956
1075
|
*
|
|
957
1076
|
* const client = createClient({
|
|
958
|
-
* chain:
|
|
1077
|
+
* chain: Zone.a,
|
|
959
1078
|
* transport: http(),
|
|
960
1079
|
* })
|
|
961
1080
|
*
|
|
@@ -1009,11 +1128,10 @@ export namespace getAuthorizationTokenInfo {
|
|
|
1009
1128
|
* @example
|
|
1010
1129
|
* ```ts
|
|
1011
1130
|
* import { createClient } from 'viem'
|
|
1012
|
-
* import { http,
|
|
1013
|
-
* import { Actions } from 'viem/tempo'
|
|
1131
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1014
1132
|
*
|
|
1015
1133
|
* const client = createClient({
|
|
1016
|
-
* chain:
|
|
1134
|
+
* chain: Zone.a,
|
|
1017
1135
|
* transport: http(),
|
|
1018
1136
|
* })
|
|
1019
1137
|
*
|
|
@@ -1035,7 +1153,7 @@ export async function getWithdrawalFee<
|
|
|
1035
1153
|
return readContract(client, {
|
|
1036
1154
|
...rest,
|
|
1037
1155
|
address: Addresses.zoneOutbox,
|
|
1038
|
-
abi:
|
|
1156
|
+
abi: Abis.zoneOutbox,
|
|
1039
1157
|
functionName: 'calculateWithdrawalFee',
|
|
1040
1158
|
args: [callbackGas],
|
|
1041
1159
|
})
|
|
@@ -1058,11 +1176,10 @@ export namespace getWithdrawalFee {
|
|
|
1058
1176
|
* @example
|
|
1059
1177
|
* ```ts
|
|
1060
1178
|
* import { createClient } from 'viem'
|
|
1061
|
-
* import { http,
|
|
1062
|
-
* import { Actions } from 'viem/tempo'
|
|
1179
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1063
1180
|
*
|
|
1064
1181
|
* const client = createClient({
|
|
1065
|
-
* chain:
|
|
1182
|
+
* chain: Zone.a,
|
|
1066
1183
|
* transport: http(),
|
|
1067
1184
|
* })
|
|
1068
1185
|
*
|
|
@@ -1149,11 +1266,10 @@ export namespace getZoneInfo {
|
|
|
1149
1266
|
* @example
|
|
1150
1267
|
* ```ts
|
|
1151
1268
|
* import { createClient } from 'viem'
|
|
1152
|
-
* import { Actions } from 'viem/tempo'
|
|
1153
|
-
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
1269
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1154
1270
|
*
|
|
1155
1271
|
* const client = createClient({
|
|
1156
|
-
* chain:
|
|
1272
|
+
* chain: Zone.a,
|
|
1157
1273
|
* transport: http(),
|
|
1158
1274
|
* })
|
|
1159
1275
|
*
|
|
@@ -1253,12 +1369,11 @@ export namespace waitForTempoBlock {
|
|
|
1253
1369
|
* ```ts
|
|
1254
1370
|
* import { createClient } from 'viem'
|
|
1255
1371
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1256
|
-
* import { http,
|
|
1257
|
-
* import { Actions } from 'viem/tempo'
|
|
1372
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1258
1373
|
*
|
|
1259
1374
|
* const client = createClient({
|
|
1260
1375
|
* account: privateKeyToAccount('0x...'),
|
|
1261
|
-
* chain:
|
|
1376
|
+
* chain: Zone.a,
|
|
1262
1377
|
* transport: http(),
|
|
1263
1378
|
* })
|
|
1264
1379
|
*
|
|
@@ -1352,7 +1467,7 @@ export namespace requestWithdrawal {
|
|
|
1352
1467
|
}),
|
|
1353
1468
|
defineCall({
|
|
1354
1469
|
address: Addresses.zoneOutbox,
|
|
1355
|
-
abi:
|
|
1470
|
+
abi: Abis.zoneOutbox,
|
|
1356
1471
|
functionName: 'requestWithdrawal',
|
|
1357
1472
|
args: [
|
|
1358
1473
|
TokenId.toAddress(token),
|
|
@@ -1377,11 +1492,10 @@ export namespace requestWithdrawal {
|
|
|
1377
1492
|
* @example
|
|
1378
1493
|
* ```ts
|
|
1379
1494
|
* import { createClient } from 'viem'
|
|
1380
|
-
* import { http,
|
|
1381
|
-
* import { Actions } from 'viem/tempo'
|
|
1495
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1382
1496
|
*
|
|
1383
1497
|
* const client = createClient({
|
|
1384
|
-
* chain:
|
|
1498
|
+
* chain: Zone.a,
|
|
1385
1499
|
* transport: http(),
|
|
1386
1500
|
* })
|
|
1387
1501
|
*
|
|
@@ -1537,17 +1651,11 @@ type WithdrawalCalls = ReturnType<typeof requestWithdrawal.calls>
|
|
|
1537
1651
|
* import { createClient, createPublicClient, http } from 'viem'
|
|
1538
1652
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1539
1653
|
* import { tempoModerato } from 'viem/chains'
|
|
1540
|
-
* import { Actions } from 'viem/tempo'
|
|
1541
|
-
* import {
|
|
1542
|
-
* Abis,
|
|
1543
|
-
* getPortalAddress,
|
|
1544
|
-
* http as zoneHttp,
|
|
1545
|
-
* zoneModerato,
|
|
1546
|
-
* } from 'viem/tempo/zones'
|
|
1654
|
+
* import { Abis, Actions, Addresses, http as zoneHttp, Zone } from 'viem/tempo'
|
|
1547
1655
|
*
|
|
1548
1656
|
* const client = createClient({
|
|
1549
1657
|
* account: privateKeyToAccount('0x...'),
|
|
1550
|
-
* chain:
|
|
1658
|
+
* chain: Zone.a,
|
|
1551
1659
|
* transport: zoneHttp(),
|
|
1552
1660
|
* })
|
|
1553
1661
|
*
|
|
@@ -1564,7 +1672,7 @@ type WithdrawalCalls = ReturnType<typeof requestWithdrawal.calls>
|
|
|
1564
1672
|
* transport: http(),
|
|
1565
1673
|
* })
|
|
1566
1674
|
* const [withdrawal] = await tempoClient.getContractEvents({
|
|
1567
|
-
* address:
|
|
1675
|
+
* address: Addresses.zonePortal(Zone.a.id),
|
|
1568
1676
|
* abi: Abis.zonePortal,
|
|
1569
1677
|
* eventName: 'WithdrawalProcessed',
|
|
1570
1678
|
* args: { senderTag },
|
|
@@ -1600,7 +1708,7 @@ export async function requestWithdrawalSync<
|
|
|
1600
1708
|
throwOnReceiptRevert,
|
|
1601
1709
|
} as never)
|
|
1602
1710
|
const [event] = parseEventLogs({
|
|
1603
|
-
abi:
|
|
1711
|
+
abi: Abis.zoneOutbox,
|
|
1604
1712
|
logs: receipt.logs,
|
|
1605
1713
|
eventName: 'WithdrawalRequested',
|
|
1606
1714
|
strict: true,
|
|
@@ -1645,12 +1753,11 @@ export namespace requestWithdrawalSync {
|
|
|
1645
1753
|
* ```ts
|
|
1646
1754
|
* import { createClient } from 'viem'
|
|
1647
1755
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1648
|
-
* import { http,
|
|
1649
|
-
* import { Actions } from 'viem/tempo'
|
|
1756
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1650
1757
|
*
|
|
1651
1758
|
* const client = createClient({
|
|
1652
1759
|
* account: privateKeyToAccount('0x...'),
|
|
1653
|
-
* chain:
|
|
1760
|
+
* chain: Zone.a,
|
|
1654
1761
|
* transport: http(),
|
|
1655
1762
|
* })
|
|
1656
1763
|
*
|
|
@@ -1734,7 +1841,7 @@ export namespace requestVerifiableWithdrawal {
|
|
|
1734
1841
|
}),
|
|
1735
1842
|
defineCall({
|
|
1736
1843
|
address: Addresses.zoneOutbox,
|
|
1737
|
-
abi:
|
|
1844
|
+
abi: Abis.zoneOutbox,
|
|
1738
1845
|
functionName: 'requestWithdrawal',
|
|
1739
1846
|
args: [
|
|
1740
1847
|
TokenId.toAddress(token),
|
|
@@ -1759,12 +1866,11 @@ export namespace requestVerifiableWithdrawal {
|
|
|
1759
1866
|
* ```ts
|
|
1760
1867
|
* import { createClient } from 'viem'
|
|
1761
1868
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1762
|
-
* import { http,
|
|
1763
|
-
* import { Actions } from 'viem/tempo'
|
|
1869
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1764
1870
|
*
|
|
1765
1871
|
* const client = createClient({
|
|
1766
1872
|
* account: privateKeyToAccount('0x...'),
|
|
1767
|
-
* chain:
|
|
1873
|
+
* chain: Zone.a,
|
|
1768
1874
|
* transport: http(),
|
|
1769
1875
|
* })
|
|
1770
1876
|
*
|
|
@@ -1826,19 +1932,17 @@ export namespace requestVerifiableWithdrawalSync {
|
|
|
1826
1932
|
/**
|
|
1827
1933
|
* Signs a zone authorization token and stores it for the zone HTTP transport.
|
|
1828
1934
|
*
|
|
1829
|
-
* Zone chains should define `contracts.zonePortal` with the portal address.
|
|
1830
1935
|
* The `zoneId` is derived from `ZoneId.fromChainId(chain.id)` and can be overridden.
|
|
1831
1936
|
*
|
|
1832
1937
|
* @example
|
|
1833
1938
|
* ```ts
|
|
1834
1939
|
* import { createClient } from 'viem'
|
|
1835
1940
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1836
|
-
* import { http,
|
|
1837
|
-
* import { Actions } from 'viem/tempo'
|
|
1941
|
+
* import { Actions, http, Zone } from 'viem/tempo'
|
|
1838
1942
|
*
|
|
1839
1943
|
* const client = createClient({
|
|
1840
1944
|
* account: privateKeyToAccount('0x...'),
|
|
1841
|
-
* chain:
|
|
1945
|
+
* chain: Zone.a,
|
|
1842
1946
|
* transport: http(),
|
|
1843
1947
|
* })
|
|
1844
1948
|
*
|