@mantleio/viem 0.0.1-alpha.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 (453) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +54 -0
  3. package/dist/cjs/abis.js +3338 -0
  4. package/dist/cjs/abis.js.map +1 -0
  5. package/dist/cjs/actions/buildProveWithdrawal.js +55 -0
  6. package/dist/cjs/actions/buildProveWithdrawal.js.map +1 -0
  7. package/dist/cjs/actions/depositERC20.js +37 -0
  8. package/dist/cjs/actions/depositERC20.js.map +1 -0
  9. package/dist/cjs/actions/depositETH.js +36 -0
  10. package/dist/cjs/actions/depositETH.js.map +1 -0
  11. package/dist/cjs/actions/depositMNT.js +35 -0
  12. package/dist/cjs/actions/depositMNT.js.map +1 -0
  13. package/dist/cjs/actions/estimateDepositERC20Gas.js +38 -0
  14. package/dist/cjs/actions/estimateDepositERC20Gas.js.map +1 -0
  15. package/dist/cjs/actions/estimateDepositETHGas.js +37 -0
  16. package/dist/cjs/actions/estimateDepositETHGas.js.map +1 -0
  17. package/dist/cjs/actions/estimateDepositMNTGas.js +36 -0
  18. package/dist/cjs/actions/estimateDepositMNTGas.js.map +1 -0
  19. package/dist/cjs/actions/estimateFinalizeWithdrawalGas.js +29 -0
  20. package/dist/cjs/actions/estimateFinalizeWithdrawalGas.js.map +1 -0
  21. package/dist/cjs/actions/estimateInitiateERC20WithdrawalGas.js +30 -0
  22. package/dist/cjs/actions/estimateInitiateERC20WithdrawalGas.js.map +1 -0
  23. package/dist/cjs/actions/estimateInitiateETHWithdrawalGas.js +29 -0
  24. package/dist/cjs/actions/estimateInitiateETHWithdrawalGas.js.map +1 -0
  25. package/dist/cjs/actions/estimateInitiateMNTWithdrawalGas.js +30 -0
  26. package/dist/cjs/actions/estimateInitiateMNTWithdrawalGas.js.map +1 -0
  27. package/dist/cjs/actions/estimateProveWithdrawalGas.js +29 -0
  28. package/dist/cjs/actions/estimateProveWithdrawalGas.js.map +1 -0
  29. package/dist/cjs/actions/finalizeWithdrawal.js +28 -0
  30. package/dist/cjs/actions/finalizeWithdrawal.js.map +1 -0
  31. package/dist/cjs/actions/getL2Output.js +31 -0
  32. package/dist/cjs/actions/getL2Output.js.map +1 -0
  33. package/dist/cjs/actions/getPortalVersion.js +24 -0
  34. package/dist/cjs/actions/getPortalVersion.js.map +1 -0
  35. package/dist/cjs/actions/getTimeToFinalize.js +46 -0
  36. package/dist/cjs/actions/getTimeToFinalize.js.map +1 -0
  37. package/dist/cjs/actions/getTimeToNextL2Output.js +62 -0
  38. package/dist/cjs/actions/getTimeToNextL2Output.js.map +1 -0
  39. package/dist/cjs/actions/getTimeToProve.js +12 -0
  40. package/dist/cjs/actions/getTimeToProve.js.map +1 -0
  41. package/dist/cjs/actions/getWithdrawalStatus.js +133 -0
  42. package/dist/cjs/actions/getWithdrawalStatus.js.map +1 -0
  43. package/dist/cjs/actions/initiateERC20Withdrawal.js +29 -0
  44. package/dist/cjs/actions/initiateERC20Withdrawal.js.map +1 -0
  45. package/dist/cjs/actions/initiateETHWithdrawal.js +28 -0
  46. package/dist/cjs/actions/initiateETHWithdrawal.js.map +1 -0
  47. package/dist/cjs/actions/initiateMNTWithdrawal.js +29 -0
  48. package/dist/cjs/actions/initiateMNTWithdrawal.js.map +1 -0
  49. package/dist/cjs/actions/proveWithdrawal.js +28 -0
  50. package/dist/cjs/actions/proveWithdrawal.js.map +1 -0
  51. package/dist/cjs/actions/waitForNextL2Output.js +31 -0
  52. package/dist/cjs/actions/waitForNextL2Output.js.map +1 -0
  53. package/dist/cjs/actions/waitToFinalize.js +10 -0
  54. package/dist/cjs/actions/waitToFinalize.js.map +1 -0
  55. package/dist/cjs/actions/waitToProve.js +24 -0
  56. package/dist/cjs/actions/waitToProve.js.map +1 -0
  57. package/dist/cjs/chainConfig.js +12 -0
  58. package/dist/cjs/chainConfig.js.map +1 -0
  59. package/dist/cjs/chains/index.js +8 -0
  60. package/dist/cjs/chains/index.js.map +1 -0
  61. package/dist/cjs/chains/mantle.js +53 -0
  62. package/dist/cjs/chains/mantle.js.map +1 -0
  63. package/dist/cjs/chains/mantleSepoliaTestnet.js +54 -0
  64. package/dist/cjs/chains/mantleSepoliaTestnet.js.map +1 -0
  65. package/dist/cjs/contracts.js +16 -0
  66. package/dist/cjs/contracts.js.map +1 -0
  67. package/dist/cjs/decorators/publicL1.js +38 -0
  68. package/dist/cjs/decorators/publicL1.js.map +1 -0
  69. package/dist/cjs/decorators/publicL2.js +18 -0
  70. package/dist/cjs/decorators/publicL2.js.map +1 -0
  71. package/dist/cjs/decorators/walletL1.js +20 -0
  72. package/dist/cjs/decorators/walletL1.js.map +1 -0
  73. package/dist/cjs/decorators/walletL2.js +16 -0
  74. package/dist/cjs/decorators/walletL2.js.map +1 -0
  75. package/dist/cjs/errors/utils.js +3 -0
  76. package/dist/cjs/errors/utils.js.map +1 -0
  77. package/dist/cjs/errors/withdrawal.js +17 -0
  78. package/dist/cjs/errors/withdrawal.js.map +1 -0
  79. package/dist/cjs/formatters.js +51 -0
  80. package/dist/cjs/formatters.js.map +1 -0
  81. package/dist/cjs/index.js +59 -0
  82. package/dist/cjs/index.js.map +1 -0
  83. package/dist/cjs/package.json +1 -0
  84. package/dist/cjs/parsers.js +58 -0
  85. package/dist/cjs/parsers.js.map +1 -0
  86. package/dist/cjs/serializers.js +53 -0
  87. package/dist/cjs/serializers.js.map +1 -0
  88. package/dist/cjs/types/account.js +3 -0
  89. package/dist/cjs/types/account.js.map +1 -0
  90. package/dist/cjs/types/block.js +3 -0
  91. package/dist/cjs/types/block.js.map +1 -0
  92. package/dist/cjs/types/chain.js +3 -0
  93. package/dist/cjs/types/chain.js.map +1 -0
  94. package/dist/cjs/types/contract.js +3 -0
  95. package/dist/cjs/types/contract.js.map +1 -0
  96. package/dist/cjs/types/deposit.js +3 -0
  97. package/dist/cjs/types/deposit.js.map +1 -0
  98. package/dist/cjs/types/l1Actions.js +8 -0
  99. package/dist/cjs/types/l1Actions.js.map +1 -0
  100. package/dist/cjs/types/l2Actions.js +11 -0
  101. package/dist/cjs/types/l2Actions.js.map +1 -0
  102. package/dist/cjs/types/transaction.js +3 -0
  103. package/dist/cjs/types/transaction.js.map +1 -0
  104. package/dist/cjs/types/withdrawal.js +3 -0
  105. package/dist/cjs/types/withdrawal.js.map +1 -0
  106. package/dist/cjs/utils/extractTransactionDepositedLogs.js +13 -0
  107. package/dist/cjs/utils/extractTransactionDepositedLogs.js.map +1 -0
  108. package/dist/cjs/utils/extractWithdrawalMessageLogs.js +13 -0
  109. package/dist/cjs/utils/extractWithdrawalMessageLogs.js.map +1 -0
  110. package/dist/cjs/utils/getL2TransactionHash.js +29 -0
  111. package/dist/cjs/utils/getL2TransactionHash.js.map +1 -0
  112. package/dist/cjs/utils/getL2TransactionHashes.js +10 -0
  113. package/dist/cjs/utils/getL2TransactionHashes.js.map +1 -0
  114. package/dist/cjs/utils/getSourceHash.js +17 -0
  115. package/dist/cjs/utils/getSourceHash.js.map +1 -0
  116. package/dist/cjs/utils/getWithdrawalHashStorageSlot.js +9 -0
  117. package/dist/cjs/utils/getWithdrawalHashStorageSlot.js.map +1 -0
  118. package/dist/cjs/utils/getWithdrawals.js +9 -0
  119. package/dist/cjs/utils/getWithdrawals.js.map +1 -0
  120. package/dist/cjs/utils/opaqueDataToDepositData.js +32 -0
  121. package/dist/cjs/utils/opaqueDataToDepositData.js.map +1 -0
  122. package/dist/cjs/utils/parseDepositRequest.js +43 -0
  123. package/dist/cjs/utils/parseDepositRequest.js.map +1 -0
  124. package/dist/cjs/utils/parseInitWithdrawRequest.js +55 -0
  125. package/dist/cjs/utils/parseInitWithdrawRequest.js.map +1 -0
  126. package/dist/cjs/utils/poll.js +26 -0
  127. package/dist/cjs/utils/poll.js.map +1 -0
  128. package/dist/cjs/utils/promise/withCache.js +47 -0
  129. package/dist/cjs/utils/promise/withCache.js.map +1 -0
  130. package/dist/cjs/utils/wait.js +7 -0
  131. package/dist/cjs/utils/wait.js.map +1 -0
  132. package/dist/esm/abis.js +3335 -0
  133. package/dist/esm/abis.js.map +1 -0
  134. package/dist/esm/actions/buildProveWithdrawal.js +67 -0
  135. package/dist/esm/actions/buildProveWithdrawal.js.map +1 -0
  136. package/dist/esm/actions/depositERC20.js +39 -0
  137. package/dist/esm/actions/depositERC20.js.map +1 -0
  138. package/dist/esm/actions/depositETH.js +38 -0
  139. package/dist/esm/actions/depositETH.js.map +1 -0
  140. package/dist/esm/actions/depositMNT.js +37 -0
  141. package/dist/esm/actions/depositMNT.js.map +1 -0
  142. package/dist/esm/actions/estimateDepositERC20Gas.js +43 -0
  143. package/dist/esm/actions/estimateDepositERC20Gas.js.map +1 -0
  144. package/dist/esm/actions/estimateDepositETHGas.js +43 -0
  145. package/dist/esm/actions/estimateDepositETHGas.js.map +1 -0
  146. package/dist/esm/actions/estimateDepositMNTGas.js +41 -0
  147. package/dist/esm/actions/estimateDepositMNTGas.js.map +1 -0
  148. package/dist/esm/actions/estimateFinalizeWithdrawalGas.js +34 -0
  149. package/dist/esm/actions/estimateFinalizeWithdrawalGas.js.map +1 -0
  150. package/dist/esm/actions/estimateInitiateERC20WithdrawalGas.js +35 -0
  151. package/dist/esm/actions/estimateInitiateERC20WithdrawalGas.js.map +1 -0
  152. package/dist/esm/actions/estimateInitiateETHWithdrawalGas.js +34 -0
  153. package/dist/esm/actions/estimateInitiateETHWithdrawalGas.js.map +1 -0
  154. package/dist/esm/actions/estimateInitiateMNTWithdrawalGas.js +35 -0
  155. package/dist/esm/actions/estimateInitiateMNTWithdrawalGas.js.map +1 -0
  156. package/dist/esm/actions/estimateProveWithdrawalGas.js +34 -0
  157. package/dist/esm/actions/estimateProveWithdrawalGas.js.map +1 -0
  158. package/dist/esm/actions/finalizeWithdrawal.js +30 -0
  159. package/dist/esm/actions/finalizeWithdrawal.js.map +1 -0
  160. package/dist/esm/actions/getL2Output.js +33 -0
  161. package/dist/esm/actions/getL2Output.js.map +1 -0
  162. package/dist/esm/actions/getPortalVersion.js +26 -0
  163. package/dist/esm/actions/getPortalVersion.js.map +1 -0
  164. package/dist/esm/actions/getTimeToFinalize.js +48 -0
  165. package/dist/esm/actions/getTimeToFinalize.js.map +1 -0
  166. package/dist/esm/actions/getTimeToNextL2Output.js +68 -0
  167. package/dist/esm/actions/getTimeToNextL2Output.js.map +1 -0
  168. package/dist/esm/actions/getTimeToProve.js +14 -0
  169. package/dist/esm/actions/getTimeToProve.js.map +1 -0
  170. package/dist/esm/actions/getWithdrawalStatus.js +138 -0
  171. package/dist/esm/actions/getWithdrawalStatus.js.map +1 -0
  172. package/dist/esm/actions/initiateERC20Withdrawal.js +31 -0
  173. package/dist/esm/actions/initiateERC20Withdrawal.js.map +1 -0
  174. package/dist/esm/actions/initiateETHWithdrawal.js +30 -0
  175. package/dist/esm/actions/initiateETHWithdrawal.js.map +1 -0
  176. package/dist/esm/actions/initiateMNTWithdrawal.js +31 -0
  177. package/dist/esm/actions/initiateMNTWithdrawal.js.map +1 -0
  178. package/dist/esm/actions/proveWithdrawal.js +30 -0
  179. package/dist/esm/actions/proveWithdrawal.js.map +1 -0
  180. package/dist/esm/actions/waitForNextL2Output.js +33 -0
  181. package/dist/esm/actions/waitForNextL2Output.js.map +1 -0
  182. package/dist/esm/actions/waitToFinalize.js +11 -0
  183. package/dist/esm/actions/waitToFinalize.js.map +1 -0
  184. package/dist/esm/actions/waitToProve.js +26 -0
  185. package/dist/esm/actions/waitToProve.js.map +1 -0
  186. package/dist/esm/chainConfig.js +9 -0
  187. package/dist/esm/chainConfig.js.map +1 -0
  188. package/dist/esm/chains/index.js +3 -0
  189. package/dist/esm/chains/index.js.map +1 -0
  190. package/dist/esm/chains/mantle.js +50 -0
  191. package/dist/esm/chains/mantle.js.map +1 -0
  192. package/dist/esm/chains/mantleSepoliaTestnet.js +51 -0
  193. package/dist/esm/chains/mantleSepoliaTestnet.js.map +1 -0
  194. package/dist/esm/contracts.js +13 -0
  195. package/dist/esm/contracts.js.map +1 -0
  196. package/dist/esm/decorators/publicL1.js +35 -0
  197. package/dist/esm/decorators/publicL1.js.map +1 -0
  198. package/dist/esm/decorators/publicL2.js +15 -0
  199. package/dist/esm/decorators/publicL2.js.map +1 -0
  200. package/dist/esm/decorators/walletL1.js +17 -0
  201. package/dist/esm/decorators/walletL1.js.map +1 -0
  202. package/dist/esm/decorators/walletL2.js +13 -0
  203. package/dist/esm/decorators/walletL2.js.map +1 -0
  204. package/dist/esm/errors/utils.js +2 -0
  205. package/dist/esm/errors/utils.js.map +1 -0
  206. package/dist/esm/errors/withdrawal.js +12 -0
  207. package/dist/esm/errors/withdrawal.js.map +1 -0
  208. package/dist/esm/formatters.js +48 -0
  209. package/dist/esm/formatters.js.map +1 -0
  210. package/dist/esm/index.js +29 -0
  211. package/dist/esm/index.js.map +1 -0
  212. package/dist/esm/package.json +1 -0
  213. package/dist/esm/parsers.js +54 -0
  214. package/dist/esm/parsers.js.map +1 -0
  215. package/dist/esm/serializers.js +48 -0
  216. package/dist/esm/serializers.js.map +1 -0
  217. package/dist/esm/types/account.js +2 -0
  218. package/dist/esm/types/account.js.map +1 -0
  219. package/dist/esm/types/block.js +2 -0
  220. package/dist/esm/types/block.js.map +1 -0
  221. package/dist/esm/types/chain.js +2 -0
  222. package/dist/esm/types/chain.js.map +1 -0
  223. package/dist/esm/types/contract.js +2 -0
  224. package/dist/esm/types/contract.js.map +1 -0
  225. package/dist/esm/types/deposit.js +2 -0
  226. package/dist/esm/types/deposit.js.map +1 -0
  227. package/dist/esm/types/l1Actions.js +5 -0
  228. package/dist/esm/types/l1Actions.js.map +1 -0
  229. package/dist/esm/types/l2Actions.js +7 -0
  230. package/dist/esm/types/l2Actions.js.map +1 -0
  231. package/dist/esm/types/transaction.js +2 -0
  232. package/dist/esm/types/transaction.js.map +1 -0
  233. package/dist/esm/types/withdrawal.js +2 -0
  234. package/dist/esm/types/withdrawal.js.map +1 -0
  235. package/dist/esm/utils/extractTransactionDepositedLogs.js +10 -0
  236. package/dist/esm/utils/extractTransactionDepositedLogs.js.map +1 -0
  237. package/dist/esm/utils/extractWithdrawalMessageLogs.js +10 -0
  238. package/dist/esm/utils/extractWithdrawalMessageLogs.js.map +1 -0
  239. package/dist/esm/utils/getL2TransactionHash.js +26 -0
  240. package/dist/esm/utils/getL2TransactionHash.js.map +1 -0
  241. package/dist/esm/utils/getL2TransactionHashes.js +7 -0
  242. package/dist/esm/utils/getL2TransactionHashes.js.map +1 -0
  243. package/dist/esm/utils/getSourceHash.js +14 -0
  244. package/dist/esm/utils/getSourceHash.js.map +1 -0
  245. package/dist/esm/utils/getWithdrawalHashStorageSlot.js +6 -0
  246. package/dist/esm/utils/getWithdrawalHashStorageSlot.js.map +1 -0
  247. package/dist/esm/utils/getWithdrawals.js +6 -0
  248. package/dist/esm/utils/getWithdrawals.js.map +1 -0
  249. package/dist/esm/utils/opaqueDataToDepositData.js +29 -0
  250. package/dist/esm/utils/opaqueDataToDepositData.js.map +1 -0
  251. package/dist/esm/utils/parseDepositRequest.js +39 -0
  252. package/dist/esm/utils/parseDepositRequest.js.map +1 -0
  253. package/dist/esm/utils/parseInitWithdrawRequest.js +51 -0
  254. package/dist/esm/utils/parseInitWithdrawRequest.js.map +1 -0
  255. package/dist/esm/utils/poll.js +26 -0
  256. package/dist/esm/utils/poll.js.map +1 -0
  257. package/dist/esm/utils/promise/withCache.js +57 -0
  258. package/dist/esm/utils/promise/withCache.js.map +1 -0
  259. package/dist/esm/utils/wait.js +4 -0
  260. package/dist/esm/utils/wait.js.map +1 -0
  261. package/dist/types/abis.d.ts +3110 -0
  262. package/dist/types/abis.d.ts.map +1 -0
  263. package/dist/types/actions/buildProveWithdrawal.d.ts +34 -0
  264. package/dist/types/actions/buildProveWithdrawal.d.ts.map +1 -0
  265. package/dist/types/actions/depositERC20.d.ts +29 -0
  266. package/dist/types/actions/depositERC20.d.ts.map +1 -0
  267. package/dist/types/actions/depositETH.d.ts +29 -0
  268. package/dist/types/actions/depositETH.d.ts.map +1 -0
  269. package/dist/types/actions/depositMNT.d.ts +29 -0
  270. package/dist/types/actions/depositMNT.d.ts.map +1 -0
  271. package/dist/types/actions/estimateDepositERC20Gas.d.ts +26 -0
  272. package/dist/types/actions/estimateDepositERC20Gas.d.ts.map +1 -0
  273. package/dist/types/actions/estimateDepositETHGas.d.ts +26 -0
  274. package/dist/types/actions/estimateDepositETHGas.d.ts.map +1 -0
  275. package/dist/types/actions/estimateDepositMNTGas.d.ts +26 -0
  276. package/dist/types/actions/estimateDepositMNTGas.d.ts.map +1 -0
  277. package/dist/types/actions/estimateFinalizeWithdrawalGas.d.ts +26 -0
  278. package/dist/types/actions/estimateFinalizeWithdrawalGas.d.ts.map +1 -0
  279. package/dist/types/actions/estimateInitiateERC20WithdrawalGas.d.ts +25 -0
  280. package/dist/types/actions/estimateInitiateERC20WithdrawalGas.d.ts.map +1 -0
  281. package/dist/types/actions/estimateInitiateETHWithdrawalGas.d.ts +25 -0
  282. package/dist/types/actions/estimateInitiateETHWithdrawalGas.d.ts.map +1 -0
  283. package/dist/types/actions/estimateInitiateMNTWithdrawalGas.d.ts +25 -0
  284. package/dist/types/actions/estimateInitiateMNTWithdrawalGas.d.ts.map +1 -0
  285. package/dist/types/actions/estimateProveWithdrawalGas.d.ts +35 -0
  286. package/dist/types/actions/estimateProveWithdrawalGas.d.ts.map +1 -0
  287. package/dist/types/actions/finalizeWithdrawal.d.ts +29 -0
  288. package/dist/types/actions/finalizeWithdrawal.d.ts.map +1 -0
  289. package/dist/types/actions/getL2Output.d.ts +24 -0
  290. package/dist/types/actions/getL2Output.d.ts.map +1 -0
  291. package/dist/types/actions/getPortalVersion.d.ts +23 -0
  292. package/dist/types/actions/getPortalVersion.d.ts.map +1 -0
  293. package/dist/types/actions/getTimeToFinalize.d.ts +26 -0
  294. package/dist/types/actions/getTimeToFinalize.d.ts.map +1 -0
  295. package/dist/types/actions/getTimeToNextL2Output.d.ts +35 -0
  296. package/dist/types/actions/getTimeToNextL2Output.d.ts.map +1 -0
  297. package/dist/types/actions/getTimeToProve.d.ts +24 -0
  298. package/dist/types/actions/getTimeToProve.d.ts.map +1 -0
  299. package/dist/types/actions/getWithdrawalStatus.d.ts +22 -0
  300. package/dist/types/actions/getWithdrawalStatus.d.ts.map +1 -0
  301. package/dist/types/actions/initiateERC20Withdrawal.d.ts +27 -0
  302. package/dist/types/actions/initiateERC20Withdrawal.d.ts.map +1 -0
  303. package/dist/types/actions/initiateETHWithdrawal.d.ts +27 -0
  304. package/dist/types/actions/initiateETHWithdrawal.d.ts.map +1 -0
  305. package/dist/types/actions/initiateMNTWithdrawal.d.ts +27 -0
  306. package/dist/types/actions/initiateMNTWithdrawal.d.ts.map +1 -0
  307. package/dist/types/actions/proveWithdrawal.d.ts +36 -0
  308. package/dist/types/actions/proveWithdrawal.d.ts.map +1 -0
  309. package/dist/types/actions/waitForNextL2Output.d.ts +29 -0
  310. package/dist/types/actions/waitForNextL2Output.d.ts.map +1 -0
  311. package/dist/types/actions/waitToFinalize.d.ts +14 -0
  312. package/dist/types/actions/waitToFinalize.d.ts.map +1 -0
  313. package/dist/types/actions/waitToProve.d.ts +27 -0
  314. package/dist/types/actions/waitToProve.d.ts.map +1 -0
  315. package/dist/types/chainConfig.d.ts +43 -0
  316. package/dist/types/chainConfig.d.ts.map +1 -0
  317. package/dist/types/chains/index.d.ts +3 -0
  318. package/dist/types/chains/index.d.ts.map +1 -0
  319. package/dist/types/chains/mantle.d.ts +299 -0
  320. package/dist/types/chains/mantle.d.ts.map +1 -0
  321. package/dist/types/chains/mantleSepoliaTestnet.d.ts +299 -0
  322. package/dist/types/chains/mantleSepoliaTestnet.d.ts.map +1 -0
  323. package/dist/types/contracts.d.ts +21 -0
  324. package/dist/types/contracts.d.ts.map +1 -0
  325. package/dist/types/decorators/publicL1.d.ts +35 -0
  326. package/dist/types/decorators/publicL1.d.ts.map +1 -0
  327. package/dist/types/decorators/publicL2.d.ts +16 -0
  328. package/dist/types/decorators/publicL2.d.ts.map +1 -0
  329. package/dist/types/decorators/walletL1.d.ts +17 -0
  330. package/dist/types/decorators/walletL1.d.ts.map +1 -0
  331. package/dist/types/decorators/walletL2.d.ts +13 -0
  332. package/dist/types/decorators/walletL2.d.ts.map +1 -0
  333. package/dist/types/errors/utils.d.ts +4 -0
  334. package/dist/types/errors/utils.d.ts.map +1 -0
  335. package/dist/types/errors/withdrawal.d.ts +17 -0
  336. package/dist/types/errors/withdrawal.d.ts.map +1 -0
  337. package/dist/types/formatters.d.ts +20 -0
  338. package/dist/types/formatters.d.ts.map +1 -0
  339. package/dist/types/index.d.ts +30 -0
  340. package/dist/types/index.d.ts.map +1 -0
  341. package/dist/types/parsers.d.ts +8 -0
  342. package/dist/types/parsers.d.ts.map +1 -0
  343. package/dist/types/serializers.d.ts +13 -0
  344. package/dist/types/serializers.d.ts.map +1 -0
  345. package/dist/types/types/account.d.ts +7 -0
  346. package/dist/types/types/account.d.ts.map +1 -0
  347. package/dist/types/types/block.d.ts +13 -0
  348. package/dist/types/types/block.d.ts.map +1 -0
  349. package/dist/types/types/chain.d.ts +9 -0
  350. package/dist/types/types/chain.d.ts.map +1 -0
  351. package/dist/types/types/contract.d.ts +14 -0
  352. package/dist/types/types/contract.d.ts.map +1 -0
  353. package/dist/types/types/deposit.d.ts +35 -0
  354. package/dist/types/types/deposit.d.ts.map +1 -0
  355. package/dist/types/types/l1Actions.d.ts +856 -0
  356. package/dist/types/types/l1Actions.d.ts.map +1 -0
  357. package/dist/types/types/l2Actions.d.ts +3 -0
  358. package/dist/types/types/l2Actions.d.ts.map +1 -0
  359. package/dist/types/types/transaction.d.ts +58 -0
  360. package/dist/types/types/transaction.d.ts.map +1 -0
  361. package/dist/types/types/withdrawal.d.ts +39 -0
  362. package/dist/types/types/withdrawal.d.ts.map +1 -0
  363. package/dist/types/utils/extractTransactionDepositedLogs.d.ts +450 -0
  364. package/dist/types/utils/extractTransactionDepositedLogs.d.ts.map +1 -0
  365. package/dist/types/utils/extractWithdrawalMessageLogs.d.ts +160 -0
  366. package/dist/types/utils/extractWithdrawalMessageLogs.d.ts.map +1 -0
  367. package/dist/types/utils/getL2TransactionHash.d.ts +12 -0
  368. package/dist/types/utils/getL2TransactionHash.d.ts.map +1 -0
  369. package/dist/types/utils/getL2TransactionHashes.d.ts +11 -0
  370. package/dist/types/utils/getL2TransactionHashes.d.ts.map +1 -0
  371. package/dist/types/utils/getSourceHash.d.ts +25 -0
  372. package/dist/types/utils/getSourceHash.d.ts.map +1 -0
  373. package/dist/types/utils/getWithdrawalHashStorageSlot.d.ts +10 -0
  374. package/dist/types/utils/getWithdrawalHashStorageSlot.d.ts.map +1 -0
  375. package/dist/types/utils/getWithdrawals.d.ts +12 -0
  376. package/dist/types/utils/getWithdrawals.d.ts.map +1 -0
  377. package/dist/types/utils/opaqueDataToDepositData.d.ts +16 -0
  378. package/dist/types/utils/opaqueDataToDepositData.d.ts.map +1 -0
  379. package/dist/types/utils/parseDepositRequest.d.ts +11 -0
  380. package/dist/types/utils/parseDepositRequest.d.ts.map +1 -0
  381. package/dist/types/utils/parseInitWithdrawRequest.d.ts +11 -0
  382. package/dist/types/utils/parseInitWithdrawRequest.d.ts.map +1 -0
  383. package/dist/types/utils/poll.d.ts +15 -0
  384. package/dist/types/utils/poll.d.ts.map +1 -0
  385. package/dist/types/utils/promise/withCache.d.ts +41 -0
  386. package/dist/types/utils/promise/withCache.d.ts.map +1 -0
  387. package/dist/types/utils/wait.d.ts +2 -0
  388. package/dist/types/utils/wait.d.ts.map +1 -0
  389. package/package.json +113 -0
  390. package/src/mantle/abis.ts +3339 -0
  391. package/src/mantle/actions/buildProveWithdrawal.ts +150 -0
  392. package/src/mantle/actions/depositERC20.ts +103 -0
  393. package/src/mantle/actions/depositETH.ts +102 -0
  394. package/src/mantle/actions/depositMNT.ts +101 -0
  395. package/src/mantle/actions/estimateDepositERC20Gas.ts +113 -0
  396. package/src/mantle/actions/estimateDepositETHGas.ts +113 -0
  397. package/src/mantle/actions/estimateDepositMNTGas.ts +111 -0
  398. package/src/mantle/actions/estimateFinalizeWithdrawalGas.ts +102 -0
  399. package/src/mantle/actions/estimateInitiateERC20WithdrawalGas.ts +106 -0
  400. package/src/mantle/actions/estimateInitiateETHWithdrawalGas.ts +105 -0
  401. package/src/mantle/actions/estimateInitiateMNTWithdrawalGas.ts +106 -0
  402. package/src/mantle/actions/estimateProveWithdrawalGas.ts +114 -0
  403. package/src/mantle/actions/finalizeWithdrawal.ts +95 -0
  404. package/src/mantle/actions/getL2Output.ts +75 -0
  405. package/src/mantle/actions/getPortalVersion.ts +57 -0
  406. package/src/mantle/actions/getTimeToFinalize.ts +85 -0
  407. package/src/mantle/actions/getTimeToNextL2Output.ts +132 -0
  408. package/src/mantle/actions/getTimeToProve.ts +58 -0
  409. package/src/mantle/actions/getWithdrawalStatus.ts +225 -0
  410. package/src/mantle/actions/initiateERC20Withdrawal.ts +93 -0
  411. package/src/mantle/actions/initiateETHWithdrawal.ts +90 -0
  412. package/src/mantle/actions/initiateMNTWithdrawal.ts +91 -0
  413. package/src/mantle/actions/proveWithdrawal.ts +107 -0
  414. package/src/mantle/actions/waitForNextL2Output.ts +87 -0
  415. package/src/mantle/actions/waitToFinalize.ts +33 -0
  416. package/src/mantle/actions/waitToProve.ts +83 -0
  417. package/src/mantle/chainConfig.ts +9 -0
  418. package/src/mantle/chains/index.ts +2 -0
  419. package/src/mantle/chains/mantle.ts +51 -0
  420. package/src/mantle/chains/mantleSepoliaTestnet.ts +52 -0
  421. package/src/mantle/contracts.ts +14 -0
  422. package/src/mantle/decorators/publicL1.ts +182 -0
  423. package/src/mantle/decorators/publicL2.ts +96 -0
  424. package/src/mantle/decorators/walletL1.ts +67 -0
  425. package/src/mantle/decorators/walletL2.ts +55 -0
  426. package/src/mantle/errors/utils.ts +1 -0
  427. package/src/mantle/errors/withdrawal.ts +24 -0
  428. package/src/mantle/formatters.ts +64 -0
  429. package/src/mantle/index.ts +179 -0
  430. package/src/mantle/parsers.ts +97 -0
  431. package/src/mantle/serializers.ts +106 -0
  432. package/src/mantle/types/account.ts +25 -0
  433. package/src/mantle/types/block.ts +34 -0
  434. package/src/mantle/types/chain.ts +10 -0
  435. package/src/mantle/types/contract.ts +26 -0
  436. package/src/mantle/types/deposit.ts +40 -0
  437. package/src/mantle/types/l1Actions.ts +21 -0
  438. package/src/mantle/types/l2Actions.ts +6 -0
  439. package/src/mantle/types/transaction.ts +108 -0
  440. package/src/mantle/types/withdrawal.ts +45 -0
  441. package/src/mantle/utils/extractTransactionDepositedLogs.ts +33 -0
  442. package/src/mantle/utils/extractWithdrawalMessageLogs.ts +33 -0
  443. package/src/mantle/utils/getL2TransactionHash.ts +51 -0
  444. package/src/mantle/utils/getL2TransactionHashes.ts +21 -0
  445. package/src/mantle/utils/getSourceHash.ts +62 -0
  446. package/src/mantle/utils/getWithdrawalHashStorageSlot.ts +27 -0
  447. package/src/mantle/utils/getWithdrawals.ts +25 -0
  448. package/src/mantle/utils/opaqueDataToDepositData.ts +58 -0
  449. package/src/mantle/utils/parseDepositRequest.ts +67 -0
  450. package/src/mantle/utils/parseInitWithdrawRequest.ts +68 -0
  451. package/src/mantle/utils/poll.ts +45 -0
  452. package/src/mantle/utils/promise/withCache.ts +81 -0
  453. package/src/mantle/utils/wait.ts +3 -0
@@ -0,0 +1,64 @@
1
+ import {
2
+ defineBlock,
3
+ defineTransaction,
4
+ defineTransactionReceipt,
5
+ formatTransaction,
6
+ hexToBigInt,
7
+ } from "viem";
8
+ import type { ChainFormatters } from "viem";
9
+ import type { RpcTransaction } from "viem";
10
+ import type { OpStackBlock, OpStackRpcBlock } from "./types/block.js";
11
+ import type {
12
+ OpStackRpcTransaction,
13
+ OpStackRpcTransactionReceipt,
14
+ OpStackTransaction,
15
+ OpStackTransactionReceipt,
16
+ } from "./types/transaction.js";
17
+
18
+ export const formatters = {
19
+ block: /*#__PURE__*/ defineBlock({
20
+ format(args: OpStackRpcBlock): OpStackBlock {
21
+ const transactions = args.transactions?.map((transaction) => {
22
+ if (typeof transaction === "string") return transaction;
23
+ const formatted = formatTransaction(
24
+ transaction as RpcTransaction,
25
+ ) as OpStackTransaction;
26
+ if (formatted.typeHex === "0x7e") {
27
+ formatted.isSystemTx = transaction.isSystemTx;
28
+ formatted.mint = transaction.mint
29
+ ? hexToBigInt(transaction.mint)
30
+ : undefined;
31
+ formatted.sourceHash = transaction.sourceHash;
32
+ formatted.type = "deposit";
33
+ }
34
+ return formatted;
35
+ });
36
+ return {
37
+ transactions,
38
+ stateRoot: args.stateRoot,
39
+ } as OpStackBlock;
40
+ },
41
+ }),
42
+ transaction: /*#__PURE__*/ defineTransaction({
43
+ format(args: OpStackRpcTransaction): OpStackTransaction {
44
+ const transaction = {} as OpStackTransaction;
45
+ if (args.type === "0x7e") {
46
+ transaction.isSystemTx = args.isSystemTx;
47
+ transaction.mint = args.mint ? hexToBigInt(args.mint) : undefined;
48
+ transaction.sourceHash = args.sourceHash;
49
+ transaction.type = "deposit";
50
+ }
51
+ return transaction;
52
+ },
53
+ }),
54
+ transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({
55
+ format(args: OpStackRpcTransactionReceipt): OpStackTransactionReceipt {
56
+ return {
57
+ l1GasPrice: args.l1GasPrice ? hexToBigInt(args.l1GasPrice) : null,
58
+ l1GasUsed: args.l1GasUsed ? hexToBigInt(args.l1GasUsed) : null,
59
+ l1Fee: args.l1Fee ? hexToBigInt(args.l1Fee) : null,
60
+ l1FeeScalar: args.l1FeeScalar ? Number(args.l1FeeScalar) : null,
61
+ } as OpStackTransactionReceipt;
62
+ },
63
+ }),
64
+ } as const satisfies ChainFormatters;
@@ -0,0 +1,179 @@
1
+ // biome-ignore lint/performance/noBarrelFile: entrypoint module
2
+ export {
3
+ buildProveWithdrawal,
4
+ type BuildProveWithdrawalErrorType,
5
+ type BuildProveWithdrawalParameters,
6
+ type BuildProveWithdrawalReturnType,
7
+ } from "./actions/buildProveWithdrawal.js";
8
+
9
+ export {
10
+ finalizeWithdrawal,
11
+ type FinalizeWithdrawalErrorType,
12
+ type FinalizeWithdrawalParameters,
13
+ type FinalizeWithdrawalReturnType,
14
+ } from "./actions/finalizeWithdrawal.js";
15
+ export {
16
+ getL2Output,
17
+ type GetL2OutputErrorType,
18
+ type GetL2OutputParameters,
19
+ type GetL2OutputReturnType,
20
+ } from "./actions/getL2Output.js";
21
+ export {
22
+ getPortalVersion,
23
+ type GetPortalVersionErrorType,
24
+ type GetPortalVersionParameters,
25
+ type GetPortalVersionReturnType,
26
+ } from "./actions/getPortalVersion.js";
27
+ export {
28
+ getTimeToFinalize,
29
+ type GetTimeToFinalizeErrorType,
30
+ type GetTimeToFinalizeParameters,
31
+ type GetTimeToFinalizeReturnType,
32
+ } from "./actions/getTimeToFinalize.js";
33
+ export {
34
+ getTimeToNextL2Output,
35
+ type GetTimeToNextL2OutputErrorType,
36
+ type GetTimeToNextL2OutputParameters,
37
+ type GetTimeToNextL2OutputReturnType,
38
+ } from "./actions/getTimeToNextL2Output.js";
39
+ export {
40
+ getTimeToProve,
41
+ type GetTimeToProveErrorType,
42
+ type GetTimeToProveParameters,
43
+ type GetTimeToProveReturnType,
44
+ } from "./actions/getTimeToProve.js";
45
+ export {
46
+ getWithdrawalStatus,
47
+ type GetWithdrawalStatusErrorType,
48
+ type GetWithdrawalStatusParameters,
49
+ type GetWithdrawalStatusReturnType,
50
+ } from "./actions/getWithdrawalStatus.js";
51
+ export {
52
+ proveWithdrawal,
53
+ type ProveWithdrawalErrorType,
54
+ type ProveWithdrawalParameters,
55
+ type ProveWithdrawalReturnType,
56
+ } from "./actions/proveWithdrawal.js";
57
+ export {
58
+ waitForNextL2Output,
59
+ type WaitForNextL2OutputErrorType,
60
+ type WaitForNextL2OutputParameters,
61
+ type WaitForNextL2OutputReturnType,
62
+ } from "./actions/waitForNextL2Output.js";
63
+ export {
64
+ waitToFinalize,
65
+ type WaitToFinalizeErrorType,
66
+ type WaitToFinalizeParameters,
67
+ type WaitToFinalizeReturnType,
68
+ } from "./actions/waitToFinalize.js";
69
+ export {
70
+ waitToProve,
71
+ type WaitToProveErrorType,
72
+ type WaitToProveParameters,
73
+ type WaitToProveReturnType,
74
+ } from "./actions/waitToProve.js";
75
+
76
+ export { chainConfig } from "./chainConfig.js";
77
+
78
+ export {
79
+ type PublicActionsL1,
80
+ publicActionsL1,
81
+ } from "./decorators/publicL1.js";
82
+ export {
83
+ type PublicActionsL2,
84
+ publicActionsL2,
85
+ } from "./decorators/publicL2.js";
86
+ export {
87
+ type WalletActionsL1,
88
+ walletActionsL1,
89
+ } from "./decorators/walletL1.js";
90
+ export {
91
+ type WalletActionsL2,
92
+ walletActionsL2,
93
+ } from "./decorators/walletL2.js";
94
+
95
+ export {
96
+ parseTransaction,
97
+ type ParseTransactionErrorType,
98
+ type ParseTransactionReturnType,
99
+ } from "./parsers.js";
100
+
101
+ export {
102
+ serializers,
103
+ serializeTransaction,
104
+ type SerializeTransactionErrorType,
105
+ type SerializeTransactionReturnType,
106
+ } from "./serializers.js";
107
+
108
+ export type {
109
+ OpStackBlock,
110
+ OpStackBlockOverrides,
111
+ OpStackRpcBlock,
112
+ OpStackRpcBlockOverrides,
113
+ } from "./types/block.js";
114
+ export type {
115
+ OpStackDepositTransaction,
116
+ OpStackRpcDepositTransaction,
117
+ OpStackRpcTransaction,
118
+ OpStackRpcTransactionReceipt,
119
+ OpStackRpcTransactionReceiptOverrides,
120
+ OpStackTransaction,
121
+ OpStackTransactionReceipt,
122
+ OpStackTransactionReceiptOverrides,
123
+ } from "./types/transaction.js";
124
+
125
+ export {
126
+ extractWithdrawalMessageLogs,
127
+ type ExtractWithdrawalMessageLogsErrorType,
128
+ type ExtractWithdrawalMessageLogsParameters,
129
+ type ExtractWithdrawalMessageLogsReturnType,
130
+ } from "./utils/extractWithdrawalMessageLogs.js";
131
+
132
+ export {
133
+ extractTransactionDepositedLogs,
134
+ type ExtractTransactionDepositedLogsErrorType,
135
+ type ExtractTransactionDepositedLogsParameters,
136
+ type ExtractTransactionDepositedLogsReturnType,
137
+ } from "./utils/extractTransactionDepositedLogs.js";
138
+
139
+ export {
140
+ opaqueDataToDepositData,
141
+ type OpaqueDataToDepositDataErrorType,
142
+ type OpaqueDataToDepositDataParameters,
143
+ type OpaqueDataToDepositDataReturnType,
144
+ } from "./utils/opaqueDataToDepositData.js";
145
+
146
+ export {
147
+ getL2TransactionHash,
148
+ type GetL2TransactionHashErrorType,
149
+ type GetL2TransactionHashParameters,
150
+ type GetL2TransactionHashReturnType,
151
+ } from "./utils/getL2TransactionHash.js";
152
+
153
+ export {
154
+ getL2TransactionHashes,
155
+ type GetL2TransactionHashesErrorType,
156
+ type GetL2TransactionHashesParameters,
157
+ type GetL2TransactionHashesReturnType,
158
+ } from "./utils/getL2TransactionHashes.js";
159
+
160
+ export {
161
+ getSourceHash,
162
+ type GetSourceHashErrorType,
163
+ type GetSourceHashParameters,
164
+ type GetSourceHashReturnType,
165
+ } from "./utils/getSourceHash.js";
166
+
167
+ export {
168
+ getWithdrawalHashStorageSlot,
169
+ type GetWithdrawalHashStorageSlotErrorType,
170
+ type GetWithdrawalHashStorageSlotParameters,
171
+ type GetWithdrawalHashStorageSlotReturnType,
172
+ } from "./utils/getWithdrawalHashStorageSlot.js";
173
+
174
+ export {
175
+ getWithdrawals,
176
+ type GetWithdrawalsErrorType,
177
+ type GetWithdrawalsParameters,
178
+ type GetWithdrawalsReturnType,
179
+ } from "./utils/getWithdrawals.js";
@@ -0,0 +1,97 @@
1
+ import {
2
+ fromRlp,
3
+ type GetSerializedTransactionType,
4
+ type Hex,
5
+ hexToBigInt,
6
+ hexToBool,
7
+ isHex,
8
+ parseTransaction as parseTransaction_,
9
+ type ParseTransactionErrorType as ParseTransactionErrorType_,
10
+ type ParseTransactionReturnType as ParseTransactionReturnType_,
11
+ sliceHex,
12
+ } from "viem";
13
+ import { InvalidSerializedTransactionError } from "viem";
14
+ import type { ErrorType } from "./errors/utils.js";
15
+ import { assertTransactionDeposit } from "./serializers.js";
16
+ import type {
17
+ OpStackTransactionSerialized,
18
+ OpStackTransactionType,
19
+ TransactionSerializableDeposit,
20
+ TransactionSerializedDeposit,
21
+ } from "./types/transaction.js";
22
+
23
+ export function toTransactionArray(serializedTransaction: string) {
24
+ return fromRlp(`0x${serializedTransaction.slice(4)}` as Hex, "hex");
25
+ }
26
+
27
+ export type ParseTransactionReturnType<
28
+ serialized extends
29
+ OpStackTransactionSerialized = OpStackTransactionSerialized,
30
+ type extends
31
+ OpStackTransactionType = GetSerializedTransactionType<serialized>,
32
+ > = serialized extends TransactionSerializedDeposit
33
+ ? TransactionSerializableDeposit
34
+ : ParseTransactionReturnType_<serialized, type>;
35
+
36
+ export type ParseTransactionErrorType = ParseTransactionErrorType_ | ErrorType;
37
+
38
+ export function parseTransaction<
39
+ serialized extends OpStackTransactionSerialized,
40
+ >(serializedTransaction: serialized): ParseTransactionReturnType<serialized> {
41
+ const serializedType = sliceHex(serializedTransaction, 0, 1);
42
+
43
+ if (serializedType === "0x7e") {
44
+ return parseTransactionDeposit(
45
+ serializedTransaction as TransactionSerializedDeposit,
46
+ ) as ParseTransactionReturnType<serialized>;
47
+ }
48
+
49
+ return parseTransaction_(
50
+ serializedTransaction,
51
+ ) as ParseTransactionReturnType<serialized>;
52
+ }
53
+
54
+ function parseTransactionDeposit(
55
+ serializedTransaction: TransactionSerializedDeposit,
56
+ ): ParseTransactionReturnType<TransactionSerializedDeposit> {
57
+ const transactionArray = toTransactionArray(serializedTransaction);
58
+
59
+ const [sourceHash, from, to, mint, value, gas, isSystemTx, data] =
60
+ transactionArray;
61
+
62
+ if (transactionArray.length !== 8 || !isHex(sourceHash) || !isHex(from)) {
63
+ throw new InvalidSerializedTransactionError({
64
+ attributes: {
65
+ sourceHash,
66
+ from,
67
+ gas,
68
+ to,
69
+ mint,
70
+ value,
71
+ isSystemTx,
72
+ data,
73
+ },
74
+ serializedTransaction,
75
+ type: "deposit",
76
+ });
77
+ }
78
+
79
+ const transaction: TransactionSerializableDeposit = {
80
+ sourceHash,
81
+ from,
82
+ type: "deposit",
83
+ };
84
+
85
+ if (isHex(gas) && gas !== "0x") transaction.gas = hexToBigInt(gas);
86
+ if (isHex(to) && to !== "0x") transaction.to = to;
87
+ if (isHex(mint) && mint !== "0x") transaction.mint = hexToBigInt(mint);
88
+ if (isHex(value) && value !== "0x") transaction.value = hexToBigInt(value);
89
+ if (isHex(isSystemTx) && isSystemTx !== "0x") {
90
+ transaction.isSystemTx = hexToBool(isSystemTx);
91
+ }
92
+ if (isHex(data) && data !== "0x") transaction.data = data;
93
+
94
+ assertTransactionDeposit(transaction);
95
+
96
+ return transaction;
97
+ }
@@ -0,0 +1,106 @@
1
+ import {
2
+ concatHex,
3
+ isAddress,
4
+ serializeTransaction as serializeTransaction_,
5
+ type SerializeTransactionErrorType as SerializeTransactionErrorType_,
6
+ toHex,
7
+ toRlp,
8
+ } from "viem";
9
+ import { InvalidAddressError } from "viem";
10
+ import type { ChainSerializers } from "viem";
11
+ import type { Hex, Signature } from "viem";
12
+ import type { TransactionSerializable } from "viem";
13
+ import type { RequiredBy } from "viem";
14
+ import type { ErrorType } from "./errors/utils.js";
15
+ import type {
16
+ OpStackTransactionSerializable,
17
+ TransactionSerializableDeposit,
18
+ TransactionSerializedDeposit,
19
+ } from "./types/transaction.js";
20
+
21
+ export type SerializeTransactionReturnType = ReturnType<
22
+ typeof serializeTransaction
23
+ >;
24
+
25
+ export type SerializeTransactionErrorType =
26
+ | SerializeTransactionErrorType_
27
+ | ErrorType;
28
+
29
+ export function serializeTransaction(
30
+ transaction: OpStackTransactionSerializable,
31
+ signature?: Signature,
32
+ ) {
33
+ if (isDeposit(transaction)) return serializeTransactionDeposit(transaction);
34
+ return serializeTransaction_(
35
+ transaction as TransactionSerializable,
36
+ signature,
37
+ );
38
+ }
39
+
40
+ export const serializers = {
41
+ transaction: serializeTransaction,
42
+ } as const satisfies ChainSerializers;
43
+
44
+ //////////////////////////////////////////////////////////////////////////////
45
+ // Serializers
46
+
47
+ export type SerializeTransactionDepositReturnType =
48
+ TransactionSerializedDeposit;
49
+
50
+ function serializeTransactionDeposit(
51
+ transaction: TransactionSerializableDeposit,
52
+ ): SerializeTransactionDepositReturnType {
53
+ assertTransactionDeposit(transaction);
54
+
55
+ const {
56
+ sourceHash,
57
+ data,
58
+ from,
59
+ gas,
60
+ isSystemTx,
61
+ mint,
62
+ to,
63
+ value,
64
+ ethValue,
65
+ ethTxValue,
66
+ } = transaction;
67
+
68
+ const serializedTransaction: Hex[] = [
69
+ sourceHash,
70
+ from,
71
+ to ?? "0x",
72
+ mint ? toHex(mint) : "0x",
73
+ value ? toHex(value) : "0x",
74
+ gas ? toHex(gas) : "0x",
75
+ isSystemTx ? "0x1" : "0x",
76
+ ethValue ? toHex(ethValue) : "0x",
77
+ data ?? "0x",
78
+ ];
79
+
80
+ if (ethTxValue) {
81
+ serializedTransaction.push(toHex(ethTxValue));
82
+ }
83
+
84
+ return concatHex([
85
+ "0x7e",
86
+ toRlp(serializedTransaction),
87
+ ]) as SerializeTransactionDepositReturnType;
88
+ }
89
+
90
+ function isDeposit(
91
+ transaction: OpStackTransactionSerializable,
92
+ ): transaction is RequiredBy<TransactionSerializableDeposit, "type"> {
93
+ if (transaction.type === "deposit") return true;
94
+ if (typeof transaction.sourceHash !== "undefined") return true;
95
+ return false;
96
+ }
97
+
98
+ export function assertTransactionDeposit(
99
+ transaction: TransactionSerializableDeposit,
100
+ ) {
101
+ const { from, to } = transaction;
102
+ if (from && !isAddress(from)) {
103
+ throw new InvalidAddressError({ address: from });
104
+ }
105
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to });
106
+ }
@@ -0,0 +1,25 @@
1
+ import type { Address } from "viem";
2
+
3
+ import type { Account } from "viem";
4
+ import type { IsUndefined, MaybeRequired } from "viem";
5
+
6
+ export type GetAccountParameter<
7
+ account extends Account | undefined = Account | undefined,
8
+ accountOverride extends Account | Address | undefined = Account | Address,
9
+ required extends boolean = true,
10
+ nullish extends boolean = false,
11
+ > = MaybeRequired<
12
+ {
13
+ account?:
14
+ | accountOverride
15
+ | Account
16
+ | Address
17
+ | (nullish extends true ? null : never)
18
+ | undefined;
19
+ },
20
+ IsUndefined<account> extends true
21
+ ? required extends true
22
+ ? true
23
+ : false
24
+ : false
25
+ >;
@@ -0,0 +1,34 @@
1
+ import type { Block, BlockTag } from "viem";
2
+ import type { Hash } from "viem";
3
+ import type { RpcBlock } from "viem";
4
+ import type {
5
+ OpStackRpcTransaction,
6
+ OpStackTransaction,
7
+ } from "./transaction.js";
8
+
9
+ export type OpStackBlockOverrides = {
10
+ stateRoot: Hash;
11
+ };
12
+ export type OpStackBlock<
13
+ includeTransactions extends boolean = boolean,
14
+ blockTag extends BlockTag = BlockTag,
15
+ > = Block<
16
+ bigint,
17
+ includeTransactions,
18
+ blockTag,
19
+ OpStackTransaction<blockTag extends "pending" ? true : false>
20
+ > &
21
+ OpStackBlockOverrides;
22
+
23
+ export type OpStackRpcBlockOverrides = {
24
+ stateRoot: Hash;
25
+ };
26
+ export type OpStackRpcBlock<
27
+ blockTag extends BlockTag = BlockTag,
28
+ includeTransactions extends boolean = boolean,
29
+ > = RpcBlock<
30
+ blockTag,
31
+ includeTransactions,
32
+ OpStackRpcTransaction<blockTag extends "pending" ? true : false>
33
+ > &
34
+ OpStackRpcBlockOverrides;
@@ -0,0 +1,10 @@
1
+ import type { Chain, ChainContract } from "viem";
2
+
3
+ export type TargetChain<
4
+ chain extends Chain = Chain,
5
+ contractName extends string = string,
6
+ > = {
7
+ contracts: {
8
+ [_ in contractName]: { [_ in chain["id"]]: ChainContract };
9
+ };
10
+ };
@@ -0,0 +1,26 @@
1
+ import type { Address } from "viem";
2
+
3
+ import type { Chain } from "viem";
4
+ import type { Prettify } from "viem";
5
+ import type { TargetChain } from "./chain.js";
6
+
7
+ export type GetContractAddressParameter<
8
+ chain extends Chain | undefined,
9
+ contractName extends string,
10
+ > =
11
+ | (chain extends Chain
12
+ ? Prettify<
13
+ {
14
+ targetChain: Prettify<TargetChain<chain, contractName>>;
15
+ } & {
16
+ [_ in `${contractName}Address`]?: undefined;
17
+ }
18
+ >
19
+ : never)
20
+ | Prettify<
21
+ {
22
+ targetChain?: undefined;
23
+ } & {
24
+ [_ in `${contractName}Address`]: Address;
25
+ }
26
+ >;
@@ -0,0 +1,40 @@
1
+ import type { Address } from "viem";
2
+
3
+ export type DepositRequest = {
4
+ /** L2 Transaction recipient. */
5
+ // to: Address;
6
+ amount: bigint;
7
+ to?: Address;
8
+ } & (
9
+ | {
10
+ type: "mnt" | "eth";
11
+ /** Other ERC20 L1 Token Address. */
12
+ l1Token?: undefined;
13
+ /** Other ERC20 L2 Token Address. */
14
+ l2Token?: undefined;
15
+ }
16
+ | {
17
+ type: "erc20";
18
+ /** Other ERC20 L1 Token Address. */
19
+ l1Token: Address;
20
+ /** Other ERC20 L2 Token Address. */
21
+ l2Token: Address;
22
+ }
23
+ );
24
+
25
+ export type DepositERC20Request = {
26
+ amount: bigint;
27
+ /** Other ERC20 L1 Token Address. */
28
+ l1Token: Address;
29
+ /** Other ERC20 L2 Token Address. */
30
+ l2Token: Address;
31
+ to?: Address;
32
+ };
33
+ export type DepositMNTRequest = {
34
+ amount: bigint;
35
+ to?: Address;
36
+ };
37
+ export type DepositETHRequest = {
38
+ amount: bigint;
39
+ to?: Address;
40
+ };
@@ -0,0 +1,21 @@
1
+ import type { Address, Hex } from "viem";
2
+ import { l1StandardBridge } from "../abis.js";
3
+
4
+ export const depositABI = l1StandardBridge;
5
+ export const depositErc20Function = "depositERC20To";
6
+ export const l1StandardBridgeName = "l1StandardBridge";
7
+
8
+ export type DepositERC20Parameters = {
9
+ /** Gas limit for transaction execution on the L2. Default as 20000 */
10
+ minGasLimit?: bigint | undefined;
11
+ /** Value in wei of tokens to deposit. */
12
+ amount: bigint;
13
+ /** Extra data to include in the transaction. */
14
+ extraData?: Hex | undefined;
15
+ /** L2 Transaction recipient. */
16
+ to?: Address | undefined;
17
+ /** ERC20 L1 Token Address. */
18
+ l1Token: Address;
19
+ /** ERC20 L2 Token Address. */
20
+ l2Token: Address;
21
+ };
@@ -0,0 +1,6 @@
1
+ import { type Address, zeroAddress } from "viem";
2
+
3
+ export const parseWithdrawL2Token = (l2Token?: Address) => {
4
+ if (!l2Token) return zeroAddress;
5
+ return l2Token;
6
+ };