viem 1.19.9 → 1.19.11

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 (211) hide show
  1. package/CHANGELOG.md +425 -407
  2. package/README.md +46 -46
  3. package/_cjs/accounts/utils/signTransaction.js.map +1 -1
  4. package/_cjs/actions/public/createContractEventFilter.js.map +1 -1
  5. package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
  6. package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
  7. package/_cjs/actions/public/waitForTransactionReceipt.js +8 -1
  8. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  9. package/_cjs/chains/celo/serializers.js +3 -7
  10. package/_cjs/chains/celo/serializers.js.map +1 -1
  11. package/_cjs/chains/definitions/confluxESpace.js +2 -0
  12. package/_cjs/chains/definitions/confluxESpace.js.map +1 -1
  13. package/_cjs/chains/definitions/confluxESpaceTestnet.js +34 -0
  14. package/_cjs/chains/definitions/confluxESpaceTestnet.js.map +1 -0
  15. package/_cjs/chains/definitions/sapphire.js +33 -0
  16. package/_cjs/chains/definitions/sapphire.js.map +1 -0
  17. package/_cjs/chains/definitions/sapphireTestnet.js +28 -0
  18. package/_cjs/chains/definitions/sapphireTestnet.js.map +1 -0
  19. package/_cjs/chains/index.js +10 -4
  20. package/_cjs/chains/index.js.map +1 -1
  21. package/_cjs/errors/base.js.map +1 -1
  22. package/_cjs/errors/version.js +1 -1
  23. package/_cjs/errors/version.js.map +1 -1
  24. package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
  25. package/_cjs/utils/ccip.js +3 -1
  26. package/_cjs/utils/ccip.js.map +1 -1
  27. package/_cjs/utils/encoding/toBytes.js +2 -2
  28. package/_cjs/utils/encoding/toBytes.js.map +1 -1
  29. package/_cjs/utils/ens/avatar/utils.js +1 -1
  30. package/_cjs/utils/ens/avatar/utils.js.map +1 -1
  31. package/_cjs/utils/errors/getContractError.js.map +1 -1
  32. package/_cjs/utils/errors/getNodeError.js +11 -11
  33. package/_cjs/utils/errors/getNodeError.js.map +1 -1
  34. package/_cjs/utils/transaction/getTransactionType.js.map +1 -1
  35. package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
  36. package/_esm/accounts/utils/signTransaction.js.map +1 -1
  37. package/_esm/actions/ens/getEnsAddress.js +2 -2
  38. package/_esm/actions/ens/getEnsAvatar.js +2 -2
  39. package/_esm/actions/ens/getEnsName.js +2 -2
  40. package/_esm/actions/ens/getEnsResolver.js +2 -2
  41. package/_esm/actions/ens/getEnsText.js +2 -2
  42. package/_esm/actions/public/createContractEventFilter.js.map +1 -1
  43. package/_esm/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
  44. package/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
  45. package/_esm/actions/public/getBlock.js +1 -1
  46. package/_esm/actions/public/getBlockNumber.js +1 -1
  47. package/_esm/actions/public/getLogs.js +1 -1
  48. package/_esm/actions/public/getTransaction.js +1 -1
  49. package/_esm/actions/public/getTransactionConfirmations.js +1 -1
  50. package/_esm/actions/public/getTransactionReceipt.js +1 -1
  51. package/_esm/actions/public/readContract.js +1 -1
  52. package/_esm/actions/public/simulateContract.js +1 -1
  53. package/_esm/actions/public/waitForTransactionReceipt.js +12 -2
  54. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  55. package/_esm/actions/public/watchBlockNumber.js +1 -1
  56. package/_esm/actions/public/watchBlocks.js +1 -1
  57. package/_esm/actions/wallet/deployContract.js +1 -1
  58. package/_esm/actions/wallet/sendTransaction.js +1 -1
  59. package/_esm/actions/wallet/writeContract.js +1 -1
  60. package/_esm/chains/celo/serializers.js +3 -7
  61. package/_esm/chains/celo/serializers.js.map +1 -1
  62. package/_esm/chains/definitions/confluxESpace.js +2 -0
  63. package/_esm/chains/definitions/confluxESpace.js.map +1 -1
  64. package/_esm/chains/definitions/confluxESpaceTestnet.js +31 -0
  65. package/_esm/chains/definitions/confluxESpaceTestnet.js.map +1 -0
  66. package/_esm/chains/definitions/sapphire.js +30 -0
  67. package/_esm/chains/definitions/sapphire.js.map +1 -0
  68. package/_esm/chains/definitions/sapphireTestnet.js +25 -0
  69. package/_esm/chains/definitions/sapphireTestnet.js.map +1 -0
  70. package/_esm/chains/index.js +3 -0
  71. package/_esm/chains/index.js.map +1 -1
  72. package/_esm/errors/base.js.map +1 -1
  73. package/_esm/errors/version.js +1 -1
  74. package/_esm/errors/version.js.map +1 -1
  75. package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
  76. package/_esm/utils/ccip.js +3 -1
  77. package/_esm/utils/ccip.js.map +1 -1
  78. package/_esm/utils/encoding/toBytes.js +2 -2
  79. package/_esm/utils/encoding/toBytes.js.map +1 -1
  80. package/_esm/utils/ens/avatar/utils.js +1 -1
  81. package/_esm/utils/ens/avatar/utils.js.map +1 -1
  82. package/_esm/utils/ens/namehash.js +1 -1
  83. package/_esm/utils/ens/normalize.js +2 -2
  84. package/_esm/utils/errors/getContractError.js.map +1 -1
  85. package/_esm/utils/errors/getNodeError.js +11 -11
  86. package/_esm/utils/errors/getNodeError.js.map +1 -1
  87. package/_esm/utils/transaction/getTransactionType.js.map +1 -1
  88. package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
  89. package/_types/accounts/utils/signTransaction.d.ts.map +1 -1
  90. package/_types/actions/ens/getEnsAddress.d.ts +2 -2
  91. package/_types/actions/ens/getEnsAvatar.d.ts +2 -2
  92. package/_types/actions/ens/getEnsName.d.ts +2 -2
  93. package/_types/actions/ens/getEnsResolver.d.ts +2 -2
  94. package/_types/actions/ens/getEnsText.d.ts +2 -2
  95. package/_types/actions/public/createContractEventFilter.d.ts.map +1 -1
  96. package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -1
  97. package/_types/actions/public/getBlock.d.ts +1 -1
  98. package/_types/actions/public/getBlockNumber.d.ts +1 -1
  99. package/_types/actions/public/getLogs.d.ts +1 -1
  100. package/_types/actions/public/getTransaction.d.ts +1 -1
  101. package/_types/actions/public/getTransactionConfirmations.d.ts +1 -1
  102. package/_types/actions/public/getTransactionReceipt.d.ts +1 -1
  103. package/_types/actions/public/readContract.d.ts +1 -1
  104. package/_types/actions/public/simulateContract.d.ts +1 -1
  105. package/_types/actions/public/waitForTransactionReceipt.d.ts +1 -1
  106. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  107. package/_types/actions/public/watchBlockNumber.d.ts +1 -1
  108. package/_types/actions/public/watchBlocks.d.ts +1 -1
  109. package/_types/actions/wallet/deployContract.d.ts +1 -1
  110. package/_types/actions/wallet/sendTransaction.d.ts +1 -1
  111. package/_types/actions/wallet/writeContract.d.ts +1 -1
  112. package/_types/chains/celo/serializers.d.ts.map +1 -1
  113. package/_types/chains/definitions/confluxESpace.d.ts +2 -0
  114. package/_types/chains/definitions/confluxESpace.d.ts.map +1 -1
  115. package/_types/chains/definitions/confluxESpaceTestnet.d.ts +34 -0
  116. package/_types/chains/definitions/confluxESpaceTestnet.d.ts.map +1 -0
  117. package/_types/chains/definitions/sapphire.d.ts +33 -0
  118. package/_types/chains/definitions/sapphire.d.ts.map +1 -0
  119. package/_types/chains/definitions/sapphireTestnet.d.ts +28 -0
  120. package/_types/chains/definitions/sapphireTestnet.d.ts.map +1 -0
  121. package/_types/chains/index.d.ts +3 -0
  122. package/_types/chains/index.d.ts.map +1 -1
  123. package/_types/clients/decorators/public.d.ts +21 -21
  124. package/_types/clients/decorators/wallet.d.ts +3 -3
  125. package/_types/errors/version.d.ts +1 -1
  126. package/_types/errors/version.d.ts.map +1 -1
  127. package/_types/types/contract.d.ts.map +1 -1
  128. package/_types/types/filter.d.ts.map +1 -1
  129. package/_types/types/log.d.ts.map +1 -1
  130. package/_types/types/multicall.d.ts.map +1 -1
  131. package/_types/types/transaction.d.ts.map +1 -1
  132. package/_types/types/typedData.d.ts.map +1 -1
  133. package/_types/types/utils.d.ts.map +1 -1
  134. package/_types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
  135. package/_types/utils/abi/encodeErrorResult.d.ts.map +1 -1
  136. package/_types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  137. package/_types/utils/abi/encodeFunctionData.d.ts.map +1 -1
  138. package/_types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
  139. package/_types/utils/ccip.d.ts.map +1 -1
  140. package/_types/utils/encoding/fromBytes.d.ts.map +1 -1
  141. package/_types/utils/encoding/fromHex.d.ts.map +1 -1
  142. package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
  143. package/_types/utils/ens/namehash.d.ts +1 -1
  144. package/_types/utils/ens/normalize.d.ts +2 -2
  145. package/_types/utils/errors/getNodeError.d.ts.map +1 -1
  146. package/_types/utils/transaction/getSerializedTransactionType.d.ts.map +1 -1
  147. package/_types/utils/transaction/getTransactionType.d.ts.map +1 -1
  148. package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
  149. package/accounts/utils/signTransaction.ts +4 -2
  150. package/actions/ens/getEnsAddress.ts +3 -3
  151. package/actions/ens/getEnsAvatar.ts +2 -2
  152. package/actions/ens/getEnsName.ts +2 -2
  153. package/actions/ens/getEnsResolver.ts +2 -2
  154. package/actions/ens/getEnsText.ts +2 -2
  155. package/actions/public/call.ts +1 -1
  156. package/actions/public/createContractEventFilter.ts +11 -9
  157. package/actions/public/estimateMaxPriorityFeePerGas.ts +3 -1
  158. package/actions/public/getBlock.ts +1 -1
  159. package/actions/public/getBlockNumber.ts +1 -1
  160. package/actions/public/getLogs.ts +1 -1
  161. package/actions/public/getTransaction.ts +1 -1
  162. package/actions/public/getTransactionConfirmations.ts +1 -1
  163. package/actions/public/getTransactionReceipt.ts +1 -1
  164. package/actions/public/readContract.ts +1 -1
  165. package/actions/public/simulateContract.ts +1 -1
  166. package/actions/public/verifyHash.ts +1 -1
  167. package/actions/public/verifyMessage.ts +1 -1
  168. package/actions/public/verifyTypedData.ts +1 -1
  169. package/actions/public/waitForTransactionReceipt.ts +24 -9
  170. package/actions/public/watchBlockNumber.ts +1 -1
  171. package/actions/public/watchBlocks.ts +1 -1
  172. package/actions/wallet/deployContract.ts +1 -1
  173. package/actions/wallet/sendRawTransaction.ts +1 -1
  174. package/actions/wallet/sendTransaction.ts +1 -1
  175. package/actions/wallet/writeContract.ts +1 -1
  176. package/chains/celo/serializers.ts +3 -7
  177. package/chains/definitions/confluxESpace.ts +2 -0
  178. package/chains/definitions/confluxESpaceTestnet.ts +31 -0
  179. package/chains/definitions/sapphire.ts +30 -0
  180. package/chains/definitions/sapphireTestnet.ts +25 -0
  181. package/chains/index.ts +3 -0
  182. package/clients/decorators/public.ts +21 -21
  183. package/clients/decorators/wallet.ts +3 -3
  184. package/errors/base.ts +2 -2
  185. package/errors/version.ts +1 -1
  186. package/package.json +3 -3
  187. package/types/contract.ts +63 -64
  188. package/types/filter.ts +12 -12
  189. package/types/log.ts +4 -4
  190. package/types/multicall.ts +65 -57
  191. package/types/transaction.ts +4 -4
  192. package/types/typedData.ts +12 -12
  193. package/types/utils.ts +6 -7
  194. package/utils/abi/decodeFunctionResult.ts +2 -2
  195. package/utils/abi/encodeErrorResult.ts +2 -2
  196. package/utils/abi/encodeEventTopics.ts +6 -6
  197. package/utils/abi/encodeFunctionData.ts +2 -2
  198. package/utils/abi/encodeFunctionResult.ts +5 -5
  199. package/utils/ccip.ts +4 -2
  200. package/utils/encoding/fromBytes.ts +8 -8
  201. package/utils/encoding/fromHex.ts +8 -8
  202. package/utils/encoding/toBytes.ts +2 -2
  203. package/utils/ens/avatar/utils.ts +3 -1
  204. package/utils/ens/namehash.ts +1 -1
  205. package/utils/ens/normalize.ts +2 -2
  206. package/utils/errors/getContractError.ts +2 -2
  207. package/utils/errors/getNodeError.ts +12 -11
  208. package/utils/rpc.ts +1 -1
  209. package/utils/transaction/getSerializedTransactionType.ts +2 -2
  210. package/utils/transaction/getTransactionType.ts +2 -1
  211. package/utils/transaction/serializeTransaction.ts +6 -3
package/types/contract.ts CHANGED
@@ -58,10 +58,10 @@ export type ContractFunctionResult<
58
58
  > = true extends FailedToParseArgs
59
59
  ? unknown
60
60
  : TArgs extends readonly []
61
- ? void
62
- : TArgs extends readonly [infer Arg]
63
- ? Arg
64
- : TArgs
61
+ ? void
62
+ : TArgs extends readonly [infer Arg]
63
+ ? Arg
64
+ : TArgs
65
65
 
66
66
  export type GetValue<
67
67
  TAbi extends Abi | readonly unknown[],
@@ -75,8 +75,8 @@ export type GetValue<
75
75
  ? TAbiFunction['stateMutability'] extends 'payable'
76
76
  ? { value?: NoUndefined<TValueType> }
77
77
  : TAbiFunction['payable'] extends true
78
- ? { value?: NoUndefined<TValueType> }
79
- : { value?: never }
78
+ ? { value?: NoUndefined<TValueType> }
79
+ : { value?: never }
80
80
  : { value?: TValueType }
81
81
 
82
82
  export type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> =
@@ -170,10 +170,10 @@ export type GetFunctionArgs<
170
170
  args?: readonly unknown[]
171
171
  }
172
172
  : TArgs extends readonly []
173
- ? { args?: never }
174
- : {
175
- /** Arguments to pass contract method */ args: TArgs
176
- }
173
+ ? { args?: never }
174
+ : {
175
+ /** Arguments to pass contract method */ args: TArgs
176
+ }
177
177
 
178
178
  export type GetConstructorArgs<
179
179
  TAbi extends Abi | readonly unknown[],
@@ -194,10 +194,10 @@ export type GetConstructorArgs<
194
194
  args?: readonly unknown[]
195
195
  }
196
196
  : TArgs extends readonly []
197
- ? { args?: never }
198
- : {
199
- /** Arguments to pass contract constructor */ args: TArgs
200
- }
197
+ ? { args?: never }
198
+ : {
199
+ /** Arguments to pass contract constructor */ args: TArgs
200
+ }
201
201
 
202
202
  export type GetErrorArgs<
203
203
  TAbi extends Abi | readonly unknown[],
@@ -219,10 +219,10 @@ export type GetErrorArgs<
219
219
  args?: readonly unknown[]
220
220
  }
221
221
  : TArgs extends readonly []
222
- ? { args?: never }
223
- : {
224
- /** Arguments to pass contract method */ args: TArgs
225
- }
222
+ ? { args?: never }
223
+ : {
224
+ /** Arguments to pass contract method */ args: TArgs
225
+ }
226
226
 
227
227
  export type GetEventArgs<
228
228
  TAbi extends Abi | readonly unknown[],
@@ -296,10 +296,10 @@ export type LogTopicType<
296
296
  > = TTopic extends Hex
297
297
  ? TPrimitiveType
298
298
  : TTopic extends Hex[]
299
- ? TPrimitiveType[]
300
- : TTopic extends null
301
- ? null
302
- : never
299
+ ? TPrimitiveType[]
300
+ : TTopic extends null
301
+ ? null
302
+ : never
303
303
 
304
304
  /**
305
305
  * @internal
@@ -328,46 +328,45 @@ export type AbiEventParametersToPrimitiveTypes<
328
328
  > = TAbiParameters extends readonly []
329
329
  ? readonly []
330
330
  : Filter<
331
- TAbiParameters,
332
- Options['IndexedOnly'] extends true ? { indexed: true } : object
333
- > extends infer Filtered extends readonly AbiParameter[]
334
- ? _HasUnnamedAbiParameter<Filtered> extends true
335
- ? // Has unnamed tuple parameters so return as array
336
- | readonly [
337
- ...{
338
- [K in keyof Filtered]: AbiEventParameterToPrimitiveType<
339
- Filtered[K],
340
- Options
341
- >
342
- },
343
- ]
344
- // Distribute over tuple to represent optional parameters
345
- | (Options['Required'] extends true
346
- ? never
347
- : // Distribute over tuple to represent optional parameters
348
- Filtered extends readonly [
349
- ...infer Head extends readonly AbiParameter[],
350
- infer _,
351
- ]
352
- ? AbiEventParametersToPrimitiveTypes<
353
- readonly [...{ [K in keyof Head]: Omit<Head[K], 'name'> }],
354
- Options
355
- >
356
- : never)
357
- : // All tuple parameters are named so return as object
358
- {
359
- [Parameter in
360
- Filtered[number] as Parameter extends {
361
- name: infer Name extends string
362
- }
363
- ? Name
364
- : never]?: AbiEventParameterToPrimitiveType<Parameter, Options>
365
- } extends infer Mapped
366
- ? Prettify<
367
- MaybeRequired<
368
- Mapped,
369
- Options['Required'] extends boolean ? Options['Required'] : false
370
- >
371
- >
331
+ TAbiParameters,
332
+ Options['IndexedOnly'] extends true ? { indexed: true } : object
333
+ > extends infer Filtered extends readonly AbiParameter[]
334
+ ? _HasUnnamedAbiParameter<Filtered> extends true
335
+ ? // Has unnamed tuple parameters so return as array
336
+ | readonly [
337
+ ...{
338
+ [K in keyof Filtered]: AbiEventParameterToPrimitiveType<
339
+ Filtered[K],
340
+ Options
341
+ >
342
+ },
343
+ ]
344
+ // Distribute over tuple to represent optional parameters
345
+ | (Options['Required'] extends true
346
+ ? never
347
+ : // Distribute over tuple to represent optional parameters
348
+ Filtered extends readonly [
349
+ ...infer Head extends readonly AbiParameter[],
350
+ infer _,
351
+ ]
352
+ ? AbiEventParametersToPrimitiveTypes<
353
+ readonly [...{ [K in keyof Head]: Omit<Head[K], 'name'> }],
354
+ Options
355
+ >
356
+ : never)
357
+ : // All tuple parameters are named so return as object
358
+ {
359
+ [Parameter in Filtered[number] as Parameter extends {
360
+ name: infer Name extends string
361
+ }
362
+ ? Name
363
+ : never]?: AbiEventParameterToPrimitiveType<Parameter, Options>
364
+ } extends infer Mapped
365
+ ? Prettify<
366
+ MaybeRequired<
367
+ Mapped,
368
+ Options['Required'] extends boolean ? Options['Required'] : false
369
+ >
370
+ >
371
+ : never
372
372
  : never
373
- : never
package/types/filter.ts CHANGED
@@ -42,18 +42,18 @@ export type Filter<
42
42
  strict: TStrict
43
43
  }
44
44
  : TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName>
45
- ? {
46
- abi: TAbi
47
- args: TArgs
48
- eventName: TEventName
49
- strict: TStrict
50
- }
51
- : {
52
- abi: TAbi
53
- args?: never
54
- eventName: TEventName
55
- strict: TStrict
56
- }
45
+ ? {
46
+ abi: TAbi
47
+ args: TArgs
48
+ eventName: TEventName
49
+ strict: TStrict
50
+ }
51
+ : {
52
+ abi: TAbi
53
+ args?: never
54
+ eventName: TEventName
55
+ strict: TStrict
56
+ }
57
57
  : {
58
58
  abi?: never
59
59
  args?: never
package/types/log.ts CHANGED
@@ -75,10 +75,10 @@ type GetTopics<
75
75
  > = true extends _FailedToParseArgs
76
76
  ? [Hex, ...Hex[]] | []
77
77
  : TAbiEvent extends AbiEvent
78
- ? Topics<TAbiEvent['inputs']>
79
- : _AbiEvent extends AbiEvent
80
- ? Topics<_AbiEvent['inputs']>
81
- : [Hex, ...Hex[]] | []
78
+ ? Topics<TAbiEvent['inputs']>
79
+ : _AbiEvent extends AbiEvent
80
+ ? Topics<_AbiEvent['inputs']>
81
+ : [Hex, ...Hex[]] | []
82
82
 
83
83
  type GetInferredLogValues<
84
84
  TAbiEvent extends AbiEvent | undefined = undefined,
@@ -23,32 +23,37 @@ export type MulticallContracts<
23
23
  > = Depth['length'] extends MAXIMUM_DEPTH
24
24
  ? (ContractFunctionConfig & TProperties)[]
25
25
  : TContracts extends []
26
- ? []
27
- : TContracts extends [infer Head extends MulticallContract]
28
- ? [
29
- ...Result,
30
- ContractFunctionConfig<Head['abi'], Head['functionName']> & TProperties,
31
- ]
32
- : TContracts extends [
33
- infer Head extends MulticallContract,
34
- ...infer Tail extends readonly MulticallContract[],
35
- ]
36
- ? MulticallContracts<
37
- [...Tail],
38
- TProperties,
39
- [
40
- ...Result,
41
- ContractFunctionConfig<Head['abi'], Head['functionName']> & TProperties,
42
- ],
43
- [...Depth, 1]
44
- >
45
- : unknown[] extends TContracts
46
- ? TContracts
47
- : // If `TContracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
48
- // use this to infer the param types in the case of Array.map() argument
49
- TContracts extends ContractFunctionConfig<infer TAbi, infer TFunctionName>[]
50
- ? (ContractFunctionConfig<TAbi, TFunctionName> & TProperties)[]
51
- : (ContractFunctionConfig & TProperties)[]
26
+ ? []
27
+ : TContracts extends [infer Head extends MulticallContract]
28
+ ? [
29
+ ...Result,
30
+ ContractFunctionConfig<Head['abi'], Head['functionName']> &
31
+ TProperties,
32
+ ]
33
+ : TContracts extends [
34
+ infer Head extends MulticallContract,
35
+ ...infer Tail extends readonly MulticallContract[],
36
+ ]
37
+ ? MulticallContracts<
38
+ [...Tail],
39
+ TProperties,
40
+ [
41
+ ...Result,
42
+ ContractFunctionConfig<Head['abi'], Head['functionName']> &
43
+ TProperties,
44
+ ],
45
+ [...Depth, 1]
46
+ >
47
+ : unknown[] extends TContracts
48
+ ? TContracts
49
+ : // If `TContracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
50
+ // use this to infer the param types in the case of Array.map() argument
51
+ TContracts extends ContractFunctionConfig<
52
+ infer TAbi,
53
+ infer TFunctionName
54
+ >[]
55
+ ? (ContractFunctionConfig<TAbi, TFunctionName> & TProperties)[]
56
+ : (ContractFunctionConfig & TProperties)[]
52
57
 
53
58
  export type MulticallResult<
54
59
  Result,
@@ -75,34 +80,37 @@ export type MulticallResults<
75
80
  > = Depth['length'] extends MAXIMUM_DEPTH
76
81
  ? MulticallResult<ContractFunctionResult, TAllowFailure>[]
77
82
  : TContracts extends []
78
- ? []
79
- : TContracts extends [infer Head extends MulticallContract]
80
- ? [
81
- ...Result,
82
- MulticallResult<
83
- ContractFunctionResult<Head['abi'], Head['functionName']>,
84
- TAllowFailure
85
- >,
86
- ]
87
- : TContracts extends [
88
- infer Head extends MulticallContract,
89
- ...infer Tail extends readonly MulticallContract[],
90
- ]
91
- ? MulticallResults<
92
- [...Tail],
93
- TAllowFailure,
94
- [
95
- ...Result,
96
- MulticallResult<
97
- ContractFunctionResult<Head['abi'], Head['functionName']>,
98
- TAllowFailure
99
- >,
100
- ],
101
- [...Depth, 1]
102
- >
103
- : TContracts extends ContractFunctionConfig<infer TAbi, infer TFunctionName>[]
104
- ? MulticallResult<
105
- ContractFunctionResult<TAbi, TFunctionName>,
106
- TAllowFailure
107
- >[]
108
- : MulticallResult<ContractFunctionResult, TAllowFailure>[]
83
+ ? []
84
+ : TContracts extends [infer Head extends MulticallContract]
85
+ ? [
86
+ ...Result,
87
+ MulticallResult<
88
+ ContractFunctionResult<Head['abi'], Head['functionName']>,
89
+ TAllowFailure
90
+ >,
91
+ ]
92
+ : TContracts extends [
93
+ infer Head extends MulticallContract,
94
+ ...infer Tail extends readonly MulticallContract[],
95
+ ]
96
+ ? MulticallResults<
97
+ [...Tail],
98
+ TAllowFailure,
99
+ [
100
+ ...Result,
101
+ MulticallResult<
102
+ ContractFunctionResult<Head['abi'], Head['functionName']>,
103
+ TAllowFailure
104
+ >,
105
+ ],
106
+ [...Depth, 1]
107
+ >
108
+ : TContracts extends ContractFunctionConfig<
109
+ infer TAbi,
110
+ infer TFunctionName
111
+ >[]
112
+ ? MulticallResult<
113
+ ContractFunctionResult<TAbi, TFunctionName>,
114
+ TAllowFailure
115
+ >[]
116
+ : MulticallResult<ContractFunctionResult, TAllowFailure>[]
@@ -186,10 +186,10 @@ export type TransactionSerialized<TType extends TransactionType = 'legacy'> =
186
186
  TType extends 'eip1559'
187
187
  ? TransactionSerializedEIP1559
188
188
  : TType extends 'eip2930'
189
- ? TransactionSerializedEIP2930
190
- : TType extends 'legacy'
191
- ? TransactionSerializedLegacy
192
- : TransactionSerializedGeneric
189
+ ? TransactionSerializedEIP2930
190
+ : TType extends 'legacy'
191
+ ? TransactionSerializedLegacy
192
+ : TransactionSerializedGeneric
193
193
 
194
194
  export type TransactionSerializableBase<
195
195
  TQuantity = bigint,
@@ -42,18 +42,18 @@ export type GetTypedDataMessage<
42
42
  > = TPrimaryType extends 'EIP712Domain'
43
43
  ? {}
44
44
  : { [key_3: string]: any } extends TMessage // Check if we were able to infer the shape of typed data
45
- ? {
46
- /**
47
- * Data to sign
48
- *
49
- * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link types} for type inference.
50
- */
51
- message: { [key_4: string]: unknown }
52
- }
53
- : {
54
- /** Data to sign */
55
- message: TMessage
56
- }
45
+ ? {
46
+ /**
47
+ * Data to sign
48
+ *
49
+ * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link types} for type inference.
50
+ */
51
+ message: { [key_4: string]: unknown }
52
+ }
53
+ : {
54
+ /** Data to sign */
55
+ message: TMessage
56
+ }
57
57
 
58
58
  export type GetTypedDataPrimaryType<
59
59
  TTypedData extends TypedData | { [key: string]: unknown } = TypedData,
package/types/utils.ts CHANGED
@@ -54,7 +54,7 @@ export type IsNever<T> = [T] extends [never] ? true : false
54
54
  * type Result = Or<[false, false, false]>
55
55
  * // ^? type Result = false
56
56
  */
57
- export type Or<T extends readonly unknown[],> = T extends readonly [
57
+ export type Or<T extends readonly unknown[]> = T extends readonly [
58
58
  infer Head,
59
59
  ...infer Tail,
60
60
  ]
@@ -125,12 +125,11 @@ export type MaybeUndefined<
125
125
  * @private Helper for `Assign`. This is a workaround for tsc generating errorneous type definitions.
126
126
  */
127
127
  export type Assign_<T, U> = {
128
- [K in
129
- keyof T as K extends keyof U
130
- ? U[K] extends void
131
- ? never
132
- : K
133
- : K]: K extends keyof U ? U[K] : T[K]
128
+ [K in keyof T as K extends keyof U
129
+ ? U[K] extends void
130
+ ? never
131
+ : K
132
+ : K]: K extends keyof U ? U[K] : T[K]
134
133
  }
135
134
 
136
135
  /**
@@ -37,8 +37,8 @@ export type DecodeFunctionResultParameters<
37
37
  } & (TFunctionName extends string
38
38
  ? { abi: TAbi } & Partial<GetFunctionArgs<TAbi, TFunctionName>>
39
39
  : _FunctionName extends string
40
- ? { abi: [TAbi[number]] } & Partial<GetFunctionArgs<TAbi, _FunctionName>>
41
- : never)
40
+ ? { abi: [TAbi[number]] } & Partial<GetFunctionArgs<TAbi, _FunctionName>>
41
+ : never)
42
42
 
43
43
  export type DecodeFunctionResultReturnType<
44
44
  TAbi extends Abi | readonly unknown[] = Abi,
@@ -39,8 +39,8 @@ export type EncodeErrorResultParameters<
39
39
  } & (TErrorName extends string
40
40
  ? { abi: TAbi } & GetErrorArgs<TAbi, TErrorName>
41
41
  : _ErrorName extends string
42
- ? { abi: [TAbi[number]] } & GetErrorArgs<TAbi, _ErrorName>
43
- : never)
42
+ ? { abi: [TAbi[number]] } & GetErrorArgs<TAbi, _ErrorName>
43
+ : never)
44
44
 
45
45
  export type EncodeErrorResultErrorType =
46
46
  | GetAbiItemErrorType
@@ -39,8 +39,8 @@ export type EncodeEventTopicsParameters<
39
39
  } & (TEventName extends string
40
40
  ? { abi: TAbi; args?: GetEventArgs<TAbi, TEventName> }
41
41
  : _EventName extends string
42
- ? { abi: [TAbi[number]]; args?: GetEventArgs<TAbi, _EventName> }
43
- : never)
42
+ ? { abi: [TAbi[number]]; args?: GetEventArgs<TAbi, _EventName> }
43
+ : never)
44
44
 
45
45
  export type EncodeEventTopicsErrorType =
46
46
  | AbiEventNotFoundErrorType
@@ -82,8 +82,8 @@ export function encodeEventTopics<
82
82
  const args_ = Array.isArray(args)
83
83
  ? args
84
84
  : Object.values(args).length > 0
85
- ? indexedInputs?.map((x: any) => (args as any)[x.name]) ?? []
86
- : []
85
+ ? indexedInputs?.map((x: any) => (args as any)[x.name]) ?? []
86
+ : []
87
87
 
88
88
  if (args_.length > 0) {
89
89
  topics =
@@ -93,8 +93,8 @@ export function encodeEventTopics<
93
93
  encodeArg({ param, value: args_[i][j] }),
94
94
  )
95
95
  : args_[i]
96
- ? encodeArg({ param, value: args_[i] })
97
- : null,
96
+ ? encodeArg({ param, value: args_[i] })
97
+ : null,
98
98
  ) ?? []
99
99
  }
100
100
  }
@@ -36,8 +36,8 @@ export type EncodeFunctionDataParameters<
36
36
  } & (TFunctionName extends string
37
37
  ? { abi: TAbi } & GetFunctionArgs<TAbi, TFunctionName>
38
38
  : _FunctionName extends string
39
- ? { abi: [TAbi[number]] } & GetFunctionArgs<TAbi, _FunctionName>
40
- : never)
39
+ ? { abi: [TAbi[number]] } & GetFunctionArgs<TAbi, _FunctionName>
40
+ : never)
41
41
 
42
42
  export type EncodeFunctionDataErrorType =
43
43
  | AbiFunctionNotFoundErrorType
@@ -32,11 +32,11 @@ export type EncodeFunctionResultParameters<
32
32
  } & (TFunctionName extends string
33
33
  ? { abi: TAbi; result?: ContractFunctionResult<TAbi, TFunctionName> }
34
34
  : _FunctionName extends string
35
- ? {
36
- abi: [TAbi[number]]
37
- result?: ContractFunctionResult<TAbi, _FunctionName>
38
- }
39
- : never)
35
+ ? {
36
+ abi: [TAbi[number]]
37
+ result?: ContractFunctionResult<TAbi, _FunctionName>
38
+ }
39
+ : never)
40
40
 
41
41
  export type EncodeFunctionResultErrorType =
42
42
  | AbiFunctionOutputsNotFoundError
package/utils/ccip.ts CHANGED
@@ -52,7 +52,7 @@ export const offchainLookupAbiItem = {
52
52
 
53
53
  export type OffchainLookupErrorType = ErrorType
54
54
 
55
- export async function offchainLookup<TChain extends Chain | undefined,>(
55
+ export async function offchainLookup<TChain extends Chain | undefined>(
56
56
  client: Client<Transport, TChain>,
57
57
  {
58
58
  blockNumber,
@@ -140,7 +140,9 @@ export async function ccipFetch({
140
140
  if (!response.ok) {
141
141
  error = new HttpRequestError({
142
142
  body,
143
- details: stringify(result.error) || response.statusText,
143
+ details: result?.error
144
+ ? stringify(result.error)
145
+ : response.statusText,
144
146
  headers: response.headers,
145
147
  status: response.status,
146
148
  url,
@@ -27,14 +27,14 @@ export type FromBytesParameters<
27
27
  export type FromBytesReturnType<TTo> = TTo extends 'string'
28
28
  ? string
29
29
  : TTo extends 'hex'
30
- ? Hex
31
- : TTo extends 'bigint'
32
- ? bigint
33
- : TTo extends 'number'
34
- ? number
35
- : TTo extends 'boolean'
36
- ? boolean
37
- : never
30
+ ? Hex
31
+ : TTo extends 'bigint'
32
+ ? bigint
33
+ : TTo extends 'number'
34
+ ? number
35
+ : TTo extends 'boolean'
36
+ ? boolean
37
+ : never
38
38
 
39
39
  export type FromBytesErrorType =
40
40
  | BytesToHexErrorType
@@ -41,14 +41,14 @@ export type FromHexParameters<
41
41
  export type FromHexReturnType<TTo> = TTo extends 'string'
42
42
  ? string
43
43
  : TTo extends 'bigint'
44
- ? bigint
45
- : TTo extends 'number'
46
- ? number
47
- : TTo extends 'bytes'
48
- ? ByteArray
49
- : TTo extends 'boolean'
50
- ? boolean
51
- : never
44
+ ? bigint
45
+ : TTo extends 'number'
46
+ ? number
47
+ : TTo extends 'bytes'
48
+ ? ByteArray
49
+ : TTo extends 'boolean'
50
+ ? boolean
51
+ : never
52
52
 
53
53
  export type FromHexErrorType =
54
54
  | HexToNumberErrorType
@@ -114,9 +114,9 @@ const charCodeMap = {
114
114
  function charCodeToBase16(char: number) {
115
115
  if (char >= charCodeMap.zero && char <= charCodeMap.nine)
116
116
  return char - charCodeMap.zero
117
- else if (char >= charCodeMap.A && char <= charCodeMap.F)
117
+ if (char >= charCodeMap.A && char <= charCodeMap.F)
118
118
  return char - (charCodeMap.A - 10)
119
- else if (char >= charCodeMap.a && char <= charCodeMap.f)
119
+ if (char >= charCodeMap.a && char <= charCodeMap.f)
120
120
  return char - (charCodeMap.a - 10)
121
121
  return undefined
122
122
  }
@@ -117,7 +117,9 @@ export function resolveAvatarUri({
117
117
  isOnChain: false,
118
118
  isEncoded: false,
119
119
  }
120
- } else if (protocol === 'ar:/' && target) {
120
+ }
121
+
122
+ if (protocol === 'ar:/' && target) {
121
123
  return {
122
124
  uri: `${arweaveGateway}/${target}${subtarget || ''}`,
123
125
  isOnChain: false,
@@ -28,7 +28,7 @@ export type NamehashErrorType =
28
28
  * - Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `namehash`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize.html) function for this.
29
29
  *
30
30
  * @example
31
- * namehash('wagmi-dev.eth')
31
+ * namehash('wevm.eth')
32
32
  * '0xf246651c1b9a6b141d19c2604e9a58f567973833990f830d882534a747801359'
33
33
  *
34
34
  * @link https://eips.ethereum.org/EIPS/eip-137
@@ -7,8 +7,8 @@ export type NormalizeErrorType = ErrorType
7
7
  * @description Normalizes ENS name according to ENSIP-15.
8
8
  *
9
9
  * @example
10
- * normalize('wagmi-dev.eth')
11
- * 'wagmi-dev.eth'
10
+ * normalize('wevm.eth')
11
+ * 'wevm.eth'
12
12
  *
13
13
  * @see https://docs.ens.domains/contract-api-reference/name-processing#normalising-names
14
14
  * @see https://github.com/ensdomains/docs/blob/9edf9443de4333a0ea7ec658a870672d5d180d53/ens-improvement-proposals/ensip-15-normalization-standard.md
@@ -48,8 +48,8 @@ export function getContractError<err extends ErrorType<string>>(
48
48
  err instanceof RawContractError
49
49
  ? err
50
50
  : err instanceof BaseError
51
- ? err.walk((err) => 'data' in (err as Error)) || err.walk()
52
- : {}
51
+ ? err.walk((err) => 'data' in (err as Error)) || err.walk()
52
+ : {}
53
53
  ) as RawContractError
54
54
 
55
55
  const cause = (() => {