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
@@ -9,6 +9,7 @@ import {
9
9
  InvalidAbiDecodingTypeError,
10
10
  type InvalidAbiDecodingTypeErrorType,
11
11
  } from '../../errors/abi.js'
12
+ import { BaseError } from '../../errors/base.js'
12
13
  import type { ErrorType } from '../../errors/utils.js'
13
14
  import type { ByteArray, Hex } from '../../types/misc.js'
14
15
  import {
@@ -50,6 +51,7 @@ export type DecodeAbiParametersErrorType =
50
51
  | DecodeParameterErrorType
51
52
  | SizeErrorType
52
53
  | CreateCursorErrorType
54
+ | AbiDecodingSizeLimitExceededErrorType
53
55
  | ErrorType
54
56
 
55
57
  export function decodeAbiParameters<
@@ -70,6 +72,10 @@ export function decodeAbiParameters<
70
72
  size: size(data),
71
73
  })
72
74
 
75
+ // Bound the total size of decoded `bytes` and `string` values, so offsets
76
+ // that share or overlap tails cannot decode to far more data than the input.
77
+ const budget = { limit: bytes.length * 32, used: 0 }
78
+
73
79
  let consumed = 0
74
80
  const values = []
75
81
  for (let i = 0; i < params.length; ++i) {
@@ -78,6 +84,7 @@ export function decodeAbiParameters<
78
84
  // data consume no bytes, so the cursor may already be exhausted.
79
85
  if (consumed < bytes.length) cursor.setPosition(consumed)
80
86
  const [data, consumed_] = decodeParameter(cursor, param, {
87
+ budget,
81
88
  staticPosition: 0,
82
89
  })
83
90
  consumed += consumed_
@@ -99,23 +106,31 @@ type DecodeParameterErrorType =
99
106
  function decodeParameter(
100
107
  cursor: Cursor,
101
108
  param: AbiParameter,
102
- { staticPosition }: { staticPosition: number },
109
+ { budget, staticPosition }: { budget: Budget; staticPosition: number },
103
110
  ) {
104
111
  const arrayComponents = getArrayComponents(param.type)
105
112
  if (arrayComponents) {
106
113
  const [length, type] = arrayComponents
107
- return decodeArray(cursor, { ...param, type }, { length, staticPosition })
114
+ return decodeArray(
115
+ cursor,
116
+ { ...param, type },
117
+ { budget, length, staticPosition },
118
+ )
108
119
  }
109
120
  if (param.type === 'tuple')
110
- return decodeTuple(cursor, param as TupleAbiParameter, { staticPosition })
121
+ return decodeTuple(cursor, param as TupleAbiParameter, {
122
+ budget,
123
+ staticPosition,
124
+ })
111
125
 
112
126
  if (param.type === 'address') return decodeAddress(cursor)
113
127
  if (param.type === 'bool') return decodeBool(cursor)
114
128
  if (param.type.startsWith('bytes'))
115
- return decodeBytes(cursor, param, { staticPosition })
129
+ return decodeBytes(cursor, param, { budget, staticPosition })
116
130
  if (param.type.startsWith('uint') || param.type.startsWith('int'))
117
131
  return decodeNumber(cursor, param)
118
- if (param.type === 'string') return decodeString(cursor, { staticPosition })
132
+ if (param.type === 'string')
133
+ return decodeString(cursor, { budget, staticPosition })
119
134
  throw new InvalidAbiDecodingTypeError(param.type, {
120
135
  docsPath: '/docs/contract/decodeAbiParameters',
121
136
  })
@@ -127,6 +142,8 @@ function decodeParameter(
127
142
  const sizeOfLength = 32
128
143
  const sizeOfOffset = 32
129
144
 
145
+ type Budget = { limit: number; used: number }
146
+
130
147
  type DecodeAddressErrorType =
131
148
  | ChecksumAddressErrorType
132
149
  | BytesToHexErrorType
@@ -143,7 +160,11 @@ type DecodeArrayErrorType = BytesToNumberErrorType | ErrorType
143
160
  function decodeArray(
144
161
  cursor: Cursor,
145
162
  param: AbiParameter,
146
- { length, staticPosition }: { length: number | null; staticPosition: number },
163
+ {
164
+ budget,
165
+ length,
166
+ staticPosition,
167
+ }: { budget: Budget; length: number | null; staticPosition: number },
147
168
  ) {
148
169
  // If the length of the array is not known in advance (dynamic array),
149
170
  // this means we will need to wonder off to the pointer and decode.
@@ -170,6 +191,7 @@ function decodeArray(
170
191
  // Otherwise, elements will be the size of their encoding (consumed bytes).
171
192
  cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed))
172
193
  const [data, consumed_] = decodeParameter(cursor, param, {
194
+ budget,
173
195
  staticPosition: startOfData,
174
196
  })
175
197
  consumed += consumed_
@@ -202,6 +224,7 @@ function decodeArray(
202
224
  // Move cursor along to the next slot (next offset pointer).
203
225
  cursor.setPosition(start + i * 32)
204
226
  const [data] = decodeParameter(cursor, param, {
227
+ budget,
205
228
  staticPosition: start,
206
229
  })
207
230
  value.push(data)
@@ -218,6 +241,7 @@ function decodeArray(
218
241
  const value: unknown[] = []
219
242
  for (let i = 0; i < length; ++i) {
220
243
  const [data, consumed_] = decodeParameter(cursor, param, {
244
+ budget,
221
245
  staticPosition: staticPosition + consumed,
222
246
  })
223
247
  consumed += consumed_
@@ -246,7 +270,7 @@ type DecodeBytesErrorType =
246
270
  function decodeBytes(
247
271
  cursor: Cursor,
248
272
  param: AbiParameter,
249
- { staticPosition }: { staticPosition: number },
273
+ { budget, staticPosition }: { budget: Budget; staticPosition: number },
250
274
  ) {
251
275
  const [_, size] = param.type.split('bytes')
252
276
  if (!size) {
@@ -266,6 +290,9 @@ function decodeBytes(
266
290
  }
267
291
 
268
292
  const data = cursor.readBytes(length)
293
+ budget.used += length
294
+ if (budget.used > budget.limit)
295
+ throw new AbiDecodingSizeLimitExceededError({ limit: budget.limit })
269
296
 
270
297
  // As we have gone wondering, restore to the original position + next slot.
271
298
  cursor.setPosition(staticPosition + 32)
@@ -300,7 +327,7 @@ type DecodeTupleErrorType = BytesToNumberErrorType | ErrorType
300
327
  function decodeTuple(
301
328
  cursor: Cursor,
302
329
  param: TupleAbiParameter,
303
- { staticPosition }: { staticPosition: number },
330
+ { budget, staticPosition }: { budget: Budget; staticPosition: number },
304
331
  ) {
305
332
  // Tuples can have unnamed components (i.e. they are arrays), so we must
306
333
  // determine whether the tuple is named or unnamed. In the case of a named
@@ -327,6 +354,7 @@ function decodeTuple(
327
354
  const component = param.components[i]
328
355
  cursor.setPosition(start + consumed)
329
356
  const [data, consumed_] = decodeParameter(cursor, component, {
357
+ budget,
330
358
  staticPosition: start,
331
359
  })
332
360
  consumed += consumed_
@@ -343,6 +371,7 @@ function decodeTuple(
343
371
  for (let i = 0; i < param.components.length; ++i) {
344
372
  const component = param.components[i]
345
373
  const [data, consumed_] = decodeParameter(cursor, component, {
374
+ budget,
346
375
  staticPosition,
347
376
  })
348
377
  value[hasUnnamedChild ? i : component?.name!] = data
@@ -358,7 +387,7 @@ type DecodeStringErrorType =
358
387
 
359
388
  function decodeString(
360
389
  cursor: Cursor,
361
- { staticPosition }: { staticPosition: number },
390
+ { budget, staticPosition }: { budget: Budget; staticPosition: number },
362
391
  ) {
363
392
  // Get offset to start of string data.
364
393
  const offset = bytesToNumber(cursor.readBytes(32))
@@ -376,6 +405,9 @@ function decodeString(
376
405
  }
377
406
 
378
407
  const data = cursor.readBytes(length, 32)
408
+ budget.used += length
409
+ if (budget.used > budget.limit)
410
+ throw new AbiDecodingSizeLimitExceededError({ limit: budget.limit })
379
411
  const value = bytesToString(data)
380
412
 
381
413
  // As we have gone wondering, restore to the original position + next slot.
@@ -401,3 +433,22 @@ function hasDynamicChild(param: AbiParameter) {
401
433
 
402
434
  return false
403
435
  }
436
+
437
+ /** Type of {@link AbiDecodingSizeLimitExceededError}. */
438
+ export type AbiDecodingSizeLimitExceededErrorType =
439
+ AbiDecodingSizeLimitExceededError & {
440
+ name: 'AbiDecodingSizeLimitExceededError'
441
+ }
442
+
443
+ /**
444
+ * Thrown by `decodeAbiParameters` when the decoded `bytes` and `string` values
445
+ * of one decode add up to more than 32 times the size of the input data.
446
+ */
447
+ export class AbiDecodingSizeLimitExceededError extends BaseError {
448
+ constructor({ limit }: { limit: number }) {
449
+ super(
450
+ `Decoded \`bytes\` and \`string\` values exceed the size limit of ${limit} bytes.`,
451
+ { name: 'AbiDecodingSizeLimitExceededError' },
452
+ )
453
+ }
454
+ }
@@ -296,15 +296,17 @@ function encodeBytes<const param extends AbiParameter>(
296
296
  { param }: { param: param },
297
297
  ): PreparedParam {
298
298
  const [, paramSize] = param.type.split('bytes')
299
- const bytesSize = size(value)
299
+ // Odd-length hex is left-padded to whole bytes, matching `hexToBytes`.
300
+ const hex: Hex = value.length % 2 ? `0x0${value.slice(2)}` : value
301
+ const bytesSize = size(hex)
300
302
  if (!paramSize) {
301
- let value_ = value
303
+ let value_ = hex
302
304
  // If the size is not divisible by 32 bytes, pad the end
303
305
  // with empty bytes to the ceiling 32 bytes.
304
306
  if (bytesSize % 32 !== 0)
305
307
  value_ = padHex(value_, {
306
308
  dir: 'right',
307
- size: Math.ceil((value.length - 2) / 2 / 32) * 32,
309
+ size: Math.ceil(bytesSize / 32) * 32,
308
310
  })
309
311
  return {
310
312
  dynamic: true,
@@ -319,7 +321,7 @@ function encodeBytes<const param extends AbiParameter>(
319
321
  expectedSize: Number.parseInt(paramSize, 10),
320
322
  value,
321
323
  })
322
- return { dynamic: false, encoded: padHex(value, { dir: 'right' }) }
324
+ return { dynamic: false, encoded: padHex(hex, { dir: 'right' }) }
323
325
  }
324
326
 
325
327
  type EncodeBoolErrorType = PadHexErrorType | BoolToHexErrorType | ErrorType
@@ -100,7 +100,11 @@ function encode<const packedAbiType extends PackedAbiType | unknown>(
100
100
  }) as Address
101
101
  }
102
102
  if (type === 'string') return stringToHex(value as string)
103
- if (type === 'bytes') return value as Hex
103
+ if (type === 'bytes') {
104
+ const hex = value as Hex
105
+ // Odd-length hex is left-padded to whole bytes, matching `hexToBytes`.
106
+ return hex.length % 2 ? `0x0${hex.slice(2)}` : hex
107
+ }
104
108
  if (type === 'bool')
105
109
  return pad(boolToHex(value as boolean), { size: isArray ? 32 : 1 })
106
110
 
package/utils/ccip.ts CHANGED
@@ -81,20 +81,30 @@ export type OffchainLookupErrorType = OffchainLookupErrorType_ | ErrorType
81
81
  * Performs an EIP-3668 CCIP-Read lookup for a reverted `OffchainLookup` call.
82
82
  *
83
83
  * Follows at most 4 nested callbacks. Every gateway request of the lookup,
84
- * including nested local batches, draws from one query and concurrency budget.
85
- * Each gateway request uses the client transport timeout.
84
+ * including nested local batches, draws from one query and concurrency budget,
85
+ * and local batch responses draw from one byte budget. Each gateway request
86
+ * uses the client transport timeout.
86
87
  */
87
88
  export async function offchainLookup<chain extends Chain | undefined>(
88
89
  client: Client<Transport, chain>,
89
90
  {
91
+ blockHash,
90
92
  blockNumber,
91
93
  blockTag,
92
94
  budget = createCcipReadBudget(),
93
95
  data,
94
96
  depth = 0,
95
97
  requestOptions,
98
+ requireCanonical,
96
99
  to,
97
- }: Pick<CallParameters, 'blockNumber' | 'blockTag' | 'requestOptions'> & {
100
+ }: Pick<
101
+ CallParameters,
102
+ | 'blockHash'
103
+ | 'blockNumber'
104
+ | 'blockTag'
105
+ | 'requestOptions'
106
+ | 'requireCanonical'
107
+ > & {
98
108
  /** Budget shared by the callbacks of one lookup. */
99
109
  budget?: CcipReadBudget | undefined
100
110
  data: Hex
@@ -170,10 +180,12 @@ export async function offchainLookup<chain extends Chain | undefined>(
170
180
  // back here with the lookup's depth and budget.
171
181
  try {
172
182
  const { data: data_ } = await call({ ...client, ccipRead: false }, {
183
+ blockHash,
173
184
  blockNumber,
174
185
  blockTag,
175
186
  data: callbackData,
176
187
  requestOptions,
188
+ requireCanonical,
177
189
  to,
178
190
  } as CallParameters)
179
191
  return data_!
@@ -181,12 +193,14 @@ export async function offchainLookup<chain extends Chain | undefined>(
181
193
  const revertData = getRevertErrorData(err)
182
194
  if (revertData?.slice(0, 10) !== offchainLookupSignature) throw err
183
195
  return await offchainLookup(client, {
196
+ blockHash,
184
197
  blockNumber,
185
198
  blockTag,
186
199
  budget,
187
200
  data: revertData,
188
201
  depth: depth + 1,
189
202
  requestOptions,
203
+ requireCanonical,
190
204
  to,
191
205
  })
192
206
  }
@@ -24,8 +24,8 @@ export function getChainContractAddress({
24
24
  })
25
25
 
26
26
  if (
27
- blockNumber &&
28
- contract.blockCreated &&
27
+ blockNumber !== undefined &&
28
+ contract.blockCreated !== undefined &&
29
29
  contract.blockCreated > blockNumber
30
30
  )
31
31
  throw new ChainDoesNotSupportContract({
@@ -147,16 +147,14 @@ export type HexToBytesErrorType = AssertSizeErrorType | PadErrorType | ErrorType
147
147
  * const data = hexToBytes('0x48656c6c6f20776f726c6421', { size: 32 })
148
148
  * // Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
149
149
  */
150
- export function hexToBytes(hex_: Hex, opts: HexToBytesOpts = {}): ByteArray {
151
- let hex = hex_
150
+ export function hexToBytes(hex: Hex, opts: HexToBytesOpts = {}): ByteArray {
151
+ let hexString = hex.slice(2)
152
+ if (hexString.length % 2) hexString = `0${hexString}`
152
153
  if (opts.size) {
153
154
  assertSize(hex, { size: opts.size })
154
- hex = pad(hex, { dir: 'right', size: opts.size })
155
+ hexString = hexString.padEnd(opts.size * 2, '0')
155
156
  }
156
157
 
157
- let hexString = hex.slice(2) as string
158
- if (hexString.length % 2) hexString = `0${hexString}`
159
-
160
158
  const length = hexString.length / 2
161
159
  const bytes = new Uint8Array(length)
162
160
  for (let index = 0, j = 0; index < length; index++) {
@@ -17,10 +17,13 @@ import {
17
17
  EnsAvatarUriResolutionError,
18
18
  type EnsAvatarUriResolutionErrorType,
19
19
  } from '../../../errors/ens.js'
20
+ import { TimeoutError } from '../../../errors/request.js'
20
21
  import type { ErrorType } from '../../../errors/utils.js'
21
22
  import type { Chain } from '../../../types/chain.js'
22
23
  import type { AssetGatewayUrls } from '../../../types/ens.js'
23
24
  import { type NumberToHexErrorType, numberToHex } from '../../encoding/toHex.js'
25
+ import { readResponseBody } from '../../internal/http.js'
26
+ import { withTimeout } from '../../promise/withTimeout.js'
24
27
 
25
28
  type UriItem = {
26
29
  uri: string
@@ -35,12 +38,27 @@ const ipfsHashRegex =
35
38
  const base64Regex = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/
36
39
  const dataURIRegex = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/
37
40
 
41
+ const fetchTimeout = 10_000
42
+ // Same ceiling as the HTTP transport.
43
+ const maxMetadataBytes = 10_485_760
44
+
38
45
  type IsImageUriErrorType = ErrorType
39
46
 
40
47
  /** @internal */
41
- export async function isImageUri(uri: string) {
48
+ export async function isImageUri(
49
+ uri: string,
50
+ { timeout = fetchTimeout }: { timeout?: number | undefined } = {},
51
+ ) {
42
52
  try {
43
- const res = await fetch(uri, { method: 'HEAD' })
53
+ const res = await withTimeout(
54
+ ({ signal }) =>
55
+ fetch(uri, { method: 'HEAD', ...(signal ? { signal } : {}) }),
56
+ {
57
+ errorInstance: new TimeoutError({ body: {}, url: uri }),
58
+ signal: true,
59
+ timeout,
60
+ },
61
+ )
44
62
  // retrieve content type header to check if content is image
45
63
  if (res.status === 200) {
46
64
  const contentType = res.headers.get('content-type')
@@ -48,6 +66,7 @@ export async function isImageUri(uri: string) {
48
66
  }
49
67
  return false
50
68
  } catch (error: any) {
69
+ if (error instanceof TimeoutError) return false
51
70
  // if error is not cors related then fail
52
71
  if (typeof error === 'object' && typeof error.response !== 'undefined') {
53
72
  return false
@@ -171,16 +190,31 @@ export type GetMetadataAvatarUriErrorType =
171
190
 
172
191
  export async function getMetadataAvatarUri({
173
192
  gatewayUrls,
193
+ timeout = fetchTimeout,
174
194
  uri,
175
195
  }: {
176
196
  gatewayUrls?: AssetGatewayUrls | undefined
197
+ /** The timeout (in ms) for the metadata request, including its body. Default: 10_000 */
198
+ timeout?: number | undefined
177
199
  uri: string
178
200
  }): Promise<string> {
179
201
  try {
180
- const res = await fetch(uri).then((res) => res.json())
202
+ const body = await withTimeout(
203
+ async ({ signal }) => {
204
+ const response = await fetch(uri, signal ? { signal } : {})
205
+ return readResponseBody(response, {
206
+ maxResponseBodySize: maxMetadataBytes,
207
+ })
208
+ },
209
+ {
210
+ errorInstance: new TimeoutError({ body: {}, url: uri }),
211
+ signal: true,
212
+ timeout,
213
+ },
214
+ )
181
215
  const image = await parseAvatarUri({
182
216
  gatewayUrls,
183
- uri: getJsonImage(res),
217
+ uri: getJsonImage(JSON.parse(body)),
184
218
  })
185
219
  return image
186
220
  } catch {
@@ -10,12 +10,15 @@ import type {
10
10
  CcipRequestParameters,
11
11
  CcipRequestReturnType,
12
12
  } from '../ccip.js'
13
+ import { size } from '../data/size.js'
13
14
 
14
15
  export const localBatchGatewayUrl = 'x-batch-gateway:true'
15
16
 
16
17
  /**
17
18
  * Caps for one CCIP-Read lookup.
18
19
  *
20
+ * - `bytes`: local batch response bytes in total, across callbacks and nested
21
+ * batches. Going over it fails the lookup.
19
22
  * - `concurrency`: gateway requests in flight at once, across nested batches.
20
23
  * - `depth`: nested callbacks, and separately, nested local batches.
21
24
  * - `queries`: gateway requests in total, across callbacks and nested batches.
@@ -24,13 +27,16 @@ export const localBatchGatewayUrl = 'x-batch-gateway:true'
24
27
  * `batchGateways`) are the caller's own and are not counted separately.
25
28
  */
26
29
  export const ccipReadLimit = {
30
+ bytes: 10_485_760,
27
31
  concurrency: 16,
28
32
  depth: 4,
29
33
  queries: 256,
30
34
  } as const
31
35
 
32
- /** Query and concurrency budget shared by every request of one lookup. */
36
+ /** Byte, query and concurrency budget shared by every request of one lookup. */
33
37
  export type CcipReadBudget = {
38
+ /** Local batch response bytes still allowed. */
39
+ bytes: number
34
40
  /** Gateway requests still allowed. */
35
41
  queries: number
36
42
  /** Runs a gateway request once a concurrency slot is free. */
@@ -42,6 +48,7 @@ export function createCcipReadBudget(): CcipReadBudget {
42
48
  let active = 0
43
49
  const queue: (() => void)[] = []
44
50
  return {
51
+ bytes: ccipReadLimit.bytes,
45
52
  queries: ccipReadLimit.queries,
46
53
  async run(fn) {
47
54
  if (active >= ccipReadLimit.concurrency)
@@ -108,10 +115,22 @@ export async function localBatchGatewayRequest(parameters: {
108
115
  // as `ccipReadTunnel`) may send it elsewhere.
109
116
  const urls = query.urls.slice(0, budget.queries)
110
117
  budget.queries -= Math.max(1, urls.length)
111
- responses[i] = await budget.run(() => ccipRequest({ ...query, urls }))
118
+ // Requests still queued once the batch is over budget are skipped.
119
+ const response = await budget.run(async () =>
120
+ budget.bytes < 0 ? '0x' : ccipRequest({ ...query, urls }),
121
+ )
122
+ budget.bytes -= size(response)
123
+ if (budget.bytes < 0)
124
+ throw new HttpRequestError({
125
+ details: `CCIP Read exceeded the maximum response size (${ccipReadLimit.bytes} bytes).`,
126
+ url: localBatchGatewayUrl,
127
+ })
128
+ responses[i] = response
112
129
  }
113
130
  failures[i] = false
114
131
  } catch (err) {
132
+ // Over the byte budget, the whole batch fails rather than one query.
133
+ if (budget.bytes < 0) throw err
115
134
  failures[i] = true
116
135
  responses[i] = encodeError(err as CcipRequestErrorType)
117
136
  }
@@ -61,7 +61,8 @@ export function createBatchScheduler<
61
61
 
62
62
  if (args.length === 0) return
63
63
 
64
- fn(args as parameters[])
64
+ // Wrap `fn` so that synchronous throws reject the scheduled promises.
65
+ new Promise<returnType>((resolve) => resolve(fn(args as parameters[])))
65
66
  .then((data) => {
66
67
  if (sort && Array.isArray(data)) data.sort(sort)
67
68
  for (let i = 0; i < scheduler.length; i++) {
@@ -57,6 +57,11 @@ export function validateSiweMessage(
57
57
  if (nonce && message.nonce !== nonce) return false
58
58
  if (scheme && message.scheme !== scheme) return false
59
59
 
60
+ // EIP-4361 requires `nonce = 8*( ALPHA / DIGIT )` and `version = "1"`.
61
+ if (message.nonce !== undefined && !nonceRegex.test(message.nonce))
62
+ return false
63
+ if (message.version !== undefined && message.version !== '1') return false
64
+
60
65
  // Invalid `time` makes both lifetime comparisons false in JS; reject first.
61
66
  if (Number.isNaN(time.getTime())) return false
62
67
 
@@ -81,3 +86,5 @@ export function validateSiweMessage(
81
86
 
82
87
  return true
83
88
  }
89
+
90
+ const nonceRegex = /^[a-zA-Z0-9]{8,}$/
@@ -24,7 +24,8 @@ export async function estimateFee<
24
24
  parameters: EstimateFeeParameters<chain, account>,
25
25
  ): Promise<EstimateFeeReturnType> {
26
26
  const { account: account_, ...request } = parameters
27
- const account = account_ ? parseAccount(account_) : client.account
27
+ const account =
28
+ account_ === undefined ? client.account : account_ && parseAccount(account_)
28
29
 
29
30
  const formatters = client.chain?.formatters
30
31
  const formatted = formatters?.transactionRequest?.format(
@@ -21,7 +21,8 @@ export async function estimateGasL1ToL2<
21
21
  parameters: EstimateGasL1ToL2Parameters<chain, account>,
22
22
  ): Promise<EstimateGasL1ToL2ReturnType> {
23
23
  const { account: account_, ...request } = parameters
24
- const account = account_ ? parseAccount(account_) : client.account
24
+ const account =
25
+ account_ === undefined ? client.account : account_ && parseAccount(account_)
25
26
 
26
27
  const formatters = client.chain?.formatters
27
28
  const formatted = formatters?.transactionRequest?.format(
@@ -134,14 +134,15 @@ export async function finalizeWithdrawal<
134
134
  >,
135
135
  ): Promise<FinalizeWithdrawalReturnType> {
136
136
  const {
137
- account: account_ = client.account,
137
+ account: account_,
138
138
  client: l2Client,
139
139
  hash,
140
140
  index = 0,
141
141
  ...rest
142
142
  } = parameters
143
- const account = account_ ? parseAccount(account_) : client.account
144
- if (!account)
143
+ const account =
144
+ account_ === undefined ? client.account : account_ && parseAccount(account_)
145
+ if (account === undefined)
145
146
  throw new AccountNotFoundError({
146
147
  docsPath: '/docs/actions/wallet/sendTransaction',
147
148
  })
@@ -3,11 +3,12 @@ import { parseAccount } from '../../accounts/utils/parseAccount.js'
3
3
  import { getChainId } from '../../actions/public/getChainId.js'
4
4
  import { prepareTransactionRequest } from '../../actions/wallet/prepareTransactionRequest.js'
5
5
  import { sendRawTransaction } from '../../actions/wallet/sendRawTransaction.js'
6
- import type {
7
- SendTransactionErrorType,
8
- SendTransactionParameters,
9
- SendTransactionRequest,
10
- SendTransactionReturnType,
6
+ import {
7
+ type SendTransactionErrorType,
8
+ type SendTransactionParameters,
9
+ type SendTransactionRequest,
10
+ type SendTransactionReturnType,
11
+ sendTransaction,
11
12
  } from '../../actions/wallet/sendTransaction.js'
12
13
  import type { Client } from '../../clients/createClient.js'
13
14
  import type { Transport } from '../../clients/transports/createTransport.js'
@@ -20,7 +21,9 @@ import {
20
21
  getTransactionError,
21
22
  } from '../../utils/errors/getTransactionError.js'
22
23
  import { getAction } from '../../utils/getAction.js'
24
+ import { gasPerPubdataDefault } from '../constants/number.js'
23
25
  import type { ChainEIP712 } from '../types/chain.js'
26
+ import type { ZksyncTransactionRequestEIP712 } from '../types/transaction.js'
24
27
  import { assertEip712Request } from '../utils/assertEip712Request.js'
25
28
  import { signTransaction } from './signTransaction.js'
26
29
 
@@ -95,13 +98,23 @@ export async function sendEip712Transaction<
95
98
  const { account: account_ = client.account, chain = client.chain } =
96
99
  parameters
97
100
 
98
- const account = account_ ? parseAccount(account_) : client.account
99
-
100
- if (!account)
101
+ if (typeof account_ === 'undefined')
101
102
  throw new AccountNotFoundError({
102
103
  docsPath: '/docs/actions/wallet/sendTransaction',
103
104
  })
104
105
 
106
+ // Without an account to sign with, forward the request to the wallet unsigned.
107
+ // `gasPerPubdata` keeps the request formatted as an EIP-712 transaction.
108
+ if (account_ === null)
109
+ return sendTransaction(client, {
110
+ ...parameters,
111
+ gasPerPubdata:
112
+ (parameters as ZksyncTransactionRequestEIP712).gasPerPubdata ??
113
+ gasPerPubdataDefault,
114
+ } as any)
115
+
116
+ const account = parseAccount(account_)
117
+
105
118
  try {
106
119
  assertEip712Request(parameters)
107
120
 
@@ -104,13 +104,13 @@ export async function signEip712Transaction<
104
104
  ...transaction
105
105
  } = args
106
106
 
107
- const account = account_ ? parseAccount(account_) : client.account
108
-
109
- if (!account)
107
+ if (!account_)
110
108
  throw new AccountNotFoundError({
111
109
  docsPath: '/docs/actions/wallet/signTransaction',
112
110
  })
113
111
 
112
+ const account = parseAccount(account_)
113
+
114
114
  assertEip712Request({
115
115
  account,
116
116
  chain,
@@ -18,7 +18,7 @@ export class BaseFeeHigherThanValueError extends BaseError {
18
18
  }
19
19
  }
20
20
 
21
- export type TxHashNotFoundInLogsErrorType = BaseFeeHigherThanValueError & {
21
+ export type TxHashNotFoundInLogsErrorType = TxHashNotFoundInLogsError & {
22
22
  name: 'TxHashNotFoundInLogsError'
23
23
  }
24
24
  export class TxHashNotFoundInLogsError extends BaseError {