viem 2.57.17 → 2.57.19

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 (424) hide show
  1. package/CHANGELOG.md +100 -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/ens/getEnsText.js.map +1 -1
  9. package/_cjs/actions/index.js +5 -3
  10. package/_cjs/actions/index.js.map +1 -1
  11. package/_cjs/actions/public/call.js +13 -2
  12. package/_cjs/actions/public/call.js.map +1 -1
  13. package/_cjs/actions/public/getDelegation.js +2 -1
  14. package/_cjs/actions/public/getDelegation.js.map +1 -1
  15. package/_cjs/actions/public/getFeeHistory.js.map +1 -1
  16. package/_cjs/actions/public/getLogs.js +18 -1
  17. package/_cjs/actions/public/getLogs.js.map +1 -1
  18. package/_cjs/actions/public/internal/isRangeError.js +18 -0
  19. package/_cjs/actions/public/internal/isRangeError.js.map +1 -0
  20. package/_cjs/actions/public/internal/watchTransport.js +24 -0
  21. package/_cjs/actions/public/internal/watchTransport.js.map +1 -0
  22. package/_cjs/actions/public/iterateLogs.js +48 -0
  23. package/_cjs/actions/public/iterateLogs.js.map +1 -0
  24. package/_cjs/actions/public/simulateContract.js +4 -4
  25. package/_cjs/actions/public/simulateContract.js.map +1 -1
  26. package/_cjs/actions/public/verifyHash.js +72 -39
  27. package/_cjs/actions/public/verifyHash.js.map +1 -1
  28. package/_cjs/actions/public/waitForTransactionReceipt.js +18 -1
  29. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  30. package/_cjs/actions/public/watchBlockHeaders.js +2 -10
  31. package/_cjs/actions/public/watchBlockHeaders.js.map +1 -1
  32. package/_cjs/actions/public/watchBlockNumber.js +3 -18
  33. package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
  34. package/_cjs/actions/public/watchBlocks.js +3 -18
  35. package/_cjs/actions/public/watchBlocks.js.map +1 -1
  36. package/_cjs/actions/public/watchContractEvent.js +5 -33
  37. package/_cjs/actions/public/watchContractEvent.js.map +1 -1
  38. package/_cjs/actions/public/watchEvent.js +5 -33
  39. package/_cjs/actions/public/watchEvent.js.map +1 -1
  40. package/_cjs/actions/token/internal.js +2 -10
  41. package/_cjs/actions/token/internal.js.map +1 -1
  42. package/_cjs/actions/wallet/deployContract.js +2 -1
  43. package/_cjs/actions/wallet/deployContract.js.map +1 -1
  44. package/_cjs/actions/wallet/prepareTransactionRequest.js +16 -3
  45. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  46. package/_cjs/actions/wallet/sendCalls.js +2 -1
  47. package/_cjs/actions/wallet/sendCalls.js.map +1 -1
  48. package/_cjs/actions/wallet/signAuthorization.js +2 -1
  49. package/_cjs/actions/wallet/signAuthorization.js.map +1 -1
  50. package/_cjs/celo/serializers.js +1 -1
  51. package/_cjs/celo/serializers.js.map +1 -1
  52. package/_cjs/chains/definitions/kinetiqElysium.js +30 -0
  53. package/_cjs/chains/definitions/kinetiqElysium.js.map +1 -0
  54. package/_cjs/chains/definitions/kinetiqElysiumTestnet.js +31 -0
  55. package/_cjs/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
  56. package/_cjs/chains/index.js +14 -9
  57. package/_cjs/chains/index.js.map +1 -1
  58. package/_cjs/clients/decorators/public.js +2 -0
  59. package/_cjs/clients/decorators/public.js.map +1 -1
  60. package/_cjs/constants/contracts.js +1 -1
  61. package/_cjs/constants/contracts.js.map +1 -1
  62. package/_cjs/errors/chain.js +2 -2
  63. package/_cjs/errors/chain.js.map +1 -1
  64. package/_cjs/errors/typedData.js +2 -0
  65. package/_cjs/errors/typedData.js.map +1 -1
  66. package/_cjs/errors/version.js +1 -1
  67. package/_cjs/index.js +5 -4
  68. package/_cjs/index.js.map +1 -1
  69. package/_cjs/op-stack/actions/buildProveWithdrawal.js +5 -5
  70. package/_cjs/op-stack/actions/buildProveWithdrawal.js.map +1 -1
  71. package/_cjs/op-stack/actions/getL2Output.js +13 -9
  72. package/_cjs/op-stack/actions/getL2Output.js.map +1 -1
  73. package/_cjs/op-stack/actions/waitToProve.js +1 -0
  74. package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
  75. package/_cjs/tempo/Account.js +30 -0
  76. package/_cjs/tempo/Account.js.map +1 -1
  77. package/_cjs/tempo/actions/accessKey.js +1 -1
  78. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  79. package/_cjs/tempo/actions/accounts.js +19 -9
  80. package/_cjs/tempo/actions/accounts.js.map +1 -1
  81. package/_cjs/tempo/actions/earn/deployment.js +1 -1
  82. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  83. package/_cjs/tempo/actions/earn.js +3 -3
  84. package/_cjs/tempo/actions/earn.js.map +1 -1
  85. package/_cjs/tempo/actions/propAmm.js +1 -1
  86. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  87. package/_cjs/tempo/actions/token.js +10 -2
  88. package/_cjs/tempo/actions/token.js.map +1 -1
  89. package/_cjs/tempo/chainConfig.js +37 -1
  90. package/_cjs/tempo/chainConfig.js.map +1 -1
  91. package/_cjs/tempo/internal/preAuthorized.js +214 -0
  92. package/_cjs/tempo/internal/preAuthorized.js.map +1 -0
  93. package/_cjs/tempo/internal/relay/feePayer.js +25 -7
  94. package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
  95. package/_cjs/tempo/internal/relay.js +2 -2
  96. package/_cjs/tempo/internal/relay.js.map +1 -1
  97. package/_cjs/tempo/internal/utils.js +2 -10
  98. package/_cjs/tempo/internal/utils.js.map +1 -1
  99. package/_cjs/tokens/defineToken.js +1 -1
  100. package/_cjs/tokens/defineToken.js.map +1 -1
  101. package/_cjs/tokens/definitions/ousd.js +1 -0
  102. package/_cjs/tokens/definitions/ousd.js.map +1 -1
  103. package/_cjs/utils/abi/decodeAbiParameters.js +33 -9
  104. package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  105. package/_cjs/utils/abi/encodeAbiParameters.js +5 -4
  106. package/_cjs/utils/abi/encodeAbiParameters.js.map +1 -1
  107. package/_cjs/utils/abi/encodePacked.js +4 -2
  108. package/_cjs/utils/abi/encodePacked.js.map +1 -1
  109. package/_cjs/utils/ccip.js +5 -1
  110. package/_cjs/utils/ccip.js.map +1 -1
  111. package/_cjs/utils/chain/getChainContractAddress.js +2 -2
  112. package/_cjs/utils/chain/getChainContractAddress.js.map +1 -1
  113. package/_cjs/utils/encoding/toBytes.js +5 -6
  114. package/_cjs/utils/encoding/toBytes.js.map +1 -1
  115. package/_cjs/utils/ens/avatar/utils.js +25 -5
  116. package/_cjs/utils/ens/avatar/utils.js.map +1 -1
  117. package/_cjs/utils/ens/localBatchGatewayRequest.js +13 -1
  118. package/_cjs/utils/ens/localBatchGatewayRequest.js.map +1 -1
  119. package/_cjs/utils/promise/createBatchScheduler.js +1 -1
  120. package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
  121. package/_cjs/utils/siwe/validateSiweMessage.js +5 -0
  122. package/_cjs/utils/siwe/validateSiweMessage.js.map +1 -1
  123. package/_cjs/zksync/actions/estimateFee.js +1 -1
  124. package/_cjs/zksync/actions/estimateFee.js.map +1 -1
  125. package/_cjs/zksync/actions/estimateGasL1ToL2.js +1 -1
  126. package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -1
  127. package/_cjs/zksync/actions/finalizeWithdrawal.js +3 -3
  128. package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
  129. package/_cjs/zksync/actions/sendEip712Transaction.js +10 -2
  130. package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
  131. package/_cjs/zksync/actions/signEip712Transaction.js +2 -2
  132. package/_cjs/zksync/actions/signEip712Transaction.js.map +1 -1
  133. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
  134. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  135. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
  136. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
  137. package/_esm/actions/ens/getEnsAddress.js +12 -1
  138. package/_esm/actions/ens/getEnsAddress.js.map +1 -1
  139. package/_esm/actions/ens/getEnsText.js.map +1 -1
  140. package/_esm/actions/index.js +1 -0
  141. package/_esm/actions/index.js.map +1 -1
  142. package/_esm/actions/public/call.js +13 -2
  143. package/_esm/actions/public/call.js.map +1 -1
  144. package/_esm/actions/public/getDelegation.js +2 -1
  145. package/_esm/actions/public/getDelegation.js.map +1 -1
  146. package/_esm/actions/public/getFeeHistory.js.map +1 -1
  147. package/_esm/actions/public/getLogs.js +18 -1
  148. package/_esm/actions/public/getLogs.js.map +1 -1
  149. package/_esm/actions/public/internal/isRangeError.js +19 -0
  150. package/_esm/actions/public/internal/isRangeError.js.map +1 -0
  151. package/_esm/actions/public/internal/watchTransport.js +22 -0
  152. package/_esm/actions/public/internal/watchTransport.js.map +1 -0
  153. package/_esm/actions/public/iterateLogs.js +84 -0
  154. package/_esm/actions/public/iterateLogs.js.map +1 -0
  155. package/_esm/actions/public/simulateContract.js +5 -4
  156. package/_esm/actions/public/simulateContract.js.map +1 -1
  157. package/_esm/actions/public/verifyHash.js +77 -40
  158. package/_esm/actions/public/verifyHash.js.map +1 -1
  159. package/_esm/actions/public/waitForTransactionReceipt.js +20 -1
  160. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  161. package/_esm/actions/public/watchBlockHeaders.js +2 -10
  162. package/_esm/actions/public/watchBlockHeaders.js.map +1 -1
  163. package/_esm/actions/public/watchBlockNumber.js +3 -18
  164. package/_esm/actions/public/watchBlockNumber.js.map +1 -1
  165. package/_esm/actions/public/watchBlocks.js +3 -18
  166. package/_esm/actions/public/watchBlocks.js.map +1 -1
  167. package/_esm/actions/public/watchContractEvent.js +4 -36
  168. package/_esm/actions/public/watchContractEvent.js.map +1 -1
  169. package/_esm/actions/public/watchEvent.js +4 -36
  170. package/_esm/actions/public/watchEvent.js.map +1 -1
  171. package/_esm/actions/token/internal.js +2 -10
  172. package/_esm/actions/token/internal.js.map +1 -1
  173. package/_esm/actions/wallet/deployContract.js +2 -1
  174. package/_esm/actions/wallet/deployContract.js.map +1 -1
  175. package/_esm/actions/wallet/prepareTransactionRequest.js +17 -3
  176. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  177. package/_esm/actions/wallet/sendCalls.js +2 -1
  178. package/_esm/actions/wallet/sendCalls.js.map +1 -1
  179. package/_esm/actions/wallet/signAuthorization.js +2 -1
  180. package/_esm/actions/wallet/signAuthorization.js.map +1 -1
  181. package/_esm/celo/serializers.js +1 -1
  182. package/_esm/celo/serializers.js.map +1 -1
  183. package/_esm/chains/definitions/kinetiqElysium.js +27 -0
  184. package/_esm/chains/definitions/kinetiqElysium.js.map +1 -0
  185. package/_esm/chains/definitions/kinetiqElysiumTestnet.js +28 -0
  186. package/_esm/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
  187. package/_esm/chains/index.js +2 -0
  188. package/_esm/chains/index.js.map +1 -1
  189. package/_esm/clients/decorators/public.js +2 -0
  190. package/_esm/clients/decorators/public.js.map +1 -1
  191. package/_esm/constants/contracts.js +1 -1
  192. package/_esm/constants/contracts.js.map +1 -1
  193. package/_esm/errors/chain.js +2 -2
  194. package/_esm/errors/chain.js.map +1 -1
  195. package/_esm/errors/typedData.js +2 -0
  196. package/_esm/errors/typedData.js.map +1 -1
  197. package/_esm/errors/version.js +1 -1
  198. package/_esm/index.js +1 -1
  199. package/_esm/index.js.map +1 -1
  200. package/_esm/op-stack/actions/buildProveWithdrawal.js +5 -5
  201. package/_esm/op-stack/actions/buildProveWithdrawal.js.map +1 -1
  202. package/_esm/op-stack/actions/getL2Output.js +14 -9
  203. package/_esm/op-stack/actions/getL2Output.js.map +1 -1
  204. package/_esm/op-stack/actions/waitToProve.js +1 -0
  205. package/_esm/op-stack/actions/waitToProve.js.map +1 -1
  206. package/_esm/tempo/Account.js +33 -1
  207. package/_esm/tempo/Account.js.map +1 -1
  208. package/_esm/tempo/actions/accessKey.js +1 -1
  209. package/_esm/tempo/actions/accessKey.js.map +1 -1
  210. package/_esm/tempo/actions/accounts.js +24 -10
  211. package/_esm/tempo/actions/accounts.js.map +1 -1
  212. package/_esm/tempo/actions/earn/deployment.js +1 -1
  213. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  214. package/_esm/tempo/actions/earn.js +3 -3
  215. package/_esm/tempo/actions/earn.js.map +1 -1
  216. package/_esm/tempo/actions/propAmm.js +1 -1
  217. package/_esm/tempo/actions/propAmm.js.map +1 -1
  218. package/_esm/tempo/actions/token.js +10 -2
  219. package/_esm/tempo/actions/token.js.map +1 -1
  220. package/_esm/tempo/chainConfig.js +41 -1
  221. package/_esm/tempo/chainConfig.js.map +1 -1
  222. package/_esm/tempo/internal/preAuthorized.js +244 -0
  223. package/_esm/tempo/internal/preAuthorized.js.map +1 -0
  224. package/_esm/tempo/internal/relay/feePayer.js +26 -7
  225. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  226. package/_esm/tempo/internal/relay.js +8 -3
  227. package/_esm/tempo/internal/relay.js.map +1 -1
  228. package/_esm/tempo/internal/utils.js +2 -10
  229. package/_esm/tempo/internal/utils.js.map +1 -1
  230. package/_esm/tokens/defineToken.js +2 -1
  231. package/_esm/tokens/defineToken.js.map +1 -1
  232. package/_esm/tokens/definitions/ousd.js +2 -1
  233. package/_esm/tokens/definitions/ousd.js.map +1 -1
  234. package/_esm/utils/abi/decodeAbiParameters.js +37 -9
  235. package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
  236. package/_esm/utils/abi/encodeAbiParameters.js +6 -4
  237. package/_esm/utils/abi/encodeAbiParameters.js.map +1 -1
  238. package/_esm/utils/abi/encodePacked.js +5 -2
  239. package/_esm/utils/abi/encodePacked.js.map +1 -1
  240. package/_esm/utils/ccip.js +8 -3
  241. package/_esm/utils/ccip.js.map +1 -1
  242. package/_esm/utils/chain/getChainContractAddress.js +2 -2
  243. package/_esm/utils/chain/getChainContractAddress.js.map +1 -1
  244. package/_esm/utils/encoding/toBytes.js +5 -6
  245. package/_esm/utils/encoding/toBytes.js.map +1 -1
  246. package/_esm/utils/ens/avatar/utils.js +26 -5
  247. package/_esm/utils/ens/avatar/utils.js.map +1 -1
  248. package/_esm/utils/ens/localBatchGatewayRequest.js +17 -1
  249. package/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -1
  250. package/_esm/utils/promise/createBatchScheduler.js +2 -1
  251. package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
  252. package/_esm/utils/siwe/validateSiweMessage.js +6 -0
  253. package/_esm/utils/siwe/validateSiweMessage.js.map +1 -1
  254. package/_esm/zksync/actions/estimateFee.js +1 -1
  255. package/_esm/zksync/actions/estimateFee.js.map +1 -1
  256. package/_esm/zksync/actions/estimateGasL1ToL2.js +1 -1
  257. package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -1
  258. package/_esm/zksync/actions/finalizeWithdrawal.js +3 -3
  259. package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
  260. package/_esm/zksync/actions/sendEip712Transaction.js +12 -2
  261. package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
  262. package/_esm/zksync/actions/signEip712Transaction.js +2 -2
  263. package/_esm/zksync/actions/signEip712Transaction.js.map +1 -1
  264. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
  265. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -1
  266. package/_types/actions/ens/getEnsAddress.d.ts +2 -1
  267. package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
  268. package/_types/actions/ens/getEnsText.d.ts +2 -1
  269. package/_types/actions/ens/getEnsText.d.ts.map +1 -1
  270. package/_types/actions/index.d.ts +1 -0
  271. package/_types/actions/index.d.ts.map +1 -1
  272. package/_types/actions/public/call.d.ts.map +1 -1
  273. package/_types/actions/public/getDelegation.d.ts.map +1 -1
  274. package/_types/actions/public/getFeeHistory.d.ts +2 -1
  275. package/_types/actions/public/getFeeHistory.d.ts.map +1 -1
  276. package/_types/actions/public/getLogs.d.ts +20 -2
  277. package/_types/actions/public/getLogs.d.ts.map +1 -1
  278. package/_types/actions/public/internal/isRangeError.d.ts +3 -0
  279. package/_types/actions/public/internal/isRangeError.d.ts.map +1 -0
  280. package/_types/actions/public/internal/watchTransport.d.ts +6 -0
  281. package/_types/actions/public/internal/watchTransport.d.ts.map +1 -0
  282. package/_types/actions/public/iterateLogs.d.ts +94 -0
  283. package/_types/actions/public/iterateLogs.d.ts.map +1 -0
  284. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  285. package/_types/actions/public/verifyHash.d.ts +2 -1
  286. package/_types/actions/public/verifyHash.d.ts.map +1 -1
  287. package/_types/actions/public/waitForTransactionReceipt.d.ts +7 -2
  288. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  289. package/_types/actions/public/watchBlockHeaders.d.ts.map +1 -1
  290. package/_types/actions/public/watchBlockNumber.d.ts.map +1 -1
  291. package/_types/actions/public/watchBlocks.d.ts.map +1 -1
  292. package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
  293. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  294. package/_types/actions/token/internal.d.ts.map +1 -1
  295. package/_types/actions/wallet/deployContract.d.ts.map +1 -1
  296. package/_types/actions/wallet/prepareTransactionRequest.d.ts +3 -1
  297. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  298. package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
  299. package/_types/actions/wallet/signAuthorization.d.ts.map +1 -1
  300. package/_types/celo/serializers.d.ts.map +1 -1
  301. package/_types/chains/definitions/kinetiqElysium.d.ts +52 -0
  302. package/_types/chains/definitions/kinetiqElysium.d.ts.map +1 -0
  303. package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts +52 -0
  304. package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts.map +1 -0
  305. package/_types/chains/index.d.ts +2 -0
  306. package/_types/chains/index.d.ts.map +1 -1
  307. package/_types/clients/decorators/public.d.ts +33 -0
  308. package/_types/clients/decorators/public.d.ts.map +1 -1
  309. package/_types/constants/contracts.d.ts +1 -1
  310. package/_types/constants/contracts.d.ts.map +1 -1
  311. package/_types/errors/typedData.d.ts.map +1 -1
  312. package/_types/errors/version.d.ts +1 -1
  313. package/_types/index.d.ts +2 -1
  314. package/_types/index.d.ts.map +1 -1
  315. package/_types/op-stack/actions/getL2Output.d.ts +6 -0
  316. package/_types/op-stack/actions/getL2Output.d.ts.map +1 -1
  317. package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
  318. package/_types/tempo/Account.d.ts +5 -1
  319. package/_types/tempo/Account.d.ts.map +1 -1
  320. package/_types/tempo/actions/accounts.d.ts +4 -1
  321. package/_types/tempo/actions/accounts.d.ts.map +1 -1
  322. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  323. package/_types/tempo/actions/propAmm.d.ts.map +1 -1
  324. package/_types/tempo/actions/token.d.ts.map +1 -1
  325. package/_types/tempo/chainConfig.d.ts.map +1 -1
  326. package/_types/tempo/internal/preAuthorized.d.ts +41 -0
  327. package/_types/tempo/internal/preAuthorized.d.ts.map +1 -0
  328. package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
  329. package/_types/tempo/internal/utils.d.ts.map +1 -1
  330. package/_types/tokens/defineToken.d.ts +5 -1
  331. package/_types/tokens/defineToken.d.ts.map +1 -1
  332. package/_types/tokens/definitions/ousd.d.ts +2 -1
  333. package/_types/tokens/definitions/ousd.d.ts.map +1 -1
  334. package/_types/tokens/sets.d.ts +3 -0
  335. package/_types/tokens/sets.d.ts.map +1 -1
  336. package/_types/utils/abi/decodeAbiParameters.d.ts +15 -1
  337. package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  338. package/_types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
  339. package/_types/utils/ccip.d.ts +4 -3
  340. package/_types/utils/ccip.d.ts.map +1 -1
  341. package/_types/utils/encoding/toBytes.d.ts +1 -1
  342. package/_types/utils/encoding/toBytes.d.ts.map +1 -1
  343. package/_types/utils/ens/avatar/utils.d.ts +6 -2
  344. package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
  345. package/_types/utils/ens/localBatchGatewayRequest.d.ts +6 -1
  346. package/_types/utils/ens/localBatchGatewayRequest.d.ts.map +1 -1
  347. package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
  348. package/_types/utils/siwe/validateSiweMessage.d.ts.map +1 -1
  349. package/_types/zksync/actions/estimateFee.d.ts.map +1 -1
  350. package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -1
  351. package/_types/zksync/actions/finalizeWithdrawal.d.ts.map +1 -1
  352. package/_types/zksync/actions/sendEip712Transaction.d.ts +1 -1
  353. package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
  354. package/_types/zksync/errors/bridge.d.ts +1 -1
  355. package/_types/zksync/errors/bridge.d.ts.map +1 -1
  356. package/account-abstraction/actions/paymaster/getPaymasterData.ts +23 -16
  357. package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +27 -16
  358. package/actions/ens/getEnsAddress.ts +15 -1
  359. package/actions/ens/getEnsText.ts +2 -0
  360. package/actions/index.ts +6 -0
  361. package/actions/public/call.ts +15 -2
  362. package/actions/public/getDelegation.ts +6 -1
  363. package/actions/public/getFeeHistory.ts +2 -0
  364. package/actions/public/getLogs.ts +44 -0
  365. package/actions/public/internal/isRangeError.ts +18 -0
  366. package/actions/public/internal/watchTransport.ts +29 -0
  367. package/actions/public/iterateLogs.ts +209 -0
  368. package/actions/public/simulateContract.ts +6 -4
  369. package/actions/public/verifyHash.ts +87 -60
  370. package/actions/public/waitForTransactionReceipt.ts +31 -1
  371. package/actions/public/watchBlockHeaders.ts +2 -12
  372. package/actions/public/watchBlockNumber.ts +6 -24
  373. package/actions/public/watchBlocks.ts +6 -24
  374. package/actions/public/watchContractEvent.ts +7 -42
  375. package/actions/public/watchEvent.ts +7 -42
  376. package/actions/token/internal.ts +2 -10
  377. package/actions/wallet/deployContract.ts +6 -1
  378. package/actions/wallet/prepareTransactionRequest.ts +25 -3
  379. package/actions/wallet/sendCalls.ts +6 -1
  380. package/actions/wallet/signAuthorization.ts +6 -1
  381. package/celo/serializers.ts +5 -2
  382. package/chains/definitions/kinetiqElysium.ts +27 -0
  383. package/chains/definitions/kinetiqElysiumTestnet.ts +28 -0
  384. package/chains/index.ts +2 -0
  385. package/clients/decorators/public.ts +47 -0
  386. package/constants/contracts.ts +1 -1
  387. package/errors/chain.ts +2 -2
  388. package/errors/typedData.ts +2 -0
  389. package/errors/version.ts +1 -1
  390. package/index.ts +7 -0
  391. package/op-stack/actions/buildProveWithdrawal.ts +5 -5
  392. package/op-stack/actions/getL2Output.ts +24 -11
  393. package/op-stack/actions/waitToProve.ts +1 -0
  394. package/package.json +2 -2
  395. package/tempo/Account.ts +38 -1
  396. package/tempo/actions/accessKey.ts +1 -1
  397. package/tempo/actions/accounts.ts +29 -11
  398. package/tempo/actions/earn/deployment.ts +2 -1
  399. package/tempo/actions/earn.ts +2 -2
  400. package/tempo/actions/propAmm.ts +2 -1
  401. package/tempo/actions/token.ts +10 -2
  402. package/tempo/chainConfig.ts +53 -5
  403. package/tempo/internal/preAuthorized.ts +309 -0
  404. package/tempo/internal/relay/feePayer.ts +33 -11
  405. package/tempo/internal/relay.ts +8 -3
  406. package/tempo/internal/utils.ts +2 -10
  407. package/tokens/defineToken.ts +6 -2
  408. package/tokens/definitions/ousd.ts +2 -1
  409. package/utils/abi/decodeAbiParameters.ts +60 -9
  410. package/utils/abi/encodeAbiParameters.ts +6 -4
  411. package/utils/abi/encodePacked.ts +5 -1
  412. package/utils/ccip.ts +17 -3
  413. package/utils/chain/getChainContractAddress.ts +2 -2
  414. package/utils/encoding/toBytes.ts +4 -6
  415. package/utils/ens/avatar/utils.ts +38 -4
  416. package/utils/ens/localBatchGatewayRequest.ts +21 -2
  417. package/utils/promise/createBatchScheduler.ts +2 -1
  418. package/utils/siwe/validateSiweMessage.ts +7 -0
  419. package/zksync/actions/estimateFee.ts +2 -1
  420. package/zksync/actions/estimateGasL1ToL2.ts +2 -1
  421. package/zksync/actions/finalizeWithdrawal.ts +4 -3
  422. package/zksync/actions/sendEip712Transaction.ts +21 -8
  423. package/zksync/actions/signEip712Transaction.ts +3 -3
  424. package/zksync/errors/bridge.ts +1 -1
package/actions/index.ts CHANGED
@@ -242,6 +242,12 @@ export {
242
242
  type GetTransactionReceiptReturnType,
243
243
  getTransactionReceipt,
244
244
  } from './public/getTransactionReceipt.js'
245
+ export {
246
+ type IterateLogsErrorType,
247
+ type IterateLogsParameters,
248
+ type IterateLogsReturnType,
249
+ iterateLogs,
250
+ } from './public/iterateLogs.js'
245
251
  export {
246
252
  type MulticallErrorType,
247
253
  type MulticallParameters,
@@ -353,7 +353,15 @@ export async function call<chain extends Chain | undefined>(
353
353
  to
354
354
  )
355
355
  return {
356
- data: await offchainLookup(client, { data, requestOptions, to }),
356
+ data: await offchainLookup(client, {
357
+ blockHash,
358
+ blockNumber,
359
+ blockTag,
360
+ data,
361
+ requestOptions,
362
+ requireCanonical,
363
+ to,
364
+ }),
357
365
  }
358
366
 
359
367
  // Check for counterfactual deployment error.
@@ -504,12 +512,17 @@ async function scheduleMulticall<chain extends Chain | undefined>(
504
512
  requestOptions,
505
513
  )
506
514
 
507
- return decodeFunctionResult({
515
+ const results = decodeFunctionResult({
508
516
  abi: multicall3Abi,
509
517
  args: [calls],
510
518
  functionName: 'aggregate3',
511
519
  data: data || '0x',
512
520
  })
521
+ if (results.length !== requests.length)
522
+ throw new BaseError(
523
+ `Multicall returned ${results.length} results for ${requests.length} calls.`,
524
+ )
525
+ return results
513
526
  },
514
527
  })
515
528
 
@@ -11,6 +11,7 @@ import {
11
11
  } from '../../utils/address/getAddress.js'
12
12
  import { type SizeErrorType, size } from '../../utils/data/size.js'
13
13
  import { type SliceErrorType, slice } from '../../utils/data/slice.js'
14
+ import { getAction } from '../../utils/getAction.js'
14
15
  import { type GetCodeErrorType, getCode } from './getCode.js'
15
16
 
16
17
  export type GetDelegationParameters = {
@@ -62,7 +63,11 @@ export async function getDelegation<chain extends Chain | undefined>(
62
63
  client: Client<Transport, chain>,
63
64
  { address, blockNumber, blockTag = 'latest' }: GetDelegationParameters,
64
65
  ): Promise<GetDelegationReturnType> {
65
- const code = await getCode(client, {
66
+ const code = await getAction(
67
+ client,
68
+ getCode,
69
+ 'getCode',
70
+ )({
66
71
  address,
67
72
  ...(blockNumber !== undefined ? { blockNumber } : { blockTag }),
68
73
  } as GetDelegationParameters)
@@ -1,5 +1,6 @@
1
1
  import type { Client } from '../../clients/createClient.js'
2
2
  import type { Transport } from '../../clients/transports/createTransport.js'
3
+ import type { ErrorType } from '../../errors/utils.js'
3
4
  import type { BlockTag } from '../../types/block.js'
4
5
  import type { Chain } from '../../types/chain.js'
5
6
  import type { FeeHistory } from '../../types/fee.js'
@@ -43,6 +44,7 @@ export type GetFeeHistoryErrorType =
43
44
  | NumberToHexErrorType
44
45
  | RequestErrorType
45
46
  | FormatFeeHistoryErrorType
47
+ | ErrorType
46
48
 
47
49
  /**
48
50
  * Returns a collection of historical gas information.
@@ -28,6 +28,8 @@ import {
28
28
  type FormatLogErrorType,
29
29
  formatLog,
30
30
  } from '../../utils/formatters/log.js'
31
+ import type { GetBlockErrorType } from './getBlock.js'
32
+ import { type IterateLogsParameters, iterateLogs } from './iterateLogs.js'
31
33
 
32
34
  export type GetLogsParameters<
33
35
  abiEvent extends AbiEvent | undefined = undefined,
@@ -78,12 +80,30 @@ export type GetLogsParameters<
78
80
  /** Block number or tag before which to include logs */
79
81
  toBlock?: toBlock | BlockNumber | BlockTag | undefined
80
82
  blockHash?: undefined
83
+ blockRange?: undefined
81
84
  }
82
85
  | {
83
86
  fromBlock?: undefined
84
87
  toBlock?: undefined
85
88
  /** Hash of block to include logs from */
86
89
  blockHash?: Hash | undefined
90
+ blockRange?: undefined
91
+ }
92
+ | {
93
+ /** First block to include logs from. Inclusive. */
94
+ fromBlock: BlockNumber
95
+ /**
96
+ * Last block to include logs from. Inclusive. A block tag is resolved to a block number once, before the first request.
97
+ * @default 'latest'
98
+ */
99
+ toBlock?: BlockNumber | Exclude<BlockTag, 'pending'> | undefined
100
+ blockHash?: undefined
101
+ /**
102
+ * Most blocks to request in one `eth_getLogs` call. When set, logs are requested in
103
+ * consecutive ranges of at most this many blocks, and a range the RPC Provider rejects
104
+ * is halved and requested again. Must be at least `1n`.
105
+ */
106
+ blockRange: bigint
87
107
  }
88
108
  )
89
109
 
@@ -107,6 +127,7 @@ export type GetLogsErrorType =
107
127
  | DecodeEventLogErrorType
108
128
  | EncodeEventTopicsErrorType
109
129
  | FormatLogErrorType
130
+ | GetBlockErrorType
110
131
  | NumberToHexErrorType
111
132
  | RequestErrorType
112
133
  | ErrorType
@@ -153,9 +174,32 @@ export async function getLogs<
153
174
  event,
154
175
  events: events_,
155
176
  args,
177
+ blockRange,
156
178
  strict: strict_,
157
179
  }: GetLogsParameters<abiEvent, abiEvents, strict, fromBlock, toBlock> = {},
158
180
  ): Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>> {
181
+ if (blockRange !== undefined) {
182
+ const logs = []
183
+ for await (const page of iterateLogs(client, {
184
+ address,
185
+ args,
186
+ blockRange,
187
+ event,
188
+ events: events_,
189
+ fromBlock,
190
+ strict: strict_,
191
+ toBlock,
192
+ } as IterateLogsParameters))
193
+ for (const log of page.logs) logs.push(log)
194
+ return logs as GetLogsReturnType<
195
+ abiEvent,
196
+ abiEvents,
197
+ strict,
198
+ fromBlock,
199
+ toBlock
200
+ >
201
+ }
202
+
159
203
  const strict = strict_ ?? false
160
204
  const events = events_ ?? (event ? [event] : undefined)
161
205
 
@@ -0,0 +1,18 @@
1
+ import { BaseError } from '../../../errors/base.js'
2
+ import { HttpRequestError, RpcRequestError } from '../../../errors/request.js'
3
+
4
+ /** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
5
+ export function isRangeError(error: unknown) {
6
+ if (!(error instanceof BaseError)) return true
7
+ const cause = error.walk(
8
+ (err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
9
+ ) as HttpRequestError | RpcRequestError | null
10
+ if (!cause) return true
11
+ // Rate limited.
12
+ if (cause instanceof RpcRequestError && cause.code === 429) return false
13
+ // Unreachable.
14
+ if (cause instanceof HttpRequestError && cause.status === undefined)
15
+ return false
16
+ // Unauthorized, forbidden or rate limited.
17
+ return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
18
+ }
@@ -0,0 +1,29 @@
1
+ import type { Client } from '../../../clients/createClient.js'
2
+ import type { Transport } from '../../../clients/transports/createTransport.js'
3
+
4
+ /** Selects the first direct socket member of a fallback transport. */
5
+ export function getSubscriptionTransport(client: Client) {
6
+ if (client.transport.type === 'fallback') {
7
+ const transport = client.transport.transports.find(
8
+ (transport: ReturnType<Transport>) =>
9
+ transport.config.type === 'webSocket' ||
10
+ transport.config.type === 'ipc',
11
+ )
12
+ if (!transport) return client.transport
13
+ return transport.value
14
+ }
15
+ return client.transport
16
+ }
17
+
18
+ /** Defaults to subscriptions only when the first transport supports them. */
19
+ export function shouldPoll(client: Client) {
20
+ if (client.transport.type === 'webSocket' || client.transport.type === 'ipc')
21
+ return false
22
+ if (
23
+ client.transport.type === 'fallback' &&
24
+ (client.transport.transports[0].config.type === 'webSocket' ||
25
+ client.transport.transports[0].config.type === 'ipc')
26
+ )
27
+ return false
28
+ return true
29
+ }
@@ -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
  }