viem 2.23.3 → 2.23.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 (43) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/chains/definitions/ethernity.js +30 -0
  3. package/_cjs/chains/definitions/ethernity.js.map +1 -0
  4. package/_cjs/chains/definitions/xdc.js +1 -1
  5. package/_cjs/chains/definitions/xdc.js.map +1 -1
  6. package/_cjs/chains/index.js +11 -9
  7. package/_cjs/chains/index.js.map +1 -1
  8. package/_cjs/errors/version.js +1 -1
  9. package/_cjs/experimental/eip5792/actions/sendCalls.js +3 -3
  10. package/_cjs/experimental/eip5792/actions/sendCalls.js.map +1 -1
  11. package/_cjs/op-stack/actions/getWithdrawalStatus.js +17 -7
  12. package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  13. package/_esm/chains/definitions/ethernity.js +27 -0
  14. package/_esm/chains/definitions/ethernity.js.map +1 -0
  15. package/_esm/chains/definitions/xdc.js +1 -1
  16. package/_esm/chains/definitions/xdc.js.map +1 -1
  17. package/_esm/chains/index.js +1 -0
  18. package/_esm/chains/index.js.map +1 -1
  19. package/_esm/errors/version.js +1 -1
  20. package/_esm/experimental/eip5792/actions/sendCalls.js +3 -3
  21. package/_esm/experimental/eip5792/actions/sendCalls.js.map +1 -1
  22. package/_esm/op-stack/actions/getWithdrawalStatus.js +17 -7
  23. package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  24. package/_types/chains/definitions/ethernity.d.ts +33 -0
  25. package/_types/chains/definitions/ethernity.d.ts.map +1 -0
  26. package/_types/chains/definitions/xdc.d.ts +1 -1
  27. package/_types/chains/index.d.ts +1 -0
  28. package/_types/chains/index.d.ts.map +1 -1
  29. package/_types/errors/version.d.ts +1 -1
  30. package/_types/experimental/eip5792/actions/sendCalls.d.ts +2 -2
  31. package/_types/experimental/eip5792/actions/sendCalls.d.ts.map +1 -1
  32. package/_types/op-stack/actions/getWithdrawalStatus.d.ts +20 -1
  33. package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
  34. package/_types/types/eip1193.d.ts +1 -3
  35. package/_types/types/eip1193.d.ts.map +1 -1
  36. package/chains/definitions/ethernity.ts +27 -0
  37. package/chains/definitions/xdc.ts +1 -1
  38. package/chains/index.ts +1 -0
  39. package/errors/version.ts +1 -1
  40. package/experimental/eip5792/actions/sendCalls.ts +5 -5
  41. package/op-stack/actions/getWithdrawalStatus.ts +46 -14
  42. package/package.json +1 -1
  43. package/types/eip1193.ts +1 -3
@@ -1,3 +1,4 @@
1
+ import type { Address } from 'abitype'
1
2
  import {
2
3
  type ReadContractErrorType,
3
4
  readContract,
@@ -12,6 +13,7 @@ import type {
12
13
  DeriveChain,
13
14
  GetChainParameter,
14
15
  } from '../../types/chain.js'
16
+ import type { Hash } from '../../types/misc.js'
15
17
  import type { TransactionReceipt } from '../../types/transaction.js'
16
18
  import type { OneOf } from '../../types/utils.js'
17
19
  import { portal2Abi, portalAbi } from '../abis.js'
@@ -62,13 +64,33 @@ export type GetWithdrawalStatusParameters<
62
64
  * @default 100
63
65
  */
64
66
  gameLimit?: number
65
- /**
66
- * The relative index of the withdrawal in the transaction receipt logs.
67
- * @default 0
68
- */
69
- logIndex?: number
70
- receipt: TransactionReceipt
71
- }
67
+ } & OneOf<
68
+ | {
69
+ /**
70
+ * The relative index of the withdrawal in the transaction receipt logs.
71
+ * @default 0
72
+ */
73
+ logIndex?: number
74
+ /**
75
+ * The transaction receipt of the withdrawal.
76
+ */
77
+ receipt: TransactionReceipt
78
+ }
79
+ | {
80
+ /**
81
+ * The L2 block number of the withdrawal.
82
+ */
83
+ l2BlockNumber: bigint
84
+ /**
85
+ * The sender of the withdrawal.
86
+ */
87
+ sender: Address
88
+ /**
89
+ * The hash of the withdrawal.
90
+ */
91
+ withdrawalHash: Hash
92
+ }
93
+ >
72
94
  export type GetWithdrawalStatusReturnType =
73
95
  | 'waiting-to-prove'
74
96
  | 'ready-to-prove'
@@ -138,12 +160,22 @@ export async function getWithdrawalStatus<
138
160
  return Object.values(targetChain.contracts.portal)[0].address
139
161
  })()
140
162
 
141
- const withdrawal = getWithdrawals(receipt)[logIndex]
163
+ const l2BlockNumber = receipt?.blockNumber ?? parameters.l2BlockNumber
142
164
 
143
- if (!withdrawal)
144
- throw new ReceiptContainsNoWithdrawalsError({
145
- hash: receipt.transactionHash,
146
- })
165
+ const withdrawal = (() => {
166
+ if (receipt) {
167
+ const withdrawal = getWithdrawals({ logs: receipt.logs })[logIndex]
168
+ if (!withdrawal)
169
+ throw new ReceiptContainsNoWithdrawalsError({
170
+ hash: receipt.transactionHash,
171
+ })
172
+ return withdrawal
173
+ }
174
+ return {
175
+ sender: parameters.sender,
176
+ withdrawalHash: parameters.withdrawalHash,
177
+ }
178
+ })()
147
179
 
148
180
  const portalVersion = await getPortalVersion(
149
181
  client,
@@ -156,7 +188,7 @@ export async function getWithdrawalStatus<
156
188
  await Promise.allSettled([
157
189
  getL2Output(client, {
158
190
  ...parameters,
159
- l2BlockNumber: receipt.blockNumber,
191
+ l2BlockNumber,
160
192
  } as GetL2OutputParameters),
161
193
  readContract(client, {
162
194
  abi: portalAbi,
@@ -221,7 +253,7 @@ export async function getWithdrawalStatus<
221
253
  await Promise.allSettled([
222
254
  getGame(client, {
223
255
  ...parameters,
224
- l2BlockNumber: receipt.blockNumber,
256
+ l2BlockNumber,
225
257
  limit: gameLimit,
226
258
  } as GetGameParameters),
227
259
  readContract(client, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.23.3",
4
+ "version": "2.23.4",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/eip1193.ts CHANGED
@@ -210,15 +210,13 @@ export type WalletSendCallsParameters<
210
210
  > = [
211
211
  {
212
212
  calls: readonly {
213
- chainId?: chainId | undefined
214
213
  to?: Address | undefined
215
214
  data?: Hex | undefined
216
215
  value?: quantity | undefined
217
216
  }[]
218
217
  capabilities?: capabilities | undefined
219
- /** @deprecated Use `chainId` on `calls` instead. */
220
218
  chainId?: chainId | undefined
221
- from: Address
219
+ from?: Address | undefined
222
220
  version: string
223
221
  },
224
222
  ]