@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
@@ -1,2 +0,0 @@
1
- import{a as y,c as P,d as V,e as v}from"./chunk-GMKKHGXK.mjs";import{a as B}from"./chunk-ONBFUPEC.mjs";import{a as w,b as m}from"./chunk-OAEDFM7T.mjs";import{b as I,d as U}from"./chunk-P3J54CQG.mjs";import{a as d}from"./chunk-IBLZ6MZU.mjs";import{b as C}from"./chunk-4OV7QU2U.mjs";import{a as T}from"./chunk-HBIDHQ2M.mjs";import{b}from"./chunk-RNJHULIT.mjs";import{a as H}from"./chunk-PRZ7AIGA.mjs";import{b as x}from"./chunk-KM6UXNC7.mjs";import{a as G}from"./chunk-N47FTRYO.mjs";import{a as u,b as E}from"./chunk-QQIVWB6G.mjs";import{b as p}from"./chunk-KFNDDPOW.mjs";import{jwtDecode as M}from"jwt-decode";var me=1e7,R=120,k=30,F=330,ye=120,he=350,ge=300,fe=93,o=class o extends C{constructor(e,t){super();let i=p.fromHexInput(t).toUint8Array();if(i.length!==o.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${o.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=i}authKey(){let e=new E;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),i=e.deserializeBytes();return new o(t,i)}static load(e){let t=e.deserializeStr(),i=e.deserializeBytes();return new o(t,i)}static isPublicKey(e){return e instanceof o}static create(e){return _(e),new o(e.iss,_(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:i,uidKey:a="sub"}=e,n=M(t);if(typeof n.iss!="string")throw new Error("iss was not found");if(typeof n.aud!="string")throw new Error("aud was not found or an array of values");let s=n[a];return o.create({iss:n.iss,uidKey:a,uidVal:s,aud:n.aud,pepper:i})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};o.ID_COMMITMENT_LENGTH=32;var z=o;function _(r){let{uidKey:e,uidVal:t,aud:i,pepper:a}=r,n=[P(p.fromHexInput(a).toUint8Array()),y(i,R),y(t,F),y(e,k)];return V(v(n),z.ID_COMMITMENT_LENGTH)}var D=class r extends d{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:i,expiryDateSecs:a,ephemeralPublicKey:n,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=i,this.expiryDateSecs=a,this.ephemeralPublicKey=n,this.ephemeralSignature=s}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=h.deserialize(e),i=e.deserializeStr(),a=e.deserializeU64(),n=w.deserialize(e),s=m.deserialize(e);return new r({jwtHeader:i,expiryDateSecs:Number(a),ephemeralCertificate:t,ephemeralPublicKey:n,ephemeralSignature:s})}static getSimulationSignature(){return new r({jwtHeader:"{}",ephemeralCertificate:new h(new S({proof:new f(new g({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new w(new I(new Uint8Array(32))),ephemeralSignature:new m(new U(new Uint8Array(64)))})}static isSignature(e){return e instanceof r}},h=class r extends d{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(S.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},c=class r extends u{constructor(e){if(super(),this.data=p.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new r(t)}},l=class r extends u{constructor(e){if(super(),this.data=p.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new r(t)}},g=class r extends B{constructor(e){super();let{a:t,b:i,c:a}=e;this.a=new c(t),this.b=new l(i),this.c=new c(a)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=c.deserialize(e).bcsToBytes(),i=l.deserialize(e).bcsToBytes(),a=c.deserialize(e).bcsToBytes();return new r({a:t,b:i,c:a})}},f=class r extends u{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(g.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},S=class r extends d{constructor(e){super();let{proof:t,expHorizonSecs:i,trainingWheelsSignature:a,extraField:n,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=i,this.trainingWheelsSignature=a,this.extraField=n,this.overrideAudVal=s}static fromBytes(e){return r.deserialize(new G(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=f.deserialize(e),i=Number(e.deserializeU64()),a=e.deserializeOptionStr(),n=e.deserializeOptionStr(),s=e.deserializeOption(m);return new r({proof:t,expHorizonSecs:i,trainingWheelsSignature:s,extraField:a,overrideAudVal:n})}},A=class r{constructor(e,t){this.verficationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new r(new K({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},K=class r{constructor(e){let{alphaG1:t,betaG2:i,deltaG2:a,gammaAbcG1:n,gammaG2:s}=e;this.alphaG1=new c(t),this.betaG2=new l(i),this.deltaG2=new l(a),this.gammaAbcG1=[new c(n[0]),new c(n[1])],this.gammaG2=new l(s)}static fromGroth16VerificationKeyResponse(e){return new r({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function Se(r){let{aptosConfig:e}=r;return T(async()=>{let t=await L(r),i=await N(r);return A.create(i,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}async function L(r){let{aptosConfig:e,options:t}=r,i="0x1::keyless_account::Configuration",{data:a}=await b({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${x.from("0x1").toString()}/resource/${i}`,params:{ledger_version:t?.ledgerVersion}});return a.data}async function N(r){let{aptosConfig:e,options:t}=r,i="0x1::keyless_account::Groth16VerificationKey",{data:a}=await b({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${x.from("0x1").toString()}/resource/${i}`,params:{ledger_version:t?.ledgerVersion}});return a.data}export{me as a,R as b,k as c,F as d,ye as e,he as f,ge as g,fe as h,z as i,D as j,h as k,g as l,f as m,S as n,A as o,Se as p};
2
- //# sourceMappingURL=chunk-FTZGP6XW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { Deserializer, Serializable, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport {\n HexInput,\n EphemeralCertificateVariant,\n AnyPublicKeyVariant,\n SigningScheme,\n ZkpVariant,\n LedgerVersionArg,\n MoveResource,\n} from \"../../types\";\nimport { EphemeralPublicKey, EphemeralSignature } from \"./ephemeral\";\nimport { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from \"./poseidon\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Proof } from \"./proof\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { Groth16VerificationKeyResponse, KeylessConfigurationResponse } from \"../../types/keyless\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { getAptosFullNode } from \"../../client\";\nimport { memoizeAsync } from \"../../utils/memoize\";\nimport { AccountAddress } from \"../accountAddress\";\n\nexport const EPK_HORIZON_SECS = 10000000;\nexport const MAX_AUD_VAL_BYTES = 120;\nexport const MAX_UID_KEY_BYTES = 30;\nexport const MAX_UID_VAL_BYTES = 330;\nexport const MAX_ISS_VAL_BYTES = 120;\nexport const MAX_EXTRA_FIELD_BYTES = 350;\nexport const MAX_JWT_HEADER_B64_BYTES = 300;\nexport const MAX_COMMITED_EPK_BYTES = 93;\n\n/**\n * Represents a Keyless Public Key used for authentication.\n *\n * This class encapsulates the public key functionality for keyless authentication,\n * including methods for generating and verifying signatures, as well as serialization\n * and deserialization of the key. The KeylessPublicKey is represented in the SDK\n * as `AnyPublicKey`.\n */\nexport class KeylessPublicKey extends AccountPublicKey {\n /**\n * The number of bytes that `idCommitment` should be\n */\n static readonly ID_COMMITMENT_LENGTH: number = 32;\n\n /**\n * The value of the 'iss' claim on the JWT which identifies the OIDC provider.\n */\n readonly iss: string;\n\n /**\n * A value representing a cryptographic commitment to a user identity.\n *\n * It is calculated from the aud, uidKey, uidVal, pepper.\n */\n readonly idCommitment: Uint8Array;\n\n /**\n * Constructs an instance with the specified parameters for cryptographic operations.\n *\n * @param args - The parameters required to initialize the instance.\n * @param args.alphaG1 - The hex representation of the alpha G1 value.\n * @param args.betaG2 - The hex representation of the beta G2 value.\n * @param args.deltaG2 - The hex representation of the delta G2 value.\n * @param args.gammaAbcG1 - An array containing two hex representations for gamma ABC G1 values.\n * @param args.gammaG2 - The hex representation of the gamma G2 value.\n */\n // TODO: Fix the JSDoc for the below values\n constructor(iss: string, idCommitment: HexInput) {\n super();\n const idcBytes = Hex.fromHexInput(idCommitment).toUint8Array();\n if (idcBytes.length !== KeylessPublicKey.ID_COMMITMENT_LENGTH) {\n throw new Error(`Id Commitment length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);\n }\n this.iss = iss;\n this.idCommitment = idcBytes;\n }\n\n /**\n * Get the authentication key for the keyless public key.\n *\n * @returns AuthenticationKey - The authentication key derived from the keyless public key.\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Keyless);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: SigningScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n\n /**\n * Verifies the validity of a signature for a given message.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the message.\n * @returns true if the signature is valid; otherwise, false.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {\n throw new Error(\"Not yet implemented\");\n }\n\n /**\n * Serializes the current instance into a format suitable for transmission or storage.\n * This function ensures that all relevant fields are properly serialized, including the proof and optional fields.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @param serializer.proof - The proof to be serialized.\n * @param serializer.expHorizonSecs - The expiration horizon in seconds.\n * @param serializer.extraField - An optional additional field for serialization.\n * @param serializer.overrideAudVal - An optional override value for auditing.\n * @param serializer.trainingWheelsSignature - An optional signature for training wheels.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.iss);\n serializer.serializeBytes(this.idCommitment);\n }\n\n /**\n * Deserializes a ZeroKnowledgeSig object from the provided deserializer.\n * This function allows you to reconstruct a ZeroKnowledgeSig instance from its serialized form.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @returns A new instance of ZeroKnowledgeSig.\n */\n static deserialize(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n /**\n * Loads a KeylessPublicKey instance from the provided deserializer.\n * This function is used to deserialize the necessary components to create a KeylessPublicKey.\n *\n * @param deserializer - The deserializer used to extract the string and byte data.\n * @param deserializer.deserializeStr - A method to deserialize a string value.\n * @param deserializer.deserializeBytes - A method to deserialize byte data.\n * @returns A new instance of KeylessPublicKey.\n */\n static load(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n /**\n * Determines if the provided public key is an instance of KeylessPublicKey.\n *\n * @param publicKey - The public key to check.\n * @returns A boolean indicating whether the public key is a KeylessPublicKey instance.\n */\n static isPublicKey(publicKey: PublicKey): publicKey is KeylessPublicKey {\n return publicKey instanceof KeylessPublicKey;\n }\n\n /**\n * Creates a KeylessPublicKey from the JWT components plus pepper\n *\n * @param args.iss the iss of the identity\n * @param args.uidKey the key to use to get the uidVal in the JWT token\n * @param args.uidVal the value of the uidKey in the JWT token\n * @param args.aud the client ID of the application\n * @param args.pepper The pepper used to maintain privacy of the account\n * @returns KeylessPublicKey\n */\n static create(args: {\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n }): KeylessPublicKey {\n computeIdCommitment(args);\n return new KeylessPublicKey(args.iss, computeIdCommitment(args));\n }\n\n /**\n * Creates a KeylessPublicKey instance from a JWT and a pepper value.\n * This function is useful for generating a public key that can be used for authentication based on the provided JWT claims and pepper.\n *\n * @param args - The arguments for creating the KeylessPublicKey.\n * @param args.jwt - The JSON Web Token to decode.\n * @param args.pepper - The pepper value used in the key creation process.\n * @param args.uidKey - An optional key to retrieve the unique identifier from the JWT payload, defaults to \"sub\".\n * @returns A KeylessPublicKey instance created from the provided JWT and pepper.\n */\n static fromJwtAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {\n const { jwt, pepper, uidKey = \"sub\" } = args;\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n if (typeof jwtPayload.iss !== \"string\") {\n throw new Error(\"iss was not found\");\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const uidVal = jwtPayload[uidKey];\n return KeylessPublicKey.create({ iss: jwtPayload.iss, uidKey, uidVal, aud: jwtPayload.aud, pepper });\n }\n\n /**\n * Checks if the provided public key is a valid instance by verifying its structure and types.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid instance.\n */\n static isInstance(publicKey: PublicKey) {\n return (\n \"iss\" in publicKey &&\n typeof publicKey.iss === \"string\" &&\n \"idCommitment\" in publicKey &&\n publicKey.idCommitment instanceof Uint8Array\n );\n }\n}\n\nfunction computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string; pepper: HexInput }): Uint8Array {\n const { uidKey, uidVal, aud, pepper } = args;\n\n const fields = [\n bytesToBigIntLE(Hex.fromHexInput(pepper).toUint8Array()),\n hashStrToField(aud, MAX_AUD_VAL_BYTES),\n hashStrToField(uidVal, MAX_UID_VAL_BYTES),\n hashStrToField(uidKey, MAX_UID_KEY_BYTES),\n ];\n\n return bigIntToBytesLE(poseidonHash(fields), KeylessPublicKey.ID_COMMITMENT_LENGTH);\n}\n\n/**\n * Represents a signature of a message signed via a Keyless Account, utilizing proofs or a JWT token for authentication.\n */\nexport class KeylessSignature extends Signature {\n /**\n * The inner signature ZeroKnowledgeSignature or OpenIdSignature\n */\n readonly ephemeralCertificate: EphemeralCertificate;\n\n /**\n * The jwt header in the token used to create the proof/signature. In json string representation.\n */\n readonly jwtHeader: string;\n\n /**\n * The expiry timestamp in seconds of the EphemeralKeyPair used to sign\n */\n readonly expiryDateSecs: number;\n\n /**\n * The ephemeral public key used to verify the signature\n */\n readonly ephemeralPublicKey: EphemeralPublicKey;\n\n /**\n * The signature resulting from signing with the private key of the EphemeralKeyPair\n */\n readonly ephemeralSignature: EphemeralSignature;\n\n constructor(args: {\n jwtHeader: string;\n ephemeralCertificate: EphemeralCertificate;\n expiryDateSecs: number;\n ephemeralPublicKey: EphemeralPublicKey;\n ephemeralSignature: EphemeralSignature;\n }) {\n super();\n const { jwtHeader, ephemeralCertificate, expiryDateSecs, ephemeralPublicKey, ephemeralSignature } = args;\n this.jwtHeader = jwtHeader;\n this.ephemeralCertificate = ephemeralCertificate;\n this.expiryDateSecs = expiryDateSecs;\n this.ephemeralPublicKey = ephemeralPublicKey;\n this.ephemeralSignature = ephemeralSignature;\n }\n\n serialize(serializer: Serializer): void {\n this.ephemeralCertificate.serialize(serializer);\n serializer.serializeStr(this.jwtHeader);\n serializer.serializeU64(this.expiryDateSecs);\n this.ephemeralPublicKey.serialize(serializer);\n this.ephemeralSignature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessSignature {\n const ephemeralCertificate = EphemeralCertificate.deserialize(deserializer);\n const jwtHeader = deserializer.deserializeStr();\n const expiryDateSecs = deserializer.deserializeU64();\n const ephemeralPublicKey = EphemeralPublicKey.deserialize(deserializer);\n const ephemeralSignature = EphemeralSignature.deserialize(deserializer);\n return new KeylessSignature({\n jwtHeader,\n expiryDateSecs: Number(expiryDateSecs),\n ephemeralCertificate,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n static getSimulationSignature(): KeylessSignature {\n return new KeylessSignature({\n jwtHeader: \"{}\",\n ephemeralCertificate: new EphemeralCertificate(\n new ZeroKnowledgeSig({\n proof: new ZkProof(\n new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),\n ZkpVariant.Groth16,\n ),\n expHorizonSecs: 0,\n }),\n EphemeralCertificateVariant.ZkProof,\n ),\n expiryDateSecs: 0,\n ephemeralPublicKey: new EphemeralPublicKey(new Ed25519PublicKey(new Uint8Array(32))),\n ephemeralSignature: new EphemeralSignature(new Ed25519Signature(new Uint8Array(64))),\n });\n }\n\n static isSignature(signature: Signature): signature is KeylessSignature {\n return signature instanceof KeylessSignature;\n }\n}\n\n/**\n * Represents an ephemeral certificate containing a signature, specifically a ZeroKnowledgeSig.\n * This class can be extended to support additional signature types, such as OpenIdSignature.\n *\n * @extends Signature\n */\nexport class EphemeralCertificate extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: EphemeralCertificateVariant;\n\n constructor(signature: Signature, variant: EphemeralCertificateVariant) {\n super();\n this.signature = signature;\n this.variant = variant;\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n */\n toUint8Array(): Uint8Array {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralCertificate {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case EphemeralCertificateVariant.ZkProof:\n return new EphemeralCertificate(ZeroKnowledgeSig.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for EphemeralCertificate: ${variant}`);\n }\n }\n}\n\n/**\n * Represents a fixed-size byte array of 32 bytes, extending the Serializable class.\n * This class is used for handling and serializing G1 bytes in cryptographic operations.\n *\n * @extends Serializable\n */\nclass G1Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 32) {\n throw new Error(\"Input needs to be 32 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G1Bytes {\n const bytes = deserializer.deserializeFixedBytes(32);\n return new G1Bytes(bytes);\n }\n}\n\n/**\n * Represents a 64-byte G2 element in a cryptographic context.\n * This class provides methods for serialization and deserialization of G2 bytes.\n *\n * @extends Serializable\n */\nclass G2Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 64) {\n throw new Error(\"Input needs to be 64 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G2Bytes {\n const bytes = deserializer.deserializeFixedBytes(64);\n return new G2Bytes(bytes);\n }\n}\n\n/**\n * Represents a Groth16 zero-knowledge proof, consisting of three proof points in compressed serialization format.\n * The points are the compressed serialization of affine representation of the proof.\n *\n * @extends Proof\n */\nexport class Groth16Zkp extends Proof {\n /**\n * The bytes of G1 proof point a\n */\n a: G1Bytes;\n\n /**\n * The bytes of G2 proof point b\n */\n b: G2Bytes;\n\n /**\n * The bytes of G1 proof point c\n */\n c: G1Bytes;\n\n constructor(args: { a: HexInput; b: HexInput; c: HexInput }) {\n super();\n const { a, b, c } = args;\n this.a = new G1Bytes(a);\n this.b = new G2Bytes(b);\n this.c = new G1Bytes(c);\n }\n\n serialize(serializer: Serializer): void {\n this.a.serialize(serializer);\n this.b.serialize(serializer);\n this.c.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Groth16Zkp {\n const a = G1Bytes.deserialize(deserializer).bcsToBytes();\n const b = G2Bytes.deserialize(deserializer).bcsToBytes();\n const c = G1Bytes.deserialize(deserializer).bcsToBytes();\n return new Groth16Zkp({ a, b, c });\n }\n}\n\n/**\n * Represents a container for different types of zero-knowledge proofs.\n *\n * @extends Serializable\n */\nexport class ZkProof extends Serializable {\n public readonly proof: Proof;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: ZkpVariant;\n\n constructor(proof: Proof, variant: ZkpVariant) {\n super();\n this.proof = proof;\n this.variant = variant;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): ZkProof {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case ZkpVariant.Groth16:\n return new ZkProof(Groth16Zkp.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for ZkProof: ${variant}`);\n }\n }\n}\n\n/**\n * Represents a zero-knowledge signature, encapsulating the proof and its associated metadata.\n *\n * @extends Signature\n */\nexport class ZeroKnowledgeSig extends Signature {\n /**\n * The proof\n */\n readonly proof: ZkProof;\n\n /**\n * The max lifespan of the proof\n */\n readonly expHorizonSecs: number;\n\n /**\n * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.\n * Can be used to assert identity or other attributes.\n */\n readonly extraField?: string;\n\n /**\n * The 'aud' value of the recovery service which is set when recovering an account.\n */\n readonly overrideAudVal?: string;\n\n /**\n * The training wheels signature\n */\n readonly trainingWheelsSignature?: EphemeralSignature;\n\n constructor(args: {\n proof: ZkProof;\n expHorizonSecs: number;\n extraField?: string;\n overrideAudVal?: string;\n trainingWheelsSignature?: EphemeralSignature;\n }) {\n super();\n const { proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal } = args;\n this.proof = proof;\n this.expHorizonSecs = expHorizonSecs;\n this.trainingWheelsSignature = trainingWheelsSignature;\n this.extraField = extraField;\n this.overrideAudVal = overrideAudVal;\n }\n\n /**\n * Deserialize a ZeroKnowledgeSig object from its BCS serialization in bytes.\n *\n * @param bytes - The bytes representing the serialized ZeroKnowledgeSig.\n * @returns ZeroKnowledgeSig - The deserialized ZeroKnowledgeSig object.\n */\n static fromBytes(bytes: Uint8Array): ZeroKnowledgeSig {\n return ZeroKnowledgeSig.deserialize(new Deserializer(bytes));\n }\n\n serialize(serializer: Serializer): void {\n this.proof.serialize(serializer);\n serializer.serializeU64(this.expHorizonSecs);\n serializer.serializeOptionStr(this.extraField);\n serializer.serializeOptionStr(this.overrideAudVal);\n serializer.serializeOption(this.trainingWheelsSignature);\n }\n\n static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {\n const proof = ZkProof.deserialize(deserializer);\n const expHorizonSecs = Number(deserializer.deserializeU64());\n const extraField = deserializer.deserializeOptionStr();\n const overrideAudVal = deserializer.deserializeOptionStr();\n const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);\n return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });\n }\n}\n\n/**\n * Represents the on-chain configuration for how Keyless accounts operate.\n *\n * @remarks\n * This class encapsulates the verification key and the maximum lifespan of ephemeral key pairs,\n * which are essential for the functionality of Keyless accounts.\n */\nexport class KeylessConfiguration {\n /**\n * The verification key used to verify Groth16 proofs on chain\n */\n // TODO: Rename to verificationKey\n readonly verficationKey: Groth16VerificationKey;\n\n /**\n * The maximum lifespan of an ephemeral key pair. This is configured on chain.\n */\n readonly maxExpHorizonSecs: number;\n\n constructor(verficationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {\n this.verficationKey = verficationKey;\n this.maxExpHorizonSecs = maxExpHorizonSecs;\n }\n\n static create(res: Groth16VerificationKeyResponse, maxExpHorizonSecs: number): KeylessConfiguration {\n return new KeylessConfiguration(\n new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n }),\n maxExpHorizonSecs,\n );\n }\n}\n\n/**\n * Represents the verification key stored on-chain used to verify Groth16 proofs.\n */\nclass Groth16VerificationKey {\n // The docstrings below are borrowed from ark-groth16\n\n /**\n * The `alpha * G`, where `G` is the generator of G1\n */\n readonly alphaG1: G1Bytes;\n\n /**\n * The `alpha * H`, where `H` is the generator of G2\n */\n readonly betaG2: G2Bytes;\n\n /**\n * The `delta * H`, where `H` is the generator of G2\n */\n readonly deltaG2: G2Bytes;\n\n /**\n * The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1\n */\n readonly gammaAbcG1: G1Bytes[];\n\n /**\n * The `gamma * H`, where `H` is the generator of G2\n */\n readonly gammaG2: G2Bytes;\n\n constructor(args: {\n alphaG1: HexInput;\n betaG2: HexInput;\n deltaG2: HexInput;\n gammaAbcG1: [HexInput, HexInput];\n gammaG2: HexInput;\n }) {\n const { alphaG1, betaG2, deltaG2, gammaAbcG1, gammaG2 } = args;\n this.alphaG1 = new G1Bytes(alphaG1);\n this.betaG2 = new G2Bytes(betaG2);\n this.deltaG2 = new G2Bytes(deltaG2);\n this.gammaAbcG1 = [new G1Bytes(gammaAbcG1[0]), new G1Bytes(gammaAbcG1[1])];\n this.gammaG2 = new G2Bytes(gammaG2);\n }\n\n /**\n * Converts a Groth16VerificationKeyResponse object into a Groth16VerificationKey instance.\n *\n * @param res - The Groth16VerificationKeyResponse object containing the verification key data.\n * @param res.alpha_g1 - The alpha G1 value from the response.\n * @param res.beta_g2 - The beta G2 value from the response.\n * @param res.delta_g2 - The delta G2 value from the response.\n * @param res.gamma_abc_g1 - The gamma ABC G1 value from the response.\n * @param res.gamma_g2 - The gamma G2 value from the response.\n * @returns A Groth16VerificationKey instance constructed from the provided response data.\n */\n static fromGroth16VerificationKeyResponse(res: Groth16VerificationKeyResponse): Groth16VerificationKey {\n return new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n });\n }\n}\n\n/**\n * Retrieves the configuration parameters for Keyless Accounts on the blockchain, including the verifying key and the maximum\n * expiry horizon.\n *\n * @param args - The arguments for retrieving the keyless configuration.\n * @param args.aptosConfig - The Aptos configuration object containing network details.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, the latest version will be used.\n * @returns KeylessConfiguration - The configuration object containing the verifying key and maximum expiry horizon.\n */\nexport async function getKeylessConfig(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfiguration> {\n const { aptosConfig } = args;\n return memoizeAsync(\n async () => {\n const config = await getKeylessConfigurationResource(args);\n const vk = await getGroth16VerificationKeyResource(args);\n return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));\n },\n `keyless-configuration-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Retrieves the KeylessConfiguration set on chain.\n *\n * @param args - The arguments for retrieving the configuration.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns KeylessConfigurationResponse - The response containing the keyless configuration data.\n */\nasync function getKeylessConfigurationResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfigurationResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Configuration\";\n const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({\n aptosConfig,\n originMethod: \"getKeylessConfigurationResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\n/**\n * Retrieves the Groth16VerificationKey set on the blockchain.\n *\n * @param args - The arguments for retrieving the verification key.\n * @param args.aptosConfig - The Aptos configuration object.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Groth16VerificationKeyResponse - The response containing the Groth16 verification key data.\n */\nasync function getGroth16VerificationKeyResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<Groth16VerificationKeyResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Groth16VerificationKey\";\n const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({\n aptosConfig,\n originMethod: \"getGroth16VerificationKeyResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n"],"mappings":"0jBAGA,OAAqB,aAAAA,MAAiB,aAyB/B,IAAMC,GAAmB,IACnBC,EAAoB,IACpBC,EAAoB,GACpBC,EAAoB,IACpBC,GAAoB,IACpBC,GAAwB,IACxBC,GAA2B,IAC3BC,GAAyB,GAUzBC,EAAN,MAAMA,UAAyBC,CAAiB,CA6BrD,YAAYC,EAAaC,EAAwB,CAC/C,MAAM,EACN,IAAMC,EAAWC,EAAI,aAAaF,CAAY,EAAE,aAAa,EAC7D,GAAIC,EAAS,SAAWJ,EAAiB,qBACvC,MAAM,IAAI,MAAM,2CAA2CA,EAAiB,oBAAoB,EAAE,EAEpG,KAAK,IAAME,EACX,KAAK,aAAeE,CACtB,CAOA,SAA6B,CAC3B,IAAME,EAAa,IAAIC,EACvB,OAAAD,EAAW,uBAAiD,EAC5DA,EAAW,oBAAoB,KAAK,WAAW,CAAC,EACzCE,EAAkB,mBAAmB,CAC1C,SACA,MAAOF,EAAW,aAAa,CACjC,CAAC,CACH,CAWA,gBAAgBG,EAAmE,CACjF,MAAM,IAAI,MAAM,qBAAqB,CACvC,CAaA,UAAUH,EAA8B,CACtCA,EAAW,aAAa,KAAK,GAAG,EAChCA,EAAW,eAAe,KAAK,YAAY,CAC7C,CASA,OAAO,YAAYI,EAA8C,CAC/D,IAAMR,EAAMQ,EAAa,eAAe,EAClCC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AAkC3E,EAGL,CAC1C,GAAM,CAAE,YAAAsE,EAAa,QAAAM,CAAQ,EAAI5E,EAC3B6E,EAAe,+CACf,CAAE,KAAArC,CAAK,EAAI,MAAMsC,EAAmE,CACxF,YAAAR,EACA,aAAc,oCACd,KAAM,YAAYS,EAAe,KAAK,KAAK,EAAE,SAAS,CAAC,aAAaF,CAAY,GAChF,OAAQ,CAAE,eAAgBD,GAAS,aAAc,CACnD,CAAC,EAED,OAAOpC,EAAK,IACd","names":["jwtDecode","EPK_HORIZON_SECS","MAX_AUD_VAL_BYTES","MAX_UID_KEY_BYTES","MAX_UID_VAL_BYTES","MAX_ISS_VAL_BYTES","MAX_EXTRA_FIELD_BYTES","MAX_JWT_HEADER_B64_BYTES","MAX_COMMITED_EPK_BYTES","_KeylessPublicKey","AccountPublicKey","iss","idCommitment","idcBytes","Hex","serializer","Serializer","AuthenticationKey","args","deserializer","addressSeed","publicKey","computeIdCommitment","jwt","pepper","uidKey","jwtPayload","jwtDecode","uidVal","KeylessPublicKey","aud","fields","bytesToBigIntLE","hashStrToField","bigIntToBytesLE","poseidonHash","KeylessSignature","_KeylessSignature","Signature","jwtHeader","ephemeralCertificate","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","EphemeralCertificate","EphemeralPublicKey","EphemeralSignature","ZeroKnowledgeSig","ZkProof","Groth16Zkp","Ed25519PublicKey","Ed25519Signature","signature","_EphemeralCertificate","variant","G1Bytes","_G1Bytes","Serializable","data","bytes","G2Bytes","_G2Bytes","_Groth16Zkp","Proof","a","b","c","_ZkProof","proof","_ZeroKnowledgeSig","expHorizonSecs","trainingWheelsSignature","extraField","overrideAudVal","Deserializer","KeylessConfiguration","_KeylessConfiguration","verficationKey","maxExpHorizonSecs","res","Groth16VerificationKey","_Groth16VerificationKey","alphaG1","betaG2","deltaG2","gammaAbcG1","gammaG2","getKeylessConfig","aptosConfig","memoizeAsync","config","getKeylessConfigurationResource","vk","getGroth16VerificationKeyResource","options","resourceType","getAptosFullNode","AccountAddress"]}
@@ -1,2 +0,0 @@
1
- import{a as w}from"./chunk-CDQGPCHU.mjs";import{a as f}from"./chunk-WV2VJQDS.mjs";import{a as y}from"./chunk-BOWPP6YG.mjs";import{n as u}from"./chunk-FTZGP6XW.mjs";import{b as c}from"./chunk-KM6UXNC7.mjs";import{a as l}from"./chunk-N47FTRYO.mjs";import{jwtDecode as A}from"jwt-decode";var K=class o extends w{constructor(e){let r=y.create(e);super({publicKey:r,...e}),this.publicKey=r}serialize(e){if(this.proof===void 0)throw new Error("Cannot serialize - proof undefined");e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.publicKey.jwkAddress.serialize(e),this.ephemeralKeyPair.serialize(e),this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=c.deserialize(e),d=f.deserialize(e),n=u.deserialize(e);return o.create({proof:n,pepper:s,jwkAddress:a,uidKey:i,jwt:r,ephemeralKeyPair:d})}static fromBytes(e){return o.deserialize(new l(e))}static create(e){let{address:r,proof:i,jwt:s,ephemeralKeyPair:a,pepper:d,jwkAddress:n,uidKey:p="sub",proofFetchCallback:m}=e,t=A(s);if(typeof t.iss!="string")throw new Error("iss was not found");if(typeof t.aud!="string")throw new Error("aud was not found or an array of values");let h=t[p];return new o({address:r,proof:i,ephemeralKeyPair:a,iss:t.iss,uidKey:p,uidVal:h,aud:t.aud,pepper:d,jwkAddress:c.from(n),jwt:s,proofFetchCallback:m})}};export{K as a};
2
- //# sourceMappingURL=chunk-GLATLXF6.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/FederatedKeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { HexInput } from \"../types\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { ZeroKnowledgeSig } from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { FederatedKeylessPublicKey } from \"../core/crypto/federatedKeyless\";\nimport { AbstractKeylessAccount, ProofFetchCallback } from \"./AbstractKeylessAccount\";\n\n/**\n * Account implementation for the FederatedKeyless authentication scheme.\n *\n * Used to represent a FederatedKeyless based account and sign transactions with it.\n *\n * Use `FederatedKeylessAccount.create()` to instantiate a KeylessAccount with a JWT, proof, EphemeralKeyPair and the\n * address the JWKs are installed that will be used to verify the JWT.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n */\nexport class FederatedKeylessAccount extends AbstractKeylessAccount {\n /**\n * The FederatedKeylessPublicKey associated with the account\n */\n readonly publicKey: FederatedKeylessPublicKey;\n\n // Use the static constructor 'create' instead.\n private constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n jwkAddress: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n const publicKey = FederatedKeylessPublicKey.create(args);\n super({ publicKey, ...args });\n this.publicKey = publicKey;\n }\n\n serialize(serializer: Serializer): void {\n if (this.proof === undefined) {\n throw new Error(\"Cannot serialize - proof undefined\");\n }\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.publicKey.jwkAddress.serialize(serializer);\n this.ephemeralKeyPair.serialize(serializer);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): FederatedKeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const jwkAddress = AccountAddress.deserialize(deserializer);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return FederatedKeylessAccount.create({\n proof,\n pepper,\n jwkAddress,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n static fromBytes(bytes: Uint8Array): FederatedKeylessAccount {\n return FederatedKeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n static create(args: {\n address?: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n jwkAddress: AccountAddressInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): FederatedKeylessAccount {\n const { address, proof, jwt, ephemeralKeyPair, pepper, jwkAddress, uidKey = \"sub\", proofFetchCallback } = args;\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n if (typeof jwtPayload.iss !== \"string\") {\n throw new Error(\"iss was not found\");\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const uidVal = jwtPayload[uidKey];\n return new FederatedKeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss: jwtPayload.iss,\n uidKey,\n uidVal,\n aud: jwtPayload.aud,\n pepper,\n jwkAddress: AccountAddress.from(jwkAddress),\n jwt,\n proofFetchCallback,\n });\n }\n}\n"],"mappings":"sPAGA,OAAqB,aAAAA,MAAiB,aAqB/B,IAAMC,EAAN,MAAMC,UAAgCC,CAAuB,CAO1D,YAAYC,EAYjB,CACD,IAAMC,EAAYC,EAA0B,OAAOF,CAAI,EACvD,MAAM,CAAE,UAAAC,EAAW,GAAGD,CAAK,CAAC,EAC5B,KAAK,UAAYC,CACnB,CAEA,UAAUE,EAA8B,CACtC,GAAI,KAAK,QAAU,OACjB,MAAM,IAAI,MAAM,oCAAoC,EAEtDA,EAAW,aAAa,KAAK,GAAG,EAChCA,EAAW,aAAa,KAAK,MAAM,EACnCA,EAAW,oBAAoB,KAAK,MAAM,EAC1C,KAAK,UAAU,WAAW,UAAUA,CAAU,EAC9C,KAAK,iBAAiB,UAAUA,CAAU,EAC1C,KAAK,MAAM,UAAUA,CAAU,CACjC,CAEA,OAAO,YAAYC,EAAqD,CACtE,IAAMC,EAAMD,EAAa,eAAe,EAClCE,EAASF,EAAa,eAAe,EACrCG,EAASH,EAAa,sBAAsB,EAAE,EAC9CI,EAAaC,EAAe,YAAYL,CAAY,EACpDM,EAAmBC,EAAiB,YAAYP,CAAY,EAC5DQ,EAAQC,EAAiB,YAAYT,CAAY,EACvD,OAAON,EAAwB,OAAO,CACpC,MAAAc,EACA,OAAAL,EACA,WAAAC,EACA,OAAAF,EACA,IAAAD,EACA,iBAAAK,CACF,CAAC,CACH,CAEA,OAAO,UAAUI,EAA4C,CAC3D,OAAOhB,EAAwB,YAAY,IAAIiB,EAAaD,CAAK,CAAC,CACpE,CAEA,OAAO,OAAOd,EASc,CAC1B,GAAM,CAAE,QAAAgB,EAAS,MAAAJ,EAAO,IAAAP,EAAK,iBAAAK,EAAkB,OAAAH,EAAQ,WAAAC,EAAY,OAAAF,EAAS,MAAO,mBAAAW,CAAmB,EAAIjB,EAEpGkB,EAAaC,EAAkDd,CAAG,EACxE,GAAI,OAAOa,EAAW,KAAQ,SAC5B,MAAM,IAAI,MAAM,mBAAmB,EAErC,GAAI,OAAOA,EAAW,KAAQ,SAC5B,MAAM,IAAI,MAAM,yCAAyC,EAE3D,IAAME,EAASF,EAAWZ,CAAM,EAChC,OAAO,IAAIR,EAAwB,CACjC,QAAAkB,EACA,MAAAJ,EACA,iBAAAF,EACA,IAAKQ,EAAW,IAChB,OAAAZ,EACA,OAAAc,EACA,IAAKF,EAAW,IAChB,OAAAX,EACA,WAAYE,EAAe,KAAKD,CAAU,EAC1C,IAAAH,EACA,mBAAAY,CACF,CAAC,CACH,CACF","names":["jwtDecode","FederatedKeylessAccount","_FederatedKeylessAccount","AbstractKeylessAccount","args","publicKey","FederatedKeylessPublicKey","serializer","deserializer","jwt","uidKey","pepper","jwkAddress","AccountAddress","ephemeralKeyPair","EphemeralKeyPair","proof","ZeroKnowledgeSig","bytes","Deserializer","address","proofFetchCallback","jwtPayload","jwtDecode","uidVal"]}
@@ -1,2 +0,0 @@
1
- var n=class extends Error{constructor({apiType:r,aptosRequest:t,aptosResponse:e}){super(d({apiType:r,aptosRequest:t,aptosResponse:e})),this.name="AptosApiError",this.url=e.url,this.status=e.status,this.statusText=e.statusText,this.data=e.data,this.request=t}};function d({apiType:s,aptosRequest:r,aptosResponse:t}){let e=t.headers?.traceparent?.split("-")[1],u=e?`(trace_id:${e}) `:"",a=`Request to [${s}]: ${r.method} ${t.url??r.url} ${u}failed with`;return s==="Indexer"&&t.data?.errors?.[0]?.message!=null?`${a}: ${t.data.errors[0].message}`:t.data?.message!=null&&t.data?.error_code!=null?`${a}: ${JSON.stringify(t.data)}`:`${a} status: ${t.statusText}(code:${t.status}) and response body: ${l(t.data)}`}var i=400;function l(s){let r=JSON.stringify(s);return r.length<=i?r:`truncated(original_size:${r.length}): ${r.slice(0,i/2)}...${r.slice(-i/2)}`}export{n as a};
2
- //# sourceMappingURL=chunk-GQABU3RQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/types.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosRequest } from \"../types\";\nimport { AptosApiType } from \"../utils/const.js\";\n\n/**\n * The API response type\n *\n * @param status - the response status. i.e. 200\n * @param statusText - the response message\n * @param data the response data\n * @param url the url the request was made to\n * @param headers the response headers\n * @param config (optional) - the request object\n * @param request (optional) - the request object\n */\nexport interface AptosResponse<Req, Res> {\n status: number;\n statusText: string;\n data: Res;\n url: string;\n headers: any;\n config?: any;\n request?: Req;\n}\n\n/**\n * Options for handling errors in the Aptos API.\n */\ntype AptosApiErrorOpts = {\n apiType: AptosApiType;\n aptosRequest: AptosRequest;\n aptosResponse: AptosResponse<any, any>;\n};\n\n/**\n * Represents an error returned from the Aptos API.\n * This class encapsulates the details of the error, including the request URL, response status, and additional data.\n *\n * @param name - The name of the error, which is always \"AptosApiError\".\n * @param url - The URL to which the request was made.\n * @param status - The HTTP response status code (e.g., 400).\n * @param statusText - The message associated with the response status.\n * @param data - The response data returned from the API.\n * @param request - The original AptosRequest that triggered the error.\n */\nexport class AptosApiError extends Error {\n readonly url: string;\n\n readonly status: number;\n\n readonly statusText: string;\n\n readonly data: any;\n\n readonly request: AptosRequest;\n\n /**\n * Constructs an instance of AptosApiError with relevant error details.\n *\n * @param opts - The options for creating the AptosApiError.\n * @param opts.apiType - The type of API that generated the error.\n * @param opts.aptosRequest - The request object that caused the error.\n * @param opts.aptosResponse - The response object containing error details.\n *\n * @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.\n */\n constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts) {\n super(deriveErrorMessage({ apiType, aptosRequest, aptosResponse }));\n\n this.name = \"AptosApiError\";\n this.url = aptosResponse.url;\n this.status = aptosResponse.status;\n this.statusText = aptosResponse.statusText;\n this.data = aptosResponse.data;\n this.request = aptosRequest;\n }\n}\n\n/**\n * Derives an error message from the Aptos API response, providing context for debugging.\n * This function helps in understanding the nature of the error encountered during an API request.\n *\n * @param {AptosApiErrorOpts} opts - The options for deriving the error message.\n * @param {AptosApiType} opts.apiType - The type of API being called.\n * @param {AptosRequest} opts.aptosRequest - The original request made to the Aptos API.\n * @param {AptosResponse} opts.aptosResponse - The response received from the Aptos API.\n */\nfunction deriveErrorMessage({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts): string {\n // extract the W3C trace_id from the response headers if it exists. Some services set this in the response, and it's useful for debugging.\n // See https://www.w3.org/TR/trace-context/#relationship-between-the-headers .\n const traceId = aptosResponse.headers?.traceparent?.split(\"-\")[1];\n const traceIdString = traceId ? `(trace_id:${traceId}) ` : \"\";\n\n const errorPrelude: string = `Request to [${apiType}]: ${aptosRequest.method} ${\n aptosResponse.url ?? aptosRequest.url\n } ${traceIdString}failed with`;\n\n // handle graphql responses from indexer api and extract the error message of the first error\n if (apiType === AptosApiType.INDEXER && aptosResponse.data?.errors?.[0]?.message != null) {\n return `${errorPrelude}: ${aptosResponse.data.errors[0].message}`;\n }\n\n // Received well-known structured error response body - simply serialize and return it.\n // We don't need http status codes etc. in this case.\n if (aptosResponse.data?.message != null && aptosResponse.data?.error_code != null) {\n return `${errorPrelude}: ${JSON.stringify(aptosResponse.data)}`;\n }\n\n // This is the generic/catch-all case. We received some response from the API, but it doesn't appear to be a well-known structure.\n // We print http status codes and the response body (after some trimming),\n // in the hope that this gives enough context what went wrong without printing overly huge messages.\n return `${errorPrelude} status: ${aptosResponse.statusText}(code:${\n aptosResponse.status\n }) and response body: ${serializeAnyPayloadForErrorMessage(aptosResponse.data)}`;\n}\n\nconst SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH = 400;\n\n/**\n * This function accepts a payload of any type (probably an object) and serializes it to a string\n * Since we don't know the type or size of the payload, and we don't want to add a huge object in full to the error message\n * we limit the to the first 200 and last 200 characters of the serialized payload and put a \"...\" in the middle.\n * @param payload - The payload to serialize, which can be of any type.\n *\n * @returns A string representation of the serialized payload, potentially truncated.\n */\nfunction serializeAnyPayloadForErrorMessage(payload: any): string {\n const serializedPayload = JSON.stringify(payload);\n if (serializedPayload.length <= SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH) {\n return serializedPayload;\n }\n return `truncated(original_size:${serializedPayload.length}): ${serializedPayload.slice(\n 0,\n SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2,\n )}...${serializedPayload.slice(-SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2)}`;\n}\n"],"mappings":"AA+CO,IAAMA,EAAN,cAA4B,KAAM,CAqBvC,YAAY,CAAE,QAAAC,EAAS,aAAAC,EAAc,cAAAC,CAAc,EAAsB,CACvE,MAAMC,EAAmB,CAAE,QAAAH,EAAS,aAAAC,EAAc,cAAAC,CAAc,CAAC,CAAC,EAElE,KAAK,KAAO,gBACZ,KAAK,IAAMA,EAAc,IACzB,KAAK,OAASA,EAAc,OAC5B,KAAK,WAAaA,EAAc,WAChC,KAAK,KAAOA,EAAc,KAC1B,KAAK,QAAUD,CACjB,CACF,EAWA,SAASE,EAAmB,CAAE,QAAAH,EAAS,aAAAC,EAAc,cAAAC,CAAc,EAA8B,CAG/F,IAAME,EAAUF,EAAc,SAAS,aAAa,MAAM,GAAG,EAAE,CAAC,EAC1DG,EAAgBD,EAAU,aAAaA,CAAO,KAAO,GAErDE,EAAuB,eAAeN,CAAO,MAAMC,EAAa,MAAM,IAC1EC,EAAc,KAAOD,EAAa,GACpC,IAAII,CAAa,cAGjB,OAAIL,IAAY,WAAwBE,EAAc,MAAM,SAAS,CAAC,GAAG,SAAW,KAC3E,GAAGI,CAAY,KAAKJ,EAAc,KAAK,OAAO,CAAC,EAAE,OAAO,GAK7DA,EAAc,MAAM,SAAW,MAAQA,EAAc,MAAM,YAAc,KACpE,GAAGI,CAAY,KAAK,KAAK,UAAUJ,EAAc,IAAI,CAAC,GAMxD,GAAGI,CAAY,YAAYJ,EAAc,UAAU,SACxDA,EAAc,MAChB,wBAAwBK,EAAmCL,EAAc,IAAI,CAAC,EAChF,CAEA,IAAMM,EAAwC,IAU9C,SAASD,EAAmCE,EAAsB,CAChE,IAAMC,EAAoB,KAAK,UAAUD,CAAO,EAChD,OAAIC,EAAkB,QAAUF,EACvBE,EAEF,2BAA2BA,EAAkB,MAAM,MAAMA,EAAkB,MAChF,EACAF,EAAwC,CAC1C,CAAC,MAAME,EAAkB,MAAM,CAACF,EAAwC,CAAC,CAAC,EAC5E","names":["AptosApiError","apiType","aptosRequest","aptosResponse","deriveErrorMessage","traceId","traceIdString","errorPrelude","serializeAnyPayloadForErrorMessage","SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH","payload","serializedPayload"]}
@@ -1,4 +0,0 @@
1
- import{a as d}from"./chunk-YZ5BCOGI.mjs";import{a as y,b as l,c as C,d as T,e as O,f as h,g as L,h as P,i as S,j as V,k as b,l as R,n as w,o as I,p as v,q as k}from"./chunk-Y267I7DC.mjs";import{a as o}from"./chunk-BG2TZI3H.mjs";import{a as f}from"./chunk-PCLU4KLY.mjs";import{a as p}from"./chunk-HBIDHQ2M.mjs";import{e as u,f as A}from"./chunk-J245N3XF.mjs";import{b as r}from"./chunk-KM6UXNC7.mjs";import{g,h as m}from"./chunk-LEKBJ2EG.mjs";var M=class{constructor(e){this.config=e}async getAccountInfo(e){return y({aptosConfig:this.config,...e})}async getAccountModules(e){return l({aptosConfig:this.config,...e})}async getAccountModule(e){return C({aptosConfig:this.config,...e})}async getAccountTransactions(e){return T({aptosConfig:this.config,...e})}async getAccountResources(e){return O({aptosConfig:this.config,...e})}async getAccountResource(e){return h({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return L({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),P({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),S({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),V({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),b({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),R({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),w({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),I({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:u,faMetadataAddress:A,...e})}async getAccountCoinAmount(e){let{accountAddress:a,coinType:s,faMetadataAddress:t,minimumLedgerVersion:N}=e;N&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
2
- compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
3
- will be removed in the near future`);let c=s;s===void 0&&t!==void 0&&(c=await p(async()=>{try{let n=(await d({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[t]}})).at(0);if(n.vec.length>0&&m(n.vec[0]))return g(n.vec[0])}catch{}},`coin-mapping-${t.toString()}`,1e3*60*5)());let i;if(s!==void 0&&t!==void 0)i=r.from(t).toStringLong();else if(s!==void 0&&t===void 0)s===u?i=r.A.toStringLong():i=f(r.A,s).toStringLong();else if(s===void 0&&t!==void 0){let n=r.from(t);i=n.toStringLong(),n===r.A&&(c=u)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(c!==void 0){let[n]=await d({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[c],functionArguments:[a]}});return parseInt(n,10)}let[E]=await d({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[a,i]}});return parseInt(E,10)}async getAccountOwnedObjects(e){return await o({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),v({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return k({aptosConfig:this.config,...e})}};export{M as a};
4
- //# sourceMappingURL=chunk-HM5HITUC.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-I5OYNCZS.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as r}from"./chunk-QQIVWB6G.mjs";import{b as t}from"./chunk-KFNDDPOW.mjs";var o=class extends r{toUint8Array(){return this.bcsToBytes()}toString(){let i=this.toUint8Array();return t.fromHexInput(i).toString()}};export{o as a};
2
- //# sourceMappingURL=chunk-IBLZ6MZU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bcs/serializable/moveStructs.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Bool, U128, U16, U256, U32, U64, U8 } from \"./movePrimitives\";\nimport { Serializable, Serializer } from \"../serializer\";\nimport { Deserializable, Deserializer } from \"../deserializer\";\nimport { AnyNumber, HexInput, ScriptTransactionArgumentVariants } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { EntryFunctionArgument, TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * This class is the Aptos Typescript SDK representation of a Move `vector<T>`,\n * where `T` represents either a primitive type (`bool`, `u8`, `u64`, ...)\n * or a BCS-serializable struct itself.\n *\n * It is a BCS-serializable, array-like type that contains an array of values of type `T`,\n * where `T` is a class that implements `Serializable`.\n *\n * The purpose of this class is to facilitate easy construction of BCS-serializable\n * Move `vector<T>` types.\n *\n * @example\n * // in Move: `vector<u8> [1, 2, 3, 4];`\n * const vecOfU8s = new MoveVector<U8>([new U8(1), new U8(2), new U8(3), new U8(4)]);\n * // in Move: `std::bcs::to_bytes(vector<u8> [1, 2, 3, 4]);`\n * const bcsBytes = vecOfU8s.toUint8Array();\n *\n * // vector<vector<u8>> [ vector<u8> [1], vector<u8> [1, 2, 3, 4], vector<u8> [5, 6, 7, 8] ];\n * const vecOfVecs = new MoveVector<MoveVector<U8>>([\n * new MoveVector<U8>([new U8(1)]),\n * MoveVector.U8([1, 2, 3, 4]),\n * MoveVector.U8([5, 6, 7, 8]),\n * ]);\n *\n * // vector<Option<u8>> [ std::option::some<u8>(1), std::option::some<u8>(2) ];\n * const vecOfOptionU8s = new MoveVector<MoveOption<U8>>([\n * MoveOption.U8(1),\n * MoveOption.U8(2),\n * ]);\n *\n * // vector<MoveString> [ std::string::utf8(b\"hello\"), std::string::utf8(b\"world\") ];\n * const vecOfStrings = new MoveVector([new MoveString(\"hello\"), new MoveString(\"world\")]);\n * const vecOfStrings2 = MoveVector.MoveString([\"hello\", \"world\"]);\n *\n * @params\n * values: an Array<T> of values where T is a class that implements Serializable\n * @returns a `MoveVector<T>` with the values `values`\n */\nexport class MoveVector<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements TransactionArgument\n{\n public values: Array<T>;\n\n /**\n * Initializes a new instance of the class with an optional value.\n * This constructor sets up the internal vector based on the provided value.\n *\n * @param values - The initial value to be stored in the vector, or null to initialize an empty vector.\n */\n constructor(values: Array<T>) {\n super();\n this.values = values;\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows the data to be properly formatted for transmission or storage.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * NOTE: This function will only work when the inner values in the `MoveVector` are `U8`s.\n * @param serializer\n */\n\n /**\n * Serialize the string as a fixed byte string without the length prefix for use in a script function.\n * @param serializer - The serializer used to convert the byte vector into a format suitable for a script function.\n */\n serializeForScriptFunction(serializer: Serializer): void {\n // This checks if the type of a non-empty vector is of type other than U8. If so, we use the Serialized\n // transaction argument type to serialize the argument.\n if (this.values[0] !== undefined && !(this.values[0] instanceof U8)) {\n const serialized = new Serialized(this.bcsToBytes());\n serialized.serializeForScriptFunction(serializer);\n return;\n }\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8Vector);\n serializer.serialize(this);\n }\n\n /**\n * Factory method to generate a MoveVector<U8> from a `number` or `undefined`.\n *\n * This method allows you to create a MoveVector that encapsulates a U8 value, enabling you to handle optional U8 values\n * effectively.\n *\n * @param values - The values used to fill the MoveVector. If `values` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U8> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U8([1, 2, 3, 4]);\n * ```\n */\n static U8(values: Array<number> | HexInput): MoveVector<U8> {\n let numbers: Array<number>;\n\n if (Array.isArray(values) && values.length === 0) {\n // Handle empty array, since it won't have a \"first value\"\n numbers = [];\n } else if (Array.isArray(values) && typeof values[0] === \"number\") {\n numbers = values;\n } else if (typeof values === \"string\") {\n const hex = Hex.fromHexInput(values);\n numbers = Array.from(hex.toUint8Array());\n } else if (values instanceof Uint8Array) {\n numbers = Array.from(values);\n } else {\n throw new Error(\"Invalid input type, must be an number[], Uint8Array, or hex string\");\n }\n\n return new MoveVector<U8>(numbers.map((v) => new U8(v)));\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `null`.\n * \n * This method allows you to create a MoveVector that can either hold a U16 value or be empty. \n * \n * @param values - The value used to fill the MoveVector. If `value` is null or undefined, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U16> with an inner value `value`.\n * @example\n * ```typescript\n * const v = MoveVector.U16([1, 2, 3, 4]);\n * ```\n\n */\n static U16(values: Array<number>): MoveVector<U16> {\n return new MoveVector<U16>(values.map((v) => new U16(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U32> from a `number` or `null`.\n * \n * This method allows you to create a MoveVector that can either hold a U32 value or be empty. \n * \n * @param values - The value used to fill the MoveVector. If `value` is null or undefined,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U32> with an inner value `value`.\n * \n * @example\n * ```\n * const v = MoveVector.U32([1, 2, 3, 4]);\n * ```\n\n */\n static U32(values: Array<number>): MoveVector<U32> {\n return new MoveVector<U32>(values.map((v) => new U32(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U64> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U64 value that can be checked for presence.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U64> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U64([1, 2, 3, 4]);\n * ```\n */\n static U64(values: Array<AnyNumber>): MoveVector<U64> {\n return new MoveVector<U64>(values.map((v) => new U64(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U128> from a number, bigint, or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's `.isSome()`\n * method will return false.\n * @returns A MoveVector<U128> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U128([1, 2, 3, 4]);\n * ```\n */\n static U128(values: Array<AnyNumber>): MoveVector<U128> {\n return new MoveVector<U128>(values.map((v) => new U128(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U256> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U256 value, enabling checks for presence or absence of a value.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U256> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U256([1, 2, 3, 4]);\n * ```\n */\n static U256(values: Array<AnyNumber>): MoveVector<U256> {\n return new MoveVector<U256>(values.map((v) => new U256(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<Bool> from a `boolean` or `undefined`.\n * This method allows you to create an optional boolean value that can be used in various contexts where a boolean may or may\n * not be present.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<Bool> with an inner value `value`.\n *\n * @example\n * * const v = MoveVector.Bool([true, false, true, false]);\n */\n static Bool(values: Array<boolean>): MoveVector<Bool> {\n return new MoveVector<Bool>(values.map((v) => new Bool(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<MoveString> from a `string` or `undefined`.\n * This function creates a MoveVector that encapsulates a MoveString if the provided value is not null or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<MoveString> with an inner value `value`.\n *\n * @example\n * const v = MoveVector.MoveString([\"hello\", \"world\"]);\n */\n static MoveString(values: Array<string>): MoveVector<MoveString> {\n return new MoveVector<MoveString>(values.map((v) => new MoveString(v)));\n }\n\n /**\n * Serializes the current object using the provided serializer.\n * This function will serialize the value if it is present.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n */\n serialize(serializer: Serializer): void;\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.values);\n }\n\n /**\n * Deserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.\n *\n * NOTE: This only works with a depth of one. Generics will not work.\n *\n * NOTE: This will not work with types that aren't of the Serializable class.\n *\n * If you're looking for a more flexible deserialization function, you can use the deserializeVector function\n * in the Deserializer class.\n *\n * @example\n * const vec = MoveVector.deserialize(deserializer, U64);\n * @param deserializer the Deserializer instance to use, with bytes loaded into it already.\n * @param cls the class to typecast the input values to, must be a Serializable and Deserializable type.\n * @returns a MoveVector of the corresponding class T\n *\n */\n static deserialize<T extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<T>,\n ): MoveVector<T> {\n const length = deserializer.deserializeUleb128AsU32();\n const values = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n values.push(cls.deserialize(deserializer));\n }\n return new MoveVector(values);\n }\n}\n\n/**\n * Represents a serialized data structure that encapsulates a byte array.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of byte data, as well as converting to a MoveVector.\n *\n * @extends Serializable\n */\nexport class Serialized extends Serializable implements TransactionArgument {\n public readonly value: Uint8Array;\n\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n this.serialize(serializer);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Serialized);\n this.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Serialized {\n return new Serialized(deserializer.deserializeBytes());\n }\n\n /**\n * Deserialize the bytecode into a MoveVector of the specified type.\n * This function allows you to convert serialized data into a usable MoveVector format.\n *\n * @param cls - The class type of the elements in the MoveVector.\n */\n toMoveVector<T extends Serializable & EntryFunctionArgument>(cls: Deserializable<T>): MoveVector<T> {\n const deserializer = new Deserializer(this.bcsToBytes());\n deserializer.deserializeUleb128AsU32();\n const vec = deserializer.deserializeVector(cls);\n return new MoveVector(vec);\n }\n}\n\n/**\n * Represents a string value that can be serialized and deserialized.\n * This class extends the Serializable base class and provides methods\n * for serializing the string in different contexts, such as for entry\n * functions and script functions.\n *\n * @extends Serializable\n */\nexport class MoveString extends Serializable implements TransactionArgument {\n public value: string;\n\n constructor(value: string) {\n super();\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n // Serialize the string as a fixed byte string, i.e., without the length prefix\n const textEncoder = new TextEncoder();\n const fixedStringBytes = textEncoder.encode(this.value);\n // Put those bytes into a vector<u8> and serialize it as a script function argument\n const vectorU8 = MoveVector.U8(fixedStringBytes);\n vectorU8.serializeForScriptFunction(serializer);\n }\n\n static deserialize(deserializer: Deserializer): MoveString {\n return new MoveString(deserializer.deserializeStr());\n }\n}\n\nexport class MoveOption<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements EntryFunctionArgument\n{\n private vec: MoveVector<T>;\n\n public readonly value?: T;\n\n constructor(value?: T | null) {\n super();\n if (typeof value !== \"undefined\" && value !== null) {\n this.vec = new MoveVector([value]);\n } else {\n this.vec = new MoveVector([]);\n }\n\n [this.value] = this.vec.values;\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Retrieves the inner value of the MoveOption.\n *\n * This method is inspired by Rust's `Option<T>.unwrap()`, where attempting to unwrap a `None` value results in a panic.\n * This method will throw an error if the value is not present.\n *\n * @example\n * const option = new MoveOption<Bool>(new Bool(true));\n * const value = option.unwrap(); // Returns the Bool instance\n *\n * @throws {Error} Throws an error if the MoveOption does not contain a value.\n *\n * @returns {T} The contained value if present.\n */\n unwrap(): T {\n if (!this.isSome()) {\n throw new Error(\"Called unwrap on a MoveOption with no value\");\n } else {\n return this.vec.values[0];\n }\n }\n\n /**\n * Check if the MoveOption has a value.\n *\n * @returns {boolean} Returns true if there is exactly one value in the MoveOption.\n */\n isSome(): boolean {\n return this.vec.values.length === 1;\n }\n\n serialize(serializer: Serializer): void {\n // serialize 0 or 1\n // if 1, serialize the value\n this.vec.serialize(serializer);\n }\n\n /**\n * Factory method to generate a MoveOption<U8> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U8(1).isSome() === true;\n * MoveOption.U8().isSome() === false;\n * MoveOption.U8(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U8> with an inner value `value`\n */\n static U8(value?: number | null): MoveOption<U8> {\n return new MoveOption<U8>(value !== null && value !== undefined ? new U8(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U16(1).isSome() === true;\n * MoveOption.U16().isSome() === false;\n * MoveOption.U16(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U16> with an inner value `value`\n */\n static U16(value?: number | null): MoveOption<U16> {\n return new MoveOption<U16>(value !== null && value !== undefined ? new U16(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U32> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U32(1).isSome() === true;\n * MoveOption.U32().isSome() === false;\n * MoveOption.U32(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U32> with an inner value `value`\n */\n static U32(value?: number | null): MoveOption<U32> {\n return new MoveOption<U32>(value !== null && value !== undefined ? new U32(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U64(1).isSome() === true;\n * MoveOption.U64().isSome() === false;\n * MoveOption.U64(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U64> with an inner value `value`\n */\n static U64(value?: AnyNumber | null): MoveOption<U64> {\n return new MoveOption<U64>(value !== null && value !== undefined ? new U64(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U128(1).isSome() === true;\n * MoveOption.U128().isSome() === false;\n * MoveOption.U128(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U128> with an inner value `value`\n */\n static U128(value?: AnyNumber | null): MoveOption<U128> {\n return new MoveOption<U128>(value !== null && value !== undefined ? new U128(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U256(1).isSome() === true;\n * MoveOption.U256().isSome() === false;\n * MoveOption.U256(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U256> with an inner value `value`\n */\n static U256(value?: AnyNumber | null): MoveOption<U256> {\n return new MoveOption<U256>(value !== null && value !== undefined ? new U256(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.\n *\n * @example\n * MoveOption.Bool(true).isSome() === true;\n * MoveOption.Bool().isSome() === false;\n * MoveOption.Bool(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<Bool> with an inner value `value`\n */\n static Bool(value?: boolean | null): MoveOption<Bool> {\n return new MoveOption<Bool>(value !== null && value !== undefined ? new Bool(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.\n *\n * @example\n * MoveOption.MoveString(\"hello\").isSome() === true;\n * MoveOption.MoveString(\"\").isSome() === true;\n * MoveOption.MoveString().isSome() === false;\n * MoveOption.MoveString(undefined).isSome() === false;\n * @params value: the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<MoveString> with an inner value `value`\n */\n static MoveString(value?: string | null): MoveOption<MoveString> {\n return new MoveOption<MoveString>(value !== null && value !== undefined ? new MoveString(value) : undefined);\n }\n\n static deserialize<U extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<U>,\n ): MoveOption<U> {\n const vector = MoveVector.deserialize(deserializer, cls);\n return new MoveOption(vector.values[0]);\n }\n}\n"],"mappings":"8MAgDO,IAAMA,EAAN,MAAMC,UACHC,CAEV,CASE,YAAYC,EAAkB,CAC5B,MAAM,EACN,KAAK,OAASA,CAChB,CAQA,0BAA0BC,EAA8B,CACtD,IAAMC,EAAW,KAAK,WAAW,EACjCD,EAAW,eAAeC,CAAQ,CACpC,CAWA,2BAA2BD,EAA8B,CAGvD,GAAI,KAAK,OAAO,CAAC,IAAM,QAAa,EAAE,KAAK,OAAO,CAAC,YAAaE,GAAK,CAChD,IAAIC,EAAW,KAAK,WAAW,CAAC,EACxC,2BAA2BH,CAAU,EAChD,MACF,CACAA,EAAW,uBAAgE,EAC3EA,EAAW,UAAU,IAAI,CAC3B,CAiBA,OAAO,GAAGD,EAAkD,CAC1D,IAAIK,EAEJ,GAAI,MAAM,QAAQL,CAAM,GAAKA,EAAO,SAAW,EAE7CK,EAAU,CAAC,UACF,MAAM,QAAQL,CAAM,GAAK,OAAOA,EAAO,CAAC,GAAM,SACv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KAA8B,IAAIP,EAAKO,CAAK,EAAI,MAAS,CACjG,CAcA,OAAO,WAAWA,EAA+C,CAC/D,OAAO,IAAIM,EAAuBN,GAAU,KAA8B,IAAIN,EAAWM,CAAK,EAAI,MAAS,CAC7G,CAEA,OAAO,YACLL,EACAC,EACe,CACf,IAAMW,EAAS/B,EAAW,YAAYmB,EAAcC,CAAG,EACvD,OAAO,IAAIU,EAAWC,EAAO,OAAO,CAAC,CAAC,CACxC,CACF","names":["MoveVector","_MoveVector","Serializable","values","serializer","bcsBytes","U8","Serialized","numbers","hex","Hex","v","U16","U32","U64","U128","U256","Bool","MoveString","deserializer","cls","length","i","_Serialized","value","Deserializer","vec","_MoveString","fixedStringBytes","MoveOption","_MoveOption","vector"]}
@@ -1,2 +0,0 @@
1
- import{a as t}from"./chunk-5S3Z7MT4.mjs";var o=class{constructor(n){this.config=n}async simple(n){return t({aptosConfig:this.config,...n})}async multiAgent(n){return t({aptosConfig:this.config,...n})}};export{o as a};
2
- //# sourceMappingURL=chunk-JN36BNWA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/transactionSubmission/build.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AccountAddressInput } from \"../../core\";\nimport { generateTransaction } from \"../../internal/transactionSubmission\";\nimport { InputGenerateTransactionPayloadData, InputGenerateTransactionOptions } from \"../../transactions\";\nimport { MultiAgentTransaction } from \"../../transactions/instances/multiAgentTransaction\";\nimport { SimpleTransaction } from \"../../transactions/instances/simpleTransaction\";\nimport { AptosConfig } from \"../aptosConfig\";\n\n/**\n * A class to handle all `Build` transaction operations.\n */\nexport class Build {\n readonly config: AptosConfig;\n\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n * This allows you to interact with the Aptos blockchain using the provided settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n * @param config.account - The account details for authentication.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for the Aptos client\n * const config = new AptosConfig({\n * network: Network.TESTNET, // specify the network\n * nodeUrl: \"https://testnet.aptos.dev\", // specify the node URL\n * });\n *\n * // Initialize the Aptos client\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Build a simple transaction.\n *\n * This function allows you to create a transaction with specified sender and data.\n *\n * @param args.sender - The sender account address.\n * @param args.data - The transaction data.\n * @param args.options - Optional transaction configurations.\n * @param args.withFeePayer - Whether there is a fee payer for the transaction.\n *\n * @returns SimpleTransaction\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Build a simple transaction\n * const transaction = await aptos.transaction.simple({\n * sender: \"0x1\", // replace with a real sender account address\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x2\", 100], // replace with a real destination account address\n * },\n * options: {\n * gasUnitPrice: 100, // specify your own gas unit price if needed\n * maxGasAmount: 1000, // specify your own max gas amount if needed\n * },\n * });\n *\n * console.log(transaction);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async simple(args: {\n sender: AccountAddressInput;\n data: InputGenerateTransactionPayloadData;\n options?: InputGenerateTransactionOptions;\n withFeePayer?: boolean;\n }): Promise<SimpleTransaction> {\n return generateTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Build a multi-agent transaction that allows multiple signers to authorize a transaction.\n *\n * @param args - The parameters for creating the multi-agent transaction.\n * @param args.sender - The sender account address.\n * @param args.data - The transaction data.\n * @param args.secondarySignerAddresses - An array of the secondary signers' account addresses.\n * @param args.options - Optional transaction configurations.\n * @param args.withFeePayer - Whether there is a fee payer for the transaction.\n *\n * @returns MultiAgentTransaction\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Build a multi-agent transaction\n * const transaction = await aptos.multiAgent({\n * sender: \"0x1\", // replace with a real sender account address\n * data: {\n * // Transaction data structure\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x2\", 100], // replace with a real destination account address and amount\n * },\n * secondarySignerAddresses: [\"0x3\", \"0x4\"], // replace with real secondary signer addresses\n * options: {\n * // Optional transaction configurations\n * maxGasAmount: \"1000\",\n * gasUnitPrice: \"1\",\n * },\n * });\n *\n * console.log(transaction);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async multiAgent(args: {\n sender: AccountAddressInput;\n data: InputGenerateTransactionPayloadData;\n secondarySignerAddresses: AccountAddressInput[];\n options?: InputGenerateTransactionOptions;\n withFeePayer?: boolean;\n }): Promise<MultiAgentTransaction> {\n return generateTransaction({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"yCAaO,IAAMA,EAAN,KAAY,CA+BjB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwCA,MAAM,OAAOC,EAKkB,CAC7B,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CA2CA,MAAM,WAAWA,EAMkB,CACjC,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CACF","names":["Build","config","args","generateTransaction"]}
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-6Q2O5G3J.mjs";import{bytesToHex as s,hexToBytes as o}from"@noble/hashes/utils";var l=(e=>(e.TOO_SHORT="too_short",e.INVALID_LENGTH="invalid_length",e.INVALID_HEX_CHARS="invalid_hex_chars",e))(l||{}),i=class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return s(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let r=t;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new a("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new a("Hex string must be an even number of hex characters.","invalid_length");try{return new n(o(r))}catch(e){throw new a(`Hex string contains invalid hex characters: ${e?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,e)=>r===t.data[e])}};export{l as a,i as b};
2
- //# sourceMappingURL=chunk-KFNDDPOW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/hex.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"],"mappings":"oCAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBAOhC,IAAKC,OACVA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,kBAAoB,oBAHVA,OAAA,IA8BCC,EAAN,MAAMC,CAAI,CAQf,YAAYC,EAAkB,CAC5B,KAAK,KAAOA,CACd,CAWA,cAA2B,CACzB,OAAO,KAAK,IACd,CAOA,uBAAgC,CAC9B,OAAOC,EAAW,KAAK,IAAI,CAC7B,CAOA,UAAmB,CACjB,MAAO,KAAK,KAAK,sBAAsB,CAAC,EAC1C,CAeA,OAAO,cAAcC,EAAkB,CACrC,IAAIC,EAAQD,EAMZ,GAJIC,EAAM,WAAW,IAAI,IACvBA,EAAQA,EAAM,MAAM,CAAC,GAGnBA,EAAM,SAAW,EACnB,MAAM,IAAIC,EACR,4FACA,WACF,EAGF,GAAID,EAAM,OAAS,IAAM,EACvB,MAAM,IAAIC,EAAa,uDAAwD,gBAA+B,EAGhH,GAAI,CACF,OAAO,IAAIL,EAAIM,EAAWF,CAAK,CAAC,CAClC,OAASG,EAAY,CACnB,MAAM,IAAIF,EACR,+CAA+CE,GAAO,OAAO,GAC7D,mBACF,CACF,CACF,CASA,OAAO,aAAaC,EAAyB,CAC3C,OAAIA,aAAoB,WAAmB,IAAIR,EAAIQ,CAAQ,EACpDR,EAAI,cAAcQ,CAAQ,CACnC,CAgBA,OAAO,QAAQL,EAA8C,CAC3D,GAAI,CACF,OAAAH,EAAI,cAAcG,CAAG,EACd,CAAE,MAAO,EAAK,CACvB,OAASI,EAAY,CACnB,MAAO,CACL,MAAO,GACP,cAAeA,GAAO,cACtB,qBAAsBA,GAAO,OAC/B,CACF,CACF,CAQA,OAAOE,EAAqB,CAC1B,OAAI,KAAK,KAAK,SAAWA,EAAM,KAAK,OAAe,GAC5C,KAAK,KAAK,MAAM,CAACC,EAAOC,IAAUD,IAAUD,EAAM,KAAKE,CAAK,CAAC,CACtE,CACF","names":["bytesToHex","hexToBytes","HexInvalidReason","Hex","_Hex","data","bytesToHex","str","input","ParsingError","hexToBytes","error","hexInput","other","value","index"]}
@@ -1,2 +0,0 @@
1
- import{b as t}from"./chunk-KFNDDPOW.mjs";var o=n=>typeof n=="string"?t.isValid(n).valid?n:new TextEncoder().encode(n):n;export{o as a};
2
- //# sourceMappingURL=chunk-KIW54KWR.mjs.map
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-QQIVWB6G.mjs";import{a as i}from"./chunk-6Q2O5G3J.mjs";import{bytesToHex as o,hexToBytes as l}from"@noble/hashes/utils";var g=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s))(g||{}),r=class r extends a{constructor(t){if(super(),t.length!==r.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=o(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return o(this.data)}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){let e=this.bcsToBytes();t.serializeBytes(e)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r(e)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let e=r.fromString(t);if(t.length!==r.LONG_STRING_LENGTH+2)if(e.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return e}static fromString(t){let e=t;if(t.startsWith("0x")&&(e=t.slice(2)),e.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(e.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let n;try{n=l(e.padStart(64,"0"))}catch(c){throw new i(`Hex characters are invalid: ${c?.message}`,"invalid_hex_chars")}return new r(n)}static from(t){return typeof t=="string"?r.fromString(t):t instanceof Uint8Array?new r(t):t}static fromStrict(t){return typeof t=="string"?r.fromStringStrict(t):t instanceof Uint8Array?new r(t):t}static isValid(t){try{return t.strict?r.fromStrict(t.input):r.from(t.input),{valid:!0}}catch(e){return{valid:!1,invalidReason:e?.invalidReason,invalidReasonMessage:e?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,n)=>e===t.data[n])}};r.LENGTH=32,r.LONG_STRING_LENGTH=64,r.ZERO=r.from("0x0"),r.ONE=r.from("0x1"),r.TWO=r.from("0x2"),r.THREE=r.from("0x3"),r.FOUR=r.from("0x4"),r.A=r.from("0xA");var d=r;export{g as a,d as b};
2
- //# sourceMappingURL=chunk-KM6UXNC7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/accountAddress.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\n\n/**\n * Provides reasons for an address was invalid.\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @note This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString` is only provided for backwards compatibility.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT is 1 to 63 hex characters inclusive.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input - A hex string representing an account address.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n */\n static fromString(input: string): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n return new AccountAddress(addressBytes);\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n */\n static from(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"],"mappings":"6EAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBAUhC,IAAKC,OACVA,EAAA,0BAA4B,4BAC5BA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,wBAA0B,0BAC1BA,EAAA,kCAAoC,oCACpCA,EAAA,uBAAyB,yBAPfA,OAAA,IA+BCC,EAAN,MAAMA,UAAuBC,CAA4C,CAoC9E,YAAYC,EAAmB,CAE7B,GADA,MAAM,EACFA,EAAM,SAAWF,EAAe,OAClC,MAAM,IAAIG,EACR,sDACA,2BACF,EAEF,KAAK,KAAOD,CACd,CAYA,WAAqB,CACnB,OACE,KAAK,KAAK,MAAM,EAAG,KAAK,KAAK,OAAS,CAAC,EAAE,MAAOE,GAASA,IAAS,CAAC,GAAK,KAAK,KAAK,KAAK,KAAK,OAAS,CAAC,EAAI,EAE9G,CAaA,UAA0B,CACxB,MAA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ANpB","names":["bytesToHex","hexToBytes","AddressInvalidReason","_AccountAddress","Serializable","input","ParsingError","byte","hex","bytesToHex","serializer","bcsBytes","deserializer","bytes","address","parsedInput","addressBytes","hexToBytes","error","args","other","value","index","AccountAddress"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-KUX6GQ2E.mjs.map
@@ -1,2 +0,0 @@
1
- import{decode as c}from"js-base64";async function m(e){return new Promise(n=>{setTimeout(n,e)})}var u=()=>Math.floor(Date.now()/1e3);function i(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function l(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return c(t)}var g=(e,n)=>e*10**n,p=(e,n)=>e/10**n,r=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},_=e=>{let{account_address:n,module_name:t,struct_name:o}=e,s=r(t),a=r(o);return`${n}::${s}::${a}`},f=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";export{m as a,u as b,i as c,l as d,g as e,p as f,_ as g,f as h};
2
- //# sourceMappingURL=chunk-LEKBJ2EG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/helpers.ts"],"sourcesContent":["// 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\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"],"mappings":"AAGA,OAAS,UAAAA,MAAc,YASvB,eAAsBC,EAAMC,EAA+B,CACzD,OAAO,IAAI,QAASC,GAAY,CAC9B,WAAWA,EAASD,CAAM,CAC5B,CAAC,CACH,CAEO,IAAME,EAAe,IAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAQvD,SAASC,EAAiBC,EAAoC,CACnE,IAAMC,EAAO,IAAI,KAAKD,EAAqB,GAAI,EAE/C,OAAAC,EAAK,WAAW,CAAC,EACjBA,EAAK,WAAW,CAAC,EACjBA,EAAK,gBAAgB,CAAC,EACf,KAAK,MAAMA,EAAK,QAAQ,EAAI,GAAI,CACzC,CASO,SAASC,EAAgBC,EAA2B,CAEzD,IAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAEvDE,EAAeD,EAAS,KAAK,UAAU,GAAI,EAAKA,EAAO,OAAS,GAAM,CAAC,EAE7E,OADsBV,EAAOW,CAAY,CAE3C,CAaO,IAAMC,EAA0C,CAACC,EAAeC,IAAoBD,EAAQ,IAAMC,EAa5FC,EAA0C,CAACF,EAAeC,IAAoBD,EAAQ,IAAMC,EAUnGE,EAAcC,GAAgB,CAClC,IAAIC,EAAM,GACV,QAASC,EAAI,EAAGA,EAAIF,EAAI,OAAQE,GAAK,EACnCD,GAAO,OAAO,aAAa,SAASD,EAAI,UAAUE,EAAGA,EAAI,CAAC,EAAG,EAAE,CAAC,EAElE,OAAOD,CACT,EAiBaE,EAAsBC,GAIf,CAElB,GAAM,CAAE,gBAAAC,EAAiB,YAAAC,EAAa,YAAAC,CAAY,EAAIH,EAChDI,EAAaT,EAAWO,CAAW,EACnCG,EAAaV,EAAWQ,CAAW,EACzC,MAAO,GAAGF,CAAe,KAAKG,CAAU,KAAKC,CAAU,EACzD,EAWaC,EACXN,GAMA,OAAOA,GAAc,UACrB,CAAC,MAAM,QAAQA,CAAS,GACxBA,IAAc,MACd,oBAAqBA,GACrB,gBAAiBA,GACjB,gBAAiBA,GACjB,OAAOA,EAAU,iBAAoB,UACrC,OAAOA,EAAU,aAAgB,UACjC,OAAOA,EAAU,aAAgB","names":["decode","sleep","timeMs","resolve","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName","isEncodedStruct"]}
@@ -1,2 +0,0 @@
1
- import{a as y}from"./chunk-CDQGPCHU.mjs";import{a as u}from"./chunk-WV2VJQDS.mjs";import{i as c,n as d}from"./chunk-FTZGP6XW.mjs";import{a as p}from"./chunk-N47FTRYO.mjs";import{jwtDecode as h}from"jwt-decode";var f=class i extends y{constructor(e){let r=c.create(e);super({publicKey:r,...e}),this.publicKey=r}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),s=e.deserializeStr(),o=e.deserializeFixedBytes(31),a=u.deserialize(e),n=d.deserialize(e);return i.create({proof:n,pepper:o,uidKey:s,jwt:r,ephemeralKeyPair:a})}static fromBytes(e){return i.deserialize(new p(e))}static create(e){let{address:r,proof:s,jwt:o,ephemeralKeyPair:a,pepper:n,uidKey:l="sub",proofFetchCallback:K}=e,t=h(o);if(typeof t.iss!="string")throw new Error("iss was not found");if(typeof t.aud!="string")throw new Error("aud was not found or an array of values");let m=t[l];return new i({address:r,proof:s,ephemeralKeyPair:a,iss:t.iss,uidKey:l,uidVal:m,aud:t.aud,pepper:n,jwt:o,proofFetchCallback:K})}};export{f as a};
2
- //# sourceMappingURL=chunk-M22UGFQ5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { HexInput } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { KeylessPublicKey, ZeroKnowledgeSig } from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { AbstractKeylessAccount, ProofFetchCallback } from \"./AbstractKeylessAccount\";\n\n/**\n * Account implementation for the Keyless authentication scheme.\n *\n * Used to represent a Keyless based account and sign transactions with it.\n *\n * Use `KeylessAccount.create()` to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n *\n * @static\n * @readonly PEPPER_LENGTH - The length of the pepper used for privacy preservation.\n */\nexport class KeylessAccount extends AbstractKeylessAccount {\n /**\n * The KeylessPublicKey associated with the account\n */\n readonly publicKey: KeylessPublicKey;\n\n // Use the static constructor 'create' instead.\n\n /**\n * Creates an instance of the transaction with an optional proof.\n *\n * @param args.proof - An optional ZkProof associated with the transaction.\n */\n // TODO: Document rest of parameters\n private constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n const publicKey = KeylessPublicKey.create(args);\n super({ publicKey, ...args });\n this.publicKey = publicKey;\n }\n\n /**\n * Serializes the transaction data into a format suitable for transmission or storage.\n * This function ensures that both the transaction bytes and the proof are properly serialized.\n *\n * @param serializer - The serializer instance used to convert the transaction data into bytes.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n if (this.proof === undefined) {\n throw new Error(\"Cannot serialize - proof undefined\");\n }\n this.proof.serialize(serializer);\n }\n\n /**\n * Deserializes the provided deserializer to create a KeylessAccount instance.\n * This function extracts necessary components such as the JWT, UID key, pepper, ephemeral key pair, and proof from the deserializer.\n *\n * @param deserializer - The deserializer instance used to retrieve the serialized data.\n * @returns A KeylessAccount instance created from the deserialized data.\n */\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return KeylessAccount.create({\n proof,\n pepper,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n static fromBytes(bytes: Uint8Array): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n /**\n * Creates a KeylessAccount instance using the provided parameters.\n * This function allows you to set up a KeylessAccount with specific attributes such as address, proof, and JWT.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.pepper - A hexadecimal input used for additional security.\n * @param args.uidKey - Optional key for user identification, defaults to \"sub\".\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n */\n static create(args: {\n address?: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): KeylessAccount {\n const { address, proof, jwt, ephemeralKeyPair, pepper, uidKey = \"sub\", proofFetchCallback } = args;\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n if (typeof jwtPayload.iss !== \"string\") {\n throw new Error(\"iss was not found\");\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const uidVal = jwtPayload[uidKey];\n return new KeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss: jwtPayload.iss,\n uidKey,\n uidVal,\n aud: jwtPayload.aud,\n pepper,\n jwt,\n proofFetchCallback,\n });\n }\n}\n"],"mappings":"2KAGA,OAAqB,aAAAA,MAAiB,aAsB/B,IAAMC,EAAN,MAAMC,UAAuBC,CAAuB,CAcjD,YAAYC,EAWjB,CACD,IAAMC,EAAYC,EAAiB,OAAOF,CAAI,EAC9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,CACH,CACF","names":["jwtDecode","KeylessAccount","_KeylessAccount","AbstractKeylessAccount","args","publicKey","KeylessPublicKey","serializer","deserializer","jwt","uidKey","pepper","ephemeralKeyPair","EphemeralKeyPair","proof","ZeroKnowledgeSig","bytes","Deserializer","address","proofFetchCallback","jwtPayload","jwtDecode","uidVal"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-N2FKVZ4D.mjs.map
@@ -1,2 +0,0 @@
1
- import{c as r}from"./chunk-56CNRT2K.mjs";var n=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let i=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,i}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeBool()?this.deserializeStr():void 0}deserializeOption(e){return this.deserializeBool()?this.deserialize(e):void 0}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),i=this.deserializeU32();return BigInt(BigInt(i)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),i=this.deserializeU64();return BigInt(i<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),i=this.deserializeU128();return BigInt(i<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),i=0;for(;e<r;){let t=this.deserializeU8();if(e|=BigInt(t&127)<<BigInt(i),!(t&128))break;i+=7}if(e>r)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let i=this.deserializeUleb128AsU32(),t=new Array;for(let s=0;s<i;s+=1)t.push(this.deserialize(e));return t}};export{n as a};
2
- //# sourceMappingURL=chunk-N47FTRYO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bcs/deserializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from \"../types\";\n\n/**\n * This interface exists to define Deserializable<T> inputs for functions that\n * deserialize a byte buffer into a type T.\n * It is not intended to be implemented or extended, because Typescript has no support\n * for static methods in interfaces.\n *\n * @template T - The type that this will deserialize into.\n */\nexport interface Deserializable<T> {\n /**\n * Deserializes the buffered bytes into an instance of the specified class type.\n * This function provides an alternative syntax for deserialization, allowing users to call\n * `deserializer.deserialize(MyClass)` instead of `MyClass.deserialize(deserializer)`.\n *\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @returns The deserialized value of class type T.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * ```\n */\n deserialize(deserializer: Deserializer): T;\n}\n\n/**\n * A class that provides methods for deserializing various data types from a byte buffer.\n * It supports deserialization of primitive types, strings, and complex objects using a BCS (Binary Common Serialization) layout.\n */\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Creates a new instance of the class with a copy of the provided data buffer.\n * This prevents outside mutation of the buffer.\n *\n * @param data - The data to be copied into the internal buffer as a Uint8Array.\n */\n constructor(data: Uint8Array) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n /**\n * Reads a specified number of bytes from the buffer and advances the offset.\n *\n * @param length - The number of bytes to read from the buffer.\n * @throws Throws an error if the read operation exceeds the buffer's length.\n */\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Returns the number of bytes remaining in the buffer.\n *\n * This information is useful to determine if there's more data to be read.\n *\n * @returns The number of bytes remaining in the buffer.\n */\n remaining(): number {\n return this.buffer.byteLength - this.offset;\n }\n\n /**\n * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,\n * followed by the actual byte content, and decodes it into a string.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * Deserializes an optional string.\n *\n * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.\n * @returns The deserialized string if it exists, otherwise undefined.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00]));\n * assert(deserializer.deserializeOptionStr() === undefined);\n * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeOptionStr() === \"1234abcd\");\n * ```\n */\n deserializeOptionStr(): string | undefined {\n const exists = this.deserializeBool();\n return exists ? this.deserializeStr() : undefined;\n }\n\n /**\n * Deserializes an optional deserializable class.\n *\n * BCS layout for Optional<T>: 0 if none, else 1 | BCS representation of class.\n *\n * @example\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n *\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is undefined\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns The deserialized value of class type T or undefined if no value exists.\n */\n deserializeOption<T>(cls: Deserializable<T>): T | undefined {\n const exists = this.deserializeBool();\n return exists ? this.deserialize(cls) : undefined;\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * The BCS layout for \"bytes\" consists of a bytes_length followed by the bytes themselves, where bytes_length is a u32 integer\n * encoded as a uleb128 integer, indicating the length of the bytes array.\n *\n * @returns {Uint8Array} The deserialized array of bytes.\n */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes of a specified length.\n *\n * @param len - The number of bytes to read from the source.\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value from a byte stream.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n * An error is thrown if the byte value is not valid.\n *\n * @returns The deserialized boolean value.\n * @throws Throws an error if the boolean value is invalid.\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number from the binary data.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @returns {number} The deserialized uint8 number.\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint16\": Two bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint32\": Four bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * This function combines two 32-bit values to return a 64-bit unsigned integer in little-endian representation.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number from its binary representation.\n * This function combines two 64-bit values to return a single uint128 value in little-endian format.\n *\n * @returns {BigInt} The deserialized uint128 number.\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number from its binary representation.\n *\n * The BCS layout for \"uint256\" consists of thirty-two bytes in little-endian format.\n *\n * @returns {BigInt} The deserialized uint256 number.\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * This function is used for interpreting lengths of variable-length sequences and tags of enum values in BCS encoding.\n *\n * @throws {Error} Throws an error if the parsed value exceeds the maximum uint32 number.\n * @returns {number} The deserialized uint32 value.\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n\n /**\n * Helper function that primarily exists to support alternative syntax for deserialization.\n * That is, if we have a `const deserializer: new Deserializer(...)`, instead of having to use\n * `MyClass.deserialize(deserializer)`, we can call `deserializer.deserialize(MyClass)`.\n *\n * @example const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n */\n deserialize<T>(cls: Deserializable<T>): T {\n // NOTE: `deserialize` in `cls.deserialize(this)` here is a static method defined in `cls`,\n // It is separate from the `deserialize` instance method defined here in Deserializer.\n return cls.deserialize(this);\n }\n\n /**\n * Deserializes an array of BCS Deserializable values given an existing Deserializer instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n * @returns An array of deserialized values of type T.\n * @example\n * // serialize a vector of addresses\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n *\n * // deserialize the bytes into an array of addresses\n * const deserializer = new Deserializer(serializedBytes);\n * const deserializedAddresses = deserializer.deserializeVector(AccountAddress);\n * // deserializedAddresses is now an array of AccountAddress instances\n */\n deserializeVector<T>(cls: Deserializable<T>): Array<T> {\n const length = this.deserializeUleb128AsU32();\n const vector = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n vector.push(this.deserialize(cls));\n }\n return vector;\n }\n}\n"],"mappings":"yCAsCO,IAAMA,EAAN,KAAmB,CAWxB,YAAYC,EAAkB,CAE5B,KAAK,OAAS,IAAI,YAAYA,EAAK,MAAM,EACzC,IAAI,WAAW,KAAK,MAAM,EAAE,IAAIA,EAAM,CAAC,EACvC,KAAK,OAAS,CAChB,CAQQ,KAAKC,EAA6B,CACxC,GAAI,KAAK,OAASA,EAAS,KAAK,OAAO,WACrC,MAAM,IAAI,MAAM,8BAA8B,EAGhD,IAAMC,EAAQ,KAAK,OAAO,MAAM,KAAK,OAAQ,KAAK,OAASD,CAAM,EACjE,YAAK,QAAUA,EACRC,CACT,CASA,WAAoB,CAClB,OAAO,KAAK,OAAO,WAAa,KAAK,MACvC,CAeA,gBAAyB,CACvB,IAAMC,EAAQ,KAAK,iBAAiB,EAEpC,OADoB,IAAI,YAAY,EACjB,OAAOA,CAAK,CACjC,CAeA,sBAA2C,CAEzC,OADe,KAAK,gBAAgB,EACpB,KAAK,eAAe,EAAI,MAC1C,CAoBA,kBAAqBC,EAAuC,CAE1D,OADe,KAAK,gBAAgB,EACpB,KAAK,YAAYA,CAAG,EAAI,MAC1C,CAUA,kBAA+B,CAC7B,IAAMC,EAAM,KAAK,wBAAwB,EACzC,OAAO,IAAI,WAAW,KAAK,KAAKA,CAAG,CAAC,CACtC,CAOA,sBAAsBA,EAAyB,CAC7C,OAAO,IAAI,WAAW,KAAK,KAAKA,CAAG,CAAC,CACtC,CAWA,iBAA2B,CACzB,IAAMC,EAAO,IAAI,WAAW,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAC3C,GAAIA,IAAS,GAAKA,IAAS,EACzB,MAAM,IAAI,MAAM,uBAAuB,EAEzC,OAAOA,IAAS,CAClB,CASA,eAAuB,CACrB,OAAO,IAAI,SAAS,KAAK,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAC9C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","byte","vector","i"]}
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-QQIVWB6G.mjs";var e=class extends a{};export{e as a};
2
- //# sourceMappingURL=chunk-ONBFUPEC.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as b}from"./chunk-IBLZ6MZU.mjs";import{a as g}from"./chunk-KIW54KWR.mjs";import{b as S}from"./chunk-4OV7QU2U.mjs";import{d as K,f as A,g as v,h as E,i as H,j as P}from"./chunk-PHP47DI4.mjs";import{a as p}from"./chunk-PRZ7AIGA.mjs";import{a as f}from"./chunk-QQIVWB6G.mjs";import{b as s}from"./chunk-KFNDDPOW.mjs";import{ed25519 as y}from"@noble/curves/ed25519";var d=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function w(z){let e=z.toUint8Array().slice(32);for(let t=d.length-1;t>=0;t-=1){if(e[t]<d[t])return!0;if(e[t]>d[t])return!1}return!1}var i=class i extends S{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==i.LENGTH)throw new Error(`PublicKey length should be ${i.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!w(n))return!1;let o=g(t),c=s.fromHexInput(o).toUint8Array(),u=n.toUint8Array(),l=this.key.toUint8Array();return y.verify(u,c,l)}authKey(){return p.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new i(t)}static isPublicKey(e){return e instanceof i}static isInstance(e){return"key"in e&&e.key?.data?.length===i.LENGTH}};i.LENGTH=32;var m=i,r=class r extends f{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==r.LENGTH)throw new Error(`PrivateKey length should be ${r.LENGTH}`);this.signingKey=t}static generate(){let e=y.utils.randomPrivateKey();return new r(e)}static fromDerivationPath(e,t){if(!A(e))throw new Error(`Invalid derivation path ${e}`);return r.fromDerivationPathInner(e,P(t))}static fromDerivationPathInner(e,t,n=K){let{key:o,chainCode:c}=v(r.SLIP_0010_SEED,t),u=H(e).map(x=>parseInt(x,10)),{key:l}=u.reduce((x,I)=>E(x,I+n),{key:o,chainCode:c});return new r(l)}publicKey(){let e=y.getPublicKey(this.signingKey.toUint8Array());return new m(e)}sign(e){let t=g(e),n=s.fromHexInput(t).toUint8Array(),o=y.sign(n,this.signingKey.toUint8Array());return new h(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new r(t)}static isPrivateKey(e){return e instanceof r}};r.LENGTH=32,r.SLIP_0010_SEED="ed25519 seed";var U=r,a=class a extends b{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new a(t)}};a.LENGTH=64;var h=a;export{w as a,m as b,U as c,h as d};
2
- //# sourceMappingURL=chunk-P3J54CQG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/ed25519.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ed25519 } from \"@noble/curves/ed25519\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializable, Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { HexInput, SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from \"./hdKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { convertSigningMessage } from \"./utils\";\n\n/**\n * L is the value that greater than or equal to will produce a non-canonical signature, and must be rejected\n */\nconst L: number[] = [\n 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\n];\n\n/**\n * Checks if an ED25519 signature is non-canonical.\n * This function helps determine the validity of a signature by verifying its canonical form.\n *\n * @param signature - The signature to be checked for canonicality.\n * @returns A boolean indicating whether the signature is non-canonical.\n *\n * Comes from Aptos Core\n * https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-crypto/src/ed25519/ed25519_sigs.rs#L47-L85\n */\nexport function isCanonicalEd25519Signature(signature: Signature): boolean {\n const s = signature.toUint8Array().slice(32);\n for (let i = L.length - 1; i >= 0; i -= 1) {\n if (s[i] < L[i]) {\n return true;\n }\n if (s[i] > L[i]) {\n return false;\n }\n }\n // As this stage S == L which implies a non-canonical S.\n return false;\n}\n\n/**\n * Represents the public key of an Ed25519 key pair.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also\n * as `AnyPublicKey` that represents any `Unified authentication key`.\n */\nexport class Ed25519PublicKey extends AccountPublicKey {\n /**\n * Length of an Ed25519 public key\n */\n static readonly LENGTH: number = 32;\n\n /**\n * Bytes of the public key\n * @private\n */\n private readonly key: Hex;\n\n /**\n * Creates an instance of the Ed25519Signature class from a hex input.\n * This constructor validates the length of the signature to ensure it meets the required specifications.\n *\n * @param hexInput - The hex input representing the Ed25519 signature.\n * @throws Error if the signature length is not equal to Ed25519Signature.LENGTH.\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n if (hex.toUint8Array().length !== Ed25519PublicKey.LENGTH) {\n throw new Error(`PublicKey length should be ${Ed25519PublicKey.LENGTH}`);\n }\n this.key = hex;\n }\n\n // region AccountPublicKey\n\n /**\n * Verifies a signed message using a public key.\n *\n * @param args - The arguments for verification.\n * @param args.message - A signed message as a Hex string or Uint8Array.\n * @param args.signature - The signature of the message.\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n const { message, signature } = args;\n // Verify malleability\n if (!isCanonicalEd25519Signature(signature)) {\n return false;\n }\n\n const messageToVerify = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();\n const signatureBytes = signature.toUint8Array();\n const publicKeyBytes = this.key.toUint8Array();\n return ed25519.verify(signatureBytes, messageBytes, publicKeyBytes);\n }\n\n /**\n * Generates an authentication key from the public key using the Ed25519 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.Ed25519,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * @returns Uint8Array representation of the data.\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This allows for the conversion of data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserialize bytes into an Ed25519Signature object.\n * This function is used to convert serialized byte data into a usable Ed25519Signature instance.\n *\n * @param deserializer - The deserializer instance used to read the byte data.\n */\n static deserialize(deserializer: Deserializer): Ed25519PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PublicKey(bytes);\n }\n\n // endregion\n\n /**\n * Determine if the provided public key is an instance of Ed25519PublicKey.\n *\n * @param publicKey - The public key to check.\n * @returns True if the public key is an instance of Ed25519PublicKey, otherwise false.\n * @deprecated use `instanceof Ed25519PublicKey` instead.\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey {\n return publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * Determines if the provided public key is a valid Ed25519 public key.\n * This function checks for the presence of the \"key\" property and verifies that its data length matches the expected length\n * for Ed25519 public keys.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Ed25519 public key.\n */\n static isInstance(publicKey: PublicKey): publicKey is Ed25519PublicKey {\n return \"key\" in publicKey && (publicKey.key as any)?.data?.length === Ed25519PublicKey.LENGTH;\n }\n}\n\n/**\n * Represents the private key of an Ed25519 key pair.\n *\n * @static\n * @readonly LENGTH - Length of an Ed25519 private key.\n * @static\n * @readonly SLIP_0010_SEED - The Ed25519 key seed to use for BIP-32 compatibility.\n */\nexport class Ed25519PrivateKey extends Serializable implements PrivateKey {\n /**\n * Length of an Ed25519 private key\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The Ed25519 key seed to use for BIP-32 compatibility\n * See more {@link https://github.com/satoshilabs/slips/blob/master/slip-0010.md}\n */\n static readonly SLIP_0010_SEED = \"ed25519 seed\";\n\n /**\n * The Ed25519 signing key\n * @private\n */\n private readonly signingKey: Hex;\n\n // region Constructors\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * @param hexInput HexInput (string or Uint8Array)\n */\n constructor(hexInput: HexInput) {\n super();\n\n const privateKeyHex = Hex.fromHexInput(hexInput);\n if (privateKeyHex.toUint8Array().length !== Ed25519PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Ed25519PrivateKey.LENGTH}`);\n }\n\n // Create keyPair from Private key in Uint8Array format\n this.signingKey = privateKeyHex;\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Ed25519PrivateKey A newly generated Ed25519 private key.\n */\n static generate(): Ed25519PrivateKey {\n const keyPair = ed25519.utils.randomPrivateKey();\n return new Ed25519PrivateKey(keyPair);\n }\n\n /**\n * Derives a private key from a mnemonic seed phrase using a specified BIP44 path.\n * To derive multiple keys from the same phrase, change the path\n *\n * IMPORTANT: Ed25519 supports hardened derivation only, as it lacks a key homomorphism, making non-hardened derivation impossible.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param mnemonics - The mnemonic seed phrase from which the key will be derived.\n * @throws Error if the provided path is not a valid hardened path.\n */\n static fromDerivationPath(path: string, mnemonics: string): Ed25519PrivateKey {\n if (!isValidHardenedPath(path)) {\n throw new Error(`Invalid derivation path ${path}`);\n }\n return Ed25519PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));\n }\n\n /**\n * Derives a child private key from a given BIP44 path and seed.\n * A private inner function so we can separate from the main fromDerivationPath() method\n * to add tests to verify we create the keys correctly.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param seed - The seed phrase created by the mnemonics, represented as a Uint8Array.\n * @param offset - The offset used for key derivation, defaults to HARDENED_OFFSET.\n * @returns An instance of Ed25519PrivateKey derived from the specified path and seed.\n */\n private static fromDerivationPathInner(path: string, seed: Uint8Array, offset = HARDENED_OFFSET): Ed25519PrivateKey {\n const { key, chainCode } = deriveKey(Ed25519PrivateKey.SLIP_0010_SEED, seed);\n\n const segments = splitPath(path).map((el) => parseInt(el, 10));\n\n // Derive the child key based on the path\n const { key: privateKey } = segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + offset), {\n key,\n chainCode,\n });\n return new Ed25519PrivateKey(privateKey);\n }\n\n // endregion\n\n // region PrivateKey\n\n /**\n * Derive the Ed25519PublicKey for this private key.\n *\n * @returns Ed25519PublicKey - The derived public key corresponding to the private key.\n */\n publicKey(): Ed25519PublicKey {\n const bytes = ed25519.getPublicKey(this.signingKey.toUint8Array());\n return new Ed25519PublicKey(bytes);\n }\n\n /**\n * Sign the given message with the private key.\n * This function generates a digital signature for the specified message, ensuring its authenticity and integrity.\n *\n * @param message - A message as a string or Uint8Array in HexInput format.\n * @returns A digital signature for the provided message.\n */\n sign(message: HexInput): Ed25519Signature {\n const messageToSign = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToSign).toUint8Array();\n const signatureBytes = ed25519.sign(messageBytes, this.signingKey.toUint8Array());\n return new Ed25519Signature(signatureBytes);\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the private key\n */\n toUint8Array(): Uint8Array {\n return this.signingKey.toUint8Array();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toString(): string {\n return this.signingKey.toString();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PrivateKey(bytes);\n }\n\n // endregion\n\n /**\n * Determines if the provided private key is an instance of Ed25519PrivateKey.\n *\n * @param privateKey - The private key to check.\n * @returns A boolean indicating whether the private key is an Ed25519PrivateKey.\n *\n * @deprecated Use `instanceof Ed25519PrivateKey` instead.\n */\n static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {\n return privateKey instanceof Ed25519PrivateKey;\n }\n}\n\n/**\n * Represents a signature of a message signed using an Ed25519 private key.\n *\n * @static LENGTH - Length of an Ed25519 signature, which is 64 bytes.\n */\nexport class Ed25519Signature extends Signature {\n /**\n * Length of an Ed25519 signature\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n */\n private readonly data: Hex;\n\n // region Constructors\n\n constructor(hexInput: HexInput) {\n super();\n const data = Hex.fromHexInput(hexInput);\n if (data.toUint8Array().length !== Ed25519Signature.LENGTH) {\n throw new Error(`Signature length should be ${Ed25519Signature.LENGTH}`);\n }\n this.data = data;\n }\n\n // endregion\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519Signature {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519Signature(bytes);\n }\n\n // endregion\n}\n"],"mappings":"kUAGA,OAAS,WAAAA,MAAe,wBAexB,IAAMC,EAAc,CAClB,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,EAAM,EAAM,EAC5G,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAC1E,EAYO,SAASC,EAA4BC,EAA+B,CACzE,IAAMC,EAAID,EAAU,aAAa,EAAE,MAAM,EAAE,EAC3C,QAASE,EAAIJ,EAAE,OAAS,EAAGI,GAAK,EAAGA,GAAK,EAAG,CACzC,GAAID,EAAEC,CAAC,EAAIJ,EAAEI,CAAC,EACZ,MAAO,GAET,GAAID,EAAEC,CAAC,EAAIJ,EAAEI,CAAC,EACZ,MAAO,EAEX,CAEA,MAAO,EACT,CAWO,IAAMC,EAAN,MAAMA,UAAyBC,CAAiB,CAmBrD,YAAYC,EAAoB,CAC9B,MAAM,EAEN,IAAMC,EAAMC,EAAI,aAAaF,CAAQ,EACrC,GAAIC,EAAI,aAAa,EAAE,SAAWH,EAAiB,OACjD,MAAM,IAAI,MAAM,8BAA8BA,EAAiB,MAAM,EAAE,EAEzE,KAAK,IAAMG,CACb,CAWA,gBAAgBE,EAAoC,CAClD,GAAM,CAAE,QAAAC,EAAS,UAAAT,CAAU,EAAIQ,EAE/B,GAAI,CAACT,EAA4BC,CAAS,EACxC,MAAO,GAGT,IAAMU,EAAkBC,EAAsBF,CAAO,EAC/CG,EAAeL,EAAI,aAAaG,CAAe,EAAE,aAAa,EAC9DG,EAAiBb,EAAU,aAAa,EACxCc,EAAiB,KAAK,IAAI,aAAa,EAC7C,OAAOC,EAAQ,OAAOF,EAAg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CAMA,UAAU/B,EAA8B,CACtCA,EAAW,eAAe,KAAK,KAAK,aAAa,CAAC,CACpD,CAEA,OAAO,YAAYC,EAA8C,CAC/D,IAAMC,EAAQD,EAAa,iBAAiB,EAC5C,OAAO,IAAI4B,EAAiB3B,CAAK,CACnC,CAGF,EA7Ca2B,EAIK,OAAS,GAJpB,IAAMF,EAANE","names":["ed25519","L","isCanonicalEd25519Signature","signature","s","i","_Ed25519PublicKey","AccountPublicKey","hexInput","hex","Hex","args","message","messageToVerify","convertSigningMessage","messageBytes","signatureBytes","publicKeyBytes","ed25519","AuthenticationKey","serializer","deserializer","bytes","publicKey","Ed25519PublicKey","_Ed25519PrivateKey","Serializable","privateKeyHex","keyPair","path","mnemonics","isValidHardenedPath","mnemonicToSeed","seed","offset","HARDENED_OFFSET","key","chainCode","deriveKey","segments","splitPath","el","privateKey","parentKeys","segment","CKDPriv","messageToSign","Ed25519Signature","Ed25519PrivateKey","_Ed25519Signature","Signature","data"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/get.ts"],"sourcesContent":["import { AptosConfig } from \"../api/aptosConfig\";\nimport { aptosRequest } from \"./core\";\nimport { AptosResponse } from \"./types\";\nimport { AnyNumber, ClientConfig, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Options for making a GET request, including configuration for the API client.\n */\nexport type GetRequestOptions = {\n /**\n * The config for the API client\n */\n aptosConfig: AptosConfig;\n /**\n * The type of API endpoint to call e.g. fullnode, indexer, etc\n */\n type: AptosApiType;\n /**\n * The name of the API method\n */\n originMethod: string;\n /**\n * The URL path to the API method\n */\n path: string;\n /**\n * The content type of the request body\n */\n contentType?: MimeType;\n /**\n * The accepted content type of the response of the API\n */\n acceptType?: MimeType;\n /**\n * The query parameters for the request\n */\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n /**\n * Specific client overrides for this request to override aptosConfig\n */\n overrides?: ClientConfig;\n};\n\n/**\n * Options for making a request to the Aptos API, excluding the \"type\" field.\n */\nexport type GetAptosRequestOptions = Omit<GetRequestOptions, \"type\">;\n\n/**\n * Executes a GET request to retrieve data based on the provided options.\n *\n * @param options - The options for the GET request.\n * @param options.aptosConfig - The configuration object for Aptos requests.\n * @param options.overrides - Optional overrides for the request configuration.\n * @param options.params - Query parameters to include in the request.\n * @param options.contentType - The content type of the request.\n * @param options.acceptType - The accepted response type.\n * @param options.path - The specific path for the request.\n * @param options.originMethod - The original method of the request.\n * @param options.type - The type of request being made.\n * @returns The response from the GET request.\n */\nexport async function get<Req extends {}, Res extends {}>(\n options: GetRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig, overrides, params, contentType, acceptType, path, originMethod, type } = options;\n const url = aptosConfig.getRequestUrl(type);\n\n return aptosRequest<Req, Res>(\n {\n url,\n method: \"GET\",\n originMethod,\n path,\n contentType,\n acceptType,\n params,\n overrides: {\n ...aptosConfig.clientConfig,\n ...overrides,\n },\n },\n aptosConfig,\n options.type,\n );\n}\n\n/**\n * Retrieves data from the Aptos full node using the provided options.\n *\n * @param options - The options for the request to the Aptos full node.\n * @param options.aptosConfig - Configuration settings specific to the Aptos client and full node.\n * @param options.aptosConfig.clientConfig - The client configuration settings.\n * @param options.aptosConfig.fullnodeConfig - The full node configuration settings.\n * @param options.overrides - Additional overrides for the request.\n * @param options.type - The type of API request being made.\n *\n * @returns A promise that resolves with the response from the Aptos full node.\n */\nexport async function getAptosFullNode<Req extends {}, Res extends {}>(\n options: GetAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return get<Req, Res>({\n ...options,\n type: AptosApiType.FULLNODE,\n overrides: {\n ...aptosConfig.clientConfig,\n ...aptosConfig.fullnodeConfig,\n ...options.overrides,\n HEADERS: { ...aptosConfig.clientConfig?.HEADERS, ...aptosConfig.fullnodeConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Makes a GET request to the Aptos Pepper service to retrieve data.\n *\n * @param options - The options for the request.\n * @param options.param1 - Description of param1.\n * @param options.param2 - Description of param2.\n * @returns AptosResponse - The response from the Aptos Pepper service.\n */\nexport async function getAptosPepperService<Req extends {}, Res extends {}>(\n options: GetAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n return get<Req, Res>({ ...options, type: AptosApiType.PEPPER });\n}\n\n/// This function is a helper for paginating using a function wrapping an API\nexport async function paginateWithCursor<Req extends Record<string, any>, Res extends Array<{}>>(\n options: GetAptosRequestOptions,\n): Promise<Res> {\n const out: any[] = [];\n let cursor: string | undefined;\n const requestParams = options.params as { start?: string; limit?: number };\n do {\n // eslint-disable-next-line no-await-in-loop\n const response = await get<Req, Res>({\n type: AptosApiType.FULLNODE,\n aptosConfig: options.aptosConfig,\n originMethod: options.originMethod,\n path: options.path,\n params: requestParams,\n overrides: options.overrides,\n });\n /**\n * the cursor is a \"state key\" from the API perspective. Client\n * should not need to \"care\" what it represents but just use it\n * to query the next chunk of data.\n */\n cursor = response.headers[\"x-aptos-cursor\"];\n // Now that we have the cursor (if any), we remove the headers before\n // adding these to the output of this function.\n delete response.headers;\n out.push(...response.data);\n requestParams.start = cursor;\n } while (cursor !== null && cursor !== undefined);\n return out as Res;\n}\n"],"mappings":"yCA+DA,eAAsBA,EACpBC,EACkC,CAClC,GAAM,CAAE,YAAAC,EAAa,UAAAC,EAAW,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,EAAY,KAAAC,EAAM,aAAAC,EAAc,KAAAC,CAAK,EAAIR,EACxFS,EAAMR,EAAY,cAAcO,CAAI,EAE1C,OAAOE,EACL,CACE,IAAAD,EACA,OAAQ,MACR,aAAAF,EACA,KAAAD,EACA,YAAAF,EACA,WAAAC,EACA,OAAAF,EACA,UAAW,CACT,GAAGF,EAAY,aACf,GAAGC,CACL,CACF,EACAD,EACAD,EAAQ,IACV,CACF,CAcA,eAAsBW,EACpBX,EACkC,CAClC,GAAM,CAAE,YAAAC,CAAY,EAAID,EAExB,OAAOD,EAAc,CACnB,GAAGC,EACH,gBACA,UAAW,CACT,GAAGC,EAAY,aACf,GAAGA,EAAY,eACf,GAAGD,EAAQ,UACX,QAAS,CAAE,GAAGC,EAAY,cAAc,QAAS,GAAGA,EAAY,gBAAgB,OAAQ,CAC1F,CACF,CAAC,CACH,CAUA,eAAsBW,EACpBZ,EACkC,CAClC,OAAOD,EAAc,CAAE,GAAGC,EAAS,aAA0B,CAAC,CAChE,CAGA,eAAsBa,EACpBb,EACc,CACd,IAAMc,EAAa,CAAC,EAChBC,EACEC,EAAgBhB,EAAQ,OAC9B,EAAG,CAED,IAAMiB,EAAW,MAAMlB,EAAc,CACnC,gBACA,YAAaC,EAAQ,YACrB,aAAcA,EAAQ,aACtB,KAAMA,EAAQ,KACd,OAAQgB,EACR,UAAWhB,EAAQ,SACrB,CAAC,EAMDe,EAASE,EAAS,QAAQ,gBAAgB,EAG1C,OAAOA,EAAS,QAChBH,EAAI,KAAK,GAAGG,EAAS,IAAI,EACzBD,EAAc,MAAQD,CACxB,OAASA,GAAW,MACpB,OAAOD,CACT","names":["get","options","aptosConfig","overrides","params","contentType","acceptType","path","originMethod","type","url","aptosRequest","getAptosFullNode","getAptosPepperService","paginateWithCursor","out","cursor","requestParams","response"]}
@@ -1,2 +0,0 @@
1
- import{a as i}from"./chunk-MK2QAHXC.mjs";import{a as b,b as g}from"./chunk-CC7VOPYH.mjs";import{b as h,d as p}from"./chunk-P3J54CQG.mjs";import{b as a}from"./chunk-KM6UXNC7.mjs";import{a as y}from"./chunk-QQIVWB6G.mjs";var n=class extends y{static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return o.load(e);case 1:return d.load(e);case 2:return u.load(e);case 3:return l.load(e);case 4:return A.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${r}`)}}},o=class s extends n{constructor(e,r){super(),this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=h.deserialize(e),t=p.deserialize(e);return new s(r,t)}},d=class s extends n{constructor(e,r){super(),this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=b.deserialize(e),t=g.deserialize(e);return new s(r,t)}},u=class s extends n{constructor(e,r,t){super(),this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=t}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=i.deserialize(e),t=e.deserializeVector(a),c=e.deserializeVector(i);return new s(r,t,c)}},l=class s extends n{constructor(e,r,t,c){super(),this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=t,this.fee_payer=c}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=i.deserialize(e),t=e.deserializeVector(a),c=e.deserializeVector(i),_=a.deserialize(e),z=i.deserialize(e),S={address:_,authenticator:z};return new s(r,t,c,S)}},A=class s extends n{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=i.deserialize(e);return new s(r)}};export{n as a,o as b,d as c,u as d,l as e,A as f};
2
- //# sourceMappingURL=chunk-SGQFWWLQ.mjs.map