viem 2.19.9 → 2.20.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 (57) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/account-abstraction/accounts/toSmartAccount.js +4 -5
  3. package/_cjs/account-abstraction/accounts/toSmartAccount.js.map +1 -1
  4. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +12 -9
  5. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  6. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js +14 -8
  7. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
  8. package/_cjs/errors/version.js +1 -1
  9. package/_cjs/experimental/eip5792/actions/sendCalls.js +22 -7
  10. package/_cjs/experimental/eip5792/actions/sendCalls.js.map +1 -1
  11. package/_cjs/experimental/eip5792/actions/writeContracts.js.map +1 -1
  12. package/_cjs/op-stack/actions/getTimeToFinalize.js +7 -1
  13. package/_cjs/op-stack/actions/getTimeToFinalize.js.map +1 -1
  14. package/_cjs/op-stack/actions/getWithdrawalStatus.js +7 -1
  15. package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  16. package/_esm/account-abstraction/accounts/toSmartAccount.js +4 -5
  17. package/_esm/account-abstraction/accounts/toSmartAccount.js.map +1 -1
  18. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +12 -9
  19. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  20. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js +14 -8
  21. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
  22. package/_esm/errors/version.js +1 -1
  23. package/_esm/experimental/eip5792/actions/sendCalls.js +22 -7
  24. package/_esm/experimental/eip5792/actions/sendCalls.js.map +1 -1
  25. package/_esm/experimental/eip5792/actions/writeContracts.js +2 -0
  26. package/_esm/experimental/eip5792/actions/writeContracts.js.map +1 -1
  27. package/_esm/op-stack/actions/getTimeToFinalize.js +7 -1
  28. package/_esm/op-stack/actions/getTimeToFinalize.js.map +1 -1
  29. package/_esm/op-stack/actions/getWithdrawalStatus.js +7 -1
  30. package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  31. package/_types/account-abstraction/accounts/toSmartAccount.d.ts.map +1 -1
  32. package/_types/account-abstraction/accounts/types.d.ts +3 -0
  33. package/_types/account-abstraction/accounts/types.d.ts.map +1 -1
  34. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts +6 -4
  35. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  36. package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts +7 -5
  37. package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts.map +1 -1
  38. package/_types/errors/version.d.ts +1 -1
  39. package/_types/experimental/eip5792/actions/sendCalls.d.ts +33 -12
  40. package/_types/experimental/eip5792/actions/sendCalls.d.ts.map +1 -1
  41. package/_types/experimental/eip5792/actions/writeContracts.d.ts +2 -0
  42. package/_types/experimental/eip5792/actions/writeContracts.d.ts.map +1 -1
  43. package/_types/op-stack/actions/getTimeToFinalize.d.ts.map +1 -1
  44. package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
  45. package/_types/types/eip1193.d.ts +6 -6
  46. package/_types/types/eip1193.d.ts.map +1 -1
  47. package/account-abstraction/accounts/toSmartAccount.ts +12 -10
  48. package/account-abstraction/accounts/types.ts +3 -0
  49. package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +53 -32
  50. package/account-abstraction/actions/bundler/sendUserOperation.ts +50 -33
  51. package/errors/version.ts +1 -1
  52. package/experimental/eip5792/actions/sendCalls.ts +107 -21
  53. package/experimental/eip5792/actions/writeContracts.ts +2 -0
  54. package/op-stack/actions/getTimeToFinalize.ts +8 -1
  55. package/op-stack/actions/getWithdrawalStatus.ts +8 -1
  56. package/package.json +1 -1
  57. package/types/eip1193.ts +8 -11
@@ -10,7 +10,12 @@ import type { BaseError } from '../../../errors/base.js'
10
10
  import type { ErrorType } from '../../../errors/utils.js'
11
11
  import type { Chain } from '../../../types/chain.js'
12
12
  import type { Hex } from '../../../types/misc.js'
13
- import type { Assign, OneOf, Prettify } from '../../../types/utils.js'
13
+ import type {
14
+ Assign,
15
+ MaybeRequired,
16
+ OneOf,
17
+ Prettify,
18
+ } from '../../../types/utils.js'
14
19
  import type { RequestErrorType } from '../../../utils/buildRequest.js'
15
20
  import { getAction } from '../../../utils/getAction.js'
16
21
  import type { SmartAccount } from '../../accounts/types.js'
@@ -55,26 +60,39 @@ export type EstimateUserOperationGasParameters<
55
60
  >,
56
61
  _derivedVersion extends
57
62
  EntryPointVersion = DeriveEntryPointVersion<_derivedAccount>,
58
- > = Assign<
59
- UserOperationRequest<_derivedVersion>,
60
- OneOf<{ calls: UserOperationCalls<Narrow<calls>> } | { callData: Hex }> & {
61
- paymaster?:
62
- | Address
63
- | true
64
- | {
65
- /** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
66
- getPaymasterData?: PaymasterActions['getPaymasterData'] | undefined
67
- /** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
68
- getPaymasterStubData?:
69
- | PaymasterActions['getPaymasterStubData']
63
+ > = GetSmartAccountParameter<account, accountOverride, false> &
64
+ (
65
+ | UserOperation // Accept a full-formed User Operation.
66
+ | Assign<
67
+ // Accept a partially-formed User Operation (UserOperationRequest) to be filled.
68
+ UserOperationRequest<_derivedVersion>,
69
+ OneOf<
70
+ { calls: UserOperationCalls<Narrow<calls>> } | { callData: Hex }
71
+ > & {
72
+ paymaster?:
73
+ | Address
74
+ | true
75
+ | {
76
+ /** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
77
+ getPaymasterData?:
78
+ | PaymasterActions['getPaymasterData']
79
+ | undefined
80
+ /** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
81
+ getPaymasterStubData?:
82
+ | PaymasterActions['getPaymasterStubData']
83
+ | undefined
84
+ }
70
85
  | undefined
86
+ /** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
87
+ paymasterContext?: unknown | undefined
71
88
  }
72
- | undefined
73
- /** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
74
- paymasterContext?: unknown | undefined
75
- }
76
- > &
77
- GetSmartAccountParameter<account, accountOverride>
89
+ >
90
+ ) &
91
+ // Allow the EntryPoint address to be overridden, if no Account is provided, it will need to be required.
92
+ MaybeRequired<
93
+ { entryPointAddress?: Address },
94
+ _derivedAccount extends undefined ? true : false
95
+ >
78
96
 
79
97
  export type EstimateUserOperationGasReturnType<
80
98
  account extends SmartAccount | undefined = SmartAccount | undefined,
@@ -135,26 +153,28 @@ export async function estimateUserOperationGas<
135
153
  calls
136
154
  >,
137
155
  ): Promise<EstimateUserOperationGasReturnType<account, accountOverride>> {
138
- const { account: account_ = client.account } = parameters
156
+ const { account: account_ = client.account, entryPointAddress } = parameters
139
157
 
140
- if (!account_) throw new AccountNotFoundError()
141
- const account = parseAccount(account_)
158
+ if (!account_ && !parameters.sender) throw new AccountNotFoundError()
159
+ const account = account_ ? parseAccount(account_) : undefined
142
160
 
143
- const request = await getAction(
144
- client,
145
- prepareUserOperation,
146
- 'prepareUserOperation',
147
- )({
148
- ...parameters,
149
- parameters: ['factory', 'nonce', 'paymaster', 'signature'],
150
- } as unknown as PrepareUserOperationParameters)
161
+ const request = account
162
+ ? await getAction(
163
+ client,
164
+ prepareUserOperation,
165
+ 'prepareUserOperation',
166
+ )({
167
+ ...parameters,
168
+ parameters: ['factory', 'nonce', 'paymaster', 'signature'],
169
+ } as unknown as PrepareUserOperationParameters)
170
+ : parameters
151
171
 
152
172
  try {
153
173
  const result = await client.request({
154
174
  method: 'eth_estimateUserOperationGas',
155
175
  params: [
156
176
  formatUserOperationRequest(request as UserOperation),
157
- account.entryPoint.address,
177
+ (entryPointAddress ?? account?.entryPoint?.address)!,
158
178
  ],
159
179
  })
160
180
  return formatUserOperationGas(result) as EstimateUserOperationGasReturnType<
@@ -162,9 +182,10 @@ export async function estimateUserOperationGas<
162
182
  accountOverride
163
183
  >
164
184
  } catch (error) {
185
+ const calls = (parameters as any).calls
165
186
  throw getUserOperationError(error as BaseError, {
166
187
  ...(request as UserOperation),
167
- calls: parameters.calls,
188
+ ...(calls ? { calls } : {}),
168
189
  })
169
190
  }
170
191
  }
@@ -7,7 +7,7 @@ import type { BaseError } from '../../../errors/base.js'
7
7
  import type { ErrorType } from '../../../errors/utils.js'
8
8
  import type { Chain } from '../../../types/chain.js'
9
9
  import type { Hex } from '../../../types/misc.js'
10
- import type { Assign, OneOf } from '../../../types/utils.js'
10
+ import type { Assign, MaybeRequired, OneOf } from '../../../types/utils.js'
11
11
  import type { RequestErrorType } from '../../../utils/buildRequest.js'
12
12
  import { getAction } from '../../../utils/getAction.js'
13
13
  import type { SmartAccount } from '../../accounts/types.js'
@@ -47,27 +47,39 @@ export type SendUserOperationParameters<
47
47
  >,
48
48
  _derivedVersion extends
49
49
  EntryPointVersion = DeriveEntryPointVersion<_derivedAccount>,
50
- > = Assign<
51
- UserOperationRequest<_derivedVersion>,
52
- OneOf<{ calls: UserOperationCalls<Narrow<calls>> } | { callData: Hex }> & {
53
- paymaster?:
54
- | Address
55
- | true
56
- | {
57
- /** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
58
- getPaymasterData?: PaymasterActions['getPaymasterData'] | undefined
59
- /** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
60
- getPaymasterStubData?:
61
- | PaymasterActions['getPaymasterStubData']
50
+ > = GetSmartAccountParameter<account, accountOverride, false> &
51
+ (
52
+ | UserOperation // Accept a full-formed User Operation.
53
+ | Assign<
54
+ // Accept a partially-formed User Operation (UserOperationRequest) to be filled.
55
+ UserOperationRequest<_derivedVersion>,
56
+ OneOf<
57
+ { calls: UserOperationCalls<Narrow<calls>> } | { callData: Hex }
58
+ > & {
59
+ paymaster?:
60
+ | Address
61
+ | true
62
+ | {
63
+ /** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
64
+ getPaymasterData?:
65
+ | PaymasterActions['getPaymasterData']
66
+ | undefined
67
+ /** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
68
+ getPaymasterStubData?:
69
+ | PaymasterActions['getPaymasterStubData']
70
+ | undefined
71
+ }
62
72
  | undefined
73
+ /** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
74
+ paymasterContext?: unknown | undefined
63
75
  }
64
- | undefined
65
- /** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
66
- paymasterContext?: unknown
67
- }
68
- > &
69
- GetSmartAccountParameter<account, accountOverride>
70
-
76
+ >
77
+ ) &
78
+ // Allow the EntryPoint address to be overridden, if no Account is provided, it will need to be required.
79
+ MaybeRequired<
80
+ { entryPointAddress?: Address },
81
+ _derivedAccount extends undefined ? true : false
82
+ >
71
83
  export type SendUserOperationReturnType = Hex
72
84
 
73
85
  export type SendUserOperationErrorType =
@@ -111,20 +123,21 @@ export async function sendUserOperation<
111
123
  client: Client<Transport, Chain | undefined, account>,
112
124
  parameters: SendUserOperationParameters<account, accountOverride, calls>,
113
125
  ) {
114
- const { account: account_ = client.account } = parameters
126
+ const { account: account_ = client.account, entryPointAddress } = parameters
115
127
 
116
- if (!account_) throw new AccountNotFoundError()
117
- const account = parseAccount(account_)
128
+ if (!account_ && !parameters.sender) throw new AccountNotFoundError()
129
+ const account = account_ ? parseAccount(account_) : undefined
118
130
 
119
- const request = await getAction(
120
- client,
121
- prepareUserOperation,
122
- 'prepareUserOperation',
123
- )(parameters as unknown as PrepareUserOperationParameters)
131
+ const request = account
132
+ ? await getAction(
133
+ client,
134
+ prepareUserOperation,
135
+ 'prepareUserOperation',
136
+ )(parameters as unknown as PrepareUserOperationParameters)
137
+ : parameters
124
138
 
125
- const signature =
126
- parameters.signature ||
127
- (await account.signUserOperation(request as UserOperation))
139
+ const signature = (parameters.signature ||
140
+ (await account?.signUserOperation(request as UserOperation)))!
128
141
 
129
142
  const rpcParameters = formatUserOperationRequest({
130
143
  ...request,
@@ -135,14 +148,18 @@ export async function sendUserOperation<
135
148
  return await client.request(
136
149
  {
137
150
  method: 'eth_sendUserOperation',
138
- params: [rpcParameters, account.entryPoint.address],
151
+ params: [
152
+ rpcParameters,
153
+ (entryPointAddress ?? account?.entryPoint.address)!,
154
+ ],
139
155
  },
140
156
  { retryCount: 0 },
141
157
  )
142
158
  } catch (error) {
159
+ const calls = (parameters as any).calls
143
160
  throw getUserOperationError(error as BaseError, {
144
161
  ...(request as UserOperation),
145
- calls: parameters.calls,
162
+ ...(calls ? { calls } : {}),
146
163
  signature,
147
164
  })
148
165
  }
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.19.9'
1
+ export const version = '2.20.0'
@@ -1,3 +1,4 @@
1
+ import type { AbiStateMutability, Address, Narrow } from 'abitype'
1
2
  import { parseAccount } from '../../../accounts/utils/parseAccount.js'
2
3
  import type { Client } from '../../../clients/createClient.js'
3
4
  import type { Transport } from '../../../clients/transports/createTransport.js'
@@ -6,13 +7,16 @@ import type { BaseError } from '../../../errors/base.js'
6
7
  import { ChainNotFoundError } from '../../../errors/chain.js'
7
8
  import type { ErrorType } from '../../../errors/utils.js'
8
9
  import type { Account, GetAccountParameter } from '../../../types/account.js'
9
- import type { Chain, GetChainParameter } from '../../../types/chain.js'
10
+ import type { Chain, DeriveChain } from '../../../types/chain.js'
11
+ import type { ContractFunctionParameters } from '../../../types/contract.js'
10
12
  import type {
11
13
  WalletCapabilities,
12
14
  WalletSendCallsParameters,
13
15
  } from '../../../types/eip1193.js'
14
16
  import type { Hex } from '../../../types/misc.js'
15
- import type { OneOf } from '../../../types/utils.js'
17
+ import type { GetMulticallContractParameters } from '../../../types/multicall.js'
18
+ import type { MaybeRequired, OneOf, Prettify } from '../../../types/utils.js'
19
+ import { encodeFunctionData } from '../../../utils/abi/encodeFunctionData.js'
16
20
  import type { RequestErrorType } from '../../../utils/buildRequest.js'
17
21
  import { numberToHex } from '../../../utils/encoding/toHex.js'
18
22
  import { getTransactionError } from '../../../utils/errors/getTransactionError.js'
@@ -21,23 +25,17 @@ export type SendCallsParameters<
21
25
  chain extends Chain | undefined = Chain | undefined,
22
26
  account extends Account | undefined = Account | undefined,
23
27
  chainOverride extends Chain | undefined = Chain | undefined,
28
+ calls extends readonly unknown[] = readonly unknown[],
29
+ //
30
+ _chain extends Chain | undefined = DeriveChain<chain, chainOverride>,
24
31
  > = {
25
- calls: OneOf<
26
- | {
27
- to: Hex
28
- data?: Hex | undefined
29
- value?: bigint | undefined
30
- }
31
- | {
32
- data: Hex
33
- }
34
- >[]
32
+ chain?: chainOverride | Chain | undefined
33
+ calls: Calls<Narrow<calls>, _chain>
35
34
  capabilities?:
36
35
  | WalletSendCallsParameters<WalletCapabilities>[number]['capabilities']
37
36
  | undefined
38
37
  version?: WalletSendCallsParameters[number]['version'] | undefined
39
- } & GetAccountParameter<account> &
40
- GetChainParameter<chain, chainOverride>
38
+ } & GetAccountParameter<account>
41
39
 
42
40
  export type SendCallsReturnType = string
43
41
 
@@ -76,16 +74,16 @@ export type SendCallsErrorType = RequestErrorType | ErrorType
76
74
  * })
77
75
  */
78
76
  export async function sendCalls<
77
+ const calls extends readonly unknown[],
79
78
  chain extends Chain | undefined,
80
79
  account extends Account | undefined = undefined,
81
80
  chainOverride extends Chain | undefined = undefined,
82
81
  >(
83
82
  client: Client<Transport, chain, account>,
84
- parameters: SendCallsParameters<chain, account, chainOverride>,
83
+ parameters: SendCallsParameters<chain, account, chainOverride, calls>,
85
84
  ): Promise<SendCallsReturnType> {
86
85
  const {
87
86
  account: account_ = client.account,
88
- calls,
89
87
  capabilities,
90
88
  chain = client.chain,
91
89
  version = '1.0',
@@ -97,7 +95,27 @@ export async function sendCalls<
97
95
  })
98
96
  const account = parseAccount(account_)
99
97
 
100
- if (!chain) throw new ChainNotFoundError()
98
+ const calls = parameters.calls.map((call_: unknown) => {
99
+ const call = call_ as Call
100
+
101
+ const chainId = call.chain?.id ?? call.chainId ?? chain?.id
102
+ if (!chainId) throw new ChainNotFoundError()
103
+
104
+ const data = call.abi
105
+ ? encodeFunctionData({
106
+ abi: call.abi,
107
+ functionName: call.functionName,
108
+ args: call.args,
109
+ })
110
+ : call.data
111
+
112
+ return {
113
+ chainId: numberToHex(chainId),
114
+ data,
115
+ to: call.to,
116
+ value: call.value ? numberToHex(call.value) : undefined,
117
+ }
118
+ })
101
119
 
102
120
  try {
103
121
  return await client.request(
@@ -105,10 +123,7 @@ export async function sendCalls<
105
123
  method: 'wallet_sendCalls',
106
124
  params: [
107
125
  {
108
- calls: calls.map((call) => ({
109
- ...call,
110
- value: call.value ? numberToHex(call.value) : undefined,
111
- })) as any,
126
+ calls,
112
127
  capabilities,
113
128
  chainId: numberToHex(chain!.id),
114
129
  from: account.address,
@@ -126,3 +141,74 @@ export async function sendCalls<
126
141
  })
127
142
  }
128
143
  }
144
+
145
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
146
+
147
+ type RawCall = { data?: Hex; to?: Address; value?: bigint }
148
+
149
+ type Call<
150
+ chain extends Chain | undefined = Chain | undefined,
151
+ contractFunctionParameters = Omit<ContractFunctionParameters, 'address'>,
152
+ > = OneOf<
153
+ | (contractFunctionParameters & {
154
+ to: Address
155
+ value?: bigint | undefined
156
+ })
157
+ | RawCall
158
+ > &
159
+ OneOf<
160
+ | MaybeRequired<
161
+ { chain?: Chain | undefined },
162
+ chain extends Chain ? false : true
163
+ >
164
+ | MaybeRequired<{ chainId?: number }, chain extends Chain ? false : true>
165
+ >
166
+
167
+ type Calls<
168
+ calls extends readonly unknown[],
169
+ chain extends Chain | undefined,
170
+ ///
171
+ result extends readonly any[] = [],
172
+ > = calls extends readonly [] // no calls, return empty
173
+ ? readonly []
174
+ : calls extends readonly [infer call] // one call left before returning `result`
175
+ ? readonly [
176
+ ...result,
177
+ Prettify<
178
+ Call<
179
+ chain,
180
+ Omit<
181
+ GetMulticallContractParameters<call, AbiStateMutability>,
182
+ 'address'
183
+ >
184
+ >
185
+ >,
186
+ ]
187
+ : calls extends readonly [infer call, ...infer rest] // grab first call and recurse through `rest`
188
+ ? Calls<
189
+ [...rest],
190
+ chain,
191
+ [
192
+ ...result,
193
+ Prettify<
194
+ Call<
195
+ chain,
196
+ Omit<
197
+ GetMulticallContractParameters<call, AbiStateMutability>,
198
+ 'address'
199
+ >
200
+ >
201
+ >,
202
+ ]
203
+ >
204
+ : readonly unknown[] extends calls
205
+ ? calls
206
+ : // If `calls` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
207
+ // use this to infer the param types in the case of Array.map() argument
208
+ calls extends readonly (infer call extends Call<
209
+ chain,
210
+ Omit<ContractFunctionParameters, 'address'>
211
+ >)[]
212
+ ? readonly Prettify<call>[]
213
+ : // Fallback
214
+ readonly Call<chain, Omit<ContractFunctionParameters, 'address'>>[]
@@ -50,6 +50,8 @@ export type WriteContractsErrorType =
50
50
  | ErrorType
51
51
 
52
52
  /**
53
+ * @deprecated Use {@link sendCalls} instead. See https://viem.sh/experimental/eip5792/sendCalls#contract-calls.
54
+ *
53
55
  * Requests for the wallet to sign and broadcast a batch of write contract calls (transactions) to the network.
54
56
  *
55
57
  * - Docs: https://viem.sh/experimental/eip5792/writeContracts
@@ -128,11 +128,18 @@ export async function getTimeToFinalize<
128
128
  return { period: Number(period), seconds, timestamp }
129
129
  }
130
130
 
131
+ const numProofSubmitters = await readContract(client, {
132
+ abi: portal2Abi,
133
+ address: portalAddress,
134
+ functionName: 'numProofSubmitters',
135
+ args: [withdrawalHash],
136
+ }).catch(() => 1n)
137
+
131
138
  const proofSubmitter = await readContract(client, {
132
139
  abi: portal2Abi,
133
140
  address: portalAddress,
134
141
  functionName: 'proofSubmitters',
135
- args: [withdrawalHash, 0n],
142
+ args: [withdrawalHash, numProofSubmitters - 1n],
136
143
  }).catch(() => undefined)
137
144
 
138
145
  const [[_disputeGameProxy, proveTimestamp], proofMaturityDelaySeconds] =
@@ -197,11 +197,18 @@ export async function getWithdrawalStatus<
197
197
  return seconds > 0 ? 'waiting-to-finalize' : 'ready-to-finalize'
198
198
  }
199
199
 
200
+ const numProofSubmitters = await readContract(client, {
201
+ abi: portal2Abi,
202
+ address: portalAddress,
203
+ functionName: 'numProofSubmitters',
204
+ args: [withdrawal.withdrawalHash],
205
+ }).catch(() => 1n)
206
+
200
207
  const proofSubmitter = await readContract(client, {
201
208
  abi: portal2Abi,
202
209
  address: portalAddress,
203
210
  functionName: 'proofSubmitters',
204
- args: [withdrawal.withdrawalHash, 0n],
211
+ args: [withdrawal.withdrawalHash, numProofSubmitters - 1n],
205
212
  }).catch(() => withdrawal.sender)
206
213
 
207
214
  const [disputeGameResult, checkWithdrawalResult, finalizedResult] =
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.19.9",
4
+ "version": "2.20.0",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/eip1193.ts CHANGED
@@ -207,18 +207,15 @@ export type WalletSendCallsParameters<
207
207
  quantity extends Quantity | bigint = Quantity,
208
208
  > = [
209
209
  {
210
- calls: OneOf<
211
- | {
212
- to: Address
213
- data?: Hex | undefined
214
- value?: quantity | undefined
215
- }
216
- | {
217
- data: Hex
218
- }
219
- >[]
210
+ calls: readonly {
211
+ chainId?: chainId | undefined
212
+ to?: Address | undefined
213
+ data?: Hex | undefined
214
+ value?: quantity | undefined
215
+ }[]
220
216
  capabilities?: capabilities | undefined
221
- chainId: chainId
217
+ /** @deprecated Use `chainId` on `calls` instead. */
218
+ chainId?: chainId | undefined
222
219
  from: Address
223
220
  version: string
224
221
  },