viem 2.57.11 → 2.57.13

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 (377) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/_cjs/actions/public/fillTransaction.js +6 -3
  3. package/_cjs/actions/public/fillTransaction.js.map +1 -1
  4. package/_cjs/actions/public/waitForTransactionReceipt.js +83 -23
  5. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  6. package/_cjs/actions/public/watchContractEvent.js +58 -29
  7. package/_cjs/actions/public/watchContractEvent.js.map +1 -1
  8. package/_cjs/actions/public/watchEvent.js +58 -28
  9. package/_cjs/actions/public/watchEvent.js.map +1 -1
  10. package/_cjs/actions/token/approve.js +1 -1
  11. package/_cjs/actions/token/approve.js.map +1 -1
  12. package/_cjs/actions/token/getAllowance.js +1 -1
  13. package/_cjs/actions/token/getAllowance.js.map +1 -1
  14. package/_cjs/actions/token/getBalance.js +1 -1
  15. package/_cjs/actions/token/getBalance.js.map +1 -1
  16. package/_cjs/actions/token/getTotalSupply.js +1 -1
  17. package/_cjs/actions/token/getTotalSupply.js.map +1 -1
  18. package/_cjs/actions/token/transfer.js +1 -1
  19. package/_cjs/actions/token/transfer.js.map +1 -1
  20. package/_cjs/actions/wallet/sendCalls.js +1 -1
  21. package/_cjs/actions/wallet/sendCalls.js.map +1 -1
  22. package/_cjs/chains/definitions/molibra.js +21 -0
  23. package/_cjs/chains/definitions/molibra.js.map +1 -0
  24. package/_cjs/chains/definitions/valuechain.js +22 -0
  25. package/_cjs/chains/definitions/valuechain.js.map +1 -0
  26. package/_cjs/chains/definitions/valuechainTestnet.js +23 -0
  27. package/_cjs/chains/definitions/valuechainTestnet.js.map +1 -0
  28. package/_cjs/chains/index.js +13 -7
  29. package/_cjs/chains/index.js.map +1 -1
  30. package/_cjs/clients/decorators/public.js.map +1 -1
  31. package/_cjs/clients/transports/http.js +5 -1
  32. package/_cjs/clients/transports/http.js.map +1 -1
  33. package/_cjs/errors/node.js +1 -1
  34. package/_cjs/errors/node.js.map +1 -1
  35. package/_cjs/errors/request.js +20 -2
  36. package/_cjs/errors/request.js.map +1 -1
  37. package/_cjs/errors/typedData.js +3 -1
  38. package/_cjs/errors/typedData.js.map +1 -1
  39. package/_cjs/errors/version.js +1 -1
  40. package/_cjs/op-stack/abis.js +52 -0
  41. package/_cjs/op-stack/abis.js.map +1 -1
  42. package/_cjs/op-stack/actions/getTimeToFinalize.js +53 -4
  43. package/_cjs/op-stack/actions/getTimeToFinalize.js.map +1 -1
  44. package/_cjs/op-stack/actions/getTimeToProve.js +29 -2
  45. package/_cjs/op-stack/actions/getTimeToProve.js.map +1 -1
  46. package/_cjs/op-stack/actions/getWithdrawalStatus.js +20 -4
  47. package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  48. package/_cjs/op-stack/actions/waitToProve.js +28 -2
  49. package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
  50. package/_cjs/op-stack/errors/withdrawal.js +12 -1
  51. package/_cjs/op-stack/errors/withdrawal.js.map +1 -1
  52. package/_cjs/tempo/Account.js +6 -9
  53. package/_cjs/tempo/Account.js.map +1 -1
  54. package/_cjs/tempo/Addresses.js +1 -2
  55. package/_cjs/tempo/Addresses.js.map +1 -1
  56. package/_cjs/tempo/Formatters.js +13 -2
  57. package/_cjs/tempo/Formatters.js.map +1 -1
  58. package/_cjs/tempo/Relay.js.map +1 -1
  59. package/_cjs/tempo/Transaction.js.map +1 -1
  60. package/_cjs/tempo/accounts/Config.js +22 -12
  61. package/_cjs/tempo/accounts/Config.js.map +1 -1
  62. package/_cjs/tempo/actions/accessKey.js +8 -8
  63. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  64. package/_cjs/tempo/actions/accounts.js +5 -5
  65. package/_cjs/tempo/actions/accounts.js.map +1 -1
  66. package/_cjs/tempo/actions/amm.js +4 -4
  67. package/_cjs/tempo/actions/amm.js.map +1 -1
  68. package/_cjs/tempo/actions/channel.js +7 -7
  69. package/_cjs/tempo/actions/channel.js.map +1 -1
  70. package/_cjs/tempo/actions/dex.js +14 -14
  71. package/_cjs/tempo/actions/dex.js.map +1 -1
  72. package/_cjs/tempo/actions/earn/deployment.js +3 -3
  73. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  74. package/_cjs/tempo/actions/earn.js +6 -6
  75. package/_cjs/tempo/actions/earn.js.map +1 -1
  76. package/_cjs/tempo/actions/fee.js +4 -4
  77. package/_cjs/tempo/actions/fee.js.map +1 -1
  78. package/_cjs/tempo/actions/nonce.js +1 -1
  79. package/_cjs/tempo/actions/nonce.js.map +1 -1
  80. package/_cjs/tempo/actions/policy.js +6 -6
  81. package/_cjs/tempo/actions/policy.js.map +1 -1
  82. package/_cjs/tempo/actions/propAmm.js +10 -10
  83. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  84. package/_cjs/tempo/actions/receivePolicy.js +6 -6
  85. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  86. package/_cjs/tempo/actions/reward.js +6 -6
  87. package/_cjs/tempo/actions/reward.js.map +1 -1
  88. package/_cjs/tempo/actions/token.js +21 -21
  89. package/_cjs/tempo/actions/token.js.map +1 -1
  90. package/_cjs/tempo/actions/validator.js +11 -11
  91. package/_cjs/tempo/actions/validator.js.map +1 -1
  92. package/_cjs/tempo/actions/virtualAddress.js +2 -2
  93. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  94. package/_cjs/tempo/chainConfig.js +11 -4
  95. package/_cjs/tempo/chainConfig.js.map +1 -1
  96. package/_cjs/tempo/internal/relay/accounts.js +42 -7
  97. package/_cjs/tempo/internal/relay/accounts.js.map +1 -1
  98. package/_cjs/tempo/internal/relay/feePayer.js +4 -1
  99. package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
  100. package/_cjs/utils/abi/getAbiItem.js +33 -12
  101. package/_cjs/utils/abi/getAbiItem.js.map +1 -1
  102. package/_cjs/utils/abi/parseEventLogs.js +18 -10
  103. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  104. package/_cjs/utils/authorization/serializeAuthorizationList.js +4 -1
  105. package/_cjs/utils/authorization/serializeAuthorizationList.js.map +1 -1
  106. package/_cjs/utils/buildRequest.js +25 -14
  107. package/_cjs/utils/buildRequest.js.map +1 -1
  108. package/_cjs/utils/data/isHex.js +3 -1
  109. package/_cjs/utils/data/isHex.js.map +1 -1
  110. package/_cjs/utils/hash/normalizeSignature.js +1 -1
  111. package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
  112. package/_cjs/utils/rpc/http.js +24 -4
  113. package/_cjs/utils/rpc/http.js.map +1 -1
  114. package/_cjs/utils/signature/compactSignatureToSignature.js +3 -2
  115. package/_cjs/utils/signature/compactSignatureToSignature.js.map +1 -1
  116. package/_cjs/utils/signature/hashTypedData.js +1 -2
  117. package/_cjs/utils/signature/hashTypedData.js.map +1 -1
  118. package/_cjs/utils/signature/signatureToCompactSignature.js +15 -7
  119. package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
  120. package/_cjs/utils/siwe/createSiweMessage.js +1 -1
  121. package/_cjs/utils/siwe/createSiweMessage.js.map +1 -1
  122. package/_cjs/utils/typedData.js +6 -7
  123. package/_cjs/utils/typedData.js.map +1 -1
  124. package/_cjs/utils/wait.js +1 -1
  125. package/_cjs/utils/wait.js.map +1 -1
  126. package/_esm/actions/public/fillTransaction.js +8 -3
  127. package/_esm/actions/public/fillTransaction.js.map +1 -1
  128. package/_esm/actions/public/waitForTransactionReceipt.js +101 -23
  129. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  130. package/_esm/actions/public/watchContractEvent.js +73 -36
  131. package/_esm/actions/public/watchContractEvent.js.map +1 -1
  132. package/_esm/actions/public/watchEvent.js +73 -35
  133. package/_esm/actions/public/watchEvent.js.map +1 -1
  134. package/_esm/actions/token/approve.js +1 -1
  135. package/_esm/actions/token/approve.js.map +1 -1
  136. package/_esm/actions/token/getAllowance.js +1 -1
  137. package/_esm/actions/token/getAllowance.js.map +1 -1
  138. package/_esm/actions/token/getBalance.js +1 -1
  139. package/_esm/actions/token/getBalance.js.map +1 -1
  140. package/_esm/actions/token/getTotalSupply.js +1 -1
  141. package/_esm/actions/token/getTotalSupply.js.map +1 -1
  142. package/_esm/actions/token/transfer.js +1 -1
  143. package/_esm/actions/token/transfer.js.map +1 -1
  144. package/_esm/actions/wallet/sendCalls.js +1 -1
  145. package/_esm/actions/wallet/sendCalls.js.map +1 -1
  146. package/_esm/chains/definitions/molibra.js +18 -0
  147. package/_esm/chains/definitions/molibra.js.map +1 -0
  148. package/_esm/chains/definitions/valuechain.js +20 -0
  149. package/_esm/chains/definitions/valuechain.js.map +1 -0
  150. package/_esm/chains/definitions/valuechainTestnet.js +21 -0
  151. package/_esm/chains/definitions/valuechainTestnet.js.map +1 -0
  152. package/_esm/chains/index.js +5 -0
  153. package/_esm/chains/index.js.map +1 -1
  154. package/_esm/clients/decorators/public.js.map +1 -1
  155. package/_esm/clients/transports/http.js +6 -1
  156. package/_esm/clients/transports/http.js.map +1 -1
  157. package/_esm/errors/node.js +1 -1
  158. package/_esm/errors/node.js.map +1 -1
  159. package/_esm/errors/request.js +22 -2
  160. package/_esm/errors/request.js.map +1 -1
  161. package/_esm/errors/typedData.js +3 -1
  162. package/_esm/errors/typedData.js.map +1 -1
  163. package/_esm/errors/version.js +1 -1
  164. package/_esm/op-stack/abis.js +52 -0
  165. package/_esm/op-stack/abis.js.map +1 -1
  166. package/_esm/op-stack/actions/getTimeToFinalize.js +64 -6
  167. package/_esm/op-stack/actions/getTimeToFinalize.js.map +1 -1
  168. package/_esm/op-stack/actions/getTimeToProve.js +30 -2
  169. package/_esm/op-stack/actions/getTimeToProve.js.map +1 -1
  170. package/_esm/op-stack/actions/getWithdrawalStatus.js +24 -5
  171. package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  172. package/_esm/op-stack/actions/waitToProve.js +30 -3
  173. package/_esm/op-stack/actions/waitToProve.js.map +1 -1
  174. package/_esm/op-stack/errors/withdrawal.js +10 -0
  175. package/_esm/op-stack/errors/withdrawal.js.map +1 -1
  176. package/_esm/tempo/Account.js +6 -9
  177. package/_esm/tempo/Account.js.map +1 -1
  178. package/_esm/tempo/Addresses.js +0 -2
  179. package/_esm/tempo/Addresses.js.map +1 -1
  180. package/_esm/tempo/Formatters.js +12 -2
  181. package/_esm/tempo/Formatters.js.map +1 -1
  182. package/_esm/tempo/Relay.js.map +1 -1
  183. package/_esm/tempo/Transaction.js.map +1 -1
  184. package/_esm/tempo/accounts/Config.js +28 -16
  185. package/_esm/tempo/accounts/Config.js.map +1 -1
  186. package/_esm/tempo/actions/accessKey.js +8 -8
  187. package/_esm/tempo/actions/accessKey.js.map +1 -1
  188. package/_esm/tempo/actions/accounts.js +7 -7
  189. package/_esm/tempo/actions/accounts.js.map +1 -1
  190. package/_esm/tempo/actions/amm.js +4 -4
  191. package/_esm/tempo/actions/amm.js.map +1 -1
  192. package/_esm/tempo/actions/channel.js +7 -7
  193. package/_esm/tempo/actions/channel.js.map +1 -1
  194. package/_esm/tempo/actions/dex.js +14 -14
  195. package/_esm/tempo/actions/dex.js.map +1 -1
  196. package/_esm/tempo/actions/earn/deployment.js +3 -3
  197. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  198. package/_esm/tempo/actions/earn.js +6 -6
  199. package/_esm/tempo/actions/earn.js.map +1 -1
  200. package/_esm/tempo/actions/fee.js +4 -4
  201. package/_esm/tempo/actions/fee.js.map +1 -1
  202. package/_esm/tempo/actions/nonce.js +1 -1
  203. package/_esm/tempo/actions/nonce.js.map +1 -1
  204. package/_esm/tempo/actions/policy.js +6 -6
  205. package/_esm/tempo/actions/policy.js.map +1 -1
  206. package/_esm/tempo/actions/propAmm.js +10 -10
  207. package/_esm/tempo/actions/propAmm.js.map +1 -1
  208. package/_esm/tempo/actions/receivePolicy.js +6 -6
  209. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  210. package/_esm/tempo/actions/reward.js +6 -6
  211. package/_esm/tempo/actions/reward.js.map +1 -1
  212. package/_esm/tempo/actions/token.js +21 -21
  213. package/_esm/tempo/actions/token.js.map +1 -1
  214. package/_esm/tempo/actions/validator.js +11 -11
  215. package/_esm/tempo/actions/validator.js.map +1 -1
  216. package/_esm/tempo/actions/virtualAddress.js +2 -2
  217. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  218. package/_esm/tempo/chainConfig.js +13 -4
  219. package/_esm/tempo/chainConfig.js.map +1 -1
  220. package/_esm/tempo/internal/relay/accounts.js +44 -7
  221. package/_esm/tempo/internal/relay/accounts.js.map +1 -1
  222. package/_esm/tempo/internal/relay/feePayer.js +4 -1
  223. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  224. package/_esm/utils/abi/getAbiItem.js +36 -14
  225. package/_esm/utils/abi/getAbiItem.js.map +1 -1
  226. package/_esm/utils/abi/parseEventLogs.js +25 -11
  227. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  228. package/_esm/utils/authorization/serializeAuthorizationList.js +7 -1
  229. package/_esm/utils/authorization/serializeAuthorizationList.js.map +1 -1
  230. package/_esm/utils/buildRequest.js +29 -15
  231. package/_esm/utils/buildRequest.js.map +1 -1
  232. package/_esm/utils/data/isHex.js +3 -1
  233. package/_esm/utils/data/isHex.js.map +1 -1
  234. package/_esm/utils/hash/normalizeSignature.js +1 -1
  235. package/_esm/utils/hash/normalizeSignature.js.map +1 -1
  236. package/_esm/utils/hash/toSignature.js +1 -1
  237. package/_esm/utils/hash/toSignatureHash.js +1 -1
  238. package/_esm/utils/rpc/http.js +29 -7
  239. package/_esm/utils/rpc/http.js.map +1 -1
  240. package/_esm/utils/signature/compactSignatureToSignature.js +3 -2
  241. package/_esm/utils/signature/compactSignatureToSignature.js.map +1 -1
  242. package/_esm/utils/signature/hashTypedData.js +1 -2
  243. package/_esm/utils/signature/hashTypedData.js.map +1 -1
  244. package/_esm/utils/signature/signatureToCompactSignature.js +16 -7
  245. package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
  246. package/_esm/utils/siwe/createSiweMessage.js +1 -1
  247. package/_esm/utils/siwe/createSiweMessage.js.map +1 -1
  248. package/_esm/utils/typedData.js +12 -8
  249. package/_esm/utils/typedData.js.map +1 -1
  250. package/_esm/utils/wait.js +2 -1
  251. package/_esm/utils/wait.js.map +1 -1
  252. package/_types/actions/getContract.d.ts +1 -1
  253. package/_types/actions/public/fillTransaction.d.ts.map +1 -1
  254. package/_types/actions/public/waitForTransactionReceipt.d.ts +31 -1
  255. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  256. package/_types/actions/public/watchContractEvent.d.ts +1 -1
  257. package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
  258. package/_types/actions/public/watchEvent.d.ts +1 -1
  259. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  260. package/_types/chains/definitions/molibra.d.ts +52 -0
  261. package/_types/chains/definitions/molibra.d.ts.map +1 -0
  262. package/_types/chains/definitions/tempo.d.ts +14 -6
  263. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  264. package/_types/chains/definitions/tempoDevnet.d.ts +14 -6
  265. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  266. package/_types/chains/definitions/tempoLocalnet.d.ts +14 -6
  267. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  268. package/_types/chains/definitions/tempoModerato.d.ts +14 -6
  269. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  270. package/_types/chains/definitions/valuechain.d.ts +53 -0
  271. package/_types/chains/definitions/valuechain.d.ts.map +1 -0
  272. package/_types/chains/definitions/valuechainTestnet.d.ts +53 -0
  273. package/_types/chains/definitions/valuechainTestnet.d.ts.map +1 -0
  274. package/_types/chains/index.d.ts +5 -0
  275. package/_types/chains/index.d.ts.map +1 -1
  276. package/_types/clients/decorators/public.d.ts +5 -2
  277. package/_types/clients/decorators/public.d.ts.map +1 -1
  278. package/_types/clients/transports/http.d.ts.map +1 -1
  279. package/_types/errors/node.d.ts.map +1 -1
  280. package/_types/errors/request.d.ts +7 -1
  281. package/_types/errors/request.d.ts.map +1 -1
  282. package/_types/errors/typedData.d.ts.map +1 -1
  283. package/_types/errors/version.d.ts +1 -1
  284. package/_types/op-stack/abis.d.ts +40 -0
  285. package/_types/op-stack/abis.d.ts.map +1 -1
  286. package/_types/op-stack/actions/getTimeToFinalize.d.ts +3 -2
  287. package/_types/op-stack/actions/getTimeToFinalize.d.ts.map +1 -1
  288. package/_types/op-stack/actions/getTimeToProve.d.ts +3 -1
  289. package/_types/op-stack/actions/getTimeToProve.d.ts.map +1 -1
  290. package/_types/op-stack/actions/getWithdrawalStatus.d.ts +2 -2
  291. package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
  292. package/_types/op-stack/actions/waitToProve.d.ts +3 -1
  293. package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
  294. package/_types/op-stack/errors/withdrawal.d.ts +8 -0
  295. package/_types/op-stack/errors/withdrawal.d.ts.map +1 -1
  296. package/_types/tempo/Account.d.ts +14 -5
  297. package/_types/tempo/Account.d.ts.map +1 -1
  298. package/_types/tempo/Addresses.d.ts +0 -2
  299. package/_types/tempo/Addresses.d.ts.map +1 -1
  300. package/_types/tempo/Formatters.d.ts +3 -0
  301. package/_types/tempo/Formatters.d.ts.map +1 -1
  302. package/_types/tempo/Relay.d.ts +20 -0
  303. package/_types/tempo/Relay.d.ts.map +1 -1
  304. package/_types/tempo/Transaction.d.ts +7 -2
  305. package/_types/tempo/Transaction.d.ts.map +1 -1
  306. package/_types/tempo/accounts/Config.d.ts +24 -2
  307. package/_types/tempo/accounts/Config.d.ts.map +1 -1
  308. package/_types/tempo/actions/accounts.d.ts +2 -2
  309. package/_types/tempo/chainConfig.d.ts +8 -3
  310. package/_types/tempo/chainConfig.d.ts.map +1 -1
  311. package/_types/tempo/internal/relay/accounts.d.ts.map +1 -1
  312. package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
  313. package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
  314. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  315. package/_types/utils/authorization/serializeAuthorizationList.d.ts.map +1 -1
  316. package/_types/utils/buildRequest.d.ts.map +1 -1
  317. package/_types/utils/data/isHex.d.ts +12 -1
  318. package/_types/utils/data/isHex.d.ts.map +1 -1
  319. package/_types/utils/hash/toSignature.d.ts +1 -1
  320. package/_types/utils/hash/toSignatureHash.d.ts +1 -1
  321. package/_types/utils/rpc/http.d.ts +2 -2
  322. package/_types/utils/rpc/http.d.ts.map +1 -1
  323. package/_types/utils/signature/compactSignatureToSignature.d.ts +2 -1
  324. package/_types/utils/signature/compactSignatureToSignature.d.ts.map +1 -1
  325. package/_types/utils/signature/hashTypedData.d.ts.map +1 -1
  326. package/_types/utils/signature/signatureToCompactSignature.d.ts +2 -1
  327. package/_types/utils/signature/signatureToCompactSignature.d.ts.map +1 -1
  328. package/_types/utils/typedData.d.ts.map +1 -1
  329. package/_types/utils/wait.d.ts.map +1 -1
  330. package/actions/getContract.ts +1 -1
  331. package/actions/public/fillTransaction.ts +12 -3
  332. package/actions/public/waitForTransactionReceipt.ts +164 -33
  333. package/actions/public/watchContractEvent.ts +82 -39
  334. package/actions/public/watchEvent.ts +82 -38
  335. package/actions/wallet/sendCalls.ts +1 -1
  336. package/chains/definitions/molibra.ts +18 -0
  337. package/chains/definitions/valuechain.ts +20 -0
  338. package/chains/definitions/valuechainTestnet.ts +21 -0
  339. package/chains/index.ts +5 -0
  340. package/clients/decorators/public.ts +5 -2
  341. package/clients/transports/http.ts +6 -1
  342. package/errors/node.ts +1 -1
  343. package/errors/request.ts +15 -1
  344. package/errors/typedData.ts +3 -1
  345. package/errors/version.ts +1 -1
  346. package/op-stack/abis.ts +52 -0
  347. package/op-stack/actions/getTimeToFinalize.ts +89 -10
  348. package/op-stack/actions/getTimeToProve.ts +43 -2
  349. package/op-stack/actions/getWithdrawalStatus.ts +30 -6
  350. package/op-stack/actions/waitToProve.ts +45 -3
  351. package/op-stack/errors/withdrawal.ts +17 -0
  352. package/package.json +2 -2
  353. package/tempo/Account.ts +20 -22
  354. package/tempo/Addresses.ts +0 -3
  355. package/tempo/Formatters.ts +19 -7
  356. package/tempo/Relay.ts +26 -0
  357. package/tempo/Transaction.ts +10 -2
  358. package/tempo/accounts/Config.ts +40 -25
  359. package/tempo/actions/accounts.ts +2 -2
  360. package/tempo/chainConfig.ts +15 -4
  361. package/tempo/internal/relay/accounts.ts +45 -9
  362. package/tempo/internal/relay/feePayer.ts +6 -1
  363. package/utils/abi/getAbiItem.ts +49 -17
  364. package/utils/abi/parseEventLogs.ts +32 -11
  365. package/utils/authorization/serializeAuthorizationList.ts +7 -1
  366. package/utils/buildRequest.ts +29 -14
  367. package/utils/data/isHex.ts +18 -1
  368. package/utils/hash/normalizeSignature.ts +1 -1
  369. package/utils/hash/toSignature.ts +1 -1
  370. package/utils/hash/toSignatureHash.ts +1 -1
  371. package/utils/rpc/http.ts +33 -8
  372. package/utils/signature/compactSignatureToSignature.ts +4 -2
  373. package/utils/signature/hashTypedData.ts +1 -2
  374. package/utils/signature/signatureToCompactSignature.ts +13 -8
  375. package/utils/siwe/createSiweMessage.ts +1 -1
  376. package/utils/typedData.ts +11 -8
  377. package/utils/wait.ts +8 -4
@@ -327,7 +327,7 @@ export type GetContractReturnType<
327
327
  *
328
328
  * This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
329
329
  *
330
- * `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
330
+ * `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
331
331
  *
332
332
  * @example
333
333
  * import { createPublicClient, getContract, http, parseAbi } from 'viem'
@@ -202,7 +202,8 @@ export async function fillTransaction<
202
202
  if (
203
203
  hasFeePayerSignature &&
204
204
  typeof nonce !== 'undefined' &&
205
- transaction.nonce !== nonce
205
+ // Tempo formats nonces as bigints (TIP-1106 discriminators exceed 2^53).
206
+ BigInt(transaction.nonce) !== BigInt(nonce)
206
207
  )
207
208
  throw new FeePayerNonceMismatchError({
208
209
  filledNonce: transaction.nonce,
@@ -226,8 +227,16 @@ export async function fillTransaction<
226
227
  if (transaction.maxPriorityFeePerGas)
227
228
  transaction.maxPriorityFeePerGas =
228
229
  parameters.maxPriorityFeePerGas ?? transaction.maxPriorityFeePerGas
229
- if (typeof transaction.nonce !== 'undefined')
230
- transaction.nonce = parameters.nonce ?? transaction.nonce
230
+ if (
231
+ typeof transaction.nonce !== 'undefined' &&
232
+ typeof parameters.nonce !== 'undefined'
233
+ )
234
+ // Keep the formatter's representation (Tempo formats nonces as bigints).
235
+ transaction.nonce = (
236
+ typeof transaction.nonce === 'bigint'
237
+ ? BigInt(parameters.nonce)
238
+ : parameters.nonce
239
+ ) as typeof transaction.nonce
231
240
 
232
241
  // Build fee multiplier function.
233
242
  const feeMultiplier = await (async () => {
@@ -1,6 +1,12 @@
1
+ import type { Address } from 'abitype'
2
+
1
3
  import type { Client } from '../../clients/createClient.js'
2
4
  import type { Transport } from '../../clients/transports/createTransport.js'
3
5
  import { BlockNotFoundError } from '../../errors/block.js'
6
+ import {
7
+ MethodNotFoundRpcError,
8
+ MethodNotSupportedRpcError,
9
+ } from '../../errors/rpc.js'
4
10
  import {
5
11
  TransactionNotFoundError,
6
12
  TransactionReceiptNotFoundError,
@@ -9,7 +15,7 @@ import {
9
15
  } from '../../errors/transaction.js'
10
16
  import type { ErrorType } from '../../errors/utils.js'
11
17
  import type { Chain } from '../../types/chain.js'
12
- import type { Hash } from '../../types/misc.js'
18
+ import type { Hash, Hex } from '../../types/misc.js'
13
19
  import type { Transaction } from '../../types/transaction.js'
14
20
  import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
15
21
  import { getAction } from '../../utils/getAction.js'
@@ -73,6 +79,34 @@ export type WaitForTransactionReceiptParameters<
73
79
  * @default client.pollingInterval
74
80
  */
75
81
  pollingInterval?: number | undefined
82
+ /**
83
+ * The sender and nonce of the transaction, and optionally the fields it was
84
+ * sent with.
85
+ *
86
+ * A node can drop a replaced transaction before the wait first reads it, and
87
+ * `hash` alone does not identify its sender and nonce. With them, the wait
88
+ * looks up the transaction in its nonce slot (`eth_getTransactionBySenderAndNonce`).
89
+ * Without that method, it scans each block from the one it starts on, which
90
+ * misses a replacement mined earlier.
91
+ *
92
+ * `onReplaced` receives these fields, with `hash`, as `replacedTransaction`.
93
+ * Ignored on chains with their own replacement keys (e.g. Tempo nonce lanes),
94
+ * where a sender and nonce do not identify a nonce slot.
95
+ */
96
+ replacement?:
97
+ | {
98
+ /** The sender of the transaction. */
99
+ from: Address
100
+ /** The calldata of the transaction. Identifies a repriced replacement. */
101
+ input?: Hex | undefined
102
+ /** The nonce of the transaction. */
103
+ nonce: number
104
+ /** The recipient of the transaction. Identifies a repriced replacement. */
105
+ to?: Address | null | undefined
106
+ /** The value of the transaction (in wei). Identifies a repriced replacement. */
107
+ value?: bigint | undefined
108
+ }
109
+ | undefined
76
110
  /**
77
111
  * Number of times to retry if the transaction or block is not found.
78
112
  * @default 6 (exponential backoff)
@@ -110,6 +144,9 @@ export type WaitForTransactionReceiptErrorType =
110
144
  * - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions
111
145
  * - Checks if one of the Transactions is a replacement
112
146
  * - If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
147
+ * - If the Transaction is not found and `replacement` is provided:
148
+ * - Calls `eth_getTransactionBySenderAndNonce` to find the Transaction in its nonce slot
149
+ * - If it is a replacement, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
113
150
  *
114
151
  * The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).
115
152
  *
@@ -154,6 +191,12 @@ export async function waitForTransactionReceipt<
154
191
  timeout = 180_000,
155
192
  } = parameters
156
193
 
194
+ // On chains with their own replacement keys, a sender and nonce do not
195
+ // identify a nonce slot.
196
+ const replacement = client.chain?.transactionReplacement?.getKey
197
+ ? undefined
198
+ : parameters.replacement
199
+
157
200
  const getReplacementKey = (transaction: Transaction) =>
158
201
  client.chain?.transactionReplacement?.getKey?.(transaction) ??
159
202
  String(transaction.nonce)
@@ -176,14 +219,16 @@ export async function waitForTransactionReceipt<
176
219
  checkReplacement,
177
220
  confirmations,
178
221
  pollingInterval,
222
+ replacement,
179
223
  retryCount,
180
224
  timeout,
181
225
  },
182
226
  ])
183
227
 
184
228
  let transaction: GetTransactionReturnType<chain> | undefined
185
- let replacedTransaction: GetTransactionReturnType<chain> | undefined
186
229
  let receipt: GetTransactionReceiptReturnType<chain> | undefined
230
+ // A found replacement, kept while `receipt` waits for confirmations.
231
+ let replacementResponse: ReplacementReturnType<chain> | undefined
187
232
  let retrying = false
188
233
 
189
234
  let _unobserve: () => void
@@ -249,7 +294,10 @@ export async function waitForTransactionReceipt<
249
294
  )
250
295
  return
251
296
 
252
- done(() => emit.resolve(receipt!))
297
+ done(() => {
298
+ if (replacementResponse) emit.onReplaced?.(replacementResponse)
299
+ emit.resolve(receipt!)
300
+ })
253
301
  return
254
302
  }
255
303
 
@@ -271,6 +319,10 @@ export async function waitForTransactionReceipt<
271
319
  {
272
320
  delay: retryDelay,
273
321
  retryCount,
322
+ // A dropped transaction does not reappear, so a known
323
+ // sender and nonce are looked up without the retries.
324
+ shouldRetry: ({ error }) =>
325
+ !(replacement && error instanceof TransactionNotFoundError),
274
326
  },
275
327
  )
276
328
  retrying = false
@@ -299,22 +351,104 @@ export async function waitForTransactionReceipt<
299
351
  err instanceof TransactionNotFoundError ||
300
352
  err instanceof TransactionReceiptNotFoundError
301
353
  ) {
302
- if (!transaction) {
303
- retrying = false
304
- return
305
- }
354
+ retrying = false
355
+
356
+ // A node that dropped the transaction no longer returns it, so
357
+ // the known fields of it stand in. RPC hashes are lowercase.
358
+ const replaced =
359
+ transaction ??
360
+ (checkReplacement && replacement
361
+ ? ({
362
+ ...replacement,
363
+ hash: hash.toLowerCase(),
364
+ } as GetTransactionReturnType<chain>)
365
+ : undefined)
366
+ if (!replaced) return
306
367
 
307
368
  // The transaction was seen mined, so it consumed its nonce slot
308
369
  // and was not replaced: its receipt is not indexed yet. The
309
370
  // transaction is fetched once, so one first seen pending is
310
371
  // matched by replacement key instead.
311
- if (transaction.blockNumber) {
312
- retrying = false
313
- return
314
- }
372
+ if (replaced.blockNumber) return
315
373
 
316
374
  try {
317
- replacedTransaction = transaction
375
+ // Look up the transaction in the nonce slot, since the block
376
+ // scan below misses a replacement mined before the wait starts.
377
+ if (!transaction) {
378
+ retrying = true
379
+ const found = (await getAction(
380
+ client,
381
+ getTransaction,
382
+ 'getTransaction',
383
+ )({
384
+ nonce: replaced.nonce,
385
+ sender: replaced.from,
386
+ }).catch((error) => {
387
+ // Without the method, only the block scan runs from now
388
+ // on. Other errors retry the lookup on the next block.
389
+ if (
390
+ error instanceof MethodNotFoundRpcError ||
391
+ error instanceof MethodNotSupportedRpcError
392
+ )
393
+ transaction = replaced
394
+ return undefined
395
+ })) as GetTransactionReturnType<chain> | undefined
396
+ retrying = false
397
+
398
+ // The transaction still holds its nonce slot.
399
+ if (
400
+ (found as Transaction | undefined)?.hash.toLowerCase() ===
401
+ replaced.hash
402
+ ) {
403
+ transaction = found
404
+ return
405
+ }
406
+
407
+ // Another transaction holds the nonce slot, so it replaced
408
+ // this one. A pending replacement has no receipt yet.
409
+ if (found) {
410
+ const replacementReceipt = await getAction(
411
+ client,
412
+ getTransactionReceipt,
413
+ 'getTransactionReceipt',
414
+ )({ hash: found.hash }).catch((error) => {
415
+ if (error instanceof TransactionReceiptNotFoundError)
416
+ return undefined
417
+ throw error
418
+ })
419
+ if (!replacementReceipt) return
420
+
421
+ receipt = replacementReceipt
422
+ replacementResponse = {
423
+ reason:
424
+ client.chain?.transactionReplacement?.getReason?.({
425
+ replaced,
426
+ replacement: found,
427
+ }) ??
428
+ getReplacementReason(
429
+ replaced as Transaction,
430
+ found as Transaction,
431
+ ),
432
+ replacedTransaction: replaced as Transaction,
433
+ transaction: found as Transaction,
434
+ transactionReceipt: receipt,
435
+ }
436
+
437
+ // Check if we have enough confirmations. If not, continue polling.
438
+ if (
439
+ confirmations > 1 &&
440
+ (!receipt.blockNumber ||
441
+ blockNumber - receipt.blockNumber + 1n < confirmations)
442
+ )
443
+ return
444
+
445
+ done(() => {
446
+ emit.onReplaced?.(replacementResponse!)
447
+ emit.resolve(receipt!)
448
+ })
449
+ return
450
+ }
451
+ }
318
452
 
319
453
  // Let's retrieve the transactions from the current block.
320
454
  // We need to retry as some RPC Providers may be slow to sync
@@ -339,15 +473,13 @@ export async function waitForTransactionReceipt<
339
473
  )
340
474
  retrying = false
341
475
 
342
- const replacedKey = getReplacementKey(
343
- replacedTransaction as Transaction,
344
- )
476
+ const replacedKey = getReplacementKey(replaced as Transaction)
345
477
  const replacementTransaction = (
346
478
  block.transactions as {} as Transaction[]
347
479
  ).find(
348
480
  (candidate) =>
349
- isAddressEqual(candidate.from, replacedTransaction!.from) &&
350
- candidate.hash !== replacedTransaction!.hash &&
481
+ isAddressEqual(candidate.from, replaced.from) &&
482
+ candidate.hash !== replaced.hash &&
351
483
  getReplacementKey(candidate) === replacedKey,
352
484
  )
353
485
 
@@ -362,6 +494,20 @@ export async function waitForTransactionReceipt<
362
494
  )({
363
495
  hash: replacementTransaction.hash,
364
496
  })
497
+ replacementResponse = {
498
+ reason:
499
+ client.chain?.transactionReplacement?.getReason?.({
500
+ replaced,
501
+ replacement: replacementTransaction,
502
+ }) ??
503
+ getReplacementReason(
504
+ replaced as Transaction,
505
+ replacementTransaction,
506
+ ),
507
+ replacedTransaction: replaced as Transaction,
508
+ transaction: replacementTransaction,
509
+ transactionReceipt: receipt,
510
+ }
365
511
 
366
512
  // Check if we have enough confirmations. If not, continue polling.
367
513
  if (
@@ -371,23 +517,8 @@ export async function waitForTransactionReceipt<
371
517
  )
372
518
  return
373
519
 
374
- const reason =
375
- client.chain?.transactionReplacement?.getReason?.({
376
- replaced: replacedTransaction,
377
- replacement: replacementTransaction,
378
- }) ??
379
- getReplacementReason(
380
- replacedTransaction as Transaction,
381
- replacementTransaction,
382
- )
383
-
384
520
  done(() => {
385
- emit.onReplaced?.({
386
- reason,
387
- replacedTransaction: replacedTransaction! as any,
388
- transaction: replacementTransaction,
389
- transactionReceipt: receipt!,
390
- })
521
+ emit.onReplaced?.(replacementResponse!)
391
522
  emit.resolve(receipt!)
392
523
  })
393
524
  } catch (err_) {
@@ -6,6 +6,8 @@ import {
6
6
  DecodeLogDataMismatch,
7
7
  DecodeLogTopicsMismatch,
8
8
  } from '../../errors/abi.js'
9
+ import { BaseError } from '../../errors/base.js'
10
+ import { HttpRequestError, RpcRequestError } from '../../errors/request.js'
9
11
  import { InvalidInputRpcError } from '../../errors/rpc.js'
10
12
  import type { ErrorType } from '../../errors/utils.js'
11
13
  import type { BlockNumber } from '../../types/block.js'
@@ -106,7 +108,7 @@ export type WatchContractEventErrorType =
106
108
  *
107
109
  * This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
108
110
  *
109
- * `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
111
+ * `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchContractEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
110
112
  *
111
113
  * @param client - Client to use
112
114
  * @param parameters - {@link WatchContractEventParameters}
@@ -185,11 +187,34 @@ export function watchContractEvent<
185
187
  ])
186
188
 
187
189
  return observe(observerId, { onLogs, onError }, (emit) => {
188
- let previousBlockNumber: bigint
189
- if (fromBlock !== undefined) previousBlockNumber = fromBlock - 1n
190
+ let active = true
191
+ let previousBlockNumber =
192
+ fromBlock === undefined ? undefined : fromBlock - 1n
190
193
  let filter: Filter<'event', abi, eventName> | undefined
191
194
  let initialized = false
192
195
 
196
+ const emitLogs = (logs: Log[]) => {
197
+ if (logs.length === 0) return
198
+ if (batch) emit.onLogs(logs as any)
199
+ else for (const log of logs) emit.onLogs([log] as any)
200
+ }
201
+
202
+ // Fetches the logs of the blocks from `from` to `to`, inclusive.
203
+ const getLogsInRange = (from: bigint, to: bigint) =>
204
+ getAction(
205
+ client,
206
+ getContractEvents,
207
+ 'getContractEvents',
208
+ )({
209
+ abi,
210
+ address,
211
+ args,
212
+ eventName,
213
+ fromBlock: from,
214
+ toBlock: to,
215
+ strict,
216
+ } as {} as GetContractEventsParameters)
217
+
193
218
  const unwatch = poll(
194
219
  async () => {
195
220
  if (!initialized) {
@@ -208,54 +233,55 @@ export function watchContractEvent<
208
233
  })) as Filter<'event', abi, eventName>
209
234
  } catch {}
210
235
  initialized = true
211
- return
236
+ if (filter) return
212
237
  }
213
238
 
214
239
  try {
215
- let logs: Log[]
216
240
  if (filter) {
217
- logs = await getAction(
241
+ const logs = await getAction(
218
242
  client,
219
243
  getFilterChanges,
220
244
  'getFilterChanges',
221
245
  )({ filter })
222
- } else {
223
- // If the filter doesn't exist, we will fall back to use `getLogs`.
224
- // The fall back exists because some RPC Providers do not support filters.
246
+ emitLogs(logs)
247
+ return
248
+ }
225
249
 
226
- // Fetch the block number to use for `getLogs`.
227
- const blockNumber = await getAction(
228
- client,
229
- getBlockNumber,
230
- 'getBlockNumber',
231
- )({})
250
+ // If the filter doesn't exist, we will fall back to use `getLogs`.
251
+ // The fall back exists because some RPC Providers do not support filters.
252
+ const blockNumber = await getAction(
253
+ client,
254
+ getBlockNumber,
255
+ 'getBlockNumber',
256
+ )({})
232
257
 
233
- // If the block number has changed, we will need to fetch the logs.
234
- // If the block number doesn't exist, we are yet to reach the first poll interval,
235
- // so do not emit any logs.
236
- if (previousBlockNumber && previousBlockNumber < blockNumber) {
237
- logs = await getAction(
238
- client,
239
- getContractEvents,
240
- 'getContractEvents',
241
- )({
242
- abi,
243
- address,
244
- args,
245
- eventName,
246
- fromBlock: previousBlockNumber + 1n,
247
- toBlock: blockNumber,
248
- strict,
249
- } as {} as GetContractEventsParameters)
250
- } else {
251
- logs = []
258
+ // Without `fromBlock`, start watching from the current block.
259
+ previousBlockNumber ??= blockNumber
260
+
261
+ // RPC Providers limit `eth_getLogs` by block range, log count or response
262
+ // size. `size` is the most blocks to request at once: it starts with all
263
+ // new blocks and halves whenever a request fails.
264
+ let size = blockNumber - previousBlockNumber
265
+ while (previousBlockNumber < blockNumber) {
266
+ const from = previousBlockNumber + 1n
267
+ const end: bigint = previousBlockNumber + size
268
+ const to = end < blockNumber ? end : blockNumber
269
+
270
+ const logs = await getLogsInRange(from, to).catch((error) => {
271
+ // A single block cannot be split, and a smaller range does not
272
+ // help when the RPC Provider is unreachable or rejects the client.
273
+ if (from === to || !isRangeError(error)) throw error
274
+ })
275
+ if (!active) return
276
+ if (!logs) {
277
+ size = (to - from + 1n) / 2n
278
+ continue
252
279
  }
253
- previousBlockNumber = blockNumber
254
- }
255
280
 
256
- if (logs.length === 0) return
257
- if (batch) emit.onLogs(logs as any)
258
- else for (const log of logs) emit.onLogs([log] as any)
281
+ // Only move past blocks whose logs were fetched, so none are skipped.
282
+ previousBlockNumber = to
283
+ emitLogs(logs)
284
+ }
259
285
  } catch (err) {
260
286
  // If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
261
287
  // Reinitialize the filter when this occurs
@@ -271,6 +297,7 @@ export function watchContractEvent<
271
297
  )
272
298
 
273
299
  return async () => {
300
+ active = false
274
301
  if (filter)
275
302
  await getAction(
276
303
  client,
@@ -377,3 +404,19 @@ export function watchContractEvent<
377
404
 
378
405
  return enablePolling ? pollContractEvent() : subscribeContractEvent()
379
406
  }
407
+
408
+ /** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
409
+ function isRangeError(error: unknown) {
410
+ if (!(error instanceof BaseError)) return true
411
+ const cause = error.walk(
412
+ (err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
413
+ ) as HttpRequestError | RpcRequestError | null
414
+ if (!cause) return true
415
+ // Rate limited.
416
+ if (cause instanceof RpcRequestError && cause.code === 429) return false
417
+ // Unreachable.
418
+ if (cause instanceof HttpRequestError && cause.status === undefined)
419
+ return false
420
+ // Unauthorized, forbidden or rate limited.
421
+ return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
422
+ }