viem 2.57.17 → 2.57.18

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 (325) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
  3. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  4. package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
  5. package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
  6. package/_cjs/actions/ens/getEnsAddress.js +11 -1
  7. package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
  8. package/_cjs/actions/index.js +5 -3
  9. package/_cjs/actions/index.js.map +1 -1
  10. package/_cjs/actions/public/call.js +13 -2
  11. package/_cjs/actions/public/call.js.map +1 -1
  12. package/_cjs/actions/public/getLogs.js +18 -1
  13. package/_cjs/actions/public/getLogs.js.map +1 -1
  14. package/_cjs/actions/public/internal/isRangeError.js +18 -0
  15. package/_cjs/actions/public/internal/isRangeError.js.map +1 -0
  16. package/_cjs/actions/public/internal/watchTransport.js +24 -0
  17. package/_cjs/actions/public/internal/watchTransport.js.map +1 -0
  18. package/_cjs/actions/public/iterateLogs.js +48 -0
  19. package/_cjs/actions/public/iterateLogs.js.map +1 -0
  20. package/_cjs/actions/public/simulateContract.js +4 -4
  21. package/_cjs/actions/public/simulateContract.js.map +1 -1
  22. package/_cjs/actions/public/verifyHash.js +72 -39
  23. package/_cjs/actions/public/verifyHash.js.map +1 -1
  24. package/_cjs/actions/public/waitForTransactionReceipt.js +18 -1
  25. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  26. package/_cjs/actions/public/watchBlockHeaders.js +2 -10
  27. package/_cjs/actions/public/watchBlockHeaders.js.map +1 -1
  28. package/_cjs/actions/public/watchBlockNumber.js +3 -18
  29. package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
  30. package/_cjs/actions/public/watchBlocks.js +3 -18
  31. package/_cjs/actions/public/watchBlocks.js.map +1 -1
  32. package/_cjs/actions/public/watchContractEvent.js +5 -33
  33. package/_cjs/actions/public/watchContractEvent.js.map +1 -1
  34. package/_cjs/actions/public/watchEvent.js +5 -33
  35. package/_cjs/actions/public/watchEvent.js.map +1 -1
  36. package/_cjs/actions/wallet/prepareTransactionRequest.js +16 -3
  37. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  38. package/_cjs/celo/serializers.js +1 -1
  39. package/_cjs/celo/serializers.js.map +1 -1
  40. package/_cjs/clients/decorators/public.js +2 -0
  41. package/_cjs/clients/decorators/public.js.map +1 -1
  42. package/_cjs/constants/contracts.js +1 -1
  43. package/_cjs/constants/contracts.js.map +1 -1
  44. package/_cjs/errors/chain.js +2 -2
  45. package/_cjs/errors/chain.js.map +1 -1
  46. package/_cjs/errors/version.js +1 -1
  47. package/_cjs/index.js +5 -4
  48. package/_cjs/index.js.map +1 -1
  49. package/_cjs/op-stack/actions/buildProveWithdrawal.js +5 -5
  50. package/_cjs/op-stack/actions/buildProveWithdrawal.js.map +1 -1
  51. package/_cjs/op-stack/actions/getL2Output.js +13 -9
  52. package/_cjs/op-stack/actions/getL2Output.js.map +1 -1
  53. package/_cjs/op-stack/actions/waitToProve.js +1 -0
  54. package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
  55. package/_cjs/tempo/Account.js +30 -0
  56. package/_cjs/tempo/Account.js.map +1 -1
  57. package/_cjs/tempo/actions/accessKey.js +1 -1
  58. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  59. package/_cjs/tempo/actions/accounts.js +5 -5
  60. package/_cjs/tempo/actions/accounts.js.map +1 -1
  61. package/_cjs/tempo/actions/earn/deployment.js +1 -1
  62. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  63. package/_cjs/tempo/actions/earn.js +3 -3
  64. package/_cjs/tempo/actions/earn.js.map +1 -1
  65. package/_cjs/tempo/actions/propAmm.js +1 -1
  66. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  67. package/_cjs/tempo/actions/token.js +10 -2
  68. package/_cjs/tempo/actions/token.js.map +1 -1
  69. package/_cjs/tempo/chainConfig.js +14 -0
  70. package/_cjs/tempo/chainConfig.js.map +1 -1
  71. package/_cjs/tempo/internal/preAuthorized.js +214 -0
  72. package/_cjs/tempo/internal/preAuthorized.js.map +1 -0
  73. package/_cjs/tempo/internal/relay/feePayer.js +25 -7
  74. package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
  75. package/_cjs/utils/abi/decodeAbiParameters.js +33 -9
  76. package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  77. package/_cjs/utils/abi/encodeAbiParameters.js +5 -4
  78. package/_cjs/utils/abi/encodeAbiParameters.js.map +1 -1
  79. package/_cjs/utils/abi/encodePacked.js +4 -2
  80. package/_cjs/utils/abi/encodePacked.js.map +1 -1
  81. package/_cjs/utils/ccip.js +5 -1
  82. package/_cjs/utils/ccip.js.map +1 -1
  83. package/_cjs/utils/chain/getChainContractAddress.js +2 -2
  84. package/_cjs/utils/chain/getChainContractAddress.js.map +1 -1
  85. package/_cjs/utils/encoding/toBytes.js +5 -6
  86. package/_cjs/utils/encoding/toBytes.js.map +1 -1
  87. package/_cjs/utils/ens/avatar/utils.js +25 -5
  88. package/_cjs/utils/ens/avatar/utils.js.map +1 -1
  89. package/_cjs/utils/ens/localBatchGatewayRequest.js +13 -1
  90. package/_cjs/utils/ens/localBatchGatewayRequest.js.map +1 -1
  91. package/_cjs/utils/promise/createBatchScheduler.js +1 -1
  92. package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
  93. package/_cjs/utils/siwe/validateSiweMessage.js +5 -0
  94. package/_cjs/utils/siwe/validateSiweMessage.js.map +1 -1
  95. package/_cjs/zksync/actions/estimateFee.js +1 -1
  96. package/_cjs/zksync/actions/estimateFee.js.map +1 -1
  97. package/_cjs/zksync/actions/estimateGasL1ToL2.js +1 -1
  98. package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -1
  99. package/_cjs/zksync/actions/finalizeWithdrawal.js +3 -3
  100. package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
  101. package/_cjs/zksync/actions/sendEip712Transaction.js +10 -2
  102. package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
  103. package/_cjs/zksync/actions/signEip712Transaction.js +2 -2
  104. package/_cjs/zksync/actions/signEip712Transaction.js.map +1 -1
  105. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
  106. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  107. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
  108. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
  109. package/_esm/actions/ens/getEnsAddress.js +12 -1
  110. package/_esm/actions/ens/getEnsAddress.js.map +1 -1
  111. package/_esm/actions/index.js +1 -0
  112. package/_esm/actions/index.js.map +1 -1
  113. package/_esm/actions/public/call.js +13 -2
  114. package/_esm/actions/public/call.js.map +1 -1
  115. package/_esm/actions/public/getLogs.js +18 -1
  116. package/_esm/actions/public/getLogs.js.map +1 -1
  117. package/_esm/actions/public/internal/isRangeError.js +19 -0
  118. package/_esm/actions/public/internal/isRangeError.js.map +1 -0
  119. package/_esm/actions/public/internal/watchTransport.js +22 -0
  120. package/_esm/actions/public/internal/watchTransport.js.map +1 -0
  121. package/_esm/actions/public/iterateLogs.js +84 -0
  122. package/_esm/actions/public/iterateLogs.js.map +1 -0
  123. package/_esm/actions/public/simulateContract.js +5 -4
  124. package/_esm/actions/public/simulateContract.js.map +1 -1
  125. package/_esm/actions/public/verifyHash.js +77 -40
  126. package/_esm/actions/public/verifyHash.js.map +1 -1
  127. package/_esm/actions/public/waitForTransactionReceipt.js +20 -1
  128. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  129. package/_esm/actions/public/watchBlockHeaders.js +2 -10
  130. package/_esm/actions/public/watchBlockHeaders.js.map +1 -1
  131. package/_esm/actions/public/watchBlockNumber.js +3 -18
  132. package/_esm/actions/public/watchBlockNumber.js.map +1 -1
  133. package/_esm/actions/public/watchBlocks.js +3 -18
  134. package/_esm/actions/public/watchBlocks.js.map +1 -1
  135. package/_esm/actions/public/watchContractEvent.js +4 -36
  136. package/_esm/actions/public/watchContractEvent.js.map +1 -1
  137. package/_esm/actions/public/watchEvent.js +4 -36
  138. package/_esm/actions/public/watchEvent.js.map +1 -1
  139. package/_esm/actions/wallet/prepareTransactionRequest.js +17 -3
  140. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  141. package/_esm/celo/serializers.js +1 -1
  142. package/_esm/celo/serializers.js.map +1 -1
  143. package/_esm/clients/decorators/public.js +2 -0
  144. package/_esm/clients/decorators/public.js.map +1 -1
  145. package/_esm/constants/contracts.js +1 -1
  146. package/_esm/constants/contracts.js.map +1 -1
  147. package/_esm/errors/chain.js +2 -2
  148. package/_esm/errors/chain.js.map +1 -1
  149. package/_esm/errors/version.js +1 -1
  150. package/_esm/index.js +1 -1
  151. package/_esm/index.js.map +1 -1
  152. package/_esm/op-stack/actions/buildProveWithdrawal.js +5 -5
  153. package/_esm/op-stack/actions/buildProveWithdrawal.js.map +1 -1
  154. package/_esm/op-stack/actions/getL2Output.js +14 -9
  155. package/_esm/op-stack/actions/getL2Output.js.map +1 -1
  156. package/_esm/op-stack/actions/waitToProve.js +1 -0
  157. package/_esm/op-stack/actions/waitToProve.js.map +1 -1
  158. package/_esm/tempo/Account.js +33 -1
  159. package/_esm/tempo/Account.js.map +1 -1
  160. package/_esm/tempo/actions/accessKey.js +1 -1
  161. package/_esm/tempo/actions/accessKey.js.map +1 -1
  162. package/_esm/tempo/actions/accounts.js +5 -5
  163. package/_esm/tempo/actions/accounts.js.map +1 -1
  164. package/_esm/tempo/actions/earn/deployment.js +1 -1
  165. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  166. package/_esm/tempo/actions/earn.js +3 -3
  167. package/_esm/tempo/actions/earn.js.map +1 -1
  168. package/_esm/tempo/actions/propAmm.js +1 -1
  169. package/_esm/tempo/actions/propAmm.js.map +1 -1
  170. package/_esm/tempo/actions/token.js +10 -2
  171. package/_esm/tempo/actions/token.js.map +1 -1
  172. package/_esm/tempo/chainConfig.js +16 -0
  173. package/_esm/tempo/chainConfig.js.map +1 -1
  174. package/_esm/tempo/internal/preAuthorized.js +244 -0
  175. package/_esm/tempo/internal/preAuthorized.js.map +1 -0
  176. package/_esm/tempo/internal/relay/feePayer.js +26 -7
  177. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  178. package/_esm/utils/abi/decodeAbiParameters.js +37 -9
  179. package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
  180. package/_esm/utils/abi/encodeAbiParameters.js +6 -4
  181. package/_esm/utils/abi/encodeAbiParameters.js.map +1 -1
  182. package/_esm/utils/abi/encodePacked.js +5 -2
  183. package/_esm/utils/abi/encodePacked.js.map +1 -1
  184. package/_esm/utils/ccip.js +8 -3
  185. package/_esm/utils/ccip.js.map +1 -1
  186. package/_esm/utils/chain/getChainContractAddress.js +2 -2
  187. package/_esm/utils/chain/getChainContractAddress.js.map +1 -1
  188. package/_esm/utils/encoding/toBytes.js +5 -6
  189. package/_esm/utils/encoding/toBytes.js.map +1 -1
  190. package/_esm/utils/ens/avatar/utils.js +26 -5
  191. package/_esm/utils/ens/avatar/utils.js.map +1 -1
  192. package/_esm/utils/ens/localBatchGatewayRequest.js +17 -1
  193. package/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -1
  194. package/_esm/utils/promise/createBatchScheduler.js +2 -1
  195. package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
  196. package/_esm/utils/siwe/validateSiweMessage.js +6 -0
  197. package/_esm/utils/siwe/validateSiweMessage.js.map +1 -1
  198. package/_esm/zksync/actions/estimateFee.js +1 -1
  199. package/_esm/zksync/actions/estimateFee.js.map +1 -1
  200. package/_esm/zksync/actions/estimateGasL1ToL2.js +1 -1
  201. package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -1
  202. package/_esm/zksync/actions/finalizeWithdrawal.js +3 -3
  203. package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
  204. package/_esm/zksync/actions/sendEip712Transaction.js +12 -2
  205. package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
  206. package/_esm/zksync/actions/signEip712Transaction.js +2 -2
  207. package/_esm/zksync/actions/signEip712Transaction.js.map +1 -1
  208. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
  209. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -1
  210. package/_types/actions/ens/getEnsAddress.d.ts +2 -1
  211. package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
  212. package/_types/actions/index.d.ts +1 -0
  213. package/_types/actions/index.d.ts.map +1 -1
  214. package/_types/actions/public/call.d.ts.map +1 -1
  215. package/_types/actions/public/getLogs.d.ts +20 -2
  216. package/_types/actions/public/getLogs.d.ts.map +1 -1
  217. package/_types/actions/public/internal/isRangeError.d.ts +3 -0
  218. package/_types/actions/public/internal/isRangeError.d.ts.map +1 -0
  219. package/_types/actions/public/internal/watchTransport.d.ts +6 -0
  220. package/_types/actions/public/internal/watchTransport.d.ts.map +1 -0
  221. package/_types/actions/public/iterateLogs.d.ts +94 -0
  222. package/_types/actions/public/iterateLogs.d.ts.map +1 -0
  223. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  224. package/_types/actions/public/verifyHash.d.ts +2 -1
  225. package/_types/actions/public/verifyHash.d.ts.map +1 -1
  226. package/_types/actions/public/waitForTransactionReceipt.d.ts +7 -2
  227. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  228. package/_types/actions/public/watchBlockHeaders.d.ts.map +1 -1
  229. package/_types/actions/public/watchBlockNumber.d.ts.map +1 -1
  230. package/_types/actions/public/watchBlocks.d.ts.map +1 -1
  231. package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
  232. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  233. package/_types/actions/wallet/prepareTransactionRequest.d.ts +2 -1
  234. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  235. package/_types/celo/serializers.d.ts.map +1 -1
  236. package/_types/clients/decorators/public.d.ts +33 -0
  237. package/_types/clients/decorators/public.d.ts.map +1 -1
  238. package/_types/constants/contracts.d.ts +1 -1
  239. package/_types/constants/contracts.d.ts.map +1 -1
  240. package/_types/errors/version.d.ts +1 -1
  241. package/_types/index.d.ts +2 -1
  242. package/_types/index.d.ts.map +1 -1
  243. package/_types/op-stack/actions/getL2Output.d.ts +6 -0
  244. package/_types/op-stack/actions/getL2Output.d.ts.map +1 -1
  245. package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
  246. package/_types/tempo/Account.d.ts +5 -1
  247. package/_types/tempo/Account.d.ts.map +1 -1
  248. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  249. package/_types/tempo/actions/propAmm.d.ts.map +1 -1
  250. package/_types/tempo/actions/token.d.ts.map +1 -1
  251. package/_types/tempo/chainConfig.d.ts.map +1 -1
  252. package/_types/tempo/internal/preAuthorized.d.ts +41 -0
  253. package/_types/tempo/internal/preAuthorized.d.ts.map +1 -0
  254. package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
  255. package/_types/utils/abi/decodeAbiParameters.d.ts +15 -1
  256. package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  257. package/_types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
  258. package/_types/utils/ccip.d.ts +4 -3
  259. package/_types/utils/ccip.d.ts.map +1 -1
  260. package/_types/utils/encoding/toBytes.d.ts +1 -1
  261. package/_types/utils/encoding/toBytes.d.ts.map +1 -1
  262. package/_types/utils/ens/avatar/utils.d.ts +6 -2
  263. package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
  264. package/_types/utils/ens/localBatchGatewayRequest.d.ts +6 -1
  265. package/_types/utils/ens/localBatchGatewayRequest.d.ts.map +1 -1
  266. package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
  267. package/_types/utils/siwe/validateSiweMessage.d.ts.map +1 -1
  268. package/_types/zksync/actions/estimateFee.d.ts.map +1 -1
  269. package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -1
  270. package/_types/zksync/actions/finalizeWithdrawal.d.ts.map +1 -1
  271. package/_types/zksync/actions/sendEip712Transaction.d.ts +1 -1
  272. package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
  273. package/account-abstraction/actions/paymaster/getPaymasterData.ts +23 -16
  274. package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +27 -16
  275. package/actions/ens/getEnsAddress.ts +15 -1
  276. package/actions/index.ts +6 -0
  277. package/actions/public/call.ts +15 -2
  278. package/actions/public/getLogs.ts +44 -0
  279. package/actions/public/internal/isRangeError.ts +18 -0
  280. package/actions/public/internal/watchTransport.ts +29 -0
  281. package/actions/public/iterateLogs.ts +209 -0
  282. package/actions/public/simulateContract.ts +6 -4
  283. package/actions/public/verifyHash.ts +87 -60
  284. package/actions/public/waitForTransactionReceipt.ts +31 -1
  285. package/actions/public/watchBlockHeaders.ts +2 -12
  286. package/actions/public/watchBlockNumber.ts +6 -24
  287. package/actions/public/watchBlocks.ts +6 -24
  288. package/actions/public/watchContractEvent.ts +7 -42
  289. package/actions/public/watchEvent.ts +7 -42
  290. package/actions/wallet/prepareTransactionRequest.ts +23 -3
  291. package/celo/serializers.ts +5 -2
  292. package/clients/decorators/public.ts +47 -0
  293. package/constants/contracts.ts +1 -1
  294. package/errors/chain.ts +2 -2
  295. package/errors/version.ts +1 -1
  296. package/index.ts +7 -0
  297. package/op-stack/actions/buildProveWithdrawal.ts +5 -5
  298. package/op-stack/actions/getL2Output.ts +24 -11
  299. package/op-stack/actions/waitToProve.ts +1 -0
  300. package/package.json +2 -2
  301. package/tempo/Account.ts +38 -1
  302. package/tempo/actions/accessKey.ts +1 -1
  303. package/tempo/actions/accounts.ts +5 -5
  304. package/tempo/actions/earn/deployment.ts +2 -1
  305. package/tempo/actions/earn.ts +2 -2
  306. package/tempo/actions/propAmm.ts +2 -1
  307. package/tempo/actions/token.ts +10 -2
  308. package/tempo/chainConfig.ts +20 -0
  309. package/tempo/internal/preAuthorized.ts +309 -0
  310. package/tempo/internal/relay/feePayer.ts +33 -11
  311. package/utils/abi/decodeAbiParameters.ts +60 -9
  312. package/utils/abi/encodeAbiParameters.ts +6 -4
  313. package/utils/abi/encodePacked.ts +5 -1
  314. package/utils/ccip.ts +17 -3
  315. package/utils/chain/getChainContractAddress.ts +2 -2
  316. package/utils/encoding/toBytes.ts +4 -6
  317. package/utils/ens/avatar/utils.ts +38 -4
  318. package/utils/ens/localBatchGatewayRequest.ts +21 -2
  319. package/utils/promise/createBatchScheduler.ts +2 -1
  320. package/utils/siwe/validateSiweMessage.ts +7 -0
  321. package/zksync/actions/estimateFee.ts +2 -1
  322. package/zksync/actions/estimateGasL1ToL2.ts +2 -1
  323. package/zksync/actions/finalizeWithdrawal.ts +4 -3
  324. package/zksync/actions/sendEip712Transaction.ts +21 -8
  325. package/zksync/actions/signEip712Transaction.ts +3 -3
@@ -0,0 +1,209 @@
1
+ import type { AbiEvent, Address } from 'abitype'
2
+
3
+ import type { Client } from '../../clients/createClient.js'
4
+ import type { Transport } from '../../clients/transports/createTransport.js'
5
+ import { BaseError } from '../../errors/base.js'
6
+ import type { ErrorType } from '../../errors/utils.js'
7
+ import type { BlockTag } from '../../types/block.js'
8
+ import type { Chain } from '../../types/chain.js'
9
+ import type {
10
+ MaybeAbiEventName,
11
+ MaybeExtractEventArgsFromAbi,
12
+ } from '../../types/contract.js'
13
+ import { getAction } from '../../utils/getAction.js'
14
+ import { type GetBlockErrorType, getBlock } from './getBlock.js'
15
+ import {
16
+ type GetLogsErrorType,
17
+ type GetLogsParameters,
18
+ type GetLogsReturnType,
19
+ getLogs,
20
+ } from './getLogs.js'
21
+ import { isRangeError } from './internal/isRangeError.js'
22
+
23
+ export type IterateLogsParameters<
24
+ abiEvent extends AbiEvent | undefined = undefined,
25
+ abiEvents extends
26
+ | readonly AbiEvent[]
27
+ | readonly unknown[]
28
+ | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,
29
+ strict extends boolean | undefined = undefined,
30
+ //
31
+ _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,
32
+ > = {
33
+ /** Address or list of addresses from which logs originated */
34
+ address?: Address | Address[] | undefined
35
+ /**
36
+ * Most blocks to request in one `eth_getLogs` call. Must be at least `1n`.
37
+ * @default 1_000n
38
+ */
39
+ blockRange?: bigint | undefined
40
+ /** First block to include. Inclusive. */
41
+ fromBlock: bigint
42
+ /**
43
+ * Last block to include. Inclusive. A block tag is resolved to a block number once, before the first page.
44
+ * @default 'latest'
45
+ */
46
+ toBlock?: bigint | Exclude<BlockTag, 'pending'> | undefined
47
+ } & (
48
+ | {
49
+ event: abiEvent
50
+ events?: undefined
51
+ args?: MaybeExtractEventArgsFromAbi<abiEvents, _eventName> | undefined
52
+ /**
53
+ * Whether or not the logs must match the indexed/non-indexed arguments on `event`.
54
+ * @default false
55
+ */
56
+ strict?: strict | undefined
57
+ }
58
+ | {
59
+ event?: undefined
60
+ events: abiEvents
61
+ args?: undefined
62
+ /**
63
+ * Whether or not the logs must match the indexed/non-indexed arguments on `event`.
64
+ * @default false
65
+ */
66
+ strict?: strict | undefined
67
+ }
68
+ | {
69
+ event?: undefined
70
+ events?: undefined
71
+ args?: undefined
72
+ strict?: undefined
73
+ }
74
+ )
75
+
76
+ export type IterateLogsReturnType<
77
+ abiEvent extends AbiEvent | undefined = undefined,
78
+ abiEvents extends
79
+ | readonly AbiEvent[]
80
+ | readonly unknown[]
81
+ | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,
82
+ strict extends boolean | undefined = undefined,
83
+ > = AsyncGenerator<
84
+ {
85
+ /** Last block of the whole iteration: `toBlock`, or the block number its tag resolved to. */
86
+ endBlock: bigint
87
+ /** First block of the page. */
88
+ fromBlock: bigint
89
+ /** Logs from `fromBlock` to `toBlock`. */
90
+ logs: GetLogsReturnType<abiEvent, abiEvents, strict>
91
+ /** Last block of the page. A resumed iteration starts at `toBlock + 1n`. */
92
+ toBlock: bigint
93
+ },
94
+ void,
95
+ undefined
96
+ >
97
+
98
+ export type IterateLogsErrorType =
99
+ | GetBlockErrorType
100
+ | GetLogsErrorType
101
+ | ErrorType
102
+
103
+ /**
104
+ * Iterates over the event logs in a block range, one page of blocks at a time.
105
+ *
106
+ * - Docs: https://viem.sh/docs/actions/public/iterateLogs
107
+ * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
108
+ *
109
+ * Pages are contiguous and are yielded even when they contain no logs, so a consumer that
110
+ * stores each page's `toBlock` can resume from `toBlock + 1n`. A page is only requested
111
+ * once the consumer asks for it. If a request fails with an error that a smaller block
112
+ * range may avoid (such as an RPC Provider's block range or response size limit), the page
113
+ * is halved and requested again.
114
+ *
115
+ * @param client - Client to use
116
+ * @param parameters - {@link IterateLogsParameters}
117
+ * @returns An async iterator of log pages. {@link IterateLogsReturnType}
118
+ *
119
+ * @example
120
+ * import { createPublicClient, http, parseAbiItem } from 'viem'
121
+ * import { mainnet } from 'viem/chains'
122
+ * import { iterateLogs } from 'viem/actions'
123
+ *
124
+ * const client = createPublicClient({
125
+ * chain: mainnet,
126
+ * transport: http(),
127
+ * })
128
+ * for await (const page of iterateLogs(client, {
129
+ * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
130
+ * fromBlock: 16330000n,
131
+ * toBlock: 16340000n,
132
+ * })) {
133
+ * console.log(page.toBlock, page.logs)
134
+ * }
135
+ */
136
+ export async function* iterateLogs<
137
+ chain extends Chain | undefined,
138
+ const abiEvent extends AbiEvent | undefined = undefined,
139
+ const abiEvents extends
140
+ | readonly AbiEvent[]
141
+ | readonly unknown[]
142
+ | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,
143
+ strict extends boolean | undefined = undefined,
144
+ >(
145
+ client: Client<Transport, chain>,
146
+ parameters: IterateLogsParameters<abiEvent, abiEvents, strict>,
147
+ ): IterateLogsReturnType<abiEvent, abiEvents, strict> {
148
+ const {
149
+ address,
150
+ args,
151
+ blockRange = 1_000n,
152
+ event,
153
+ events,
154
+ fromBlock,
155
+ strict,
156
+ toBlock = 'latest',
157
+ } = parameters
158
+
159
+ // A range of less than one block never moves past `fromBlock`.
160
+ if (blockRange < 1n)
161
+ throw new BaseError(`\`blockRange\` must be at least 1n.`)
162
+
163
+ // Resolve a block tag once, so the iteration has a fixed end.
164
+ const endBlock =
165
+ typeof toBlock === 'bigint'
166
+ ? toBlock
167
+ : (await getAction(client, getBlock, 'getBlock')({ blockTag: toBlock }))
168
+ .number
169
+
170
+ // `size` is the most blocks to request at once. It halves when a request fails
171
+ // and doubles back up to `blockRange` after each page.
172
+ let size = blockRange
173
+ let from = fromBlock
174
+ while (from <= endBlock) {
175
+ const end = from + size - 1n
176
+ const to = end < endBlock ? end : endBlock
177
+
178
+ const logs = await getAction(
179
+ client,
180
+ getLogs,
181
+ 'getLogs',
182
+ )({
183
+ address,
184
+ args,
185
+ event,
186
+ events,
187
+ fromBlock: from,
188
+ strict,
189
+ toBlock: to,
190
+ } as GetLogsParameters).catch((error) => {
191
+ // A single block cannot be split, and a smaller range does not
192
+ // help when the RPC Provider is unreachable or rejects the client.
193
+ if (from === to || !isRangeError(error)) throw error
194
+ })
195
+ if (!logs) {
196
+ size = (to - from + 1n) / 2n
197
+ continue
198
+ }
199
+
200
+ yield {
201
+ endBlock,
202
+ fromBlock: from,
203
+ logs: logs as GetLogsReturnType<abiEvent, abiEvents, strict>,
204
+ toBlock: to,
205
+ }
206
+ from = to + 1n
207
+ size = size * 2n < blockRange ? size * 2n : blockRange
208
+ }
209
+ }
@@ -265,9 +265,10 @@ export async function simulateContract<
265
265
  ...callRequest
266
266
  } = parameters as SimulateContractParameters
267
267
 
268
- const account = callRequest.account
269
- ? parseAccount(callRequest.account)
270
- : client.account
268
+ const account =
269
+ callRequest.account === undefined
270
+ ? client.account
271
+ : callRequest.account && parseAccount(callRequest.account)
271
272
  const calldata = encodeFunctionData({ abi, args, functionName })
272
273
 
273
274
  try {
@@ -280,7 +281,8 @@ export async function simulateContract<
280
281
  data: `${calldata}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
281
282
  to: address,
282
283
  ...callRequest,
283
- account,
284
+ // `call` omits the sender for `null` at runtime, but its parameter type excludes `null`.
285
+ account: account as Account | undefined,
284
286
  })
285
287
  const result = decodeFunctionResult({
286
288
  abi,
@@ -9,20 +9,19 @@ import {
9
9
  erc6492SignatureValidatorAbi,
10
10
  multicall3Abi,
11
11
  } from '../../constants/abis.js'
12
+ import { zeroAddress } from '../../constants/address.js'
12
13
  import {
13
14
  erc6492SignatureValidatorByteCode,
14
15
  multicall3Bytecode,
15
16
  } from '../../constants/contracts.js'
16
- import {
17
- CallExecutionError,
18
- ContractFunctionExecutionError,
19
- } from '../../errors/contract.js'
17
+ import { CallExecutionError } from '../../errors/contract.js'
20
18
  import type { InvalidHexBooleanError } from '../../errors/encoding.js'
21
19
  import type { ErrorType } from '../../errors/utils.js'
22
20
  import type { BlockTag } from '../../types/block.js'
23
21
  import type { Chain } from '../../types/chain.js'
24
22
  import type { ByteArray, Hash, Hex, Signature } from '../../types/misc.js'
25
23
  import type { OneOf } from '../../types/utils.js'
24
+ import { decodeFunctionResult } from '../../utils/abi/decodeFunctionResult.js'
26
25
  import {
27
26
  type EncodeDeployDataErrorType,
28
27
  encodeDeployData,
@@ -49,7 +48,6 @@ import {
49
48
  type NumberToHexErrorType,
50
49
  numberToHex,
51
50
  } from '../../utils/encoding/toHex.js'
52
- import { getAction } from '../../utils/getAction.js'
53
51
  import {
54
52
  type RecoverAddressErrorType,
55
53
  recoverAddress,
@@ -60,7 +58,7 @@ import {
60
58
  } from '../../utils/signature/serializeSignature.js'
61
59
  import { type CallErrorType, type CallParameters, call } from './call.js'
62
60
  import { type GetCodeErrorType, getCode } from './getCode.js'
63
- import { type ReadContractErrorType, readContract } from './readContract.js'
61
+ import type { ReadContractErrorType } from './readContract.js'
64
62
 
65
63
  export type BlockParameters = OneOf<
66
64
  | {
@@ -70,6 +68,7 @@ export type BlockParameters = OneOf<
70
68
  | {
71
69
  /**
72
70
  * The block tag to check if the contract was already deployed.
71
+ * Pre-delegated ERC-8010 signatures are verified against `'pending'` when no block is selected.
73
72
  * @default 'latest'
74
73
  */
75
74
  blockTag?: BlockTag | undefined
@@ -137,12 +136,26 @@ export async function verifyHash<chain extends Chain | undefined>(
137
136
  hash,
138
137
  erc6492VerifierAddress:
139
138
  verifierAddress = parameters.universalSignatureVerifierAddress ??
140
- chain?.contracts?.erc6492Verifier?.address,
139
+ (() => {
140
+ const { blockNumber } = parameters
141
+ const verifier = chain?.contracts?.erc6492Verifier
142
+ // Use the deployless validator for blocks before the verifier was created.
143
+ if (
144
+ blockNumber !== undefined &&
145
+ verifier?.blockCreated &&
146
+ verifier.blockCreated > blockNumber
147
+ )
148
+ return undefined
149
+ return verifier?.address
150
+ })(),
141
151
  multicallAddress = parameters.multicallAddress ??
142
152
  chain?.contracts?.multicall3?.address,
143
153
  mode = 'auto',
144
154
  } = parameters
145
155
 
156
+ // No signature is valid for the zero address.
157
+ if (address === zeroAddress) return false
158
+
146
159
  if (chain?.verifyHash) return await chain.verifyHash(client, parameters)
147
160
 
148
161
  const signature = (() => {
@@ -251,48 +264,51 @@ export async function verifyErc8010(
251
264
  if (!valid) throw new VerificationError()
252
265
 
253
266
  // Deployless verification.
254
- const results = await getAction(
255
- client,
256
- readContract,
257
- 'readContract',
258
- )({
267
+ const { data: aggregate3Data } = await call({ ...client, ccipRead: false }, {
259
268
  ...(multicallAddress
260
- ? { address: multicallAddress }
269
+ ? { to: multicallAddress }
261
270
  : { code: multicall3Bytecode }),
262
271
  authorizationList: [authorization],
263
- abi: multicall3Abi,
264
272
  blockHash,
265
273
  blockNumber,
266
- blockTag: 'pending',
267
- functionName: 'aggregate3',
268
- requireCanonical,
269
- args: [
270
- [
271
- ...(initData
272
- ? ([
273
- {
274
- allowFailure: true,
275
- target: to ?? address,
276
- callData: initData,
277
- },
278
- ] as const)
279
- : []),
280
- {
281
- allowFailure: true,
282
- target: address,
283
- callData: encodeFunctionData({
284
- abi: erc1271Abi,
285
- functionName: 'isValidSignature',
286
- args: [hash, signature],
287
- }),
288
- },
274
+ blockTag: blockTag ?? 'pending',
275
+ data: encodeFunctionData({
276
+ abi: multicall3Abi,
277
+ functionName: 'aggregate3',
278
+ args: [
279
+ [
280
+ ...(initData
281
+ ? ([
282
+ {
283
+ allowFailure: true,
284
+ target: to ?? address,
285
+ callData: initData,
286
+ },
287
+ ] as const)
288
+ : []),
289
+ {
290
+ allowFailure: true,
291
+ target: address,
292
+ callData: encodeFunctionData({
293
+ abi: erc1271Abi,
294
+ functionName: 'isValidSignature',
295
+ args: [hash, signature],
296
+ }),
297
+ },
298
+ ],
289
299
  ],
290
- ],
300
+ }),
301
+ requireCanonical,
302
+ } as CallParameters)
303
+ const results = decodeFunctionResult({
304
+ abi: multicall3Abi,
305
+ functionName: 'aggregate3',
306
+ data: aggregate3Data ?? '0x',
291
307
  })
292
308
 
293
- const data = results[results.length - 1]?.returnData
309
+ const result = results[results.length - 1]
294
310
 
295
- if (data?.startsWith('0x1626ba7e')) return true
311
+ if (result?.success && result.returnData.startsWith('0x1626ba7e')) return true
296
312
  throw new VerificationError()
297
313
  }
298
314
 
@@ -344,6 +360,7 @@ async function verifyErc6492(
344
360
 
345
361
  const args = verifierAddress
346
362
  ? ({
363
+ batch: false,
347
364
  to: verifierAddress,
348
365
  data: encodeFunctionData({
349
366
  abi: erc6492SignatureValidatorAbi,
@@ -361,14 +378,14 @@ async function verifyErc6492(
361
378
  ...rest,
362
379
  } as unknown as CallParameters)
363
380
 
364
- const { data } = await getAction(
365
- client,
366
- call,
367
- 'call',
368
- )(args).catch((error) => {
369
- if (error instanceof CallExecutionError) throw new VerificationError()
370
- throw error
371
- })
381
+ // Verification calls run without CCIP-Read. They use `call` directly
382
+ // because a client's own `call` action keeps its CCIP-Read setting.
383
+ const { data } = await call({ ...client, ccipRead: false }, args).catch(
384
+ (error) => {
385
+ if (error instanceof CallExecutionError) throw new VerificationError()
386
+ throw error
387
+ },
388
+ )
372
389
 
373
390
  if (hexToBool(data ?? '0x0')) return true
374
391
  throw new VerificationError()
@@ -402,25 +419,35 @@ export async function verifyErc1271(
402
419
  signature,
403
420
  } = parameters
404
421
 
405
- const result = await getAction(
406
- client,
407
- readContract,
408
- 'readContract',
409
- )({
410
- address,
411
- abi: erc1271Abi,
412
- args: [hash, signature],
422
+ const { data } = await call({ ...client, ccipRead: false }, {
423
+ batch: false,
413
424
  blockHash,
414
425
  blockNumber,
415
426
  blockTag,
416
- functionName: 'isValidSignature',
427
+ data: encodeFunctionData({
428
+ abi: erc1271Abi,
429
+ functionName: 'isValidSignature',
430
+ args: [hash, signature],
431
+ }),
417
432
  requireCanonical,
418
- }).catch((error) => {
419
- if (error instanceof ContractFunctionExecutionError)
420
- throw new VerificationError()
433
+ to: address,
434
+ } as CallParameters).catch((error) => {
435
+ if (error instanceof CallExecutionError) throw new VerificationError()
421
436
  throw error
422
437
  })
423
438
 
439
+ const result = (() => {
440
+ try {
441
+ return decodeFunctionResult({
442
+ abi: erc1271Abi,
443
+ functionName: 'isValidSignature',
444
+ data: data ?? '0x',
445
+ })
446
+ } catch {
447
+ throw new VerificationError()
448
+ }
449
+ })()
450
+
424
451
  if (result.startsWith('0x1626ba7e')) return true
425
452
  throw new VerificationError()
426
453
  }
@@ -13,7 +13,11 @@ import {
13
13
  WaitForTransactionReceiptTimeoutError,
14
14
  type WaitForTransactionReceiptTimeoutErrorType,
15
15
  } from '../../errors/transaction.js'
16
- import type { ErrorType } from '../../errors/utils.js'
16
+ import {
17
+ type AbortErrorType,
18
+ type ErrorType,
19
+ getAbortError,
20
+ } from '../../errors/utils.js'
17
21
  import type { Chain } from '../../types/chain.js'
18
22
  import type { Hash, Hex } from '../../types/misc.js'
19
23
  import type { Transaction } from '../../types/transaction.js'
@@ -26,6 +30,7 @@ import {
26
30
  withRetry,
27
31
  } from '../../utils/promise/withRetry.js'
28
32
  import { stringify } from '../../utils/stringify.js'
33
+ import { uid } from '../../utils/uid.js'
29
34
 
30
35
  import { type GetBlockErrorType, getBlock } from './getBlock.js'
31
36
  import {
@@ -117,6 +122,11 @@ export type WaitForTransactionReceiptParameters<
117
122
  * @default `({ count }) => ~~(1 << count) * 200` (exponential backoff)
118
123
  */
119
124
  retryDelay?: WithRetryParameters['delay'] | undefined
125
+ /**
126
+ * Signal that stops the wait. Aborting rejects with the signal's reason and
127
+ * stops polling and retries. It does not cancel the transaction.
128
+ */
129
+ signal?: AbortSignal | undefined
120
130
  /**
121
131
  * Optional timeout (in milliseconds) to wait before stopping polling.
122
132
  * @default 180_000
@@ -125,6 +135,7 @@ export type WaitForTransactionReceiptParameters<
125
135
  }
126
136
 
127
137
  export type WaitForTransactionReceiptErrorType =
138
+ | AbortErrorType
128
139
  | ObserveErrorType
129
140
  | GetBlockErrorType
130
141
  | GetTransactionErrorType
@@ -188,9 +199,12 @@ export async function waitForTransactionReceipt<
188
199
  onReplaced,
189
200
  retryCount = 6,
190
201
  retryDelay = ({ count }) => ~~(1 << count) * 200, // exponential backoff
202
+ signal,
191
203
  timeout = 180_000,
192
204
  } = parameters
193
205
 
206
+ if (signal?.aborted) throw getAbortError(signal)
207
+
194
208
  // On chains with their own replacement keys, a sender and nonce do not
195
209
  // identify a nonce slot.
196
210
  const replacement = client.chain?.transactionReplacement?.getKey
@@ -221,6 +235,9 @@ export async function waitForTransactionReceipt<
221
235
  pollingInterval,
222
236
  replacement,
223
237
  retryCount,
238
+ // A cancellable wait polls on its own, so aborting it cannot stop
239
+ // polling for another caller.
240
+ signal: signal ? uid() : undefined,
224
241
  timeout,
225
242
  },
226
243
  ])
@@ -249,6 +266,14 @@ export async function waitForTransactionReceipt<
249
266
  }, timeout)
250
267
  : undefined
251
268
 
269
+ const onAbort = () => {
270
+ clearTimeout(timer)
271
+ _unwatch?.()
272
+ _unobserve?.()
273
+ reject(getAbortError(signal))
274
+ }
275
+ signal?.addEventListener('abort', onAbort, { once: true })
276
+
252
277
  _unobserve = observe(
253
278
  observerId,
254
279
  { onReplaced, resolve, reject },
@@ -259,6 +284,8 @@ export async function waitForTransactionReceipt<
259
284
  'getTransactionReceipt',
260
285
  )({ hash }).catch(() => undefined)
261
286
 
287
+ if (signal?.aborted) return
288
+
262
289
  if (receipt && confirmations <= 1) {
263
290
  clearTimeout(timer)
264
291
  emit.resolve(receipt)
@@ -350,6 +377,7 @@ export async function waitForTransactionReceipt<
350
377
  {
351
378
  delay: retryDelay,
352
379
  retryCount,
380
+ signal,
353
381
  // A dropped transaction does not reappear, so a known
354
382
  // sender and nonce are looked up without the retries.
355
383
  shouldRetry: ({ error }) =>
@@ -498,6 +526,7 @@ export async function waitForTransactionReceipt<
498
526
  {
499
527
  delay: retryDelay,
500
528
  retryCount,
529
+ signal,
501
530
  shouldRetry: ({ error }) =>
502
531
  error instanceof BlockNotFoundError,
503
532
  },
@@ -589,6 +618,7 @@ export async function waitForTransactionReceipt<
589
618
  // never start polling again. The timer is cleared here as well, since a
590
619
  // caller that resolves through another caller's poll never reaches `done`.
591
620
  return promise.finally(() => {
621
+ signal?.removeEventListener('abort', onAbort)
592
622
  clearTimeout(timer)
593
623
  _unobserve?.()
594
624
  })
@@ -8,6 +8,7 @@ import { observe } from '../../utils/observe.js'
8
8
  import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
9
9
 
10
10
  import type { GetBlockReturnType } from './getBlock.js'
11
+ import { getSubscriptionTransport } from './internal/watchTransport.js'
11
12
 
12
13
  const blockFields = [
13
14
  'size',
@@ -88,18 +89,7 @@ export function watchBlockHeaders<
88
89
  let unsubscribe = () => (active = false)
89
90
  ;(async () => {
90
91
  try {
91
- const transport = (() => {
92
- if (client.transport.type === 'fallback') {
93
- const transport = client.transport.transports.find(
94
- (transport: ReturnType<Transport>) =>
95
- transport.config.type === 'webSocket' ||
96
- transport.config.type === 'ipc',
97
- )
98
- if (!transport) return client.transport
99
- return transport.value
100
- }
101
- return client.transport
102
- })()
92
+ const transport = getSubscriptionTransport(client)
103
93
 
104
94
  const { unsubscribe: unsubscribe_ } = await transport.subscribe({
105
95
  params: ['newHeads'],
@@ -13,6 +13,10 @@ import {
13
13
  type GetBlockNumberReturnType,
14
14
  getBlockNumber,
15
15
  } from './getBlockNumber.js'
16
+ import {
17
+ getSubscriptionTransport,
18
+ shouldPoll,
19
+ } from './internal/watchTransport.js'
16
20
 
17
21
  export type OnBlockNumberParameter = GetBlockNumberReturnType
18
22
  export type OnBlockNumberFn = (
@@ -97,18 +101,7 @@ export function watchBlockNumber<
97
101
  ): WatchBlockNumberReturnType {
98
102
  const enablePolling = (() => {
99
103
  if (typeof poll_ !== 'undefined') return poll_
100
- if (
101
- client.transport.type === 'webSocket' ||
102
- client.transport.type === 'ipc'
103
- )
104
- return false
105
- if (
106
- client.transport.type === 'fallback' &&
107
- (client.transport.transports[0].config.type === 'webSocket' ||
108
- client.transport.transports[0].config.type === 'ipc')
109
- )
110
- return false
111
- return true
104
+ return shouldPoll(client)
112
105
  })()
113
106
  // Polling less than twice per block skips blocks, so emit the missed
114
107
  // ones unless told otherwise.
@@ -186,18 +179,7 @@ export function watchBlockNumber<
186
179
  let unsubscribe = () => (active = false)
187
180
  ;(async () => {
188
181
  try {
189
- const transport = (() => {
190
- if (client.transport.type === 'fallback') {
191
- const transport = client.transport.transports.find(
192
- (transport: ReturnType<Transport>) =>
193
- transport.config.type === 'webSocket' ||
194
- transport.config.type === 'ipc',
195
- )
196
- if (!transport) return client.transport
197
- return transport.value
198
- }
199
- return client.transport
200
- })()
182
+ const transport = getSubscriptionTransport(client)
201
183
 
202
184
  const { unsubscribe: unsubscribe_ } = await transport.subscribe({
203
185
  params: ['newHeads'],