viem 1.6.0 → 1.6.3

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 (179) hide show
  1. package/dist/cjs/actions/ens/getEnsAddress.js +2 -2
  2. package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
  3. package/dist/cjs/actions/getContract.js.map +1 -1
  4. package/dist/cjs/actions/public/multicall.js +2 -3
  5. package/dist/cjs/actions/public/multicall.js.map +1 -1
  6. package/dist/cjs/chains/index.js +2 -1
  7. package/dist/cjs/chains/index.js.map +1 -1
  8. package/dist/cjs/clients/decorators/public.js.map +1 -1
  9. package/dist/cjs/constants/number.js +96 -96
  10. package/dist/cjs/constants/number.js.map +1 -1
  11. package/dist/cjs/errors/version.js +1 -1
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  14. package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
  15. package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
  16. package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
  17. package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
  18. package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
  19. package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
  20. package/dist/cjs/utils/abi/encodePacked.js.map +1 -1
  21. package/dist/cjs/utils/poll.js +1 -1
  22. package/dist/cjs/utils/poll.js.map +1 -1
  23. package/dist/cjs/utils/typedData.js +2 -2
  24. package/dist/cjs/utils/typedData.js.map +1 -1
  25. package/dist/esm/actions/ens/getEnsAddress.js +2 -2
  26. package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
  27. package/dist/esm/actions/getContract.js.map +1 -1
  28. package/dist/esm/actions/public/multicall.js +2 -4
  29. package/dist/esm/actions/public/multicall.js.map +1 -1
  30. package/dist/esm/chains/index.js +1 -0
  31. package/dist/esm/chains/index.js.map +1 -1
  32. package/dist/esm/clients/decorators/public.js.map +1 -1
  33. package/dist/esm/constants/number.js +96 -96
  34. package/dist/esm/constants/number.js.map +1 -1
  35. package/dist/esm/errors/version.js +1 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
  38. package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
  39. package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
  40. package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
  41. package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
  42. package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
  43. package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
  44. package/dist/esm/utils/abi/encodePacked.js.map +1 -1
  45. package/dist/esm/utils/poll.js +1 -1
  46. package/dist/esm/utils/poll.js.map +1 -1
  47. package/dist/esm/utils/typedData.js +2 -2
  48. package/dist/esm/utils/typedData.js.map +1 -1
  49. package/dist/types/accounts/types.d.ts +1 -1
  50. package/dist/types/accounts/types.d.ts.map +1 -1
  51. package/dist/types/accounts/utils/signTypedData.d.ts +1 -1
  52. package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
  53. package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
  54. package/dist/types/actions/getContract.d.ts +5 -5
  55. package/dist/types/actions/getContract.d.ts.map +1 -1
  56. package/dist/types/actions/public/createContractEventFilter.d.ts +3 -3
  57. package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
  58. package/dist/types/actions/public/createEventFilter.d.ts +5 -5
  59. package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
  60. package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
  61. package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
  62. package/dist/types/actions/public/getFilterChanges.d.ts +1 -1
  63. package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
  64. package/dist/types/actions/public/getFilterLogs.d.ts +1 -1
  65. package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
  66. package/dist/types/actions/public/getLogs.d.ts +4 -4
  67. package/dist/types/actions/public/getLogs.d.ts.map +1 -1
  68. package/dist/types/actions/public/multicall.d.ts +1 -1
  69. package/dist/types/actions/public/multicall.d.ts.map +1 -1
  70. package/dist/types/actions/public/readContract.d.ts +1 -1
  71. package/dist/types/actions/public/readContract.d.ts.map +1 -1
  72. package/dist/types/actions/public/simulateContract.d.ts +1 -1
  73. package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
  74. package/dist/types/actions/public/watchContractEvent.d.ts +3 -3
  75. package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
  76. package/dist/types/actions/public/watchEvent.d.ts +4 -4
  77. package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
  78. package/dist/types/actions/wallet/deployContract.d.ts +3 -3
  79. package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
  80. package/dist/types/actions/wallet/signTypedData.d.ts +1 -1
  81. package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
  82. package/dist/types/actions/wallet/writeContract.d.ts +1 -1
  83. package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
  84. package/dist/types/chains/index.d.ts +154 -36
  85. package/dist/types/chains/index.d.ts.map +1 -1
  86. package/dist/types/clients/decorators/public.d.ts +10 -10
  87. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  88. package/dist/types/clients/decorators/wallet.d.ts +3 -3
  89. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  90. package/dist/types/constants/number.d.ts.map +1 -1
  91. package/dist/types/errors/version.d.ts +1 -1
  92. package/dist/types/index.d.ts +2 -2
  93. package/dist/types/index.d.ts.map +1 -1
  94. package/dist/types/types/eip1193.d.ts +1 -1
  95. package/dist/types/types/eip1193.d.ts.map +1 -1
  96. package/dist/types/types/multicall.d.ts +8 -8
  97. package/dist/types/types/multicall.d.ts.map +1 -1
  98. package/dist/types/types/typedData.d.ts +3 -3
  99. package/dist/types/types/typedData.d.ts.map +1 -1
  100. package/dist/types/utils/abi/decodeAbiParameters.d.ts +2 -2
  101. package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  102. package/dist/types/utils/abi/decodeDeployData.d.ts +3 -3
  103. package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
  104. package/dist/types/utils/abi/decodeErrorResult.d.ts +3 -3
  105. package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
  106. package/dist/types/utils/abi/decodeEventLog.d.ts +3 -3
  107. package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
  108. package/dist/types/utils/abi/decodeFunctionResult.d.ts +4 -4
  109. package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
  110. package/dist/types/utils/abi/encodeAbiParameters.d.ts +2 -2
  111. package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
  112. package/dist/types/utils/abi/encodeDeployData.d.ts +3 -3
  113. package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
  114. package/dist/types/utils/abi/encodeErrorResult.d.ts +4 -4
  115. package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
  116. package/dist/types/utils/abi/encodeEventTopics.d.ts +4 -4
  117. package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  118. package/dist/types/utils/abi/encodeFunctionData.d.ts +4 -4
  119. package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
  120. package/dist/types/utils/abi/encodeFunctionResult.d.ts +4 -4
  121. package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
  122. package/dist/types/utils/abi/encodePacked.d.ts +3 -3
  123. package/dist/types/utils/abi/encodePacked.d.ts.map +1 -1
  124. package/dist/types/utils/abi/getAbiItem.d.ts +3 -3
  125. package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
  126. package/dist/types/utils/signature/hashTypedData.d.ts +1 -1
  127. package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
  128. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +1 -1
  129. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
  130. package/dist/types/utils/signature/verifyTypedData.d.ts +1 -1
  131. package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
  132. package/dist/types/utils/typedData.d.ts +1 -1
  133. package/dist/types/utils/typedData.d.ts.map +1 -1
  134. package/package.json +2 -2
  135. package/src/accounts/types.ts +1 -1
  136. package/src/accounts/utils/signTypedData.ts +1 -1
  137. package/src/actions/ens/getEnsAddress.ts +6 -8
  138. package/src/actions/getContract.ts +6 -5
  139. package/src/actions/public/createContractEventFilter.ts +3 -3
  140. package/src/actions/public/createEventFilter.ts +6 -6
  141. package/src/actions/public/estimateContractGas.ts +1 -1
  142. package/src/actions/public/getFilterChanges.ts +1 -1
  143. package/src/actions/public/getFilterLogs.ts +1 -1
  144. package/src/actions/public/getLogs.ts +5 -5
  145. package/src/actions/public/multicall.ts +9 -8
  146. package/src/actions/public/readContract.ts +1 -1
  147. package/src/actions/public/simulateContract.ts +1 -1
  148. package/src/actions/public/watchContractEvent.ts +3 -3
  149. package/src/actions/public/watchEvent.ts +5 -5
  150. package/src/actions/wallet/deployContract.ts +3 -3
  151. package/src/actions/wallet/signTypedData.ts +1 -1
  152. package/src/actions/wallet/writeContract.ts +1 -1
  153. package/src/chains/index.ts +1 -0
  154. package/src/clients/decorators/public.ts +14 -14
  155. package/src/clients/decorators/wallet.ts +3 -3
  156. package/src/constants/number.ts +96 -96
  157. package/src/errors/version.ts +1 -1
  158. package/src/index.ts +2 -0
  159. package/src/types/eip1193.ts +1 -1
  160. package/src/types/multicall.ts +14 -11
  161. package/src/types/typedData.ts +2 -3
  162. package/src/utils/abi/decodeAbiParameters.ts +7 -8
  163. package/src/utils/abi/decodeDeployData.ts +3 -3
  164. package/src/utils/abi/decodeErrorResult.ts +3 -8
  165. package/src/utils/abi/decodeEventLog.ts +3 -3
  166. package/src/utils/abi/decodeFunctionResult.ts +4 -6
  167. package/src/utils/abi/encodeAbiParameters.ts +8 -9
  168. package/src/utils/abi/encodeDeployData.ts +3 -3
  169. package/src/utils/abi/encodeErrorResult.ts +4 -4
  170. package/src/utils/abi/encodeEventTopics.ts +4 -9
  171. package/src/utils/abi/encodeFunctionData.ts +4 -4
  172. package/src/utils/abi/encodeFunctionResult.ts +4 -4
  173. package/src/utils/abi/encodePacked.ts +6 -8
  174. package/src/utils/abi/getAbiItem.ts +3 -3
  175. package/src/utils/poll.ts +1 -1
  176. package/src/utils/signature/hashTypedData.ts +1 -1
  177. package/src/utils/signature/recoverTypedDataAddress.ts +1 -1
  178. package/src/utils/signature/verifyTypedData.ts +1 -1
  179. package/src/utils/typedData.ts +2 -3
@@ -80,8 +80,8 @@ export type MulticallReturnType<
80
80
  * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
81
81
  */
82
82
  export async function multicall<
83
- TChain extends Chain | undefined,
84
83
  TContracts extends ContractFunctionConfig[],
84
+ TChain extends Chain | undefined,
85
85
  TAllowFailure extends boolean = true,
86
86
  >(
87
87
  client: Client<Transport, TChain>,
@@ -92,7 +92,7 @@ export async function multicall<
92
92
  batchSize: batchSize_,
93
93
  blockNumber,
94
94
  blockTag,
95
- contracts: contracts_,
95
+ contracts,
96
96
  multicallAddress: multicallAddress_,
97
97
  } = args
98
98
 
@@ -102,9 +102,6 @@ export async function multicall<
102
102
  client.batch.multicall.batchSize) ||
103
103
  1_024)
104
104
 
105
- // Fix type cast from `Narrow` in type definition.
106
- const contracts = contracts_ as readonly [...MulticallContracts<TContracts>]
107
-
108
105
  let multicallAddress = multicallAddress_
109
106
  if (!multicallAddress) {
110
107
  if (!client.chain)
@@ -129,7 +126,9 @@ export async function multicall<
129
126
  let currentChunk = 0
130
127
  let currentChunkSize = 0
131
128
  for (let i = 0; i < contracts.length; i++) {
132
- const { abi, address, args, functionName } = contracts[i]
129
+ const { abi, address, args, functionName } = contracts[
130
+ i
131
+ ] as ContractFunctionConfig
133
132
  try {
134
133
  const callData = encodeFunctionData({
135
134
  abi,
@@ -188,7 +187,9 @@ export async function multicall<
188
187
  return results.flat().map(({ returnData, success }, i) => {
189
188
  const calls = chunkedCalls.flat()
190
189
  const { callData } = calls[i]
191
- const { abi, address, functionName, args } = contracts[i]
190
+ const { abi, address, functionName, args } = contracts[
191
+ i
192
+ ] as ContractFunctionConfig
192
193
  try {
193
194
  if (callData === '0x') throw new AbiDecodingZeroDataError()
194
195
  if (!success) throw new RawContractError({ data: returnData })
@@ -196,7 +197,7 @@ export async function multicall<
196
197
  abi,
197
198
  args,
198
199
  data: returnData,
199
- functionName: functionName,
200
+ functionName,
200
201
  })
201
202
  return allowFailure ? { result, status: 'success' } : result
202
203
  } catch (err) {
@@ -64,7 +64,7 @@ export type ReadContractReturnType<
64
64
  */
65
65
  export async function readContract<
66
66
  TChain extends Chain | undefined,
67
- TAbi extends Abi | readonly unknown[],
67
+ const TAbi extends Abi | readonly unknown[],
68
68
  TFunctionName extends string,
69
69
  >(
70
70
  client: Client<Transport, TChain>,
@@ -102,7 +102,7 @@ export type SimulateContractReturnType<
102
102
  */
103
103
  export async function simulateContract<
104
104
  TChain extends Chain | undefined,
105
- TAbi extends Abi | readonly unknown[],
105
+ const TAbi extends Abi | readonly unknown[],
106
106
  TFunctionName extends string,
107
107
  TChainOverride extends Chain | undefined,
108
108
  >(
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiEvent, Address, ExtractAbiEvent, Narrow } from 'abitype'
1
+ import type { Abi, AbiEvent, Address, ExtractAbiEvent } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -68,7 +68,7 @@ export type WatchContractEventParameters<
68
68
  /** The address of the contract. */
69
69
  address?: Address | Address[]
70
70
  /** Contract ABI. */
71
- abi: Narrow<TAbi>
71
+ abi: TAbi
72
72
  args?: GetEventArgs<TAbi, TEventName>
73
73
  /** Contract event. */
74
74
  eventName?: InferEventName<TAbi, TEventName>
@@ -137,7 +137,7 @@ export type WatchContractEventReturnType = () => void
137
137
  */
138
138
  export function watchContractEvent<
139
139
  TChain extends Chain | undefined,
140
- TAbi extends Abi | readonly unknown[],
140
+ const TAbi extends Abi | readonly unknown[],
141
141
  TEventName extends string,
142
142
  TStrict extends boolean | undefined = undefined,
143
143
  >(
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiEvent, Address, Narrow } from 'abitype'
1
+ import type { Abi, AbiEvent, Address } from 'abitype'
2
2
 
3
3
  import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -107,7 +107,7 @@ export type WatchEventParameters<
107
107
  }) &
108
108
  (
109
109
  | {
110
- event: Narrow<TAbiEvent>
110
+ event: TAbiEvent
111
111
  events?: never
112
112
  args?: MaybeExtractEventArgsFromAbi<TAbiEvents, _EventName>
113
113
  /**
@@ -118,7 +118,7 @@ export type WatchEventParameters<
118
118
  }
119
119
  | {
120
120
  event?: never
121
- events?: Narrow<TAbiEvents>
121
+ events?: TAbiEvents
122
122
  args?: never
123
123
  /**
124
124
  * Whether or not the logs must match the indexed/non-indexed arguments on `event`.
@@ -170,8 +170,8 @@ export type WatchEventReturnType = () => void
170
170
  */
171
171
  export function watchEvent<
172
172
  TChain extends Chain | undefined,
173
- TAbiEvent extends AbiEvent | undefined = undefined,
174
- TAbiEvents extends
173
+ const TAbiEvent extends AbiEvent | undefined = undefined,
174
+ const TAbiEvents extends
175
175
  | readonly AbiEvent[]
176
176
  | readonly unknown[]
177
177
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1,4 +1,4 @@
1
- import type { Abi, Narrow } from 'abitype'
1
+ import type { Abi } from 'abitype'
2
2
 
3
3
  import type { Account } from '../../accounts/types.js'
4
4
  import type { Client } from '../../clients/createClient.js'
@@ -24,7 +24,7 @@ export type DeployContractParameters<
24
24
  SendTransactionParameters<TChain, TAccount, TChainOverride>,
25
25
  'accessList' | 'chain' | 'to' | 'data'
26
26
  > & {
27
- abi: Narrow<TAbi>
27
+ abi: TAbi
28
28
  bytecode: Hex
29
29
  } & GetChain<TChain, TChainOverride> &
30
30
  GetConstructorArgs<TAbi>
@@ -59,7 +59,7 @@ export type DeployContractReturnType = SendTransactionReturnType
59
59
  * })
60
60
  */
61
61
  export function deployContract<
62
- TAbi extends Abi | readonly unknown[],
62
+ const TAbi extends Abi | readonly unknown[],
63
63
  TChain extends Chain | undefined,
64
64
  TAccount extends Account | undefined,
65
65
  TChainOverride extends Chain | undefined,
@@ -121,7 +121,7 @@ export type SignTypedDataReturnType = Hex
121
121
  * })
122
122
  */
123
123
  export async function signTypedData<
124
- TTypedData extends TypedData | { [key: string]: unknown },
124
+ const TTypedData extends TypedData | { [key: string]: unknown },
125
125
  TPrimaryType extends string,
126
126
  TChain extends Chain | undefined,
127
127
  TAccount extends Account | undefined,
@@ -104,7 +104,7 @@ export type WriteContractReturnType = SendTransactionReturnType
104
104
  export async function writeContract<
105
105
  TChain extends Chain | undefined,
106
106
  TAccount extends Account | undefined,
107
- TAbi extends Abi | readonly unknown[],
107
+ const TAbi extends Abi | readonly unknown[],
108
108
  TFunctionName extends string,
109
109
  TChainOverride extends Chain | undefined,
110
110
  >(
@@ -94,6 +94,7 @@ export const polygonZkEvmTestnet = /*#__PURE__*/ defineChain(
94
94
  )
95
95
  export const pulsechain = /*#__PURE__*/ defineChain(chains.pulsechain)
96
96
  export const pulsechainV4 = /*#__PURE__*/ defineChain(chains.pulsechainV4)
97
+ export const scrollSepolia = /*#__PURE__*/ defineChain(chains.scrollSepolia)
97
98
  export const scrollTestnet = /*#__PURE__*/ defineChain(chains.scrollTestnet)
98
99
  export const sepolia = /*#__PURE__*/ defineChain(chains.sepolia)
99
100
  export const skaleBlockBrawlers = /*#__PURE__*/ defineChain(
@@ -278,7 +278,7 @@ export type PublicActions<
278
278
  * })
279
279
  */
280
280
  createContractEventFilter: <
281
- TAbi extends Abi | readonly unknown[],
281
+ const TAbi extends Abi | readonly unknown[],
282
282
  TEventName extends string | undefined,
283
283
  TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined,
284
284
  TStrict extends boolean | undefined = undefined,
@@ -325,8 +325,8 @@ export type PublicActions<
325
325
  * })
326
326
  */
327
327
  createEventFilter: <
328
- TAbiEvent extends AbiEvent | undefined = undefined,
329
- TAbiEvents extends
328
+ const TAbiEvent extends AbiEvent | undefined = undefined,
329
+ const TAbiEvents extends
330
330
  | readonly AbiEvent[]
331
331
  | readonly unknown[]
332
332
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -406,7 +406,7 @@ export type PublicActions<
406
406
  */
407
407
  estimateContractGas: <
408
408
  TChain extends Chain | undefined,
409
- TAbi extends Abi | readonly unknown[],
409
+ const TAbi extends Abi | readonly unknown[],
410
410
  TFunctionName extends string,
411
411
  >(
412
412
  args: EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
@@ -844,7 +844,7 @@ export type PublicActions<
844
844
  */
845
845
  getFilterChanges: <
846
846
  TFilterType extends FilterType,
847
- TAbi extends Abi | readonly unknown[] | undefined,
847
+ const TAbi extends Abi | readonly unknown[] | undefined,
848
848
  TEventName extends string | undefined,
849
849
  TStrict extends boolean | undefined = undefined,
850
850
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -895,7 +895,7 @@ export type PublicActions<
895
895
  * const logs = await client.getFilterLogs({ filter })
896
896
  */
897
897
  getFilterLogs: <
898
- TAbi extends Abi | readonly unknown[] | undefined,
898
+ const TAbi extends Abi | readonly unknown[] | undefined,
899
899
  TEventName extends string | undefined,
900
900
  TStrict extends boolean | undefined = undefined,
901
901
  TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
@@ -951,8 +951,8 @@ export type PublicActions<
951
951
  * const logs = await client.getLogs()
952
952
  */
953
953
  getLogs: <
954
- TAbiEvent extends AbiEvent | undefined = undefined,
955
- TAbiEvents extends
954
+ const TAbiEvent extends AbiEvent | undefined = undefined,
955
+ const TAbiEvents extends
956
956
  | readonly AbiEvent[]
957
957
  | readonly unknown[]
958
958
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1170,7 +1170,7 @@ export type PublicActions<
1170
1170
  * // 424122n
1171
1171
  */
1172
1172
  readContract: <
1173
- TAbi extends Abi | readonly unknown[],
1173
+ const TAbi extends Abi | readonly unknown[],
1174
1174
  TFunctionName extends string,
1175
1175
  >(
1176
1176
  args: ReadContractParameters<TAbi, TFunctionName>,
@@ -1206,7 +1206,7 @@ export type PublicActions<
1206
1206
  * })
1207
1207
  */
1208
1208
  simulateContract: <
1209
- TAbi extends Abi | readonly unknown[],
1209
+ const TAbi extends Abi | readonly unknown[],
1210
1210
  TFunctionName extends string,
1211
1211
  TChainOverride extends Chain | undefined,
1212
1212
  >(
@@ -1383,7 +1383,7 @@ export type PublicActions<
1383
1383
  * })
1384
1384
  */
1385
1385
  watchContractEvent: <
1386
- TAbi extends Abi | readonly unknown[],
1386
+ const TAbi extends Abi | readonly unknown[],
1387
1387
  TEventName extends string,
1388
1388
  TStrict extends boolean | undefined = undefined,
1389
1389
  >(
@@ -1421,8 +1421,8 @@ export type PublicActions<
1421
1421
  * })
1422
1422
  */
1423
1423
  watchEvent: <
1424
- TAbiEvent extends AbiEvent | undefined = undefined,
1425
- TAbiEvents extends
1424
+ const TAbiEvent extends AbiEvent | undefined = undefined,
1425
+ const TAbiEvents extends
1426
1426
  | readonly AbiEvent[]
1427
1427
  | readonly unknown[]
1428
1428
  | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
@@ -1502,7 +1502,7 @@ export function publicActions<
1502
1502
  getTransactionConfirmations(client, args),
1503
1503
  getTransactionCount: (args) => getTransactionCount(client, args),
1504
1504
  getTransactionReceipt: (args) => getTransactionReceipt(client, args),
1505
- multicall: (args) => multicall(client, args),
1505
+ multicall: (args) => multicall(client, args as any) as any,
1506
1506
  readContract: (args) => readContract(client, args),
1507
1507
  simulateContract: (args) => simulateContract(client, args),
1508
1508
  verifyMessage: (args) => verifyMessage(client, args),
@@ -112,7 +112,7 @@ export type WalletActions<
112
112
  * })
113
113
  */
114
114
  deployContract: <
115
- TAbi extends Abi | readonly unknown[],
115
+ const TAbi extends Abi | readonly unknown[],
116
116
  TChainOverride extends Chain | undefined,
117
117
  >(
118
118
  args: DeployContractParameters<TAbi, TChain, TAccount, TChainOverride>,
@@ -410,7 +410,7 @@ export type WalletActions<
410
410
  * })
411
411
  */
412
412
  signTypedData: <
413
- TTypedData extends TypedData | { [key: string]: unknown },
413
+ const TTypedData extends TypedData | { [key: string]: unknown },
414
414
  TPrimaryType extends string,
415
415
  >(
416
416
  args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>,
@@ -509,7 +509,7 @@ export type WalletActions<
509
509
  * const hash = await client.writeContract(request)
510
510
  */
511
511
  writeContract: <
512
- TAbi extends Abi | readonly unknown[],
512
+ const TAbi extends Abi | readonly unknown[],
513
513
  TFunctionName extends string,
514
514
  TChainOverride extends Chain | undefined,
515
515
  >(
@@ -1,98 +1,98 @@
1
- export const maxInt8 = 2n ** (8n - 1n)
2
- export const maxInt16 = 2n ** (16n - 1n)
3
- export const maxInt24 = 2n ** (24n - 1n)
4
- export const maxInt32 = 2n ** (32n - 1n)
5
- export const maxInt40 = 2n ** (40n - 1n)
6
- export const maxInt48 = 2n ** (48n - 1n)
7
- export const maxInt56 = 2n ** (56n - 1n)
8
- export const maxInt64 = 2n ** (64n - 1n)
9
- export const maxInt72 = 2n ** (72n - 1n)
10
- export const maxInt80 = 2n ** (80n - 1n)
11
- export const maxInt88 = 2n ** (88n - 1n)
12
- export const maxInt96 = 2n ** (96n - 1n)
13
- export const maxInt104 = 2n ** (104n - 1n)
14
- export const maxInt112 = 2n ** (112n - 1n)
15
- export const maxInt120 = 2n ** (120n - 1n)
16
- export const maxInt128 = 2n ** (128n - 1n)
17
- export const maxInt136 = 2n ** (136n - 1n)
18
- export const maxInt144 = 2n ** (144n - 1n)
19
- export const maxInt152 = 2n ** (152n - 1n)
20
- export const maxInt160 = 2n ** (160n - 1n)
21
- export const maxInt168 = 2n ** (168n - 1n)
22
- export const maxInt176 = 2n ** (176n - 1n)
23
- export const maxInt184 = 2n ** (184n - 1n)
24
- export const maxInt192 = 2n ** (192n - 1n)
25
- export const maxInt200 = 2n ** (200n - 1n)
26
- export const maxInt208 = 2n ** (208n - 1n)
27
- export const maxInt216 = 2n ** (216n - 1n)
28
- export const maxInt224 = 2n ** (224n - 1n)
29
- export const maxInt232 = 2n ** (232n - 1n)
30
- export const maxInt240 = 2n ** (240n - 1n)
31
- export const maxInt248 = 2n ** (248n - 1n)
32
- export const maxInt256 = 2n ** (256n - 1n)
1
+ export const maxInt8 = 2n ** (8n - 1n) - 1n
2
+ export const maxInt16 = 2n ** (16n - 1n) - 1n
3
+ export const maxInt24 = 2n ** (24n - 1n) - 1n
4
+ export const maxInt32 = 2n ** (32n - 1n) - 1n
5
+ export const maxInt40 = 2n ** (40n - 1n) - 1n
6
+ export const maxInt48 = 2n ** (48n - 1n) - 1n
7
+ export const maxInt56 = 2n ** (56n - 1n) - 1n
8
+ export const maxInt64 = 2n ** (64n - 1n) - 1n
9
+ export const maxInt72 = 2n ** (72n - 1n) - 1n
10
+ export const maxInt80 = 2n ** (80n - 1n) - 1n
11
+ export const maxInt88 = 2n ** (88n - 1n) - 1n
12
+ export const maxInt96 = 2n ** (96n - 1n) - 1n
13
+ export const maxInt104 = 2n ** (104n - 1n) - 1n
14
+ export const maxInt112 = 2n ** (112n - 1n) - 1n
15
+ export const maxInt120 = 2n ** (120n - 1n) - 1n
16
+ export const maxInt128 = 2n ** (128n - 1n) - 1n
17
+ export const maxInt136 = 2n ** (136n - 1n) - 1n
18
+ export const maxInt144 = 2n ** (144n - 1n) - 1n
19
+ export const maxInt152 = 2n ** (152n - 1n) - 1n
20
+ export const maxInt160 = 2n ** (160n - 1n) - 1n
21
+ export const maxInt168 = 2n ** (168n - 1n) - 1n
22
+ export const maxInt176 = 2n ** (176n - 1n) - 1n
23
+ export const maxInt184 = 2n ** (184n - 1n) - 1n
24
+ export const maxInt192 = 2n ** (192n - 1n) - 1n
25
+ export const maxInt200 = 2n ** (200n - 1n) - 1n
26
+ export const maxInt208 = 2n ** (208n - 1n) - 1n
27
+ export const maxInt216 = 2n ** (216n - 1n) - 1n
28
+ export const maxInt224 = 2n ** (224n - 1n) - 1n
29
+ export const maxInt232 = 2n ** (232n - 1n) - 1n
30
+ export const maxInt240 = 2n ** (240n - 1n) - 1n
31
+ export const maxInt248 = 2n ** (248n - 1n) - 1n
32
+ export const maxInt256 = 2n ** (256n - 1n) - 1n
33
33
 
34
- export const minInt8 = -(2n ** 8n)
35
- export const minInt16 = -(2n ** 16n)
36
- export const minInt24 = -(2n ** 24n)
37
- export const minInt32 = -(2n ** 32n)
38
- export const minInt40 = -(2n ** 40n)
39
- export const minInt48 = -(2n ** 48n)
40
- export const minInt56 = -(2n ** 56n)
41
- export const minInt64 = -(2n ** 64n)
42
- export const minInt72 = -(2n ** 72n)
43
- export const minInt80 = -(2n ** 80n)
44
- export const minInt88 = -(2n ** 88n)
45
- export const minInt96 = -(2n ** 96n)
46
- export const minInt104 = -(2n ** 104n)
47
- export const minInt112 = -(2n ** 112n)
48
- export const minInt120 = -(2n ** 120n)
49
- export const minInt128 = -(2n ** 128n)
50
- export const minInt136 = -(2n ** 136n)
51
- export const minInt144 = -(2n ** 144n)
52
- export const minInt152 = -(2n ** 152n)
53
- export const minInt160 = -(2n ** 160n)
54
- export const minInt168 = -(2n ** 168n)
55
- export const minInt176 = -(2n ** 176n)
56
- export const minInt184 = -(2n ** 184n)
57
- export const minInt192 = -(2n ** 192n)
58
- export const minInt200 = -(2n ** 200n)
59
- export const minInt208 = -(2n ** 208n)
60
- export const minInt216 = -(2n ** 216n)
61
- export const minInt224 = -(2n ** 224n)
62
- export const minInt232 = -(2n ** 232n)
63
- export const minInt240 = -(2n ** 240n)
64
- export const minInt248 = -(2n ** 248n)
65
- export const minInt256 = -(2n ** 256n)
34
+ export const minInt8 = -(2n ** (8n - 1n))
35
+ export const minInt16 = -(2n ** (16n - 1n))
36
+ export const minInt24 = -(2n ** (24n - 1n))
37
+ export const minInt32 = -(2n ** (32n - 1n))
38
+ export const minInt40 = -(2n ** (40n - 1n))
39
+ export const minInt48 = -(2n ** (48n - 1n))
40
+ export const minInt56 = -(2n ** (56n - 1n))
41
+ export const minInt64 = -(2n ** (64n - 1n))
42
+ export const minInt72 = -(2n ** (72n - 1n))
43
+ export const minInt80 = -(2n ** (80n - 1n))
44
+ export const minInt88 = -(2n ** (88n - 1n))
45
+ export const minInt96 = -(2n ** (96n - 1n))
46
+ export const minInt104 = -(2n ** (104n - 1n))
47
+ export const minInt112 = -(2n ** (112n - 1n))
48
+ export const minInt120 = -(2n ** (120n - 1n))
49
+ export const minInt128 = -(2n ** (128n - 1n))
50
+ export const minInt136 = -(2n ** (136n - 1n))
51
+ export const minInt144 = -(2n ** (144n - 1n))
52
+ export const minInt152 = -(2n ** (152n - 1n))
53
+ export const minInt160 = -(2n ** (160n - 1n))
54
+ export const minInt168 = -(2n ** (168n - 1n))
55
+ export const minInt176 = -(2n ** (176n - 1n))
56
+ export const minInt184 = -(2n ** (184n - 1n))
57
+ export const minInt192 = -(2n ** (192n - 1n))
58
+ export const minInt200 = -(2n ** (200n - 1n))
59
+ export const minInt208 = -(2n ** (208n - 1n))
60
+ export const minInt216 = -(2n ** (216n - 1n))
61
+ export const minInt224 = -(2n ** (224n - 1n))
62
+ export const minInt232 = -(2n ** (232n - 1n))
63
+ export const minInt240 = -(2n ** (240n - 1n))
64
+ export const minInt248 = -(2n ** (248n - 1n))
65
+ export const minInt256 = -(2n ** (256n - 1n))
66
66
 
67
- export const maxUint8 = 2n ** 8n
68
- export const maxUint16 = 2n ** 16n
69
- export const maxUint24 = 2n ** 24n
70
- export const maxUint32 = 2n ** 32n
71
- export const maxUint40 = 2n ** 40n
72
- export const maxUint48 = 2n ** 48n
73
- export const maxUint56 = 2n ** 56n
74
- export const maxUint64 = 2n ** 64n
75
- export const maxUint72 = 2n ** 72n
76
- export const maxUint80 = 2n ** 80n
77
- export const maxUint88 = 2n ** 88n
78
- export const maxUint96 = 2n ** 96n
79
- export const maxUint104 = 2n ** 104n
80
- export const maxUint112 = 2n ** 112n
81
- export const maxUint120 = 2n ** 120n
82
- export const maxUint128 = 2n ** 128n
83
- export const maxUint136 = 2n ** 136n
84
- export const maxUint144 = 2n ** 144n
85
- export const maxUint152 = 2n ** 152n
86
- export const maxUint160 = 2n ** 160n
87
- export const maxUint168 = 2n ** 168n
88
- export const maxUint176 = 2n ** 176n
89
- export const maxUint184 = 2n ** 184n
90
- export const maxUint192 = 2n ** 192n
91
- export const maxUint200 = 2n ** 200n
92
- export const maxUint208 = 2n ** 208n
93
- export const maxUint216 = 2n ** 216n
94
- export const maxUint224 = 2n ** 224n
95
- export const maxUint232 = 2n ** 232n
96
- export const maxUint240 = 2n ** 240n
97
- export const maxUint248 = 2n ** 248n
98
- export const maxUint256 = 2n ** 256n
67
+ export const maxUint8 = 2n ** 8n - 1n
68
+ export const maxUint16 = 2n ** 16n - 1n
69
+ export const maxUint24 = 2n ** 24n - 1n
70
+ export const maxUint32 = 2n ** 32n - 1n
71
+ export const maxUint40 = 2n ** 40n - 1n
72
+ export const maxUint48 = 2n ** 48n - 1n
73
+ export const maxUint56 = 2n ** 56n - 1n
74
+ export const maxUint64 = 2n ** 64n - 1n
75
+ export const maxUint72 = 2n ** 72n - 1n
76
+ export const maxUint80 = 2n ** 80n - 1n
77
+ export const maxUint88 = 2n ** 88n - 1n
78
+ export const maxUint96 = 2n ** 96n - 1n
79
+ export const maxUint104 = 2n ** 104n - 1n
80
+ export const maxUint112 = 2n ** 112n - 1n
81
+ export const maxUint120 = 2n ** 120n - 1n
82
+ export const maxUint128 = 2n ** 128n - 1n
83
+ export const maxUint136 = 2n ** 136n - 1n
84
+ export const maxUint144 = 2n ** 144n - 1n
85
+ export const maxUint152 = 2n ** 152n - 1n
86
+ export const maxUint160 = 2n ** 160n - 1n
87
+ export const maxUint168 = 2n ** 168n - 1n
88
+ export const maxUint176 = 2n ** 176n - 1n
89
+ export const maxUint184 = 2n ** 184n - 1n
90
+ export const maxUint192 = 2n ** 192n - 1n
91
+ export const maxUint200 = 2n ** 200n - 1n
92
+ export const maxUint208 = 2n ** 208n - 1n
93
+ export const maxUint216 = 2n ** 216n - 1n
94
+ export const maxUint224 = 2n ** 224n - 1n
95
+ export const maxUint232 = 2n ** 232n - 1n
96
+ export const maxUint240 = 2n ** 240n - 1n
97
+ export const maxUint248 = 2n ** 248n - 1n
98
+ export const maxUint256 = 2n ** 256n - 1n
@@ -1 +1 @@
1
- export const version = '1.5.4'
1
+ export const version = '1.6.3'
package/src/index.ts CHANGED
@@ -597,6 +597,7 @@ export type {
597
597
  } from './types/chain.js'
598
598
  export type {
599
599
  AddEthereumChainParameter,
600
+ EIP1193EventMap,
600
601
  EIP1193Events,
601
602
  EIP1193Parameters,
602
603
  EIP1193Provider,
@@ -633,6 +634,7 @@ export type { GetTransportConfig } from './types/transport.js'
633
634
  export type { HDKey } from '@scure/bip32'
634
635
  export type { Log } from './types/log.js'
635
636
  export type {
637
+ MulticallContract,
636
638
  MulticallContracts,
637
639
  MulticallResult,
638
640
  MulticallResults,
@@ -51,7 +51,7 @@ export type ProviderMessage = {
51
51
  data: unknown
52
52
  }
53
53
 
54
- type EIP1193EventMap = {
54
+ export type EIP1193EventMap = {
55
55
  accountsChanged(accounts: Address[]): void
56
56
  chainChanged(chainId: string): void
57
57
  connect(connectInfo: ProviderConnectInfo): void
@@ -1,4 +1,4 @@
1
- import type { Abi } from 'abitype'
1
+ import type { Abi, ExtractAbiFunctionNames } from 'abitype'
2
2
 
3
3
  import type {
4
4
  ContractFunctionConfig,
@@ -7,13 +7,16 @@ import type {
7
7
 
8
8
  type MAXIMUM_DEPTH = 20
9
9
 
10
- export type Contract<
10
+ export type MulticallContract<
11
11
  TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[],
12
- TFunctionName extends string = string,
12
+ TFunctionName extends ExtractAbiFunctionNames<
13
+ TAbi extends Abi ? TAbi : Abi,
14
+ 'pure' | 'view'
15
+ > = string,
13
16
  > = { abi: TAbi; functionName: TFunctionName }
14
17
 
15
18
  export type MulticallContracts<
16
- TContracts extends Contract[],
19
+ TContracts extends readonly MulticallContract[],
17
20
  TProperties extends Record<string, any> = object,
18
21
  Result extends any[] = [],
19
22
  Depth extends readonly number[] = [],
@@ -21,14 +24,14 @@ export type MulticallContracts<
21
24
  ? (ContractFunctionConfig & TProperties)[]
22
25
  : TContracts extends []
23
26
  ? []
24
- : TContracts extends [infer Head extends Contract]
27
+ : TContracts extends [infer Head extends MulticallContract]
25
28
  ? [
26
29
  ...Result,
27
30
  ContractFunctionConfig<Head['abi'], Head['functionName']> & TProperties,
28
31
  ]
29
32
  : TContracts extends [
30
- infer Head extends Contract,
31
- ...infer Tail extends Contract[],
33
+ infer Head extends MulticallContract,
34
+ ...infer Tail extends readonly MulticallContract[],
32
35
  ]
33
36
  ? MulticallContracts<
34
37
  [...Tail],
@@ -65,7 +68,7 @@ export type MulticallResult<
65
68
  : Result
66
69
 
67
70
  export type MulticallResults<
68
- TContracts extends Contract[],
71
+ TContracts extends readonly MulticallContract[],
69
72
  TAllowFailure extends boolean = true,
70
73
  Result extends any[] = [],
71
74
  Depth extends readonly number[] = [],
@@ -73,7 +76,7 @@ export type MulticallResults<
73
76
  ? MulticallResult<ContractFunctionResult, TAllowFailure>[]
74
77
  : TContracts extends []
75
78
  ? []
76
- : TContracts extends [infer Head extends Contract]
79
+ : TContracts extends [infer Head extends MulticallContract]
77
80
  ? [
78
81
  ...Result,
79
82
  MulticallResult<
@@ -82,8 +85,8 @@ export type MulticallResults<
82
85
  >,
83
86
  ]
84
87
  : TContracts extends [
85
- infer Head extends Contract,
86
- ...infer Tail extends Contract[],
88
+ infer Head extends MulticallContract,
89
+ ...infer Tail extends readonly MulticallContract[],
87
90
  ]
88
91
  ? MulticallResults<
89
92
  [...Tail],
@@ -1,5 +1,4 @@
1
1
  import type {
2
- Narrow,
3
2
  TypedData,
4
3
  TypedDataDomain,
5
4
  TypedDataToPrimitiveTypes,
@@ -74,8 +73,8 @@ export type GetTypedDataTypes<
74
73
  TPrimaryType extends string = string,
75
74
  > = TPrimaryType extends 'EIP712Domain'
76
75
  ? {
77
- types?: Narrow<TTypedData>
76
+ types?: TTypedData
78
77
  }
79
78
  : {
80
- types: Narrow<TTypedData>
79
+ types: TTypedData
81
80
  }