@aptos-labs/ts-sdk 1.31.0 → 1.32.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 (541) hide show
  1. package/README.md +1 -1
  2. package/dist/common/{accountAddress-DnSqjhSl.d.ts → accountAddress-6RqI8Aam.d.ts} +144 -63
  3. package/dist/common/chunk-F43XVDYJ.js +2 -0
  4. package/dist/common/chunk-F43XVDYJ.js.map +1 -0
  5. package/dist/common/cli/index.d.ts +1 -1
  6. package/dist/common/cli/index.js +1 -1
  7. package/dist/common/cli/index.js.map +1 -1
  8. package/dist/common/index.d.ts +542 -111
  9. package/dist/common/index.js +36 -29
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/{Ed25519Account-DpH9qAcg.d.mts → Ed25519Account-B3xHXAQe.d.mts} +2 -2
  12. package/dist/esm/account/AbstractKeylessAccount.d.mts +86 -14
  13. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  14. package/dist/esm/account/Account.d.mts +5 -4
  15. package/dist/esm/account/Account.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.d.mts +5 -4
  17. package/dist/esm/account/Ed25519Account.mjs +1 -1
  18. package/dist/esm/account/EphemeralKeyPair.d.mts +4 -3
  19. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  20. package/dist/esm/account/FederatedKeylessAccount.d.mts +57 -8
  21. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  22. package/dist/esm/account/KeylessAccount.d.mts +29 -11
  23. package/dist/esm/account/KeylessAccount.mjs +1 -1
  24. package/dist/esm/account/MultiKeyAccount.d.mts +23 -10
  25. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  26. package/dist/esm/account/SingleKeyAccount.d.mts +5 -4
  27. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  28. package/dist/esm/account/index.d.mts +6 -5
  29. package/dist/esm/account/index.mjs +1 -1
  30. package/dist/esm/api/account.d.mts +6 -5
  31. package/dist/esm/api/account.mjs +1 -1
  32. package/dist/esm/api/ans.d.mts +4 -3
  33. package/dist/esm/api/ans.mjs +1 -1
  34. package/dist/esm/api/aptos.d.mts +6 -4
  35. package/dist/esm/api/aptos.mjs +1 -1
  36. package/dist/esm/api/aptosConfig.d.mts +2 -1
  37. package/dist/esm/api/coin.d.mts +4 -3
  38. package/dist/esm/api/coin.mjs +1 -1
  39. package/dist/esm/api/digitalAsset.d.mts +6 -5
  40. package/dist/esm/api/digitalAsset.mjs +1 -1
  41. package/dist/esm/api/event.d.mts +4 -3
  42. package/dist/esm/api/event.mjs +1 -1
  43. package/dist/esm/api/faucet.d.mts +3 -2
  44. package/dist/esm/api/faucet.mjs +1 -1
  45. package/dist/esm/api/fungibleAsset.d.mts +6 -5
  46. package/dist/esm/api/fungibleAsset.mjs +1 -1
  47. package/dist/esm/api/general.d.mts +4 -3
  48. package/dist/esm/api/general.mjs +1 -1
  49. package/dist/esm/api/index.d.mts +6 -4
  50. package/dist/esm/api/index.mjs +1 -1
  51. package/dist/esm/api/keyless.d.mts +7 -6
  52. package/dist/esm/api/keyless.mjs +1 -1
  53. package/dist/esm/api/object.d.mts +4 -3
  54. package/dist/esm/api/object.mjs +1 -1
  55. package/dist/esm/api/staking.d.mts +4 -3
  56. package/dist/esm/api/staking.mjs +1 -1
  57. package/dist/esm/api/table.d.mts +4 -3
  58. package/dist/esm/api/table.mjs +1 -1
  59. package/dist/esm/api/transaction.d.mts +5 -3
  60. package/dist/esm/api/transaction.mjs +1 -1
  61. package/dist/esm/api/transactionSubmission/build.d.mts +69 -3
  62. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  63. package/dist/esm/api/transactionSubmission/management.d.mts +5 -4
  64. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  65. package/dist/esm/api/transactionSubmission/sign.d.mts +5 -4
  66. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  67. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  68. package/dist/esm/api/transactionSubmission/simulate.d.mts +4 -3
  69. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  70. package/dist/esm/api/transactionSubmission/submit.d.mts +4 -3
  71. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  72. package/dist/esm/api/utils.d.mts +3 -2
  73. package/dist/esm/api/utils.mjs +1 -1
  74. package/dist/esm/bcs/consts.d.mts +3 -2
  75. package/dist/esm/bcs/deserializer.d.mts +36 -27
  76. package/dist/esm/bcs/deserializer.mjs +1 -1
  77. package/dist/esm/bcs/index.d.mts +3 -2
  78. package/dist/esm/bcs/index.mjs +1 -1
  79. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +3 -2
  80. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  81. package/dist/esm/bcs/serializable/fixedBytes.d.mts +3 -2
  82. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  83. package/dist/esm/bcs/serializable/movePrimitives.d.mts +3 -2
  84. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  85. package/dist/esm/bcs/serializable/moveStructs.d.mts +12 -12
  86. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  87. package/dist/esm/bcs/serializer.d.mts +14 -13
  88. package/dist/esm/bcs/serializer.mjs +1 -1
  89. package/dist/esm/{chunk-4ZK3JNQT.mjs → chunk-2NHQQQZK.mjs} +2 -2
  90. package/dist/esm/{chunk-MSHZ4FWB.mjs → chunk-2QBCTW67.mjs} +2 -2
  91. package/dist/esm/{chunk-MSHZ4FWB.mjs.map → chunk-2QBCTW67.mjs.map} +1 -1
  92. package/dist/esm/{chunk-F2RY4YQ7.mjs → chunk-37Y54PJ5.mjs} +2 -2
  93. package/dist/esm/chunk-3DQVGPFE.mjs +2 -0
  94. package/dist/esm/chunk-3DQVGPFE.mjs.map +1 -0
  95. package/dist/esm/{chunk-OAEDFM7T.mjs → chunk-3XCYCFYI.mjs} +2 -2
  96. package/dist/esm/{chunk-6FLHGOKP.mjs → chunk-42H7WETG.mjs} +2 -2
  97. package/dist/esm/{chunk-AZ6LVQEG.mjs → chunk-46L6BAJG.mjs} +2 -2
  98. package/dist/esm/{chunk-KW4FVBDD.mjs → chunk-4DNCQM3S.mjs} +2 -2
  99. package/dist/esm/chunk-4O5XDQDO.mjs +2 -0
  100. package/dist/esm/chunk-4PBXTMN3.mjs +2 -0
  101. package/dist/esm/chunk-4PBXTMN3.mjs.map +1 -0
  102. package/dist/esm/chunk-4YEOOZ2N.mjs +4 -0
  103. package/dist/esm/{chunk-HM5HITUC.mjs.map → chunk-4YEOOZ2N.mjs.map} +1 -1
  104. package/dist/esm/{chunk-5N6KJ7KS.mjs → chunk-5AKSORBJ.mjs} +2 -2
  105. package/dist/esm/chunk-5B3SMBXQ.mjs +2 -0
  106. package/dist/esm/{chunk-UCRROMZN.mjs → chunk-5NJWJXSS.mjs} +2 -2
  107. package/dist/esm/{chunk-CL6EEMSL.mjs → chunk-6K4TOFCO.mjs} +2 -2
  108. package/dist/esm/{chunk-RNJHULIT.mjs → chunk-6LLGRGCN.mjs} +2 -2
  109. package/dist/esm/chunk-6LLGRGCN.mjs.map +1 -0
  110. package/dist/esm/{chunk-IAVI3H4V.mjs → chunk-6PJH53CK.mjs} +2 -2
  111. package/dist/esm/{chunk-PCLU4KLY.mjs → chunk-6ZOVTYLJ.mjs} +2 -2
  112. package/dist/esm/chunk-7ECCT6PK.mjs +1 -0
  113. package/dist/esm/chunk-7WXDXBXK.mjs +2 -0
  114. package/dist/esm/{chunk-WV2VJQDS.mjs.map → chunk-7WXDXBXK.mjs.map} +1 -1
  115. package/dist/esm/{chunk-RAJTNQNL.mjs → chunk-AAATWCJT.mjs} +2 -2
  116. package/dist/esm/{chunk-NODYW7DM.mjs → chunk-ACVIE7IE.mjs} +2 -2
  117. package/dist/esm/chunk-AHWZA3GD.mjs +2 -0
  118. package/dist/esm/chunk-AHWZA3GD.mjs.map +1 -0
  119. package/dist/esm/{chunk-QQIVWB6G.mjs → chunk-AJ5JHBAE.mjs} +2 -2
  120. package/dist/esm/{chunk-QQIVWB6G.mjs.map → chunk-AJ5JHBAE.mjs.map} +1 -1
  121. package/dist/esm/{chunk-PRZ7AIGA.mjs → chunk-AKIO3OIT.mjs} +2 -2
  122. package/dist/esm/chunk-AMCJQIOT.mjs +2 -0
  123. package/dist/esm/{chunk-2CGJLPHP.mjs.map → chunk-AMCJQIOT.mjs.map} +1 -1
  124. package/dist/esm/{chunk-KRVLR3L4.mjs → chunk-AOROYJ74.mjs} +2 -2
  125. package/dist/esm/chunk-AVPQOD67.mjs +2 -0
  126. package/dist/esm/chunk-AVPQOD67.mjs.map +1 -0
  127. package/dist/esm/chunk-AVZYJAXR.mjs +2 -0
  128. package/dist/esm/chunk-AVZYJAXR.mjs.map +1 -0
  129. package/dist/esm/{chunk-6DMDYBV6.mjs → chunk-BLLHTGAP.mjs} +2 -2
  130. package/dist/esm/{chunk-JGNMNCQB.mjs → chunk-BRV3RLKW.mjs} +2 -2
  131. package/dist/esm/{chunk-7JK7UG4E.mjs → chunk-CA3Q2X6B.mjs} +2 -2
  132. package/dist/esm/chunk-D52UKPQF.mjs +2 -0
  133. package/dist/esm/chunk-D52UKPQF.mjs.map +1 -0
  134. package/dist/esm/{chunk-SOLWFAUY.mjs → chunk-DDVOBEJA.mjs} +2 -2
  135. package/dist/esm/chunk-DDVOBEJA.mjs.map +1 -0
  136. package/dist/esm/{chunk-RNRNGJDA.mjs → chunk-DP3YPGIK.mjs} +2 -2
  137. package/dist/esm/{chunk-KYJU5PWF.mjs → chunk-DSKAMBBL.mjs} +2 -2
  138. package/dist/esm/{chunk-L5J3V3HW.mjs → chunk-E2NYQVP3.mjs} +2 -2
  139. package/dist/esm/chunk-EEB7EZFO.mjs +2 -0
  140. package/dist/esm/chunk-EEB7EZFO.mjs.map +1 -0
  141. package/dist/esm/{chunk-4JXB6V5O.mjs → chunk-F2AIWA7L.mjs} +2 -2
  142. package/dist/esm/chunk-F45G3GP3.mjs +7 -0
  143. package/dist/esm/chunk-F45G3GP3.mjs.map +1 -0
  144. package/dist/esm/{chunk-WSZCPSV4.mjs → chunk-FXUI3SSD.mjs} +2 -2
  145. package/dist/esm/chunk-G2GN4LH5.mjs +2 -0
  146. package/dist/esm/chunk-G2GN4LH5.mjs.map +1 -0
  147. package/dist/esm/chunk-GBVRCWCD.mjs +2 -0
  148. package/dist/esm/chunk-GBVRCWCD.mjs.map +1 -0
  149. package/dist/esm/chunk-H457BI3I.mjs +2 -0
  150. package/dist/esm/chunk-H457BI3I.mjs.map +1 -0
  151. package/dist/esm/{chunk-A2AEFKXS.mjs → chunk-HEHVWRMO.mjs} +2 -2
  152. package/dist/esm/{chunk-UGL2GPGK.mjs → chunk-HFWFDS6Y.mjs} +2 -2
  153. package/dist/esm/{chunk-OXM4BVAY.mjs → chunk-HXXELLHN.mjs} +2 -2
  154. package/dist/esm/{chunk-RBJNSUSU.mjs → chunk-IBMZYDAR.mjs} +2 -2
  155. package/dist/esm/{chunk-AT2ZGTXQ.mjs → chunk-IDNDUJOK.mjs} +2 -2
  156. package/dist/esm/{chunk-3H5DGQKX.mjs → chunk-II654QZU.mjs} +2 -2
  157. package/dist/esm/{chunk-JNRMHDRA.mjs → chunk-JDNI5VIJ.mjs} +2 -2
  158. package/dist/esm/{chunk-73GCGRFW.mjs → chunk-JJUINAQE.mjs} +2 -2
  159. package/dist/esm/{chunk-VYMRIKUV.mjs → chunk-JLD7DLKM.mjs} +2 -2
  160. package/dist/esm/chunk-JNO7KPMG.mjs +4 -0
  161. package/dist/esm/chunk-JNO7KPMG.mjs.map +1 -0
  162. package/dist/esm/chunk-K4TJRYGQ.mjs +2 -0
  163. package/dist/esm/chunk-K4TJRYGQ.mjs.map +1 -0
  164. package/dist/esm/{chunk-XFJD6QIP.mjs → chunk-KA5FX53Q.mjs} +2 -2
  165. package/dist/esm/{chunk-2GEIHUHT.mjs → chunk-KT3DT5GV.mjs} +2 -2
  166. package/dist/esm/chunk-KT3DT5GV.mjs.map +1 -0
  167. package/dist/esm/chunk-KUL55M2H.mjs +2 -0
  168. package/dist/esm/chunk-KUL55M2H.mjs.map +1 -0
  169. package/dist/esm/{chunk-ZPIMARUG.mjs → chunk-L2QVUMBV.mjs} +2 -2
  170. package/dist/esm/chunk-L2SDI7PI.mjs +2 -0
  171. package/dist/esm/chunk-L2SDI7PI.mjs.map +1 -0
  172. package/dist/esm/chunk-L56DQ4N3.mjs +2 -0
  173. package/dist/esm/chunk-L56DQ4N3.mjs.map +1 -0
  174. package/dist/esm/{chunk-TPJLAYW6.mjs → chunk-LAAFLCDM.mjs} +2 -2
  175. package/dist/esm/{chunk-AGBA3Y7A.mjs → chunk-LGTOOAQI.mjs} +2 -2
  176. package/dist/esm/chunk-MHN6XY4Z.mjs +2 -0
  177. package/dist/esm/{chunk-JVTDP4KV.mjs → chunk-MOGPSSTD.mjs} +2 -2
  178. package/dist/esm/{chunk-WZCKSN2U.mjs → chunk-NARS3JDH.mjs} +2 -2
  179. package/dist/esm/{chunk-YZ5BCOGI.mjs → chunk-NHKAQRJB.mjs} +2 -2
  180. package/dist/esm/{chunk-PHP47DI4.mjs → chunk-OIOGOW6I.mjs} +1 -1
  181. package/dist/esm/{chunk-PHP47DI4.mjs.map → chunk-OIOGOW6I.mjs.map} +1 -1
  182. package/dist/esm/{chunk-T5BCTWGK.mjs → chunk-OJBMR5CT.mjs} +2 -2
  183. package/dist/esm/chunk-OJBMR5CT.mjs.map +1 -0
  184. package/dist/esm/{chunk-LDZPO76C.mjs → chunk-OKE3FXIP.mjs} +2 -2
  185. package/dist/esm/chunk-ONFKJ57C.mjs +2 -0
  186. package/dist/esm/chunk-ONFKJ57C.mjs.map +1 -0
  187. package/dist/esm/{chunk-ZINOJTLU.mjs → chunk-OPO5EYF7.mjs} +2 -2
  188. package/dist/esm/{chunk-BVVHGSWC.mjs → chunk-PW3ISXPN.mjs} +2 -2
  189. package/dist/esm/{chunk-CC7VOPYH.mjs → chunk-QQM47PHZ.mjs} +2 -2
  190. package/dist/esm/{chunk-EUGLLGYW.mjs → chunk-SBCLBDCP.mjs} +2 -2
  191. package/dist/esm/chunk-SPRNSFUV.mjs +2 -0
  192. package/dist/esm/chunk-SPRNSFUV.mjs.map +1 -0
  193. package/dist/esm/{chunk-EE7GDBA5.mjs → chunk-SU2WB34N.mjs} +2 -2
  194. package/dist/esm/{chunk-OTY3NO7Q.mjs → chunk-T6ADNZE5.mjs} +2 -2
  195. package/dist/esm/{chunk-IECDO22V.mjs → chunk-TM7OZT3W.mjs} +2 -2
  196. package/dist/esm/chunk-TM7OZT3W.mjs.map +1 -0
  197. package/dist/esm/chunk-UGTIALNW.mjs +2 -0
  198. package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
  199. package/dist/esm/chunk-UZTJWOLS.mjs +2 -0
  200. package/dist/esm/chunk-V4FKFCBL.mjs +2 -0
  201. package/dist/esm/chunk-V4FKFCBL.mjs.map +1 -0
  202. package/dist/esm/{chunk-ZPQUCT22.mjs → chunk-VCY3JGZM.mjs} +2 -2
  203. package/dist/esm/{chunk-XOCRDV2V.mjs → chunk-VQZMI3EZ.mjs} +2 -2
  204. package/dist/esm/chunk-WGIYSLH6.mjs +2 -0
  205. package/dist/esm/chunk-WGIYSLH6.mjs.map +1 -0
  206. package/dist/esm/{chunk-2652SPOM.mjs → chunk-WKNX43KN.mjs} +2 -2
  207. package/dist/esm/chunk-WKNX43KN.mjs.map +1 -0
  208. package/dist/esm/chunk-WQF3IOXC.mjs +2 -0
  209. package/dist/esm/chunk-WQF3IOXC.mjs.map +1 -0
  210. package/dist/esm/{chunk-IFXUWUP2.mjs → chunk-WSFHH3BK.mjs} +2 -2
  211. package/dist/esm/{chunk-4LKLOUMG.mjs → chunk-X3JPX7T6.mjs} +2 -2
  212. package/dist/esm/{chunk-22ZSW5EN.mjs → chunk-XKOSS5KC.mjs} +2 -2
  213. package/dist/esm/{chunk-BG2TZI3H.mjs → chunk-XT5T5LAP.mjs} +2 -2
  214. package/dist/esm/chunk-XUP6VABV.mjs +2 -0
  215. package/dist/esm/chunk-XUP6VABV.mjs.map +1 -0
  216. package/dist/esm/{chunk-XQ7ONNII.mjs → chunk-YNT7JHMS.mjs} +2 -2
  217. package/dist/esm/{chunk-BOWPP6YG.mjs → chunk-YPBNYKOD.mjs} +2 -2
  218. package/dist/esm/{chunk-MK2QAHXC.mjs → chunk-YZ3YPLEU.mjs} +2 -2
  219. package/dist/esm/{chunk-OZN3OOJV.mjs → chunk-ZMBXHMVQ.mjs} +2 -2
  220. package/dist/esm/{chunk-XFY4O2S3.mjs → chunk-ZRWZIAF5.mjs} +2 -2
  221. package/dist/esm/cli/index.d.mts +3 -2
  222. package/dist/esm/cli/index.mjs +1 -1
  223. package/dist/esm/cli/localNode.mjs +1 -1
  224. package/dist/esm/cli/move.d.mts +2 -1
  225. package/dist/esm/client/core.d.mts +2 -2
  226. package/dist/esm/client/core.mjs +1 -1
  227. package/dist/esm/client/get.d.mts +2 -2
  228. package/dist/esm/client/get.mjs +1 -1
  229. package/dist/esm/client/index.d.mts +3 -3
  230. package/dist/esm/client/index.mjs +1 -1
  231. package/dist/esm/client/post.d.mts +2 -2
  232. package/dist/esm/client/post.mjs +1 -1
  233. package/dist/esm/core/account/index.d.mts +3 -2
  234. package/dist/esm/core/account/index.mjs +1 -1
  235. package/dist/esm/core/account/utils/address.d.mts +3 -2
  236. package/dist/esm/core/account/utils/address.mjs +1 -1
  237. package/dist/esm/core/account/utils/index.d.mts +3 -2
  238. package/dist/esm/core/account/utils/index.mjs +1 -1
  239. package/dist/esm/core/accountAddress.d.mts +20 -10
  240. package/dist/esm/core/accountAddress.mjs +1 -1
  241. package/dist/esm/core/authenticationKey.d.mts +4 -3
  242. package/dist/esm/core/authenticationKey.mjs +1 -1
  243. package/dist/esm/core/crypto/ed25519.d.mts +27 -12
  244. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  245. package/dist/esm/core/crypto/ephemeral.d.mts +4 -3
  246. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  247. package/dist/esm/core/crypto/federatedKeyless.d.mts +5 -4
  248. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  249. package/dist/esm/core/crypto/hdKey.d.mts +0 -1
  250. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  251. package/dist/esm/core/crypto/index.d.mts +5 -4
  252. package/dist/esm/core/crypto/index.mjs +1 -1
  253. package/dist/esm/core/crypto/keyless.d.mts +73 -11
  254. package/dist/esm/core/crypto/keyless.mjs +1 -1
  255. package/dist/esm/core/crypto/multiEd25519.d.mts +4 -3
  256. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  257. package/dist/esm/core/crypto/multiKey.d.mts +4 -3
  258. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  259. package/dist/esm/core/crypto/privateKey.d.mts +38 -10
  260. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  261. package/dist/esm/core/crypto/proof.d.mts +3 -2
  262. package/dist/esm/core/crypto/proof.mjs +1 -1
  263. package/dist/esm/core/crypto/publicKey.d.mts +4 -3
  264. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  265. package/dist/esm/core/crypto/secp256k1.d.mts +24 -9
  266. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  267. package/dist/esm/core/crypto/signature.d.mts +3 -2
  268. package/dist/esm/core/crypto/signature.mjs +1 -1
  269. package/dist/esm/core/crypto/singleKey.d.mts +4 -3
  270. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  271. package/dist/esm/core/crypto/utils.d.mts +3 -2
  272. package/dist/esm/core/crypto/utils.mjs +1 -1
  273. package/dist/esm/core/hex.d.mts +40 -3
  274. package/dist/esm/core/hex.mjs +1 -1
  275. package/dist/esm/core/index.d.mts +6 -5
  276. package/dist/esm/core/index.mjs +1 -1
  277. package/dist/esm/errors/index.d.mts +123 -0
  278. package/dist/esm/errors/index.mjs +2 -0
  279. package/dist/esm/index.d.mts +13 -11
  280. package/dist/esm/index.mjs +1 -1
  281. package/dist/esm/internal/account.d.mts +5 -4
  282. package/dist/esm/internal/account.mjs +1 -1
  283. package/dist/esm/internal/ans.d.mts +5 -4
  284. package/dist/esm/internal/ans.mjs +1 -1
  285. package/dist/esm/internal/coin.d.mts +3 -2
  286. package/dist/esm/internal/coin.mjs +1 -1
  287. package/dist/esm/internal/digitalAsset.d.mts +5 -4
  288. package/dist/esm/internal/digitalAsset.mjs +1 -1
  289. package/dist/esm/internal/event.d.mts +3 -2
  290. package/dist/esm/internal/event.mjs +1 -1
  291. package/dist/esm/internal/faucet.d.mts +2 -1
  292. package/dist/esm/internal/faucet.mjs +1 -1
  293. package/dist/esm/internal/fungibleAsset.d.mts +5 -4
  294. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  295. package/dist/esm/internal/general.d.mts +3 -2
  296. package/dist/esm/internal/general.mjs +1 -1
  297. package/dist/esm/internal/keyless.d.mts +10 -5
  298. package/dist/esm/internal/keyless.mjs +1 -1
  299. package/dist/esm/internal/object.d.mts +3 -2
  300. package/dist/esm/internal/object.mjs +1 -1
  301. package/dist/esm/internal/staking.d.mts +2 -1
  302. package/dist/esm/internal/staking.mjs +1 -1
  303. package/dist/esm/internal/table.d.mts +3 -2
  304. package/dist/esm/internal/table.mjs +1 -1
  305. package/dist/esm/internal/transaction.d.mts +2 -1
  306. package/dist/esm/internal/transaction.mjs +1 -1
  307. package/dist/esm/internal/transactionSubmission.d.mts +4 -3
  308. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  309. package/dist/esm/internal/view.d.mts +4 -3
  310. package/dist/esm/internal/view.mjs +1 -1
  311. package/dist/esm/{publicKey-_tPa99ea.d.mts → publicKey-BVXX1nVl.d.mts} +2 -2
  312. package/dist/esm/transactions/authenticator/account.d.mts +4 -3
  313. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  314. package/dist/esm/transactions/authenticator/index.d.mts +4 -3
  315. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  316. package/dist/esm/transactions/authenticator/transaction.d.mts +10 -4
  317. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  318. package/dist/esm/transactions/index.d.mts +7 -5
  319. package/dist/esm/transactions/index.mjs +1 -1
  320. package/dist/esm/transactions/instances/chainId.d.mts +3 -2
  321. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  322. package/dist/esm/transactions/instances/identifier.d.mts +3 -2
  323. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  324. package/dist/esm/transactions/instances/index.d.mts +4 -3
  325. package/dist/esm/transactions/instances/index.mjs +1 -1
  326. package/dist/esm/transactions/instances/moduleId.d.mts +3 -2
  327. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  328. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +3 -2
  329. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  330. package/dist/esm/transactions/instances/rawTransaction.d.mts +3 -2
  331. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  332. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +4 -3
  333. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  334. package/dist/esm/transactions/instances/signedTransaction.d.mts +4 -3
  335. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  336. package/dist/esm/transactions/instances/simpleTransaction.d.mts +3 -2
  337. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  338. package/dist/esm/transactions/instances/transactionArgument.d.mts +3 -2
  339. package/dist/esm/transactions/instances/transactionPayload.d.mts +3 -2
  340. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  341. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +5 -4
  342. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  343. package/dist/esm/transactions/management/index.d.mts +5 -4
  344. package/dist/esm/transactions/management/index.mjs +1 -1
  345. package/dist/esm/transactions/management/transactionWorker.d.mts +5 -4
  346. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  347. package/dist/esm/transactions/script-composer/index.d.mts +44 -0
  348. package/dist/esm/transactions/script-composer/index.mjs +2 -0
  349. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -2
  350. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  351. package/dist/esm/transactions/transactionBuilder/index.d.mts +5 -4
  352. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  353. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +26 -5
  354. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  355. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +4 -3
  356. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  357. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +4 -3
  358. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  359. package/dist/esm/transactions/typeTag/index.d.mts +3 -2
  360. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  361. package/dist/esm/transactions/typeTag/parser.d.mts +3 -2
  362. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  363. package/dist/esm/transactions/types.d.mts +12 -3
  364. package/dist/esm/types/index.d.mts +4 -1260
  365. package/dist/esm/types/index.mjs +1 -1
  366. package/dist/esm/types/keyless.d.mts +22 -1
  367. package/dist/esm/types/types.d.mts +1290 -0
  368. package/dist/esm/types/types.mjs +2 -0
  369. package/dist/esm/types/types.mjs.map +1 -0
  370. package/dist/esm/utils/helpers.d.mts +11 -3
  371. package/dist/esm/utils/helpers.mjs +1 -1
  372. package/dist/esm/utils/index.d.mts +3 -2
  373. package/dist/esm/utils/index.mjs +1 -1
  374. package/dist/esm/utils/normalizeBundle.d.mts +3 -2
  375. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  376. package/dist/esm/version.d.mts +1 -1
  377. package/dist/esm/version.mjs +1 -1
  378. package/package.json +2 -1
  379. package/src/account/AbstractKeylessAccount.ts +203 -10
  380. package/src/account/FederatedKeylessAccount.ts +83 -35
  381. package/src/account/KeylessAccount.ts +44 -37
  382. package/src/account/MultiKeyAccount.ts +18 -5
  383. package/src/api/keyless.ts +2 -2
  384. package/src/api/transactionSubmission/build.ts +82 -1
  385. package/src/bcs/deserializer.ts +53 -30
  386. package/src/bcs/serializable/moveStructs.ts +16 -17
  387. package/src/bcs/serializer.ts +22 -12
  388. package/src/client/core.ts +2 -2
  389. package/src/client/get.ts +1 -2
  390. package/src/client/index.ts +0 -1
  391. package/src/client/post.ts +1 -2
  392. package/src/core/accountAddress.ts +36 -9
  393. package/src/core/crypto/ed25519.ts +34 -14
  394. package/src/core/crypto/hdKey.ts +0 -1
  395. package/src/core/crypto/keyless.ts +245 -38
  396. package/src/core/crypto/privateKey.ts +81 -5
  397. package/src/core/crypto/secp256k1.ts +31 -11
  398. package/src/core/hex.ts +47 -0
  399. package/src/errors/index.ts +406 -0
  400. package/src/index.ts +1 -0
  401. package/src/internal/account.ts +6 -6
  402. package/src/internal/ans.ts +2 -1
  403. package/src/internal/keyless.ts +46 -18
  404. package/src/internal/transaction.ts +2 -1
  405. package/src/internal/transactionSubmission.ts +36 -18
  406. package/src/transactions/authenticator/transaction.ts +20 -0
  407. package/src/transactions/index.ts +1 -0
  408. package/src/transactions/script-composer/index.ts +76 -0
  409. package/src/transactions/transactionBuilder/remoteAbi.ts +55 -1
  410. package/src/transactions/types.ts +11 -0
  411. package/src/types/index.ts +2 -1483
  412. package/src/types/keyless.ts +19 -0
  413. package/src/types/types.ts +1512 -0
  414. package/src/utils/helpers.ts +10 -0
  415. package/src/version.ts +1 -1
  416. package/dist/common/chunk-7IYTZDXV.js +0 -2
  417. package/dist/common/chunk-7IYTZDXV.js.map +0 -1
  418. package/dist/esm/chunk-2652SPOM.mjs.map +0 -1
  419. package/dist/esm/chunk-2CGJLPHP.mjs +0 -2
  420. package/dist/esm/chunk-2GEIHUHT.mjs.map +0 -1
  421. package/dist/esm/chunk-4CDDWSKZ.mjs +0 -2
  422. package/dist/esm/chunk-4OV7QU2U.mjs +0 -2
  423. package/dist/esm/chunk-4VU2ABLU.mjs +0 -2
  424. package/dist/esm/chunk-4VU2ABLU.mjs.map +0 -1
  425. package/dist/esm/chunk-5S3Z7MT4.mjs +0 -2
  426. package/dist/esm/chunk-5S3Z7MT4.mjs.map +0 -1
  427. package/dist/esm/chunk-5SGSPCOY.mjs +0 -2
  428. package/dist/esm/chunk-5SGSPCOY.mjs.map +0 -1
  429. package/dist/esm/chunk-7XS45O6M.mjs +0 -2
  430. package/dist/esm/chunk-7XS45O6M.mjs.map +0 -1
  431. package/dist/esm/chunk-BAGUHYFD.mjs +0 -2
  432. package/dist/esm/chunk-BAGUHYFD.mjs.map +0 -1
  433. package/dist/esm/chunk-CDQGPCHU.mjs +0 -2
  434. package/dist/esm/chunk-CDQGPCHU.mjs.map +0 -1
  435. package/dist/esm/chunk-DMSHPWA5.mjs +0 -2
  436. package/dist/esm/chunk-DMSHPWA5.mjs.map +0 -1
  437. package/dist/esm/chunk-FTZGP6XW.mjs +0 -2
  438. package/dist/esm/chunk-FTZGP6XW.mjs.map +0 -1
  439. package/dist/esm/chunk-GLATLXF6.mjs +0 -2
  440. package/dist/esm/chunk-GLATLXF6.mjs.map +0 -1
  441. package/dist/esm/chunk-GQABU3RQ.mjs +0 -2
  442. package/dist/esm/chunk-GQABU3RQ.mjs.map +0 -1
  443. package/dist/esm/chunk-HM5HITUC.mjs +0 -4
  444. package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
  445. package/dist/esm/chunk-IBLZ6MZU.mjs +0 -2
  446. package/dist/esm/chunk-IECDO22V.mjs.map +0 -1
  447. package/dist/esm/chunk-JN36BNWA.mjs +0 -2
  448. package/dist/esm/chunk-JN36BNWA.mjs.map +0 -1
  449. package/dist/esm/chunk-KFNDDPOW.mjs +0 -2
  450. package/dist/esm/chunk-KFNDDPOW.mjs.map +0 -1
  451. package/dist/esm/chunk-KIW54KWR.mjs +0 -2
  452. package/dist/esm/chunk-KM6UXNC7.mjs +0 -2
  453. package/dist/esm/chunk-KM6UXNC7.mjs.map +0 -1
  454. package/dist/esm/chunk-KUX6GQ2E.mjs +0 -1
  455. package/dist/esm/chunk-LEKBJ2EG.mjs +0 -2
  456. package/dist/esm/chunk-LEKBJ2EG.mjs.map +0 -1
  457. package/dist/esm/chunk-M22UGFQ5.mjs +0 -2
  458. package/dist/esm/chunk-M22UGFQ5.mjs.map +0 -1
  459. package/dist/esm/chunk-N2FKVZ4D.mjs +0 -1
  460. package/dist/esm/chunk-N47FTRYO.mjs +0 -2
  461. package/dist/esm/chunk-N47FTRYO.mjs.map +0 -1
  462. package/dist/esm/chunk-ONBFUPEC.mjs +0 -2
  463. package/dist/esm/chunk-P3J54CQG.mjs +0 -2
  464. package/dist/esm/chunk-P3J54CQG.mjs.map +0 -1
  465. package/dist/esm/chunk-RNJHULIT.mjs.map +0 -1
  466. package/dist/esm/chunk-SGQFWWLQ.mjs +0 -2
  467. package/dist/esm/chunk-SGQFWWLQ.mjs.map +0 -1
  468. package/dist/esm/chunk-SOLWFAUY.mjs.map +0 -1
  469. package/dist/esm/chunk-T5BCTWGK.mjs.map +0 -1
  470. package/dist/esm/chunk-WV2VJQDS.mjs +0 -2
  471. package/dist/esm/chunk-Y267I7DC.mjs +0 -2
  472. package/dist/esm/chunk-Y267I7DC.mjs.map +0 -1
  473. package/dist/esm/client/types.d.mts +0 -66
  474. package/dist/esm/client/types.mjs +0 -2
  475. package/src/client/types.ts +0 -138
  476. /package/dist/esm/{chunk-4ZK3JNQT.mjs.map → chunk-2NHQQQZK.mjs.map} +0 -0
  477. /package/dist/esm/{chunk-F2RY4YQ7.mjs.map → chunk-37Y54PJ5.mjs.map} +0 -0
  478. /package/dist/esm/{chunk-OAEDFM7T.mjs.map → chunk-3XCYCFYI.mjs.map} +0 -0
  479. /package/dist/esm/{chunk-6FLHGOKP.mjs.map → chunk-42H7WETG.mjs.map} +0 -0
  480. /package/dist/esm/{chunk-AZ6LVQEG.mjs.map → chunk-46L6BAJG.mjs.map} +0 -0
  481. /package/dist/esm/{chunk-KW4FVBDD.mjs.map → chunk-4DNCQM3S.mjs.map} +0 -0
  482. /package/dist/esm/{chunk-IBLZ6MZU.mjs.map → chunk-4O5XDQDO.mjs.map} +0 -0
  483. /package/dist/esm/{chunk-5N6KJ7KS.mjs.map → chunk-5AKSORBJ.mjs.map} +0 -0
  484. /package/dist/esm/{chunk-KIW54KWR.mjs.map → chunk-5B3SMBXQ.mjs.map} +0 -0
  485. /package/dist/esm/{chunk-UCRROMZN.mjs.map → chunk-5NJWJXSS.mjs.map} +0 -0
  486. /package/dist/esm/{chunk-CL6EEMSL.mjs.map → chunk-6K4TOFCO.mjs.map} +0 -0
  487. /package/dist/esm/{chunk-IAVI3H4V.mjs.map → chunk-6PJH53CK.mjs.map} +0 -0
  488. /package/dist/esm/{chunk-PCLU4KLY.mjs.map → chunk-6ZOVTYLJ.mjs.map} +0 -0
  489. /package/dist/esm/{chunk-I5OYNCZS.mjs.map → chunk-7ECCT6PK.mjs.map} +0 -0
  490. /package/dist/esm/{chunk-RAJTNQNL.mjs.map → chunk-AAATWCJT.mjs.map} +0 -0
  491. /package/dist/esm/{chunk-NODYW7DM.mjs.map → chunk-ACVIE7IE.mjs.map} +0 -0
  492. /package/dist/esm/{chunk-PRZ7AIGA.mjs.map → chunk-AKIO3OIT.mjs.map} +0 -0
  493. /package/dist/esm/{chunk-KRVLR3L4.mjs.map → chunk-AOROYJ74.mjs.map} +0 -0
  494. /package/dist/esm/{chunk-6DMDYBV6.mjs.map → chunk-BLLHTGAP.mjs.map} +0 -0
  495. /package/dist/esm/{chunk-JGNMNCQB.mjs.map → chunk-BRV3RLKW.mjs.map} +0 -0
  496. /package/dist/esm/{chunk-7JK7UG4E.mjs.map → chunk-CA3Q2X6B.mjs.map} +0 -0
  497. /package/dist/esm/{chunk-RNRNGJDA.mjs.map → chunk-DP3YPGIK.mjs.map} +0 -0
  498. /package/dist/esm/{chunk-KYJU5PWF.mjs.map → chunk-DSKAMBBL.mjs.map} +0 -0
  499. /package/dist/esm/{chunk-L5J3V3HW.mjs.map → chunk-E2NYQVP3.mjs.map} +0 -0
  500. /package/dist/esm/{chunk-4JXB6V5O.mjs.map → chunk-F2AIWA7L.mjs.map} +0 -0
  501. /package/dist/esm/{chunk-WSZCPSV4.mjs.map → chunk-FXUI3SSD.mjs.map} +0 -0
  502. /package/dist/esm/{chunk-A2AEFKXS.mjs.map → chunk-HEHVWRMO.mjs.map} +0 -0
  503. /package/dist/esm/{chunk-UGL2GPGK.mjs.map → chunk-HFWFDS6Y.mjs.map} +0 -0
  504. /package/dist/esm/{chunk-OXM4BVAY.mjs.map → chunk-HXXELLHN.mjs.map} +0 -0
  505. /package/dist/esm/{chunk-RBJNSUSU.mjs.map → chunk-IBMZYDAR.mjs.map} +0 -0
  506. /package/dist/esm/{chunk-AT2ZGTXQ.mjs.map → chunk-IDNDUJOK.mjs.map} +0 -0
  507. /package/dist/esm/{chunk-3H5DGQKX.mjs.map → chunk-II654QZU.mjs.map} +0 -0
  508. /package/dist/esm/{chunk-JNRMHDRA.mjs.map → chunk-JDNI5VIJ.mjs.map} +0 -0
  509. /package/dist/esm/{chunk-73GCGRFW.mjs.map → chunk-JJUINAQE.mjs.map} +0 -0
  510. /package/dist/esm/{chunk-VYMRIKUV.mjs.map → chunk-JLD7DLKM.mjs.map} +0 -0
  511. /package/dist/esm/{chunk-XFJD6QIP.mjs.map → chunk-KA5FX53Q.mjs.map} +0 -0
  512. /package/dist/esm/{chunk-ZPIMARUG.mjs.map → chunk-L2QVUMBV.mjs.map} +0 -0
  513. /package/dist/esm/{chunk-TPJLAYW6.mjs.map → chunk-LAAFLCDM.mjs.map} +0 -0
  514. /package/dist/esm/{chunk-AGBA3Y7A.mjs.map → chunk-LGTOOAQI.mjs.map} +0 -0
  515. /package/dist/esm/{chunk-4OV7QU2U.mjs.map → chunk-MHN6XY4Z.mjs.map} +0 -0
  516. /package/dist/esm/{chunk-JVTDP4KV.mjs.map → chunk-MOGPSSTD.mjs.map} +0 -0
  517. /package/dist/esm/{chunk-WZCKSN2U.mjs.map → chunk-NARS3JDH.mjs.map} +0 -0
  518. /package/dist/esm/{chunk-YZ5BCOGI.mjs.map → chunk-NHKAQRJB.mjs.map} +0 -0
  519. /package/dist/esm/{chunk-LDZPO76C.mjs.map → chunk-OKE3FXIP.mjs.map} +0 -0
  520. /package/dist/esm/{chunk-ZINOJTLU.mjs.map → chunk-OPO5EYF7.mjs.map} +0 -0
  521. /package/dist/esm/{chunk-BVVHGSWC.mjs.map → chunk-PW3ISXPN.mjs.map} +0 -0
  522. /package/dist/esm/{chunk-CC7VOPYH.mjs.map → chunk-QQM47PHZ.mjs.map} +0 -0
  523. /package/dist/esm/{chunk-EUGLLGYW.mjs.map → chunk-SBCLBDCP.mjs.map} +0 -0
  524. /package/dist/esm/{chunk-EE7GDBA5.mjs.map → chunk-SU2WB34N.mjs.map} +0 -0
  525. /package/dist/esm/{chunk-OTY3NO7Q.mjs.map → chunk-T6ADNZE5.mjs.map} +0 -0
  526. /package/dist/esm/{chunk-ONBFUPEC.mjs.map → chunk-UGTIALNW.mjs.map} +0 -0
  527. /package/dist/esm/{chunk-KUX6GQ2E.mjs.map → chunk-UIRAXHDH.mjs.map} +0 -0
  528. /package/dist/esm/{chunk-4CDDWSKZ.mjs.map → chunk-UZTJWOLS.mjs.map} +0 -0
  529. /package/dist/esm/{chunk-ZPQUCT22.mjs.map → chunk-VCY3JGZM.mjs.map} +0 -0
  530. /package/dist/esm/{chunk-XOCRDV2V.mjs.map → chunk-VQZMI3EZ.mjs.map} +0 -0
  531. /package/dist/esm/{chunk-IFXUWUP2.mjs.map → chunk-WSFHH3BK.mjs.map} +0 -0
  532. /package/dist/esm/{chunk-4LKLOUMG.mjs.map → chunk-X3JPX7T6.mjs.map} +0 -0
  533. /package/dist/esm/{chunk-22ZSW5EN.mjs.map → chunk-XKOSS5KC.mjs.map} +0 -0
  534. /package/dist/esm/{chunk-BG2TZI3H.mjs.map → chunk-XT5T5LAP.mjs.map} +0 -0
  535. /package/dist/esm/{chunk-XQ7ONNII.mjs.map → chunk-YNT7JHMS.mjs.map} +0 -0
  536. /package/dist/esm/{chunk-BOWPP6YG.mjs.map → chunk-YPBNYKOD.mjs.map} +0 -0
  537. /package/dist/esm/{chunk-MK2QAHXC.mjs.map → chunk-YZ3YPLEU.mjs.map} +0 -0
  538. /package/dist/esm/{chunk-OZN3OOJV.mjs.map → chunk-ZMBXHMVQ.mjs.map} +0 -0
  539. /package/dist/esm/{chunk-XFY4O2S3.mjs.map → chunk-ZRWZIAF5.mjs.map} +0 -0
  540. /package/dist/esm/{chunk-N2FKVZ4D.mjs.map → errors/index.mjs.map} +0 -0
  541. /package/dist/esm/{client/types.mjs.map → transactions/script-composer/index.mjs.map} +0 -0
package/README.md CHANGED
@@ -12,7 +12,7 @@ The [TypeScript SDK](https://www.npmjs.com/package/@aptos-labs/ts-sdk) allows yo
12
12
  ## Learn How To Use The TypeScript SDK
13
13
  ### [Quickstart](https://aptos.dev/en/build/sdks/ts-sdk/quickstart)
14
14
  ### [Tutorials](https://aptos.dev/en/build/sdks/ts-sdk)
15
- ### [Examples](./examples)
15
+ ### [Examples](./examples/README.md)
16
16
  ### [Reference Docs (For looking up specific functions)](https://aptos-labs.github.io/aptos-ts-sdk/)
17
17
 
18
18
 
@@ -1,21 +1,3 @@
1
- declare const NetworkToIndexerAPI: Record<string, string>;
2
- declare const NetworkToNodeAPI: Record<string, string>;
3
- declare const NetworkToFaucetAPI: Record<string, string>;
4
- declare const NetworkToPepperAPI: Record<string, string>;
5
- declare const NetworkToProverAPI: Record<string, string>;
6
- /**
7
- * Different network environments for connecting to services, ranging from production to development setups.
8
- */
9
- declare enum Network {
10
- MAINNET = "mainnet",
11
- TESTNET = "testnet",
12
- DEVNET = "devnet",
13
- LOCAL = "local",
14
- CUSTOM = "custom"
15
- }
16
- declare const NetworkToChainId: Record<string, number>;
17
- declare const NetworkToNetworkName: Record<string, Network>;
18
-
19
1
  type GetAccountCoinsDataQuery = {
20
2
  current_fungible_asset_balances: Array<{
21
3
  amount?: any | null;
@@ -555,6 +537,24 @@ type GraphqlQuery = {
555
537
  variables?: {};
556
538
  };
557
539
 
540
+ declare const NetworkToIndexerAPI: Record<string, string>;
541
+ declare const NetworkToNodeAPI: Record<string, string>;
542
+ declare const NetworkToFaucetAPI: Record<string, string>;
543
+ declare const NetworkToPepperAPI: Record<string, string>;
544
+ declare const NetworkToProverAPI: Record<string, string>;
545
+ /**
546
+ * Different network environments for connecting to services, ranging from production to development setups.
547
+ */
548
+ declare enum Network {
549
+ MAINNET = "mainnet",
550
+ TESTNET = "testnet",
551
+ DEVNET = "devnet",
552
+ LOCAL = "local",
553
+ CUSTOM = "custom"
554
+ }
555
+ declare const NetworkToChainId: Record<string, number>;
556
+ declare const NetworkToNetworkName: Record<string, Network>;
557
+
558
558
  /**
559
559
  * Different MIME types used for data interchange in transactions and responses.
560
560
  */
@@ -650,6 +650,14 @@ declare enum AccountAuthenticatorVariant {
650
650
  SingleKey = 2,
651
651
  MultiKey = 3
652
652
  }
653
+ /**
654
+ * Variants of private keys that can comply with the AIP-80 standard.
655
+ * {@link https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md}
656
+ */
657
+ declare enum PrivateKeyVariants {
658
+ Ed25519 = "ed25519",
659
+ Secp256k1 = "secp256k1"
660
+ }
653
661
  /**
654
662
  * Variants of public keys used in cryptographic operations.
655
663
  */
@@ -854,6 +862,26 @@ type AptosRequest = {
854
862
  originMethod?: string;
855
863
  overrides?: ClientConfig & FullNodeConfig & IndexerConfig & FaucetConfig;
856
864
  };
865
+ /**
866
+ * The API response type
867
+ *
868
+ * @param status - the response status. i.e. 200
869
+ * @param statusText - the response message
870
+ * @param data the response data
871
+ * @param url the url the request was made to
872
+ * @param headers the response headers
873
+ * @param config (optional) - the request object
874
+ * @param request (optional) - the request object
875
+ */
876
+ interface AptosResponse<Req, Res> {
877
+ status: number;
878
+ statusText: string;
879
+ data: Res;
880
+ url: string;
881
+ headers: any;
882
+ config?: any;
883
+ request?: Req;
884
+ }
857
885
  /**
858
886
  * The ledger version of transactions, defaulting to the latest version if not specified.
859
887
  */
@@ -1866,6 +1894,7 @@ declare class Deserializer {
1866
1894
  */
1867
1895
  remaining(): number;
1868
1896
  /**
1897
+ * @deprecated use `deserializeOption` instead.
1869
1898
  * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,
1870
1899
  * followed by the actual byte content, and decodes it into a string.
1871
1900
  *
@@ -1880,38 +1909,45 @@ declare class Deserializer {
1880
1909
  */
1881
1910
  deserializeStr(): string;
1882
1911
  /**
1883
- * Deserializes an optional string.
1912
+ * Deserializes an optional value from the buffer.
1884
1913
  *
1885
- * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.
1886
- * @returns The deserialized string if it exists, otherwise undefined.
1887
- * @example
1888
- * ```typescript
1889
- * const deserializer = new Deserializer(new Uint8Array([0x00]));
1890
- * assert(deserializer.deserializeOptionStr() === undefined);
1891
- * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));
1892
- * assert(deserializer.deserializeOptionStr() === "1234abcd");
1893
- * ```
1894
- */
1895
- deserializeOptionStr(): string | undefined;
1896
- /**
1897
- * Deserializes an optional deserializable class.
1914
+ * The BCS layout for Optional<T> starts with a boolean byte (0 if none, 1 if some),
1915
+ * followed by the value if present.
1916
+ *
1917
+ * @template T - The type of the value to deserialize
1918
+ * @param type - Either a Deserializable class or one of the string literals: "string", "bytes", or "fixedBytes"
1919
+ * @param len - Required length when type is "fixedBytes", ignored otherwise
1920
+ * @returns The deserialized value if present, undefined otherwise
1898
1921
  *
1899
- * BCS layout for Optional<T>: 0 if none, else 1 | BCS representation of class.
1922
+ * @throws {Error} When "fixedBytes" is specified without a length
1900
1923
  *
1901
1924
  * @example
1902
- * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));
1903
- * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
1904
- * // value is now an instance of MyClass
1925
+ * ```typescript
1926
+ * // Deserialize an optional string
1927
+ * const deserializer = new Deserializer(new Uint8Array([1, 3, 97, 98, 99]));
1928
+ * const optStr = deserializer.deserializeOption("string");
1929
+ * // optStr === "abc"
1905
1930
  *
1931
+ * // Deserialize an optional custom type
1906
1932
  * const deserializer = new Deserializer(new Uint8Array([0]));
1907
- * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
1908
- * // value is undefined
1909
- *
1910
- * @param cls The BCS-deserializable class to deserialize the buffered bytes into.
1911
- *
1912
- * @returns The deserialized value of class type T or undefined if no value exists.
1933
+ * const optValue = deserializer.deserializeOption(MyClass);
1934
+ * // optValue === undefined
1935
+ *
1936
+ * // Deserialize optional bytes
1937
+ * const deserializer = new Deserializer(new Uint8Array([1, 3, 1, 2, 3]));
1938
+ * const optBytes = deserializer.deserializeOption("bytes");
1939
+ * // optBytes === Uint8Array[1, 2, 3]
1940
+ *
1941
+ * // Deserialize optional fixed bytes
1942
+ * const deserializer = new Deserializer(new Uint8Array([1, 1, 2, 3, 4]));
1943
+ * const optBytes = deserializer.deserializeOption("fixedBytes", 4);
1944
+ * // optBytes === Uint8Array[1, 2, 3, 4]
1945
+ * ```
1913
1946
  */
1914
- deserializeOption<T>(cls: Deserializable<T>): T | undefined;
1947
+ deserializeOption(type: "string"): string | undefined;
1948
+ deserializeOption(type: "bytes"): Uint8Array | undefined;
1949
+ deserializeOption(type: "fixedBytes", len: number): Uint8Array | undefined;
1950
+ deserializeOption<T>(type: Deserializable<T>): T | undefined;
1915
1951
  /**
1916
1952
  * Deserializes an array of bytes.
1917
1953
  *
@@ -2154,6 +2190,41 @@ declare class Hex {
2154
2190
  * @returns A Hex instance created from the provided hexInput.
2155
2191
  */
2156
2192
  static fromHexInput(hexInput: HexInput): Hex;
2193
+ /**
2194
+ * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.
2195
+ *
2196
+ * @param hexInput - A HexInput which can be a string or Uint8Array.
2197
+ * @returns A Uint8Array created from the provided hexInput.
2198
+ */
2199
+ static hexInputToUint8Array(hexInput: HexInput): Uint8Array;
2200
+ /**
2201
+ * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.
2202
+ *
2203
+ * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
2204
+ * @returns A hex string with '0x' prefix (e.g., "0x1234")
2205
+ *
2206
+ * @example
2207
+ * ```typescript
2208
+ * Hex.hexInputToString("1234") // returns "0x1234"
2209
+ * Hex.hexInputToString("0x1234") // returns "0x1234"
2210
+ * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns "0x1234"
2211
+ * ```
2212
+ */
2213
+ static hexInputToString(hexInput: HexInput): string;
2214
+ /**
2215
+ * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.
2216
+ *
2217
+ * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
2218
+ * @returns A hex string without '0x' prefix (e.g., "1234")
2219
+ *
2220
+ * @example
2221
+ * ```typescript
2222
+ * Hex.hexInputToStringWithoutPrefix("1234") // returns "1234"
2223
+ * Hex.hexInputToStringWithoutPrefix("0x1234") // returns "1234"
2224
+ * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns "1234"
2225
+ * ```
2226
+ */
2227
+ static hexInputToStringWithoutPrefix(hexInput: HexInput): string;
2157
2228
  /**
2158
2229
  * Check if the provided string is a valid hexadecimal representation.
2159
2230
  *
@@ -2173,6 +2244,7 @@ declare class Hex {
2173
2244
  */
2174
2245
  equals(other: Hex): boolean;
2175
2246
  }
2247
+ declare const hexToAsciiString: (hex: string) => string;
2176
2248
 
2177
2249
  /**
2178
2250
  * This class serves as a base class for all serializable types. It facilitates
@@ -2392,25 +2464,25 @@ declare class Serializer {
2392
2464
  */
2393
2465
  serializeVector<T extends Serializable>(values: Array<T>): void;
2394
2466
  /**
2395
- * Serializes a BCS Serializable value into a serializer instance or handles the case when the value is undefined.
2396
- * This function allows you to efficiently add serialized data to the serializer's byte buffer.
2467
+ * Serializes an optional value which can be a Serializable, string, or Uint8Array.
2468
+ * For strings and Uint8Arrays, it uses the appropriate serialization method.
2397
2469
  *
2398
- * @param value The BCS Serializable value to serialize, or undefined if there is no value.
2470
+ * @param value The value to serialize (Serializable, string, Uint8Array, or undefined)
2471
+ * @param len Optional fixed length for Uint8Array serialization. If provided, uses serializeFixedBytes instead of serializeBytes
2399
2472
  *
2400
2473
  * @example
2401
2474
  * ```typescript
2402
2475
  * const serializer = new Serializer();
2403
- * serializer.serializeOption(new AccountAddress(...));
2404
- * const serializedBytes = serializer.toUint8Array();
2405
- * // serializedBytes is now the BCS-serialized byte representation of AccountAddress
2406
- *
2407
- * const serializer = new Serializer();
2408
- * serializer.serializeOption(undefined);
2409
- * assert(serializer.toUint8Array() === new Uint8Array([0x00]));
2476
+ * serializer.serializeOption("hello"); // Serializes optional string
2477
+ * serializer.serializeOption(new Uint8Array([1, 2, 3])); // Serializes optional bytes
2478
+ * serializer.serializeOption(new Uint8Array([1, 2, 3]), 3); // Serializes optional fixed-length bytes
2479
+ * serializer.serializeOption(new AccountAddress(...)); // Serializes optional Serializable
2480
+ * serializer.serializeOption(undefined); // Serializes none case
2410
2481
  * ```
2411
2482
  */
2412
- serializeOption<T extends Serializable>(value?: T): void;
2483
+ serializeOption<T extends Serializable | string | Uint8Array>(value?: T, len?: number): void;
2413
2484
  /**
2485
+ * @deprecated use `serializeOption` instead.
2414
2486
  * Serializes an optional string, supporting UTF8 encoding.
2415
2487
  * The function encodes the existence of the string first, followed by the length and content if it exists.
2416
2488
  *
@@ -2497,7 +2569,8 @@ declare enum AddressInvalidReason {
2497
2569
  TOO_LONG = "too_long",
2498
2570
  LEADING_ZERO_X_REQUIRED = "leading_zero_x_required",
2499
2571
  LONG_FORM_REQUIRED_UNLESS_SPECIAL = "long_form_required_unless_special",
2500
- INVALID_PADDING_ZEROES = "INVALID_PADDING_ZEROES"
2572
+ INVALID_PADDING_ZEROES = "INVALID_PADDING_ZEROES",
2573
+ INVALID_PADDING_STRICTNESS = "INVALID_PADDING_STRICTNESS"
2501
2574
  }
2502
2575
  /**
2503
2576
  * The input for an account address, which can be either a hexadecimal string or a standard account address.
@@ -2661,7 +2734,9 @@ declare class AccountAddress extends Serializable implements TransactionArgument
2661
2734
  *
2662
2735
  * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.
2663
2736
  *
2664
- * @note This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.
2737
+ * @remarks
2738
+ *
2739
+ * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.
2665
2740
  *
2666
2741
  * @see AIP-40 documentation for more details on address formats:
2667
2742
  * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
@@ -2672,7 +2747,7 @@ declare class AccountAddress extends Serializable implements TransactionArgument
2672
2747
  /**
2673
2748
  * NOTE: This function has relaxed parsing behavior. For strict behavior, please use
2674
2749
  * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this
2675
- * function, `fromString` is only provided for backwards compatibility.
2750
+ * function, `fromString`.
2676
2751
  *
2677
2752
  * Creates an instance of AccountAddress from a hex string.
2678
2753
  *
@@ -2680,23 +2755,26 @@ declare class AccountAddress extends Serializable implements TransactionArgument
2680
2755
  * following formats are accepted:
2681
2756
  *
2682
2757
  * - LONG, with or without leading 0x
2683
- * - SHORT, with or without leading 0x
2758
+ * - SHORT*, with or without leading 0x
2684
2759
  *
2685
2760
  * Where:
2686
2761
  * - LONG is 64 hex characters.
2687
- * - SHORT is 1 to 63 hex characters inclusive.
2762
+ * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.
2688
2763
  * - Padding zeroes are allowed, e.g. 0x0123 is valid.
2689
2764
  *
2690
2765
  * Learn more about the different address formats by reading AIP-40:
2691
2766
  * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
2692
2767
  *
2693
- * @param input - A hex string representing an account address.
2768
+ * @param input A hex string representing an account address.
2769
+ * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.
2694
2770
  *
2695
2771
  * @returns An instance of AccountAddress.
2696
2772
  *
2697
2773
  * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.
2698
2774
  */
2699
- static fromString(input: string): AccountAddress;
2775
+ static fromString(input: string, { maxMissingChars }?: {
2776
+ maxMissingChars?: number;
2777
+ }): AccountAddress;
2700
2778
  /**
2701
2779
  * Convenience method for creating an AccountAddress from various input types.
2702
2780
  * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding
@@ -2704,8 +2782,11 @@ declare class AccountAddress extends Serializable implements TransactionArgument
2704
2782
  *
2705
2783
  * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,
2706
2784
  * or an existing AccountAddress.
2785
+ * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.
2707
2786
  */
2708
- static from(input: AccountAddressInput): AccountAddress;
2787
+ static from(input: AccountAddressInput, { maxMissingChars }?: {
2788
+ maxMissingChars?: number;
2789
+ }): AccountAddress;
2709
2790
  /**
2710
2791
  * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.
2711
2792
  *
@@ -2735,4 +2816,4 @@ declare class AccountAddress extends Serializable implements TransactionArgument
2735
2816
  equals(other: AccountAddress): boolean;
2736
2817
  }
2737
2818
 
2738
- export { type GetEventsResponse as $, type AnyNumber as A, type GetAccountOwnedTokensFromCollectionResponse as B, type Client as C, Deserializer as D, type EntryFunctionArgument as E, type FullNodeConfig as F, type GetAccountOwnedTokensQueryResponse as G, type HexInput as H, type IndexerConfig as I, type GetAccountCollectionsWithOwnedTokenResponse as J, type GetAccountCoinsDataResponse as K, type LedgerVersionArg as L, type MoveModuleId as M, Network as N, type OrderByArg as O, type PaginationArgs as P, type GetObjectDataQueryResponse as Q, type GetCollectionDataResponse as R, Serializable as S, type TransactionArgument as T, type Uint8 as U, type GetTokenDataResponse as V, type WhereArg as W, type GetCurrentTokenOwnershipResponse as X, type GetOwnedTokensResponse as Y, ZkpVariant as Z, type GetTokenActivityResponse as _, Serializer as a, type WriteSetChangeWriteTableItem as a$, type WaitForTransactionOptions as a0, type UserTransactionResponse as a1, type MoveFunction as a2, type GetFungibleAssetMetadataResponse as a3, type GetFungibleAssetActivitiesResponse as a4, type GetCurrentFungibleAssetBalancesResponse as a5, type LedgerInfo as a6, type Block as a7, type GetChainTopUserTransactionsResponse as a8, type GraphqlQuery as a9, AccountAuthenticatorVariant as aA, AnySignatureVariant as aB, EphemeralSignatureVariant as aC, type Uint64 as aD, type Uint128 as aE, type Uint256 as aF, type ClientHeadersType as aG, TransactionResponseType as aH, isPendingTransactionResponse as aI, isUserTransactionResponse as aJ, isGenesisTransactionResponse as aK, isBlockMetadataTransactionResponse as aL, isStateCheckpointTransactionResponse as aM, isValidatorTransactionResponse as aN, isBlockEpilogueTransactionResponse as aO, type GenesisTransactionResponse as aP, type BlockMetadataTransactionResponse as aQ, type StateCheckpointTransactionResponse as aR, type ValidatorTransactionResponse as aS, type BlockEndInfo as aT, type BlockEpilogueTransactionResponse as aU, type WriteSetChange as aV, type WriteSetChangeDeleteModule as aW, type WriteSetChangeDeleteResource as aX, type WriteSetChangeDeleteTableItem as aY, type WriteSetChangeWriteModule as aZ, type WriteSetChangeWriteResource as a_, type GetProcessorStatusResponse as aa, type GetANSNameResponse as ab, type GetNumberOfDelegatorsResponse as ac, type GetDelegatedStakingActivitiesResponse as ad, type PendingTransactionResponse as ae, type CommittedTransactionResponse as af, type GasEstimation as ag, type TableItemRequest as ah, type GetTableItemsDataResponse as ai, type GetTableItemsMetadataResponse as aj, type AptosRequest as ak, type ClientRequest as al, type ClientResponse as am, MimeType as an, ensureBoolean as ao, outOfRangeErrorMessage as ap, validateNumberInRange as aq, AddressInvalidReason as ar, ParsingError as as, type ParsingResult as at, HexInvalidReason as au, TypeTagVariants as av, ScriptTransactionArgumentVariants as aw, TransactionPayloadVariants as ax, TransactionVariants as ay, TransactionAuthenticatorVariant as az, type Uint16 as b, type DecodedTableData as b0, type DeletedTableData as b1, type TransactionPayloadResponse as b2, type EntryFunctionPayloadResponse as b3, type ScriptPayloadResponse as b4, type MultisigPayloadResponse as b5, type GenesisPayload as b6, type MoveScriptBytecode as b7, type TransactionSignature as b8, isEd25519Signature as b9, MoveFunctionVisibility as bA, MoveAbility as bB, type MoveStructField as bC, type MoveModule as bD, type MoveStruct as bE, RoleType as bF, DeriveScheme as bG, type GenerateAccountWithEd25519 as bH, type GenerateAccountWithSingleSignerSecp256k1Key as bI, type GenerateAccount as bJ, type OrderBy as bK, type OrderByValue as bL, type TokenStandard as bM, NetworkToIndexerAPI as bN, NetworkToNodeAPI as bO, NetworkToFaucetAPI as bP, NetworkToPepperAPI as bQ, NetworkToProverAPI as bR, NetworkToChainId as bS, NetworkToNetworkName as bT, isSecp256k1Signature as ba, isMultiAgentSignature as bb, isFeePayerSignature as bc, isMultiEd25519Signature as bd, type TransactionEd25519Signature as be, type TransactionSecp256k1Signature as bf, type TransactionMultiEd25519Signature as bg, type TransactionMultiAgentSignature as bh, type TransactionFeePayerSignature as bi, type AccountSignature as bj, type WriteSet as bk, type ScriptWriteSet as bl, type DirectWriteSet as bm, type EventGuid as bn, type Event as bo, type MoveUint8Type as bp, type MoveUint16Type as bq, type MoveUint32Type as br, type MoveUint64Type as bs, type MoveUint128Type as bt, type MoveUint256Type as bu, type MoveAddressType as bv, type MoveObjectType as bw, type MoveOptionType as bx, type MoveStructType as by, type MoveType as bz, type Uint32 as c, type Deserializable as d, Hex as e, type AuthenticationKeyScheme as f, AccountAddress as g, AnyPublicKeyVariant as h, EphemeralPublicKeyVariant as i, type ClientConfig as j, type FaucetConfig as k, type AptosSettings as l, EphemeralCertificateVariant as m, type AccountAddressInput as n, type ScriptFunctionArgument as o, type MoveFunctionId as p, type MoveStructId as q, type MoveValue as r, type MoveFunctionGenericTypeParam as s, SigningSchemeInput as t, SigningScheme as u, type AccountData as v, type MoveModuleBytecode as w, type TransactionResponse as x, type MoveResource as y, type TokenStandardArg as z };
2819
+ export { type GetTokenActivityResponse as $, type AnyNumber as A, type TokenStandardArg as B, type Client as C, Deserializer as D, type EntryFunctionArgument as E, type FullNodeConfig as F, type GetAccountOwnedTokensQueryResponse as G, type HexInput as H, type IndexerConfig as I, type GetAccountOwnedTokensFromCollectionResponse as J, type GetAccountCollectionsWithOwnedTokenResponse as K, type LedgerVersionArg as L, type MoveModuleId as M, Network as N, type OrderByArg as O, PrivateKeyVariants as P, type GetAccountCoinsDataResponse as Q, type GetObjectDataQueryResponse as R, Serializable as S, type TransactionArgument as T, type Uint8 as U, type GetCollectionDataResponse as V, type WhereArg as W, type GetTokenDataResponse as X, type GetCurrentTokenOwnershipResponse as Y, ZkpVariant as Z, type GetOwnedTokensResponse as _, Serializer as a, type WriteSetChange as a$, type GetEventsResponse as a0, type WaitForTransactionOptions as a1, type UserTransactionResponse as a2, type MoveFunction as a3, type GetFungibleAssetMetadataResponse as a4, type GetFungibleAssetActivitiesResponse as a5, type GetCurrentFungibleAssetBalancesResponse as a6, type LedgerInfo as a7, type Block as a8, type GetChainTopUserTransactionsResponse as a9, type TokenStandard as aA, TypeTagVariants as aB, ScriptTransactionArgumentVariants as aC, TransactionPayloadVariants as aD, TransactionVariants as aE, TransactionAuthenticatorVariant as aF, AccountAuthenticatorVariant as aG, AnySignatureVariant as aH, EphemeralSignatureVariant as aI, type Uint64 as aJ, type Uint128 as aK, type Uint256 as aL, type ClientHeadersType as aM, TransactionResponseType as aN, isPendingTransactionResponse as aO, isUserTransactionResponse as aP, isGenesisTransactionResponse as aQ, isBlockMetadataTransactionResponse as aR, isStateCheckpointTransactionResponse as aS, isValidatorTransactionResponse as aT, isBlockEpilogueTransactionResponse as aU, type GenesisTransactionResponse as aV, type BlockMetadataTransactionResponse as aW, type StateCheckpointTransactionResponse as aX, type ValidatorTransactionResponse as aY, type BlockEndInfo as aZ, type BlockEpilogueTransactionResponse as a_, type GraphqlQuery as aa, type GetProcessorStatusResponse as ab, type GetANSNameResponse as ac, type GetNumberOfDelegatorsResponse as ad, type GetDelegatedStakingActivitiesResponse as ae, type PendingTransactionResponse as af, type CommittedTransactionResponse as ag, type GasEstimation as ah, type TableItemRequest as ai, type GetTableItemsDataResponse as aj, type GetTableItemsMetadataResponse as ak, type ClientRequest as al, type ClientResponse as am, type AptosRequest as an, type AptosResponse as ao, MimeType as ap, ensureBoolean as aq, outOfRangeErrorMessage as ar, validateNumberInRange as as, AddressInvalidReason as at, ParsingError as au, type ParsingResult as av, HexInvalidReason as aw, hexToAsciiString as ax, type OrderBy as ay, type OrderByValue as az, type Uint16 as b, type WriteSetChangeDeleteModule as b0, type WriteSetChangeDeleteResource as b1, type WriteSetChangeDeleteTableItem as b2, type WriteSetChangeWriteModule as b3, type WriteSetChangeWriteResource as b4, type WriteSetChangeWriteTableItem as b5, type DecodedTableData as b6, type DeletedTableData as b7, type TransactionPayloadResponse as b8, type EntryFunctionPayloadResponse as b9, type MoveUint256Type as bA, type MoveAddressType as bB, type MoveObjectType as bC, type MoveOptionType as bD, type MoveStructType as bE, type MoveType as bF, MoveFunctionVisibility as bG, MoveAbility as bH, type MoveStructField as bI, type MoveModule as bJ, type MoveStruct as bK, RoleType as bL, DeriveScheme as bM, type GenerateAccountWithEd25519 as bN, type GenerateAccountWithSingleSignerSecp256k1Key as bO, type GenerateAccount as bP, NetworkToIndexerAPI as bQ, NetworkToNodeAPI as bR, NetworkToFaucetAPI as bS, NetworkToPepperAPI as bT, NetworkToProverAPI as bU, NetworkToChainId as bV, NetworkToNetworkName as bW, type ScriptPayloadResponse as ba, type MultisigPayloadResponse as bb, type GenesisPayload as bc, type MoveScriptBytecode as bd, type TransactionSignature as be, isEd25519Signature as bf, isSecp256k1Signature as bg, isMultiAgentSignature as bh, isFeePayerSignature as bi, isMultiEd25519Signature as bj, type TransactionEd25519Signature as bk, type TransactionSecp256k1Signature as bl, type TransactionMultiEd25519Signature as bm, type TransactionMultiAgentSignature as bn, type TransactionFeePayerSignature as bo, type AccountSignature as bp, type WriteSet as bq, type ScriptWriteSet as br, type DirectWriteSet as bs, type EventGuid as bt, type Event as bu, type MoveUint8Type as bv, type MoveUint16Type as bw, type MoveUint32Type as bx, type MoveUint64Type as by, type MoveUint128Type as bz, type Uint32 as c, type Deserializable as d, Hex as e, type AuthenticationKeyScheme as f, AccountAddress as g, AnyPublicKeyVariant as h, EphemeralPublicKeyVariant as i, type ClientConfig as j, type FaucetConfig as k, type AptosSettings as l, EphemeralCertificateVariant as m, type AccountAddressInput as n, type ScriptFunctionArgument as o, type MoveFunctionId as p, type MoveStructId as q, type MoveValue as r, type MoveFunctionGenericTypeParam as s, SigningSchemeInput as t, SigningScheme as u, type AccountData as v, type PaginationArgs as w, type MoveModuleBytecode as x, type TransactionResponse as y, type MoveResource as z };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=(e,n,t,r)=>{for(var o=r>1?void 0:r?u(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(r?a(n,t,o):a(o))||o);return r&&o&&i(n,t,o),o};var _jsbase64 = require('js-base64');async function p(e){return new Promise(n=>{setTimeout(n,e)})}function f(e){return e instanceof Error?e.message:String(e)}var _=()=>Math.floor(Date.now()/1e3);function S(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function x(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return _jsbase64.decode.call(void 0, t)}var h=(e,n)=>e*10**n,y= exports.h =(e,n)=>e/10**n,c=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},b= exports.i =e=>{let{account_address:n,module_name:t,struct_name:r}=e,o=c(t),s=c(r);return`${n}::${o}::${s}`},M= exports.j =e=>typeof e=="object"&&!Array.isArray(e)&&e!==null&&"account_address"in e&&"module_name"in e&&"struct_name"in e&&typeof e.account_address=="string"&&typeof e.module_name=="string"&&typeof e.struct_name=="string";exports.a = m; exports.b = p; exports.c = f; exports.d = _; exports.e = S; exports.f = x; exports.g = h; exports.h = y; exports.i = b; exports.j = M;
2
+ //# sourceMappingURL=chunk-F43XVDYJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/oliverhe/aptos-ts-sdk/dist/common/chunk-F43XVDYJ.js","../../src/utils/helpers.ts"],"names":["sleep","timeMs","resolve","getErrorMessage","error","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","decode","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName"],"mappings":"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","file":"/Users/oliverhe/aptos-ts-sdk/dist/common/chunk-F43XVDYJ.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\nimport { MoveStructId } from \"../types\";\n\n/**\n * Sleep for the specified amount of time in milliseconds.\n * This function can be used to introduce delays in asynchronous operations.\n *\n * @param timeMs - The time in milliseconds to sleep.\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\n/**\n * Get the error message from an unknown error.\n *\n * @param error The error to get the message from\n * @returns The error message\n */\nexport function getErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport const nowInSeconds = () => Math.floor(Date.now() / 1000);\n\n/**\n * Floors the given timestamp to the nearest whole hour.\n * This function is useful for normalizing timestamps to hourly intervals.\n *\n * @param timestampInSeconds - The timestamp in seconds to be floored.\n */\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\n/**\n * Decodes a base64 URL-encoded string into its original form.\n * This function is useful for converting base64 URL-encoded data back to a readable format.\n *\n * @param base64Url - The base64 URL-encoded string to decode.\n * @returns The decoded string.\n */\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * a human-readable amount format to the smallest unit format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n */\nexport const convertAmountFromHumanReadableToOnChain = (value: number, decimal: number) => value * 10 ** decimal;\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * the smallest unit format to a human-readable amount format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n */\nexport const convertAmountFromOnChainToHumanReadable = (value: number, decimal: number) => value / 10 ** decimal;\n\n/**\n * Convert a hex string to an ascii string with the `0x` prefix.\n *\n * `0x6170746f735f636f696e` --> `aptos_coin`\n *\n * @param hex The hex string to convert (e.g. `0x6170746f735f636f696e`)\n * @returns The ascii string\n */\nconst hexToAscii = (hex: string) => {\n let str = \"\";\n for (let n = 2; n < hex.length; n += 2) {\n str += String.fromCharCode(parseInt(hex.substring(n, n + 2), 16));\n }\n return str;\n};\n\n/**\n * Convert an encoded struct to a MoveStructId.\n *\n * @example\n * const structObj = {\n * account_address: \"0x1\",\n * module_name: \"0x6170746f735f636f696e\",\n * struct_name: \"0x4170746f73436f696e\",\n * };\n * // structId is \"0x1::aptos_coin::AptosCoin\"\n * const structId = parseEncodedStruct(structObj);\n *\n * @param structObj The struct with account_address, module_name, and struct_name properties\n * @returns The MoveStructId\n */\nexport const parseEncodedStruct = (structObj: {\n account_address: string;\n module_name: string;\n struct_name: string;\n}): MoveStructId => {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { account_address, module_name, struct_name } = structObj;\n const moduleName = hexToAscii(module_name);\n const structName = hexToAscii(struct_name);\n return `${account_address}::${moduleName}::${structName}`;\n};\n\n/**\n * Determines whether the given object is an encoded struct type with the following properties:\n * - account_address: string\n * - module_name: string\n * - struct_name: string\n *\n * @param structObj The object to check\n * @returns Whether the object is an encoded struct type\n */\nexport const isEncodedStruct = (\n structObj: any,\n): structObj is {\n account_address: string;\n module_name: string;\n struct_name: string;\n} =>\n typeof structObj === \"object\" &&\n !Array.isArray(structObj) &&\n structObj !== null &&\n \"account_address\" in structObj &&\n \"module_name\" in structObj &&\n \"struct_name\" in structObj &&\n typeof structObj.account_address === \"string\" &&\n typeof structObj.module_name === \"string\" &&\n typeof structObj.struct_name === \"string\";\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ChildProcessWithoutNullStreams } from 'child_process';
2
- import { N as Network, g as AccountAddress } from '../accountAddress-DnSqjhSl.js';
2
+ import { N as Network, g as AccountAddress } from '../accountAddress-6RqI8Aam.js';
3
3
 
4
4
  /**
5
5
  * Represents a local node for running a testnet environment.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk7IYTZDXVjs = require('../chunk-7IYTZDXV.js');var _child_process = require('child_process');var _treekill = require('tree-kill'); var _treekill2 = _interopRequireDefault(_treekill);var _os = require('os');var l=class{constructor(s){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.showStdout=!0;this.process=null;this.showStdout=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _ => _.showStdout]), () => (!0))}async stop(){await new Promise((s,e)=>{_optionalChain([this, 'access', _2 => _2.process, 'optionalAccess', _3 => _3.pid])&&_treekill2.default.call(void 0, this.process.pid,r=>{r?e(r):s(!0)})})}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let s="npx",e=["aptos","node","run-localnet","--force-restart","--assume-yes","--with-indexer-api"],r=_os.platform.call(void 0, ),o;r==="win32"?o=_child_process.spawn.call(void 0, s,e,{shell:!0}):o=_child_process.spawn.call(void 0, s,e),this.process=o,_optionalChain([o, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6("data",a=>{let t=a.toString();console.log(t)})]),_optionalChain([o, 'access', _7 => _7.stdout, 'optionalAccess', _8 => _8.on, 'call', _9 => _9("data",a=>{let t=a.toString();this.showStdout&&console.log(t)})])}async waitUntilProcessIsUp(){let s=await this.checkIfProcessIsUp(),e=Date.now()/1e3,r=e;for(;!s&&e+this.MAXIMUM_WAIT_TIME_SEC>r;)await _chunk7IYTZDXVjs.b.call(void 0, 1e3),s=await this.checkIfProcessIsUp(),r=Date.now()/1e3;if(!s)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch (e2){return!1}}};var h=class{async init(s){let{network:e,profile:r,extraArguments:o,showStdout:a}=s,t=["aptos","init",`--network=${_nullishCoalesce(e, () => ("local"))}`,`--profile=${_nullishCoalesce(r, () => ("default"))}`];return o&&t.push(...o),this.runCommand(t,a)}async compile(s){let{packageDirectoryPath:e,namedAddresses:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","compile","--package-dir",e],n=this.parseNamedAddresses(r);return t.push(...this.prepareNamedAddresses(n)),o&&t.push(...o),this.runCommand(t,a)}async test(s){let{packageDirectoryPath:e,namedAddresses:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","test","--package-dir",e],n=this.parseNamedAddresses(r);return t.push(...this.prepareNamedAddresses(n)),o&&t.push(...o),this.runCommand(t,a)}async publish(s){let{packageDirectoryPath:e,namedAddresses:r,profile:o,extraArguments:a,showStdout:t}=s,n=["aptos","move","publish","--package-dir",e,`--profile=${_nullishCoalesce(o, () => ("default"))}`],i=this.parseNamedAddresses(r);return n.push(...this.prepareNamedAddresses(i)),a&&n.push(...a),this.runCommand(n,t)}async createObjectAndPublishPackage(s){let{packageDirectoryPath:e,addressName:r,namedAddresses:o,profile:a,extraArguments:t,showStdout:n}=s,i=["aptos","move","create-object-and-publish-package","--package-dir",e,"--address-name",r,`--profile=${_nullishCoalesce(a, () => ("default"))}`],d=this.parseNamedAddresses(o);i.push(...this.prepareNamedAddresses(d)),t&&i.push(...t);let{output:c}=await this.runCommand(i,n);return{objectAddress:this.extractAddressFromOutput(c)}}async upgradeObjectPackage(s){let{packageDirectoryPath:e,objectAddress:r,namedAddresses:o,profile:a,extraArguments:t,showStdout:n}=s,i=["aptos","move","upgrade-object-package","--package-dir",e,"--object-address",r,`--profile=${_nullishCoalesce(a, () => ("default"))}`],d=this.parseNamedAddresses(o);return i.push(...this.prepareNamedAddresses(d)),t&&i.push(...t),this.runCommand(i,n)}async buildPublishPayload(s){let{outputFile:e,packageDirectoryPath:r,namedAddresses:o,extraArguments:a,showStdout:t}=s,n=["aptos","move","build-publish-payload","--json-output-file",e,"--package-dir",r],i=this.parseNamedAddresses(o);return n.push(...this.prepareNamedAddresses(i)),a&&n.push(...a),this.runCommand(n,t)}async runScript(s){let{compiledScriptPath:e,profile:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","run-script","--compiled-script-path",e,`--profile=${_nullishCoalesce(r, () => ("default"))}`];return o&&t.push(...o),this.runCommand(t,a)}async runCommand(s,e=!0){return new Promise((r,o)=>{let a=_os.platform.call(void 0, ),t,n="",i="";a==="win32"?t=_child_process.spawn.call(void 0, "npx",s,{shell:!0}):t=_child_process.spawn.call(void 0, "npx",s),t.stdout.on("data",d=>{i=d.toString(),n+=d.toString()}),e&&(t.stdout.pipe(process.stdout),t.stderr.pipe(process.stderr)),process.stdin.pipe(t.stdin),t.on("close",d=>{if(d===0)try{let c=JSON.parse(i);c.Error?o(new Error(`Error: ${c.Error}`)):c.Result&&r({result:c.Result,output:n})}catch (e3){r({output:n})}else o(new Error(`Child process exited with code ${d}`))})})}prepareNamedAddresses(s){let e=s.size,r=[];if(e===0)return r;r.push("--named-addresses");let o=[];return s.forEach((a,t)=>{let n=`${t}=${a.toString()}`;o.push(n)}),r.push(o.join(",")),r}parseNamedAddresses(s){let e=new Map;return Object.keys(s).forEach(r=>{let o=s[r];e.set(r,o)}),e}extractAddressFromOutput(s){let e=s.match("Code was successfully deployed to object address (0x[0-9a-fA-F]+)");if(e)return e[1];throw new Error("Failed to extract object address from output")}};exports.LocalNode = l; exports.Move = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkF43XVDYJjs = require('../chunk-F43XVDYJ.js');var _child_process = require('child_process');var _treekill = require('tree-kill'); var _treekill2 = _interopRequireDefault(_treekill);var _os = require('os');var l=class{constructor(s){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.showStdout=!0;this.process=null;this.showStdout=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _ => _.showStdout]), () => (!0))}async stop(){await new Promise((s,e)=>{_optionalChain([this, 'access', _2 => _2.process, 'optionalAccess', _3 => _3.pid])&&_treekill2.default.call(void 0, this.process.pid,r=>{r?e(r):s(!0)})})}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let s="npx",e=["aptos","node","run-localnet","--force-restart","--assume-yes","--with-indexer-api"],r=_os.platform.call(void 0, ),o;r==="win32"?o=_child_process.spawn.call(void 0, s,e,{shell:!0}):o=_child_process.spawn.call(void 0, s,e),this.process=o,_optionalChain([o, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6("data",a=>{let t=a.toString();console.log(t)})]),_optionalChain([o, 'access', _7 => _7.stdout, 'optionalAccess', _8 => _8.on, 'call', _9 => _9("data",a=>{let t=a.toString();this.showStdout&&console.log(t)})])}async waitUntilProcessIsUp(){let s=await this.checkIfProcessIsUp(),e=Date.now()/1e3,r=e;for(;!s&&e+this.MAXIMUM_WAIT_TIME_SEC>r;)await _chunkF43XVDYJjs.b.call(void 0, 1e3),s=await this.checkIfProcessIsUp(),r=Date.now()/1e3;if(!s)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch (e2){return!1}}};var h=class{async init(s){let{network:e,profile:r,extraArguments:o,showStdout:a}=s,t=["aptos","init",`--network=${_nullishCoalesce(e, () => ("local"))}`,`--profile=${_nullishCoalesce(r, () => ("default"))}`];return o&&t.push(...o),this.runCommand(t,a)}async compile(s){let{packageDirectoryPath:e,namedAddresses:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","compile","--package-dir",e],n=this.parseNamedAddresses(r);return t.push(...this.prepareNamedAddresses(n)),o&&t.push(...o),this.runCommand(t,a)}async test(s){let{packageDirectoryPath:e,namedAddresses:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","test","--package-dir",e],n=this.parseNamedAddresses(r);return t.push(...this.prepareNamedAddresses(n)),o&&t.push(...o),this.runCommand(t,a)}async publish(s){let{packageDirectoryPath:e,namedAddresses:r,profile:o,extraArguments:a,showStdout:t}=s,n=["aptos","move","publish","--package-dir",e,`--profile=${_nullishCoalesce(o, () => ("default"))}`],i=this.parseNamedAddresses(r);return n.push(...this.prepareNamedAddresses(i)),a&&n.push(...a),this.runCommand(n,t)}async createObjectAndPublishPackage(s){let{packageDirectoryPath:e,addressName:r,namedAddresses:o,profile:a,extraArguments:t,showStdout:n}=s,i=["aptos","move","create-object-and-publish-package","--package-dir",e,"--address-name",r,`--profile=${_nullishCoalesce(a, () => ("default"))}`],d=this.parseNamedAddresses(o);i.push(...this.prepareNamedAddresses(d)),t&&i.push(...t);let{output:c}=await this.runCommand(i,n);return{objectAddress:this.extractAddressFromOutput(c)}}async upgradeObjectPackage(s){let{packageDirectoryPath:e,objectAddress:r,namedAddresses:o,profile:a,extraArguments:t,showStdout:n}=s,i=["aptos","move","upgrade-object-package","--package-dir",e,"--object-address",r,`--profile=${_nullishCoalesce(a, () => ("default"))}`],d=this.parseNamedAddresses(o);return i.push(...this.prepareNamedAddresses(d)),t&&i.push(...t),this.runCommand(i,n)}async buildPublishPayload(s){let{outputFile:e,packageDirectoryPath:r,namedAddresses:o,extraArguments:a,showStdout:t}=s,n=["aptos","move","build-publish-payload","--json-output-file",e,"--package-dir",r],i=this.parseNamedAddresses(o);return n.push(...this.prepareNamedAddresses(i)),a&&n.push(...a),this.runCommand(n,t)}async runScript(s){let{compiledScriptPath:e,profile:r,extraArguments:o,showStdout:a}=s,t=["aptos","move","run-script","--compiled-script-path",e,`--profile=${_nullishCoalesce(r, () => ("default"))}`];return o&&t.push(...o),this.runCommand(t,a)}async runCommand(s,e=!0){return new Promise((r,o)=>{let a=_os.platform.call(void 0, ),t,n="",i="";a==="win32"?t=_child_process.spawn.call(void 0, "npx",s,{shell:!0}):t=_child_process.spawn.call(void 0, "npx",s),t.stdout.on("data",d=>{i=d.toString(),n+=d.toString()}),e&&(t.stdout.pipe(process.stdout),t.stderr.pipe(process.stderr)),process.stdin.pipe(t.stdin),t.on("close",d=>{if(d===0)try{let c=JSON.parse(i);c.Error?o(new Error(`Error: ${c.Error}`)):c.Result&&r({result:c.Result,output:n})}catch (e3){r({output:n})}else o(new Error(`Child process exited with code ${d}`))})})}prepareNamedAddresses(s){let e=s.size,r=[];if(e===0)return r;r.push("--named-addresses");let o=[];return s.forEach((a,t)=>{let n=`${t}=${a.toString()}`;o.push(n)}),r.push(o.join(",")),r}parseNamedAddresses(s){let e=new Map;return Object.keys(s).forEach(r=>{let o=s[r];e.set(r,o)}),e}extractAddressFromOutput(s){let e=s.match("Code was successfully deployed to object address (0x[0-9a-fA-F]+)");if(e)return e[1];throw new Error("Failed to extract object address from output")}};exports.LocalNode = l; exports.Move = h;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/maayansavir/work/aptos-ts-sdk/dist/common/cli/index.js","../../../src/cli/localNode.ts","../../../src/cli/move.ts"],"names":["LocalNode","args","resolve","reject","kill","err","cliCommand","cliArgs","currentPlatform","platform","childProcess","spawn","data","str","operational","start","last","sleep","Move","network","profile","extraArguments","showStdout"],"mappings":"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","file":"/Users/maayansavir/work/aptos-ts-sdk/dist/common/cli/index.js","sourcesContent":[null,"/* eslint-disable no-console */\n\nimport { ChildProcessWithoutNullStreams, spawn } from \"child_process\";\nimport kill from \"tree-kill\";\nimport { platform } from \"os\";\n\nimport { sleep } from \"../utils/helpers\";\n\n/**\n * Represents a local node for running a testnet environment.\n * This class provides methods to start, stop, and check the status of the local testnet process.\n * It manages the lifecycle of the node process and ensures that it is operational before executing tests.\n */\nexport class LocalNode {\n readonly MAXIMUM_WAIT_TIME_SEC = 75;\n\n readonly READINESS_ENDPOINT = \"http://127.0.0.1:8070/\";\n\n showStdout: boolean = true;\n\n process: ChildProcessWithoutNullStreams | null = null;\n\n constructor(args?: { showStdout?: boolean }) {\n this.showStdout = args?.showStdout ?? true;\n }\n\n /**\n * Kills the current process and all its descendant processes.\n *\n * @returns {Promise<void>} A promise that resolves to true if the process was successfully killed.\n * @throws {Error} If there is an error while attempting to kill the process.\n */\n async stop(): Promise<void> {\n await new Promise((resolve, reject) => {\n if (!this.process?.pid) return;\n\n /**\n * Terminates the process associated with the given process ID.\n *\n * @param pid - The process ID of the process to be terminated.\n * @param callback - A function that is called after the termination attempt is complete.\n * @param callback.err - An error object if the termination failed; otherwise, null.\n * @param callback.resolve - A boolean indicating whether the termination was successful.\n */\n kill(this.process.pid, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve(true);\n }\n });\n });\n }\n\n /**\n * Runs a local testnet and waits for the process to be up.\n * If the local node process is already running, it returns without starting the process.\n *\n * @returns {Promise<void>} A promise that resolves when the process is up.\n */\n async run(): Promise<void> {\n const nodeIsUp = await this.checkIfProcessIsUp();\n if (nodeIsUp) {\n return;\n }\n this.start();\n await this.waitUntilProcessIsUp();\n }\n\n /**\n * Starts the local testnet by running the Aptos node with the specified command-line arguments.\n *\n * @returns {void}\n *\n * @throws {Error} If there is an issue starting the local testnet.\n */\n start(): void {\n const cliCommand = \"npx\";\n const cliArgs = [\"aptos\", \"node\", \"run-localnet\", \"--force-restart\", \"--assume-yes\", \"--with-indexer-api\"];\n\n const currentPlatform = platform();\n let childProcess;\n // Check if current OS is windows\n if (currentPlatform === \"win32\") {\n childProcess = spawn(cliCommand, cliArgs, { shell: true });\n } else {\n childProcess = spawn(cliCommand, cliArgs);\n }\n\n this.process = childProcess;\n\n childProcess.stderr?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output error log\n console.log(str);\n });\n\n childProcess.stdout?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output log\n if (this.showStdout) {\n console.log(str);\n }\n });\n }\n\n /**\n * Waits for the local testnet process to be operational within a specified maximum wait time.\n * This function continuously checks if the process is up and will throw an error if it fails to start.\n *\n * @returns Promise<boolean> - Resolves to true if the process is up, otherwise throws an error.\n */\n async waitUntilProcessIsUp(): Promise<boolean> {\n let operational = await this.checkIfProcessIsUp();\n const start = Date.now() / 1000;\n let last = start;\n\n while (!operational && start + this.MAXIMUM_WAIT_TIME_SEC > last) {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000);\n // eslint-disable-next-line no-await-in-loop\n operational = await this.checkIfProcessIsUp();\n last = Date.now() / 1000;\n }\n\n // If we are here it means something blocks the process to start.\n // Might worth checking if another process is running on port 8080\n if (!operational) {\n throw new Error(\"Process failed to start\");\n }\n\n return true;\n }\n\n /**\n * Checks if the local testnet is up by querying the readiness endpoint.\n *\n * @returns Promise<boolean> - A promise that resolves to true if the testnet is up, otherwise false.\n */\n async checkIfProcessIsUp(): Promise<boolean> {\n try {\n // Query readiness endpoint\n const data = await fetch(this.READINESS_ENDPOINT);\n if (data.status === 200) {\n return true;\n }\n return false;\n } catch (err: any) {\n return false;\n }\n }\n}\n","import { spawn } from \"child_process\";\nimport { platform } from \"os\";\n\nimport { AccountAddress } from \"../core\";\nimport { Network } from \"../utils\";\n\n/**\n * Class representing a Move package management utility for the Aptos blockchain.\n * This class provides methods to initialize directories, compile packages, run tests, publish modules, create objects, upgrade\n * packages, build transaction payloads, and run scripts.\n */\nexport class Move {\n /**\n * Initialize the current directory for Aptos by configuring the necessary settings.\n * Configuration will be pushed into .aptos/config.yaml.\n *\n * @param args - The arguments for initialization.\n * @param args.network - Optional Network type argument to use for default settings; defaults to local.\n * @param args.profile - Optional Profile to use from the config file; defaults to 'default'. This will override associated\n * settings such as the REST URL, the Faucet URL, and the private key arguments.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async init(args: {\n network?: Network;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { network, profile, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"init\", `--network=${network ?? \"local\"}`, `--profile=${profile ?? \"default\"}`];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Compile a Move package located at the specified directory path.\n * This function helps in preparing the Move package for deployment or further processing.\n *\n * @param args - The arguments for compiling the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async compile(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"compile\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run Move unit tests for a specified package.\n *\n * @param args - The arguments for running the tests.\n * @param args.packageDirectoryPath - The path to a Move package (the folder containing a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The stdout output from running the tests.\n */\n async test(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"test\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Publishes the modules to the publisher account on the Aptos blockchain.\n *\n * @param args - The arguments for publishing the modules.\n * @param args.packageDirectoryPath - The path to a move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async publish(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"publish\",\n \"--package-dir\",\n packageDirectoryPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Create a new object and publish the Move package to it on the Aptos blockchain.\n *\n * @param args - The arguments for creating the object and publishing the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.addressName - Address name for the Move package.\n * @param args.namedAddresses - Named addresses for the Move binary.\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The object address.\n *\n * A complete example in CLI:\n * aptos move create-object-and-publish-package \\\n * --package-dir path_to_directory_that_has_move.toml \\\n * --address-name launchpad_addr \\\n * --named-addresses \"launchpad_addr=0x123,initial_creator_addr=0x456\" \\\n * --profile my_profile \\\n * --assume-yes\n */\n async createObjectAndPublishPackage(args: {\n packageDirectoryPath: string;\n addressName: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ objectAddress: string }> {\n const { packageDirectoryPath, addressName, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"create-object-and-publish-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--address-name\",\n addressName,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n const { output } = await this.runCommand(cliArgs, showStdout);\n return { objectAddress: this.extractAddressFromOutput(output) };\n }\n\n /**\n * Upgrade a Move package previously published to an object on the Aptos blockchain.\n * The caller must be the object owner to execute this function.\n *\n * @param args - The arguments for upgrading the object package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.objectAddress - Address of the object that the Move package published to. Ex. 0x1000\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async upgradeObjectPackage(args: {\n packageDirectoryPath: string;\n objectAddress: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, objectAddress, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"upgrade-object-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--object-address\",\n objectAddress,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Build a publication transaction payload and store it in a JSON output file.\n *\n * @param args - The arguments for building the publishing payload.\n * @param args.packageDirectoryPath - Path to a move package (the folder with a Move.toml file).\n * @param args.outputFile - Output file to write the publication transaction to.\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"] *\n * @returns stdout\n */\n async buildPublishPayload(args: {\n packageDirectoryPath: string;\n outputFile: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { outputFile, packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"build-publish-payload\",\n \"--json-output-file\",\n outputFile,\n \"--package-dir\",\n packageDirectoryPath,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Runs a Move script using the provided compiled script path and optional parameters. Ensure that the script is compiled\n * before executing this function.\n *\n * @param args - The arguments for running the script.\n * @param args.compiledScriptPath - Path to a compiled Move script bytecode file.\n * Ex. \"build/my_package/bytecode_scripts/my_move_script.mv\"\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n *\n * @returns The standard output from running the script.\n */\n async runScript(args: {\n compiledScriptPath: string;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { compiledScriptPath, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"run-script\",\n \"--compiled-script-path\",\n compiledScriptPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run a command with the specified arguments and return the output.\n *\n * @param args - An array of strings representing the command-line arguments to be passed to the command.\n * @param showStdout - Show the standard output generated by the command.\n * @returns The standard output generated by the command.\n */\n // eslint-disable-next-line class-methods-use-this\n private async runCommand(args: Array<string>, showStdout: boolean = true): Promise<{ result?: any; output: string }> {\n return new Promise((resolve, reject) => {\n const currentPlatform = platform();\n let childProcess;\n let stdout = \"\";\n // CLI final stdout is the Result/Error JSON string output\n // so we need to keep track of the last stdout\n let lastStdout = \"\";\n\n // Check if current OS is windows\n if (currentPlatform === \"win32\") {\n childProcess = spawn(\"npx\", args, { shell: true });\n } else {\n childProcess = spawn(\"npx\", args);\n }\n\n childProcess.stdout.on(\"data\", (data) => {\n lastStdout = data.toString();\n stdout += data.toString();\n });\n\n if (showStdout) {\n childProcess.stdout.pipe(process.stdout);\n childProcess.stderr.pipe(process.stderr);\n }\n process.stdin.pipe(childProcess.stdin);\n\n childProcess.on(\"close\", (code) => {\n if (code === 0) {\n try {\n // parse the last stdout as it might be the result\n const parsed = JSON.parse(lastStdout);\n if (parsed.Error) {\n reject(new Error(`Error: ${parsed.Error}`)); // Reject if the \"Error\" key exists\n } else if (parsed.Result) {\n resolve({ result: parsed.Result, output: stdout }); // Resolve if the \"Result\" key exists\n }\n } catch (error: any) {\n // resolve the stdout as it might be just a stdout\n resolve({ output: stdout });\n }\n } else {\n reject(new Error(`Child process exited with code ${code}`)); // Reject with an error if the child process exits with an error code\n }\n });\n });\n }\n\n /**\n * Convert named addresses from a Map into an array separated by a comma.\n *\n * @param namedAddresses - A Map where the key is a string representing the name and the value is an AccountAddress.\n * Ex. {'alice' => '0x123', 'bob' => '0x456'}\n * @returns An array of named addresses formatted as strings separated by a comma. Ex. \"alice=0x123,bob=0x456\"\n */\n // eslint-disable-next-line class-methods-use-this\n private prepareNamedAddresses(namedAddresses: Map<string, AccountAddress>): Array<string> {\n const totalNames = namedAddresses.size;\n const newArgs: Array<string> = [];\n\n if (totalNames === 0) {\n return newArgs;\n }\n\n newArgs.push(\"--named-addresses\");\n\n const names: Array<string> = [];\n namedAddresses.forEach((value, key) => {\n const toAppend = `${key}=${value.toString()}`;\n names.push(toAppend);\n });\n newArgs.push(names.join(\",\"));\n return newArgs;\n }\n\n /**\n * Parse named addresses from a Record type into a Map.\n *\n * This function transforms a collection of named addresses into a more accessible format by mapping each name to its\n * corresponding address.\n *\n * @param namedAddresses - A record containing named addresses where the key is the name and the value is the AccountAddress.\n * @returns A Map where each key is a name and each value is the corresponding address.\n */\n // eslint-disable-next-line class-methods-use-this\n private parseNamedAddresses(namedAddresses: Record<string, AccountAddress>): Map<string, AccountAddress> {\n const addressesMap = new Map();\n\n Object.keys(namedAddresses).forEach((key) => {\n const address = namedAddresses[key];\n addressesMap.set(key, address);\n });\n\n return addressesMap;\n }\n\n /**\n * Extracts the object address from the provided output string.\n *\n * @param output - The output string containing the object address.\n * @returns The extracted object address.\n * @throws Error if the object address cannot be extracted from the output.\n */\n // eslint-disable-next-line class-methods-use-this\n private extractAddressFromOutput(output: string): string {\n const match = output.match(\"Code was successfully deployed to object address (0x[0-9a-fA-F]+)\");\n if (match) {\n return match[1];\n }\n throw new Error(\"Failed to extract object address from output\");\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/oliverhe/aptos-ts-sdk/dist/common/cli/index.js","../../../src/cli/localNode.ts","../../../src/cli/move.ts"],"names":["LocalNode","args","resolve","reject","kill","err","cliCommand","cliArgs","currentPlatform","platform","childProcess","spawn","data","str","operational","start","last","sleep","Move","network","profile","extraArguments","showStdout"],"mappings":"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","file":"/Users/oliverhe/aptos-ts-sdk/dist/common/cli/index.js","sourcesContent":[null,"/* eslint-disable no-console */\n\nimport { ChildProcessWithoutNullStreams, spawn } from \"child_process\";\nimport kill from \"tree-kill\";\nimport { platform } from \"os\";\n\nimport { sleep } from \"../utils/helpers\";\n\n/**\n * Represents a local node for running a testnet environment.\n * This class provides methods to start, stop, and check the status of the local testnet process.\n * It manages the lifecycle of the node process and ensures that it is operational before executing tests.\n */\nexport class LocalNode {\n readonly MAXIMUM_WAIT_TIME_SEC = 75;\n\n readonly READINESS_ENDPOINT = \"http://127.0.0.1:8070/\";\n\n showStdout: boolean = true;\n\n process: ChildProcessWithoutNullStreams | null = null;\n\n constructor(args?: { showStdout?: boolean }) {\n this.showStdout = args?.showStdout ?? true;\n }\n\n /**\n * Kills the current process and all its descendant processes.\n *\n * @returns {Promise<void>} A promise that resolves to true if the process was successfully killed.\n * @throws {Error} If there is an error while attempting to kill the process.\n */\n async stop(): Promise<void> {\n await new Promise((resolve, reject) => {\n if (!this.process?.pid) return;\n\n /**\n * Terminates the process associated with the given process ID.\n *\n * @param pid - The process ID of the process to be terminated.\n * @param callback - A function that is called after the termination attempt is complete.\n * @param callback.err - An error object if the termination failed; otherwise, null.\n * @param callback.resolve - A boolean indicating whether the termination was successful.\n */\n kill(this.process.pid, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve(true);\n }\n });\n });\n }\n\n /**\n * Runs a local testnet and waits for the process to be up.\n * If the local node process is already running, it returns without starting the process.\n *\n * @returns {Promise<void>} A promise that resolves when the process is up.\n */\n async run(): Promise<void> {\n const nodeIsUp = await this.checkIfProcessIsUp();\n if (nodeIsUp) {\n return;\n }\n this.start();\n await this.waitUntilProcessIsUp();\n }\n\n /**\n * Starts the local testnet by running the Aptos node with the specified command-line arguments.\n *\n * @returns {void}\n *\n * @throws {Error} If there is an issue starting the local testnet.\n */\n start(): void {\n const cliCommand = \"npx\";\n const cliArgs = [\"aptos\", \"node\", \"run-localnet\", \"--force-restart\", \"--assume-yes\", \"--with-indexer-api\"];\n\n const currentPlatform = platform();\n let childProcess;\n // Check if current OS is windows\n if (currentPlatform === \"win32\") {\n childProcess = spawn(cliCommand, cliArgs, { shell: true });\n } else {\n childProcess = spawn(cliCommand, cliArgs);\n }\n\n this.process = childProcess;\n\n childProcess.stderr?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output error log\n console.log(str);\n });\n\n childProcess.stdout?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output log\n if (this.showStdout) {\n console.log(str);\n }\n });\n }\n\n /**\n * Waits for the local testnet process to be operational within a specified maximum wait time.\n * This function continuously checks if the process is up and will throw an error if it fails to start.\n *\n * @returns Promise<boolean> - Resolves to true if the process is up, otherwise throws an error.\n */\n async waitUntilProcessIsUp(): Promise<boolean> {\n let operational = await this.checkIfProcessIsUp();\n const start = Date.now() / 1000;\n let last = start;\n\n while (!operational && start + this.MAXIMUM_WAIT_TIME_SEC > last) {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000);\n // eslint-disable-next-line no-await-in-loop\n operational = await this.checkIfProcessIsUp();\n last = Date.now() / 1000;\n }\n\n // If we are here it means something blocks the process to start.\n // Might worth checking if another process is running on port 8080\n if (!operational) {\n throw new Error(\"Process failed to start\");\n }\n\n return true;\n }\n\n /**\n * Checks if the local testnet is up by querying the readiness endpoint.\n *\n * @returns Promise<boolean> - A promise that resolves to true if the testnet is up, otherwise false.\n */\n async checkIfProcessIsUp(): Promise<boolean> {\n try {\n // Query readiness endpoint\n const data = await fetch(this.READINESS_ENDPOINT);\n if (data.status === 200) {\n return true;\n }\n return false;\n } catch (err: any) {\n return false;\n }\n }\n}\n","import { spawn } from \"child_process\";\nimport { platform } from \"os\";\n\nimport { AccountAddress } from \"../core\";\nimport { Network } from \"../utils\";\n\n/**\n * Class representing a Move package management utility for the Aptos blockchain.\n * This class provides methods to initialize directories, compile packages, run tests, publish modules, create objects, upgrade\n * packages, build transaction payloads, and run scripts.\n */\nexport class Move {\n /**\n * Initialize the current directory for Aptos by configuring the necessary settings.\n * Configuration will be pushed into .aptos/config.yaml.\n *\n * @param args - The arguments for initialization.\n * @param args.network - Optional Network type argument to use for default settings; defaults to local.\n * @param args.profile - Optional Profile to use from the config file; defaults to 'default'. This will override associated\n * settings such as the REST URL, the Faucet URL, and the private key arguments.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async init(args: {\n network?: Network;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { network, profile, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"init\", `--network=${network ?? \"local\"}`, `--profile=${profile ?? \"default\"}`];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Compile a Move package located at the specified directory path.\n * This function helps in preparing the Move package for deployment or further processing.\n *\n * @param args - The arguments for compiling the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async compile(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"compile\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run Move unit tests for a specified package.\n *\n * @param args - The arguments for running the tests.\n * @param args.packageDirectoryPath - The path to a Move package (the folder containing a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The stdout output from running the tests.\n */\n async test(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"test\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Publishes the modules to the publisher account on the Aptos blockchain.\n *\n * @param args - The arguments for publishing the modules.\n * @param args.packageDirectoryPath - The path to a move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async publish(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"publish\",\n \"--package-dir\",\n packageDirectoryPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Create a new object and publish the Move package to it on the Aptos blockchain.\n *\n * @param args - The arguments for creating the object and publishing the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.addressName - Address name for the Move package.\n * @param args.namedAddresses - Named addresses for the Move binary.\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The object address.\n *\n * A complete example in CLI:\n * aptos move create-object-and-publish-package \\\n * --package-dir path_to_directory_that_has_move.toml \\\n * --address-name launchpad_addr \\\n * --named-addresses \"launchpad_addr=0x123,initial_creator_addr=0x456\" \\\n * --profile my_profile \\\n * --assume-yes\n */\n async createObjectAndPublishPackage(args: {\n packageDirectoryPath: string;\n addressName: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ objectAddress: string }> {\n const { packageDirectoryPath, addressName, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"create-object-and-publish-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--address-name\",\n addressName,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n const { output } = await this.runCommand(cliArgs, showStdout);\n return { objectAddress: this.extractAddressFromOutput(output) };\n }\n\n /**\n * Upgrade a Move package previously published to an object on the Aptos blockchain.\n * The caller must be the object owner to execute this function.\n *\n * @param args - The arguments for upgrading the object package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.objectAddress - Address of the object that the Move package published to. Ex. 0x1000\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n */\n async upgradeObjectPackage(args: {\n packageDirectoryPath: string;\n objectAddress: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, objectAddress, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"upgrade-object-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--object-address\",\n objectAddress,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Build a publication transaction payload and store it in a JSON output file.\n *\n * @param args - The arguments for building the publishing payload.\n * @param args.packageDirectoryPath - Path to a move package (the folder with a Move.toml file).\n * @param args.outputFile - Output file to write the publication transaction to.\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"] *\n * @returns stdout\n */\n async buildPublishPayload(args: {\n packageDirectoryPath: string;\n outputFile: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { outputFile, packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"build-publish-payload\",\n \"--json-output-file\",\n outputFile,\n \"--package-dir\",\n packageDirectoryPath,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Runs a Move script using the provided compiled script path and optional parameters. Ensure that the script is compiled\n * before executing this function.\n *\n * @param args - The arguments for running the script.\n * @param args.compiledScriptPath - Path to a compiled Move script bytecode file.\n * Ex. \"build/my_package/bytecode_scripts/my_move_script.mv\"\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n *\n * @returns The standard output from running the script.\n */\n async runScript(args: {\n compiledScriptPath: string;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { compiledScriptPath, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"run-script\",\n \"--compiled-script-path\",\n compiledScriptPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run a command with the specified arguments and return the output.\n *\n * @param args - An array of strings representing the command-line arguments to be passed to the command.\n * @param showStdout - Show the standard output generated by the command.\n * @returns The standard output generated by the command.\n */\n // eslint-disable-next-line class-methods-use-this\n private async runCommand(args: Array<string>, showStdout: boolean = true): Promise<{ result?: any; output: string }> {\n return new Promise((resolve, reject) => {\n const currentPlatform = platform();\n let childProcess;\n let stdout = \"\";\n // CLI final stdout is the Result/Error JSON string output\n // so we need to keep track of the last stdout\n let lastStdout = \"\";\n\n // Check if current OS is windows\n if (currentPlatform === \"win32\") {\n childProcess = spawn(\"npx\", args, { shell: true });\n } else {\n childProcess = spawn(\"npx\", args);\n }\n\n childProcess.stdout.on(\"data\", (data) => {\n lastStdout = data.toString();\n stdout += data.toString();\n });\n\n if (showStdout) {\n childProcess.stdout.pipe(process.stdout);\n childProcess.stderr.pipe(process.stderr);\n }\n process.stdin.pipe(childProcess.stdin);\n\n childProcess.on(\"close\", (code) => {\n if (code === 0) {\n try {\n // parse the last stdout as it might be the result\n const parsed = JSON.parse(lastStdout);\n if (parsed.Error) {\n reject(new Error(`Error: ${parsed.Error}`)); // Reject if the \"Error\" key exists\n } else if (parsed.Result) {\n resolve({ result: parsed.Result, output: stdout }); // Resolve if the \"Result\" key exists\n }\n } catch (error: any) {\n // resolve the stdout as it might be just a stdout\n resolve({ output: stdout });\n }\n } else {\n reject(new Error(`Child process exited with code ${code}`)); // Reject with an error if the child process exits with an error code\n }\n });\n });\n }\n\n /**\n * Convert named addresses from a Map into an array separated by a comma.\n *\n * @param namedAddresses - A Map where the key is a string representing the name and the value is an AccountAddress.\n * Ex. {'alice' => '0x123', 'bob' => '0x456'}\n * @returns An array of named addresses formatted as strings separated by a comma. Ex. \"alice=0x123,bob=0x456\"\n */\n // eslint-disable-next-line class-methods-use-this\n private prepareNamedAddresses(namedAddresses: Map<string, AccountAddress>): Array<string> {\n const totalNames = namedAddresses.size;\n const newArgs: Array<string> = [];\n\n if (totalNames === 0) {\n return newArgs;\n }\n\n newArgs.push(\"--named-addresses\");\n\n const names: Array<string> = [];\n namedAddresses.forEach((value, key) => {\n const toAppend = `${key}=${value.toString()}`;\n names.push(toAppend);\n });\n newArgs.push(names.join(\",\"));\n return newArgs;\n }\n\n /**\n * Parse named addresses from a Record type into a Map.\n *\n * This function transforms a collection of named addresses into a more accessible format by mapping each name to its\n * corresponding address.\n *\n * @param namedAddresses - A record containing named addresses where the key is the name and the value is the AccountAddress.\n * @returns A Map where each key is a name and each value is the corresponding address.\n */\n // eslint-disable-next-line class-methods-use-this\n private parseNamedAddresses(namedAddresses: Record<string, AccountAddress>): Map<string, AccountAddress> {\n const addressesMap = new Map();\n\n Object.keys(namedAddresses).forEach((key) => {\n const address = namedAddresses[key];\n addressesMap.set(key, address);\n });\n\n return addressesMap;\n }\n\n /**\n * Extracts the object address from the provided output string.\n *\n * @param output - The output string containing the object address.\n * @returns The extracted object address.\n * @throws Error if the object address cannot be extracted from the output.\n */\n // eslint-disable-next-line class-methods-use-this\n private extractAddressFromOutput(output: string): string {\n const match = output.match(\"Code was successfully deployed to object address (0x[0-9a-fA-F]+)\");\n if (match) {\n return match[1];\n }\n throw new Error(\"Failed to extract object address from output\");\n }\n}\n"]}