@aptos-labs/ts-sdk 1.34.0 → 1.35.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 (419) hide show
  1. package/README.md +8 -9
  2. package/dist/common/{accountAddress-CDtCLtJA.d.ts → accountAddress-CuHovHdK.d.ts} +19 -0
  3. package/dist/common/chunk-RX5UBAME.js +4 -0
  4. package/dist/common/chunk-RX5UBAME.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 +489 -241
  9. package/dist/common/index.js +32 -32
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/Account.d.mts +1 -1
  14. package/dist/esm/account/Account.mjs +1 -1
  15. package/dist/esm/account/AccountUtils.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  17. package/dist/esm/account/Ed25519Account.mjs +1 -1
  18. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  19. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  20. package/dist/esm/account/KeylessAccount.mjs +1 -1
  21. package/dist/esm/account/MultiEd25519Account.d.mts +108 -0
  22. package/dist/esm/account/MultiEd25519Account.mjs +2 -0
  23. package/dist/esm/account/MultiKeyAccount.d.mts +1 -2
  24. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  25. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  26. package/dist/esm/account/index.d.mts +1 -0
  27. package/dist/esm/account/index.mjs +1 -1
  28. package/dist/esm/account/utils.mjs +1 -1
  29. package/dist/esm/api/account/abstraction.mjs +1 -1
  30. package/dist/esm/api/account.d.mts +1 -1
  31. package/dist/esm/api/account.mjs +1 -1
  32. package/dist/esm/api/ans.mjs +1 -1
  33. package/dist/esm/api/aptos.d.mts +3 -1
  34. package/dist/esm/api/aptos.mjs +1 -1
  35. package/dist/esm/api/aptosConfig.mjs +1 -1
  36. package/dist/esm/api/coin.d.mts +2 -2
  37. package/dist/esm/api/coin.mjs +1 -1
  38. package/dist/esm/api/digitalAsset.mjs +1 -1
  39. package/dist/esm/api/event.mjs +1 -1
  40. package/dist/esm/api/experimental.d.mts +83 -0
  41. package/dist/esm/api/experimental.mjs +2 -0
  42. package/dist/esm/api/experimental.mjs.map +1 -0
  43. package/dist/esm/api/faucet.mjs +1 -1
  44. package/dist/esm/api/fungibleAsset.mjs +1 -1
  45. package/dist/esm/api/general.mjs +1 -1
  46. package/dist/esm/api/index.d.mts +1 -0
  47. package/dist/esm/api/index.mjs +1 -1
  48. package/dist/esm/api/keyless.mjs +1 -1
  49. package/dist/esm/api/object.mjs +1 -1
  50. package/dist/esm/api/staking.mjs +1 -1
  51. package/dist/esm/api/table.mjs +1 -1
  52. package/dist/esm/api/transaction.mjs +1 -1
  53. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  54. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  55. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  56. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  57. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  58. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  59. package/dist/esm/api/utils.mjs +1 -1
  60. package/dist/esm/bcs/deserializer.mjs +1 -1
  61. package/dist/esm/bcs/index.mjs +1 -1
  62. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  63. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  64. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  65. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  66. package/dist/esm/bcs/serializer.mjs +1 -1
  67. package/dist/esm/{chunk-P7SE5LQE.mjs → chunk-27ESCVVC.mjs} +2 -2
  68. package/dist/esm/chunk-2SAYQUUX.mjs +2 -0
  69. package/dist/esm/chunk-2SAYQUUX.mjs.map +1 -0
  70. package/dist/esm/{chunk-UTXEW2FT.mjs → chunk-2TRQERBL.mjs} +2 -2
  71. package/dist/esm/chunk-2V636AYW.mjs +2 -0
  72. package/dist/esm/{chunk-L6FONDPA.mjs → chunk-2YKERRHD.mjs} +2 -2
  73. package/dist/esm/chunk-2ZLFQBT2.mjs +2 -0
  74. package/dist/esm/chunk-2ZLFQBT2.mjs.map +1 -0
  75. package/dist/esm/{chunk-XDIX7NIP.mjs → chunk-3LDVJ2YK.mjs} +2 -2
  76. package/dist/esm/{chunk-J7HRQ2IH.mjs → chunk-44EHAKKW.mjs} +2 -2
  77. package/dist/esm/{chunk-2FNFUTFJ.mjs → chunk-53IBOHXB.mjs} +2 -2
  78. package/dist/esm/{chunk-X6IHNXWY.mjs → chunk-5H5D6QVX.mjs} +2 -2
  79. package/dist/esm/{chunk-G4O6FXCF.mjs → chunk-5W2ERBGY.mjs} +2 -2
  80. package/dist/esm/{chunk-VOCI2675.mjs → chunk-67A5U2X6.mjs} +2 -2
  81. package/dist/esm/{chunk-XXHZQFYW.mjs → chunk-6IJZRG3U.mjs} +2 -2
  82. package/dist/esm/{chunk-N4DM5FYH.mjs → chunk-6KZT3KFZ.mjs} +2 -2
  83. package/dist/esm/chunk-752TOOCA.mjs +2 -0
  84. package/dist/esm/chunk-752TOOCA.mjs.map +1 -0
  85. package/dist/esm/{chunk-ZP5EBIBE.mjs → chunk-7A2KHJ3D.mjs} +2 -2
  86. package/dist/esm/{chunk-ROT6S6BM.mjs → chunk-7CRQNXR5.mjs} +2 -2
  87. package/dist/esm/{chunk-TM6IKHMX.mjs → chunk-7OUPEQRN.mjs} +2 -2
  88. package/dist/esm/chunk-A3VO773Q.mjs +2 -0
  89. package/dist/esm/{chunk-DWJ3PGWE.mjs → chunk-AEGA5N2W.mjs} +2 -2
  90. package/dist/esm/{chunk-BI3BTSUB.mjs → chunk-AIPHJFJL.mjs} +2 -2
  91. package/dist/esm/{chunk-HLJE5XGE.mjs → chunk-AQWKKSRN.mjs} +2 -2
  92. package/dist/esm/{chunk-D6T3NYOA.mjs → chunk-B23VO5TB.mjs} +2 -2
  93. package/dist/esm/{chunk-42T3UGSW.mjs → chunk-BHVSIRNF.mjs} +2 -2
  94. package/dist/esm/chunk-BMPHQ3E7.mjs +2 -0
  95. package/dist/esm/{chunk-EGZI6EJ2.mjs → chunk-BPHCRTHD.mjs} +2 -2
  96. package/dist/esm/{chunk-XH3BEKII.mjs → chunk-BQYKFATL.mjs} +2 -2
  97. package/dist/esm/chunk-BY3XFRUM.mjs +2 -0
  98. package/dist/esm/{chunk-EY2JUXEC.mjs.map → chunk-BY3XFRUM.mjs.map} +1 -1
  99. package/dist/esm/{chunk-DBIZE7G6.mjs → chunk-CGTMSLVZ.mjs} +2 -2
  100. package/dist/esm/{chunk-4T75XRI2.mjs → chunk-CPAAEEF4.mjs} +2 -2
  101. package/dist/esm/{chunk-DMS7K76O.mjs → chunk-CPFQUFVD.mjs} +2 -2
  102. package/dist/esm/chunk-CXLNTATW.mjs +2 -0
  103. package/dist/esm/chunk-CXLNTATW.mjs.map +1 -0
  104. package/dist/esm/{chunk-Q7RG7KQS.mjs → chunk-DAJFOJ3L.mjs} +2 -2
  105. package/dist/esm/chunk-DOVH6HPL.mjs +2 -0
  106. package/dist/esm/{chunk-U2SJIG2T.mjs → chunk-E5PAUR4N.mjs} +2 -2
  107. package/dist/esm/{chunk-6LGXFXXR.mjs → chunk-EGCL6KA6.mjs} +2 -2
  108. package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-ERLDXTIY.mjs} +2 -2
  109. package/dist/esm/{chunk-CSG67JHZ.mjs → chunk-FJ5J7CVW.mjs} +2 -2
  110. package/dist/esm/{chunk-DLLDRANJ.mjs → chunk-FOEPRHAC.mjs} +2 -2
  111. package/dist/esm/{chunk-6JTNS5O6.mjs → chunk-G5F5ZOH5.mjs} +2 -2
  112. package/dist/esm/chunk-GFPEB22G.mjs +1 -0
  113. package/dist/esm/chunk-GFPEB22G.mjs.map +1 -0
  114. package/dist/esm/{chunk-AZWVCBK2.mjs → chunk-GI4AR6DQ.mjs} +2 -2
  115. package/dist/esm/{chunk-Y3Y4DVCK.mjs → chunk-GRRBXHVG.mjs} +2 -2
  116. package/dist/esm/{chunk-HT2WC3QV.mjs → chunk-GTVMJJQQ.mjs} +2 -2
  117. package/dist/esm/{chunk-HL2O3T57.mjs → chunk-GU4MD5ST.mjs} +2 -2
  118. package/dist/esm/chunk-H4YAL2IL.mjs +2 -0
  119. package/dist/esm/{chunk-X24PSWCX.mjs → chunk-HBTJN4RJ.mjs} +2 -2
  120. package/dist/esm/{chunk-IDTLNF4M.mjs → chunk-HHWJHOFZ.mjs} +2 -2
  121. package/dist/esm/{chunk-OURSLL3I.mjs → chunk-HKL4MFNL.mjs} +2 -2
  122. package/dist/esm/{chunk-G6RLN6ET.mjs → chunk-HVIF6DW6.mjs} +2 -2
  123. package/dist/esm/{chunk-VKDTI6NX.mjs → chunk-HYJQHVDZ.mjs} +2 -2
  124. package/dist/esm/chunk-HYJQHVDZ.mjs.map +1 -0
  125. package/dist/esm/{chunk-XAPQNCTN.mjs → chunk-ILUFGYLO.mjs} +2 -2
  126. package/dist/esm/{chunk-ABXES4FS.mjs → chunk-IMYNN4TW.mjs} +2 -2
  127. package/dist/esm/{chunk-2GIPNLDO.mjs → chunk-IOHESHLR.mjs} +2 -2
  128. package/dist/esm/{chunk-GQX5KMF7.mjs → chunk-JNNFNYDO.mjs} +2 -2
  129. package/dist/esm/{chunk-3HFZN7L5.mjs → chunk-K233I26C.mjs} +2 -2
  130. package/dist/esm/{chunk-AC3BISWL.mjs → chunk-KK5HUWF6.mjs} +2 -2
  131. package/dist/esm/chunk-KSLLV3ZC.mjs +2 -0
  132. package/dist/esm/chunk-KSLLV3ZC.mjs.map +1 -0
  133. package/dist/esm/{chunk-N7C6LQPZ.mjs → chunk-L6KVC7CJ.mjs} +2 -2
  134. package/dist/esm/{chunk-Q4C4U6I4.mjs → chunk-LQOSHBB7.mjs} +2 -2
  135. package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-LS3IDL2N.mjs} +2 -2
  136. package/dist/esm/{chunk-HFCWJ6QL.mjs → chunk-MAWGZICD.mjs} +2 -2
  137. package/dist/esm/{chunk-JF66JS2R.mjs → chunk-MFLHAVIW.mjs} +2 -2
  138. package/dist/esm/chunk-OLGEN23M.mjs +2 -0
  139. package/dist/esm/{chunk-4UK4MUSD.mjs → chunk-ONGH5DXZ.mjs} +2 -2
  140. package/dist/esm/{chunk-4776UXL6.mjs → chunk-OPD5EKOA.mjs} +2 -2
  141. package/dist/esm/{chunk-V2EXS6TM.mjs → chunk-P5CM4C2G.mjs} +2 -2
  142. package/dist/esm/{chunk-BBUN4IO4.mjs → chunk-PC25RPDV.mjs} +2 -2
  143. package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-PDAWVDI7.mjs} +2 -2
  144. package/dist/esm/chunk-PIPDQFL2.mjs +2 -0
  145. package/dist/esm/chunk-PIPDQFL2.mjs.map +1 -0
  146. package/dist/esm/{chunk-6PBMD2BQ.mjs → chunk-PWGTRRSJ.mjs} +2 -2
  147. package/dist/esm/{chunk-PWYJWTEM.mjs → chunk-PYY2RXFP.mjs} +2 -2
  148. package/dist/esm/chunk-PYY2RXFP.mjs.map +1 -0
  149. package/dist/esm/chunk-QUJM5W4L.mjs +2 -0
  150. package/dist/esm/chunk-QUJM5W4L.mjs.map +1 -0
  151. package/dist/esm/{chunk-H4GZWYIG.mjs → chunk-QYJKCRVA.mjs} +2 -2
  152. package/dist/esm/{chunk-X2CPDUOS.mjs → chunk-R6QCPXQG.mjs} +2 -2
  153. package/dist/esm/chunk-R6QCPXQG.mjs.map +1 -0
  154. package/dist/esm/{chunk-33CBJFX2.mjs → chunk-RDPWCN4B.mjs} +2 -2
  155. package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-RIINVEZA.mjs} +2 -2
  156. package/dist/esm/{chunk-EBMEXURY.mjs → chunk-RXHER6EA.mjs} +2 -2
  157. package/dist/esm/chunk-SJDHW55X.mjs +2 -0
  158. package/dist/esm/chunk-SJDHW55X.mjs.map +1 -0
  159. package/dist/esm/{chunk-KEJAUCQF.mjs → chunk-T7X4GZDU.mjs} +2 -2
  160. package/dist/esm/{chunk-BUTMGMSD.mjs → chunk-TH5JCPN2.mjs} +2 -2
  161. package/dist/esm/{chunk-ORMOQWWH.mjs → chunk-TKXEVD7A.mjs} +2 -2
  162. package/dist/esm/{chunk-FN4C3CKC.mjs → chunk-TTY5GFMN.mjs} +2 -2
  163. package/dist/esm/chunk-TWETGZ3W.mjs +2 -0
  164. package/dist/esm/chunk-TWETGZ3W.mjs.map +1 -0
  165. package/dist/esm/{chunk-PR3W2QEH.mjs → chunk-U4DEYWFT.mjs} +2 -2
  166. package/dist/esm/{chunk-7CYCKCVU.mjs → chunk-UJJGIPOA.mjs} +2 -2
  167. package/dist/esm/{chunk-ZCEBDPBJ.mjs → chunk-US2HZFOM.mjs} +2 -2
  168. package/dist/esm/{chunk-S47HA7O7.mjs → chunk-VDYUMBOT.mjs} +2 -2
  169. package/dist/esm/chunk-VHY6ZATX.mjs +2 -0
  170. package/dist/esm/chunk-VHY6ZATX.mjs.map +1 -0
  171. package/dist/esm/{chunk-TDGUMBON.mjs → chunk-VWZEJTGP.mjs} +2 -2
  172. package/dist/esm/{chunk-TDGUMBON.mjs.map → chunk-VWZEJTGP.mjs.map} +1 -1
  173. package/dist/esm/{chunk-3EY7MT2M.mjs → chunk-W2C5KRUQ.mjs} +2 -2
  174. package/dist/esm/{chunk-O37BZP2G.mjs → chunk-W4SMZ6IW.mjs} +2 -2
  175. package/dist/esm/chunk-WFKPVKU3.mjs +2 -0
  176. package/dist/esm/chunk-WFKPVKU3.mjs.map +1 -0
  177. package/dist/esm/{chunk-CXNF73OX.mjs → chunk-WHVCUVZP.mjs} +2 -2
  178. package/dist/esm/{chunk-QBFGY74I.mjs → chunk-WLDYBSOG.mjs} +2 -2
  179. package/dist/esm/{chunk-HEAWDTLG.mjs → chunk-XRVZAEQO.mjs} +2 -2
  180. package/dist/esm/chunk-XSBUL2WP.mjs +2 -0
  181. package/dist/esm/chunk-XSBUL2WP.mjs.map +1 -0
  182. package/dist/esm/{chunk-DNWFDS7F.mjs → chunk-XW3BXTCZ.mjs} +2 -2
  183. package/dist/esm/{chunk-L2AQG3G3.mjs → chunk-Y65PKZLK.mjs} +2 -2
  184. package/dist/esm/{chunk-WXDA4CCR.mjs → chunk-YAGIE4GN.mjs} +2 -2
  185. package/dist/esm/{chunk-CRFLR3ZY.mjs → chunk-YLUULY6G.mjs} +2 -2
  186. package/dist/esm/{chunk-SCBYJU6K.mjs → chunk-YWSDONJJ.mjs} +2 -2
  187. package/dist/esm/{chunk-BYHCW7MI.mjs → chunk-YXYYII5S.mjs} +2 -2
  188. package/dist/esm/{chunk-XTOIL6MB.mjs → chunk-ZD2TY5N3.mjs} +2 -2
  189. package/dist/esm/{chunk-5BSMF22B.mjs → chunk-ZS2IVRHT.mjs} +2 -2
  190. package/dist/esm/cli/index.mjs +1 -1
  191. package/dist/esm/cli/localNode.mjs +1 -1
  192. package/dist/esm/client/core.d.mts +36 -1
  193. package/dist/esm/client/core.mjs +1 -1
  194. package/dist/esm/client/get.d.mts +35 -1
  195. package/dist/esm/client/get.mjs +1 -1
  196. package/dist/esm/client/index.d.mts +3 -3
  197. package/dist/esm/client/index.mjs +1 -1
  198. package/dist/esm/client/post.d.mts +34 -1
  199. package/dist/esm/client/post.mjs +1 -1
  200. package/dist/esm/core/account/index.mjs +1 -1
  201. package/dist/esm/core/account/utils/address.mjs +1 -1
  202. package/dist/esm/core/account/utils/index.mjs +1 -1
  203. package/dist/esm/core/accountAddress.mjs +1 -1
  204. package/dist/esm/core/authenticationKey.mjs +1 -1
  205. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  206. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  207. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  208. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  209. package/dist/esm/core/crypto/index.d.mts +1 -1
  210. package/dist/esm/core/crypto/index.mjs +1 -1
  211. package/dist/esm/core/crypto/keyless.mjs +1 -1
  212. package/dist/esm/core/crypto/multiEd25519.d.mts +17 -2
  213. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  214. package/dist/esm/core/crypto/multiKey.d.mts +33 -15
  215. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  216. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  217. package/dist/esm/core/crypto/proof.mjs +1 -1
  218. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  219. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  220. package/dist/esm/core/crypto/signature.mjs +1 -1
  221. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  222. package/dist/esm/core/crypto/utils.mjs +1 -1
  223. package/dist/esm/core/hex.mjs +1 -1
  224. package/dist/esm/core/index.d.mts +1 -1
  225. package/dist/esm/core/index.mjs +1 -1
  226. package/dist/esm/errors/index.mjs +1 -1
  227. package/dist/esm/index.d.mts +6 -4
  228. package/dist/esm/index.mjs +1 -1
  229. package/dist/esm/internal/abstraction.mjs +1 -1
  230. package/dist/esm/internal/account.mjs +1 -1
  231. package/dist/esm/internal/ans.mjs +1 -1
  232. package/dist/esm/internal/coin.mjs +1 -1
  233. package/dist/esm/internal/digitalAsset.mjs +1 -1
  234. package/dist/esm/internal/event.mjs +1 -1
  235. package/dist/esm/internal/experimental.d.mts +52 -0
  236. package/dist/esm/internal/experimental.mjs +2 -0
  237. package/dist/esm/internal/experimental.mjs.map +1 -0
  238. package/dist/esm/internal/faucet.mjs +1 -1
  239. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  240. package/dist/esm/internal/general.mjs +1 -1
  241. package/dist/esm/internal/keyless.mjs +1 -1
  242. package/dist/esm/internal/object.mjs +1 -1
  243. package/dist/esm/internal/staking.mjs +1 -1
  244. package/dist/esm/internal/table.mjs +1 -1
  245. package/dist/esm/internal/transaction.mjs +1 -1
  246. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  247. package/dist/esm/internal/view.mjs +1 -1
  248. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  249. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  250. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  251. package/dist/esm/transactions/index.mjs +1 -1
  252. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  253. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  254. package/dist/esm/transactions/instances/index.mjs +1 -1
  255. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  256. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  257. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  258. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  259. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  260. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  261. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  262. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  263. package/dist/esm/transactions/management/index.mjs +1 -1
  264. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  265. package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
  266. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  267. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  268. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  269. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  270. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
  271. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  272. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  273. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  274. package/dist/esm/types/index.mjs +1 -1
  275. package/dist/esm/types/types.d.mts +19 -0
  276. package/dist/esm/types/types.mjs +1 -1
  277. package/dist/esm/utils/helpers.mjs +1 -1
  278. package/dist/esm/utils/index.mjs +1 -1
  279. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  280. package/dist/esm/version.d.mts +1 -1
  281. package/dist/esm/version.mjs +1 -1
  282. package/package.json +2 -7
  283. package/src/account/MultiEd25519Account.ts +154 -0
  284. package/src/account/MultiKeyAccount.ts +1 -2
  285. package/src/account/index.ts +1 -0
  286. package/src/api/account.ts +1 -1
  287. package/src/api/aptos.ts +6 -0
  288. package/src/api/aptosConfig.ts +2 -2
  289. package/src/api/experimental.ts +64 -0
  290. package/src/client/core.ts +120 -0
  291. package/src/client/get.ts +73 -1
  292. package/src/client/post.ts +70 -1
  293. package/src/core/crypto/multiEd25519.ts +19 -3
  294. package/src/core/crypto/multiKey.ts +76 -52
  295. package/src/core/hex.ts +3 -1
  296. package/src/internal/experimental.ts +55 -0
  297. package/src/internal/view.ts +4 -4
  298. package/src/transactions/transactionBuilder/transactionBuilder.ts +7 -0
  299. package/src/types/types.ts +20 -0
  300. package/src/version.ts +1 -1
  301. package/dist/common/chunk-ZYPBABLQ.js +0 -4
  302. package/dist/common/chunk-ZYPBABLQ.js.map +0 -1
  303. package/dist/esm/chunk-4YLUM62M.mjs +0 -2
  304. package/dist/esm/chunk-66HHRRIX.mjs +0 -2
  305. package/dist/esm/chunk-66HHRRIX.mjs.map +0 -1
  306. package/dist/esm/chunk-7C2RDOWS.mjs +0 -1
  307. package/dist/esm/chunk-7DPHPPMG.mjs +0 -2
  308. package/dist/esm/chunk-7DPHPPMG.mjs.map +0 -1
  309. package/dist/esm/chunk-DNJQWGB7.mjs +0 -2
  310. package/dist/esm/chunk-DPW6ELCQ.mjs +0 -2
  311. package/dist/esm/chunk-EMURYYVO.mjs +0 -2
  312. package/dist/esm/chunk-EY2JUXEC.mjs +0 -2
  313. package/dist/esm/chunk-F2ZTBAJJ.mjs +0 -2
  314. package/dist/esm/chunk-F2ZTBAJJ.mjs.map +0 -1
  315. package/dist/esm/chunk-I7YHK6ZF.mjs +0 -2
  316. package/dist/esm/chunk-I7YHK6ZF.mjs.map +0 -1
  317. package/dist/esm/chunk-PNSF3E67.mjs +0 -2
  318. package/dist/esm/chunk-PNSF3E67.mjs.map +0 -1
  319. package/dist/esm/chunk-PWYJWTEM.mjs.map +0 -1
  320. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  321. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  322. package/dist/esm/chunk-ULHOJ2BE.mjs +0 -2
  323. package/dist/esm/chunk-ULHOJ2BE.mjs.map +0 -1
  324. package/dist/esm/chunk-V7G2EDNR.mjs +0 -2
  325. package/dist/esm/chunk-V7G2EDNR.mjs.map +0 -1
  326. package/dist/esm/chunk-VKDTI6NX.mjs.map +0 -1
  327. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  328. package/dist/esm/chunk-X2CPDUOS.mjs.map +0 -1
  329. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  330. package/dist/esm/chunk-YIF242TF.mjs +0 -2
  331. package/dist/esm/chunk-YIF242TF.mjs.map +0 -1
  332. /package/dist/esm/{chunk-7C2RDOWS.mjs.map → account/MultiEd25519Account.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-P7SE5LQE.mjs.map → chunk-27ESCVVC.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-UTXEW2FT.mjs.map → chunk-2TRQERBL.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-2V636AYW.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-L6FONDPA.mjs.map → chunk-2YKERRHD.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-XDIX7NIP.mjs.map → chunk-3LDVJ2YK.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-J7HRQ2IH.mjs.map → chunk-44EHAKKW.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-2FNFUTFJ.mjs.map → chunk-53IBOHXB.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-X6IHNXWY.mjs.map → chunk-5H5D6QVX.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-G4O6FXCF.mjs.map → chunk-5W2ERBGY.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-VOCI2675.mjs.map → chunk-67A5U2X6.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-XXHZQFYW.mjs.map → chunk-6IJZRG3U.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-N4DM5FYH.mjs.map → chunk-6KZT3KFZ.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-ZP5EBIBE.mjs.map → chunk-7A2KHJ3D.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-ROT6S6BM.mjs.map → chunk-7CRQNXR5.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-TM6IKHMX.mjs.map → chunk-7OUPEQRN.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-A3VO773Q.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-DWJ3PGWE.mjs.map → chunk-AEGA5N2W.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-BI3BTSUB.mjs.map → chunk-AIPHJFJL.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-HLJE5XGE.mjs.map → chunk-AQWKKSRN.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-D6T3NYOA.mjs.map → chunk-B23VO5TB.mjs.map} +0 -0
  353. /package/dist/esm/{chunk-42T3UGSW.mjs.map → chunk-BHVSIRNF.mjs.map} +0 -0
  354. /package/dist/esm/{chunk-4YLUM62M.mjs.map → chunk-BMPHQ3E7.mjs.map} +0 -0
  355. /package/dist/esm/{chunk-EGZI6EJ2.mjs.map → chunk-BPHCRTHD.mjs.map} +0 -0
  356. /package/dist/esm/{chunk-XH3BEKII.mjs.map → chunk-BQYKFATL.mjs.map} +0 -0
  357. /package/dist/esm/{chunk-DBIZE7G6.mjs.map → chunk-CGTMSLVZ.mjs.map} +0 -0
  358. /package/dist/esm/{chunk-4T75XRI2.mjs.map → chunk-CPAAEEF4.mjs.map} +0 -0
  359. /package/dist/esm/{chunk-DMS7K76O.mjs.map → chunk-CPFQUFVD.mjs.map} +0 -0
  360. /package/dist/esm/{chunk-Q7RG7KQS.mjs.map → chunk-DAJFOJ3L.mjs.map} +0 -0
  361. /package/dist/esm/{chunk-DPW6ELCQ.mjs.map → chunk-DOVH6HPL.mjs.map} +0 -0
  362. /package/dist/esm/{chunk-U2SJIG2T.mjs.map → chunk-E5PAUR4N.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-6LGXFXXR.mjs.map → chunk-EGCL6KA6.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-ERLDXTIY.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-CSG67JHZ.mjs.map → chunk-FJ5J7CVW.mjs.map} +0 -0
  366. /package/dist/esm/{chunk-DLLDRANJ.mjs.map → chunk-FOEPRHAC.mjs.map} +0 -0
  367. /package/dist/esm/{chunk-6JTNS5O6.mjs.map → chunk-G5F5ZOH5.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-AZWVCBK2.mjs.map → chunk-GI4AR6DQ.mjs.map} +0 -0
  369. /package/dist/esm/{chunk-Y3Y4DVCK.mjs.map → chunk-GRRBXHVG.mjs.map} +0 -0
  370. /package/dist/esm/{chunk-HT2WC3QV.mjs.map → chunk-GTVMJJQQ.mjs.map} +0 -0
  371. /package/dist/esm/{chunk-HL2O3T57.mjs.map → chunk-GU4MD5ST.mjs.map} +0 -0
  372. /package/dist/esm/{chunk-EMURYYVO.mjs.map → chunk-H4YAL2IL.mjs.map} +0 -0
  373. /package/dist/esm/{chunk-X24PSWCX.mjs.map → chunk-HBTJN4RJ.mjs.map} +0 -0
  374. /package/dist/esm/{chunk-IDTLNF4M.mjs.map → chunk-HHWJHOFZ.mjs.map} +0 -0
  375. /package/dist/esm/{chunk-OURSLL3I.mjs.map → chunk-HKL4MFNL.mjs.map} +0 -0
  376. /package/dist/esm/{chunk-G6RLN6ET.mjs.map → chunk-HVIF6DW6.mjs.map} +0 -0
  377. /package/dist/esm/{chunk-XAPQNCTN.mjs.map → chunk-ILUFGYLO.mjs.map} +0 -0
  378. /package/dist/esm/{chunk-ABXES4FS.mjs.map → chunk-IMYNN4TW.mjs.map} +0 -0
  379. /package/dist/esm/{chunk-2GIPNLDO.mjs.map → chunk-IOHESHLR.mjs.map} +0 -0
  380. /package/dist/esm/{chunk-GQX5KMF7.mjs.map → chunk-JNNFNYDO.mjs.map} +0 -0
  381. /package/dist/esm/{chunk-3HFZN7L5.mjs.map → chunk-K233I26C.mjs.map} +0 -0
  382. /package/dist/esm/{chunk-AC3BISWL.mjs.map → chunk-KK5HUWF6.mjs.map} +0 -0
  383. /package/dist/esm/{chunk-N7C6LQPZ.mjs.map → chunk-L6KVC7CJ.mjs.map} +0 -0
  384. /package/dist/esm/{chunk-Q4C4U6I4.mjs.map → chunk-LQOSHBB7.mjs.map} +0 -0
  385. /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-LS3IDL2N.mjs.map} +0 -0
  386. /package/dist/esm/{chunk-HFCWJ6QL.mjs.map → chunk-MAWGZICD.mjs.map} +0 -0
  387. /package/dist/esm/{chunk-JF66JS2R.mjs.map → chunk-MFLHAVIW.mjs.map} +0 -0
  388. /package/dist/esm/{chunk-DNJQWGB7.mjs.map → chunk-OLGEN23M.mjs.map} +0 -0
  389. /package/dist/esm/{chunk-4UK4MUSD.mjs.map → chunk-ONGH5DXZ.mjs.map} +0 -0
  390. /package/dist/esm/{chunk-4776UXL6.mjs.map → chunk-OPD5EKOA.mjs.map} +0 -0
  391. /package/dist/esm/{chunk-V2EXS6TM.mjs.map → chunk-P5CM4C2G.mjs.map} +0 -0
  392. /package/dist/esm/{chunk-BBUN4IO4.mjs.map → chunk-PC25RPDV.mjs.map} +0 -0
  393. /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-PDAWVDI7.mjs.map} +0 -0
  394. /package/dist/esm/{chunk-6PBMD2BQ.mjs.map → chunk-PWGTRRSJ.mjs.map} +0 -0
  395. /package/dist/esm/{chunk-H4GZWYIG.mjs.map → chunk-QYJKCRVA.mjs.map} +0 -0
  396. /package/dist/esm/{chunk-33CBJFX2.mjs.map → chunk-RDPWCN4B.mjs.map} +0 -0
  397. /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-RIINVEZA.mjs.map} +0 -0
  398. /package/dist/esm/{chunk-EBMEXURY.mjs.map → chunk-RXHER6EA.mjs.map} +0 -0
  399. /package/dist/esm/{chunk-KEJAUCQF.mjs.map → chunk-T7X4GZDU.mjs.map} +0 -0
  400. /package/dist/esm/{chunk-BUTMGMSD.mjs.map → chunk-TH5JCPN2.mjs.map} +0 -0
  401. /package/dist/esm/{chunk-ORMOQWWH.mjs.map → chunk-TKXEVD7A.mjs.map} +0 -0
  402. /package/dist/esm/{chunk-FN4C3CKC.mjs.map → chunk-TTY5GFMN.mjs.map} +0 -0
  403. /package/dist/esm/{chunk-PR3W2QEH.mjs.map → chunk-U4DEYWFT.mjs.map} +0 -0
  404. /package/dist/esm/{chunk-7CYCKCVU.mjs.map → chunk-UJJGIPOA.mjs.map} +0 -0
  405. /package/dist/esm/{chunk-ZCEBDPBJ.mjs.map → chunk-US2HZFOM.mjs.map} +0 -0
  406. /package/dist/esm/{chunk-S47HA7O7.mjs.map → chunk-VDYUMBOT.mjs.map} +0 -0
  407. /package/dist/esm/{chunk-3EY7MT2M.mjs.map → chunk-W2C5KRUQ.mjs.map} +0 -0
  408. /package/dist/esm/{chunk-O37BZP2G.mjs.map → chunk-W4SMZ6IW.mjs.map} +0 -0
  409. /package/dist/esm/{chunk-CXNF73OX.mjs.map → chunk-WHVCUVZP.mjs.map} +0 -0
  410. /package/dist/esm/{chunk-QBFGY74I.mjs.map → chunk-WLDYBSOG.mjs.map} +0 -0
  411. /package/dist/esm/{chunk-HEAWDTLG.mjs.map → chunk-XRVZAEQO.mjs.map} +0 -0
  412. /package/dist/esm/{chunk-DNWFDS7F.mjs.map → chunk-XW3BXTCZ.mjs.map} +0 -0
  413. /package/dist/esm/{chunk-L2AQG3G3.mjs.map → chunk-Y65PKZLK.mjs.map} +0 -0
  414. /package/dist/esm/{chunk-WXDA4CCR.mjs.map → chunk-YAGIE4GN.mjs.map} +0 -0
  415. /package/dist/esm/{chunk-CRFLR3ZY.mjs.map → chunk-YLUULY6G.mjs.map} +0 -0
  416. /package/dist/esm/{chunk-SCBYJU6K.mjs.map → chunk-YWSDONJJ.mjs.map} +0 -0
  417. /package/dist/esm/{chunk-BYHCW7MI.mjs.map → chunk-YXYYII5S.mjs.map} +0 -0
  418. /package/dist/esm/{chunk-XTOIL6MB.mjs.map → chunk-ZD2TY5N3.mjs.map} +0 -0
  419. /package/dist/esm/{chunk-5BSMF22B.mjs.map → chunk-ZS2IVRHT.mjs.map} +0 -0
@@ -302,6 +302,7 @@ export interface ClientRequest<Req> {
302
302
  originMethod?: string;
303
303
  body?: Req;
304
304
  contentType?: string;
305
+ acceptType?: string;
305
306
  params?: any;
306
307
  overrides?: ClientConfig & FullNodeConfig & IndexerConfig & FaucetConfig;
307
308
  headers?: Record<string, any>;
@@ -333,6 +334,23 @@ export interface Client {
333
334
  * @param requestOptions.overrides - Optional configuration overrides for the request.
334
335
  */
335
336
  provider<Req, Res>(requestOptions: ClientRequest<Req>): Promise<ClientResponse<Res>>;
337
+
338
+ /**
339
+ * Sends a request to the specified URL with the given options, that returns a binary response
340
+ *
341
+ * @experimental
342
+ * @param requestOptions - The options for the request.
343
+ * @param requestOptions.url - The URL to send the request to.
344
+ * @param requestOptions.method - The HTTP method to use, either "GET" or "POST".
345
+ * @param requestOptions.path - An optional path to append to the URL.
346
+ * @param requestOptions.body - The body of the request, applicable for POST requests.
347
+ * @param requestOptions.contentType - The content type of the request body.
348
+ * @param requestOptions.acceptType - The expected content type of the response.
349
+ * @param requestOptions.params - Optional parameters to include in the request.
350
+ * @param requestOptions.originMethod - An optional method to specify the origin of the request.
351
+ * @param requestOptions.overrides - Optional configuration overrides for the request.
352
+ */
353
+ binaryProvider?: <Req>(requestOptions: ClientRequest<Req>) => Promise<ClientResponse<Buffer>>;
336
354
  }
337
355
 
338
356
  /**
@@ -344,6 +362,8 @@ export interface Client {
344
362
  * @param body (optional) - the body of the request
345
363
  * @param contentType (optional) - the content type to set the `content-type` header to,
346
364
  * by default is set to `application/json`
365
+ * @param acceptType (optional) - the content type to set the `accept-type` header to,
366
+ * by default is set to `application/json`
347
367
  * @param params (optional) - query params to add to the request
348
368
  * @param originMethod (optional) - the local method the request came from
349
369
  * @param overrides (optional) - a `ClientConfig` object type to override request data
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "1.34.0";
9
+ export const VERSION = "1.35.0";
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var M=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var y=(r,e,t,n)=>{for(var s=n>1?void 0:n?E(e,t):e,i=r.length-1,g;i>=0;i--)(g=r[i])&&(s=(n?g(e,t,s):g(s))||s);return n&&s&&M(e,t,s),s};var u=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var _utils = require('@noble/hashes/utils');var k=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(k||{}),_= exports.j =class r{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new u("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new u("Hex string must be an even number of hex characters.","invalid_length");try{return new r(_utils.hexToBytes.call(void 0, t))}catch(n){throw new u(`Hex string contains invalid hex characters: ${_optionalChain([n, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new r(e):r.fromHexString(e)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:r.fromHexString(e).toUint8Array()}static hexInputToString(e){return r.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return r.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return r.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}},ue= exports.k =r=>new TextDecoder().decode(_.fromHexInput(r).toUint8Array());var R=255,U= exports.c =65535,x= exports.d =4294967295,b= exports.e =18446744073709551615n,S= exports.f =340282366920938463463374607431768211455n,T= exports.g =115792089237316195423570985008687907853269984665640564039457584007913129639935n;var f=class{bcsToBytes(){let e=new c;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return _.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},c= exports.m =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,n){this.ensureBufferWillHandleSize(t);let s=new DataView(this.buffer,this.offset);e.apply(s,[0,n,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){C(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(x),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&b,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&S,n=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(n)}serializeU32AsUleb128(e){let t=e,n=[];for(;t>>>7;)n.push(t&127|128),t>>>=7;n.push(t),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e,t){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?t!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};y([h(0,R)],c.prototype,"serializeU8",1),y([h(0,U)],c.prototype,"serializeU16",1),y([h(0,x)],c.prototype,"serializeU32",1),y([h(BigInt(0),b)],c.prototype,"serializeU64",1),y([h(BigInt(0),S)],c.prototype,"serializeU128",1),y([h(BigInt(0),T)],c.prototype,"serializeU256",1),y([h(0,x)],c.prototype,"serializeU32AsUleb128",1);function C(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var w=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function H(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(w(r,e,t))}function h(r,e){return(t,n,s)=>{let i=s.value;return s.value=function(d){return H(d,r,e),i.apply(this,[d])},s}}var O=(s=>(s.JSON="application/json",s.BCS="application/x-bcs",s.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",s.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",s))(O||{}),W= exports.r =(a=>(a[a.Bool=0]="Bool",a[a.U8=1]="U8",a[a.U64=2]="U64",a[a.U128=3]="U128",a[a.Address=4]="Address",a[a.Signer=5]="Signer",a[a.Vector=6]="Vector",a[a.Struct=7]="Struct",a[a.U16=8]="U16",a[a.U32=9]="U32",a[a.U256=10]="U256",a[a.Reference=254]="Reference",a[a.Generic=255]="Generic",a))(W||{}),v= exports.s =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p[p.Serialized=9]="Serialized",p))(v||{}),z= exports.t =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(z||{}),D= exports.u =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(D||{}),F= exports.v =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(F||{}),G= exports.w =(g=>(g[g.Ed25519=0]="Ed25519",g[g.MultiEd25519=1]="MultiEd25519",g[g.SingleKey=2]="SingleKey",g[g.MultiKey=3]="MultiKey",g[g.NoAccountAuthenticator=4]="NoAccountAuthenticator",g[g.Abstraction=5]="Abstraction",g))(G||{}),P= exports.x =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(P||{}),L= exports.y =(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.Keyless=3]="Keyless",s[s.FederatedKeyless=4]="FederatedKeyless",s))(L||{}),$= exports.z =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))($||{}),q= exports.A =(e=>(e[e.Ed25519=0]="Ed25519",e))(q||{}),X= exports.B =(e=>(e[e.Ed25519=0]="Ed25519",e))(X||{}),Y= exports.C =(e=>(e[e.ZkProof=0]="ZkProof",e))(Y||{}),Z= exports.D =(e=>(e[e.Groth16=0]="Groth16",e))(Z||{}),Q= exports.E =(d=>(d.Pending="pending_transaction",d.User="user_transaction",d.Genesis="genesis_transaction",d.BlockMetadata="block_metadata_transaction",d.StateCheckpoint="state_checkpoint_transaction",d.Validator="validator_transaction",d.BlockEpilogue="block_epilogue_transaction",d))(Q||{});function xe(r){return r.type==="pending_transaction"}function fe(r){return r.type==="user_transaction"}function me(r){return r.type==="genesis_transaction"}function be(r){return r.type==="block_metadata_transaction"}function Se(r){return r.type==="state_checkpoint_transaction"}function Re(r){return r.type==="validator_transaction"}function Ue(r){return r.type==="block_epilogue_transaction"}function Te(r){return"signature"in r&&r.signature==="ed25519_signature"}function ve(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function Ae(r){return r.type==="multi_agent_signature"}function Ie(r){return r.type==="fee_payer_signature"}function Me(r){return r.type==="multi_ed25519_signature"}var j=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(j||{}),K= exports.S =(s=>(s.STORE="store",s.DROP="drop",s.KEY="key",s.COPY="copy",s))(K||{}),J= exports.T =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(J||{}),V= exports.U =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.SingleKey=2]="SingleKey",s[s.MultiKey=3]="MultiKey",s))(V||{}),ee= exports.V =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(ee||{}),te= exports.W =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(te||{});var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var ne=(l=>(l.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",l.INVALID_HEX_CHARS="invalid_hex_chars",l.TOO_SHORT="too_short",l.TOO_LONG="too_long",l.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",l.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",l.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",l.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",l))(ne||{}),o=class o extends f{constructor(e){if(super(),e.length!==o.LENGTH)throw new u("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(o.LENGTH);return new o(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new u("Hex string must start with a leading 0x.","leading_zero_x_required");let t=o.fromString(e);if(e.length!==o.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new u(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new u(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e,{maxMissingChars:t=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new u("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new u("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(t>63||t<0)throw new u(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let s;try{s=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(g){throw new u(`Hex characters are invalid: ${_optionalChain([g, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let i=new o(s);if(n.length<64-t&&!i.isSpecial())throw new u(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
2
- the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
3
- Received ${e}`,"too_short");return i}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?o.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new o(e):e}static fromStrict(e){return typeof e=="string"?o.fromStringStrict(e):e instanceof Uint8Array?new o(e):e}static isValid(e){try{return e.strict?o.fromStrict(e.input):o.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}};o.LENGTH=32,o.LONG_STRING_LENGTH=64,o.ZERO=o.from("0x0"),o.ONE=o.from("0x1"),o.TWO=o.from("0x2"),o.THREE=o.from("0x3"),o.FOUR=o.from("0x4"),o.A=o.from("0xA");var m=o;var _jsbase64 = require('js-base64');async function qe(r){return new Promise(e=>{setTimeout(e,r)})}function Xe(r){return r instanceof Error?r.message:String(r)}var Ye=()=>Math.floor(Date.now()/1e3);function Ze(r){let e=new Date(r*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function Qe(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e+"==".substring(0,(3-e.length%3)%3);return _jsbase64.decode.call(void 0, t)}var je=(r,e)=>r*10**e,Ke= exports.ea =(r,e)=>r/10**e,I=r=>{let e="";for(let t=2;t<r.length;t+=2)e+=String.fromCharCode(parseInt(r.substring(t,t+2),16));return e},Je= exports.fa =r=>{let{account_address:e,module_name:t,struct_name:n}=r,s=I(t),i=I(n);return`${e}::${s}::${i}`},Ve= exports.ga =r=>typeof r=="object"&&!Array.isArray(r)&&r!==null&&"account_address"in r&&"module_name"in r&&"struct_name"in r&&typeof r.account_address=="string"&&typeof r.module_name=="string"&&typeof r.struct_name=="string";function et(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],s=e[2];return{moduleAddress:t,moduleName:n,functionName:s}}function tt(r){let e=r.split("::");return e.length===3&&m.isValid({input:e[0]}).valid}exports.a = y; exports.b = R; exports.c = U; exports.d = x; exports.e = b; exports.f = S; exports.g = T; exports.h = u; exports.i = k; exports.j = _; exports.k = ue; exports.l = f; exports.m = c; exports.n = C; exports.o = w; exports.p = H; exports.q = O; exports.r = W; exports.s = v; exports.t = z; exports.u = D; exports.v = F; exports.w = G; exports.x = P; exports.y = L; exports.z = $; exports.A = q; exports.B = X; exports.C = Y; exports.D = Z; exports.E = Q; exports.F = xe; exports.G = fe; exports.H = me; exports.I = be; exports.J = Se; exports.K = Re; exports.L = Ue; exports.M = Te; exports.N = ve; exports.O = Ae; exports.P = Ie; exports.Q = Me; exports.R = j; exports.S = K; exports.T = J; exports.U = V; exports.V = ee; exports.W = te; exports.X = _scriptcomposerpack.CallArgument; exports.Y = ne; exports.Z = m; exports._ = qe; exports.$ = Xe; exports.aa = Ye; exports.ba = Ze; exports.ca = Qe; exports.da = je; exports.ea = Ke; exports.fa = Je; exports.ga = Ve; exports.ha = et; exports.ia = tt;
4
- //# sourceMappingURL=chunk-ZYPBABLQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/philip/Documents/General/aptos-ts-sdk/dist/common/chunk-ZYPBABLQ.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACyTsB;AA1UV,SAAA","file":"/Users/philip/Documents/General/aptos-ts-sdk/dist/common/chunk-ZYPBABLQ.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// 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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// 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 * @group Implementation\n * @category Serialization\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 INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category 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 * @group Implementation\n * @category Serialization\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 * @remarks\n *\n * 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 * @group Implementation\n * @category Serialization\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`.\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. The address can have missing values up to `maxMissingChars` before it is padded.\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 * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\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 * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): 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 // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\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 const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\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 * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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"]}
@@ -1,2 +0,0 @@
1
- import{a as e}from"./chunk-XTOIL6MB.mjs";function t(i,r){let l=r.bcsToBytes(),a=new e(l);return i.deserialize(a)}export{t as a};
2
- //# sourceMappingURL=chunk-4YLUM62M.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as b}from"./chunk-PR3W2QEH.mjs";import{a as A}from"./chunk-L2AQG3G3.mjs";import{a as m}from"./chunk-XDIX7NIP.mjs";import{a as u}from"./chunk-2GIPNLDO.mjs";import{a as y}from"./chunk-N7C6LQPZ.mjs";import{a as w}from"./chunk-F2ZTBAJJ.mjs";import{a}from"./chunk-Q7RG7KQS.mjs";import{a as c}from"./chunk-QBFGY74I.mjs";import{a as l}from"./chunk-6LGXFXXR.mjs";import{a as f}from"./chunk-7CYCKCVU.mjs";import{a as g}from"./chunk-H4GZWYIG.mjs";import{a as p}from"./chunk-XXHZQFYW.mjs";import{a as r}from"./chunk-TDGUMBON.mjs";import{a as s}from"./chunk-HLJE5XGE.mjs";import{a as h}from"./chunk-S47HA7O7.mjs";var t=class{constructor(e){this.config=new w(e),this.account=new r(this.config),this.abstraction=new s(this.config),this.ans=new h(this.config),this.coin=new a(this.config),this.digitalAsset=new c(this.config),this.event=new l(this.config),this.faucet=new f(this.config),this.fungibleAsset=new g(this.config),this.general=new p(this.config),this.staking=new m(this.config),this.transaction=new y(this.config),this.table=new u(this.config),this.keyless=new b(this.config),this.object=new A(this.config)}};function n(d,e,j){Object.getOwnPropertyNames(e.prototype).forEach(i=>{let o=Object.getOwnPropertyDescriptor(e.prototype,i);o&&(o.value=function(...k){return this[j][i](...k)},Object.defineProperty(d.prototype,i,o))})}n(t,r,"account");n(t,s,"abstraction");n(t,h,"ans");n(t,a,"coin");n(t,c,"digitalAsset");n(t,l,"event");n(t,f,"faucet");n(t,g,"fungibleAsset");n(t,p,"general");n(t,m,"staking");n(t,y,"transaction");n(t,u,"table");n(t,b,"keyless");n(t,A,"object");export{t as a};
2
- //# sourceMappingURL=chunk-66HHRRIX.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/aptos.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./account\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Coin } from \"./coin\";\nimport { DigitalAsset } from \"./digitalAsset\";\nimport { Event } from \"./event\";\nimport { Faucet } from \"./faucet\";\nimport { FungibleAsset } from \"./fungibleAsset\";\nimport { General } from \"./general\";\nimport { ANS } from \"./ans\";\nimport { Staking } from \"./staking\";\nimport { Transaction } from \"./transaction\";\nimport { Table } from \"./table\";\nimport { Keyless } from \"./keyless\";\nimport { AptosObject } from \"./object\";\nimport { AccountAbstraction } from \"./account/abstraction\";\n\n/**\n * The main entry point for interacting with the Aptos APIs,\n * providing access to various functionalities organized into\n * distinct namespaces.\n *\n * To utilize the SDK, instantiate a new Aptos object to gain\n * access to the complete range of SDK features.\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 connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class Aptos {\n readonly config: AptosConfig;\n\n readonly account: Account;\n\n readonly ans: ANS;\n\n readonly coin: Coin;\n\n readonly digitalAsset: DigitalAsset;\n\n readonly event: Event;\n\n readonly faucet: Faucet;\n\n readonly fungibleAsset: FungibleAsset;\n\n readonly general: General;\n\n readonly staking: Staking;\n\n readonly transaction: Transaction;\n\n readonly table: Table;\n\n readonly keyless: Keyless;\n\n readonly object: AptosObject;\n\n /**\n * Initializes a new instance of the Aptos client with the provided configuration settings.\n * This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.\n *\n * @param settings - Configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify your own settings if needed\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(settings?: AptosConfig) {\n this.config = new AptosConfig(settings);\n this.account = new Account(this.config);\n this.abstraction = new AccountAbstraction(this.config);\n this.ans = new ANS(this.config);\n this.coin = new Coin(this.config);\n this.digitalAsset = new DigitalAsset(this.config);\n this.event = new Event(this.config);\n this.faucet = new Faucet(this.config);\n this.fungibleAsset = new FungibleAsset(this.config);\n this.general = new General(this.config);\n this.staking = new Staking(this.config);\n this.transaction = new Transaction(this.config);\n this.table = new Table(this.config);\n this.keyless = new Keyless(this.config);\n this.object = new AptosObject(this.config);\n }\n}\n\n// extends Aptos interface so all the methods and properties\n// from the other classes will be recognized by typescript.\nexport interface Aptos\n extends Account,\n ANS,\n Coin,\n DigitalAsset,\n Event,\n Faucet,\n FungibleAsset,\n General,\n Keyless,\n Staking,\n Table,\n AptosObject,\n Omit<Transaction, \"build\" | \"simulate\" | \"submit\" | \"batch\"> {}\n\n/**\nIn TypeScript, we can’t inherit or extend from more than one class,\nMixins helps us to get around that by creating a partial classes\nthat we can combine to form a single class that contains all the methods and properties from the partial classes.\n{@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n\nHere, we combine any subclass and the Aptos class.\n * @group Client\n*/\nfunction applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {\n // Mixin instance methods\n Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);\n if (!propertyDescriptor) return;\n // eslint-disable-next-line func-names\n propertyDescriptor.value = function (...args: any) {\n return (this as any)[baseClassProp][propertyName](...args);\n };\n Object.defineProperty(targetClass.prototype, propertyName, propertyDescriptor);\n });\n}\n\napplyMixin(Aptos, Account, \"account\");\napplyMixin(Aptos, AccountAbstraction, \"abstraction\");\napplyMixin(Aptos, ANS, \"ans\");\napplyMixin(Aptos, Coin, \"coin\");\napplyMixin(Aptos, DigitalAsset, \"digitalAsset\");\napplyMixin(Aptos, Event, \"event\");\napplyMixin(Aptos, Faucet, \"faucet\");\napplyMixin(Aptos, FungibleAsset, \"fungibleAsset\");\napplyMixin(Aptos, General, \"general\");\napplyMixin(Aptos, Staking, \"staking\");\napplyMixin(Aptos, Transaction, \"transaction\");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AOK,EAAK,KAAK,EAC5BY,EAAWjB,EAAOM,EAAM,MAAM,EAC9BW,EAAWjB,EAAOO,EAAc,cAAc,EAC9CU,EAAWjB,EAAOQ,EAAO,OAAO,EAChCS,EAAWjB,EAAOS,EAAQ,QAAQ,EAClCQ,EAAWjB,EAAOU,EAAe,eAAe,EAChDO,EAAWjB,EAAOW,EAAS,SAAS,EACpCM,EAAWjB,EAAOY,EAAS,SAAS,EACpCK,EAAWjB,EAAOa,EAAa,aAAa,EAC5CI,EAAWjB,EAAOc,EAAO,OAAO,EAChCG,EAAWjB,EAAOe,EAAS,SAAS,EACpCE,EAAWjB,EAAOgB,EAAa,QAAQ","names":["Aptos","settings","AptosConfig","Account","AccountAbstraction","ANS","Coin","DigitalAsset","Event","Faucet","FungibleAsset","General","Staking","Transaction","Table","Keyless","AptosObject","applyMixin","targetClass","baseClass","baseClassProp","propertyName","propertyDescriptor","args"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-7C2RDOWS.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as w,d as cn,e as un,g as $}from"./chunk-HEAWDTLG.mjs";import{r as sn}from"./chunk-ABXES4FS.mjs";import{a as rn}from"./chunk-3EY7MT2M.mjs";import{b as on}from"./chunk-Y3Y4DVCK.mjs";import{a as an}from"./chunk-AC3BISWL.mjs";import{a as f}from"./chunk-SCBYJU6K.mjs";import{b as D,d as R,e as M,f as T}from"./chunk-XH3BEKII.mjs";import{a as q,b as l,d as h,e as B,f as E}from"./chunk-EGZI6EJ2.mjs";import{a as tn}from"./chunk-KEJAUCQF.mjs";import{a as en}from"./chunk-4UK4MUSD.mjs";import{a as Q,c as Y,d as nn}from"./chunk-P7SE5LQE.mjs";import{c as X,d as z,e as L,f as F,g as Z,h as j,i as J}from"./chunk-J7HRQ2IH.mjs";import{a as H}from"./chunk-XKUIMGKU.mjs";import{a as O,b as V}from"./chunk-PNSF3E67.mjs";import{a as x,b as p}from"./chunk-UTXEW2FT.mjs";import{a as G}from"./chunk-GQX5KMF7.mjs";import{a as v}from"./chunk-DNWFDS7F.mjs";import{i as b,j as k}from"./chunk-G6RLN6ET.mjs";import{b as N,d as W}from"./chunk-TM6IKHMX.mjs";import{a as C}from"./chunk-YOZBVVKL.mjs";import{a as _}from"./chunk-4YLUM62M.mjs";import{g as S}from"./chunk-4RXKALLC.mjs";import{b as K,c as U}from"./chunk-RJ7F4JDV.mjs";import{j as y}from"./chunk-42T3UGSW.mjs";import{b as u}from"./chunk-Q4C4U6I4.mjs";import{b as P}from"./chunk-STY74NUA.mjs";import{sha3_256 as gn}from"@noble/hashes/sha3";async function Xn(n){if(sn(n))return hn(n);let{moduleAddress:e,moduleName:t,functionName:i}=y(n.function),r=await An({key:"entry-function",moduleAddress:e,moduleName:t,functionName:i,aptosConfig:n.aptosConfig,abi:n.abi,fetch:cn});return pn({...n,abi:r})}function pn(n){let e=n.abi,{moduleAddress:t,moduleName:i,functionName:r}=y(n.function),a=w(n.typeArguments);if(a.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${a.length}`);let o=n.functionArguments.map((s,d)=>$(n.function,e,s,d,a));if(o.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${i}::${r}', expected ${e.parameters.length} but got ${o.length}`);let c=F.build(`${t}::${i}`,r,a,o);if("multisigAddress"in n){let s=u.from(n.multisigAddress);return new L(new j(s,new J(c)))}return new z(c)}async function zn(n){let{moduleAddress:e,moduleName:t,functionName:i}=y(n.function),r=await An({key:"view-function",moduleAddress:e,moduleName:t,functionName:i,aptosConfig:n.aptosConfig,abi:n.abi,fetch:un});return ln({abi:r,...n})}function ln(n){let e=n.abi,{moduleAddress:t,moduleName:i,functionName:r}=y(n.function),a=w(n.typeArguments);if(a.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${a.length}`);let o=n?.functionArguments?.map((c,s)=>$(n.function,e,c,s,a))??[];if(o.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${i}::${r}', expected ${e.parameters.length} but got ${o.length}`);return F.build(`${t}::${i}`,r,a,o)}function hn(n){return new X(new Z(P.fromHexInput(n.bytecode).toUint8Array(),w(n.typeArguments),n.functionArguments))}async function Tn(n){let{aptosConfig:e,sender:t,payload:i,options:r,feePayerAddress:a}=n,o=async()=>S[e.network]?{chainId:S[e.network]}:{chainId:(await an({aptosConfig:e})).chain_id},c=async()=>r?.gasUnitPrice?{gasEstimate:r.gasUnitPrice}:{gasEstimate:(await on({aptosConfig:e})).gas_estimate},s=async()=>{let g=async()=>r?.accountSequenceNumber!==void 0?r.accountSequenceNumber:(await rn({aptosConfig:e,accountAddress:t})).sequence_number;if(a&&u.from(a).equals(u.ZERO))try{return await g()}catch{return 0}else return g()},[{chainId:d},{gasEstimate:m},I]=await Promise.all([o(),c(),s()]),{maxGasAmount:mn,gasUnitPrice:yn,expireTimestamp:fn}={maxGasAmount:r?.maxGasAmount?BigInt(r.maxGasAmount):BigInt(2e5),gasUnitPrice:r?.gasUnitPrice??BigInt(m),expireTimestamp:r?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+20)};return new Q(u.from(t),BigInt(I),i,BigInt(mn),BigInt(yn),BigInt(fn),new H(d))}async function Ln(n){let{aptosConfig:e,sender:t,payload:i,options:r,feePayerAddress:a}=n,o=await Tn({aptosConfig:e,sender:t,payload:i,options:r,feePayerAddress:a});if("secondarySignerAddresses"in n){let c=n.secondarySignerAddresses?.map(s=>u.from(s))??[];return new en(o,c,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new tn(o,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Zn(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:i,feePayerPublicKey:r}=n,a=A(e);if(t.feePayerAddress){let c=new nn(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),s=[];t.secondarySignerAddresses&&(i?s=i.map(I=>A(I)):s=Array.from({length:t.secondarySignerAddresses.length},()=>A(void 0)));let d=A(r),m=new M(a,t.secondarySignerAddresses??[],s,{address:t.feePayerAddress,authenticator:d});return new f(c.raw_txn,m).bcsToBytes()}if(t.secondarySignerAddresses){let c=new Y(t.rawTransaction,t.secondarySignerAddresses),s=[];i?s=i.map(m=>A(m)):s=Array.from({length:t.secondarySignerAddresses.length},()=>A(void 0));let d=new R(a,t.secondarySignerAddresses,s);return new f(c.raw_txn,d).bcsToBytes()}let o;if(a instanceof l)o=new D(a.public_key,a.signature);else if(a instanceof h||a instanceof B)o=new T(a);else if(a instanceof E)o=new T(a);else throw new Error("Invalid public key");return new f(t.rawTransaction,o).bcsToBytes()}function A(n){if(!n)return new E;let t=b.isInstance(n)||v.isInstance(n)||G.isInstance(n)?new x(n):n,i=new W(new Uint8Array(64));if(N.isInstance(t))return new l(t,i);if(x.isInstance(t))return b.isInstance(t.publicKey)?new h(t,new p(k.getSimulationSignature())):new h(t,new p(i));if(O.isInstance(t))return new B(t,new V({signatures:t.publicKeys.map(()=>new p(i)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((r,a)=>a)})}));throw new Error("Unsupported PublicKey used for simulations")}function wn(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:i}=n,r=_(q,n.senderAuthenticator),a;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");a=new M(r,e.secondarySignerAddresses??[],i??[],{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!i)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");a=new R(r,e.secondarySignerAddresses,i)}else r instanceof l?a=new D(r.public_key,r.signature):a=new T(r);return new f(e.rawTransaction,a).bcsToBytes()}function dn(n){let e=gn.create();for(let t of n)e.update(t);return e.digest()}var In=dn(["APTOS::Transaction"]);function jn(n){let e=wn(n);return new P(dn([In,new Uint8Array([0]),e])).toString()}async function An({key:n,moduleAddress:e,moduleName:t,functionName:i,aptosConfig:r,abi:a,fetch:o}){return a!==void 0?a:C(async()=>o(e,t,i,r),`${n}-${r.network}-${e}-${t}-${i}`,1e3*60*5)()}export{Xn as a,pn as b,zn as c,ln as d,Tn as e,Ln as f,Zn as g,A as h,wn as i,dn as j,jn as k};
2
- //# sourceMappingURL=chunk-7DPHPPMG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/transactions/transactionBuilder/transactionBuilder.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file handles the transaction creation lifecycle.\n * It holds different operations to generate a transaction payload, a raw transaction,\n * and a signed transaction that can be simulated, signed and submitted to chain.\n */\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { AccountAddress, AccountAddressInput, Hex, PublicKey } from \"../../core\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n Secp256k1PublicKey,\n FederatedKeylessPublicKey,\n MultiKey,\n MultiKeySignature,\n} from \"../../core/crypto\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"../../core/crypto/ed25519\";\nimport { getInfo } from \"../../internal/account\";\nimport { getLedgerInfo } from \"../../internal/general\";\nimport { getGasPriceEstimation } from \"../../internal/transaction\";\nimport { NetworkToChainId } from \"../../utils/apiEndpoints\";\nimport { DEFAULT_MAX_GAS_AMOUNT, DEFAULT_TXN_EXP_SEC_FROM_NOW } from \"../../utils/const\";\nimport { normalizeBundle } from \"../../utils/normalizeBundle\";\nimport {\n AccountAuthenticator,\n AccountAuthenticatorEd25519,\n AccountAuthenticatorMultiKey,\n AccountAuthenticatorNoAccountAuthenticator,\n AccountAuthenticatorSingleKey,\n} from \"../authenticator/account\";\nimport {\n TransactionAuthenticator,\n TransactionAuthenticatorEd25519,\n TransactionAuthenticatorFeePayer,\n TransactionAuthenticatorMultiAgent,\n TransactionAuthenticatorSingleSender,\n} from \"../authenticator/transaction\";\nimport {\n ChainId,\n EntryFunction,\n FeePayerRawTransaction,\n MultiAgentRawTransaction,\n MultiSig,\n MultiSigTransactionPayload,\n RawTransaction,\n Script,\n TransactionPayloadEntryFunction,\n TransactionPayloadMultiSig,\n TransactionPayloadScript,\n} from \"../instances\";\nimport { SignedTransaction } from \"../instances/signedTransaction\";\nimport {\n AnyRawTransaction,\n AnyTransactionPayloadInstance,\n EntryFunctionArgumentTypes,\n InputGenerateMultiAgentRawTransactionArgs,\n InputGenerateRawTransactionArgs,\n InputGenerateSingleSignerRawTransactionArgs,\n InputGenerateTransactionOptions,\n InputScriptData,\n InputSimulateTransactionData,\n InputMultiSigDataWithRemoteABI,\n InputEntryFunctionDataWithRemoteABI,\n InputGenerateTransactionPayloadDataWithRemoteABI,\n InputSubmitTransactionData,\n InputGenerateTransactionPayloadDataWithABI,\n InputEntryFunctionDataWithABI,\n InputMultiSigDataWithABI,\n InputViewFunctionDataWithRemoteABI,\n InputViewFunctionDataWithABI,\n FunctionABI,\n} from \"../types\";\nimport { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from \"./remoteAbi\";\nimport { memoizeAsync } from \"../../utils/memoize\";\nimport { isScriptDataInput } from \"./helpers\";\nimport { SimpleTransaction } from \"../instances/simpleTransaction\";\nimport { MultiAgentTransaction } from \"../instances/multiAgentTransaction\";\nimport { getFunctionParts } from \"../../utils/helpers\";\n\n/**\n * Builds a transaction payload based on the provided arguments and returns a transaction payload.\n * This function uses the RemoteABI by default, but can also utilize a specified ABI.\n * When we call our `generateTransactionPayload` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n * @param args - The input data for generating the transaction payload.\n * @param args.function - The function to be called, specified in the format \"moduleAddress::moduleName::functionName\".\n * @param args.functionArguments - The arguments to pass to the function.\n * @param args.typeArguments - The type arguments for the function.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.abi - The ABI to use for the transaction, if not using the RemoteABI.\n *\n * @returns TransactionPayload - The generated transaction payload, which can be of type TransactionPayloadScript,\n * TransactionPayloadMultiSig, or TransactionPayloadEntryFunction.\n * @group Implementation\n * @category Transactions\n */\nexport async function generateTransactionPayload(args: InputScriptData): Promise<TransactionPayloadScript>;\n/**\n * @group Implementation\n * @category Transactions\n */\nexport async function generateTransactionPayload(\n args: InputEntryFunctionDataWithRemoteABI,\n): Promise<TransactionPayloadEntryFunction>;\n/**\n * @group Implementation\n * @category Transactions\n */\nexport async function generateTransactionPayload(\n args: InputMultiSigDataWithRemoteABI,\n): Promise<TransactionPayloadMultiSig>;\n\n/**\n * Builds a transaction payload based on the data argument and returns\n * a transaction payload - TransactionPayloadScript | TransactionPayloadMultiSig | TransactionPayloadEntryFunction\n *\n * This uses the RemoteABI by default, and the remote ABI can be skipped by using generateTransactionPayloadWithABI\n *\n * @param args.data GenerateTransactionPayloadData\n *\n * @return TransactionPayload\n * @group Implementation\n * @category Transactions\n */\nexport async function generateTransactionPayload(\n args: InputGenerateTransactionPayloadDataWithRemoteABI,\n): Promise<AnyTransactionPayloadInstance> {\n if (isScriptDataInput(args)) {\n return generateTransactionPayloadScript(args);\n }\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n const functionAbi = await fetchAbi({\n key: \"entry-function\",\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig: args.aptosConfig,\n abi: args.abi,\n fetch: fetchEntryFunctionAbi,\n });\n\n // Fill in the ABI\n return generateTransactionPayloadWithABI({ ...args, abi: functionAbi });\n}\n\n/**\n * Generates a transaction payload using the provided ABI and function details.\n * This function helps create a properly structured transaction payload for executing a specific function on a module.\n *\n * @param args - The input data required to generate the transaction payload.\n * @param args.abi - The ABI of the function to be executed.\n * @param args.function - The fully qualified name of the function in the format `moduleAddress::moduleName::functionName`.\n * @param args.typeArguments - An array of type arguments that correspond to the function's type parameters.\n * @param args.functionArguments - An array of arguments to be passed to the function.\n * @param args.multisigAddress - (Optional) The address for a multisig transaction if applicable.\n *\n * @throws Error if the type argument count does not match the ABI or if the number of function arguments is incorrect.\n * @group Implementation\n * @category Transactions\n */\nexport function generateTransactionPayloadWithABI(args: InputEntryFunctionDataWithABI): TransactionPayloadEntryFunction;\n/**\n * @group Implementation\n * @category Transactions\n */\nexport function generateTransactionPayloadWithABI(args: InputMultiSigDataWithABI): TransactionPayloadMultiSig;\n/**\n * @group Implementation\n * @category Transactions\n */\nexport function generateTransactionPayloadWithABI(\n args: InputGenerateTransactionPayloadDataWithABI,\n): AnyTransactionPayloadInstance {\n const functionAbi = args.abi;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n // Ensure that all type arguments are typed properly\n const typeArguments = standardizeTypeTags(args.typeArguments);\n\n // Check the type argument count against the ABI\n if (typeArguments.length !== functionAbi.typeParameters.length) {\n throw new Error(\n `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,\n );\n }\n\n // Check all BCS types, and convert any non-BCS types\n const functionArguments: Array<EntryFunctionArgumentTypes> = args.functionArguments.map((arg, i) =>\n /**\n * Converts the argument for a specified function using its ABI and type arguments.\n * This function helps ensure that the correct number of arguments is provided for the function call.\n *\n * @param args - The arguments for the function call.\n * @param args.function - The specific function to be invoked.\n * @param functionAbi - The ABI (Application Binary Interface) of the function, which includes parameter details.\n * @param arg - The argument to be converted.\n * @param i - The index of the argument in the function call.\n * @param typeArguments - Additional type arguments that may be required for the conversion.\n * @group Implementation\n * @category Transactions\n */\n // TODO: Fix JSDoc\n convertArgument(args.function, functionAbi, arg, i, typeArguments),\n );\n\n // Check that all arguments are accounted for\n if (functionArguments.length !== functionAbi.parameters.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`,\n );\n }\n\n // Generate entry function payload\n const entryFunctionPayload = EntryFunction.build(\n `${moduleAddress}::${moduleName}`,\n functionName,\n typeArguments,\n functionArguments,\n );\n\n // Send it as multi sig if it's a multisig payload\n if (\"multisigAddress\" in args) {\n const multisigAddress = AccountAddress.from(args.multisigAddress);\n return new TransactionPayloadMultiSig(\n new MultiSig(multisigAddress, new MultiSigTransactionPayload(entryFunctionPayload)),\n );\n }\n\n // Otherwise send as an entry function\n return new TransactionPayloadEntryFunction(entryFunctionPayload);\n}\n\n/**\n * Generates the payload for a view function call using the provided arguments.\n * This function helps in preparing the necessary data to interact with a specific view function on the blockchain.\n *\n * @param args - The input data required to generate the view function payload.\n * @param args.function - The function identifier in the format \"moduleAddress::moduleName::functionName\".\n * @param args.aptosConfig - Configuration settings for the Aptos client.\n * @param args.abi - The ABI (Application Binary Interface) of the module.\n *\n * @returns The generated payload for the view function call.\n * @group Implementation\n * @category Transactions\n */\nexport async function generateViewFunctionPayload(args: InputViewFunctionDataWithRemoteABI): Promise<EntryFunction> {\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n const functionAbi = await fetchAbi({\n key: \"view-function\",\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig: args.aptosConfig,\n abi: args.abi,\n fetch: fetchViewFunctionAbi,\n });\n\n // Fill in the ABI\n return generateViewFunctionPayloadWithABI({ abi: functionAbi, ...args });\n}\n\n/**\n * Generates a payload for a view function call using the provided ABI and arguments.\n * This function ensures that the type arguments and function arguments are correctly formatted\n * and match the expected counts as defined in the ABI.\n *\n * @param args - The input data for generating the view function payload.\n * @param args.abi - The ABI of the function to be called.\n * @param args.function - The full name of the function in the format \"moduleAddress::moduleName::functionName\".\n * @param args.typeArguments - An array of type arguments to be used in the function call.\n * @param args.functionArguments - An array of arguments to be passed to the function.\n *\n * @throws Error if the type argument count does not match the ABI or if the function arguments\n * do not match the expected parameters defined in the ABI.\n * @group Implementation\n * @category Transactions\n */\nexport function generateViewFunctionPayloadWithABI(args: InputViewFunctionDataWithABI): EntryFunction {\n const functionAbi = args.abi;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n // Ensure that all type arguments are typed properly\n const typeArguments = standardizeTypeTags(args.typeArguments);\n\n // Check the type argument count against the ABI\n if (typeArguments.length !== functionAbi.typeParameters.length) {\n throw new Error(\n `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,\n );\n }\n\n // Check all BCS types, and convert any non-BCS types\n const functionArguments: Array<EntryFunctionArgumentTypes> =\n args?.functionArguments?.map((arg, i) => convertArgument(args.function, functionAbi, arg, i, typeArguments)) ?? [];\n\n // Check that all arguments are accounted for\n if (functionArguments.length !== functionAbi.parameters.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`,\n );\n }\n\n // Generate entry function payload\n return EntryFunction.build(`${moduleAddress}::${moduleName}`, functionName, typeArguments, functionArguments);\n}\n\n/**\n * Generates a transaction payload script based on the provided input data.\n * This function helps in creating a structured script for transaction processing.\n *\n * @param args - The input data required to generate the transaction payload script.\n * @param args.bytecode - The bytecode to be converted into a Uint8Array.\n * @param args.typeArguments - The type arguments that will be standardized.\n * @param args.functionArguments - The arguments for the function being called.\n * @returns A new instance of TransactionPayloadScript.\n * @group Implementation\n * @category Transactions\n */\nfunction generateTransactionPayloadScript(args: InputScriptData) {\n return new TransactionPayloadScript(\n new Script(\n Hex.fromHexInput(args.bytecode).toUint8Array(),\n standardizeTypeTags(args.typeArguments),\n args.functionArguments,\n ),\n );\n}\n\n/**\n * Generates a raw transaction that can be sent to the Aptos network.\n *\n * @param args - The arguments for generating the raw transaction.\n * @param args.aptosConfig - The configuration for the Aptos network.\n * @param args.sender - The transaction's sender account address as a hex input.\n * @param args.payload - The transaction payload, which can be created using generateTransactionPayload().\n * @param args.options - Optional parameters for transaction generation.\n * @param args.feePayerAddress - The address of the fee payer for sponsored transactions.\n *\n * @returns RawTransaction - The generated raw transaction.\n * @group Implementation\n * @category Transactions\n */\nexport async function generateRawTransaction(args: {\n aptosConfig: AptosConfig;\n sender: AccountAddressInput;\n payload: AnyTransactionPayloadInstance;\n options?: InputGenerateTransactionOptions;\n feePayerAddress?: AccountAddressInput;\n}): Promise<RawTransaction> {\n const { aptosConfig, sender, payload, options, feePayerAddress } = args;\n\n const getChainId = async () => {\n if (NetworkToChainId[aptosConfig.network]) {\n return { chainId: NetworkToChainId[aptosConfig.network] };\n }\n const info = await getLedgerInfo({ aptosConfig });\n return { chainId: info.chain_id };\n };\n\n const getGasUnitPrice = async () => {\n if (options?.gasUnitPrice) {\n return { gasEstimate: options.gasUnitPrice };\n }\n const estimation = await getGasPriceEstimation({ aptosConfig });\n return { gasEstimate: estimation.gas_estimate };\n };\n\n const getSequenceNumberForAny = async () => {\n const getSequenceNumber = async () => {\n if (options?.accountSequenceNumber !== undefined) {\n return options.accountSequenceNumber;\n }\n\n return (await getInfo({ aptosConfig, accountAddress: sender })).sequence_number;\n };\n\n /**\n * Check if is sponsored transaction to honor AIP-52\n * {@link https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-52.md}\n * @group Implementation\n * @category Transactions\n */\n if (feePayerAddress && AccountAddress.from(feePayerAddress).equals(AccountAddress.ZERO)) {\n // Handle sponsored transaction generation with the option that\n // the main signer has not been created on chain\n try {\n // Check if main signer has been created on chain, if not assign sequence number 0\n return await getSequenceNumber();\n } catch (e: any) {\n return 0;\n }\n } else {\n return getSequenceNumber();\n }\n };\n const [{ chainId }, { gasEstimate }, sequenceNumber] = await Promise.all([\n getChainId(),\n getGasUnitPrice(),\n getSequenceNumberForAny(),\n ]);\n\n const { maxGasAmount, gasUnitPrice, expireTimestamp } = {\n maxGasAmount: options?.maxGasAmount ? BigInt(options.maxGasAmount) : BigInt(DEFAULT_MAX_GAS_AMOUNT),\n gasUnitPrice: options?.gasUnitPrice ?? BigInt(gasEstimate),\n expireTimestamp: options?.expireTimestamp ?? BigInt(Math.floor(Date.now() / 1000) + DEFAULT_TXN_EXP_SEC_FROM_NOW),\n };\n\n return new RawTransaction(\n AccountAddress.from(sender),\n BigInt(sequenceNumber),\n payload,\n BigInt(maxGasAmount),\n BigInt(gasUnitPrice),\n BigInt(expireTimestamp),\n new ChainId(chainId),\n );\n}\n\n/**\n * Generates a transaction based on the provided arguments.\n * This function can create both simple and multi-agent transactions, allowing for flexible transaction handling.\n *\n * @param args - The input arguments for generating the transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.sender - The transaction's sender account address as a hex input.\n * @param args.payload - The transaction payload, which can be created using `generateTransactionPayload()`.\n * @param args.options - Optional. Transaction options object.\n * @param args.secondarySignerAddresses - Optional. An array of addresses for additional signers in a multi-signature transaction.\n * @param args.feePayerAddress - Optional. The address of the fee payer for sponsored transactions.\n * @returns An instance of a transaction, which may include secondary signer addresses and a fee payer address.\n * @group Implementation\n * @category Transactions\n */\nexport async function buildTransaction(args: InputGenerateSingleSignerRawTransactionArgs): Promise<SimpleTransaction>;\n/**\n * @group Implementation\n * @category Transactions\n */\nexport async function buildTransaction(args: InputGenerateMultiAgentRawTransactionArgs): Promise<MultiAgentTransaction>;\n\n/**\n * Generates a transaction based on the provided arguments\n *\n * Note: we can start with one function to support all different payload/transaction types,\n * and if to complex to use, we could have function for each type\n *\n * @param args.aptosConfig AptosConfig\n * @param args.sender The transaction's sender account address as a hex input\n * @param args.payload The transaction payload - can create by using generateTransactionPayload()\n * @param args.options optional. Transaction options object\n * @param args.secondarySignerAddresses optional. For when want to create a multi signers transaction\n * @param args.feePayerAddress optional. For when want to create a fee payer (aka sponsored) transaction\n *\n * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses?: Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n * @group Implementation\n * @category Transactions\n */\nexport async function buildTransaction(args: InputGenerateRawTransactionArgs): Promise<AnyRawTransaction> {\n const { aptosConfig, sender, payload, options, feePayerAddress } = args;\n // generate raw transaction\n const rawTxn = await generateRawTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n feePayerAddress,\n });\n\n // if multi agent transaction\n if (\"secondarySignerAddresses\" in args) {\n const signers: Array<AccountAddress> =\n args.secondarySignerAddresses?.map((signer) => AccountAddress.from(signer)) ?? [];\n\n return new MultiAgentTransaction(\n rawTxn,\n signers,\n args.feePayerAddress ? AccountAddress.from(args.feePayerAddress) : undefined,\n );\n }\n // return the raw transaction\n return new SimpleTransaction(rawTxn, args.feePayerAddress ? AccountAddress.from(args.feePayerAddress) : undefined);\n}\n\n/**\n * Generate a signed transaction for simulation before submitting it to the chain.\n * This function helps in preparing a transaction that can be simulated, allowing users to verify its validity and expected behavior.\n *\n * @param args - The input data required to generate the signed transaction for simulation.\n * @param args.transaction - An Aptos transaction type to sign.\n * @param args.signerPublicKey - The public key of the signer.\n * @param args.secondarySignersPublicKeys - Optional. The public keys of secondary signers if it is a multi-signer transaction.\n * @param args.feePayerPublicKey - Optional. The public key of the fee payer in a sponsored transaction.\n * @param args.options - Optional. Additional options for simulating the transaction.\n *\n * @returns A signed serialized transaction that can be simulated.\n * @group Implementation\n * @category Transactions\n */\nexport function generateSignedTransactionForSimulation(args: InputSimulateTransactionData): Uint8Array {\n const { signerPublicKey, transaction, secondarySignersPublicKeys, feePayerPublicKey } = args;\n\n const accountAuthenticator = getAuthenticatorForSimulation(signerPublicKey);\n\n // fee payer transaction\n if (transaction.feePayerAddress) {\n const transactionToSign = new FeePayerRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses ?? [],\n transaction.feePayerAddress,\n );\n let secondaryAccountAuthenticators: Array<AccountAuthenticator> = [];\n if (transaction.secondarySignerAddresses) {\n if (secondarySignersPublicKeys) {\n secondaryAccountAuthenticators = secondarySignersPublicKeys.map((publicKey) =>\n getAuthenticatorForSimulation(publicKey),\n );\n } else {\n secondaryAccountAuthenticators = Array.from({ length: transaction.secondarySignerAddresses.length }, () =>\n getAuthenticatorForSimulation(undefined),\n );\n }\n }\n const feePayerAuthenticator = getAuthenticatorForSimulation(feePayerPublicKey);\n\n const transactionAuthenticator = new TransactionAuthenticatorFeePayer(\n accountAuthenticator,\n transaction.secondarySignerAddresses ?? [],\n secondaryAccountAuthenticators,\n {\n address: transaction.feePayerAddress,\n authenticator: feePayerAuthenticator,\n },\n );\n return new SignedTransaction(transactionToSign.raw_txn, transactionAuthenticator).bcsToBytes();\n }\n\n // multi agent transaction\n if (transaction.secondarySignerAddresses) {\n const transactionToSign = new MultiAgentRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses,\n );\n\n let secondaryAccountAuthenticators: Array<AccountAuthenticator> = [];\n\n if (secondarySignersPublicKeys) {\n secondaryAccountAuthenticators = secondarySignersPublicKeys.map((publicKey) =>\n getAuthenticatorForSimulation(publicKey),\n );\n } else {\n secondaryAccountAuthenticators = Array.from({ length: transaction.secondarySignerAddresses.length }, () =>\n getAuthenticatorForSimulation(undefined),\n );\n }\n\n const transactionAuthenticator = new TransactionAuthenticatorMultiAgent(\n accountAuthenticator,\n transaction.secondarySignerAddresses,\n secondaryAccountAuthenticators,\n );\n\n return new SignedTransaction(transactionToSign.raw_txn, transactionAuthenticator).bcsToBytes();\n }\n\n // single signer raw transaction\n let transactionAuthenticator;\n if (accountAuthenticator instanceof AccountAuthenticatorEd25519) {\n transactionAuthenticator = new TransactionAuthenticatorEd25519(\n accountAuthenticator.public_key,\n accountAuthenticator.signature,\n );\n } else if (\n accountAuthenticator instanceof AccountAuthenticatorSingleKey ||\n accountAuthenticator instanceof AccountAuthenticatorMultiKey\n ) {\n transactionAuthenticator = new TransactionAuthenticatorSingleSender(accountAuthenticator);\n } else if (accountAuthenticator instanceof AccountAuthenticatorNoAccountAuthenticator) {\n transactionAuthenticator = new TransactionAuthenticatorSingleSender(accountAuthenticator);\n } else {\n throw new Error(\"Invalid public key\");\n }\n return new SignedTransaction(transaction.rawTransaction, transactionAuthenticator).bcsToBytes();\n}\n\n/**\n * @group Implementation\n * @category Transactions\n */\nexport function getAuthenticatorForSimulation(publicKey?: PublicKey) {\n if (!publicKey) {\n return new AccountAuthenticatorNoAccountAuthenticator();\n }\n\n // Wrap the public key types below with AnyPublicKey as they are only support through single sender.\n // Learn more about AnyPublicKey here - https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md\n const convertToAnyPublicKey =\n KeylessPublicKey.isInstance(publicKey) ||\n FederatedKeylessPublicKey.isInstance(publicKey) ||\n Secp256k1PublicKey.isInstance(publicKey);\n const accountPublicKey = convertToAnyPublicKey ? new AnyPublicKey(publicKey) : publicKey;\n\n // No need to for the signature to be matching in scheme. All that matters for simulations is that it's not valid\n const invalidSignature = new Ed25519Signature(new Uint8Array(64));\n\n if (Ed25519PublicKey.isInstance(accountPublicKey)) {\n return new AccountAuthenticatorEd25519(accountPublicKey, invalidSignature);\n }\n\n if (AnyPublicKey.isInstance(accountPublicKey)) {\n if (KeylessPublicKey.isInstance(accountPublicKey.publicKey)) {\n return new AccountAuthenticatorSingleKey(\n accountPublicKey,\n new AnySignature(KeylessSignature.getSimulationSignature()),\n );\n }\n return new AccountAuthenticatorSingleKey(accountPublicKey, new AnySignature(invalidSignature));\n }\n\n if (MultiKey.isInstance(accountPublicKey)) {\n return new AccountAuthenticatorMultiKey(\n accountPublicKey,\n new MultiKeySignature({\n signatures: accountPublicKey.publicKeys.map(() => new AnySignature(invalidSignature)),\n bitmap: accountPublicKey.createBitmap({\n bits: Array(accountPublicKey.publicKeys.length)\n .fill(0)\n .map((_, i) => i),\n }),\n }),\n );\n }\n\n throw new Error(\"Unsupported PublicKey used for simulations\");\n}\n\n/**\n * Generate a signed transaction ready for submission to the blockchain.\n * This function prepares the transaction by authenticating the sender and any additional signers based on the provided arguments.\n *\n * @param args - The input data required to generate the signed transaction.\n * @param args.transaction - An Aptos transaction type containing the details of the transaction.\n * @param args.senderAuthenticator - The account authenticator of the transaction sender.\n * @param args.feePayerAuthenticator - The authenticator for the fee payer, required if the transaction has a fee payer address.\n * @param args.additionalSignersAuthenticators - Optional authenticators for additional signers in a multi-signer transaction.\n *\n * @returns A Uint8Array representing the signed transaction in bytes.\n *\n * @throws Error if the feePayerAuthenticator is not provided for a fee payer transaction.\n * @throws Error if additionalSignersAuthenticators are not provided for a multi-signer transaction.\n * @group Implementation\n * @category Transactions\n */\nexport function generateSignedTransaction(args: InputSubmitTransactionData): Uint8Array {\n const { transaction, feePayerAuthenticator, additionalSignersAuthenticators } = args;\n const senderAuthenticator = normalizeBundle(AccountAuthenticator, args.senderAuthenticator);\n\n let txnAuthenticator: TransactionAuthenticator;\n if (transaction.feePayerAddress) {\n if (!feePayerAuthenticator) {\n throw new Error(\"Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction\");\n }\n txnAuthenticator = new TransactionAuthenticatorFeePayer(\n senderAuthenticator,\n transaction.secondarySignerAddresses ?? [],\n additionalSignersAuthenticators ?? [],\n {\n address: transaction.feePayerAddress,\n authenticator: feePayerAuthenticator,\n },\n );\n } else if (transaction.secondarySignerAddresses) {\n if (!additionalSignersAuthenticators) {\n throw new Error(\n \"Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction\",\n );\n }\n txnAuthenticator = new TransactionAuthenticatorMultiAgent(\n senderAuthenticator,\n transaction.secondarySignerAddresses,\n additionalSignersAuthenticators,\n );\n } else if (senderAuthenticator instanceof AccountAuthenticatorEd25519) {\n txnAuthenticator = new TransactionAuthenticatorEd25519(\n senderAuthenticator.public_key,\n senderAuthenticator.signature,\n );\n } else {\n txnAuthenticator = new TransactionAuthenticatorSingleSender(senderAuthenticator);\n }\n\n return new SignedTransaction(transaction.rawTransaction, txnAuthenticator).bcsToBytes();\n}\n\n/**\n * Hashes the set of values using a SHA-3 256 hash algorithm.\n * @param input - An array of UTF-8 strings or Uint8Array byte arrays to be hashed.\n * @group Implementation\n * @category Transactions\n */\nexport function hashValues(input: (Uint8Array | string)[]): Uint8Array {\n const hash = sha3Hash.create();\n for (const item of input) {\n hash.update(item);\n }\n return hash.digest();\n}\n\n/**\n * The domain separated prefix for hashing transactions\n * @group Implementation\n * @category Transactions\n */\nconst TRANSACTION_PREFIX = hashValues([\"APTOS::Transaction\"]);\n\n/**\n * Generates a user transaction hash for the provided transaction payload, which must already have an authenticator.\n * This function helps ensure the integrity and uniqueness of the transaction by producing a hash based on the signed transaction data.\n *\n * @param args - The input data required to submit the transaction.\n * @param args.authenticator - The authenticator for the transaction.\n * @param args.payload - The payload containing the transaction details.\n * @param args.sender - The address of the sender initiating the transaction.\n * @param args.sequenceNumber - The sequence number of the transaction for the sender.\n * @group Implementation\n * @category Transactions\n */\nexport function generateUserTransactionHash(args: InputSubmitTransactionData): string {\n const signedTransaction = generateSignedTransaction(args);\n\n // Transaction signature is defined as, the domain separated prefix based on struct (Transaction)\n // Then followed by the type of the transaction for the enum, UserTransaction is 0\n // Then followed by BCS encoded bytes of the signed transaction\n return new Hex(hashValues([TRANSACTION_PREFIX, new Uint8Array([0]), signedTransaction])).toString();\n}\n\n/**\n * Fetches and caches ABIs while allowing for pass-through on provided ABIs.\n *\n * @param key - A unique identifier for the cached ABI.\n * @param moduleAddress - The address of the module from which to fetch the ABI.\n * @param moduleName - The name of the module containing the function.\n * @param functionName - The name of the function whose ABI is being fetched.\n * @param aptosConfig - Configuration settings for Aptos.\n * @param abi - An optional ABI to use if already available.\n * @param fetch - A function to fetch the ABI if it is not provided.\n * @group Implementation\n * @category Transactions\n */\nasync function fetchAbi<T extends FunctionABI>({\n key,\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig,\n abi,\n fetch,\n}: {\n key: string;\n moduleAddress: string;\n moduleName: string;\n functionName: string;\n aptosConfig: AptosConfig;\n abi?: T;\n fetch: (moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig) => Promise<T>;\n}): Promise<T> {\n if (abi !== undefined) {\n return abi;\n }\n\n // We fetch the entry function ABI, and then pretend that we already had the ABI\n return memoizeAsync(\n async () => fetch(moduleAddress, moduleName, functionName, aptosConfig),\n `${key}-${aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n"],"mappings":"otCAQA,OAAS,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A,IAAMG,GAAqBL,GAAW,CAAC,oBAAoB,CAAC,EAcrD,SAASM,GAA4B3G,EAA0C,CACpF,IAAM4G,EAAoBb,GAA0B/F,CAAI,EAKxD,OAAO,IAAI8B,EAAIuE,GAAW,CAACK,GAAoB,IAAI,WAAW,CAAC,CAAC,CAAC,EAAGE,CAAiB,CAAC,CAAC,EAAE,SAAS,CACpG,CAeA,eAAepG,GAAgC,CAC7C,IAAAqG,EACA,cAAA1G,EACA,WAAAC,EACA,aAAAC,EACA,YAAA2B,EACA,IAAA8E,EACA,MAAAC,CACF,EAQe,CACb,OAAID,IAAQ,OACHA,EAIFE,EACL,SAAYD,EAAM5G,EAAeC,EAAYC,EAAc2B,CAAW,EACtE,GAAG6E,CAAG,IAAI7E,EAAY,OAAO,IAAI7B,CAAa,IAAIC,CAAU,IAAIC,CAAY,GAC5E,IAAO,GAAK,CACd,EAAE,CACJ","names":["sha3Hash","generateTransactionPayload","args","isScriptDataInput","generateTransactionPayloadScript","moduleAddress","moduleName","functionName","getFunctionParts","functionAbi","fetchAbi","fetchEntryFunctionAbi","generateTransactionPayloadWithABI","typeArguments","standardizeTypeTags","functionArguments","arg","i","convertArgument","entryFunctionPayload","EntryFunction","multisigAddress","AccountAddress","TransactionPayloadMultiSig","MultiSig","MultiSigTransactionPayload","TransactionPayloadEntryFunction","generateViewFunctionPayload","fetchViewFunctionAbi","generateViewFunctionPayloadWithABI","TransactionPayloadScript","Script","Hex","generateRawTransaction","aptosConfig","sender","payload","options","feePayerAddress","getChainId","NetworkToChainId","getLedgerInfo","getGasUnitPrice","getGasPriceEstimation","getSequenceNumberForAny","getSequenceNumber","getInfo","chainId","gasEstimate","sequenceNumber","maxGasAmount","gasUnitPrice","expireTimestamp","RawTransaction","ChainId","buildTransaction","rawTxn","signers","signer","MultiAgentTransaction","SimpleTransaction","generateSignedTransactionForSimulation","signerPublicKey","transaction","secondarySignersPublicKeys","feePayerPublicKey","accountAuthenticator","getAuthenticatorForSimulation","transactionToSign","FeePayerRawTransaction","secondaryAccountAuthenticators","publicKey","feePayerAuthenticator","transactionAuthenticator","TransactionAuthenticatorFeePayer","SignedTransaction","MultiAgentRawTransaction","TransactionAuthenticatorMultiAgent","AccountAuthenticatorEd25519","TransactionAuthenticatorEd25519","AccountAuthenticatorSingleKey","AccountAuthenticatorMultiKey","TransactionAuthenticatorSingleSender","AccountAuthenticatorNoAccountAuthenticator","accountPublicKey","KeylessPublicKey","FederatedKeylessPublicKey","Secp256k1PublicKey","AnyPublicKey","invalidSignature","Ed25519Signature","Ed25519PublicKey","AnySignature","KeylessSignature","MultiKey","MultiKeySignature","_","generateSignedTransaction","additionalSignersAuthenticators","senderAuthenticator","normalizeBundle","AccountAuthenticator","txnAuthenticator","hashValues","input","hash","sha3Hash","item","TRANSACTION_PREFIX","generateUserTransactionHash","signedTransaction","key","abi","fetch","memoizeAsync"]}
@@ -1,2 +0,0 @@
1
- import{a as t}from"./chunk-2FNFUTFJ.mjs";import{a as p}from"./chunk-CSG67JHZ.mjs";import{e as s}from"./chunk-7DPHPPMG.mjs";import{a as i}from"./chunk-KEJAUCQF.mjs";import{c as a}from"./chunk-J7HRQ2IH.mjs";import{b as r}from"./chunk-Q4C4U6I4.mjs";import{a as e}from"./chunk-XTOIL6MB.mjs";var c=class{constructor(n){this.config=n}async simple(n){return t({aptosConfig:this.config,...n})}async scriptComposer(n){let o=new p(this.config);await o.init();let d=(await n.builder(o)).build(),u=await s({aptosConfig:this.config,payload:a.load(new e(d)),...n});return new i(u,n.withFeePayer===!0?r.ZERO:void 0)}async multiAgent(n){return t({aptosConfig:this.config,...n})}};export{c as a};
2
- //# sourceMappingURL=chunk-DNJQWGB7.mjs.map
@@ -1,2 +0,0 @@
1
- import{b as t}from"./chunk-STY74NUA.mjs";var o=n=>typeof n=="string"?t.isValid(n).valid?n:new TextEncoder().encode(n):n;export{o as a};
2
- //# sourceMappingURL=chunk-DPW6ELCQ.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as e}from"./chunk-EBMEXURY.mjs";import{b as r}from"./chunk-STY74NUA.mjs";var t=class extends e{toUint8Array(){return this.bcsToBytes()}toString(){let n=this.toUint8Array();return r.fromHexInput(n).toString()}},a=class extends t{};export{t as a,a as b};
2
- //# sourceMappingURL=chunk-EMURYYVO.mjs.map
@@ -1,2 +0,0 @@
1
- var o="1.34.0";export{o as a};
2
- //# sourceMappingURL=chunk-EY2JUXEC.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as o,b as n,c as i,d as r,e as t}from"./chunk-4RXKALLC.mjs";import f from"@aptos-labs/aptos-client";var s=class{constructor(e){this.network=e?.network??"devnet",this.fullnode=e?.fullnode,this.faucet=e?.faucet,this.pepper=e?.pepper,this.prover=e?.prover,this.indexer=e?.indexer,this.client=e?.client??{provider:f},this.clientConfig=e?.clientConfig??{},this.fullnodeConfig=e?.fullnodeConfig??{},this.indexerConfig=e?.indexerConfig??{},this.faucetConfig=e?.faucetConfig??{}}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return n[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return i[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return o[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return r[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return t[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return r[this.network]===e}isProverServiceRequest(e){return t[this.network]===e}};export{s as a};
2
- //# sourceMappingURL=chunk-F2ZTBAJJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/aptosConfig.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport aptosClient from \"@aptos-labs/aptos-client\";\nimport { AptosSettings, ClientConfig, Client, FullNodeConfig, IndexerConfig, FaucetConfig } from \"../types\";\nimport {\n NetworkToNodeAPI,\n NetworkToFaucetAPI,\n NetworkToIndexerAPI,\n Network,\n NetworkToPepperAPI,\n NetworkToProverAPI,\n} from \"../utils/apiEndpoints\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Represents the configuration settings for an Aptos SDK client instance.\n * This class allows customization of various endpoints and client settings.\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 connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class AptosConfig {\n /**\n * The Network that this SDK is associated with. Defaults to DEVNET\n * @group Client\n */\n readonly network: Network;\n\n /**\n * The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client\n * @group Client\n */\n readonly client: Client;\n\n /**\n * The optional hardcoded fullnode URL to send requests to instead of using the network\n * @group Client\n */\n readonly fullnode?: string;\n\n /**\n * The optional hardcoded faucet URL to send requests to instead of using the network\n * @group Client\n */\n readonly faucet?: string;\n\n /**\n * The optional hardcoded pepper service URL to send requests to instead of using the network\n * @group Client\n */\n readonly pepper?: string;\n\n /**\n * The optional hardcoded prover service URL to send requests to instead of using the network\n * @group Client\n */\n readonly prover?: string;\n\n /**\n * The optional hardcoded indexer URL to send requests to instead of using the network\n * @group Client\n */\n readonly indexer?: string;\n\n /**\n * Optional client configurations\n * @group Client\n */\n readonly clientConfig?: ClientConfig;\n\n /**\n * Optional specific Fullnode configurations\n * @group Client\n */\n readonly fullnodeConfig?: FullNodeConfig;\n\n /**\n * Optional specific Indexer configurations\n * @group Client\n */\n readonly indexerConfig?: IndexerConfig;\n\n /**\n * Optional specific Faucet configurations\n * @group Client\n */\n readonly faucetConfig?: FaucetConfig;\n\n /**\n * Initializes an instance of the Aptos client with the specified settings.\n * This allows users to configure various aspects of the client, such as network and endpoints.\n *\n * @param settings - Optional configuration settings for the Aptos client.\n * @param settings.network - The network to connect to, defaults to `Network.DEVNET`.\n * @param settings.fullnode - The fullnode endpoint to use for requests.\n * @param settings.faucet - The faucet endpoint for obtaining test tokens.\n * @param settings.pepper - The pepper used for transaction signing.\n * @param settings.prover - The prover endpoint for transaction verification.\n * @param settings.indexer - The indexer endpoint for querying blockchain data.\n * @param settings.client - Custom client settings, defaults to a standard Aptos client.\n * @param settings.clientConfig - Additional configuration for the client.\n * @param settings.fullnodeConfig - Additional configuration for the fullnode.\n * @param settings.indexerConfig - Additional configuration for the indexer.\n * @param settings.faucetConfig - Additional configuration for the faucet.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify the network\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(settings?: AptosSettings) {\n this.network = settings?.network ?? Network.DEVNET;\n this.fullnode = settings?.fullnode;\n this.faucet = settings?.faucet;\n this.pepper = settings?.pepper;\n this.prover = settings?.prover;\n this.indexer = settings?.indexer;\n this.client = settings?.client ?? { provider: aptosClient };\n this.clientConfig = settings?.clientConfig ?? {};\n this.fullnodeConfig = settings?.fullnodeConfig ?? {};\n this.indexerConfig = settings?.indexerConfig ?? {};\n this.faucetConfig = settings?.faucetConfig ?? {};\n }\n\n /**\n * Returns the URL endpoint to send the request to based on the specified API type.\n * If a custom URL was provided in the configuration, that URL is returned. Otherwise, the URL endpoint is derived from the network.\n *\n * @param apiType - The type of Aptos API to get the URL for. This can be one of the following: FULLNODE, FAUCET, INDEXER, PEPPER, PROVER.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, AptosApiType } 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 * // Getting the request URL for the FULLNODE API\n * const url = config.getRequestUrl(AptosApiType.FULLNODE);\n * console.log(\"Request URL for FULLNODE:\", url);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n getRequestUrl(apiType: AptosApiType): string {\n switch (apiType) {\n case AptosApiType.FULLNODE:\n if (this.fullnode !== undefined) return this.fullnode;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom full node url\");\n return NetworkToNodeAPI[this.network];\n case AptosApiType.FAUCET:\n if (this.faucet !== undefined) return this.faucet;\n if (this.network === Network.TESTNET) {\n throw new Error(\n \"There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet\",\n );\n }\n if (this.network === Network.MAINNET) {\n throw new Error(\"There is no mainnet faucet\");\n }\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom faucet url\");\n return NetworkToFaucetAPI[this.network];\n case AptosApiType.INDEXER:\n if (this.indexer !== undefined) return this.indexer;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom indexer url\");\n return NetworkToIndexerAPI[this.network];\n case AptosApiType.PEPPER:\n if (this.pepper !== undefined) return this.pepper;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom pepper service url\");\n return NetworkToPepperAPI[this.network];\n case AptosApiType.PROVER:\n if (this.prover !== undefined) return this.prover;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom prover service url\");\n return NetworkToProverAPI[this.network];\n default:\n throw Error(`apiType ${apiType} is not supported`);\n }\n }\n\n /**\n * Checks if the provided URL is a known pepper service endpoint.\n *\n * @param url - The URL to check against the known pepper service endpoints.\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 * const url = \"https://example.pepper.service\"; // replace with a real pepper service URL\n *\n * // Check if the URL is a known pepper service endpoint\n * const isPepperService = config.isPepperServiceRequest(url);\n *\n * console.log(`Is the URL a known pepper service? ${isPepperService}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n isPepperServiceRequest(url: string): boolean {\n return NetworkToPepperAPI[this.network] === url;\n }\n\n /**\n * Checks if the provided URL is a known prover service endpoint.\n *\n * @param url - The URL to check against known prover service endpoints.\n * @returns A boolean indicating whether the URL is a known prover service endpoint.\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 * // Check if the URL is a known prover service endpoint\n * const url = \"https://prover.testnet.aptos.dev\"; // replace with a real URL if needed\n * const isProver = config.isProverServiceRequest(url);\n *\n * console.log(`Is the URL a known prover service? ${isProver}`);\n * ```\n * @group Client\n */\n isProverServiceRequest(url: string): boolean {\n return NetworkToProverAPI[this.network] === url;\n }\n}\n"],"mappings":"qEAGA,OAAOA,MAAiB,2BAiCjB,IAAMC,EAAN,KAAkB,CAmGvB,YAAYC,EAA0B,CACpC,KAAK,QAAUA,GAAU,SAAW,SACpC,KAAK,SAAWA,GAAU,SAC1B,KAAK,OAASA,GAAU,OACxB,KAAK,OAASA,GAAU,OACxB,KAAK,OAASA,GAAU,OACxB,KAAK,QAAUA,GAAU,QACzB,KAAK,OAASA,GAAU,QAAU,CAAE,SAAUC,CAAY,EAC1D,KAAK,aAAeD,GAAU,cAAgB,CAAC,EAC/C,KAAK,eAAiBA,GAAU,gBAAkB,CAAC,EACnD,KAAK,cAAgBA,GAAU,eAAiB,CAAC,EACjD,KAAK,aAAeA,GAAU,cAAgB,CAAC,CACjD,CAwBA,cAAcE,EAA+B,CAC3C,OAAQA,EAAS,CACf,eACE,GAAI,KAAK,WAAa,OAAW,OAAO,KAAK,SAC7C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,uCAAuC,EAC5F,OAAOC,EAAiB,KAAK,OAAO,EACtC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,UACnB,MAAM,IAAI,MACR,yHACF,EAEF,GAAI,KAAK,UAAY,UACnB,MAAM,IAAI,MAAM,4BAA4B,EAE9C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,oCAAoC,EACzF,OAAOC,EAAmB,KAAK,OAAO,EACxC,cACE,GAAI,KAAK,UAAY,OAAW,OAAO,KAAK,QAC5C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,qCAAqC,EAC1F,OAAOC,EAAoB,KAAK,OAAO,EACzC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,QACE,MAAM,MAAM,WAAWL,CAAO,mBAAmB,CACrD,CACF,CA0BA,uBAAuBM,EAAsB,CAC3C,OAAOF,EAAmB,KAAK,OAAO,IAAME,CAC9C,CAuBA,uBAAuBA,EAAsB,CAC3C,OAAOD,EAAmB,KAAK,OAAO,IAAMC,CAC9C,CACF","names":["aptosClient","AptosConfig","settings","aptosClient","apiType","NetworkToNodeAPI","NetworkToFaucetAPI","NetworkToIndexerAPI","NetworkToPepperAPI","NetworkToProverAPI","url"]}
@@ -1,2 +0,0 @@
1
- import{b as h,d as l}from"./chunk-TM6IKHMX.mjs";import{b as E}from"./chunk-EMURYYVO.mjs";import{a as p}from"./chunk-WCMW2L3P.mjs";import{a as g}from"./chunk-FN4C3CKC.mjs";var o=class o extends E{constructor(r){super();let{publicKeys:e,threshold:t}=r;if(e.length>o.MAX_KEYS||e.length<o.MIN_KEYS)throw new Error(`Must have between ${o.MIN_KEYS} and ${o.MAX_KEYS} public keys, inclusive`);if(t<o.MIN_THRESHOLD||t>e.length)throw new Error(`Threshold must be between ${o.MIN_THRESHOLD} and ${e.length}, inclusive`);this.publicKeys=e,this.threshold=t}verifySignature(r){let{message:e,signature:t}=r;if(!(t instanceof y))return!1;let s=[];for(let i=0;i<4;i+=1)for(let n=0;n<8;n+=1)if((t.bitmap[i]&1<<7-n)!==0){let u=i*8+n;s.push(u)}if(s.length!==t.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(s.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<s.length;i+=1)if(!this.publicKeys[s[i]].verifySignature({message:e,signature:t.signatures[i]}))return!1;return!0}authKey(){return g.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let r=new Uint8Array(this.publicKeys.length*h.LENGTH+1);return this.publicKeys.forEach((e,t)=>{r.set(e.toUint8Array(),t*h.LENGTH)}),r[this.publicKeys.length*h.LENGTH]=this.threshold,r}serialize(r){r.serializeBytes(this.toUint8Array())}static deserialize(r){let e=r.deserializeBytes(),t=e[e.length-1],s=[];for(let i=0;i<e.length-1;i+=h.LENGTH){let n=i;s.push(new h(e.subarray(n,n+h.LENGTH)))}return new o({publicKeys:s,threshold:t})}};o.MAX_KEYS=32,o.MIN_KEYS=2,o.MIN_THRESHOLD=1;var d=o,a=class a extends p{constructor(r){super();let{signatures:e,bitmap:t}=r;if(e.length>a.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${a.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=e,!(t instanceof Uint8Array))this.bitmap=a.createBitmap({bits:t});else{if(t.length!==a.BITMAP_LEN)throw new Error(`"bitmap" length should be ${a.BITMAP_LEN}`);this.bitmap=t}}toUint8Array(){let r=new Uint8Array(this.signatures.length*l.LENGTH+a.BITMAP_LEN);return this.signatures.forEach((e,t)=>{r.set(e.toUint8Array(),t*l.LENGTH)}),r.set(this.bitmap,this.signatures.length*l.LENGTH),r}serialize(r){r.serializeBytes(this.toUint8Array())}static deserialize(r){let e=r.deserializeBytes(),t=e.subarray(e.length-4),s=[];for(let i=0;i<e.length-t.length;i+=l.LENGTH){let n=i;s.push(new l(e.subarray(n,n+l.LENGTH)))}return new a({signatures:s,bitmap:t})}static createBitmap(r){let{bits:e}=r,t=128,s=new Uint8Array([0,0,0,0]),i=new Set;return e.forEach((n,c)=>{if(n>=a.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${a.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(n))throw new Error("Duplicate bits detected.");if(c>0&&n<=e[c-1])throw new Error("The bits need to be sorted in ascending order.");i.add(n);let u=Math.floor(n/8),b=s[u];b|=t>>n%8,s[u]=b}),s}};a.MAX_SIGNATURES_SUPPORTED=32,a.BITMAP_LEN=4;var y=a;export{d as a,y as b};
2
- //# sourceMappingURL=chunk-I7YHK6ZF.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/multiEd25519.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Deserializer, Serializer } from \"../../bcs\";\nimport { SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { AccountPublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents the public key of a K-of-N Ed25519 multi-sig transaction.\n *\n * A K-of-N multi-sig transaction requires at least K out of N authorized signers to sign the transaction\n * for it to be executed. This class encapsulates the logic for managing the public keys and the threshold\n * for valid signatures.\n *\n * @see {@link https://aptos.dev/integration/creating-a-signed-transaction/ | Creating a Signed Transaction}\n * @group Implementation\n * @category Serialization\n */\nexport class MultiEd25519PublicKey extends AccountPublicKey {\n /**\n * Maximum number of public keys supported\n * @group Implementation\n * @category Serialization\n */\n static readonly MAX_KEYS = 32;\n\n /**\n * Minimum number of public keys needed\n * @group Implementation\n * @category Serialization\n */\n static readonly MIN_KEYS = 2;\n\n /**\n * Minimum threshold for the number of valid signatures required\n * @group Implementation\n * @category Serialization\n */\n static readonly MIN_THRESHOLD = 1;\n\n /**\n * List of Ed25519 public keys for this LegacyMultiEd25519PublicKey\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKeys: Ed25519PublicKey[];\n\n /**\n * The minimum number of valid signatures required, for the number of public keys specified\n * @group Implementation\n * @category Serialization\n */\n public readonly threshold: number;\n\n /**\n * Public key for a K-of-N multi-sig transaction. A K-of-N multi-sig transaction means that for such a\n * transaction to be executed, at least K out of the N authorized signers have signed the transaction\n * and passed the check conducted by the chain.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/ | Creating a Signed Transaction}\n * @param args - A wrapper to let you choose the param order.\n * @param args.publicKeys A list of public keys\n * @param args.threshold At least \"threshold\" signatures must be valid\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { publicKeys: Ed25519PublicKey[]; threshold: number }) {\n super();\n const { publicKeys, threshold } = args;\n\n // Validate number of public keys\n if (publicKeys.length > MultiEd25519PublicKey.MAX_KEYS || publicKeys.length < MultiEd25519PublicKey.MIN_KEYS) {\n throw new Error(\n `Must have between ${MultiEd25519PublicKey.MIN_KEYS} and ` +\n `${MultiEd25519PublicKey.MAX_KEYS} public keys, inclusive`,\n );\n }\n\n // Validate threshold: must be between 1 and the number of public keys, inclusive\n if (threshold < MultiEd25519PublicKey.MIN_THRESHOLD || threshold > publicKeys.length) {\n throw new Error(\n `Threshold must be between ${MultiEd25519PublicKey.MIN_THRESHOLD} and ${publicKeys.length}, inclusive`,\n );\n }\n\n this.publicKeys = publicKeys;\n this.threshold = threshold;\n }\n\n // region AccountPublicKey\n\n /**\n * Verifies a multi-signature against a given message.\n * This function ensures that the provided signatures meet the required threshold and are valid for the given message.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The multi-signature containing multiple signatures and a bitmap indicating which signatures are valid.\n * @returns True if the signature is valid; otherwise, false.\n * @throws Error if the bitmap and signatures length mismatch or if there are not enough valid signatures.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n const { message, signature } = args;\n if (!(signature instanceof MultiEd25519Signature)) {\n return false;\n }\n\n const indices: number[] = [];\n for (let i = 0; i < 4; i += 1) {\n for (let j = 0; j < 8; j += 1) {\n // eslint-disable-next-line no-bitwise\n const bitIsSet = (signature.bitmap[i] & (1 << (7 - j))) !== 0;\n if (bitIsSet) {\n const index = i * 8 + j;\n indices.push(index);\n }\n }\n }\n\n if (indices.length !== signature.signatures.length) {\n throw new Error(\"Bitmap and signatures length mismatch\");\n }\n\n if (indices.length < this.threshold) {\n throw new Error(\"Not enough signatures\");\n }\n\n for (let i = 0; i < indices.length; i += 1) {\n const publicKey = this.publicKeys[indices[i]];\n if (!publicKey.verifySignature({ message, signature: signature.signatures[i] })) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Generates an authentication key based on the current instance's byte representation.\n * This function is essential for creating a secure authentication key that can be used for various cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.MultiEd25519,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Converts a PublicKeys into Uint8Array (bytes) with: bytes = p1_bytes | ... | pn_bytes | threshold\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n const bytes = new Uint8Array(this.publicKeys.length * Ed25519PublicKey.LENGTH + 1);\n this.publicKeys.forEach((k: Ed25519PublicKey, i: number) => {\n bytes.set(k.toUint8Array(), i * Ed25519PublicKey.LENGTH);\n });\n\n bytes[this.publicKeys.length * Ed25519PublicKey.LENGTH] = this.threshold;\n\n return bytes;\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the current instance into bytes using the provided serializer.\n * This allows for the conversion of the instance's data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to convert the instance into bytes.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n /**\n * Deserializes a MultiEd25519Signature from the provided deserializer.\n * This function helps in reconstructing a MultiEd25519Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): MultiEd25519PublicKey {\n const bytes = deserializer.deserializeBytes();\n const threshold = bytes[bytes.length - 1];\n\n const keys: Ed25519PublicKey[] = [];\n\n for (let i = 0; i < bytes.length - 1; i += Ed25519PublicKey.LENGTH) {\n const begin = i;\n keys.push(new Ed25519PublicKey(bytes.subarray(begin, begin + Ed25519PublicKey.LENGTH)));\n }\n return new MultiEd25519PublicKey({ publicKeys: keys, threshold });\n }\n\n // endregion\n}\n\n/**\n * Represents the signature of a K-of-N Ed25519 multi-sig transaction.\n *\n * @see {@link https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n * @group Implementation\n * @category Serialization\n */\nexport class MultiEd25519Signature extends Signature {\n /**\n * Maximum number of Ed25519 signatures supported\n * @group Implementation\n * @category Serialization\n */\n static MAX_SIGNATURES_SUPPORTED = 32;\n\n /**\n * Number of bytes in the bitmap representing who signed the transaction (32-bits)\n * @group Implementation\n * @category Serialization\n */\n static BITMAP_LEN: number = 4;\n\n /**\n * The list of underlying Ed25519 signatures\n * @group Implementation\n * @category Serialization\n */\n public readonly signatures: Ed25519Signature[];\n\n /**\n * 32-bit Bitmap representing who signed the transaction\n *\n * This is represented where each public key can be masked to determine whether the message was signed by that key.\n * @group Implementation\n * @category Serialization\n */\n public readonly bitmap: Uint8Array;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n *\n * @param args.signatures A list of signatures\n * @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth\n * signature should be provided in `signatures`. Bits are read from left to right.\n * Alternatively, you can specify an array of bitmap positions.\n * Valid position should range between 0 and 31.\n * @see MultiEd25519Signature.createBitmap\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { signatures: Ed25519Signature[]; bitmap: Uint8Array | number[] }) {\n super();\n const { signatures, bitmap } = args;\n\n if (signatures.length > MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(\n `The number of signatures cannot be greater than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED}`,\n );\n }\n this.signatures = signatures;\n\n if (!(bitmap instanceof Uint8Array)) {\n this.bitmap = MultiEd25519Signature.createBitmap({ bits: bitmap });\n } else if (bitmap.length !== MultiEd25519Signature.BITMAP_LEN) {\n throw new Error(`\"bitmap\" length should be ${MultiEd25519Signature.BITMAP_LEN}`);\n } else {\n this.bitmap = bitmap;\n }\n }\n\n // region AccountSignature\n\n /**\n * Converts a MultiSignature into Uint8Array (bytes) with `bytes = s1_bytes | ... | sn_bytes | bitmap`\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n const bytes = new Uint8Array(this.signatures.length * Ed25519Signature.LENGTH + MultiEd25519Signature.BITMAP_LEN);\n this.signatures.forEach((k: Ed25519Signature, i: number) => {\n bytes.set(k.toUint8Array(), i * Ed25519Signature.LENGTH);\n });\n\n bytes.set(this.bitmap, this.signatures.length * Ed25519Signature.LENGTH);\n\n return bytes;\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): MultiEd25519Signature {\n const bytes = deserializer.deserializeBytes();\n const bitmap = bytes.subarray(bytes.length - 4);\n\n const signatures: Ed25519Signature[] = [];\n\n for (let i = 0; i < bytes.length - bitmap.length; i += Ed25519Signature.LENGTH) {\n const begin = i;\n signatures.push(new Ed25519Signature(bytes.subarray(begin, begin + Ed25519Signature.LENGTH)));\n }\n return new MultiEd25519Signature({ signatures, bitmap });\n }\n\n // endregion\n\n /**\n * Helper method to create a bitmap out of the specified bit positions.\n * This function allows you to set specific bits in a 32-bit long bitmap based on the provided positions.\n *\n * @param args The arguments for creating the bitmap.\n * @param args.bits The bitmap positions that should be set. A position starts at index 0. Valid positions should range between 0 and 31.\n *\n * @example\n * Here's an example of valid `bits`\n * ```\n * [0, 2, 31]\n * ```\n * `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.\n * The result bitmap should be 0b1010000000000000000000000000001\n *\n * @returns bitmap that is 32 bits long.\n * @group Implementation\n * @category Serialization\n */\n static createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number, index) => {\n if (bit >= MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`Cannot have a signature larger than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED - 1}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(\"Duplicate bits detected.\");\n }\n\n if (index > 0 && bit <= bits[index - 1]) {\n throw new Error(\"The bits need to be sorted in ascending order.\");\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-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GAAKmB,GAAOH,EAAKhB,EAAQ,CAAC,EACpC,MAAM,IAAI,MAAM,gDAAgD,EAGlEkB,EAAY,IAAIC,CAAG,EAEnB,IAAMC,EAAa,KAAK,MAAMD,EAAM,CAAC,EAEjCE,EAAOP,EAAOM,CAAU,EAG5BC,GAAQJ,GAAkBE,EAAM,EAEhCL,EAAOM,CAAU,EAAIC,CACvB,CAAC,EAEMP,CACT,CACF,EAnKaH,EAMJ,yBAA2B,GANvBA,EAaJ,WAAqB,EAbvB,IAAMd,EAANc","names":["_MultiEd25519PublicKey","AccountPublicKey","args","publicKeys","threshold","message","signature","MultiEd25519Signature","indices","j","index","AuthenticationKey","bytes","Ed25519PublicKey","k","i","serializer","deserializer","keys","begin","MultiEd25519PublicKey","_MultiEd25519Signature","Signature","signatures","bitmap","Ed25519Signature","bits","firstBitInByte","dupCheckSet","bit","byteOffset","byte"]}
@@ -1,2 +0,0 @@
1
- import{a as o,b as l}from"./chunk-UTXEW2FT.mjs";import{b as m}from"./chunk-EMURYYVO.mjs";import{a as g}from"./chunk-WCMW2L3P.mjs";import{a as y}from"./chunk-FN4C3CKC.mjs";function d(h){let e=h;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var p=class h extends m{constructor(e){super();let{publicKeys:r,signaturesRequired:t}=e;if(t<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<t)throw new Error(`Provided ${r.length} public keys is smaller than the ${t} required signatures`);this.publicKeys=r.map(i=>i instanceof o?i:new o(i)),this.signaturesRequired=t}verifySignature(e){throw new Error("not implemented")}authKey(){return y.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(o),t=e.deserializeU8();return new h({publicKeys:r,signaturesRequired:t})}createBitmap(e){let{bits:r}=e,t=128,i=new Uint8Array([0,0,0,0]),a=new Set;return r.forEach((n,u)=>{if(u+1>this.publicKeys.length)throw new Error(`Signature index ${u+1} is out of public keys range, ${this.publicKeys.length}.`);if(a.has(n))throw new Error(`Duplicate bit ${n} detected.`);a.add(n);let c=Math.floor(n/8),b=i[c];b|=t>>n%8,i[c]=b}),i}getIndex(e){let r=e instanceof o?e:new o(e),t=this.publicKeys.findIndex(i=>i.toString()===r.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in MultiKey ${this.publicKeys}`)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},s=class s extends g{constructor(e){super();let{signatures:r,bitmap:t}=e;if(r.length>s.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${s.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(a=>a instanceof l?a:new l(a)),!(t instanceof Uint8Array))this.bitmap=s.createBitmap({bits:t});else{if(t.length!==s.BITMAP_LEN)throw new Error(`"bitmap" length should be ${s.BITMAP_LEN}`);this.bitmap=t}let i=this.bitmap.reduce((a,n)=>a+d(n),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,t=128,i=new Uint8Array([0,0,0,0]),a=new Set;return r.forEach(n=>{if(n>=s.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${s.MAX_SIGNATURES_SUPPORTED-1}.`);if(a.has(n))throw new Error("Duplicate bits detected.");a.add(n);let u=Math.floor(n/8),c=i[u];c|=t>>n%8,i[u]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeVector(l),t=e.deserializeBytes();return new s({signatures:r,bitmap:t})}};s.BITMAP_LEN=4,s.MAX_SIGNATURES_SUPPORTED=s.BITMAP_LEN*8;var f=s;export{p as a,f as b};
2
- //# sourceMappingURL=chunk-PNSF3E67.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/multiKey.ts"],"sourcesContent":["import { SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { AnyPublicKey, AnySignature } from \"./singleKey\";\n\n/**\n * Counts the number of set bits (1s) in a byte.\n * This function can help you determine the population count of a given byte value.\n *\n * @param byte - The byte value for which to count the number of set bits.\n * @group Implementation\n * @category Serialization\n */\n/* eslint-disable no-bitwise */\nfunction bitCount(byte: number) {\n let n = byte;\n n -= (n >> 1) & 0x55555555;\n n = (n & 0x33333333) + ((n >> 2) & 0x33333333);\n return (((n + (n >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;\n}\n/* eslint-enable no-bitwise */\n\n/**\n * Represents a multi-key authentication scheme for accounts, allowing multiple public keys\n * to be associated with a single account. This class enforces a minimum number of valid signatures\n * required to authorize actions, ensuring enhanced security for multi-agent accounts.\n *\n * The public keys of each individual agent can be any type of public key supported by Aptos.\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263), Aptos supports\n * `Legacy` and `Unified` authentication keys.\n * @group Implementation\n * @category Serialization\n */\nexport class MultiKey extends AccountPublicKey {\n /**\n * List of any public keys\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKeys: AnyPublicKey[];\n\n /**\n * The minimum number of valid signatures required, for the number of public keys specified\n * @group Implementation\n * @category Serialization\n */\n public readonly signaturesRequired: number;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n * This constructor initializes a multi-signature transaction with the provided signatures and bitmap.\n *\n * @param args An object containing the parameters for the multi-signature transaction.\n * @param args.signatures A list of signatures.\n * @param args.bitmap A bitmap represented as a Uint8Array or an array of numbers, where each bit indicates whether a\n * corresponding signature is present. A maximum of 32 signatures is supported, and the length of the bitmap must be 4 bytes.\n *\n * @throws Error if the number of signatures exceeds the maximum supported, if the bitmap length is incorrect, or if the number\n * of signatures does not match the bitmap.\n * @group Implementation\n * @category Serialization\n */\n // region Constructors\n constructor(args: { publicKeys: Array<PublicKey>; signaturesRequired: number }) {\n super();\n const { publicKeys, signaturesRequired } = args;\n\n // Validate number of public keys is greater than signature required\n if (signaturesRequired < 1) {\n throw new Error(\"The number of required signatures needs to be greater than 0\");\n }\n\n // Validate number of public keys is greater than signature required\n if (publicKeys.length < signaturesRequired) {\n throw new Error(\n `Provided ${publicKeys.length} public keys is smaller than the ${signaturesRequired} required signatures`,\n );\n }\n\n // Make sure that all keys are normalized to the SingleKey authentication scheme\n this.publicKeys = publicKeys.map((publicKey) =>\n publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey),\n );\n\n this.signaturesRequired = signaturesRequired;\n }\n\n // endregion\n\n // region AccountPublicKey\n\n /**\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by checking if the signature is valid.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify.\n * @group Implementation\n * @category Serialization\n */\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n verifySignature(args: VerifySignatureArgs): boolean {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Generates an authentication key based on the current instance's byte representation.\n * This key can be used for secure authentication processes within the system.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.MultiKey,\n input: this.toUint8Array(),\n });\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the object by writing its signatures and bitmap to the provided serializer.\n * This allows the object to be converted into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.publicKeys);\n serializer.serializeU8(this.signaturesRequired);\n }\n\n /**\n * Deserializes a MultiKeySignature from the provided deserializer.\n * This function retrieves the signatures and bitmap necessary for creating a MultiKeySignature object.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): MultiKey {\n const keys = deserializer.deserializeVector(AnyPublicKey);\n const signaturesRequired = deserializer.deserializeU8();\n\n return new MultiKey({ publicKeys: keys, signaturesRequired });\n }\n\n // endregion\n\n /**\n * Create a bitmap that holds the mapping from the original public keys\n * to the signatures passed in\n *\n * @param args.bits array of the index mapping to the matching public keys\n * @returns Uint8array bit map\n * @group Implementation\n * @category Serialization\n */\n createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number, idx: number) => {\n if (idx + 1 > this.publicKeys.length) {\n throw new Error(`Signature index ${idx + 1} is out of public keys range, ${this.publicKeys.length}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(`Duplicate bit ${bit} detected.`);\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n\n /**\n * Get the index of the provided public key.\n *\n * This function retrieves the index of a specified public key within the MultiKey.\n * If the public key does not exist, it throws an error.\n *\n * @param publicKey - The public key to find the index for.\n * @returns The corresponding index of the public key, if it exists.\n * @throws Error - If the public key is not found in the MultiKey.\n * @group Implementation\n * @category Serialization\n */\n getIndex(publicKey: PublicKey): number {\n const anyPublicKey = publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey);\n const index = this.publicKeys.findIndex((pk) => pk.toString() === anyPublicKey.toString());\n\n if (index !== -1) {\n return index;\n }\n throw new Error(`Public key ${publicKey} not found in MultiKey ${this.publicKeys}`);\n }\n\n public static isInstance(value: PublicKey): value is MultiKey {\n return \"publicKeys\" in value && \"signaturesRequired\" in value;\n }\n}\n\n/**\n * Represents a multi-signature transaction using Ed25519 signatures.\n * This class allows for the creation and management of a K-of-N multi-signature scheme,\n * where a specified number of signatures are required to authorize a transaction.\n *\n * It includes functionality to validate the number of signatures against a bitmap,\n * which indicates which public keys have signed the transaction.\n * @group Implementation\n * @category Serialization\n */\nexport class MultiKeySignature extends Signature {\n /**\n * Number of bytes in the bitmap representing who signed the transaction (32-bits)\n * @group Implementation\n * @category Serialization\n */\n static BITMAP_LEN: number = 4;\n\n /**\n * Maximum number of Ed25519 signatures supported\n * @group Implementation\n * @category Serialization\n */\n static MAX_SIGNATURES_SUPPORTED = MultiKeySignature.BITMAP_LEN * 8;\n\n /**\n * The list of underlying Ed25519 signatures\n * @group Implementation\n * @category Serialization\n */\n public readonly signatures: AnySignature[];\n\n /**\n * 32-bit Bitmap representing who signed the transaction\n *\n * This is represented where each public key can be masked to determine whether the message was signed by that key.\n * @group Implementation\n * @category Serialization\n */\n public readonly bitmap: Uint8Array;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n *\n * @param args.signatures A list of signatures\n * @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth\n * signature should be provided in `signatures`. Bits are read from left to right\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { signatures: Array<Signature | AnySignature>; bitmap: Uint8Array | number[] }) {\n super();\n const { signatures, bitmap } = args;\n\n if (signatures.length > MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`The number of signatures cannot be greater than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED}`);\n }\n\n // Make sure that all signatures are normalized to the SingleKey authentication scheme\n this.signatures = signatures.map((signature) =>\n signature instanceof AnySignature ? signature : new AnySignature(signature),\n );\n\n if (!(bitmap instanceof Uint8Array)) {\n this.bitmap = MultiKeySignature.createBitmap({ bits: bitmap });\n } else if (bitmap.length !== MultiKeySignature.BITMAP_LEN) {\n throw new Error(`\"bitmap\" length should be ${MultiKeySignature.BITMAP_LEN}`);\n } else {\n this.bitmap = bitmap;\n }\n\n const nSignatures = this.bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);\n if (nSignatures !== this.signatures.length) {\n throw new Error(`Expecting ${nSignatures} signatures from the bitmap, but got ${this.signatures.length}`);\n }\n }\n\n /**\n * Helper method to create a bitmap out of the specified bit positions\n * @param args.bits The bitmap positions that should be set. A position starts at index 0.\n * Valid position should range between 0 and 31.\n * @example\n * Here's an example of valid `bits`\n * ```\n * [0, 2, 31]\n * ```\n * `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.\n * The result bitmap should be 0b1010000000000000000000000000001\n *\n * @returns bitmap that is 32bit long\n * @group Implementation\n * @category Serialization\n */\n static createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number) => {\n if (bit >= MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`Cannot have a signature larger than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED - 1}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(\"Duplicate bits detected.\");\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n // Note: we should not need to serialize the vector length, as it can be derived from the bitmap\n serializer.serializeVector(this.signatures);\n serializer.serializeBytes(this.bitmap);\n }\n\n static deserialize(deserializer: Deserializer): MultiKeySignature {\n const signatures = deserializer.deserializeVector(AnySignature);\n const bitmap = deserializer.deserializeBytes();\n return new MultiKeySignature({ signatures, bitmap });\n }\n\n // endregion\n}\n"],"mappings":"2KAiBA,SAASA,EAASC,EAAc,CAC9B,IAAIC,EAAID,EACR,OAAAC,GAAMA,GAAK,EAAK,WAChBA,GAAKA,EAAI,YAAgBA,GAAK,EAAK,YACzBA,GAAKA,GAAK,GAAM,WAAa,UAAc,EACvD,CAcO,IAAMC,EAAN,MAAMC,UAAiBC,CAAiB,CA8B7C,YAAYC,EAAoE,CAC9E,MAAM,EACN,GAAM,CAAE,WAAAC,EAAY,mBAAAC,CAAmB,EAAIF,EAG3C,GAAIE,EAAqB,EACvB,MAAM,IAAI,MAAM,8DAA8D,EAIhF,GAAID,EAAW,OAASC,EACtB,MAAM,IAAI,MACR,YAAYD,EAAW,MAAM,oCAAoCC,CAAkB,sBACrF,EAIF,KAAK,WAAaD,EAAW,IAAKE,GAChCA,aAAqBC,EAAeD,EAAY,IAAIC,EAAaD,CAAS,CAC5E,EAEA,KAAK,mBAAqBD,CAC5B,CAiBA,gBAAgBF,EAAoC,CAClD,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAUA,SAA6B,CAC3B,OAAOK,EAAkB,mBAAmB,CAC1C,SACA,MAAO,KAAK,aAAa,CAC3B,CAAC,CACH,CAcA,UAAUC,EAA8B,CACtCA,EAAW,gBAAgB,KAAK,UAAU,EAC1CA,EAAW,YAAY,KAAK,kBAAkB,CAChD,CAUA,OAAO,YAAYC,EAAsC,CACvD,IAAMC,EAAOD,EAAa,kBAAkBH,CAAY,EAClDF,EAAqBK,EAAa,cAAc,EAEtD,OAAO,IAAIT,EAAS,CAAE,WAAYU,EAAM,mBAAAN,CAAmB,CAAC,CAC9D,C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ANjBA,EAaJ,yBAA2BA,EAAkB,WAAa,EAb5D,IAAMO,EAANP","names":["bitCount","byte","n","MultiKey","_MultiKey","AccountPublicKey","args","publicKeys","signaturesRequired","publicKey","AnyPublicKey","AuthenticationKey","serializer","deserializer","keys","bits","firstBitInByte","bitmap","dupCheckSet","bit","idx","byteOffset","anyPublicKey","index","pk","value","_MultiKeySignature","Signature","signatures","signature","AnySignature","nSignatures","acc","MultiKeySignature"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/internal/view.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LedgerVersionArg, MimeType, MoveValue } from \"../types\";\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport {\n generateViewFunctionPayload,\n InputViewFunctionData,\n InputViewFunctionJsonData,\n ViewFunctionJsonPayload,\n} from \"../transactions\";\nimport { Serializer } from \"../bcs\";\nimport { postAptosFullNode } from \"../client\";\n\nexport async function view<T extends Array<MoveValue> = Array<MoveValue>>(args: {\n aptosConfig: AptosConfig;\n payload: InputViewFunctionData;\n options?: LedgerVersionArg;\n}): Promise<T> {\n const { aptosConfig, payload, options } = args;\n const viewFunctionPayload = await generateViewFunctionPayload({\n ...payload,\n aptosConfig,\n });\n\n const serializer = new Serializer();\n viewFunctionPayload.serialize(serializer);\n const bytes = serializer.toUint8Array();\n\n const { data } = await postAptosFullNode<Uint8Array, MoveValue[]>({\n aptosConfig,\n path: \"view\",\n originMethod: \"view\",\n contentType: MimeType.BCS_VIEW_FUNCTION,\n params: { ledger_version: options?.ledgerVersion },\n body: bytes,\n });\n\n return data as T;\n}\n\nexport async function viewJson<T extends Array<MoveValue> = Array<MoveValue>>(args: {\n aptosConfig: AptosConfig;\n payload: InputViewFunctionJsonData;\n options?: LedgerVersionArg;\n}): Promise<T> {\n const { aptosConfig, payload, options } = args;\n const { data } = await postAptosFullNode<ViewFunctionJsonPayload, MoveValue[]>({\n aptosConfig,\n originMethod: \"viewJson\",\n path: \"view\",\n params: { ledger_version: options?.ledgerVersion },\n body: {\n function: payload.function,\n type_arguments: payload.typeArguments ?? [],\n arguments: payload.functionArguments ?? [],\n },\n });\n\n return data as T;\n}\n"],"mappings":"2HAcA,eAAsBA,EAAoDC,EAI3D,CACb,GAAM,CAAE,YAAAC,EAAa,QAAAC,EAAS,QAAAC,CAAQ,EAAIH,EACpCI,EAAsB,MAAMC,EAA4B,CAC5D,GAAGH,EACH,YAAAD,CACF,CAAC,EAEKK,EAAa,IAAIC,EACvBH,EAAoB,UAAUE,CAAU,EACxC,IAAME,EAAQF,EAAW,aAAa,EAEhC,CAAE,KAAAG,CAAK,EAAI,MAAMC,EAA2C,CAChE,YAAAT,EACA,KAAM,OACN,aAAc,OACd,oDACA,OAAQ,CAAE,eAAgBE,GAAS,aAAc,EACjD,KAAMK,CACR,CAAC,EAED,OAAOC,CACT,CAEA,eAAsBE,EAAwDX,EAI/D,CACb,GAAM,CAAE,YAAAC,EAAa,QAAAC,EAAS,QAAAC,CAAQ,EAAIH,EACpC,CAAE,KAAAS,CAAK,EAAI,MAAMC,EAAwD,CAC7E,YAAAT,EACA,aAAc,WACd,KAAM,OACN,OAAQ,CAAE,eAAgBE,GAAS,aAAc,EACjD,KAAM,CACJ,SAAUD,EAAQ,SAClB,eAAgBA,EAAQ,eAAiB,CAAC,EAC1C,UAAWA,EAAQ,mBAAqB,CAAC,CAC3C,CACF,CAAC,EAED,OAAOO,CACT","names":["view","args","aptosConfig","payload","options","viewFunctionPayload","generateViewFunctionPayload","serializer","Serializer","bytes","data","postAptosFullNode","viewJson"]}
@@ -1,2 +0,0 @@
1
- import{a as i}from"./chunk-IF4UU2MT.mjs";import{bytesToHex as o,hexToBytes as s}from"@noble/hashes/utils";var u=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(u||{}),a=class e{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return o(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 i("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 i("Hex string must be an even number of hex characters.","invalid_length");try{return new e(s(r))}catch(n){throw new i(`Hex string contains invalid hex characters: ${n?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new e(t):e.fromHexString(t)}static hexInputToUint8Array(t){return t instanceof Uint8Array?t:e.fromHexString(t).toUint8Array()}static hexInputToString(t){return e.fromHexInput(t).toString()}static hexInputToStringWithoutPrefix(t){return e.fromHexInput(t).toStringWithoutPrefix()}static isValid(t){try{return e.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,n)=>r===t.data[n])}},l=e=>new TextDecoder().decode(a.fromHexInput(e).toUint8Array());export{u as a,a as b,l as c};
2
- //# sourceMappingURL=chunk-STY74NUA.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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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 * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\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 * @group Implementation\n * @category Serialization\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 * @group Implementation\n * @category Serialization\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\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n"],"mappings":"yCAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBAShC,IAAKC,OACVA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,kBAAoB,oBAHVA,OAAA,IAgCCC,EAAN,MAAMC,CAAI,CAUf,YAAYC,EAAkB,CAC5B,KAAK,KAAOA,CACd,CAaA,cAA2B,CACzB,OAAO,KAAK,IACd,CASA,uBAAgC,CAC9B,OA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AgB,IAAI,YAAY,EAAE,OAAOd,EAAI,aAAac,CAAG,EAAE,aAAa,CAAC","names":["bytesToHex","hexToBytes","HexInvalidReason","Hex","_Hex","data","bytesToHex","str","input","ParsingError","hexToBytes","error","hexInput","other","value","index","hexToAsciiString","hex"]}
@@ -1,2 +0,0 @@
1
- import{b as p}from"./chunk-YIF242TF.mjs";async function o(e){let{type:t,originMethod:s,path:i,body:r,acceptType:R,contentType:f,params:c,aptosConfig:n,overrides:A}=e,d=n.getRequestUrl(t);return p({url:d,method:"POST",originMethod:s,path:i,body:r,contentType:f,acceptType:R,params:c,overrides:A},n,e.type)}async function q(e){let{aptosConfig:t}=e;return o({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...t.clientConfig?.HEADERS,...t.fullnodeConfig?.HEADERS}}})}async function C(e){let{aptosConfig:t}=e;return o({...e,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...e.overrides,HEADERS:{...t.clientConfig?.HEADERS,...t.indexerConfig?.HEADERS}}})}async function E(e){let{aptosConfig:t}=e,s={...t,clientConfig:{...t.clientConfig}};return delete s?.clientConfig?.API_KEY,o({...e,type:"Faucet",overrides:{...s.clientConfig,...s.faucetConfig,...e.overrides,HEADERS:{...s.clientConfig?.HEADERS,...s.faucetConfig?.HEADERS}}})}async function a(e){return o({...e,type:"Pepper"})}async function m(e){return o({...e,type:"Prover"})}export{o as a,q as b,C as c,E as d,a as e,m as f};
2
- //# sourceMappingURL=chunk-ULHOJ2BE.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/post.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { aptosRequest } from \"./core\";\nimport { AptosResponse, AnyNumber, ClientConfig, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Options for making a POST request, including the API client configuration.\n * @group Implementation\n * @category Client\n */\nexport type PostRequestOptions = {\n /**\n * The config for the API client\n * @group Implementation\n * @category Client\n */\n aptosConfig: AptosConfig;\n /**\n * The type of API endpoint to call e.g. fullnode, indexer, etc\n * @group Implementation\n * @category Client\n */\n type: AptosApiType;\n /**\n * The name of the API method\n * @group Implementation\n * @category Client\n */\n originMethod: string;\n /**\n * The URL path to the API method\n * @group Implementation\n * @category Client\n */\n path: string;\n /**\n * The content type of the request body\n * @group Implementation\n * @category Client\n */\n contentType?: MimeType;\n /**\n * The accepted content type of the response of the API\n * @group Implementation\n * @category Client\n */\n acceptType?: MimeType;\n /**\n * The query parameters for the request\n * @group Implementation\n * @category Client\n */\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n /**\n * The body of the request, should match the content type of the request\n * @group Implementation\n * @category Client\n */\n body?: any;\n /**\n * Specific client overrides for this request to override aptosConfig\n * @group Implementation\n * @category Client\n */\n overrides?: ClientConfig;\n};\n\n/**\n * Options for posting a request to Aptos, excluding the type field.\n * @group Implementation\n * @category Client\n */\nexport type PostAptosRequestOptions = Omit<PostRequestOptions, \"type\">;\n\n/**\n * Executes a POST request to the specified URL with the provided options.\n *\n * @param options - The options for the POST request.\n * @param options.type - The type of the request.\n * @param options.originMethod - The original method that initiated the request.\n * @param options.path - The path for the request.\n * @param options.body - The body content to be sent with the request.\n * @param options.acceptType - The type of response expected from the server.\n * @param options.contentType - The content type of the request body.\n * @param options.params - Additional parameters to include in the request.\n * @param options.aptosConfig - Configuration settings for the Aptos request.\n * @param options.overrides - Any overrides for the default request behavior.\n * @returns The response from the POST request.\n * @group Implementation\n * @category Client\n */\nexport async function post<Req extends {}, Res extends {}>(\n options: PostRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { type, originMethod, path, body, acceptType, contentType, params, aptosConfig, overrides } = options;\n const url = aptosConfig.getRequestUrl(type);\n\n return aptosRequest<Req, Res>(\n {\n url,\n method: \"POST\",\n originMethod,\n path,\n body,\n contentType,\n acceptType,\n params,\n overrides,\n },\n aptosConfig,\n options.type,\n );\n}\n\n/**\n * Sends a request to the Aptos full node using the specified options.\n * This function allows you to interact with the Aptos blockchain by sending requests to the full node.\n *\n * @param options - The options for the request.\n * @param options.aptosConfig - Configuration settings for the Aptos client.\n * @param options.aptosConfig.clientConfig - Client-specific configuration settings.\n * @param options.aptosConfig.fullnodeConfig - Full node-specific configuration settings.\n * @param options.overrides - Additional overrides for the request.\n * @group Implementation\n * @category Client\n */\nexport async function postAptosFullNode<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return post<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 * Sends a request to the Aptos indexer with the specified options.\n * This function allows you to interact with the Aptos indexer and customize the request using various configurations.\n *\n * @param options - The options for the request to the Aptos indexer.\n * @param options.aptosConfig - Configuration settings specific to the Aptos client and indexer.\n * @param options.aptosConfig.clientConfig - The client configuration settings.\n * @param options.aptosConfig.indexerConfig - The indexer configuration settings.\n * @param options.overrides - Additional overrides for the request.\n * @param options.overrides.HEADERS - Custom headers to include in the request.\n * @group Implementation\n * @category Client\n */\nexport async function postAptosIndexer<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return post<Req, Res>({\n ...options,\n type: AptosApiType.INDEXER,\n overrides: {\n ...aptosConfig.clientConfig,\n ...aptosConfig.indexerConfig,\n ...options.overrides,\n HEADERS: { ...aptosConfig.clientConfig?.HEADERS, ...aptosConfig.indexerConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Sends a request to the Aptos faucet to obtain test tokens.\n * This function modifies the provided configuration to ensure that the API_KEY is not included in the request.\n *\n * Note that only devnet has a publicly accessible faucet. For testnet, you must use\n * the minting page at https://aptos.dev/network/faucet.\n *\n * @param options - The options for the request.\n * @param options.aptosConfig - The configuration settings for the Aptos client.\n * @param options.aptosConfig.clientConfig - The client-specific configuration settings.\n * @param options.aptosConfig.clientConfig.HEADERS - Optional headers to include in the request.\n * @param options.aptosConfig.faucetConfig - The configuration settings specific to the faucet.\n * @param options.overrides - Additional overrides for the request configuration.\n * @group Implementation\n * @category Client\n */\nexport async function postAptosFaucet<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n // Faucet does not support API_KEY\n // Create a new object with the desired modification\n const modifiedAptosConfig = {\n ...aptosConfig,\n clientConfig: { ...aptosConfig.clientConfig },\n };\n // Delete API_KEY config\n delete modifiedAptosConfig?.clientConfig?.API_KEY;\n\n return post<Req, Res>({\n ...options,\n type: AptosApiType.FAUCET,\n overrides: {\n ...modifiedAptosConfig.clientConfig,\n ...modifiedAptosConfig.faucetConfig,\n ...options.overrides,\n HEADERS: { ...modifiedAptosConfig.clientConfig?.HEADERS, ...modifiedAptosConfig.faucetConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Makes a post request to the pepper service.\n *\n * @param options - The options for the request.\n * @param options.url - The URL to which the request is sent.\n * @param options.headers - The headers to include in the request.\n * @param options.body - The body of the request.\n * @returns A promise that resolves to the response from the pepper service.\n * @group Implementation\n * @category Client\n */\nexport async function postAptosPepperService<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n return post<Req, Res>({ ...options, type: AptosApiType.PEPPER });\n}\n\n/**\n * Sends a request to the Aptos proving service with the specified options.\n *\n * @param options - The options for the request to the Aptos proving service.\n * @param options.type - The type of the request, which should be set to AptosApiType.PROVER.\n * @param options.data - The data to be included in the request.\n * @group Implementation\n * @category Client\n */\nexport async function postAptosProvingService<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<Apt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AAGf,EAAQ,UACX,QAAS,CAAE,GAAGe,EAAoB,cAAc,QAAS,GAAGA,EAAoB,cAAc,OAAQ,CACxG,CACF,CAAC,CACH,CAaA,eAAsBC,EACpBhB,EACkC,CAClC,OAAOD,EAAe,CAAE,GAAGC,EAAS,aAA0B,CAAC,CACjE,CAWA,eAAsBiB,EACpBjB,EACkC,CAClC,OAAOD,EAAe,CAAE,GAAGC,EAAS,aAA0B,CAAC,CACjE","names":["post","options","type","originMethod","path","body","acceptType","contentType","params","aptosConfig","overrides","url","aptosRequest","postAptosFullNode","postAptosIndexer","postAptosFaucet","modifiedAptosConfig","postAptosPepperService","postAptosProvingService"]}
@@ -1,2 +0,0 @@
1
- import{b as a}from"./chunk-YIF242TF.mjs";async function p(e){let{aptosConfig:t,overrides:s,params:n,contentType:o,acceptType:r,path:i,originMethod:d,type:R}=e,u=t.getRequestUrl(R);return a({url:u,method:"GET",originMethod:d,path:i,contentType:o,acceptType:r,params:n,overrides:{...t.clientConfig,...s}},t,e.type)}async function m(e){let{aptosConfig:t}=e;return p({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...t.clientConfig?.HEADERS,...t.fullnodeConfig?.HEADERS}}})}async function y(e){return p({...e,type:"Pepper"})}async function l(e){let t=[],s,n=e.params;do{let o=await p({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:n,overrides:e.overrides});s=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),n.start=s}while(s!=null);return t}async function q(e){let t=[],s,n=e.params,o=n.limit;do{let r=await p({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:n,overrides:e.overrides});if(s=r.headers["x-aptos-cursor"],delete r.headers,t.push(...r.data),n.offset=s,o!==void 0){let i=o-t.length;if(i<=0)break;n.limit=i}}while(s!=null);return t}export{p as a,m as b,y as c,l as d,q as e};
2
- //# sourceMappingURL=chunk-V7G2EDNR.mjs.map