viem 2.53.1 → 2.54.0

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 (441) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/_cjs/actions/index.js +3 -2
  3. package/_cjs/actions/index.js.map +1 -1
  4. package/_cjs/actions/token/approve.js +62 -0
  5. package/_cjs/actions/token/approve.js.map +1 -0
  6. package/_cjs/actions/token/approveSync.js +25 -0
  7. package/_cjs/actions/token/approveSync.js.map +1 -0
  8. package/_cjs/actions/token/getAllowance.js +32 -0
  9. package/_cjs/actions/token/getAllowance.js.map +1 -0
  10. package/_cjs/actions/token/getBalance.js +41 -0
  11. package/_cjs/actions/token/getBalance.js.map +1 -0
  12. package/_cjs/actions/token/getMetadata.js +40 -0
  13. package/_cjs/actions/token/getMetadata.js.map +1 -0
  14. package/_cjs/actions/token/getTotalSupply.js +32 -0
  15. package/_cjs/actions/token/getTotalSupply.js.map +1 -0
  16. package/_cjs/actions/token/index.js +20 -0
  17. package/_cjs/actions/token/index.js.map +1 -0
  18. package/_cjs/actions/token/internal.js +125 -0
  19. package/_cjs/actions/token/internal.js.map +1 -0
  20. package/_cjs/actions/token/transfer.js +70 -0
  21. package/_cjs/actions/token/transfer.js.map +1 -0
  22. package/_cjs/actions/token/transferSync.js +25 -0
  23. package/_cjs/actions/token/transferSync.js.map +1 -0
  24. package/_cjs/chains/definitions/battlechain.js +31 -0
  25. package/_cjs/chains/definitions/battlechain.js.map +1 -0
  26. package/_cjs/chains/definitions/marooTestnet.js +30 -0
  27. package/_cjs/chains/definitions/marooTestnet.js.map +1 -0
  28. package/_cjs/chains/index.js +18 -14
  29. package/_cjs/chains/index.js.map +1 -1
  30. package/_cjs/clients/createClient.js +39 -1
  31. package/_cjs/clients/createClient.js.map +1 -1
  32. package/_cjs/clients/createPublicClient.js.map +1 -1
  33. package/_cjs/clients/createWalletClient.js.map +1 -1
  34. package/_cjs/clients/decorators/public.js +11 -0
  35. package/_cjs/clients/decorators/public.js.map +1 -1
  36. package/_cjs/clients/decorators/wallet.js +8 -0
  37. package/_cjs/clients/decorators/wallet.js.map +1 -1
  38. package/_cjs/clients/transports/http.js +2 -1
  39. package/_cjs/clients/transports/http.js.map +1 -1
  40. package/_cjs/errors/encoding.js +9 -1
  41. package/_cjs/errors/encoding.js.map +1 -1
  42. package/_cjs/errors/request.js +24 -1
  43. package/_cjs/errors/request.js.map +1 -1
  44. package/_cjs/errors/transaction.js +9 -1
  45. package/_cjs/errors/transaction.js.map +1 -1
  46. package/_cjs/errors/version.js +1 -1
  47. package/_cjs/index.js +9 -6
  48. package/_cjs/index.js.map +1 -1
  49. package/_cjs/tempo/Client.js.map +1 -1
  50. package/_cjs/tempo/Decorator.js +234 -215
  51. package/_cjs/tempo/Decorator.js.map +1 -1
  52. package/_cjs/tempo/actions/token.js +210 -112
  53. package/_cjs/tempo/actions/token.js.map +1 -1
  54. package/_cjs/tempo/internal/utils.js +108 -0
  55. package/_cjs/tempo/internal/utils.js.map +1 -1
  56. package/_cjs/tokens/defineToken.js +21 -0
  57. package/_cjs/tokens/defineToken.js.map +1 -0
  58. package/_cjs/tokens/definitions/alphausd.js +14 -0
  59. package/_cjs/tokens/definitions/alphausd.js.map +1 -0
  60. package/_cjs/tokens/definitions/betausd.js +14 -0
  61. package/_cjs/tokens/definitions/betausd.js.map +1 -0
  62. package/_cjs/tokens/definitions/brla.js +14 -0
  63. package/_cjs/tokens/definitions/brla.js.map +1 -0
  64. package/_cjs/tokens/definitions/cbbtc.js +14 -0
  65. package/_cjs/tokens/definitions/cbbtc.js.map +1 -0
  66. package/_cjs/tokens/definitions/chfau.js +14 -0
  67. package/_cjs/tokens/definitions/chfau.js.map +1 -0
  68. package/_cjs/tokens/definitions/cusd.js +14 -0
  69. package/_cjs/tokens/definitions/cusd.js.map +1 -0
  70. package/_cjs/tokens/definitions/dlusd.js +14 -0
  71. package/_cjs/tokens/definitions/dlusd.js.map +1 -0
  72. package/_cjs/tokens/definitions/eurau.js +14 -0
  73. package/_cjs/tokens/definitions/eurau.js.map +1 -0
  74. package/_cjs/tokens/definitions/eurce.js +15 -0
  75. package/_cjs/tokens/definitions/eurce.js.map +1 -0
  76. package/_cjs/tokens/definitions/frxusd.js +14 -0
  77. package/_cjs/tokens/definitions/frxusd.js.map +1 -0
  78. package/_cjs/tokens/definitions/gbpa.js +14 -0
  79. package/_cjs/tokens/definitions/gbpa.js.map +1 -0
  80. package/_cjs/tokens/definitions/gusd.js +14 -0
  81. package/_cjs/tokens/definitions/gusd.js.map +1 -0
  82. package/_cjs/tokens/definitions/iusd.js +14 -0
  83. package/_cjs/tokens/definitions/iusd.js.map +1 -0
  84. package/_cjs/tokens/definitions/pathusd.js +15 -0
  85. package/_cjs/tokens/definitions/pathusd.js.map +1 -0
  86. package/_cjs/tokens/definitions/reusd.js +14 -0
  87. package/_cjs/tokens/definitions/reusd.js.map +1 -0
  88. package/_cjs/tokens/definitions/rusd.js +14 -0
  89. package/_cjs/tokens/definitions/rusd.js.map +1 -0
  90. package/_cjs/tokens/definitions/sbc.js +14 -0
  91. package/_cjs/tokens/definitions/sbc.js.map +1 -0
  92. package/_cjs/tokens/definitions/siusd.js +14 -0
  93. package/_cjs/tokens/definitions/siusd.js.map +1 -0
  94. package/_cjs/tokens/definitions/stcusd.js +14 -0
  95. package/_cjs/tokens/definitions/stcusd.js.map +1 -0
  96. package/_cjs/tokens/definitions/susde.js +14 -0
  97. package/_cjs/tokens/definitions/susde.js.map +1 -0
  98. package/_cjs/tokens/definitions/syrupusdc.js +14 -0
  99. package/_cjs/tokens/definitions/syrupusdc.js.map +1 -0
  100. package/_cjs/tokens/definitions/thetausd.js +14 -0
  101. package/_cjs/tokens/definitions/thetausd.js.map +1 -0
  102. package/_cjs/tokens/definitions/usd1.js +14 -0
  103. package/_cjs/tokens/definitions/usd1.js.map +1 -0
  104. package/_cjs/tokens/definitions/usdb.js +14 -0
  105. package/_cjs/tokens/definitions/usdb.js.map +1 -0
  106. package/_cjs/tokens/definitions/usdc.js +41 -0
  107. package/_cjs/tokens/definitions/usdc.js.map +1 -0
  108. package/_cjs/tokens/definitions/usdce.js +15 -0
  109. package/_cjs/tokens/definitions/usdce.js.map +1 -0
  110. package/_cjs/tokens/definitions/usde.js +14 -0
  111. package/_cjs/tokens/definitions/usde.js.map +1 -0
  112. package/_cjs/tokens/definitions/usdt0.js +14 -0
  113. package/_cjs/tokens/definitions/usdt0.js.map +1 -0
  114. package/_cjs/tokens/definitions/wsrusd.js +14 -0
  115. package/_cjs/tokens/definitions/wsrusd.js.map +1 -0
  116. package/_cjs/tokens/index.js +64 -0
  117. package/_cjs/tokens/index.js.map +1 -0
  118. package/_cjs/utils/encoding/fromRlp.js +7 -4
  119. package/_cjs/utils/encoding/fromRlp.js.map +1 -1
  120. package/_cjs/utils/rpc/http.js +58 -3
  121. package/_cjs/utils/rpc/http.js.map +1 -1
  122. package/_cjs/utils/transaction/parseTransaction.js +4 -1
  123. package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
  124. package/_esm/actions/index.js +1 -0
  125. package/_esm/actions/index.js.map +1 -1
  126. package/_esm/actions/token/approve.js +123 -0
  127. package/_esm/actions/token/approve.js.map +1 -0
  128. package/_esm/actions/token/approveSync.js +50 -0
  129. package/_esm/actions/token/approveSync.js.map +1 -0
  130. package/_esm/actions/token/getAllowance.js +62 -0
  131. package/_esm/actions/token/getAllowance.js.map +1 -0
  132. package/_esm/actions/token/getBalance.js +70 -0
  133. package/_esm/actions/token/getBalance.js.map +1 -0
  134. package/_esm/actions/token/getMetadata.js +60 -0
  135. package/_esm/actions/token/getMetadata.js.map +1 -0
  136. package/_esm/actions/token/getTotalSupply.js +60 -0
  137. package/_esm/actions/token/getTotalSupply.js.map +1 -0
  138. package/_esm/actions/token/index.js +10 -0
  139. package/_esm/actions/token/index.js.map +1 -0
  140. package/_esm/actions/token/internal.js +188 -0
  141. package/_esm/actions/token/internal.js.map +1 -0
  142. package/_esm/actions/token/transfer.js +147 -0
  143. package/_esm/actions/token/transfer.js.map +1 -0
  144. package/_esm/actions/token/transferSync.js +54 -0
  145. package/_esm/actions/token/transferSync.js.map +1 -0
  146. package/_esm/chains/definitions/battlechain.js +28 -0
  147. package/_esm/chains/definitions/battlechain.js.map +1 -0
  148. package/_esm/chains/definitions/marooTestnet.js +27 -0
  149. package/_esm/chains/definitions/marooTestnet.js.map +1 -0
  150. package/_esm/chains/index.js +2 -0
  151. package/_esm/chains/index.js.map +1 -1
  152. package/_esm/clients/createClient.js +53 -1
  153. package/_esm/clients/createClient.js.map +1 -1
  154. package/_esm/clients/createPublicClient.js.map +1 -1
  155. package/_esm/clients/createWalletClient.js.map +1 -1
  156. package/_esm/clients/decorators/public.js +17 -0
  157. package/_esm/clients/decorators/public.js.map +1 -1
  158. package/_esm/clients/decorators/wallet.js +8 -0
  159. package/_esm/clients/decorators/wallet.js.map +1 -1
  160. package/_esm/clients/transports/http.js +2 -1
  161. package/_esm/clients/transports/http.js.map +1 -1
  162. package/_esm/errors/encoding.js +7 -0
  163. package/_esm/errors/encoding.js.map +1 -1
  164. package/_esm/errors/request.js +22 -0
  165. package/_esm/errors/request.js.map +1 -1
  166. package/_esm/errors/transaction.js +7 -0
  167. package/_esm/errors/transaction.js.map +1 -1
  168. package/_esm/errors/version.js +1 -1
  169. package/_esm/index.js +3 -3
  170. package/_esm/index.js.map +1 -1
  171. package/_esm/tempo/Client.js.map +1 -1
  172. package/_esm/tempo/Decorator.js +234 -218
  173. package/_esm/tempo/Decorator.js.map +1 -1
  174. package/_esm/tempo/actions/token.js +335 -186
  175. package/_esm/tempo/actions/token.js.map +1 -1
  176. package/_esm/tempo/actions/wallet.js +1 -1
  177. package/_esm/tempo/internal/utils.js +154 -0
  178. package/_esm/tempo/internal/utils.js.map +1 -1
  179. package/_esm/tokens/defineToken.js +57 -0
  180. package/_esm/tokens/defineToken.js.map +1 -0
  181. package/_esm/tokens/definitions/alphausd.js +12 -0
  182. package/_esm/tokens/definitions/alphausd.js.map +1 -0
  183. package/_esm/tokens/definitions/betausd.js +12 -0
  184. package/_esm/tokens/definitions/betausd.js.map +1 -0
  185. package/_esm/tokens/definitions/brla.js +12 -0
  186. package/_esm/tokens/definitions/brla.js.map +1 -0
  187. package/_esm/tokens/definitions/cbbtc.js +12 -0
  188. package/_esm/tokens/definitions/cbbtc.js.map +1 -0
  189. package/_esm/tokens/definitions/chfau.js +12 -0
  190. package/_esm/tokens/definitions/chfau.js.map +1 -0
  191. package/_esm/tokens/definitions/cusd.js +12 -0
  192. package/_esm/tokens/definitions/cusd.js.map +1 -0
  193. package/_esm/tokens/definitions/dlusd.js +12 -0
  194. package/_esm/tokens/definitions/dlusd.js.map +1 -0
  195. package/_esm/tokens/definitions/eurau.js +12 -0
  196. package/_esm/tokens/definitions/eurau.js.map +1 -0
  197. package/_esm/tokens/definitions/eurce.js +13 -0
  198. package/_esm/tokens/definitions/eurce.js.map +1 -0
  199. package/_esm/tokens/definitions/frxusd.js +12 -0
  200. package/_esm/tokens/definitions/frxusd.js.map +1 -0
  201. package/_esm/tokens/definitions/gbpa.js +12 -0
  202. package/_esm/tokens/definitions/gbpa.js.map +1 -0
  203. package/_esm/tokens/definitions/gusd.js +12 -0
  204. package/_esm/tokens/definitions/gusd.js.map +1 -0
  205. package/_esm/tokens/definitions/iusd.js +12 -0
  206. package/_esm/tokens/definitions/iusd.js.map +1 -0
  207. package/_esm/tokens/definitions/pathusd.js +13 -0
  208. package/_esm/tokens/definitions/pathusd.js.map +1 -0
  209. package/_esm/tokens/definitions/reusd.js +12 -0
  210. package/_esm/tokens/definitions/reusd.js.map +1 -0
  211. package/_esm/tokens/definitions/rusd.js +12 -0
  212. package/_esm/tokens/definitions/rusd.js.map +1 -0
  213. package/_esm/tokens/definitions/sbc.js +12 -0
  214. package/_esm/tokens/definitions/sbc.js.map +1 -0
  215. package/_esm/tokens/definitions/siusd.js +12 -0
  216. package/_esm/tokens/definitions/siusd.js.map +1 -0
  217. package/_esm/tokens/definitions/stcusd.js +12 -0
  218. package/_esm/tokens/definitions/stcusd.js.map +1 -0
  219. package/_esm/tokens/definitions/susde.js +12 -0
  220. package/_esm/tokens/definitions/susde.js.map +1 -0
  221. package/_esm/tokens/definitions/syrupusdc.js +12 -0
  222. package/_esm/tokens/definitions/syrupusdc.js.map +1 -0
  223. package/_esm/tokens/definitions/thetausd.js +12 -0
  224. package/_esm/tokens/definitions/thetausd.js.map +1 -0
  225. package/_esm/tokens/definitions/usd1.js +12 -0
  226. package/_esm/tokens/definitions/usd1.js.map +1 -0
  227. package/_esm/tokens/definitions/usdb.js +12 -0
  228. package/_esm/tokens/definitions/usdb.js.map +1 -0
  229. package/_esm/tokens/definitions/usdc.js +67 -0
  230. package/_esm/tokens/definitions/usdc.js.map +1 -0
  231. package/_esm/tokens/definitions/usdce.js +13 -0
  232. package/_esm/tokens/definitions/usdce.js.map +1 -0
  233. package/_esm/tokens/definitions/usde.js +12 -0
  234. package/_esm/tokens/definitions/usde.js.map +1 -0
  235. package/_esm/tokens/definitions/usdt0.js +12 -0
  236. package/_esm/tokens/definitions/usdt0.js.map +1 -0
  237. package/_esm/tokens/definitions/wsrusd.js +12 -0
  238. package/_esm/tokens/definitions/wsrusd.js.map +1 -0
  239. package/_esm/tokens/index.js +32 -0
  240. package/_esm/tokens/index.js.map +1 -0
  241. package/_esm/utils/encoding/fromRlp.js +8 -5
  242. package/_esm/utils/encoding/fromRlp.js.map +1 -1
  243. package/_esm/utils/rpc/http.js +59 -4
  244. package/_esm/utils/rpc/http.js.map +1 -1
  245. package/_esm/utils/transaction/parseTransaction.js +5 -2
  246. package/_esm/utils/transaction/parseTransaction.js.map +1 -1
  247. package/_types/actions/index.d.ts +1 -0
  248. package/_types/actions/index.d.ts.map +1 -1
  249. package/_types/actions/token/approve.d.ts +253 -0
  250. package/_types/actions/token/approve.d.ts.map +1 -0
  251. package/_types/actions/token/approveSync.d.ts +57 -0
  252. package/_types/actions/token/approveSync.d.ts.map +1 -0
  253. package/_types/actions/token/getAllowance.d.ts +77 -0
  254. package/_types/actions/token/getAllowance.d.ts.map +1 -0
  255. package/_types/actions/token/getBalance.d.ts +69 -0
  256. package/_types/actions/token/getBalance.d.ts.map +1 -0
  257. package/_types/actions/token/getMetadata.d.ts +43 -0
  258. package/_types/actions/token/getMetadata.d.ts.map +1 -0
  259. package/_types/actions/token/getTotalSupply.d.ts +63 -0
  260. package/_types/actions/token/getTotalSupply.d.ts.map +1 -0
  261. package/_types/actions/token/index.d.ts +9 -0
  262. package/_types/actions/token/index.d.ts.map +1 -0
  263. package/_types/actions/token/internal.d.ts +168 -0
  264. package/_types/actions/token/internal.d.ts.map +1 -0
  265. package/_types/actions/token/transfer.d.ts +288 -0
  266. package/_types/actions/token/transfer.d.ts.map +1 -0
  267. package/_types/actions/token/transferSync.d.ts +61 -0
  268. package/_types/actions/token/transferSync.d.ts.map +1 -0
  269. package/_types/chains/definitions/battlechain.d.ts +447 -0
  270. package/_types/chains/definitions/battlechain.d.ts.map +1 -0
  271. package/_types/chains/definitions/marooTestnet.d.ts +49 -0
  272. package/_types/chains/definitions/marooTestnet.d.ts.map +1 -0
  273. package/_types/chains/index.d.ts +2 -0
  274. package/_types/chains/index.d.ts.map +1 -1
  275. package/_types/clients/createClient.d.ts +24 -6
  276. package/_types/clients/createClient.d.ts.map +1 -1
  277. package/_types/clients/createPublicClient.d.ts +4 -3
  278. package/_types/clients/createPublicClient.d.ts.map +1 -1
  279. package/_types/clients/createWalletClient.d.ts +4 -3
  280. package/_types/clients/createWalletClient.d.ts.map +1 -1
  281. package/_types/clients/decorators/public.d.ts +128 -3
  282. package/_types/clients/decorators/public.d.ts.map +1 -1
  283. package/_types/clients/decorators/wallet.d.ts +208 -3
  284. package/_types/clients/decorators/wallet.d.ts.map +1 -1
  285. package/_types/clients/transports/http.d.ts +2 -0
  286. package/_types/clients/transports/http.d.ts.map +1 -1
  287. package/_types/errors/encoding.d.ts +8 -0
  288. package/_types/errors/encoding.d.ts.map +1 -1
  289. package/_types/errors/request.d.ts +11 -0
  290. package/_types/errors/request.d.ts.map +1 -1
  291. package/_types/errors/transaction.d.ts +8 -0
  292. package/_types/errors/transaction.d.ts.map +1 -1
  293. package/_types/errors/version.d.ts +1 -1
  294. package/_types/index.d.ts +4 -3
  295. package/_types/index.d.ts.map +1 -1
  296. package/_types/tempo/Client.d.ts +1 -1
  297. package/_types/tempo/Client.d.ts.map +1 -1
  298. package/_types/tempo/Decorator.d.ts +88 -5
  299. package/_types/tempo/Decorator.d.ts.map +1 -1
  300. package/_types/tempo/actions/token.d.ts +223 -151
  301. package/_types/tempo/actions/token.d.ts.map +1 -1
  302. package/_types/tempo/actions/wallet.d.ts +3 -3
  303. package/_types/tempo/internal/types.d.ts +17 -0
  304. package/_types/tempo/internal/types.d.ts.map +1 -1
  305. package/_types/tempo/internal/utils.d.ts +73 -0
  306. package/_types/tempo/internal/utils.d.ts.map +1 -1
  307. package/_types/tokens/defineToken.d.ts +112 -0
  308. package/_types/tokens/defineToken.d.ts.map +1 -0
  309. package/_types/tokens/definitions/alphausd.d.ts +11 -0
  310. package/_types/tokens/definitions/alphausd.d.ts.map +1 -0
  311. package/_types/tokens/definitions/betausd.d.ts +11 -0
  312. package/_types/tokens/definitions/betausd.d.ts.map +1 -0
  313. package/_types/tokens/definitions/brla.d.ts +11 -0
  314. package/_types/tokens/definitions/brla.d.ts.map +1 -0
  315. package/_types/tokens/definitions/cbbtc.d.ts +11 -0
  316. package/_types/tokens/definitions/cbbtc.d.ts.map +1 -0
  317. package/_types/tokens/definitions/chfau.d.ts +11 -0
  318. package/_types/tokens/definitions/chfau.d.ts.map +1 -0
  319. package/_types/tokens/definitions/cusd.d.ts +11 -0
  320. package/_types/tokens/definitions/cusd.d.ts.map +1 -0
  321. package/_types/tokens/definitions/dlusd.d.ts +11 -0
  322. package/_types/tokens/definitions/dlusd.d.ts.map +1 -0
  323. package/_types/tokens/definitions/eurau.d.ts +11 -0
  324. package/_types/tokens/definitions/eurau.d.ts.map +1 -0
  325. package/_types/tokens/definitions/eurce.d.ts +12 -0
  326. package/_types/tokens/definitions/eurce.d.ts.map +1 -0
  327. package/_types/tokens/definitions/frxusd.d.ts +11 -0
  328. package/_types/tokens/definitions/frxusd.d.ts.map +1 -0
  329. package/_types/tokens/definitions/gbpa.d.ts +11 -0
  330. package/_types/tokens/definitions/gbpa.d.ts.map +1 -0
  331. package/_types/tokens/definitions/gusd.d.ts +11 -0
  332. package/_types/tokens/definitions/gusd.d.ts.map +1 -0
  333. package/_types/tokens/definitions/iusd.d.ts +11 -0
  334. package/_types/tokens/definitions/iusd.d.ts.map +1 -0
  335. package/_types/tokens/definitions/pathusd.d.ts +12 -0
  336. package/_types/tokens/definitions/pathusd.d.ts.map +1 -0
  337. package/_types/tokens/definitions/reusd.d.ts +11 -0
  338. package/_types/tokens/definitions/reusd.d.ts.map +1 -0
  339. package/_types/tokens/definitions/rusd.d.ts +11 -0
  340. package/_types/tokens/definitions/rusd.d.ts.map +1 -0
  341. package/_types/tokens/definitions/sbc.d.ts +11 -0
  342. package/_types/tokens/definitions/sbc.d.ts.map +1 -0
  343. package/_types/tokens/definitions/siusd.d.ts +11 -0
  344. package/_types/tokens/definitions/siusd.d.ts.map +1 -0
  345. package/_types/tokens/definitions/stcusd.d.ts +11 -0
  346. package/_types/tokens/definitions/stcusd.d.ts.map +1 -0
  347. package/_types/tokens/definitions/susde.d.ts +11 -0
  348. package/_types/tokens/definitions/susde.d.ts.map +1 -0
  349. package/_types/tokens/definitions/syrupusdc.d.ts +11 -0
  350. package/_types/tokens/definitions/syrupusdc.d.ts.map +1 -0
  351. package/_types/tokens/definitions/thetausd.d.ts +11 -0
  352. package/_types/tokens/definitions/thetausd.d.ts.map +1 -0
  353. package/_types/tokens/definitions/usd1.d.ts +11 -0
  354. package/_types/tokens/definitions/usd1.d.ts.map +1 -0
  355. package/_types/tokens/definitions/usdb.d.ts +11 -0
  356. package/_types/tokens/definitions/usdb.d.ts.map +1 -0
  357. package/_types/tokens/definitions/usdc.d.ts +67 -0
  358. package/_types/tokens/definitions/usdc.d.ts.map +1 -0
  359. package/_types/tokens/definitions/usdce.d.ts +12 -0
  360. package/_types/tokens/definitions/usdce.d.ts.map +1 -0
  361. package/_types/tokens/definitions/usde.d.ts +11 -0
  362. package/_types/tokens/definitions/usde.d.ts.map +1 -0
  363. package/_types/tokens/definitions/usdt0.d.ts +11 -0
  364. package/_types/tokens/definitions/usdt0.d.ts.map +1 -0
  365. package/_types/tokens/definitions/wsrusd.d.ts +11 -0
  366. package/_types/tokens/definitions/wsrusd.d.ts.map +1 -0
  367. package/_types/tokens/index.d.ts +31 -0
  368. package/_types/tokens/index.d.ts.map +1 -0
  369. package/_types/utils/encoding/fromRlp.d.ts +2 -2
  370. package/_types/utils/encoding/fromRlp.d.ts.map +1 -1
  371. package/_types/utils/rpc/http.d.ts +6 -2
  372. package/_types/utils/rpc/http.d.ts.map +1 -1
  373. package/_types/utils/transaction/parseTransaction.d.ts +2 -2
  374. package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
  375. package/actions/index.ts +1 -0
  376. package/actions/token/approve.ts +202 -0
  377. package/actions/token/approveSync.ts +95 -0
  378. package/actions/token/getAllowance.ts +105 -0
  379. package/actions/token/getBalance.ts +115 -0
  380. package/actions/token/getMetadata.ts +98 -0
  381. package/actions/token/getTotalSupply.ts +97 -0
  382. package/actions/token/index.ts +9 -0
  383. package/actions/token/internal.ts +367 -0
  384. package/actions/token/transfer.ts +230 -0
  385. package/actions/token/transferSync.ts +99 -0
  386. package/chains/definitions/battlechain.ts +28 -0
  387. package/chains/definitions/marooTestnet.ts +27 -0
  388. package/chains/index.ts +2 -0
  389. package/clients/createClient.ts +90 -8
  390. package/clients/createPublicClient.ts +22 -4
  391. package/clients/createWalletClient.ts +22 -4
  392. package/clients/decorators/public.ts +166 -4
  393. package/clients/decorators/wallet.ts +242 -3
  394. package/clients/transports/http.ts +4 -0
  395. package/errors/encoding.ts +11 -0
  396. package/errors/request.ts +17 -0
  397. package/errors/transaction.ts +11 -0
  398. package/errors/version.ts +1 -1
  399. package/index.ts +7 -0
  400. package/package.json +6 -1
  401. package/tempo/Client.ts +4 -2
  402. package/tempo/Decorator.ts +398 -337
  403. package/tempo/actions/token.ts +519 -296
  404. package/tempo/actions/wallet.ts +3 -3
  405. package/tempo/internal/types.ts +19 -0
  406. package/tempo/internal/utils.ts +204 -0
  407. package/tokens/defineToken.ts +142 -0
  408. package/tokens/definitions/alphausd.ts +13 -0
  409. package/tokens/definitions/betausd.ts +13 -0
  410. package/tokens/definitions/brla.ts +13 -0
  411. package/tokens/definitions/cbbtc.ts +13 -0
  412. package/tokens/definitions/chfau.ts +13 -0
  413. package/tokens/definitions/cusd.ts +13 -0
  414. package/tokens/definitions/dlusd.ts +13 -0
  415. package/tokens/definitions/eurau.ts +13 -0
  416. package/tokens/definitions/eurce.ts +14 -0
  417. package/tokens/definitions/frxusd.ts +13 -0
  418. package/tokens/definitions/gbpa.ts +13 -0
  419. package/tokens/definitions/gusd.ts +13 -0
  420. package/tokens/definitions/iusd.ts +13 -0
  421. package/tokens/definitions/pathusd.ts +14 -0
  422. package/tokens/definitions/reusd.ts +13 -0
  423. package/tokens/definitions/rusd.ts +13 -0
  424. package/tokens/definitions/sbc.ts +13 -0
  425. package/tokens/definitions/siusd.ts +13 -0
  426. package/tokens/definitions/stcusd.ts +13 -0
  427. package/tokens/definitions/susde.ts +13 -0
  428. package/tokens/definitions/syrupusdc.ts +13 -0
  429. package/tokens/definitions/thetausd.ts +13 -0
  430. package/tokens/definitions/usd1.ts +13 -0
  431. package/tokens/definitions/usdb.ts +13 -0
  432. package/tokens/definitions/usdc.ts +67 -0
  433. package/tokens/definitions/usdce.ts +14 -0
  434. package/tokens/definitions/usde.ts +13 -0
  435. package/tokens/definitions/usdt0.ts +13 -0
  436. package/tokens/definitions/wsrusd.ts +13 -0
  437. package/tokens/index.ts +31 -0
  438. package/tokens/package.json +6 -0
  439. package/utils/encoding/fromRlp.ts +22 -3
  440. package/utils/rpc/http.ts +70 -2
  441. package/utils/transaction/parseTransaction.ts +7 -2
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const stcusd = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c0000000000000000000008ee4fcff88888888', // tempo
8
+ },
9
+ currency: 'stcUSD',
10
+ decimals: 6,
11
+ name: 'Staked Cap USD',
12
+ symbol: 'stcUSD',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const susde = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c000000000000000000000bd95bfb69fbe6ce3', // tempo
8
+ },
9
+ currency: 'sUSDe',
10
+ decimals: 6,
11
+ name: 'Staked USDe',
12
+ symbol: 'sUSDe',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const syrupusdc = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c0000000000000000000008191667423f70e67', // tempo
8
+ },
9
+ currency: 'syrupUSDC',
10
+ decimals: 6,
11
+ name: 'Syrup USDC',
12
+ symbol: 'syrupUSDC',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const thetausd = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 42431: '0x20c0000000000000000000000000000000000003', // tempoModerato
8
+ },
9
+ currency: 'USD',
10
+ decimals: 6,
11
+ name: 'ThetaUSD',
12
+ symbol: 'thetaUSD',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const usd1 = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c000000000000000000000111111111e910f0f', // tempo
8
+ },
9
+ currency: 'USD',
10
+ decimals: 6,
11
+ name: 'USD1',
12
+ symbol: 'USD1',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const usdb = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c0000000000000000000003158081efd85bfc2', // tempo
8
+ },
9
+ currency: 'USD',
10
+ decimals: 6,
11
+ name: 'USDBridge',
12
+ symbol: 'USDB',
13
+ })
@@ -0,0 +1,67 @@
1
+ import { defineToken } from '../defineToken.js'
2
+
3
+ /**
4
+ * [USDC](https://www.circle.com/usdc) token, with canonical contract addresses
5
+ * across supported chains.
6
+ *
7
+ * Pass to a Client's `tokens` array, call with a chain id to produce a
8
+ * [token config](/docs/chains/tokens), or read the metadata and `addresses`
9
+ * map directly.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { createPublicClient, http } from 'viem'
14
+ * import { mainnet } from 'viem/chains'
15
+ * import { usdc } from 'viem/tokens'
16
+ *
17
+ * const client = createPublicClient({
18
+ * chain: mainnet,
19
+ * tokens: [usdc],
20
+ * transport: http(),
21
+ * })
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { usdc } from 'viem/tokens'
27
+ *
28
+ * usdc.addresses[1]
29
+ * // '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
30
+ * ```
31
+ */
32
+ export const usdc = /*#__PURE__*/ defineToken({
33
+ addresses: {
34
+ 1: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // mainnet
35
+ 10: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', // optimism
36
+ 130: '0x078D782b760474a361dDA0AF3839290b0EF57AD6', // unichain
37
+ 137: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', // polygon
38
+ 146: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894', // sonic
39
+ 480: '0x79A02482A880bCE3F13e09Da970dC34db4CD24d1', // worldchain
40
+ 1301: '0x31d0220469e10c4E71834a79b1f276d740d3768F', // unichainSepolia
41
+ 1328: '0x4fCF1784B31630811181f670Aea7A7bEF803eaED', // seiTestnet
42
+ 1329: '0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392', // sei
43
+ 4801: '0x66145f38cBAC35Ca6F1Dfb4914dF98F1614aeA88', // worldchainSepolia
44
+ 8453: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // base
45
+ 42161: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // arbitrum
46
+ 43113: '0x5425890298aed601595a70AB815c96711a31Bc65', // avalancheFuji
47
+ 43114: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', // avalanche
48
+ 57054: '0xA4879Fed32Ecbef99399e5cbC247E533421C4eC6', // sonicBlazeTestnet
49
+ 57073: '0x2D270e6886d130D724215A266106e6832161EAEd', // ink
50
+ 59141: '0xFEce4462D57bD51A6A552365A011b95f0E16d9B7', // lineaSepolia
51
+ 59144: '0x176211869cA2b568f2A7D4EE941E073a821EE1ff', // linea
52
+ 80002: '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582', // polygonAmoy
53
+ 81224: '0xd996633a415985DBd7D6D12f4A4343E31f5037cf', // codex
54
+ 84532: '0x036CbD53842c5426634e7929541eC2318f3dCF7e', // baseSepolia
55
+ 421614: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // arbitrumSepolia
56
+ 763373: '0xFabab97dCE620294D2B0b0e46C68964e326300Ac', // inkSepolia
57
+ 812242: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f', // codexTestnet
58
+ 5042002: '0x3600000000000000000000000000000000000000', // arcTestnet
59
+ 11155111: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // sepolia
60
+ 11155420: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7', // optimismSepolia
61
+ },
62
+ currency: 'USD',
63
+ decimals: 6,
64
+ name: 'USD Coin',
65
+ popular: true,
66
+ symbol: 'USDC',
67
+ })
@@ -0,0 +1,14 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const usdce = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c000000000000000000000b9537d11c60e8b50', // tempo
8
+ 42431: '0x20c0000000000000000000009e8d7eb59b783726', // tempoModerato
9
+ },
10
+ currency: 'USD',
11
+ decimals: 6,
12
+ name: 'Bridged USDC (Stargate)',
13
+ symbol: 'USDC.e',
14
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const usde = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c0000000000000000000002f52d5cc21a3207b', // tempo
8
+ },
9
+ currency: 'USD',
10
+ decimals: 6,
11
+ name: 'USDe',
12
+ symbol: 'USDe',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const usdt0 = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c00000000000000000000014f22ca97301eb73', // tempo
8
+ },
9
+ currency: 'USD',
10
+ decimals: 6,
11
+ name: 'USDT0',
12
+ symbol: 'USDT0',
13
+ })
@@ -0,0 +1,13 @@
1
+ // Generated with `pnpm gen:tokenlist`. Do not modify manually.
2
+
3
+ import { defineToken } from '../defineToken.js'
4
+
5
+ export const wsrusd = /*#__PURE__*/ defineToken({
6
+ addresses: {
7
+ 4217: '0x20c000000000000000000000aeed2ec36a54d0e5', // tempo
8
+ },
9
+ currency: 'wsrUSD',
10
+ decimals: 6,
11
+ name: 'Wrapped Savings rUSD',
12
+ symbol: 'wsrUSD',
13
+ })
@@ -0,0 +1,31 @@
1
+ // biome-ignore lint/performance/noBarrelFile: entrypoint module
2
+ export { defineToken, type Token, type Tokens } from './defineToken.js'
3
+ export { alphausd } from './definitions/alphausd.js'
4
+ export { betausd } from './definitions/betausd.js'
5
+ export { brla } from './definitions/brla.js'
6
+ export { cbbtc } from './definitions/cbbtc.js'
7
+ export { chfau } from './definitions/chfau.js'
8
+ export { cusd } from './definitions/cusd.js'
9
+ export { dlusd } from './definitions/dlusd.js'
10
+ export { eurau } from './definitions/eurau.js'
11
+ export { eurce } from './definitions/eurce.js'
12
+ export { frxusd } from './definitions/frxusd.js'
13
+ export { gbpa } from './definitions/gbpa.js'
14
+ export { gusd } from './definitions/gusd.js'
15
+ export { iusd } from './definitions/iusd.js'
16
+ export { pathusd } from './definitions/pathusd.js'
17
+ export { reusd } from './definitions/reusd.js'
18
+ export { rusd } from './definitions/rusd.js'
19
+ export { sbc } from './definitions/sbc.js'
20
+ export { siusd } from './definitions/siusd.js'
21
+ export { stcusd } from './definitions/stcusd.js'
22
+ export { susde } from './definitions/susde.js'
23
+ export { syrupusdc } from './definitions/syrupusdc.js'
24
+ export { thetausd } from './definitions/thetausd.js'
25
+ export { usd1 } from './definitions/usd1.js'
26
+ export { usdb } from './definitions/usdb.js'
27
+ export { usdc } from './definitions/usdc.js'
28
+ export { usdce } from './definitions/usdce.js'
29
+ export { usde } from './definitions/usde.js'
30
+ export { usdt0 } from './definitions/usdt0.js'
31
+ export { wsrusd } from './definitions/wsrusd.js'
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../_types/tokens/index.d.ts",
4
+ "module": "../_esm/tokens/index.js",
5
+ "main": "../_cjs/tokens/index.js"
6
+ }
@@ -2,6 +2,8 @@ import { BaseError, type BaseErrorType } from '../../errors/base.js'
2
2
  import {
3
3
  InvalidHexValueError,
4
4
  type InvalidHexValueErrorType,
5
+ RlpDepthLimitExceededError,
6
+ type RlpDepthLimitExceededErrorType,
5
7
  } from '../../errors/encoding.js'
6
8
  import type { ErrorType } from '../../errors/utils.js'
7
9
  import type { ByteArray, Hex } from '../../types/misc.js'
@@ -17,6 +19,8 @@ import type { RecursiveArray } from './toRlp.js'
17
19
 
18
20
  type To = 'hex' | 'bytes'
19
21
 
22
+ const rlpDepthLimit = 1_024
23
+
20
24
  export type FromRlpReturnType<to extends To> =
21
25
  | (to extends 'bytes' ? RecursiveArray<ByteArray> : never)
22
26
  | (to extends 'hex' ? RecursiveArray<Hex> : never)
@@ -26,6 +30,7 @@ export type FromRlpErrorType =
26
30
  | FromRlpCursorErrorType
27
31
  | HexToBytesErrorType
28
32
  | InvalidHexValueErrorType
33
+ | RlpDepthLimitExceededErrorType
29
34
  | ErrorType
30
35
 
31
36
  export function fromRlp<to extends To = 'hex'>(
@@ -58,7 +63,11 @@ type FromRlpCursorErrorType =
58
63
  function fromRlpCursor<to extends To = 'hex'>(
59
64
  cursor: Cursor,
60
65
  to: to | To | undefined = 'hex',
66
+ recursiveDepth = 0,
61
67
  ): FromRlpReturnType<to> {
68
+ if (recursiveDepth >= rlpDepthLimit)
69
+ throw new RlpDepthLimitExceededError({ limit: rlpDepthLimit })
70
+
62
71
  if (cursor.bytes.length === 0)
63
72
  return (
64
73
  to === 'hex' ? bytesToHex(cursor.bytes) : cursor.bytes
@@ -76,7 +85,12 @@ function fromRlpCursor<to extends To = 'hex'>(
76
85
 
77
86
  // list
78
87
  const length = readLength(cursor, prefix, 0xc0)
79
- return readList(cursor, length, to) as {} as FromRlpReturnType<to>
88
+ return readList(
89
+ cursor,
90
+ length,
91
+ to,
92
+ recursiveDepth + 1,
93
+ ) as {} as FromRlpReturnType<to>
80
94
  }
81
95
 
82
96
  type ReadLengthErrorType = BaseErrorType | ErrorType
@@ -93,10 +107,15 @@ function readLength(cursor: Cursor, prefix: number, offset: number) {
93
107
 
94
108
  type ReadListErrorType = ErrorType
95
109
 
96
- function readList<to extends To>(cursor: Cursor, length: number, to: to | To) {
110
+ function readList<to extends To>(
111
+ cursor: Cursor,
112
+ length: number,
113
+ to: to | To,
114
+ recursiveDepth: number,
115
+ ) {
97
116
  const position = cursor.position
98
117
  const value: FromRlpReturnType<to>[] = []
99
118
  while (cursor.position - position < length)
100
- value.push(fromRlpCursor(cursor, to))
119
+ value.push(fromRlpCursor(cursor, to, recursiveDepth))
101
120
  return value
102
121
  }
package/utils/rpc/http.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  HttpRequestError,
3
3
  type HttpRequestErrorType as HttpRequestErrorType_,
4
+ ResponseBodyTooLargeError,
5
+ type ResponseBodyTooLargeErrorType,
4
6
  TimeoutError,
5
7
  type TimeoutErrorType,
6
8
  } from '../../errors/request.js'
@@ -25,6 +27,8 @@ export type HttpRpcClientOptions = {
25
27
  | undefined
26
28
  /** Request configuration to pass to `fetch`. */
27
29
  fetchOptions?: Omit<RequestInit, 'body'> | undefined
30
+ /** Maximum response body size in bytes. Set to `false` to disable. @default 10_485_760 */
31
+ maxResponseBodySize?: number | false | undefined
28
32
  /** A callback to handle the request. */
29
33
  onRequest?:
30
34
  | ((
@@ -49,6 +53,8 @@ export type HttpRequestParameters<
49
53
  fetchFn?: HttpRpcClientOptions['fetchFn'] | undefined
50
54
  /** Request configuration to pass to `fetch`. */
51
55
  fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined
56
+ /** Maximum response body size in bytes. Set to `false` to disable. */
57
+ maxResponseBodySize?: HttpRpcClientOptions['maxResponseBodySize'] | undefined
52
58
  /** A callback to handle the response. */
53
59
  onRequest?:
54
60
  | ((
@@ -70,10 +76,13 @@ export type HttpRequestReturnType<
70
76
 
71
77
  export type HttpRequestErrorType =
72
78
  | HttpRequestErrorType_
79
+ | ResponseBodyTooLargeErrorType
73
80
  | TimeoutErrorType
74
81
  | WithTimeoutErrorType
75
82
  | ErrorType
76
83
 
84
+ const defaultMaxResponseBodySize = 10_485_760
85
+
77
86
  export type HttpRpcClient = {
78
87
  request<body extends RpcRequest | RpcRequest[]>(
79
88
  params: HttpRequestParameters<body>,
@@ -91,6 +100,8 @@ export function getHttpRpcClient(
91
100
  const {
92
101
  body,
93
102
  fetchFn = options.fetchFn ?? fetch,
103
+ maxResponseBodySize = options.maxResponseBodySize ??
104
+ defaultMaxResponseBodySize,
94
105
  onRequest = options.onRequest,
95
106
  onResponse = options.onResponse,
96
107
  timeout = options.timeout ?? 10_000,
@@ -144,12 +155,15 @@ export function getHttpRpcClient(
144
155
  if (onResponse) await onResponse(response)
145
156
 
146
157
  let data: any
158
+ const responseBody = await readResponseBody(response, {
159
+ maxResponseBodySize,
160
+ })
147
161
  if (
148
162
  response.headers.get('Content-Type')?.startsWith('application/json')
149
163
  )
150
- data = await response.json()
164
+ data = JSON.parse(responseBody)
151
165
  else {
152
- data = await response.text()
166
+ data = responseBody
153
167
  try {
154
168
  data = JSON.parse(data || '{}')
155
169
  } catch (err) {
@@ -181,6 +195,7 @@ export function getHttpRpcClient(
181
195
  if (signal_?.aborted) throw getAbortError(signal_)
182
196
  if (isAbortError(err)) throw err
183
197
  if (err instanceof HttpRequestError) throw err
198
+ if (err instanceof ResponseBodyTooLargeError) throw err
184
199
  if (err instanceof TimeoutError) throw err
185
200
  throw new HttpRequestError({
186
201
  body,
@@ -192,6 +207,59 @@ export function getHttpRpcClient(
192
207
  }
193
208
  }
194
209
 
210
+ async function readResponseBody(
211
+ response: Response,
212
+ { maxResponseBodySize }: { maxResponseBodySize: number | false },
213
+ ): Promise<string> {
214
+ if (maxResponseBodySize === false) return response.text()
215
+
216
+ const contentLength = response.headers.get('Content-Length')
217
+ if (contentLength) {
218
+ const size = Number(contentLength)
219
+ if (size > maxResponseBodySize)
220
+ throw new ResponseBodyTooLargeError({
221
+ maxSize: maxResponseBodySize,
222
+ size,
223
+ })
224
+ }
225
+
226
+ if (!response.body) {
227
+ const body = await response.text()
228
+ const size = new TextEncoder().encode(body).length
229
+ if (size > maxResponseBodySize)
230
+ throw new ResponseBodyTooLargeError({
231
+ maxSize: maxResponseBodySize,
232
+ size,
233
+ })
234
+ return body
235
+ }
236
+
237
+ const reader = response.body.getReader()
238
+ const decoder = new TextDecoder()
239
+ let body = ''
240
+ let size = 0
241
+
242
+ try {
243
+ while (true) {
244
+ const { done, value } = await reader.read()
245
+ if (done) break
246
+ size += value.byteLength
247
+ if (size > maxResponseBodySize) {
248
+ await reader.cancel()
249
+ throw new ResponseBodyTooLargeError({
250
+ maxSize: maxResponseBodySize,
251
+ size,
252
+ })
253
+ }
254
+ body += decoder.decode(value, { stream: true })
255
+ }
256
+ body += decoder.decode()
257
+ return body
258
+ } finally {
259
+ reader.releaseLock()
260
+ }
261
+ }
262
+
195
263
  /** @internal */
196
264
  export function parseUrl(url_: string) {
197
265
  try {
@@ -7,6 +7,8 @@ import {
7
7
  type InvalidLegacyVErrorType,
8
8
  InvalidSerializedTransactionError,
9
9
  type InvalidSerializedTransactionErrorType,
10
+ InvalidYParityError,
11
+ type InvalidYParityErrorType,
10
12
  } from '../../errors/transaction.js'
11
13
  import type { ErrorType } from '../../errors/utils.js'
12
14
  import type {
@@ -593,6 +595,7 @@ function parseAuthorizationList(
593
595
 
594
596
  type ParseEIP155SignatureErrorType =
595
597
  | HexToBigIntErrorType
598
+ | InvalidYParityErrorType
596
599
  | PadHexErrorType
597
600
  | ErrorType
598
601
 
@@ -600,8 +603,10 @@ function parseEIP155Signature(
600
603
  transactionArray: RecursiveArray<Hex>,
601
604
  ): Signature & { yParity: number } {
602
605
  const signature = transactionArray.slice(-3)
603
- const v =
604
- signature[0] === '0x' || hexToBigInt(signature[0] as Hex) === 0n ? 27n : 28n
606
+ const yParity = signature[0] === '0x' ? 0n : hexToBigInt(signature[0] as Hex)
607
+ if (yParity !== 0n && yParity !== 1n)
608
+ throw new InvalidYParityError({ yParity })
609
+ const v = yParity === 0n ? 27n : 28n
605
610
  return {
606
611
  r: padHex(signature[1] as Hex, { size: 32 }),
607
612
  s: padHex(signature[2] as Hex, { size: 32 }),