viem 1.5.4 → 1.6.2

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 (343) hide show
  1. package/chains/utils/package.json +5 -0
  2. package/dist/cjs/accounts/index.js +5 -1
  3. package/dist/cjs/accounts/index.js.map +1 -1
  4. package/dist/cjs/accounts/utils/privateKeyToAddress.js +12 -0
  5. package/dist/cjs/accounts/utils/privateKeyToAddress.js.map +1 -0
  6. package/dist/cjs/accounts/utils/signTransaction.js.map +1 -1
  7. package/dist/cjs/actions/getContract.js.map +1 -1
  8. package/dist/cjs/actions/public/estimateGas.js +3 -1
  9. package/dist/cjs/actions/public/estimateGas.js.map +1 -1
  10. package/dist/cjs/actions/public/multicall.js +2 -3
  11. package/dist/cjs/actions/public/multicall.js.map +1 -1
  12. package/dist/cjs/actions/public/watchContractEvent.js +134 -67
  13. package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
  14. package/dist/cjs/actions/public/watchEvent.js +136 -62
  15. package/dist/cjs/actions/public/watchEvent.js.map +1 -1
  16. package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
  17. package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
  18. package/dist/cjs/chains/{formatters/celo.js → celo/formatters.js} +1 -1
  19. package/dist/cjs/chains/celo/formatters.js.map +1 -0
  20. package/dist/cjs/chains/{serializers/celo.js → celo/serializers.js} +1 -1
  21. package/dist/cjs/chains/celo/serializers.js.map +1 -0
  22. package/dist/cjs/{types/formatter.js → chains/celo/types.js} +1 -1
  23. package/dist/cjs/chains/celo/types.js.map +1 -0
  24. package/dist/cjs/chains/index.js +32 -16
  25. package/dist/cjs/chains/index.js.map +1 -1
  26. package/dist/cjs/chains/optimism/fees.js +7 -0
  27. package/dist/cjs/chains/optimism/fees.js.map +1 -0
  28. package/dist/cjs/chains/{formatters/optimism.js → optimism/formatters.js} +13 -1
  29. package/dist/cjs/chains/optimism/formatters.js.map +1 -0
  30. package/dist/cjs/{types/serializer.js → chains/optimism/types.js} +1 -1
  31. package/dist/cjs/chains/optimism/types.js.map +1 -0
  32. package/dist/cjs/chains/utils.js +11 -0
  33. package/dist/cjs/chains/utils.js.map +1 -0
  34. package/dist/cjs/clients/decorators/public.js.map +1 -1
  35. package/dist/cjs/constants/number.js +96 -96
  36. package/dist/cjs/constants/number.js.map +1 -1
  37. package/dist/cjs/errors/node.js +1 -1
  38. package/dist/cjs/errors/node.js.map +1 -1
  39. package/dist/cjs/errors/version.js +1 -1
  40. package/dist/cjs/index.js.map +1 -1
  41. package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  42. package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
  43. package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
  44. package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
  45. package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
  46. package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
  47. package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
  48. package/dist/cjs/utils/abi/encodePacked.js.map +1 -1
  49. package/dist/cjs/utils/chain.js +5 -3
  50. package/dist/cjs/utils/chain.js.map +1 -1
  51. package/dist/cjs/utils/formatters/block.js.map +1 -1
  52. package/dist/cjs/utils/formatters/extract.js.map +1 -1
  53. package/dist/cjs/utils/formatters/formatter.js.map +1 -1
  54. package/dist/cjs/utils/formatters/transaction.js.map +1 -1
  55. package/dist/cjs/utils/formatters/transactionReceipt.js.map +1 -1
  56. package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
  57. package/dist/cjs/utils/poll.js +1 -1
  58. package/dist/cjs/utils/poll.js.map +1 -1
  59. package/dist/cjs/utils/transaction/prepareRequest.js +15 -6
  60. package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
  61. package/dist/cjs/utils/typedData.js +2 -2
  62. package/dist/cjs/utils/typedData.js.map +1 -1
  63. package/dist/esm/accounts/index.js +2 -0
  64. package/dist/esm/accounts/index.js.map +1 -1
  65. package/dist/esm/accounts/utils/privateKeyToAddress.js +15 -0
  66. package/dist/esm/accounts/utils/privateKeyToAddress.js.map +1 -0
  67. package/dist/esm/accounts/utils/signTransaction.js.map +1 -1
  68. package/dist/esm/actions/getContract.js.map +1 -1
  69. package/dist/esm/actions/public/estimateGas.js +4 -2
  70. package/dist/esm/actions/public/estimateGas.js.map +1 -1
  71. package/dist/esm/actions/public/multicall.js +2 -4
  72. package/dist/esm/actions/public/multicall.js.map +1 -1
  73. package/dist/esm/actions/public/watchContractEvent.js +145 -76
  74. package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
  75. package/dist/esm/actions/public/watchEvent.js +146 -70
  76. package/dist/esm/actions/public/watchEvent.js.map +1 -1
  77. package/dist/esm/actions/wallet/sendTransaction.js +1 -1
  78. package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
  79. package/dist/esm/actions/wallet/writeContract.js.map +1 -1
  80. package/dist/esm/chains/{formatters/celo.js → celo/formatters.js} +2 -2
  81. package/dist/esm/chains/celo/formatters.js.map +1 -0
  82. package/dist/esm/chains/{serializers/celo.js → celo/serializers.js} +1 -1
  83. package/dist/esm/chains/celo/serializers.js.map +1 -0
  84. package/dist/esm/chains/celo/types.js +2 -0
  85. package/dist/esm/chains/celo/types.js.map +1 -0
  86. package/dist/esm/chains/index.js +23 -7
  87. package/dist/esm/chains/index.js.map +1 -1
  88. package/dist/esm/chains/optimism/fees.js +4 -0
  89. package/dist/esm/chains/optimism/fees.js.map +1 -0
  90. package/dist/esm/chains/{formatters/optimism.js → optimism/formatters.js} +15 -2
  91. package/dist/esm/chains/optimism/formatters.js.map +1 -0
  92. package/dist/esm/chains/optimism/types.js +2 -0
  93. package/dist/esm/chains/optimism/types.js.map +1 -0
  94. package/dist/esm/chains/utils.js +4 -0
  95. package/dist/esm/chains/utils.js.map +1 -0
  96. package/dist/esm/clients/decorators/public.js.map +1 -1
  97. package/dist/esm/constants/number.js +96 -96
  98. package/dist/esm/constants/number.js.map +1 -1
  99. package/dist/esm/errors/node.js +1 -1
  100. package/dist/esm/errors/node.js.map +1 -1
  101. package/dist/esm/errors/version.js +1 -1
  102. package/dist/esm/index.js.map +1 -1
  103. package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
  104. package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
  105. package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
  106. package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
  107. package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
  108. package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
  109. package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
  110. package/dist/esm/utils/abi/encodePacked.js.map +1 -1
  111. package/dist/esm/utils/chain.js +5 -3
  112. package/dist/esm/utils/chain.js.map +1 -1
  113. package/dist/esm/utils/formatters/block.js.map +1 -1
  114. package/dist/esm/utils/formatters/extract.js.map +1 -1
  115. package/dist/esm/utils/formatters/formatter.js.map +1 -1
  116. package/dist/esm/utils/formatters/transaction.js.map +1 -1
  117. package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
  118. package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
  119. package/dist/esm/utils/poll.js +1 -1
  120. package/dist/esm/utils/poll.js.map +1 -1
  121. package/dist/esm/utils/transaction/prepareRequest.js +14 -5
  122. package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
  123. package/dist/esm/utils/typedData.js +2 -2
  124. package/dist/esm/utils/typedData.js.map +1 -1
  125. package/dist/types/accounts/index.d.ts +2 -0
  126. package/dist/types/accounts/index.d.ts.map +1 -1
  127. package/dist/types/accounts/types.d.ts +1 -1
  128. package/dist/types/accounts/types.d.ts.map +1 -1
  129. package/dist/types/accounts/utils/privateKeyToAddress.d.ts +11 -0
  130. package/dist/types/accounts/utils/privateKeyToAddress.d.ts.map +1 -0
  131. package/dist/types/accounts/utils/signTransaction.d.ts +2 -2
  132. package/dist/types/accounts/utils/signTransaction.d.ts.map +1 -1
  133. package/dist/types/accounts/utils/signTypedData.d.ts +1 -1
  134. package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
  135. package/dist/types/actions/getContract.d.ts +5 -5
  136. package/dist/types/actions/getContract.d.ts.map +1 -1
  137. package/dist/types/actions/public/createContractEventFilter.d.ts +3 -3
  138. package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
  139. package/dist/types/actions/public/createEventFilter.d.ts +5 -5
  140. package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
  141. package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
  142. package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
  143. package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
  144. package/dist/types/actions/public/getFilterChanges.d.ts +1 -1
  145. package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
  146. package/dist/types/actions/public/getFilterLogs.d.ts +1 -1
  147. package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
  148. package/dist/types/actions/public/getLogs.d.ts +4 -4
  149. package/dist/types/actions/public/getLogs.d.ts.map +1 -1
  150. package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
  151. package/dist/types/actions/public/getTransactionReceipt.d.ts.map +1 -1
  152. package/dist/types/actions/public/multicall.d.ts +1 -1
  153. package/dist/types/actions/public/multicall.d.ts.map +1 -1
  154. package/dist/types/actions/public/readContract.d.ts +1 -1
  155. package/dist/types/actions/public/readContract.d.ts.map +1 -1
  156. package/dist/types/actions/public/simulateContract.d.ts +3 -3
  157. package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
  158. package/dist/types/actions/public/watchContractEvent.d.ts +34 -8
  159. package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
  160. package/dist/types/actions/public/watchEvent.d.ts +35 -12
  161. package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
  162. package/dist/types/actions/wallet/deployContract.d.ts +4 -4
  163. package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
  164. package/dist/types/actions/wallet/sendTransaction.d.ts +2 -2
  165. package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
  166. package/dist/types/actions/wallet/signTypedData.d.ts +1 -1
  167. package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
  168. package/dist/types/actions/wallet/writeContract.d.ts +4 -2
  169. package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
  170. package/dist/types/chains/{formatters/celo.d.ts → celo/formatters.d.ts} +26 -85
  171. package/dist/types/chains/celo/formatters.d.ts.map +1 -0
  172. package/dist/types/chains/{serializers/celo.d.ts → celo/serializers.d.ts} +4 -4
  173. package/dist/types/chains/celo/serializers.d.ts.map +1 -0
  174. package/dist/types/chains/celo/types.d.ts +60 -0
  175. package/dist/types/chains/celo/types.d.ts.map +1 -0
  176. package/dist/types/chains/index.d.ts +2681 -2790
  177. package/dist/types/chains/index.d.ts.map +1 -1
  178. package/dist/types/chains/optimism/fees.d.ts +4 -0
  179. package/dist/types/chains/optimism/fees.d.ts.map +1 -0
  180. package/dist/types/chains/{formatters/optimism.d.ts → optimism/formatters.d.ts} +77 -54
  181. package/dist/types/chains/optimism/formatters.d.ts.map +1 -0
  182. package/dist/types/chains/optimism/types.d.ts +53 -0
  183. package/dist/types/chains/optimism/types.d.ts.map +1 -0
  184. package/dist/types/chains/utils.d.ts +6 -0
  185. package/dist/types/chains/utils.d.ts.map +1 -0
  186. package/dist/types/clients/decorators/public.d.ts +10 -10
  187. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  188. package/dist/types/clients/decorators/wallet.d.ts +3 -3
  189. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  190. package/dist/types/constants/number.d.ts.map +1 -1
  191. package/dist/types/errors/node.d.ts.map +1 -1
  192. package/dist/types/errors/version.d.ts +1 -1
  193. package/dist/types/index.d.ts +14 -4
  194. package/dist/types/index.d.ts.map +1 -1
  195. package/dist/types/types/chain.d.ts +52 -8
  196. package/dist/types/types/chain.d.ts.map +1 -1
  197. package/dist/types/types/multicall.d.ts +8 -8
  198. package/dist/types/types/multicall.d.ts.map +1 -1
  199. package/dist/types/types/rpc.d.ts +1 -1
  200. package/dist/types/types/rpc.d.ts.map +1 -1
  201. package/dist/types/types/typedData.d.ts +3 -3
  202. package/dist/types/types/typedData.d.ts.map +1 -1
  203. package/dist/types/types/utils.d.ts +10 -0
  204. package/dist/types/types/utils.d.ts.map +1 -1
  205. package/dist/types/utils/abi/decodeAbiParameters.d.ts +2 -2
  206. package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  207. package/dist/types/utils/abi/decodeDeployData.d.ts +3 -3
  208. package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
  209. package/dist/types/utils/abi/decodeErrorResult.d.ts +3 -3
  210. package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
  211. package/dist/types/utils/abi/decodeEventLog.d.ts +3 -3
  212. package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
  213. package/dist/types/utils/abi/decodeFunctionResult.d.ts +4 -4
  214. package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
  215. package/dist/types/utils/abi/encodeAbiParameters.d.ts +2 -2
  216. package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
  217. package/dist/types/utils/abi/encodeDeployData.d.ts +3 -3
  218. package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
  219. package/dist/types/utils/abi/encodeErrorResult.d.ts +4 -4
  220. package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
  221. package/dist/types/utils/abi/encodeEventTopics.d.ts +4 -4
  222. package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  223. package/dist/types/utils/abi/encodeFunctionData.d.ts +4 -4
  224. package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
  225. package/dist/types/utils/abi/encodeFunctionResult.d.ts +4 -4
  226. package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
  227. package/dist/types/utils/abi/encodePacked.d.ts +3 -3
  228. package/dist/types/utils/abi/encodePacked.d.ts.map +1 -1
  229. package/dist/types/utils/abi/getAbiItem.d.ts +3 -3
  230. package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
  231. package/dist/types/utils/chain.d.ts +3 -6
  232. package/dist/types/utils/chain.d.ts.map +1 -1
  233. package/dist/types/utils/formatters/block.d.ts +7 -3
  234. package/dist/types/utils/formatters/block.d.ts.map +1 -1
  235. package/dist/types/utils/formatters/extract.d.ts +2 -2
  236. package/dist/types/utils/formatters/extract.d.ts.map +1 -1
  237. package/dist/types/utils/formatters/formatter.d.ts +1 -1
  238. package/dist/types/utils/formatters/transaction.d.ts +8 -4
  239. package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
  240. package/dist/types/utils/formatters/transactionReceipt.d.ts +3 -4
  241. package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
  242. package/dist/types/utils/formatters/transactionRequest.d.ts +4 -5
  243. package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
  244. package/dist/types/utils/signature/hashTypedData.d.ts +1 -1
  245. package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
  246. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +1 -1
  247. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
  248. package/dist/types/utils/signature/verifyTypedData.d.ts +1 -1
  249. package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
  250. package/dist/types/utils/transaction/prepareRequest.d.ts +6 -11
  251. package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
  252. package/dist/types/utils/typedData.d.ts +1 -1
  253. package/dist/types/utils/typedData.d.ts.map +1 -1
  254. package/package.json +9 -3
  255. package/src/accounts/index.ts +6 -0
  256. package/src/accounts/types.ts +1 -1
  257. package/src/accounts/utils/privateKeyToAddress.ts +20 -0
  258. package/src/accounts/utils/signTransaction.ts +2 -2
  259. package/src/accounts/utils/signTypedData.ts +1 -1
  260. package/src/actions/getContract.ts +6 -5
  261. package/src/actions/public/createContractEventFilter.ts +3 -3
  262. package/src/actions/public/createEventFilter.ts +6 -6
  263. package/src/actions/public/estimateContractGas.ts +1 -1
  264. package/src/actions/public/estimateGas.ts +11 -2
  265. package/src/actions/public/getFilterChanges.ts +1 -1
  266. package/src/actions/public/getFilterLogs.ts +1 -1
  267. package/src/actions/public/getLogs.ts +5 -5
  268. package/src/actions/public/multicall.ts +9 -8
  269. package/src/actions/public/readContract.ts +1 -1
  270. package/src/actions/public/simulateContract.ts +3 -3
  271. package/src/actions/public/watchContractEvent.ts +204 -90
  272. package/src/actions/public/watchEvent.ts +232 -111
  273. package/src/actions/wallet/deployContract.ts +4 -4
  274. package/src/actions/wallet/sendTransaction.ts +9 -6
  275. package/src/actions/wallet/signTypedData.ts +1 -1
  276. package/src/actions/wallet/writeContract.ts +12 -8
  277. package/src/chains/{formatters/celo.ts → celo/formatters.ts} +29 -48
  278. package/src/chains/{serializers/celo.ts → celo/serializers.ts} +5 -5
  279. package/src/chains/celo/types.ts +111 -0
  280. package/src/chains/index.ts +23 -7
  281. package/src/chains/optimism/fees.ts +5 -0
  282. package/src/chains/optimism/formatters.ts +74 -0
  283. package/src/chains/optimism/types.ts +102 -0
  284. package/src/chains/utils.ts +41 -0
  285. package/src/clients/decorators/public.ts +16 -16
  286. package/src/clients/decorators/wallet.ts +3 -3
  287. package/src/constants/number.ts +96 -96
  288. package/src/errors/node.ts +2 -1
  289. package/src/errors/version.ts +1 -1
  290. package/src/index.ts +25 -8
  291. package/src/types/chain.ts +91 -14
  292. package/src/types/multicall.ts +14 -11
  293. package/src/types/rpc.ts +2 -6
  294. package/src/types/typedData.ts +2 -3
  295. package/src/types/utils.ts +11 -0
  296. package/src/utils/abi/decodeAbiParameters.ts +7 -8
  297. package/src/utils/abi/decodeDeployData.ts +3 -3
  298. package/src/utils/abi/decodeErrorResult.ts +3 -8
  299. package/src/utils/abi/decodeEventLog.ts +3 -3
  300. package/src/utils/abi/decodeFunctionResult.ts +4 -6
  301. package/src/utils/abi/encodeAbiParameters.ts +8 -9
  302. package/src/utils/abi/encodeDeployData.ts +3 -3
  303. package/src/utils/abi/encodeErrorResult.ts +4 -4
  304. package/src/utils/abi/encodeEventTopics.ts +4 -9
  305. package/src/utils/abi/encodeFunctionData.ts +4 -4
  306. package/src/utils/abi/encodeFunctionResult.ts +4 -4
  307. package/src/utils/abi/encodePacked.ts +6 -8
  308. package/src/utils/abi/getAbiItem.ts +3 -3
  309. package/src/utils/chain.ts +21 -10
  310. package/src/utils/formatters/block.ts +8 -6
  311. package/src/utils/formatters/extract.ts +2 -2
  312. package/src/utils/formatters/formatter.ts +2 -2
  313. package/src/utils/formatters/transaction.ts +8 -6
  314. package/src/utils/formatters/transactionReceipt.ts +9 -3
  315. package/src/utils/formatters/transactionRequest.ts +9 -3
  316. package/src/utils/poll.ts +1 -1
  317. package/src/utils/signature/hashTypedData.ts +1 -1
  318. package/src/utils/signature/recoverTypedDataAddress.ts +1 -1
  319. package/src/utils/signature/verifyTypedData.ts +1 -1
  320. package/src/utils/transaction/prepareRequest.ts +48 -22
  321. package/src/utils/typedData.ts +2 -3
  322. package/dist/cjs/chains/formatters/celo.js.map +0 -1
  323. package/dist/cjs/chains/formatters/optimism.js.map +0 -1
  324. package/dist/cjs/chains/serializers/celo.js.map +0 -1
  325. package/dist/cjs/types/formatter.js.map +0 -1
  326. package/dist/cjs/types/serializer.js.map +0 -1
  327. package/dist/esm/chains/formatters/celo.js.map +0 -1
  328. package/dist/esm/chains/formatters/optimism.js.map +0 -1
  329. package/dist/esm/chains/serializers/celo.js.map +0 -1
  330. package/dist/esm/types/formatter.js +0 -2
  331. package/dist/esm/types/formatter.js.map +0 -1
  332. package/dist/esm/types/serializer.js +0 -2
  333. package/dist/esm/types/serializer.js.map +0 -1
  334. package/dist/types/chains/formatters/celo.d.ts.map +0 -1
  335. package/dist/types/chains/formatters/optimism.d.ts.map +0 -1
  336. package/dist/types/chains/serializers/celo.d.ts.map +0 -1
  337. package/dist/types/types/formatter.d.ts +0 -17
  338. package/dist/types/types/formatter.d.ts.map +0 -1
  339. package/dist/types/types/serializer.d.ts +0 -7
  340. package/dist/types/types/serializer.d.ts.map +0 -1
  341. package/src/chains/formatters/optimism.ts +0 -91
  342. package/src/types/formatter.ts +0 -42
  343. package/src/types/serializer.ts +0 -19
@@ -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
@@ -88,7 +88,8 @@ export class NonceTooHighError extends BaseError {
88
88
  }
89
89
 
90
90
  export class NonceTooLowError extends BaseError {
91
- static nodeMessage = /nonce too low|transaction already imported/
91
+ static nodeMessage =
92
+ /nonce too low|transaction already imported|already known/
92
93
  override name = 'NonceTooLowError'
93
94
  constructor({ cause, nonce }: { cause?: BaseError; nonce?: number } = {}) {
94
95
  super(
@@ -1 +1 @@
1
- export const version = '1.5.4'
1
+ export const version = '1.6.2'
package/src/index.ts CHANGED
@@ -571,7 +571,30 @@ export type {
571
571
  Signature,
572
572
  SignableMessage,
573
573
  } from './types/misc.js'
574
- export type { Chain } from './types/chain.js'
574
+ export type {
575
+ Chain,
576
+ ChainContract,
577
+ ChainFees,
578
+ ChainFormatter,
579
+ /** @deprecated use `ChainFormatter` instead. */
580
+ ChainFormatter as Formatter,
581
+ ChainFormatters,
582
+ /** @deprecated use `ChainFormatters` instead. */
583
+ ChainFormatters as Formatters,
584
+ ChainSerializers,
585
+ /** @deprecated use `ChainSerializers` instead. */
586
+ ChainSerializers as Serializers,
587
+ ExtractChainFormatterExclude,
588
+ /** @deprecated use `ExtractChainFormatterExclude` instead. */
589
+ ExtractChainFormatterExclude as ExtractFormatterExclude,
590
+ ExtractChainFormatterParameters,
591
+ /** @deprecated use `ExtractChainFormatterParameters` instead. */
592
+ ExtractChainFormatterParameters as ExtractFormatterParameters,
593
+ ExtractChainFormatterReturnType,
594
+ /** @deprecated use `ExtractChainFormatterReturnType` instead. */
595
+ ExtractChainFormatterReturnType as ExtractFormatterReturnType,
596
+ GetChain,
597
+ } from './types/chain.js'
575
598
  export type {
576
599
  AddEthereumChainParameter,
577
600
  EIP1193Events,
@@ -599,13 +622,6 @@ export type {
599
622
  FeeValuesLegacy,
600
623
  } from './types/fee.js'
601
624
  export type { Filter } from './types/filter.js'
602
- export type {
603
- Formatter,
604
- Formatters,
605
- ExtractFormatterParameters,
606
- ExtractFormatterReturnType,
607
- } from './types/formatter.js'
608
- export type { Serializers } from './types/serializer.js'
609
625
  export type {
610
626
  GetTypedDataDomain,
611
627
  GetTypedDataMessage,
@@ -617,6 +633,7 @@ export type { GetTransportConfig } from './types/transport.js'
617
633
  export type { HDKey } from '@scure/bip32'
618
634
  export type { Log } from './types/log.js'
619
635
  export type {
636
+ MulticallContract,
620
637
  MulticallContracts,
621
638
  MulticallResult,
622
639
  MulticallResults,
@@ -1,17 +1,24 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
- import type { Formatters } from './formatter.js'
4
- import type { Serializers } from './serializer.js'
5
- import type { IsUndefined } from './utils.js'
3
+ import type { FormattedBlock } from '../utils/formatters/block.js'
4
+ import type { PrepareRequestParameters } from '../utils/transaction/prepareRequest.js'
5
+ import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
6
+ import type {
7
+ TransactionSerializable,
8
+ TransactionSerializableGeneric,
9
+ } from './transaction.js'
10
+ import type { IsUndefined, Prettify } from './utils.js'
6
11
 
7
12
  export type Chain<
8
- formatters extends Formatters | undefined = Formatters | undefined,
9
- serializers extends Serializers<formatters> | undefined =
10
- | Serializers<formatters>
11
- | undefined,
12
- > = import('@wagmi/chains').Chain & {
13
+ formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
14
+ > = import('@wagmi/chains').Chain & ChainConfig<formatters>
15
+
16
+ export type ChainConfig<
17
+ formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
18
+ > = {
13
19
  formatters?: formatters | undefined
14
- serializers?: serializers | undefined
20
+ serializers?: ChainSerializers<formatters> | undefined
21
+ fees?: ChainFees<formatters> | undefined
15
22
  }
16
23
 
17
24
  export type ChainContract = {
@@ -19,9 +26,79 @@ export type ChainContract = {
19
26
  blockCreated?: number
20
27
  }
21
28
 
29
+ export type ChainFees<
30
+ formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
31
+ > = {
32
+ defaultPriorityFee:
33
+ | bigint
34
+ | ((args: {
35
+ block: Prettify<FormattedBlock<{ formatters: formatters }>>
36
+ request: PrepareRequestParameters<
37
+ Omit<Chain, 'formatters'> & { formatters: formatters }
38
+ >
39
+ }) => Promise<bigint> | bigint)
40
+ }
41
+
42
+ export type ChainFormatters = {
43
+ block?: ChainFormatter<'block'>
44
+ transaction?: ChainFormatter<'transaction'>
45
+ transactionReceipt?: ChainFormatter<'transactionReceipt'>
46
+ transactionRequest?: ChainFormatter<'transactionRequest'>
47
+ }
48
+
49
+ export type ChainFormatter<type extends string = string> = {
50
+ format: (args: any) => any
51
+ type: type
52
+ }
53
+
54
+ export type ChainSerializers<
55
+ formatters extends ChainFormatters | undefined = undefined,
56
+ > = {
57
+ transaction?: SerializeTransactionFn<
58
+ formatters extends ChainFormatters
59
+ ? formatters['transactionRequest'] extends ChainFormatter
60
+ ? TransactionSerializableGeneric &
61
+ Parameters<formatters['transactionRequest']['format']>[0]
62
+ : TransactionSerializable
63
+ : TransactionSerializable
64
+ >
65
+ }
66
+
67
+ /////////////////////////////////////////////////////////////////////
68
+ // Utils
69
+
70
+ export type ExtractChainFormatterExclude<
71
+ chain extends { formatters?: Chain['formatters'] } | undefined,
72
+ type extends keyof ChainFormatters,
73
+ > = chain extends { formatters?: infer _Formatters extends ChainFormatters }
74
+ ? _Formatters[type] extends { exclude: infer Exclude }
75
+ ? Extract<Exclude, string[]>[number]
76
+ : ''
77
+ : ''
78
+
79
+ export type ExtractChainFormatterParameters<
80
+ chain extends { formatters?: Chain['formatters'] } | undefined,
81
+ type extends keyof ChainFormatters,
82
+ fallback,
83
+ > = chain extends { formatters?: infer _Formatters extends ChainFormatters }
84
+ ? _Formatters[type] extends ChainFormatter
85
+ ? Parameters<_Formatters[type]['format']>[0]
86
+ : fallback
87
+ : fallback
88
+
89
+ export type ExtractChainFormatterReturnType<
90
+ chain extends { formatters?: Chain['formatters'] } | undefined,
91
+ type extends keyof ChainFormatters,
92
+ fallback,
93
+ > = chain extends { formatters?: infer _Formatters extends ChainFormatters }
94
+ ? _Formatters[type] extends ChainFormatter
95
+ ? ReturnType<_Formatters[type]['format']>
96
+ : fallback
97
+ : fallback
98
+
22
99
  export type GetChain<
23
- TChain extends Chain | undefined,
24
- TChainOverride extends Chain | undefined = undefined,
25
- > = IsUndefined<TChain> extends true
26
- ? { chain: TChainOverride | null }
27
- : { chain?: TChainOverride | null }
100
+ chain extends Chain | undefined,
101
+ chainOverride extends Chain | undefined = undefined,
102
+ > = IsUndefined<chain> extends true
103
+ ? { chain: chainOverride | null }
104
+ : { chain?: chainOverride | null }
@@ -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],
package/src/types/rpc.ts CHANGED
@@ -26,12 +26,8 @@ export type TransactionType = '0x0' | '0x1' | '0x2' | (string & {})
26
26
  export type RpcBlock<
27
27
  TBlockTag extends BlockTag = BlockTag,
28
28
  TIncludeTransactions extends boolean = boolean,
29
- > = Block<
30
- Quantity,
31
- TIncludeTransactions,
32
- TBlockTag,
33
- RpcTransaction<TBlockTag extends 'pending' ? true : false>
34
- >
29
+ TTransaction = RpcTransaction<TBlockTag extends 'pending' ? true : false>,
30
+ > = Block<Quantity, TIncludeTransactions, TBlockTag, TTransaction>
35
31
  export type RpcBlockNumber = BlockNumber<Quantity>
36
32
  export type RpcBlockIdentifier = BlockIdentifier<Quantity>
37
33
  export type RpcUncle = Uncle<Quantity>
@@ -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
  }
@@ -155,6 +155,17 @@ export type OptionalNullable<T> = {
155
155
  [K in keyof T as T[K] extends NonNullable<unknown> ? never : K]?: T[K]
156
156
  }
157
157
 
158
+ /**
159
+ * @description Make properties K of type T never.
160
+ *
161
+ * @example
162
+ * NeverBy<{ a: string, b: boolean, c: number }, 'a' | 'c'>
163
+ * => { a: never, b: boolean, c: never }
164
+ */
165
+ export type NeverBy<T, K extends keyof T> = {
166
+ [U in keyof T]: U extends K ? never : T[U]
167
+ }
168
+
158
169
  /**
159
170
  * @description Constructs a type by excluding `undefined` from `T`.
160
171
  *
@@ -2,7 +2,6 @@ import type {
2
2
  AbiParameter,
3
3
  AbiParameterToPrimitiveType,
4
4
  AbiParametersToPrimitiveTypes,
5
- Narrow,
6
5
  } from 'abitype'
7
6
 
8
7
  import {
@@ -33,8 +32,8 @@ export type DecodeAbiParametersReturnType<
33
32
  >
34
33
 
35
34
  export function decodeAbiParameters<
36
- TParams extends readonly AbiParameter[] | readonly unknown[],
37
- >(params: Narrow<TParams>, data: Hex): DecodeAbiParametersReturnType<TParams> {
35
+ const TParams extends readonly AbiParameter[] | readonly unknown[],
36
+ >(params: TParams, data: Hex): DecodeAbiParametersReturnType<TParams> {
38
37
  if (data === '0x' && (params as unknown[]).length > 0)
39
38
  throw new AbiDecodingZeroDataError()
40
39
  if (size(data) && size(data) < 32)
@@ -53,7 +52,7 @@ export function decodeAbiParameters<
53
52
 
54
53
  type TupleAbiParameter = AbiParameter & { components: readonly AbiParameter[] }
55
54
 
56
- function decodeParams<TParams extends readonly AbiParameter[]>({
55
+ function decodeParams<const TParams extends readonly AbiParameter[]>({
57
56
  data,
58
57
  params,
59
58
  }: { data: Hex; params: TParams }) {
@@ -126,7 +125,7 @@ function decodeAddress(value: Hex) {
126
125
  return { consumed: 32, value: checksumAddress(slice(value, -20)) }
127
126
  }
128
127
 
129
- function decodeArray<TParam extends AbiParameter>(
128
+ function decodeArray<const TParam extends AbiParameter>(
130
129
  data: Hex,
131
130
  {
132
131
  param,
@@ -211,7 +210,7 @@ function decodeBool(value: Hex) {
211
210
  return { consumed: 32, value: hexToBool(value) }
212
211
  }
213
212
 
214
- function decodeBytes<TParam extends AbiParameter>(
213
+ function decodeBytes<const TParam extends AbiParameter>(
215
214
  data: Hex,
216
215
  { param, position }: { param: TParam; position: number },
217
216
  ) {
@@ -239,7 +238,7 @@ function decodeBytes<TParam extends AbiParameter>(
239
238
  return { consumed: 32, value }
240
239
  }
241
240
 
242
- function decodeNumber<TParam extends AbiParameter>(
241
+ function decodeNumber<const TParam extends AbiParameter>(
243
242
  value: Hex,
244
243
  { param }: { param: TParam },
245
244
  ) {
@@ -268,7 +267,7 @@ function decodeString(data: Hex, { position }: { position: number }) {
268
267
  }
269
268
 
270
269
  function decodeTuple<
271
- TParam extends AbiParameter & { components: readonly AbiParameter[] },
270
+ const TParam extends AbiParameter & { components: readonly AbiParameter[] },
272
271
  >(data: Hex, { param, position }: { param: TParam; position: number }) {
273
272
  // Tuples can have unnamed components (i.e. they are arrays), so we must
274
273
  // determine whether the tuple is named or unnamed. In the case of a named
@@ -1,4 +1,4 @@
1
- import type { Abi, Narrow } from 'abitype'
1
+ import type { Abi } from 'abitype'
2
2
 
3
3
  import {
4
4
  AbiConstructorNotFoundError,
@@ -14,7 +14,7 @@ const docsPath = '/docs/contract/decodeDeployData'
14
14
  export type DecodeDeployDataParameters<
15
15
  TAbi extends Abi | readonly unknown[] = Abi,
16
16
  > = {
17
- abi: Narrow<TAbi>
17
+ abi: TAbi
18
18
  bytecode: Hex
19
19
  data: Hex
20
20
  }
@@ -24,7 +24,7 @@ export type DecodeDeployDataReturnType<
24
24
  bytecode: Hex
25
25
  } & GetConstructorArgs<TAbi>
26
26
 
27
- export function decodeDeployData<TAbi extends Abi | readonly unknown[]>({
27
+ export function decodeDeployData<const TAbi extends Abi | readonly unknown[]>({
28
28
  abi,
29
29
  bytecode,
30
30
  data,
@@ -1,9 +1,4 @@
1
- import type {
2
- Abi,
3
- ExtractAbiError,
4
- ExtractAbiErrorNames,
5
- Narrow,
6
- } from 'abitype'
1
+ import type { Abi, ExtractAbiError, ExtractAbiErrorNames } from 'abitype'
7
2
 
8
3
  import { solidityError, solidityPanic } from '../../constants/solidity.js'
9
4
  import {
@@ -20,7 +15,7 @@ import { formatAbiItem } from './formatAbiItem.js'
20
15
 
21
16
  export type DecodeErrorResultParameters<
22
17
  TAbi extends Abi | readonly unknown[] = Abi,
23
- > = { abi?: Narrow<TAbi>; data: Hex }
18
+ > = { abi?: TAbi; data: Hex }
24
19
 
25
20
  export type DecodeErrorResultReturnType<
26
21
  TAbi extends Abi | readonly unknown[] = Abi,
@@ -37,7 +32,7 @@ export type DecodeErrorResultReturnType<
37
32
  }
38
33
  }[_ErrorNames]
39
34
 
40
- export function decodeErrorResult<TAbi extends Abi | readonly unknown[]>({
35
+ export function decodeErrorResult<const TAbi extends Abi | readonly unknown[]>({
41
36
  abi,
42
37
  data,
43
38
  }: DecodeErrorResultParameters<TAbi>): DecodeErrorResultReturnType<TAbi> {
@@ -1,4 +1,4 @@
1
- import type { Abi, AbiParameter, ExtractAbiEventNames, Narrow } from 'abitype'
1
+ import type { Abi, AbiParameter, ExtractAbiEventNames } from 'abitype'
2
2
 
3
3
  import {
4
4
  AbiDecodingDataSizeTooSmallError,
@@ -26,7 +26,7 @@ export type DecodeEventLogParameters<
26
26
  TData extends Hex | undefined = undefined,
27
27
  TStrict extends boolean = true,
28
28
  > = {
29
- abi: Narrow<TAbi>
29
+ abi: TAbi
30
30
  data?: TData
31
31
  eventName?: InferEventName<TAbi, TEventName>
32
32
  strict?: TStrict
@@ -61,7 +61,7 @@ export type DecodeEventLogReturnType<
61
61
  const docsPath = '/docs/contract/decodeEventLog'
62
62
 
63
63
  export function decodeEventLog<
64
- TAbi extends Abi | readonly unknown[],
64
+ const TAbi extends Abi | readonly unknown[],
65
65
  TEventName extends string | undefined = undefined,
66
66
  TTopics extends Hex[] = Hex[],
67
67
  TData extends Hex | undefined = undefined,