@aptos-labs/ts-sdk 1.32.1 → 1.33.0-sc.1

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 (399) hide show
  1. package/dist/common/{accountAddress-6RqI8Aam.d.ts → accountAddress-fJZJVSBc.d.ts} +2 -1
  2. package/dist/common/chunk-F43XVDYJ.js.map +1 -1
  3. package/dist/common/cli/index.d.ts +10 -1
  4. package/dist/common/cli/index.js +1 -1
  5. package/dist/common/cli/index.js.map +1 -1
  6. package/dist/common/index.d.ts +127 -14
  7. package/dist/common/index.js +31 -31
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/esm/account/AbstractKeylessAccount.d.mts +1 -0
  10. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  11. package/dist/esm/account/Account.d.mts +1 -0
  12. package/dist/esm/account/Account.mjs +1 -1
  13. package/dist/esm/account/Ed25519Account.d.mts +1 -0
  14. package/dist/esm/account/Ed25519Account.mjs +1 -1
  15. package/dist/esm/account/EphemeralKeyPair.d.mts +1 -0
  16. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  17. package/dist/esm/account/FederatedKeylessAccount.d.mts +1 -0
  18. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  19. package/dist/esm/account/KeylessAccount.d.mts +1 -0
  20. package/dist/esm/account/KeylessAccount.mjs +1 -1
  21. package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
  22. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  23. package/dist/esm/account/SingleKeyAccount.d.mts +1 -0
  24. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  25. package/dist/esm/account/index.d.mts +1 -0
  26. package/dist/esm/account/index.mjs +1 -1
  27. package/dist/esm/api/account.d.mts +1 -0
  28. package/dist/esm/api/account.mjs +1 -1
  29. package/dist/esm/api/ans.d.mts +1 -0
  30. package/dist/esm/api/ans.mjs +1 -1
  31. package/dist/esm/api/aptos.d.mts +2 -0
  32. package/dist/esm/api/aptos.mjs +1 -1
  33. package/dist/esm/api/aptosConfig.d.mts +1 -0
  34. package/dist/esm/api/coin.d.mts +1 -0
  35. package/dist/esm/api/coin.mjs +1 -1
  36. package/dist/esm/api/digitalAsset.d.mts +1 -0
  37. package/dist/esm/api/digitalAsset.mjs +1 -1
  38. package/dist/esm/api/event.d.mts +1 -0
  39. package/dist/esm/api/event.mjs +1 -1
  40. package/dist/esm/api/faucet.d.mts +1 -0
  41. package/dist/esm/api/faucet.mjs +1 -1
  42. package/dist/esm/api/fungibleAsset.d.mts +1 -0
  43. package/dist/esm/api/fungibleAsset.mjs +1 -1
  44. package/dist/esm/api/general.d.mts +1 -0
  45. package/dist/esm/api/general.mjs +1 -1
  46. package/dist/esm/api/index.d.mts +2 -0
  47. package/dist/esm/api/index.mjs +1 -1
  48. package/dist/esm/api/keyless.d.mts +1 -0
  49. package/dist/esm/api/keyless.mjs +1 -1
  50. package/dist/esm/api/object.d.mts +1 -0
  51. package/dist/esm/api/object.mjs +1 -1
  52. package/dist/esm/api/staking.d.mts +1 -0
  53. package/dist/esm/api/staking.mjs +1 -1
  54. package/dist/esm/api/table.d.mts +1 -0
  55. package/dist/esm/api/table.mjs +1 -1
  56. package/dist/esm/api/transaction.d.mts +2 -0
  57. package/dist/esm/api/transaction.mjs +1 -1
  58. package/dist/esm/api/transactionSubmission/build.d.mts +66 -0
  59. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  60. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  61. package/dist/esm/api/transactionSubmission/management.d.mts +1 -0
  62. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  63. package/dist/esm/api/transactionSubmission/sign.d.mts +1 -0
  64. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  65. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  66. package/dist/esm/api/transactionSubmission/simulate.d.mts +10 -8
  67. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  68. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -0
  69. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  70. package/dist/esm/api/utils.d.mts +1 -0
  71. package/dist/esm/api/utils.mjs +1 -1
  72. package/dist/esm/bcs/consts.d.mts +1 -0
  73. package/dist/esm/bcs/deserializer.d.mts +1 -0
  74. package/dist/esm/bcs/index.d.mts +1 -0
  75. package/dist/esm/bcs/index.mjs +1 -1
  76. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -0
  77. package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -0
  78. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -0
  79. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  80. package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -0
  81. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  82. package/dist/esm/bcs/serializer.d.mts +1 -0
  83. package/dist/esm/{chunk-RC43EXC4.mjs → chunk-2CKUTG67.mjs} +2 -2
  84. package/dist/esm/{chunk-UKVH4UGL.mjs → chunk-2E3EAJPC.mjs} +2 -2
  85. package/dist/esm/{chunk-KCEI5JYS.mjs → chunk-2G7SAWM3.mjs} +2 -2
  86. package/dist/esm/chunk-2WLKSKL7.mjs +2 -0
  87. package/dist/esm/chunk-2WLKSKL7.mjs.map +1 -0
  88. package/dist/esm/{chunk-O4MRRWRI.mjs → chunk-362NFXZR.mjs} +2 -2
  89. package/dist/esm/{chunk-ML7D2CVG.mjs → chunk-3BWKODVZ.mjs} +2 -2
  90. package/dist/esm/chunk-3OLFJ65O.mjs +2 -0
  91. package/dist/esm/chunk-3OLFJ65O.mjs.map +1 -0
  92. package/dist/esm/{chunk-ETF76XA3.mjs → chunk-3QIOEU3Z.mjs} +2 -2
  93. package/dist/esm/{chunk-SY4HK6CC.mjs → chunk-3QUZFCNW.mjs} +2 -2
  94. package/dist/esm/chunk-3QUZFCNW.mjs.map +1 -0
  95. package/dist/esm/{chunk-H7AALSJ7.mjs → chunk-3TOPGQJA.mjs} +2 -2
  96. package/dist/esm/{chunk-AGEJNSEX.mjs → chunk-4JX6OQEE.mjs} +2 -2
  97. package/dist/esm/{chunk-MBEWPBGN.mjs → chunk-4ZNSNWQL.mjs} +2 -2
  98. package/dist/esm/{chunk-EJKX6MGV.mjs → chunk-554TWPPO.mjs} +2 -2
  99. package/dist/esm/{chunk-KM6IOJ6Y.mjs → chunk-5XLZACVT.mjs} +2 -2
  100. package/dist/esm/{chunk-NF7ZQQE3.mjs → chunk-6EVBSHT2.mjs} +2 -2
  101. package/dist/esm/{chunk-JONEH52T.mjs → chunk-6YFM6NEC.mjs} +2 -2
  102. package/dist/esm/{chunk-TGW36YOD.mjs → chunk-77ILVREP.mjs} +2 -2
  103. package/dist/esm/{chunk-4IQZOAN7.mjs → chunk-7BKLEHKL.mjs} +2 -2
  104. package/dist/esm/{chunk-FFCCBAEZ.mjs → chunk-7CDITZUS.mjs} +2 -2
  105. package/dist/esm/{chunk-JIT2FYGE.mjs → chunk-7R44XXPU.mjs} +2 -2
  106. package/dist/esm/chunk-A7KFSQSE.mjs +2 -0
  107. package/dist/esm/chunk-A7KFSQSE.mjs.map +1 -0
  108. package/dist/esm/{chunk-HBWIDPNN.mjs → chunk-AOQJI6IC.mjs} +2 -2
  109. package/dist/esm/{chunk-U3GE6IPF.mjs → chunk-AR6BOLET.mjs} +2 -2
  110. package/dist/esm/{chunk-TQA6HY6A.mjs → chunk-B2OF42B3.mjs} +2 -2
  111. package/dist/esm/{chunk-4J2JYRV3.mjs → chunk-B6ERS4UX.mjs} +2 -2
  112. package/dist/esm/{chunk-YP3VO6GM.mjs → chunk-BKSQPS2O.mjs} +2 -2
  113. package/dist/esm/{chunk-JGLEKXFP.mjs → chunk-BVUMR7DQ.mjs} +2 -2
  114. package/dist/esm/{chunk-LHBMBCFC.mjs → chunk-BZ7OCXLM.mjs} +2 -2
  115. package/dist/esm/{chunk-HPZQGMSH.mjs → chunk-CK5NDXQT.mjs} +2 -2
  116. package/dist/esm/{chunk-BP45UJII.mjs → chunk-CW6P2DDJ.mjs} +2 -2
  117. package/dist/esm/{chunk-KX43GEAB.mjs → chunk-D6WMUQB5.mjs} +2 -2
  118. package/dist/esm/{chunk-2REHS35S.mjs → chunk-DBAISV4K.mjs} +2 -2
  119. package/dist/esm/chunk-EPBNJZ4A.mjs +2 -0
  120. package/dist/esm/chunk-EPBNJZ4A.mjs.map +1 -0
  121. package/dist/esm/{chunk-7OHMMGS6.mjs → chunk-EVA2SMAU.mjs} +2 -2
  122. package/dist/esm/{chunk-P2FTRAK3.mjs → chunk-EVASO3UR.mjs} +2 -2
  123. package/dist/esm/{chunk-5O3RHPER.mjs → chunk-FFBC7GFN.mjs} +2 -2
  124. package/dist/esm/chunk-FZDEGDUY.mjs +2 -0
  125. package/dist/esm/{chunk-AITN3DO4.mjs.map → chunk-FZDEGDUY.mjs.map} +1 -1
  126. package/dist/esm/{chunk-OVI7L7OG.mjs → chunk-H6RW3TML.mjs} +2 -2
  127. package/dist/esm/{chunk-FYYTCJS4.mjs → chunk-HXCL6KBW.mjs} +2 -2
  128. package/dist/esm/chunk-IHGA5KAD.mjs +2 -0
  129. package/dist/esm/{chunk-I2NMCLNW.mjs.map → chunk-IHGA5KAD.mjs.map} +1 -1
  130. package/dist/esm/{chunk-RLH25IDA.mjs → chunk-IIV42FZR.mjs} +2 -2
  131. package/dist/esm/{chunk-RSO5YIDW.mjs → chunk-IKJAX5KQ.mjs} +2 -2
  132. package/dist/esm/{chunk-UWLW2VLZ.mjs → chunk-IZ3I5XZU.mjs} +2 -2
  133. package/dist/esm/{chunk-5KCKWL2C.mjs → chunk-J2NQJ34O.mjs} +2 -2
  134. package/dist/esm/chunk-J45GIVXE.mjs +2 -0
  135. package/dist/esm/chunk-J45GIVXE.mjs.map +1 -0
  136. package/dist/esm/{chunk-LYO22HMF.mjs → chunk-JJXLJY37.mjs} +2 -2
  137. package/dist/esm/{chunk-CPKG25HX.mjs → chunk-LRN4ALMT.mjs} +2 -2
  138. package/dist/esm/{chunk-ERDYU5YQ.mjs → chunk-MKM5MDD5.mjs} +2 -2
  139. package/dist/esm/{chunk-GZBVXXUL.mjs → chunk-NNWPYX3K.mjs} +2 -2
  140. package/dist/esm/{chunk-A3USS2NC.mjs → chunk-OZK26LTY.mjs} +2 -2
  141. package/dist/esm/{chunk-SPX2YFZN.mjs → chunk-P6RNNESB.mjs} +2 -2
  142. package/dist/esm/chunk-PC4HNMCP.mjs +2 -0
  143. package/dist/esm/chunk-PC4HNMCP.mjs.map +1 -0
  144. package/dist/esm/{chunk-VGITSRT6.mjs → chunk-PMA7XAFK.mjs} +2 -2
  145. package/dist/esm/{chunk-WYOFF5DJ.mjs → chunk-QCIRC2SG.mjs} +2 -2
  146. package/dist/esm/{chunk-CEW2NI3K.mjs → chunk-S22QVNK7.mjs} +2 -2
  147. package/dist/esm/{chunk-K62JTXWQ.mjs → chunk-SHAKBL2R.mjs} +2 -2
  148. package/dist/esm/{chunk-X7JNNNMC.mjs → chunk-SOLRIYPW.mjs} +2 -2
  149. package/dist/esm/{chunk-IQ4SCMB6.mjs → chunk-T7BTSSX7.mjs} +2 -2
  150. package/dist/esm/{chunk-IUSAYAEI.mjs → chunk-TE3SBS7J.mjs} +2 -2
  151. package/dist/esm/chunk-U2PRGW4O.mjs +2 -0
  152. package/dist/esm/chunk-U2PRGW4O.mjs.map +1 -0
  153. package/dist/esm/{chunk-L25CRR2W.mjs → chunk-U7UTBXJD.mjs} +2 -2
  154. package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
  155. package/dist/esm/{chunk-2LQ4FTSR.mjs → chunk-UQIMOQZ7.mjs} +2 -2
  156. package/dist/esm/{chunk-I5GENJBA.mjs → chunk-UTOO6IVJ.mjs} +2 -2
  157. package/dist/esm/{chunk-D54FD6XE.mjs → chunk-WIDWY7A2.mjs} +2 -2
  158. package/dist/esm/{chunk-E2GPZCQI.mjs → chunk-WJSZAGHP.mjs} +2 -2
  159. package/dist/esm/{chunk-II26BNYA.mjs → chunk-XEW2YQE2.mjs} +2 -2
  160. package/dist/esm/chunk-XEW2YQE2.mjs.map +1 -0
  161. package/dist/esm/chunk-YQHOQJRQ.mjs +2 -0
  162. package/dist/esm/{chunk-RZGTHCJY.mjs.map → chunk-YQHOQJRQ.mjs.map} +1 -1
  163. package/dist/esm/{chunk-LGHPJTF3.mjs → chunk-YT3IP57B.mjs} +2 -2
  164. package/dist/esm/cli/index.d.mts +1 -0
  165. package/dist/esm/cli/index.mjs +1 -1
  166. package/dist/esm/cli/move.d.mts +10 -0
  167. package/dist/esm/cli/move.mjs +1 -1
  168. package/dist/esm/client/core.d.mts +1 -0
  169. package/dist/esm/client/core.mjs +1 -1
  170. package/dist/esm/client/get.d.mts +1 -0
  171. package/dist/esm/client/get.mjs +1 -1
  172. package/dist/esm/client/index.d.mts +1 -0
  173. package/dist/esm/client/index.mjs +1 -1
  174. package/dist/esm/client/post.d.mts +1 -0
  175. package/dist/esm/client/post.mjs +1 -1
  176. package/dist/esm/core/account/index.d.mts +1 -0
  177. package/dist/esm/core/account/index.mjs +1 -1
  178. package/dist/esm/core/account/utils/address.d.mts +1 -0
  179. package/dist/esm/core/account/utils/address.mjs +1 -1
  180. package/dist/esm/core/account/utils/index.d.mts +1 -0
  181. package/dist/esm/core/account/utils/index.mjs +1 -1
  182. package/dist/esm/core/accountAddress.d.mts +1 -0
  183. package/dist/esm/core/accountAddress.mjs +1 -1
  184. package/dist/esm/core/authenticationKey.d.mts +1 -0
  185. package/dist/esm/core/authenticationKey.mjs +1 -1
  186. package/dist/esm/core/crypto/ed25519.d.mts +1 -0
  187. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  188. package/dist/esm/core/crypto/ephemeral.d.mts +1 -0
  189. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  190. package/dist/esm/core/crypto/federatedKeyless.d.mts +1 -0
  191. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  192. package/dist/esm/core/crypto/index.d.mts +1 -0
  193. package/dist/esm/core/crypto/index.mjs +1 -1
  194. package/dist/esm/core/crypto/keyless.d.mts +1 -0
  195. package/dist/esm/core/crypto/keyless.mjs +1 -1
  196. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -0
  197. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  198. package/dist/esm/core/crypto/multiKey.d.mts +1 -0
  199. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  200. package/dist/esm/core/crypto/privateKey.d.mts +1 -0
  201. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  202. package/dist/esm/core/crypto/proof.d.mts +1 -0
  203. package/dist/esm/core/crypto/proof.mjs +1 -1
  204. package/dist/esm/core/crypto/publicKey.d.mts +1 -0
  205. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  206. package/dist/esm/core/crypto/secp256k1.d.mts +1 -0
  207. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  208. package/dist/esm/core/crypto/signature.d.mts +1 -0
  209. package/dist/esm/core/crypto/signature.mjs +1 -1
  210. package/dist/esm/core/crypto/singleKey.d.mts +1 -0
  211. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  212. package/dist/esm/core/crypto/utils.d.mts +1 -0
  213. package/dist/esm/core/hex.d.mts +1 -0
  214. package/dist/esm/core/index.d.mts +1 -0
  215. package/dist/esm/core/index.mjs +1 -1
  216. package/dist/esm/errors/index.d.mts +1 -0
  217. package/dist/esm/index.d.mts +5 -3
  218. package/dist/esm/index.mjs +1 -1
  219. package/dist/esm/internal/account.d.mts +1 -0
  220. package/dist/esm/internal/account.mjs +1 -1
  221. package/dist/esm/internal/ans.d.mts +1 -0
  222. package/dist/esm/internal/ans.mjs +1 -1
  223. package/dist/esm/internal/coin.d.mts +1 -0
  224. package/dist/esm/internal/coin.mjs +1 -1
  225. package/dist/esm/internal/digitalAsset.d.mts +1 -0
  226. package/dist/esm/internal/digitalAsset.mjs +1 -1
  227. package/dist/esm/internal/event.d.mts +1 -0
  228. package/dist/esm/internal/event.mjs +1 -1
  229. package/dist/esm/internal/faucet.d.mts +1 -0
  230. package/dist/esm/internal/faucet.mjs +1 -1
  231. package/dist/esm/internal/fungibleAsset.d.mts +1 -0
  232. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  233. package/dist/esm/internal/general.d.mts +1 -0
  234. package/dist/esm/internal/general.mjs +1 -1
  235. package/dist/esm/internal/keyless.d.mts +1 -0
  236. package/dist/esm/internal/keyless.mjs +1 -1
  237. package/dist/esm/internal/object.d.mts +1 -0
  238. package/dist/esm/internal/object.mjs +1 -1
  239. package/dist/esm/internal/staking.d.mts +1 -0
  240. package/dist/esm/internal/staking.mjs +1 -1
  241. package/dist/esm/internal/table.d.mts +1 -0
  242. package/dist/esm/internal/table.mjs +1 -1
  243. package/dist/esm/internal/transaction.d.mts +1 -0
  244. package/dist/esm/internal/transaction.mjs +1 -1
  245. package/dist/esm/internal/transactionSubmission.d.mts +2 -1
  246. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  247. package/dist/esm/internal/view.d.mts +1 -0
  248. package/dist/esm/internal/view.mjs +1 -1
  249. package/dist/esm/transactions/authenticator/account.d.mts +11 -1
  250. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  251. package/dist/esm/transactions/authenticator/index.d.mts +2 -1
  252. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  253. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -0
  254. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  255. package/dist/esm/transactions/index.d.mts +5 -3
  256. package/dist/esm/transactions/index.mjs +1 -1
  257. package/dist/esm/transactions/instances/chainId.d.mts +1 -0
  258. package/dist/esm/transactions/instances/identifier.d.mts +1 -0
  259. package/dist/esm/transactions/instances/index.d.mts +1 -0
  260. package/dist/esm/transactions/instances/index.mjs +1 -1
  261. package/dist/esm/transactions/instances/moduleId.d.mts +1 -0
  262. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  263. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -0
  264. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  265. package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -0
  266. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  267. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -0
  268. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  269. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -0
  270. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  271. package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -0
  272. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  273. package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -0
  274. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -0
  275. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  276. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -0
  277. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  278. package/dist/esm/transactions/management/index.d.mts +1 -0
  279. package/dist/esm/transactions/management/index.mjs +1 -1
  280. package/dist/esm/transactions/management/transactionWorker.d.mts +1 -0
  281. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  282. package/dist/esm/transactions/script-composer/index.d.mts +44 -0
  283. package/dist/esm/transactions/script-composer/index.mjs +2 -0
  284. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -0
  285. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  286. package/dist/esm/transactions/transactionBuilder/index.d.mts +2 -1
  287. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  288. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +23 -2
  289. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  290. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -0
  291. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  292. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -2
  293. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  294. package/dist/esm/transactions/typeTag/index.d.mts +1 -0
  295. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  296. package/dist/esm/transactions/typeTag/parser.d.mts +1 -0
  297. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  298. package/dist/esm/transactions/types.d.mts +13 -3
  299. package/dist/esm/types/index.d.mts +1 -0
  300. package/dist/esm/types/index.mjs +1 -1
  301. package/dist/esm/types/types.d.mts +3 -1
  302. package/dist/esm/types/types.mjs +1 -1
  303. package/dist/esm/utils/helpers.d.mts +1 -0
  304. package/dist/esm/utils/index.d.mts +1 -0
  305. package/dist/esm/utils/index.mjs +1 -1
  306. package/dist/esm/utils/normalizeBundle.d.mts +1 -0
  307. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  308. package/dist/esm/version.d.mts +1 -1
  309. package/dist/esm/version.mjs +1 -1
  310. package/package.json +2 -1
  311. package/src/api/transactionSubmission/build.ts +82 -1
  312. package/src/api/transactionSubmission/helpers.ts +0 -6
  313. package/src/api/transactionSubmission/simulate.ts +9 -8
  314. package/src/cli/move.ts +16 -0
  315. package/src/internal/transactionSubmission.ts +1 -1
  316. package/src/transactions/authenticator/account.ts +19 -0
  317. package/src/transactions/index.ts +1 -0
  318. package/src/transactions/script-composer/index.ts +76 -0
  319. package/src/transactions/transactionBuilder/remoteAbi.ts +55 -1
  320. package/src/transactions/transactionBuilder/transactionBuilder.ts +25 -17
  321. package/src/transactions/types.ts +14 -2
  322. package/src/types/index.ts +1 -0
  323. package/src/types/types.ts +1 -0
  324. package/src/version.ts +1 -1
  325. package/dist/esm/chunk-26WX3UFP.mjs +0 -2
  326. package/dist/esm/chunk-26WX3UFP.mjs.map +0 -1
  327. package/dist/esm/chunk-AITN3DO4.mjs +0 -2
  328. package/dist/esm/chunk-DYELAVMR.mjs +0 -2
  329. package/dist/esm/chunk-DYELAVMR.mjs.map +0 -1
  330. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  331. package/dist/esm/chunk-I2NMCLNW.mjs +0 -2
  332. package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
  333. package/dist/esm/chunk-II26BNYA.mjs.map +0 -1
  334. package/dist/esm/chunk-KTM6KVUJ.mjs +0 -2
  335. package/dist/esm/chunk-KTM6KVUJ.mjs.map +0 -1
  336. package/dist/esm/chunk-RZGTHCJY.mjs +0 -2
  337. package/dist/esm/chunk-SY4HK6CC.mjs.map +0 -1
  338. package/dist/esm/chunk-WQF3IOXC.mjs +0 -2
  339. package/dist/esm/chunk-WQF3IOXC.mjs.map +0 -1
  340. package/dist/esm/chunk-XIB6LX22.mjs +0 -2
  341. package/dist/esm/chunk-XIB6LX22.mjs.map +0 -1
  342. /package/dist/esm/{chunk-RC43EXC4.mjs.map → chunk-2CKUTG67.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-UKVH4UGL.mjs.map → chunk-2E3EAJPC.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-KCEI5JYS.mjs.map → chunk-2G7SAWM3.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-O4MRRWRI.mjs.map → chunk-362NFXZR.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-ML7D2CVG.mjs.map → chunk-3BWKODVZ.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-ETF76XA3.mjs.map → chunk-3QIOEU3Z.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-H7AALSJ7.mjs.map → chunk-3TOPGQJA.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-AGEJNSEX.mjs.map → chunk-4JX6OQEE.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-MBEWPBGN.mjs.map → chunk-4ZNSNWQL.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-EJKX6MGV.mjs.map → chunk-554TWPPO.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-KM6IOJ6Y.mjs.map → chunk-5XLZACVT.mjs.map} +0 -0
  353. /package/dist/esm/{chunk-NF7ZQQE3.mjs.map → chunk-6EVBSHT2.mjs.map} +0 -0
  354. /package/dist/esm/{chunk-JONEH52T.mjs.map → chunk-6YFM6NEC.mjs.map} +0 -0
  355. /package/dist/esm/{chunk-TGW36YOD.mjs.map → chunk-77ILVREP.mjs.map} +0 -0
  356. /package/dist/esm/{chunk-4IQZOAN7.mjs.map → chunk-7BKLEHKL.mjs.map} +0 -0
  357. /package/dist/esm/{chunk-FFCCBAEZ.mjs.map → chunk-7CDITZUS.mjs.map} +0 -0
  358. /package/dist/esm/{chunk-JIT2FYGE.mjs.map → chunk-7R44XXPU.mjs.map} +0 -0
  359. /package/dist/esm/{chunk-HBWIDPNN.mjs.map → chunk-AOQJI6IC.mjs.map} +0 -0
  360. /package/dist/esm/{chunk-U3GE6IPF.mjs.map → chunk-AR6BOLET.mjs.map} +0 -0
  361. /package/dist/esm/{chunk-TQA6HY6A.mjs.map → chunk-B2OF42B3.mjs.map} +0 -0
  362. /package/dist/esm/{chunk-4J2JYRV3.mjs.map → chunk-B6ERS4UX.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-YP3VO6GM.mjs.map → chunk-BKSQPS2O.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-JGLEKXFP.mjs.map → chunk-BVUMR7DQ.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-LHBMBCFC.mjs.map → chunk-BZ7OCXLM.mjs.map} +0 -0
  366. /package/dist/esm/{chunk-HPZQGMSH.mjs.map → chunk-CK5NDXQT.mjs.map} +0 -0
  367. /package/dist/esm/{chunk-BP45UJII.mjs.map → chunk-CW6P2DDJ.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-KX43GEAB.mjs.map → chunk-D6WMUQB5.mjs.map} +0 -0
  369. /package/dist/esm/{chunk-2REHS35S.mjs.map → chunk-DBAISV4K.mjs.map} +0 -0
  370. /package/dist/esm/{chunk-7OHMMGS6.mjs.map → chunk-EVA2SMAU.mjs.map} +0 -0
  371. /package/dist/esm/{chunk-P2FTRAK3.mjs.map → chunk-EVASO3UR.mjs.map} +0 -0
  372. /package/dist/esm/{chunk-5O3RHPER.mjs.map → chunk-FFBC7GFN.mjs.map} +0 -0
  373. /package/dist/esm/{chunk-OVI7L7OG.mjs.map → chunk-H6RW3TML.mjs.map} +0 -0
  374. /package/dist/esm/{chunk-FYYTCJS4.mjs.map → chunk-HXCL6KBW.mjs.map} +0 -0
  375. /package/dist/esm/{chunk-RLH25IDA.mjs.map → chunk-IIV42FZR.mjs.map} +0 -0
  376. /package/dist/esm/{chunk-RSO5YIDW.mjs.map → chunk-IKJAX5KQ.mjs.map} +0 -0
  377. /package/dist/esm/{chunk-UWLW2VLZ.mjs.map → chunk-IZ3I5XZU.mjs.map} +0 -0
  378. /package/dist/esm/{chunk-5KCKWL2C.mjs.map → chunk-J2NQJ34O.mjs.map} +0 -0
  379. /package/dist/esm/{chunk-LYO22HMF.mjs.map → chunk-JJXLJY37.mjs.map} +0 -0
  380. /package/dist/esm/{chunk-CPKG25HX.mjs.map → chunk-LRN4ALMT.mjs.map} +0 -0
  381. /package/dist/esm/{chunk-ERDYU5YQ.mjs.map → chunk-MKM5MDD5.mjs.map} +0 -0
  382. /package/dist/esm/{chunk-GZBVXXUL.mjs.map → chunk-NNWPYX3K.mjs.map} +0 -0
  383. /package/dist/esm/{chunk-A3USS2NC.mjs.map → chunk-OZK26LTY.mjs.map} +0 -0
  384. /package/dist/esm/{chunk-SPX2YFZN.mjs.map → chunk-P6RNNESB.mjs.map} +0 -0
  385. /package/dist/esm/{chunk-VGITSRT6.mjs.map → chunk-PMA7XAFK.mjs.map} +0 -0
  386. /package/dist/esm/{chunk-WYOFF5DJ.mjs.map → chunk-QCIRC2SG.mjs.map} +0 -0
  387. /package/dist/esm/{chunk-CEW2NI3K.mjs.map → chunk-S22QVNK7.mjs.map} +0 -0
  388. /package/dist/esm/{chunk-K62JTXWQ.mjs.map → chunk-SHAKBL2R.mjs.map} +0 -0
  389. /package/dist/esm/{chunk-X7JNNNMC.mjs.map → chunk-SOLRIYPW.mjs.map} +0 -0
  390. /package/dist/esm/{chunk-IQ4SCMB6.mjs.map → chunk-T7BTSSX7.mjs.map} +0 -0
  391. /package/dist/esm/{chunk-IUSAYAEI.mjs.map → chunk-TE3SBS7J.mjs.map} +0 -0
  392. /package/dist/esm/{chunk-L25CRR2W.mjs.map → chunk-U7UTBXJD.mjs.map} +0 -0
  393. /package/dist/esm/{chunk-FD6FGKYY.mjs.map → chunk-UIRAXHDH.mjs.map} +0 -0
  394. /package/dist/esm/{chunk-2LQ4FTSR.mjs.map → chunk-UQIMOQZ7.mjs.map} +0 -0
  395. /package/dist/esm/{chunk-I5GENJBA.mjs.map → chunk-UTOO6IVJ.mjs.map} +0 -0
  396. /package/dist/esm/{chunk-D54FD6XE.mjs.map → chunk-WIDWY7A2.mjs.map} +0 -0
  397. /package/dist/esm/{chunk-E2GPZCQI.mjs.map → chunk-WJSZAGHP.mjs.map} +0 -0
  398. /package/dist/esm/{chunk-LGHPJTF3.mjs.map → chunk-YT3IP57B.mjs.map} +0 -0
  399. /package/dist/esm/{chunk-I5OYNCZS.mjs.map → transactions/script-composer/index.mjs.map} +0 -0
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkF43XVDYJjs = require('./chunk-F43XVDYJ.js');var Dr=255,Or=65535,Re=4294967295,it=18446744073709551615n,Xt=340282366920938463463374607431768211455n,zr=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var N=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<Re;){let n=this.deserializeU8();if(e|=BigInt(n&127)<<BigInt(t),!(n&128))break;t+=7}if(e>Re)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),n=new Array;for(let i=0;i<t;i+=1)n.push(this.deserialize(e));return n}};var _utils = require('@noble/hashes/utils');var Q=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var Ca=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(Ca||{}),g= exports.Hex =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 Q("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 Q("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 Q(`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])}},Ui= exports.hexToAsciiString =r=>new TextDecoder().decode(g.fromHexInput(r).toUint8Array());var l=class{bcsToBytes(){let e=new H;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return g.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},H= exports.Serializer =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 i=new DataView(this.buffer,this.offset);e.apply(i,[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){kn(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(Re),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&it,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&Xt,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))}};_chunkF43XVDYJjs.a.call(void 0, [ot(0,Dr)],H.prototype,"serializeU8",1),_chunkF43XVDYJjs.a.call(void 0, [ot(0,Or)],H.prototype,"serializeU16",1),_chunkF43XVDYJjs.a.call(void 0, [ot(0,Re)],H.prototype,"serializeU32",1),_chunkF43XVDYJjs.a.call(void 0, [ot(BigInt(0),it)],H.prototype,"serializeU64",1),_chunkF43XVDYJjs.a.call(void 0, [ot(BigInt(0),Xt)],H.prototype,"serializeU128",1),_chunkF43XVDYJjs.a.call(void 0, [ot(BigInt(0),zr)],H.prototype,"serializeU256",1),_chunkF43XVDYJjs.a.call(void 0, [ot(0,Re)],H.prototype,"serializeU32AsUleb128",1);function kn(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var Ra=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function $e(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(Ra(r,e,t))}function ot(r,e){return(t,n,i)=>{let o=i.value;return i.value=function(a){return $e(a,r,e),o.apply(this,[a])},i}}var st=class r extends l{constructor(e){super(),this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let n=e.deserializeFixedBytes(t);return new r(n)}};var Nr=class r extends l{constructor(e){super(),this.value=new st(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let n=st.deserialize(e,t);return new r(n.value)}};var Fr=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(Fr||{}),Ki= exports.TypeTagVariants =(y=>(y[y.Bool=0]="Bool",y[y.U8=1]="U8",y[y.U64=2]="U64",y[y.U128=3]="U128",y[y.Address=4]="Address",y[y.Signer=5]="Signer",y[y.Vector=6]="Vector",y[y.Struct=7]="Struct",y[y.U16=8]="U16",y[y.U32=9]="U32",y[y.U256=10]="U256",y[y.Reference=254]="Reference",y[y.Generic=255]="Generic",y))(Ki||{}),Yt= exports.ScriptTransactionArgumentVariants =(d=>(d[d.U8=0]="U8",d[d.U64=1]="U64",d[d.U128=2]="U128",d[d.Address=3]="Address",d[d.U8Vector=4]="U8Vector",d[d.Bool=5]="Bool",d[d.U16=6]="U16",d[d.U32=7]="U32",d[d.U256=8]="U256",d[d.Serialized=9]="Serialized",d))(Yt||{}),ki= exports.TransactionPayloadVariants =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(ki||{}),Di= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(Di||{}),Oi= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(Oi||{}),zi= exports.AccountAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(zi||{}),Gr= exports.PrivateKeyVariants =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(Gr||{}),Br= exports.AnyPublicKeyVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.Secp256k1=1]="Secp256k1",i[i.Keyless=3]="Keyless",i[i.FederatedKeyless=4]="FederatedKeyless",i))(Br||{}),Ni= exports.AnySignatureVariant =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))(Ni||{}),Dn= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Dn||{}),Fi= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Fi||{}),On= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(On||{}),zn= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(zn||{}),Nn= exports.TransactionResponseType =(a=>(a.Pending="pending_transaction",a.User="user_transaction",a.Genesis="genesis_transaction",a.BlockMetadata="block_metadata_transaction",a.StateCheckpoint="state_checkpoint_transaction",a.Validator="validator_transaction",a.BlockEpilogue="block_epilogue_transaction",a))(Nn||{});function Yu(r){return r.type==="pending_transaction"}function Zu(r){return r.type==="user_transaction"}function ep(r){return r.type==="genesis_transaction"}function tp(r){return r.type==="block_metadata_transaction"}function rp(r){return r.type==="state_checkpoint_transaction"}function np(r){return r.type==="validator_transaction"}function ip(r){return r.type==="block_epilogue_transaction"}function op(r){return"signature"in r&&r.signature==="ed25519_signature"}function sp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function ap(r){return r.type==="multi_agent_signature"}function cp(r){return r.type==="fee_payer_signature"}function up(r){return r.type==="multi_ed25519_signature"}var Ua=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Ua||{}),Gi= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(Gi||{}),Ka= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(Ka||{}),he= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(he||{}),Fn= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Fn||{}),Bi= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Bi||{});var U=class r extends l{constructor(e){super(),kn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new de(e.deserializeU256())}static deserialize(e){return new r(e.deserializeBool())}},j= exports.U8 =class r extends l{constructor(e){super(),$e(e,0,Dr),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new r(e.deserializeU8())}},Te= exports.U16 =class r extends l{constructor(e){super(),$e(e,0,Or),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new r(e.deserializeU16())}},be= exports.U32 =class r extends l{constructor(e){super(),$e(e,0,Re),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new r(e.deserializeU32())}},$= exports.U64 =class r extends l{constructor(e){super(),$e(e,BigInt(0),it),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new r(e.deserializeU64())}},we= exports.U128 =class r extends l{constructor(e){super(),$e(e,BigInt(0),Xt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new r(e.deserializeU128())}},de= exports.U256 =class r extends l{constructor(e){super(),$e(e,BigInt(0),zr),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new r(e.deserializeU256())}};var b=class r extends l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof j)){new Zt(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let n=g.fromHexInput(e);t=Array.from(n.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new r(t.map(n=>new j(n)))}static U16(e){return new r(e.map(t=>new Te(t)))}static U32(e){return new r(e.map(t=>new be(t)))}static U64(e){return new r(e.map(t=>new $(t)))}static U128(e){return new r(e.map(t=>new we(t)))}static U256(e){return new r(e.map(t=>new de(t)))}static Bool(e){return new r(e.map(t=>new U(t)))}static MoveString(e){return new r(e.map(t=>new S(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let n=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<n;o+=1)i.push(t.deserialize(e));return new r(i)}},Zt= exports.Serialized =class r extends l{constructor(e){super(),this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new r(e.deserializeBytes())}toMoveVector(e){let t=new N(this.bcsToBytes());t.deserializeUleb128AsU32();let n=t.deserializeVector(e);return new b(n)}},S= exports.MoveString =class r extends l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let n=new TextEncoder().encode(this.value);b.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},J= exports.MoveOption =class r extends l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new b([e]):this.vec=new b([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new j(e):void 0)}static U16(e){return new r(e!=null?new Te(e):void 0)}static U32(e){return new r(e!=null?new be(e):void 0)}static U64(e){return new r(e!=null?new $(e):void 0)}static U128(e){return new r(e!=null?new we(e):void 0)}static U256(e){return new r(e!=null?new de(e):void 0)}static Bool(e){return new r(e!=null?new U(e):void 0)}static MoveString(e){return new r(e!=null?new S(e):void 0)}static deserialize(e,t){let n=b.deserialize(e,t);return new r(n.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Da=(c=>(c.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",c.INVALID_HEX_CHARS="invalid_hex_chars",c.TOO_SHORT="too_short",c.TOO_LONG="too_long",c.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",c.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",c.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",c.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",c))(Da||{}),E=class E extends l{constructor(e){if(super(),e.length!==E.LENGTH)throw new Q("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(E.LENGTH);return new E(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new Q("Hex string must start with a leading 0x.","leading_zero_x_required");let t=E.fromString(e);if(e.length!==E.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new Q(`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 Q(`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 Q("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new Q("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 Q(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let i;try{i=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(s){throw new Q(`Hex characters are invalid: ${_optionalChain([s, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let o=new E(i);if(n.length<64-t&&!o.isSpecial())throw new Q(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkF43XVDYJjs = require('./chunk-F43XVDYJ.js');var Fr=255,Gr=65535,Ue=4294967295,ot=18446744073709551615n,nr=340282366920938463463374607431768211455n,Br=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var D=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<Ue;){let n=this.deserializeU8();if(e|=BigInt(n&127)<<BigInt(t),!(n&128))break;t+=7}if(e>Ue)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),n=new Array;for(let i=0;i<t;i+=1)n.push(this.deserialize(e));return n}};var _utils = require('@noble/hashes/utils');var Q=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var Oa=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(Oa||{}),g= exports.Hex =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 Q("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 Q("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 Q(`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])}},zi= exports.hexToAsciiString =r=>new TextDecoder().decode(g.fromHexInput(r).toUint8Array());var l=class{bcsToBytes(){let e=new H;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return g.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},H= exports.Serializer =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 i=new DataView(this.buffer,this.offset);e.apply(i,[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){zn(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(Ue),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&ot,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&nr,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))}};_chunkF43XVDYJjs.a.call(void 0, [st(0,Fr)],H.prototype,"serializeU8",1),_chunkF43XVDYJjs.a.call(void 0, [st(0,Gr)],H.prototype,"serializeU16",1),_chunkF43XVDYJjs.a.call(void 0, [st(0,Ue)],H.prototype,"serializeU32",1),_chunkF43XVDYJjs.a.call(void 0, [st(BigInt(0),ot)],H.prototype,"serializeU64",1),_chunkF43XVDYJjs.a.call(void 0, [st(BigInt(0),nr)],H.prototype,"serializeU128",1),_chunkF43XVDYJjs.a.call(void 0, [st(BigInt(0),Br)],H.prototype,"serializeU256",1),_chunkF43XVDYJjs.a.call(void 0, [st(0,Ue)],H.prototype,"serializeU32AsUleb128",1);function zn(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var za=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function $e(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(za(r,e,t))}function st(r,e){return(t,n,i)=>{let o=i.value;return i.value=function(a){return $e(a,r,e),o.apply(this,[a])},i}}var at=class r extends l{constructor(e){super(),this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let n=e.deserializeFixedBytes(t);return new r(n)}};var Mr=class r extends l{constructor(e){super(),this.value=new at(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let n=at.deserialize(e,t);return new r(n.value)}};var Vr=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(Vr||{}),Ni= exports.TypeTagVariants =(y=>(y[y.Bool=0]="Bool",y[y.U8=1]="U8",y[y.U64=2]="U64",y[y.U128=3]="U128",y[y.Address=4]="Address",y[y.Signer=5]="Signer",y[y.Vector=6]="Vector",y[y.Struct=7]="Struct",y[y.U16=8]="U16",y[y.U32=9]="U32",y[y.U256=10]="U256",y[y.Reference=254]="Reference",y[y.Generic=255]="Generic",y))(Ni||{}),ir= exports.ScriptTransactionArgumentVariants =(d=>(d[d.U8=0]="U8",d[d.U64=1]="U64",d[d.U128=2]="U128",d[d.Address=3]="Address",d[d.U8Vector=4]="U8Vector",d[d.Bool=5]="Bool",d[d.U16=6]="U16",d[d.U32=7]="U32",d[d.U256=8]="U256",d[d.Serialized=9]="Serialized",d))(ir||{}),Fi= exports.TransactionPayloadVariants =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(Fi||{}),Gi= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(Gi||{}),Bi= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(Bi||{}),Mi= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o[o.NoAccountAuthenticator=4]="NoAccountAuthenticator",o))(Mi||{}),Lr= exports.PrivateKeyVariants =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(Lr||{}),qr= exports.AnyPublicKeyVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.Secp256k1=1]="Secp256k1",i[i.Keyless=3]="Keyless",i[i.FederatedKeyless=4]="FederatedKeyless",i))(qr||{}),Vi= exports.AnySignatureVariant =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))(Vi||{}),Nn= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Nn||{}),Li= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Li||{}),Fn= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(Fn||{}),Gn= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(Gn||{}),Bn= exports.TransactionResponseType =(a=>(a.Pending="pending_transaction",a.User="user_transaction",a.Genesis="genesis_transaction",a.BlockMetadata="block_metadata_transaction",a.StateCheckpoint="state_checkpoint_transaction",a.Validator="validator_transaction",a.BlockEpilogue="block_epilogue_transaction",a))(Bn||{});function sp(r){return r.type==="pending_transaction"}function ap(r){return r.type==="user_transaction"}function cp(r){return r.type==="genesis_transaction"}function up(r){return r.type==="block_metadata_transaction"}function pp(r){return r.type==="state_checkpoint_transaction"}function dp(r){return r.type==="validator_transaction"}function lp(r){return r.type==="block_epilogue_transaction"}function gp(r){return"signature"in r&&r.signature==="ed25519_signature"}function yp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function mp(r){return r.type==="multi_agent_signature"}function fp(r){return r.type==="fee_payer_signature"}function Ap(r){return r.type==="multi_ed25519_signature"}var Na=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Na||{}),qi= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(qi||{}),Fa= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(Fa||{}),he= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(he||{}),Mn= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Mn||{}),Hi= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Hi||{});var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var U=class r extends l{constructor(e){super(),zn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new de(e.deserializeU256())}static deserialize(e){return new r(e.deserializeBool())}},j= exports.U8 =class r extends l{constructor(e){super(),$e(e,0,Fr),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new r(e.deserializeU8())}},Te= exports.U16 =class r extends l{constructor(e){super(),$e(e,0,Gr),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new r(e.deserializeU16())}},be= exports.U32 =class r extends l{constructor(e){super(),$e(e,0,Ue),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new r(e.deserializeU32())}},$= exports.U64 =class r extends l{constructor(e){super(),$e(e,BigInt(0),ot),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new r(e.deserializeU64())}},we= exports.U128 =class r extends l{constructor(e){super(),$e(e,BigInt(0),nr),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new r(e.deserializeU128())}},de= exports.U256 =class r extends l{constructor(e){super(),$e(e,BigInt(0),Br),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new r(e.deserializeU256())}};var b=class r extends l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof j)){new or(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let n=g.fromHexInput(e);t=Array.from(n.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new r(t.map(n=>new j(n)))}static U16(e){return new r(e.map(t=>new Te(t)))}static U32(e){return new r(e.map(t=>new be(t)))}static U64(e){return new r(e.map(t=>new $(t)))}static U128(e){return new r(e.map(t=>new we(t)))}static U256(e){return new r(e.map(t=>new de(t)))}static Bool(e){return new r(e.map(t=>new U(t)))}static MoveString(e){return new r(e.map(t=>new S(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let n=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<n;o+=1)i.push(t.deserialize(e));return new r(i)}},or= exports.Serialized =class r extends l{constructor(e){super(),this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new r(e.deserializeBytes())}toMoveVector(e){let t=new D(this.bcsToBytes());t.deserializeUleb128AsU32();let n=t.deserializeVector(e);return new b(n)}},S= exports.MoveString =class r extends l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let n=new TextEncoder().encode(this.value);b.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},J= exports.MoveOption =class r extends l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new b([e]):this.vec=new b([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new j(e):void 0)}static U16(e){return new r(e!=null?new Te(e):void 0)}static U32(e){return new r(e!=null?new be(e):void 0)}static U64(e){return new r(e!=null?new $(e):void 0)}static U128(e){return new r(e!=null?new we(e):void 0)}static U256(e){return new r(e!=null?new de(e):void 0)}static Bool(e){return new r(e!=null?new U(e):void 0)}static MoveString(e){return new r(e!=null?new S(e):void 0)}static deserialize(e,t){let n=b.deserialize(e,t);return new r(n.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ba=(c=>(c.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",c.INVALID_HEX_CHARS="invalid_hex_chars",c.TOO_SHORT="too_short",c.TOO_LONG="too_long",c.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",c.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",c.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",c.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",c))(Ba||{}),E=class E extends l{constructor(e){if(super(),e.length!==E.LENGTH)throw new Q("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(E.LENGTH);return new E(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new Q("Hex string must start with a leading 0x.","leading_zero_x_required");let t=E.fromString(e);if(e.length!==E.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new Q(`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 Q(`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 Q("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new Q("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 Q(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let i;try{i=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(s){throw new Q(`Hex characters are invalid: ${_optionalChain([s, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let o=new E(i);if(n.length<64-t&&!o.isSpecial())throw new Q(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
2
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 o}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?E.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new E(e):e}static fromStrict(e){return typeof e=="string"?E.fromStringStrict(e):e instanceof Uint8Array?new E(e):e}static isValid(e){try{return e.strict?E.fromStrict(e.input):E.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])}};E.LENGTH=32,E.LONG_STRING_LENGTH=64,E.ZERO=E.from("0x0"),E.ONE=E.from("0x1"),E.TWO=E.from("0x2"),E.THREE=E.from("0x3"),E.FOUR=E.from("0x4"),E.A=E.from("0xA");var u=E;var We=class We extends l{constructor(e){super();let{data:t}=e,n=g.fromHexInput(t);if(n.toUint8Array().length!==We.LENGTH)throw new Error(`Authentication Key length should be ${We.LENGTH}`);this.data=n}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(We.LENGTH);return new We({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:n}=e,i=g.fromHexInput(n).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new We({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};We.LENGTH=32;var B=We;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Vi = _interopRequireWildcard(_bip39);var Fa=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ga= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Ba= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Ba||{}),Li= exports.HARDENED_OFFSET =2147483648;function qi(r){return Ga.test(r)}function Hi(r){return Fa.test(r)}var Gn=(r,e)=>{let t=_hmac.hmac.create(_sha512.sha512,r).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},$i= exports.CKDPriv =({key:r,chainCode:e},t)=>{let n=new ArrayBuffer(4);new DataView(n).setUint32(0,t);let i=new Uint8Array(n),o=new Uint8Array([0]),s=new Uint8Array([...o,...r,...i]);return Gn(e,s)},Ma=r=>r.replace(/'/g,""),Wi= exports.splitPath =r=>r.split("/").slice(1).map(Ma),Mr= exports.mnemonicToSeed =r=>{let e=r.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return Vi.mnemonicToSeedSync(e)};var er=class er{static formatPrivateKey(e,t){return`${er.AIP80_PREFIXES[t]}${g.fromHexInput(e).toString()}`}static parseHexInput(e,t,n){let i,o=er.AIP80_PREFIXES[t];if(typeof e=="string")if(!n&&!e.startsWith(o))i=g.fromHexInput(e),n!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=g.fromHexString(e.split("-")[2]);else throw n?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=g.fromHexInput(e),n!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are parsed as AIP-80 compliant strings instead of Uint8Array (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: Uint8Array, type: 'ed25519' | 'secp256k1'): string`.");return i}};er.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var Qe=er;var at=class extends l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return g.fromHexInput(e).toString()}},ne= exports.AccountPublicKey =class extends at{};var M=class extends l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return g.fromHexInput(e).toString()}};var xt=r=>typeof r=="string"?g.isValid(r).valid?r:new TextEncoder().encode(r):r;var Bn=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Va(r){let e=r.toUint8Array().slice(32);for(let t=Bn.length-1;t>=0;t-=1){if(e[t]<Bn[t])return!0;if(e[t]>Bn[t])return!1}return!1}var je=class je extends ne{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==je.LENGTH)throw new Error(`PublicKey length should be ${je.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!Va(n))return!1;let i=xt(t),o=g.fromHexInput(i).toUint8Array(),s=n.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new je(t)}static isPublicKey(e){return e instanceof je}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _8 => _8.key, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.length])===je.LENGTH}};je.LENGTH=32;var P=je,le=class le extends l{constructor(e,t){super();let n=Qe.parseHexInput(e,"ed25519",t);if(n.toUint8Array().length!==le.LENGTH)throw new Error(`PrivateKey length should be ${le.LENGTH}`);this.signingKey=n}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new le(e,!1)}static fromDerivationPath(e,t){if(!Hi(e))throw new Error(`Invalid derivation path ${e}`);return le.fromDerivationPathInner(e,Mr(t))}static fromDerivationPathInner(e,t,n=Li){let{key:i,chainCode:o}=Gn(le.SLIP_0010_SEED,t),s=Wi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>$i(c,p+n),{key:i,chainCode:o});return new le(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let t=xt(e),n=g.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(n,this.signingKey.toUint8Array());return new I(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Qe.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new le(t,!1)}static isPrivateKey(e){return e instanceof le}};le.LENGTH=32,le.SLIP_0010_SEED="ed25519 seed";var Y=le,Et=class Et extends M{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==Et.LENGTH)throw new Error(`Signature length should be ${Et.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Et(t)}};Et.LENGTH=64;var I=Et;var ge=class ge extends ne{constructor(e){super();let{publicKeys:t,threshold:n}=e;if(t.length>ge.MAX_KEYS||t.length<ge.MIN_KEYS)throw new Error(`Must have between ${ge.MIN_KEYS} and ${ge.MAX_KEYS} public keys, inclusive`);if(n<ge.MIN_THRESHOLD||n>t.length)throw new Error(`Threshold must be between ${ge.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=n}verifySignature(e){let{message:t,signature:n}=e;if(!(n instanceof ct))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((n.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==n.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:n.signatures[o]}))return!1;return!0}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((t,n)=>{e.set(t.toUint8Array(),n*P.LENGTH)}),e[this.publicKeys.length*P.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=P.LENGTH){let s=o;i.push(new P(t.subarray(s,s+P.LENGTH)))}return new ge({publicKeys:i,threshold:n})}};ge.MAX_KEYS=32,ge.MIN_KEYS=2,ge.MIN_THRESHOLD=1;var Pt=ge,oe=class oe extends M{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>oe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${oe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(n instanceof Uint8Array))this.bitmap=oe.createBitmap({bits:n});else{if(n.length!==oe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${oe.BITMAP_LEN}`);this.bitmap=n}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+oe.BITMAP_LEN);return this.signatures.forEach((t,n)=>{e.set(t.toUint8Array(),n*I.LENGTH)}),e.set(this.bitmap,this.signatures.length*I.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-n.length;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new oe({signatures:i,bitmap:n})}static createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=oe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${oe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}};oe.MAX_SIGNATURES_SUPPORTED=32,oe.BITMAP_LEN=4;var ct=oe;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Je=class Je extends at{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==Je.LENGTH)throw new Error(`PublicKey length should be ${Je.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e,i=xt(t),o=g.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=n.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new pt(t)}static deserialize(e){let t=e.deserializeBytes();return new Je(t)}static isPublicKey(e){return e instanceof Je}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _11 => _11.key, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.length])===Je.LENGTH}};Je.LENGTH=65;var Ue=Je,Se=class Se extends l{constructor(e,t){super();let n=Qe.parseHexInput(e,"secp256k1",t);if(n.toUint8Array().length!==Se.LENGTH)throw new Error(`PrivateKey length should be ${Se.LENGTH}`);this.key=n}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Se(e,!1)}static fromDerivationPath(e,t){if(!qi(e))throw new Error(`Invalid derivation path ${e}`);return Se.fromDerivationPathInner(e,Mr(t))}static fromDerivationPathInner(e,t){let{privateKey:n}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(n===null)throw new Error("Invalid key");return new Se(n,!1)}sign(e){let t=xt(e),n=g.fromHexInput(t),i=_sha3.sha3_256.call(void 0, n.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new pt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Ue(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return Qe.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Se(t,!1)}static isPrivateKey(e){return e instanceof Se}};Se.LENGTH=32;var ut=Se,vt=class vt extends M{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==vt.LENGTH)throw new Error(`Signature length should be ${vt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new vt(t)}};vt.LENGTH=64;var pt=vt;var _jwtdecode = require('jwt-decode');var dt=class r extends at{constructor(e){super();let t=e.constructor.name;switch(t){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:n}=e;return this.publicKey.verifySignature({message:t,signature:n.signature})}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof r}},xe= exports.EphemeralSignature =class r extends M{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=g.fromHexInput(e),n=new N(t.toUint8Array());return r.deserialize(n)}serialize(e){if(this.signature instanceof I)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Mn=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Ji=31,sc=16,ji=(sc-1)*Ji;function qr(r,e){let n=new TextEncoder().encode(r);return ac(n,e)}function ac(r,e){if(r.length>e)throw new Error(`Inputted bytes of length ${r} is longer than ${e}`);let t=Vn(r,e);return rr(t)}function cc(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);let t=dc(r,e);return uc(t)}function Vn(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);return cc(r,e).concat([BigInt(r.length)])}function uc(r){if(r.length>ji)throw new Error(`Can't pack more than ${ji}. Was given ${r.length} bytes`);return pc(r,Ji).map(e=>tr(e))}function pc(r,e){let t=[];for(let n=0;n<r.length;n+=e)t.push(r.subarray(n,n+e));return t}function tr(r){let e=BigInt(0);for(let t=r.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(r[t]);return e}function Xi(r,e){let t=BigInt(r),n=new Uint8Array(e);for(let i=0;i<e;i+=1)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);return n}function dc(r,e){if(e<r.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(r);for(let n=r.length;n<e;n+=1)t[n]=0;return t}function rr(r){if(r.length>Mn.length)throw new Error(`Unable to hash input of length ${r.length}. Max input length is ${Mn.length}`);return Mn[r.length-1](r)}var Hr=class extends l{};var Yi="1.32.1";var Zi={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},eo= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},to= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Ln= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},qn= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Hn= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(Hn||{}),$n= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},gl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var It=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(It||{}),ro= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,no= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,$r= exports.DEFAULT_TXN_TIMEOUT_SEC =20,lt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",io= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",oo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Wn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ke= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(Ke||{}),so= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function ao(r,e){let t=e.bcsToBytes(),n=new N(t);return r.deserialize(n)}var lc=(o=>(o[o.API_ERROR=0]="API_ERROR",o[o.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",o[o.SESSION_EXPIRED=2]="SESSION_EXPIRED",o[o.INVALID_STATE=3]="INVALID_STATE",o[o.UNKNOWN=4]="UNKNOWN",o))(lc||{}),gc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(gc||{}),Wr= exports.KeylessErrorType =(m=>(m[m.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",m[m.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",m[m.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",m[m.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",m[m.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",m[m.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",m[m.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",m[m.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",m[m.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",m[m.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",m[m.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",m[m.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",m[m.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",m[m.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",m[m.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",m[m.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",m[m.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",m[m.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",m[m.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",m[m.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",m[m.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",m[m.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",m[m.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",m[m.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",m[m.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",m[m.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",m[m.UNKNOWN=26]="UNKNOWN",m))(Wr||{}),co={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["An unknown error has occurred.",4,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},K= exports.KeylessError =class r extends Error{constructor(e){let{innerError:t,category:n,resolutionTip:i,type:o,message:s=co[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=n,this.resolutionTip=i,this.type=o,this.details=a,this.message=r.constructMessage(s,i,t,a)}static constructMessage(e,t,n,i){let o=`
3
+ Received ${e}`,"too_short");return o}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?E.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new E(e):e}static fromStrict(e){return typeof e=="string"?E.fromStringStrict(e):e instanceof Uint8Array?new E(e):e}static isValid(e){try{return e.strict?E.fromStrict(e.input):E.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])}};E.LENGTH=32,E.LONG_STRING_LENGTH=64,E.ZERO=E.from("0x0"),E.ONE=E.from("0x1"),E.TWO=E.from("0x2"),E.THREE=E.from("0x3"),E.FOUR=E.from("0x4"),E.A=E.from("0xA");var u=E;var We=class We extends l{constructor(e){super();let{data:t}=e,n=g.fromHexInput(t);if(n.toUint8Array().length!==We.LENGTH)throw new Error(`Authentication Key length should be ${We.LENGTH}`);this.data=n}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(We.LENGTH);return new We({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:n}=e,i=g.fromHexInput(n).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new We({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};We.LENGTH=32;var B=We;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Wi = _interopRequireWildcard(_bip39);var qa=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ha= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,$a= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))($a||{}),Qi= exports.HARDENED_OFFSET =2147483648;function ji(r){return Ha.test(r)}function Ji(r){return qa.test(r)}var Ln=(r,e)=>{let t=_hmac.hmac.create(_sha512.sha512,r).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Xi= exports.CKDPriv =({key:r,chainCode:e},t)=>{let n=new ArrayBuffer(4);new DataView(n).setUint32(0,t);let i=new Uint8Array(n),o=new Uint8Array([0]),s=new Uint8Array([...o,...r,...i]);return Ln(e,s)},Wa=r=>r.replace(/'/g,""),Yi= exports.splitPath =r=>r.split("/").slice(1).map(Wa),Hr= exports.mnemonicToSeed =r=>{let e=r.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return Wi.mnemonicToSeedSync(e)};var sr=class sr{static formatPrivateKey(e,t){return`${sr.AIP80_PREFIXES[t]}${g.fromHexInput(e).toString()}`}static parseHexInput(e,t,n){let i,o=sr.AIP80_PREFIXES[t];if(typeof e=="string")if(!n&&!e.startsWith(o))i=g.fromHexInput(e),n!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=g.fromHexString(e.split("-")[2]);else throw n?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=g.fromHexInput(e),n!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are parsed as AIP-80 compliant strings instead of Uint8Array (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: Uint8Array, type: 'ed25519' | 'secp256k1'): string`.");return i}};sr.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var Qe=sr;var ct=class extends l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return g.fromHexInput(e).toString()}},ne= exports.AccountPublicKey =class extends ct{};var M=class extends l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return g.fromHexInput(e).toString()}};var vt=r=>typeof r=="string"?g.isValid(r).valid?r:new TextEncoder().encode(r):r;var qn=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Qa(r){let e=r.toUint8Array().slice(32);for(let t=qn.length-1;t>=0;t-=1){if(e[t]<qn[t])return!0;if(e[t]>qn[t])return!1}return!1}var je=class je extends ne{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==je.LENGTH)throw new Error(`PublicKey length should be ${je.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!Qa(n))return!1;let i=vt(t),o=g.fromHexInput(i).toUint8Array(),s=n.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new je(t)}static isPublicKey(e){return e instanceof je}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _8 => _8.key, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.length])===je.LENGTH}};je.LENGTH=32;var P=je,le=class le extends l{constructor(e,t){super();let n=Qe.parseHexInput(e,"ed25519",t);if(n.toUint8Array().length!==le.LENGTH)throw new Error(`PrivateKey length should be ${le.LENGTH}`);this.signingKey=n}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new le(e,!1)}static fromDerivationPath(e,t){if(!Ji(e))throw new Error(`Invalid derivation path ${e}`);return le.fromDerivationPathInner(e,Hr(t))}static fromDerivationPathInner(e,t,n=Qi){let{key:i,chainCode:o}=Ln(le.SLIP_0010_SEED,t),s=Yi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Xi(c,p+n),{key:i,chainCode:o});return new le(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let t=vt(e),n=g.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(n,this.signingKey.toUint8Array());return new I(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Qe.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new le(t,!1)}static isPrivateKey(e){return e instanceof le}};le.LENGTH=32,le.SLIP_0010_SEED="ed25519 seed";var Z=le,It=class It extends M{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==It.LENGTH)throw new Error(`Signature length should be ${It.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new It(t)}};It.LENGTH=64;var I=It;var ge=class ge extends ne{constructor(e){super();let{publicKeys:t,threshold:n}=e;if(t.length>ge.MAX_KEYS||t.length<ge.MIN_KEYS)throw new Error(`Must have between ${ge.MIN_KEYS} and ${ge.MAX_KEYS} public keys, inclusive`);if(n<ge.MIN_THRESHOLD||n>t.length)throw new Error(`Threshold must be between ${ge.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=n}verifySignature(e){let{message:t,signature:n}=e;if(!(n instanceof ut))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((n.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==n.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:n.signatures[o]}))return!1;return!0}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((t,n)=>{e.set(t.toUint8Array(),n*P.LENGTH)}),e[this.publicKeys.length*P.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=P.LENGTH){let s=o;i.push(new P(t.subarray(s,s+P.LENGTH)))}return new ge({publicKeys:i,threshold:n})}};ge.MAX_KEYS=32,ge.MIN_KEYS=2,ge.MIN_THRESHOLD=1;var Ct=ge,oe=class oe extends M{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>oe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${oe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(n instanceof Uint8Array))this.bitmap=oe.createBitmap({bits:n});else{if(n.length!==oe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${oe.BITMAP_LEN}`);this.bitmap=n}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+oe.BITMAP_LEN);return this.signatures.forEach((t,n)=>{e.set(t.toUint8Array(),n*I.LENGTH)}),e.set(this.bitmap,this.signatures.length*I.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-n.length;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new oe({signatures:i,bitmap:n})}static createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=oe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${oe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}};oe.MAX_SIGNATURES_SUPPORTED=32,oe.BITMAP_LEN=4;var ut=oe;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Je=class Je extends ct{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==Je.LENGTH)throw new Error(`PublicKey length should be ${Je.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e,i=vt(t),o=g.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=n.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new dt(t)}static deserialize(e){let t=e.deserializeBytes();return new Je(t)}static isPublicKey(e){return e instanceof Je}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _11 => _11.key, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.length])===Je.LENGTH}};Je.LENGTH=65;var Ke=Je,Se=class Se extends l{constructor(e,t){super();let n=Qe.parseHexInput(e,"secp256k1",t);if(n.toUint8Array().length!==Se.LENGTH)throw new Error(`PrivateKey length should be ${Se.LENGTH}`);this.key=n}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Se(e,!1)}static fromDerivationPath(e,t){if(!ji(e))throw new Error(`Invalid derivation path ${e}`);return Se.fromDerivationPathInner(e,Hr(t))}static fromDerivationPathInner(e,t){let{privateKey:n}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(n===null)throw new Error("Invalid key");return new Se(n,!1)}sign(e){let t=vt(e),n=g.fromHexInput(t),i=_sha3.sha3_256.call(void 0, n.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new dt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Ke(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return Qe.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Se(t,!1)}static isPrivateKey(e){return e instanceof Se}};Se.LENGTH=32;var pt=Se,Rt=class Rt extends M{constructor(e){super();let t=g.fromHexInput(e);if(t.toUint8Array().length!==Rt.LENGTH)throw new Error(`Signature length should be ${Rt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Rt(t)}};Rt.LENGTH=64;var dt=Rt;var _jwtdecode = require('jwt-decode');var lt=class r extends ct{constructor(e){super();let t=e.constructor.name;switch(t){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:n}=e;return this.publicKey.verifySignature({message:t,signature:n.signature})}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof r}},xe= exports.EphemeralSignature =class r extends M{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=g.fromHexInput(e),n=new D(t.toUint8Array());return r.deserialize(n)}serialize(e){if(this.signature instanceof I)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Hn=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],to=31,lc=16,eo=(lc-1)*to;function Qr(r,e){let n=new TextEncoder().encode(r);return gc(n,e)}function gc(r,e){if(r.length>e)throw new Error(`Inputted bytes of length ${r} is longer than ${e}`);let t=$n(r,e);return cr(t)}function yc(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);let t=Ac(r,e);return mc(t)}function $n(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);return yc(r,e).concat([BigInt(r.length)])}function mc(r){if(r.length>eo)throw new Error(`Can't pack more than ${eo}. Was given ${r.length} bytes`);return fc(r,to).map(e=>ar(e))}function fc(r,e){let t=[];for(let n=0;n<r.length;n+=e)t.push(r.subarray(n,n+e));return t}function ar(r){let e=BigInt(0);for(let t=r.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(r[t]);return e}function ro(r,e){let t=BigInt(r),n=new Uint8Array(e);for(let i=0;i<e;i+=1)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);return n}function Ac(r,e){if(e<r.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(r);for(let n=r.length;n<e;n+=1)t[n]=0;return t}function cr(r){if(r.length>Hn.length)throw new Error(`Unable to hash input of length ${r.length}. Max input length is ${Hn.length}`);return Hn[r.length-1](r)}var jr=class extends l{};var no="1.33.0";var io={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},oo= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},so= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Wn= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Qn= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},jn= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(jn||{}),Jn= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},_l= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var gt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(gt||{}),ao= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,co= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Jr= exports.DEFAULT_TXN_TIMEOUT_SEC =20,yt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",uo= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",po= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Xn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",ke= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(ke||{}),lo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function go(r,e){let t=e.bcsToBytes(),n=new D(t);return r.deserialize(n)}var hc=(o=>(o[o.API_ERROR=0]="API_ERROR",o[o.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",o[o.SESSION_EXPIRED=2]="SESSION_EXPIRED",o[o.INVALID_STATE=3]="INVALID_STATE",o[o.UNKNOWN=4]="UNKNOWN",o))(hc||{}),Tc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(Tc||{}),Xr= exports.KeylessErrorType =(m=>(m[m.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",m[m.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",m[m.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",m[m.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",m[m.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",m[m.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",m[m.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",m[m.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",m[m.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",m[m.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",m[m.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",m[m.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",m[m.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",m[m.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",m[m.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",m[m.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",m[m.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",m[m.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",m[m.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",m[m.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",m[m.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",m[m.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",m[m.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",m[m.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",m[m.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",m[m.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",m[m.UNKNOWN=26]="UNKNOWN",m))(Xr||{}),yo={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["An unknown error has occurred.",4,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},K= exports.KeylessError =class r extends Error{constructor(e){let{innerError:t,category:n,resolutionTip:i,type:o,message:s=yo[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=n,this.resolutionTip=i,this.type=o,this.details=a,this.message=r.constructMessage(s,i,t,a)}static constructMessage(e,t,n,i){let o=`
4
4
  Message: ${e}`;return i&&(o+=`
5
5
  Details: ${i}`),n instanceof ye?o+=`
6
6
  AptosApiError: ${n.message}`:n!==void 0&&(o+=`
7
7
  Error: ${_chunkF43XVDYJjs.c.call(void 0, n)}`),o+=`
8
- KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,details:i}=e,[o,s,a]=co[n];return new r({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:n})}},ye= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:n}){super(yc({apiType:e,aptosRequest:t,aptosResponse:n})),this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=t}};function yc({apiType:r,aptosRequest:e,aptosResponse:t}){let n=_optionalChain([t, 'access', _14 => _14.headers, 'optionalAccess', _15 => _15.traceparent, 'optionalAccess', _16 => _16.split, 'call', _17 => _17("-"), 'access', _18 => _18[1]]),i=n?`(trace_id:${n}) `:"",o=`Request to [${r}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return r==="Indexer"&&_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.errors, 'optionalAccess', _21 => _21[0], 'optionalAccess', _22 => _22.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _23 => _23.data, 'optionalAccess', _24 => _24.message])!=null&&_optionalChain([t, 'access', _25 => _25.data, 'optionalAccess', _26 => _26.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${mc(t.data)}`}var Qn=400;function mc(r){let e=JSON.stringify(r);return e.length<=Qn?e:`truncated(original_size:${e.length}): ${e.slice(0,Qn/2)}...${e.slice(-Qn/2)}`}async function fc(r,e){let{url:t,method:n,body:i,contentType:o,params:s,overrides:a,originMethod:c}=r,p={..._optionalChain([a, 'optionalAccess', _27 => _27.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Yi}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _28 => _28.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _29 => _29.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _30 => _30.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _31 => _31.API_KEY])}`),e.provider({url:t,method:n,body:i,params:s,headers:p,overrides:a})}async function Qr(r,e,t){let{url:n,path:i}=r,o=i?`${n}/${i}`:n,s=await fc({...r,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ye({apiType:t,aptosRequest:r,aptosResponse:a})}async function jn(r){let{aptosConfig:e,overrides:t,params:n,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=r,p=e.getRequestUrl(c);return Qr({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:n,overrides:{...e.clientConfig,...t}},e,r.type)}async function V(r){let{aptosConfig:e}=r;return jn({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function Bl(r){return jn({...r,type:"Pepper"})}async function Ct(r){let e=[],t,n=r.params;do{let i=await jn({type:"Fullnode",aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),n.start=t}while(t!=null);return e}async function nr(r){let{type:e,originMethod:t,path:n,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=r,d=c.getRequestUrl(e);return Qr({url:d,method:"POST",originMethod:t,path:n,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,r.type)}async function Xe(r){let{aptosConfig:e}=r;return nr({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.fullnodeConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function uo(r){let{aptosConfig:e}=r;return nr({...r,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([e, 'access', _42 => _42.indexerConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function po(r){let{aptosConfig:e}=r,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _44 => _44.clientConfig, 'optionalAccess', _45 => delete _45.API_KEY]),nr({...r,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...r.overrides,HEADERS:{..._optionalChain([t, 'access', _46 => _46.clientConfig, 'optionalAccess', _47 => _47.HEADERS]),..._optionalChain([t, 'access', _48 => _48.faucetConfig, 'optionalAccess', _49 => _49.HEADERS])}}})}async function lo(r){return nr({...r,type:"Pepper"})}async function go(r){return nr({...r,type:"Prover"})}var Jn=new Map;function Ee(r,e,t){return async(...n)=>{if(Jn.has(e)){let{value:o,timestamp:s}=Jn.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await r(...n);return Jn.set(e,{value:i,timestamp:Date.now()}),i}}var Tg=1e7,hc= exports.MAX_AUD_VAL_BYTES =120,Tc= exports.MAX_UID_KEY_BYTES =30,bc= exports.MAX_UID_VAL_BYTES =330,bg= exports.MAX_ISS_VAL_BYTES =120,wg= exports.MAX_EXTRA_FIELD_BYTES =350,_g= exports.MAX_JWT_HEADER_B64_BYTES =300,Sg= exports.MAX_COMMITED_EPK_BYTES =93,Pe=class Pe extends ne{constructor(e,t){super();let n=g.fromHexInput(t).toUint8Array();if(n.length!==Pe.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Pe.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=n}authKey(){let e=new H;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Pe(t,n)}static load(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Pe(t,n)}static isPublicKey(e){return e instanceof Pe}static create(e){return yo(e),new Pe(e.iss,yo(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:n,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Pe.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:n})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Pe.ID_COMMITMENT_LENGTH=32;var D=Pe;function yo(r){let{uidKey:e,uidVal:t,aud:n,pepper:i}=r,o=[tr(g.fromHexInput(i).toUint8Array()),qr(n,hc),qr(t,bc),qr(e,Tc)];return Xi(rr(o),D.ID_COMMITMENT_LENGTH)}var De=class r extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:n,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=n,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Sc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Rt.deserialize(e),n=e.deserializeStr(),i=e.deserializeU64(),o=dt.deserialize(e),s=xe.deserialize(e);return new r({jwtHeader:n,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new r({jwtHeader:"{}",ephemeralCertificate:new Rt(new Oe({proof:new Kt(new Ut({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new dt(new P(new Uint8Array(32))),ephemeralSignature:new xe(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof r}},Rt= exports.EphemeralCertificate =class r extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(Oe.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},ke=class r extends l{constructor(e){if(super(),this.data=g.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new r(t)}},gt=class r extends l{constructor(e){if(super(),this.data=g.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new r(t)}},Ut= exports.Groth16Zkp =class r extends Hr{constructor(e){super();let{a:t,b:n,c:i}=e;this.a=new ke(t),this.b=new gt(n),this.c=new ke(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=ke.deserialize(e).bcsToBytes(),n=gt.deserialize(e).bcsToBytes(),i=ke.deserialize(e).bcsToBytes();return new r({a:t,b:n,c:i})}},Kt= exports.ZkProof =class r extends l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(Ut.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},Oe= exports.ZeroKnowledgeSig =class r extends M{constructor(e){super();let{proof:t,expHorizonSecs:n,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=n,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return r.deserialize(new N(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Kt.deserialize(e),n=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(xe);return new r({proof:t,expHorizonSecs:n,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Xn= exports.KeylessConfiguration =class r{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new r(new Yn({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},Yn= exports.Groth16VerificationKey =class r{constructor(e){let{alphaG1:t,betaG2:n,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new ke(t),this.betaG2=new gt(n),this.deltaG2=new gt(i),this.gammaAbcG1=[new ke(o[0]),new ke(o[1])],this.gammaG2=new gt(s)}hash(){let e=new H;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new r({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function ir(r){let{aptosConfig:e}=r;try{return await Ee(async()=>{let t=await wc(r),n=await _c(r);return Xn.create(n,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof K?t:K.fromErrorType({type:25,error:t})}}function kt(r){let{jwt:e,uidKey:t="sub"}=r,n;try{n=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw K.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkF43XVDYJjs.c.call(void 0, o)}`})}if(typeof n.iss!="string")throw K.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof n.aud!="string")throw K.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=n[t];return{iss:n.iss,aud:n.aud,uidVal:i}}async function wc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _50 => _50.ledgerVersion])}});return i.data}catch(i){throw K.fromErrorType({type:22,error:i})}}async function _c(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _51 => _51.ledgerVersion])}});return i.data}catch(i){throw K.fromErrorType({type:23,error:i})}}async function fo(r){let{aptosConfig:e,jwkAddr:t,options:n}=r,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _52 => _52.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _53 => _53.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,d=new N(g.fromHexInput(p).toUint8Array()),A=Zn.deserialize(d);a.push(A)}o.set(Ui(s.issuer),a)}return o}var Zn=class r extends l{constructor(e){super();let{kid:t,kty:n,alg:i,e:o,n:s}=e;this.kid=t,this.kty=n,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,n=new N(g.fromHexInput(t).toUint8Array());return r.deserialize(n)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new r({kid:t,kty:n,alg:i,n:o,e:s})}};function Sc(r){try{let e=JSON.parse(r);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var Z=class r extends ne{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new H;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=D.deserialize(e);return new r(t,n)}static isPublicKey(e){return e instanceof r}static create(e){return new r(e.jwkAddress,D.create(e))}static fromJwtAndPepper(e){return new r(e.jwkAddress,D.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof D}};var F=class r extends ne{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof Ue)this.variant=1;else if(e instanceof D)this.variant=3;else if(e instanceof Z)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:n}=e;return L.isInstance(n)?this.publicKey.verifySignature({message:t,signature:n.signature}):!1}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=P.deserialize(e);break;case 1:n=Ue.deserialize(e);break;case 3:n=D.deserialize(e);break;case 4:n=Z.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new r(n)}static isPublicKey(e){return e instanceof r}isEd25519(){return this.publicKey instanceof P}isSecp256k1PublicKey(){return this.publicKey instanceof Ue}static isInstance(e){return"publicKey"in e&&"variant"in e}},L= exports.AnySignature =class r extends M{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof pt)this.variant=1;else if(e instanceof De)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=I.deserialize(e);break;case 1:n=pt.deserialize(e);break;case 3:n=De.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new r(n)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function xc(r){let e=r;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Ye=class r extends ne{constructor(e){super();let{publicKeys:t,signaturesRequired:n}=e;if(n<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<n)throw new Error(`Provided ${t.length} public keys is smaller than the ${n} required signatures`);this.publicKeys=t.map(i=>i instanceof F?i:new F(i)),this.signaturesRequired=n}verifySignature(e){throw new Error("not implemented")}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(F),n=e.deserializeU8();return new r({publicKeys:t,signaturesRequired:n})}createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}getIndex(e){let t=e instanceof F?e:new F(e),n=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(n!==-1)return n;throw new Error("Public key not found in MultiKey")}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},se=class se extends M{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>se.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${se.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof L?o:new L(o)),!(n instanceof Uint8Array))this.bitmap=se.createBitmap({bits:n});else{if(n.length!==se.BITMAP_LEN)throw new Error(`"bitmap" length should be ${se.BITMAP_LEN}`);this.bitmap=n}let i=this.bitmap.reduce((o,s)=>o+xc(s),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:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=se.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${se.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=n>>s%8,i[a]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(L),n=e.deserializeBytes();return new se({signatures:t,bitmap:n})}};se.BITMAP_LEN=4,se.MAX_SIGNATURES_SUPPORTED=se.BITMAP_LEN*8;var ze=se;var ee=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _e.load(e);case 1:return jr.load(e);case 2:return ie.load(e);case 3:return ve.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof _e}isMultiEd25519(){return this instanceof jr}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof ve}},_e= exports.AccountAuthenticatorEd25519 =class r extends ee{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},jr= exports.AccountAuthenticatorMultiEd25519 =class r extends ee{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Pt.deserialize(e),n=ct.deserialize(e);return new r(t,n)}},ie= exports.AccountAuthenticatorSingleKey =class r extends ee{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=F.deserialize(e),n=L.deserialize(e);return new r(t,n)}},ve= exports.AccountAuthenticatorMultiKey =class r extends ee{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Ye.deserialize(e),n=ze.deserialize(e);return new r(t,n)}};var Dt=class r extends l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new r(t)}};var R=class r extends l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new r(t)}};var Jr=(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,254]);return new u(_sha3.sha3_256.call(void 0, i))},Dy= exports.createResourceAddress =(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,255]);return new u(_sha3.sha3_256.call(void 0, i))},Oy= exports.createTokenAddress =(r,e,t)=>{let n=`${e}::${t}`;return Jr(r,n)};var or=class r extends l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new r(u.fromString(t[0]),new R(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e);return new r(t,n)}};var O=class r extends l{deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(r);return new Ie(t,n,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return G.load(e);case 1:return ae.load(e);case 2:return W.load(e);case 3:return Ge.load(e);case 4:return X.load(e);case 5:return yt.load(e);case 6:return C.load(e);case 7:return f.load(e);case 8:return Ne.load(e);case 9:return Fe.load(e);case 10:return Be.load(e);case 255:return z.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof X}isGeneric(){return this instanceof z}isSigner(){return this instanceof yt}isVector(){return this instanceof C}isStruct(){return this instanceof f}isU8(){return this instanceof ae}isU16(){return this instanceof Ne}isU32(){return this instanceof Fe}isU64(){return this instanceof W}isU128(){return this instanceof Ge}isU256(){return this instanceof Be}isPrimitive(){return this instanceof yt||this instanceof X||this instanceof G||this instanceof ae||this instanceof Ne||this instanceof Fe||this instanceof W||this instanceof Ge||this instanceof Be}},G= exports.TypeTagBool =class r extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new r}},ae= exports.TypeTagU8 =class r extends O{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new r}},Ne= exports.TypeTagU16 =class r extends O{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new r}},Fe= exports.TypeTagU32 =class r extends O{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new r}},W= exports.TypeTagU64 =class r extends O{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new r}},Ge= exports.TypeTagU128 =class r extends O{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new r}},Be= exports.TypeTagU256 =class r extends O{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new r}},X= exports.TypeTagAddress =class r extends O{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}},yt= exports.TypeTagSigner =class r extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new r}},Xr= exports.TypeTagReference =class r extends O{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let n=O.deserialize(t);return new r(n)}},z= exports.TypeTagGeneric =class r extends O{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let n=t.deserializeU32();return new r(n)}},C= exports.TypeTagVector =class r extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new r(new ae)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let n=O.deserialize(t);return new r(n)}},f= exports.TypeTagStruct =class r extends O{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(n=>n.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let n=Ie.deserialize(t);return new r(n)}isTypeTag(t,n,i){return this.value.moduleName.identifier===n&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},Ie= exports.StructTag =class r extends l{constructor(e,t,n,i){super(),this.address=e,this.moduleName=t,this.name=n,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(O);return new r(t,n,i,o)}};function im(){return new Ie(u.ONE,new R("aptos_coin"),new R("AptosCoin"),[])}function v(){return new Ie(u.ONE,new R("string"),new R("String"),[])}function om(r){return new Ie(u.ONE,new R("option"),new R("Option"),[r])}function ce(r){return new Ie(u.ONE,new R("object"),new R("Object"),[r])}function Ec(r){let e=r.deserializeUleb128AsU32();switch(e){case 0:return j.deserialize(r);case 1:return $.deserialize(r);case 2:return we.deserialize(r);case 3:return u.deserialize(r);case 4:return b.deserialize(r,j);case 5:return U.deserialize(r);case 6:return Te.deserialize(r);case 7:return be.deserialize(r);case 8:return de.deserialize(r);case 9:return Zt.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var mt=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return sr.load(e);case 2:return ar.load(e);case 3:return cr.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},sr= exports.TransactionPayloadScript =class r extends mt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=ur.deserialize(e);return new r(t)}},ar= exports.TransactionPayloadEntryFunction =class r extends mt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=ft.deserialize(e);return new r(t)}},cr= exports.TransactionPayloadMultiSig =class r extends mt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=pr.deserialize(e);return new r(t)}},ft= exports.EntryFunction =class r{constructor(e,t,n,i){this.module_name=e,this.function_name=t,this.type_args=n,this.args=i}static build(e,t,n,i){return new r(or.fromStr(e),new R(t),n,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=or.deserialize(e),n=R.deserialize(e),i=e.deserializeVector(O),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=Nr.deserialize(e,c);s.push(p)}return new r(t,n,i,s)}},ur= exports.Script =class r{constructor(e,t,n){this.bytecode=e,this.type_args=t,this.args=n}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),n=e.deserializeVector(O),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Ec(e);o.push(a)}return new r(t,n,o)}},pr= exports.MultiSig =class r{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),n=e.deserializeBool(),i;return n&&(i=dr.deserialize(e)),new r(t,i)}},dr= exports.MultiSigTransactionPayload =class r extends l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new r(ft.deserialize(e))}};var me=class r extends l{constructor(e,t,n,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=n,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=e.deserializeU64(),i=mt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Dt.deserialize(e);return new r(t,n,i,o,s,a,c)}},Yr= exports.RawTransactionWithData =class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return At.load(e);case 1:return ht.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},At= exports.MultiAgentRawTransaction =class r extends Yr{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=me.deserialize(e),n=e.deserializeVector(u);return new r(t,n)}},ht= exports.FeePayerRawTransaction =class r extends Yr{constructor(e,t,n){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=n}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=me.deserialize(e),n=e.deserializeVector(u),i=u.deserialize(e);return new r(t,n,i)}};var Zr=class extends l{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new S("account");this.structName=new S("RotationProofChallenge");this.sequenceNumber=new $(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=b.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var Me=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Tt.load(e);case 1:return en.load(e);case 2:return bt.load(e);case 3:return wt.load(e);case 4:return _t.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Tt}isMultiEd25519(){return this instanceof en}isMultiAgent(){return this instanceof bt}isFeePayer(){return this instanceof wt}isSingleSender(){return this instanceof _t}},Tt= exports.TransactionAuthenticatorEd25519 =class r extends Me{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},en= exports.TransactionAuthenticatorMultiEd25519 =class r extends Me{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Pt.deserialize(e),n=ct.deserialize(e);return new r(t,n)}},bt= exports.TransactionAuthenticatorMultiAgent =class r extends Me{constructor(e,t,n){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=ee.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(ee);return new r(t,n,i)}},wt= exports.TransactionAuthenticatorFeePayer =class r extends Me{constructor(e,t,n,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=ee.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(ee),o=u.deserialize(e),s=ee.deserialize(e),a={address:o,authenticator:s};return new r(t,n,i,a)}},_t= exports.TransactionAuthenticatorSingleSender =class r extends Me{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=ee.deserialize(e);return new r(t)}};var Ve=class r extends l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=me.deserialize(e),n=Me.deserialize(e);return new r(t,n)}};var tn=class r extends l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=me.deserialize(e),n=e.deserializeBool(),i;return n&&(i=u.deserialize(e)),new r(t,i)}};var rn=class r extends l{constructor(e,t,n){super(),this.rawTransaction=e,this.feePayerAddress=n,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=me.deserialize(e),n=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new r(t,n,o)}};function ei(r){return r.feePayerAddress?new ht(r.rawTransaction,_nullishCoalesce(r.secondarySignerAddresses, () => ([])),r.feePayerAddress):r.secondarySignerAddresses?new At(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Ot(r,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let n=t.digest(),i=r,o=new Uint8Array(n.length+i.length);return o.set(n),o.set(i,n.length),o}function Af(r){return Ot(r.bcsToBytes(),`APTOS::${r.constructor.name}`)}function zt(r){let e=ei(r);return r.feePayerAddress?Ot(e.bcsToBytes(),Wn):r.secondarySignerAddresses?Ot(e.bcsToBytes(),Wn):Ot(e.bcsToBytes(),oo)}var Nt=class r{constructor(e){this.signingScheme=0;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}static generate(){let e=Y.generate();return new r({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:n}=e,i=Y.fromDerivationPath(t,n);return new r({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new _e(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new _e(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(zt(e))}};var Ft=class r{constructor(e){this.signingScheme=2;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=new F(t.publicKey()),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,n;switch(t){case 0:n=Y.generate();break;case 2:n=ut.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:n})}static fromDerivationPath(e){let{scheme:t=0,path:n,mnemonic:i}=e,o;switch(t){case 0:o=Y.fromDerivationPath(n,i);break;case 2:o=ut.fromDerivationPath(n,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new L(this.privateKey.sign(e))}signTransaction(e){return this.sign(zt(e))}};var Ze=class{static generate(e={}){let{scheme:t=0,legacy:n=!0}=e;return t===0&&n?Nt.generate():Ft.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:n,legacy:i=!0}=e;return t instanceof Y&&i?new Nt({privateKey:t,address:n}):new Ft({privateKey:t,address:n})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:n,path:i,legacy:o=!0}=e;return t===0&&o?Nt.fromDerivationPath({mnemonic:n,path:i}):Ft.fromDerivationPath({scheme:t,mnemonic:n,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var Ic=1209600,Gt=class Gt extends l{constructor(e){super();let{privateKey:t,expiryDateSecs:n,blinder:i}=e;this.privateKey=t,this.publicKey=new dt(t.publicKey()),this.expiryDateSecs=n||_chunkF43XVDYJjs.e.call(void 0, _chunkF43XVDYJjs.d.call(void 0, )+Ic),this.blinder=i!==void 0?g.fromHexInput(i).toUint8Array():Cc();let o=Vn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(tr(this.blinder));let s=rr(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=Y.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Gt({privateKey:n,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Gt.deserialize(new N(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _54 => _54.scheme])){case 0:default:t=Y.generate()}return new Gt({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _55 => _55.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new xe(this.privateKey.sign(e))}};Gt.BLINDER_LENGTH=31;var lr=Gt;function Cc(){return _utils.randomBytes.call(void 0, lr.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function nn(r){return r!=null&&typeof r.checkKeylessAccountValidity=="function"}var Bt=class Bt extends l{constructor(e){super();let{address:t,ephemeralKeyPair:n,publicKey:i,uidKey:o,uidVal:s,aud:a,pepper:c,proof:p,proofFetchCallback:d,jwt:A,verificationKeyHash:w}=e;if(this.ephemeralKeyPair=n,this.publicKey=i,this.accountAddress=t?u.from(t):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=A,this.emitter=new _eventemitter32.default,this.proofOrPromise=p,p instanceof Oe)this.proof=p;else{if(d===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async x=>{await d(x),this.emitter.removeAllListeners()}),this.init(p)}this.signingScheme=2;let y=g.fromHexInput(c).toUint8Array();if(y.length!==Bt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Bt.PEPPER_LENGTH}`);if(this.pepper=y,w!==void 0){if(g.hexInputToUint8Array(w).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=g.hexInputToUint8Array(w)}}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(t){t instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:t.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(this.accountAddress.serialize(e),e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(e),e.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(e){let t=u.deserialize(e),n=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeFixedBytes(31),s=lr.deserialize(e),a=Oe.deserialize(e),c=e.deserializeOption("fixedBytes",32);return{address:t,jwt:n,uidKey:i,pepper:o,ephemeralKeyPair:s,proof:a,verificationKeyHash:c}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let t=new L(this.sign(e)),n=new F(this.publicKey);return new ie(n,t)}signTransactionWithAuthenticator(e){let t=new L(this.signTransaction(e)),n=new F(this.publicKey);return new ie(n,t)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(e){if(this.isExpired())throw K.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw K.fromErrorType({type:2});let t=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(t.kid===void 0)throw K.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:n}=await ir({aptosConfig:e});if(g.hexInputToString(n.hash())!==g.hexInputToString(this.verificationKeyHash))throw K.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Bt.fetchJWK({aptosConfig:e,publicKey:this.publicKey,kid:t.kid})}sign(e){let{expiryDateSecs:t}=this.ephemeralKeyPair;if(this.isExpired())throw K.fromErrorType({type:0});if(this.proof===void 0)throw K.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let n=this.ephemeralKeyPair.getPublicKey(),i=this.ephemeralKeyPair.sign(e);return new De({jwtHeader:_chunkF43XVDYJjs.f.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Rt(this.proof,0),expiryDateSecs:t,ephemeralPublicKey:n,ephemeralSignature:i})}signTransaction(e){if(this.proof===void 0)throw K.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let t=ei(e),i=new ti(t,this.proof.proof).hash();return this.sign(i)}verifySignature(e){let{message:t,signature:n}=e;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:t,signature:n.ephemeralSignature}))}static async fetchJWK(e){let{aptosConfig:t,publicKey:n,kid:i}=e,o=n instanceof D?n:n.keylessPublicKey,{iss:s}=o,a,c=n instanceof Z?n.jwkAddress:void 0;try{a=await fo({aptosConfig:t,jwkAddr:c})}catch(A){throw K.fromErrorType({type:24,error:A,details:`Failed to fetch ${c?"Federated":"Patched"}JWKs ${c?`for address ${c}`:"0x1"}`})}let p=a.get(s);if(p===void 0)throw K.fromErrorType({type:7,details:`JWKs for issuer ${s} not found.`});let d=p.find(A=>A.kid===i);if(d===void 0)throw K.fromErrorType({type:6,details:`JWK with kid '${i}' for issuer '${s}' not found.`});return d}};Bt.PEPPER_LENGTH=31;var ue=Bt,ti= exports.TransactionAndProof =class extends l{constructor(t,n){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=n}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Ot(this.bcsToBytes(),this.domainSeparator)}};var Mt=class r extends ue{constructor(e){let t=D.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ue.partialDeserialize(e),{iss:p,aud:d,uidVal:A}=kt({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:A,aud:d,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return r.deserialize(new N(g.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:d,aud:A,uidVal:w}=kt({jwt:i,uidKey:a});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:d,uidKey:a,uidVal:w,aud:A,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var on=class r extends ue{constructor(e){let t=Z.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ue.partialDeserialize(e),p=u.deserialize(e),{iss:d,aud:A,uidVal:w}=kt({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:w,aud:A,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return r.deserialize(new N(g.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:d}=e,{iss:A,aud:w,uidVal:y}=kt({jwt:i,uidKey:c});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:A,uidKey:c,uidVal:y,aud:w,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:d?d.hash():void 0})}};var ho=class r{constructor(e){let{multiKey:t,signers:n,address:i}=e;this.publicKey=t,this.signingScheme=3,this.accountAddress=i?u.from(i):this.publicKey.authKey().derivedAddress();let o=[];for(let a of n)o.push(this.publicKey.getIndex(a.publicKey));let s=n.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:n,signers:i}=e,o=new Ye({publicKeys:t,signaturesRequired:n});return new r({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof r}signWithAuthenticator(e){return new ve(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ve(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(n=>n instanceof ue).map(async n=>n.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let n=this.signers.filter(i=>i instanceof ue).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(n)}sign(e){let t=[];for(let n of this.signers)t.push(n.sign(e));return new ze({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let n of this.signers)t.push(n.signTransaction(e));return new ze({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:n}=e;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<n.signatures.length;o+=1){let s=n.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:t,signature:s}))return!1}return!0}};var Kc=`
8
+ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,details:i}=e,[o,s,a]=yo[n];return new r({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:n})}},ye= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:n}){super(bc({apiType:e,aptosRequest:t,aptosResponse:n})),this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=t}};function bc({apiType:r,aptosRequest:e,aptosResponse:t}){let n=_optionalChain([t, 'access', _14 => _14.headers, 'optionalAccess', _15 => _15.traceparent, 'optionalAccess', _16 => _16.split, 'call', _17 => _17("-"), 'access', _18 => _18[1]]),i=n?`(trace_id:${n}) `:"",o=`Request to [${r}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return r==="Indexer"&&_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.errors, 'optionalAccess', _21 => _21[0], 'optionalAccess', _22 => _22.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _23 => _23.data, 'optionalAccess', _24 => _24.message])!=null&&_optionalChain([t, 'access', _25 => _25.data, 'optionalAccess', _26 => _26.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${wc(t.data)}`}var Yn=400;function wc(r){let e=JSON.stringify(r);return e.length<=Yn?e:`truncated(original_size:${e.length}): ${e.slice(0,Yn/2)}...${e.slice(-Yn/2)}`}async function _c(r,e){let{url:t,method:n,body:i,contentType:o,params:s,overrides:a,originMethod:c}=r,p={..._optionalChain([a, 'optionalAccess', _27 => _27.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${no}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _28 => _28.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _29 => _29.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _30 => _30.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _31 => _31.API_KEY])}`),e.provider({url:t,method:n,body:i,params:s,headers:p,overrides:a})}async function Yr(r,e,t){let{url:n,path:i}=r,o=i?`${n}/${i}`:n,s=await _c({...r,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye({apiType:t,aptosRequest:r,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ye({apiType:t,aptosRequest:r,aptosResponse:a})}async function Zn(r){let{aptosConfig:e,overrides:t,params:n,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=r,p=e.getRequestUrl(c);return Yr({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:n,overrides:{...e.clientConfig,...t}},e,r.type)}async function V(r){let{aptosConfig:e}=r;return Zn({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function jl(r){return Zn({...r,type:"Pepper"})}async function Ut(r){let e=[],t,n=r.params;do{let i=await Zn({type:"Fullnode",aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),n.start=t}while(t!=null);return e}async function ur(r){let{type:e,originMethod:t,path:n,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=r,d=c.getRequestUrl(e);return Yr({url:d,method:"POST",originMethod:t,path:n,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,r.type)}async function Xe(r){let{aptosConfig:e}=r;return ur({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.fullnodeConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function mo(r){let{aptosConfig:e}=r;return ur({...r,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([e, 'access', _42 => _42.indexerConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function fo(r){let{aptosConfig:e}=r,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _44 => _44.clientConfig, 'optionalAccess', _45 => delete _45.API_KEY]),ur({...r,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...r.overrides,HEADERS:{..._optionalChain([t, 'access', _46 => _46.clientConfig, 'optionalAccess', _47 => _47.HEADERS]),..._optionalChain([t, 'access', _48 => _48.faucetConfig, 'optionalAccess', _49 => _49.HEADERS])}}})}async function Ao(r){return ur({...r,type:"Pepper"})}async function ho(r){return ur({...r,type:"Prover"})}var ei=new Map;function Ee(r,e,t){return async(...n)=>{if(ei.has(e)){let{value:o,timestamp:s}=ei.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await r(...n);return ei.set(e,{value:i,timestamp:Date.now()}),i}}var Ig=1e7,xc= exports.MAX_AUD_VAL_BYTES =120,Ec= exports.MAX_UID_KEY_BYTES =30,Pc= exports.MAX_UID_VAL_BYTES =330,Cg= exports.MAX_ISS_VAL_BYTES =120,Rg= exports.MAX_EXTRA_FIELD_BYTES =350,Ug= exports.MAX_JWT_HEADER_B64_BYTES =300,Kg= exports.MAX_COMMITED_EPK_BYTES =93,Pe=class Pe extends ne{constructor(e,t){super();let n=g.fromHexInput(t).toUint8Array();if(n.length!==Pe.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Pe.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=n}authKey(){let e=new H;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Pe(t,n)}static load(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Pe(t,n)}static isPublicKey(e){return e instanceof Pe}static create(e){return To(e),new Pe(e.iss,To(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:n,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Pe.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:n})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Pe.ID_COMMITMENT_LENGTH=32;var O=Pe;function To(r){let{uidKey:e,uidVal:t,aud:n,pepper:i}=r,o=[ar(g.fromHexInput(i).toUint8Array()),Qr(n,xc),Qr(t,Pc),Qr(e,Ec)];return ro(cr(o),O.ID_COMMITMENT_LENGTH)}var Oe=class r extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:n,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=n,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Cc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Kt.deserialize(e),n=e.deserializeStr(),i=e.deserializeU64(),o=lt.deserialize(e),s=xe.deserialize(e);return new r({jwtHeader:n,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new r({jwtHeader:"{}",ephemeralCertificate:new Kt(new ze({proof:new Dt(new kt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new lt(new P(new Uint8Array(32))),ephemeralSignature:new xe(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof r}},Kt= exports.EphemeralCertificate =class r extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(ze.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},De=class r extends l{constructor(e){if(super(),this.data=g.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new r(t)}},mt=class r extends l{constructor(e){if(super(),this.data=g.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new r(t)}},kt= exports.Groth16Zkp =class r extends jr{constructor(e){super();let{a:t,b:n,c:i}=e;this.a=new De(t),this.b=new mt(n),this.c=new De(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=De.deserialize(e).bcsToBytes(),n=mt.deserialize(e).bcsToBytes(),i=De.deserialize(e).bcsToBytes();return new r({a:t,b:n,c:i})}},Dt= exports.ZkProof =class r extends l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(kt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ze= exports.ZeroKnowledgeSig =class r extends M{constructor(e){super();let{proof:t,expHorizonSecs:n,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=n,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return r.deserialize(new D(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Dt.deserialize(e),n=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(xe);return new r({proof:t,expHorizonSecs:n,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},ti= exports.KeylessConfiguration =class r{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new r(new ri({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},ri= exports.Groth16VerificationKey =class r{constructor(e){let{alphaG1:t,betaG2:n,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new De(t),this.betaG2=new mt(n),this.deltaG2=new mt(i),this.gammaAbcG1=[new De(o[0]),new De(o[1])],this.gammaG2=new mt(s)}hash(){let e=new H;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new r({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function pr(r){let{aptosConfig:e}=r;try{return await Ee(async()=>{let t=await vc(r),n=await Ic(r);return ti.create(n,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof K?t:K.fromErrorType({type:25,error:t})}}function Ot(r){let{jwt:e,uidKey:t="sub"}=r,n;try{n=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw K.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkF43XVDYJjs.c.call(void 0, o)}`})}if(typeof n.iss!="string")throw K.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof n.aud!="string")throw K.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=n[t];return{iss:n.iss,aud:n.aud,uidVal:i}}async function vc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _50 => _50.ledgerVersion])}});return i.data}catch(i){throw K.fromErrorType({type:22,error:i})}}async function Ic(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _51 => _51.ledgerVersion])}});return i.data}catch(i){throw K.fromErrorType({type:23,error:i})}}async function wo(r){let{aptosConfig:e,jwkAddr:t,options:n}=r,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _52 => _52.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _53 => _53.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,d=new D(g.fromHexInput(p).toUint8Array()),A=ni.deserialize(d);a.push(A)}o.set(zi(s.issuer),a)}return o}var ni=class r extends l{constructor(e){super();let{kid:t,kty:n,alg:i,e:o,n:s}=e;this.kid=t,this.kty=n,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,n=new D(g.fromHexInput(t).toUint8Array());return r.deserialize(n)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new r({kid:t,kty:n,alg:i,n:o,e:s})}};function Cc(r){try{let e=JSON.parse(r);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var ee=class r extends ne{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new H;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=O.deserialize(e);return new r(t,n)}static isPublicKey(e){return e instanceof r}static create(e){return new r(e.jwkAddress,O.create(e))}static fromJwtAndPepper(e){return new r(e.jwkAddress,O.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof O}};var F=class r extends ne{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof Ke)this.variant=1;else if(e instanceof O)this.variant=3;else if(e instanceof ee)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:n}=e;return L.isInstance(n)?this.publicKey.verifySignature({message:t,signature:n.signature}):!1}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=P.deserialize(e);break;case 1:n=Ke.deserialize(e);break;case 3:n=O.deserialize(e);break;case 4:n=ee.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new r(n)}static isPublicKey(e){return e instanceof r}isEd25519(){return this.publicKey instanceof P}isSecp256k1PublicKey(){return this.publicKey instanceof Ke}static isInstance(e){return"publicKey"in e&&"variant"in e}},L= exports.AnySignature =class r extends M{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof dt)this.variant=1;else if(e instanceof Oe)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=I.deserialize(e);break;case 1:n=dt.deserialize(e);break;case 3:n=Oe.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new r(n)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Rc(r){let e=r;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Ye=class r extends ne{constructor(e){super();let{publicKeys:t,signaturesRequired:n}=e;if(n<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<n)throw new Error(`Provided ${t.length} public keys is smaller than the ${n} required signatures`);this.publicKeys=t.map(i=>i instanceof F?i:new F(i)),this.signaturesRequired=n}verifySignature(e){throw new Error("not implemented")}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(F),n=e.deserializeU8();return new r({publicKeys:t,signaturesRequired:n})}createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}getIndex(e){let t=e instanceof F?e:new F(e),n=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(n!==-1)return n;throw new Error("Public key not found in MultiKey")}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},se=class se extends M{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>se.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${se.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof L?o:new L(o)),!(n instanceof Uint8Array))this.bitmap=se.createBitmap({bits:n});else{if(n.length!==se.BITMAP_LEN)throw new Error(`"bitmap" length should be ${se.BITMAP_LEN}`);this.bitmap=n}let i=this.bitmap.reduce((o,s)=>o+Rc(s),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:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=se.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${se.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=n>>s%8,i[a]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(L),n=e.deserializeBytes();return new se({signatures:t,bitmap:n})}};se.BITMAP_LEN=4,se.MAX_SIGNATURES_SUPPORTED=se.BITMAP_LEN*8;var Ne=se;var X=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _e.load(e);case 1:return Zr.load(e);case 2:return ie.load(e);case 3:return ve.load(e);case 4:return zt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof _e}isMultiEd25519(){return this instanceof Zr}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof ve}},_e= exports.AccountAuthenticatorEd25519 =class r extends X{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},Zr= exports.AccountAuthenticatorMultiEd25519 =class r extends X{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ct.deserialize(e),n=ut.deserialize(e);return new r(t,n)}},ie= exports.AccountAuthenticatorSingleKey =class r extends X{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=F.deserialize(e),n=L.deserialize(e);return new r(t,n)}},ve= exports.AccountAuthenticatorMultiKey =class r extends X{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Ye.deserialize(e),n=Ne.deserialize(e);return new r(t,n)}},zt= exports.AccountAuthenticatorNoAccountAuthenticator =class r extends X{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}};var Nt=class r extends l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new r(t)}};var R=class r extends l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new r(t)}};var en=(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,254]);return new u(_sha3.sha3_256.call(void 0, i))},Ly= exports.createResourceAddress =(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,255]);return new u(_sha3.sha3_256.call(void 0, i))},qy= exports.createTokenAddress =(r,e,t)=>{let n=`${e}::${t}`;return en(r,n)};var dr=class r extends l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new r(u.fromString(t[0]),new R(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e);return new r(t,n)}};var z=class r extends l{deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(r);return new Ie(t,n,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return G.load(e);case 1:return ae.load(e);case 2:return W.load(e);case 3:return Be.load(e);case 4:return Y.load(e);case 5:return ft.load(e);case 6:return C.load(e);case 7:return f.load(e);case 8:return Fe.load(e);case 9:return Ge.load(e);case 10:return Me.load(e);case 255:return N.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof Y}isGeneric(){return this instanceof N}isSigner(){return this instanceof ft}isVector(){return this instanceof C}isStruct(){return this instanceof f}isU8(){return this instanceof ae}isU16(){return this instanceof Fe}isU32(){return this instanceof Ge}isU64(){return this instanceof W}isU128(){return this instanceof Be}isU256(){return this instanceof Me}isPrimitive(){return this instanceof ft||this instanceof Y||this instanceof G||this instanceof ae||this instanceof Fe||this instanceof Ge||this instanceof W||this instanceof Be||this instanceof Me}},G= exports.TypeTagBool =class r extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new r}},ae= exports.TypeTagU8 =class r extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new r}},Fe= exports.TypeTagU16 =class r extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new r}},Ge= exports.TypeTagU32 =class r extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new r}},W= exports.TypeTagU64 =class r extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new r}},Be= exports.TypeTagU128 =class r extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new r}},Me= exports.TypeTagU256 =class r extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new r}},Y= exports.TypeTagAddress =class r extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}},ft= exports.TypeTagSigner =class r extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new r}},tn= exports.TypeTagReference =class r extends z{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let n=z.deserialize(t);return new r(n)}},N= exports.TypeTagGeneric =class r extends z{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let n=t.deserializeU32();return new r(n)}},C= exports.TypeTagVector =class r extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new r(new ae)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let n=z.deserialize(t);return new r(n)}},f= exports.TypeTagStruct =class r extends z{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(n=>n.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let n=Ie.deserialize(t);return new r(n)}isTypeTag(t,n,i){return this.value.moduleName.identifier===n&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},Ie= exports.StructTag =class r extends l{constructor(e,t,n,i){super(),this.address=e,this.moduleName=t,this.name=n,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(z);return new r(t,n,i,o)}};function gm(){return new Ie(u.ONE,new R("aptos_coin"),new R("AptosCoin"),[])}function v(){return new Ie(u.ONE,new R("string"),new R("String"),[])}function ym(r){return new Ie(u.ONE,new R("option"),new R("Option"),[r])}function ce(r){return new Ie(u.ONE,new R("object"),new R("Object"),[r])}function Uc(r){let e=r.deserializeUleb128AsU32();switch(e){case 0:return j.deserialize(r);case 1:return $.deserialize(r);case 2:return we.deserialize(r);case 3:return u.deserialize(r);case 4:return b.deserialize(r,j);case 5:return U.deserialize(r);case 6:return Te.deserialize(r);case 7:return be.deserialize(r);case 8:return de.deserialize(r);case 9:return or.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var At=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ht.load(e);case 2:return lr.load(e);case 3:return gr.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},ht= exports.TransactionPayloadScript =class r extends At{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=yr.deserialize(e);return new r(t)}},lr= exports.TransactionPayloadEntryFunction =class r extends At{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Tt.deserialize(e);return new r(t)}},gr= exports.TransactionPayloadMultiSig =class r extends At{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=mr.deserialize(e);return new r(t)}},Tt= exports.EntryFunction =class r{constructor(e,t,n,i){this.module_name=e,this.function_name=t,this.type_args=n,this.args=i}static build(e,t,n,i){return new r(dr.fromStr(e),new R(t),n,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=dr.deserialize(e),n=R.deserialize(e),i=e.deserializeVector(z),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=Mr.deserialize(e,c);s.push(p)}return new r(t,n,i,s)}},yr= exports.Script =class r{constructor(e,t,n){this.bytecode=e,this.type_args=t,this.args=n}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),n=e.deserializeVector(z),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Uc(e);o.push(a)}return new r(t,n,o)}},mr= exports.MultiSig =class r{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),n=e.deserializeBool(),i;return n&&(i=fr.deserialize(e)),new r(t,i)}},fr= exports.MultiSigTransactionPayload =class r extends l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new r(Tt.deserialize(e))}};var me=class r extends l{constructor(e,t,n,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=n,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=e.deserializeU64(),i=At.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Nt.deserialize(e);return new r(t,n,i,o,s,a,c)}},rn= exports.RawTransactionWithData =class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return bt.load(e);case 1:return wt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},bt= exports.MultiAgentRawTransaction =class r extends rn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=me.deserialize(e),n=e.deserializeVector(u);return new r(t,n)}},wt= exports.FeePayerRawTransaction =class r extends rn{constructor(e,t,n){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=n}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=me.deserialize(e),n=e.deserializeVector(u),i=u.deserialize(e);return new r(t,n,i)}};var nn=class extends l{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new S("account");this.structName=new S("RotationProofChallenge");this.sequenceNumber=new $(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=b.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var Ve=class extends l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _t.load(e);case 1:return on.load(e);case 2:return St.load(e);case 3:return xt.load(e);case 4:return Ze.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof _t}isMultiEd25519(){return this instanceof on}isMultiAgent(){return this instanceof St}isFeePayer(){return this instanceof xt}isSingleSender(){return this instanceof Ze}},_t= exports.TransactionAuthenticatorEd25519 =class r extends Ve{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},on= exports.TransactionAuthenticatorMultiEd25519 =class r extends Ve{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ct.deserialize(e),n=ut.deserialize(e);return new r(t,n)}},St= exports.TransactionAuthenticatorMultiAgent =class r extends Ve{constructor(e,t,n){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=X.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(X);return new r(t,n,i)}},xt= exports.TransactionAuthenticatorFeePayer =class r extends Ve{constructor(e,t,n,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=X.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(X),o=u.deserialize(e),s=X.deserialize(e),a={address:o,authenticator:s};return new r(t,n,i,a)}},Ze= exports.TransactionAuthenticatorSingleSender =class r extends Ve{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=X.deserialize(e);return new r(t)}};var Le=class r extends l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=me.deserialize(e),n=Ve.deserialize(e);return new r(t,n)}};var Ft=class r extends l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=me.deserialize(e),n=e.deserializeBool(),i;return n&&(i=u.deserialize(e)),new r(t,i)}};var sn=class r extends l{constructor(e,t,n){super(),this.rawTransaction=e,this.feePayerAddress=n,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=me.deserialize(e),n=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new r(t,n,o)}};function ii(r){return r.feePayerAddress?new wt(r.rawTransaction,_nullishCoalesce(r.secondarySignerAddresses, () => ([])),r.feePayerAddress):r.secondarySignerAddresses?new bt(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Gt(r,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let n=t.digest(),i=r,o=new Uint8Array(n.length+i.length);return o.set(n),o.set(i,n.length),o}function Pf(r){return Gt(r.bcsToBytes(),`APTOS::${r.constructor.name}`)}function Bt(r){let e=ii(r);return r.feePayerAddress?Gt(e.bcsToBytes(),Xn):r.secondarySignerAddresses?Gt(e.bcsToBytes(),Xn):Gt(e.bcsToBytes(),po)}var Mt=class r{constructor(e){this.signingScheme=0;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}static generate(){let e=Z.generate();return new r({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:n}=e,i=Z.fromDerivationPath(t,n);return new r({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new _e(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new _e(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Bt(e))}};var Vt=class r{constructor(e){this.signingScheme=2;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=new F(t.publicKey()),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,n;switch(t){case 0:n=Z.generate();break;case 2:n=pt.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:n})}static fromDerivationPath(e){let{scheme:t=0,path:n,mnemonic:i}=e,o;switch(t){case 0:o=Z.fromDerivationPath(n,i);break;case 2:o=pt.fromDerivationPath(n,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new L(this.privateKey.sign(e))}signTransaction(e){return this.sign(Bt(e))}};var et=class{static generate(e={}){let{scheme:t=0,legacy:n=!0}=e;return t===0&&n?Mt.generate():Vt.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:n,legacy:i=!0}=e;return t instanceof Z&&i?new Mt({privateKey:t,address:n}):new Vt({privateKey:t,address:n})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:n,path:i,legacy:o=!0}=e;return t===0&&o?Mt.fromDerivationPath({mnemonic:n,path:i}):Vt.fromDerivationPath({scheme:t,mnemonic:n,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var Dc=1209600,Lt=class Lt extends l{constructor(e){super();let{privateKey:t,expiryDateSecs:n,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=n||_chunkF43XVDYJjs.e.call(void 0, _chunkF43XVDYJjs.d.call(void 0, )+Dc),this.blinder=i!==void 0?g.fromHexInput(i).toUint8Array():Oc();let o=$n(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(ar(this.blinder));let s=cr(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=Z.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Lt({privateKey:n,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Lt.deserialize(new D(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _54 => _54.scheme])){case 0:default:t=Z.generate()}return new Lt({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _55 => _55.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new xe(this.privateKey.sign(e))}};Lt.BLINDER_LENGTH=31;var Ar=Lt;function Oc(){return _utils.randomBytes.call(void 0, Ar.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function an(r){return r!=null&&typeof r.checkKeylessAccountValidity=="function"}var qt=class qt extends l{constructor(e){super();let{address:t,ephemeralKeyPair:n,publicKey:i,uidKey:o,uidVal:s,aud:a,pepper:c,proof:p,proofFetchCallback:d,jwt:A,verificationKeyHash:w}=e;if(this.ephemeralKeyPair=n,this.publicKey=i,this.accountAddress=t?u.from(t):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=A,this.emitter=new _eventemitter32.default,this.proofOrPromise=p,p instanceof ze)this.proof=p;else{if(d===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async x=>{await d(x),this.emitter.removeAllListeners()}),this.init(p)}this.signingScheme=2;let y=g.fromHexInput(c).toUint8Array();if(y.length!==qt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${qt.PEPPER_LENGTH}`);if(this.pepper=y,w!==void 0){if(g.hexInputToUint8Array(w).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=g.hexInputToUint8Array(w)}}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(t){t instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:t.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(this.accountAddress.serialize(e),e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(e),e.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(e){let t=u.deserialize(e),n=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeFixedBytes(31),s=Ar.deserialize(e),a=ze.deserialize(e),c=e.deserializeOption("fixedBytes",32);return{address:t,jwt:n,uidKey:i,pepper:o,ephemeralKeyPair:s,proof:a,verificationKeyHash:c}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let t=new L(this.sign(e)),n=new F(this.publicKey);return new ie(n,t)}signTransactionWithAuthenticator(e){let t=new L(this.signTransaction(e)),n=new F(this.publicKey);return new ie(n,t)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(e){if(this.isExpired())throw K.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw K.fromErrorType({type:2});let t=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(t.kid===void 0)throw K.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:n}=await pr({aptosConfig:e});if(g.hexInputToString(n.hash())!==g.hexInputToString(this.verificationKeyHash))throw K.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await qt.fetchJWK({aptosConfig:e,publicKey:this.publicKey,kid:t.kid})}sign(e){let{expiryDateSecs:t}=this.ephemeralKeyPair;if(this.isExpired())throw K.fromErrorType({type:0});if(this.proof===void 0)throw K.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let n=this.ephemeralKeyPair.getPublicKey(),i=this.ephemeralKeyPair.sign(e);return new Oe({jwtHeader:_chunkF43XVDYJjs.f.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Kt(this.proof,0),expiryDateSecs:t,ephemeralPublicKey:n,ephemeralSignature:i})}signTransaction(e){if(this.proof===void 0)throw K.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let t=ii(e),i=new oi(t,this.proof.proof).hash();return this.sign(i)}verifySignature(e){let{message:t,signature:n}=e;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:t,signature:n.ephemeralSignature}))}static async fetchJWK(e){let{aptosConfig:t,publicKey:n,kid:i}=e,o=n instanceof O?n:n.keylessPublicKey,{iss:s}=o,a,c=n instanceof ee?n.jwkAddress:void 0;try{a=await wo({aptosConfig:t,jwkAddr:c})}catch(A){throw K.fromErrorType({type:24,error:A,details:`Failed to fetch ${c?"Federated":"Patched"}JWKs ${c?`for address ${c}`:"0x1"}`})}let p=a.get(s);if(p===void 0)throw K.fromErrorType({type:7,details:`JWKs for issuer ${s} not found.`});let d=p.find(A=>A.kid===i);if(d===void 0)throw K.fromErrorType({type:6,details:`JWK with kid '${i}' for issuer '${s}' not found.`});return d}};qt.PEPPER_LENGTH=31;var ue=qt,oi= exports.TransactionAndProof =class extends l{constructor(t,n){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=n}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Gt(this.bcsToBytes(),this.domainSeparator)}};var Ht=class r extends ue{constructor(e){let t=O.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ue.partialDeserialize(e),{iss:p,aud:d,uidVal:A}=Ot({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:A,aud:d,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return r.deserialize(new D(g.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:d,aud:A,uidVal:w}=Ot({jwt:i,uidKey:a});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:d,uidKey:a,uidVal:w,aud:A,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var cn=class r extends ue{constructor(e){let t=ee.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ue.partialDeserialize(e),p=u.deserialize(e),{iss:d,aud:A,uidVal:w}=Ot({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:w,aud:A,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return r.deserialize(new D(g.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:d}=e,{iss:A,aud:w,uidVal:y}=Ot({jwt:i,uidKey:c});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:A,uidKey:c,uidVal:y,aud:w,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:d?d.hash():void 0})}};var So=class r{constructor(e){let{multiKey:t,signers:n,address:i}=e;this.publicKey=t,this.signingScheme=3,this.accountAddress=i?u.from(i):this.publicKey.authKey().derivedAddress();let o=[];for(let a of n)o.push(this.publicKey.getIndex(a.publicKey));let s=n.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:n,signers:i}=e,o=new Ye({publicKeys:t,signaturesRequired:n});return new r({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof r}signWithAuthenticator(e){return new ve(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ve(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(n=>n instanceof ue).map(async n=>n.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let n=this.signers.filter(i=>i instanceof ue).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(n)}sign(e){let t=[];for(let n of this.signers)t.push(n.sign(e));return new Ne({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let n of this.signers)t.push(n.signTransaction(e));return new Ne({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:n}=e;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<n.signatures.length;o+=1){let s=n.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:t,signature:s}))return!1}return!0}};var Fc=`
9
9
  fragment TokenActivitiesFields on token_activities_v2 {
10
10
  after_value
11
11
  before_value
@@ -23,7 +23,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
23
23
  transaction_version
24
24
  type
25
25
  }
26
- `,kc=`
26
+ `,Gc=`
27
27
  fragment AnsTokenFragment on current_aptos_names {
28
28
  domain
29
29
  expiration_timestamp
@@ -35,7 +35,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
35
35
  subdomain_expiration_policy
36
36
  domain_expiration_timestamp
37
37
  }
38
- `,sn=`
38
+ `,un=`
39
39
  fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
40
40
  token_standard
41
41
  token_properties_mutated_v1
@@ -82,7 +82,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
82
82
  }
83
83
  }
84
84
  }
85
- `,To=`
85
+ `,xo=`
86
86
  query getAccountCoinsCount($address: String) {
87
87
  current_fungible_asset_balances_aggregate(
88
88
  where: {owner_address: {_eq: $address}}
@@ -92,7 +92,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
92
92
  }
93
93
  }
94
94
  }
95
- `,bo=`
95
+ `,Eo=`
96
96
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
97
97
  current_fungible_asset_balances(
98
98
  where: $where_condition
@@ -125,7 +125,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
125
125
  }
126
126
  }
127
127
  }
128
- `,wo=`
128
+ `,Po=`
129
129
  query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
130
130
  current_collection_ownership_v2_view(
131
131
  where: $where_condition
@@ -159,7 +159,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
159
159
  single_token_uri
160
160
  }
161
161
  }
162
- `,_o=`
162
+ `,vo=`
163
163
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
164
164
  current_token_ownerships_v2(
165
165
  where: $where_condition
@@ -170,7 +170,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
170
170
  ...CurrentTokenOwnershipFields
171
171
  }
172
172
  }
173
- ${sn}`,uh=`
173
+ ${un}`,hh=`
174
174
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
175
175
  current_token_ownerships_v2(
176
176
  where: $where_condition
@@ -181,7 +181,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
181
181
  ...CurrentTokenOwnershipFields
182
182
  }
183
183
  }
184
- ${sn}`,So=`
184
+ ${un}`,Io=`
185
185
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
186
186
  current_token_ownerships_v2(
187
187
  where: $where_condition
@@ -192,7 +192,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
192
192
  ...CurrentTokenOwnershipFields
193
193
  }
194
194
  }
195
- ${sn}`,xo=`
195
+ ${un}`,Co=`
196
196
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
197
197
  current_token_ownerships_v2_aggregate(
198
198
  where: $where_condition
@@ -204,7 +204,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
204
204
  }
205
205
  }
206
206
  }
207
- `,Eo=`
207
+ `,Ro=`
208
208
  query getAccountTransactionsCount($address: String) {
209
209
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
210
210
  aggregate {
@@ -212,13 +212,13 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
212
212
  }
213
213
  }
214
214
  }
215
- `,Po=`
215
+ `,Uo=`
216
216
  query getChainTopUserTransactions($limit: Int) {
217
217
  user_transactions(limit: $limit, order_by: {version: desc}) {
218
218
  version
219
219
  }
220
220
  }
221
- `,vo=`
221
+ `,Ko=`
222
222
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
223
223
  current_collections_v2(where: $where_condition) {
224
224
  uri
@@ -248,7 +248,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
248
248
  }
249
249
  }
250
250
  }
251
- `,Io=`
251
+ `,ko=`
252
252
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
253
253
  current_fungible_asset_balances(
254
254
  where: $where_condition
@@ -266,7 +266,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
266
266
  token_standard
267
267
  }
268
268
  }
269
- `,Co=`
269
+ `,Do=`
270
270
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
271
271
  delegated_staking_activities(
272
272
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -279,7 +279,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
279
279
  transaction_version
280
280
  }
281
281
  }
282
- `,Ro=`
282
+ `,Oo=`
283
283
  query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
284
284
  events(
285
285
  where: $where_condition
@@ -298,7 +298,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
298
298
  indexed_type
299
299
  }
300
300
  }
301
- `,Uo=`
301
+ `,zo=`
302
302
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
303
303
  fungible_asset_activities(
304
304
  where: $where_condition
@@ -323,7 +323,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
323
323
  type
324
324
  }
325
325
  }
326
- `,Ko=`
326
+ `,No=`
327
327
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
328
328
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
329
329
  icon_uri
@@ -342,7 +342,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
342
342
  maximum_v2
343
343
  }
344
344
  }
345
- `,Vt=`
345
+ `,$t=`
346
346
  query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
347
347
  current_aptos_names(
348
348
  limit: $limit
@@ -353,14 +353,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
353
353
  ...AnsTokenFragment
354
354
  }
355
355
  }
356
- ${kc}`,ri=`
356
+ ${Gc}`,si=`
357
357
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
358
358
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
359
359
  num_active_delegator
360
360
  pool_address
361
361
  }
362
362
  }
363
- `,an=`
363
+ `,pn=`
364
364
  query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
365
365
  current_objects(
366
366
  where: $where_condition
@@ -377,7 +377,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
377
377
  is_deleted
378
378
  }
379
379
  }
380
- `,ni=`
380
+ `,ai=`
381
381
  query getProcessorStatus($where_condition: processor_status_bool_exp) {
382
382
  processor_status(where: $where_condition) {
383
383
  last_success_version
@@ -385,7 +385,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
385
385
  last_updated
386
386
  }
387
387
  }
388
- `,ko=`
388
+ `,Fo=`
389
389
  query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
390
390
  table_items(
391
391
  where: $where_condition
@@ -401,7 +401,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
401
401
  write_set_change_index
402
402
  }
403
403
  }
404
- `,Do=`
404
+ `,Go=`
405
405
  query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
406
406
  table_metadatas(
407
407
  where: $where_condition
@@ -414,7 +414,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
414
414
  value_type
415
415
  }
416
416
  }
417
- `,Oo=`
417
+ `,Bo=`
418
418
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
419
419
  token_activities_v2(
420
420
  where: $where_condition
@@ -425,7 +425,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
425
425
  ...TokenActivitiesFields
426
426
  }
427
427
  }
428
- ${Kc}`,ii=`
428
+ ${Fc}`,ci=`
429
429
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
430
430
  current_token_ownerships_v2(
431
431
  where: $where_condition
@@ -436,7 +436,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
436
436
  ...CurrentTokenOwnershipFields
437
437
  }
438
438
  }
439
- ${sn}`,zo=`
439
+ ${un}`,Mo=`
440
440
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
441
441
  current_token_datas_v2(
442
442
  where: $where_condition
@@ -476,7 +476,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
476
476
  }
477
477
  }
478
478
  }
479
- `;async function cn(r){let{aptosConfig:e}=r,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function No(r){let{aptosConfig:e,limit:t}=r;return(await h({aptosConfig:e,query:{query:Po,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function h(r){let{aptosConfig:e,query:t,originMethod:n}=r,{data:i}=await uo({aptosConfig:e,originMethod:_nullishCoalesce(n, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Dc(r){let{aptosConfig:e}=r;return(await h({aptosConfig:e,query:{query:ni},originMethod:"getProcessorStatuses"})).processor_status}async function un(r){let e=await Dc({aptosConfig:r.aptosConfig});return BigInt(e[0].last_success_version)}async function pn(r){let{aptosConfig:e,processorType:t}=r;return(await h({aptosConfig:e,query:{query:ni,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function dn(r){let{aptosConfig:e,handle:t,data:n,options:i}=r;return(await Xe({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _56 => _56.ledgerVersion])},body:n})).data}async function Fo(r){let{aptosConfig:e,options:t}=r,n={query:ko,variables:{where_condition:_optionalChain([t, 'optionalAccess', _57 => _57.where]),offset:_optionalChain([t, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([t, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([t, 'optionalAccess', _60 => _60.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getTableItemsData"})).table_items}async function Go(r){let{aptosConfig:e,options:t}=r,n={query:Do,variables:{where_condition:_optionalChain([t, 'optionalAccess', _61 => _61.where]),offset:_optionalChain([t, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([t, 'optionalAccess', _63 => _63.limit]),order_by:_optionalChain([t, 'optionalAccess', _64 => _64.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Ce(r){let{aptosConfig:e,accountAddress:t}=r,{data:n}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return n}async function Vo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ct({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _65 => _65.ledgerVersion]),start:_optionalChain([n, 'optionalAccess', _66 => _66.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _67 => _67.limit]), () => (1e3))}})}async function ln(r){return _optionalChain([r, 'access', _68 => _68.options, 'optionalAccess', _69 => _69.ledgerVersion])!==void 0?Bo(r):Ee(async()=>Bo(r),`module-${r.accountAddress}-${r.moduleName}`,1e3*60*5)()}async function Bo(r){let{aptosConfig:e,accountAddress:t,moduleName:n,options:i}=r,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _70 => _70.ledgerVersion])}});return o}async function Lo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ct({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([n, 'optionalAccess', _71 => _71.offset]),limit:_optionalChain([n, 'optionalAccess', _72 => _72.limit])}})}async function qo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ct({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _73 => _73.ledgerVersion]),start:_optionalChain([n, 'optionalAccess', _74 => _74.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _75 => _75.limit]), () => (999))}})}async function oi(r){let{aptosConfig:e,accountAddress:t,resourceType:n,options:i}=r,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _76 => _76.ledgerVersion])}});return o.data}async function Lt(r){let{aptosConfig:e,authenticationKey:t,options:n}=r,i=await oi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:n}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await dn({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:n});return u.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ho(r){let{aptosConfig:e,accountAddress:t}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await h({aptosConfig:e,query:{query:xo,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function $o(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([n, 'optionalAccess', _77 => _77.tokenStandard])&&(o.token_standard={_eq:_optionalChain([n, 'optionalAccess', _78 => _78.tokenStandard])});let s={query:_o,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _79 => _79.offset]),limit:_optionalChain([n, 'optionalAccess', _80 => _80.limit]),order_by:_optionalChain([n, 'optionalAccess', _81 => _81.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Wo(r){let{aptosConfig:e,accountAddress:t,collectionAddress:n,options:i}=r,o=u.from(t).toStringLong(),s=u.from(n).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _82 => _82.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _83 => _83.tokenStandard])});let c={query:So,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _84 => _84.offset]),limit:_optionalChain([i, 'optionalAccess', _85 => _85.limit]),order_by:_optionalChain([i, 'optionalAccess', _86 => _86.orderBy])}};return(await h({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Qo(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}};_optionalChain([n, 'optionalAccess', _87 => _87.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([n, 'optionalAccess', _88 => _88.tokenStandard])}});let s={query:wo,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _89 => _89.offset]),limit:_optionalChain([n, 'optionalAccess', _90 => _90.limit]),order_by:_optionalChain([n, 'optionalAccess', _91 => _91.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function jo(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:Eo,variables:{address:n}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Jo(r){let{aptosConfig:e,accountAddress:t,options:n}=r,i=u.from(t).toStringLong(),o={..._optionalChain([n, 'optionalAccess', _92 => _92.where]),owner_address:{_eq:i}},s={query:bo,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _93 => _93.offset]),limit:_optionalChain([n, 'optionalAccess', _94 => _94.limit]),order_by:_optionalChain([n, 'optionalAccess', _95 => _95.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Xo(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:To,variables:{address:n}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function Yo(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:an,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _96 => _96.offset]),limit:_optionalChain([n, 'optionalAccess', _97 => _97.limit]),order_by:_optionalChain([n, 'optionalAccess', _98 => _98.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Zo(r){let{aptosConfig:e,privateKey:t}=r,n=new F(t.publicKey());if(t instanceof ut){let o=B.fromPublicKey({publicKey:n}).derivedAddress();return Ze.fromPrivateKey({privateKey:t,address:o})}if(t instanceof Y){let i=B.fromPublicKey({publicKey:n});if(await Mo({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return Ze.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=B.fromPublicKey({publicKey:n.publicKey});if(await Mo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return Ze.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function Mo(r){let{aptosConfig:e,authKey:t}=r,n=await Lt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Ce({aptosConfig:e,accountAddress:n}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${n.toString()}`)}}async function ai(r){let{aptosConfig:e,options:t}=r;return Ct({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _99 => _99.offset]),limit:_optionalChain([t, 'optionalAccess', _100 => _100.limit])}})}async function yn(r){let{aptosConfig:e}=r;return Ee(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function es(r){let{aptosConfig:e,ledgerVersion:t}=r,{data:n}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return n}async function gr(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return n}async function ts(r){let{aptosConfig:e,transactionHash:t}=r;try{return(await gr({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(n){if(_optionalChain([n, 'optionalAccess', _101 => _101.status])===404)return!0;throw n}}async function Oc(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return n}async function qt(r){let{aptosConfig:e,transactionHash:t,options:n}=r,i=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _102 => _102.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _103 => _103.checkSuccess]), () => (!0)),s=!0,a=0,c,p,d=200,A=1.5;function w(y){if(!(y instanceof ye)||(p=y,y.status!==404&&y.status>=400&&y.status<500))throw y}try{c=await gr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(y){w(y)}if(s){let y=Date.now();try{c=await Oc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(x){w(x)}a=(Date.now()-y)/1e3}for(;s&&!(a>=i);){try{if(c=await gr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(y){w(y)}await _chunkF43XVDYJjs.b.call(void 0, d),a+=d/1e3,d*=A}if(c===void 0)throw p||new gn(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new gn(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new si(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function mn(r){let{aptosConfig:e,processorType:t}=r,n=BigInt(r.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<n;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await un({aptosConfig:e}):s=(await pn({aptosConfig:e,processorType:t})).last_success_version,s>=n)break;await _chunkF43XVDYJjs.b.call(void 0, 200)}}var gn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},si=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function rs(r){let{aptosConfig:e,ledgerVersion:t,options:n}=r,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _104 => _104.withTransactions])}});return is({block:i,...r})}async function ns(r){let{aptosConfig:e,blockHeight:t,options:n}=r,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _105 => _105.withTransactions])}});return is({block:i,...r})}async function is(r){let{aptosConfig:e,block:t,options:n}=r;if(_optionalChain([n, 'optionalAccess', _106 => _106.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _107 => _107.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],d=100n;for(let w=c+1n;w<s;w+=BigInt(100))p.push(ai({aptosConfig:e,options:{offset:w,limit:Math.min(Number(d),Number(s-w+1n))}}));let A=await Promise.all(p);for(let w of A)t.transactions.push(...w)}return t}async function T(r){r.minimumLedgerVersion!==void 0&&await mn({aptosConfig:r.config,minimumLedgerVersion:r.minimumLedgerVersion,processorType:r.processorType})}function os(r){return typeof r=="boolean"}function et(r){return typeof r=="string"}function zc(r){return typeof r=="number"}function fn(r){if(zc(r))return r;if(et(r)&&r!=="")return Number.parseInt(r,10)}function An(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function ss(r){return r==null}function as(r){return ci(r)||pi(r)||di(r)||li(r)||gi(r)||yi(r)||mi(r)||hn(r)||ui(r)||Nc(r)||r instanceof b||r instanceof J}function ci(r){return r instanceof U}function hn(r){return r instanceof u}function ui(r){return r instanceof S}function Nc(r){return r instanceof st}function pi(r){return r instanceof j}function di(r){return r instanceof Te}function li(r){return r instanceof be}function gi(r){return r instanceof $}function yi(r){return r instanceof we}function mi(r){return r instanceof de}function cs(r){return"bytecode"in r}function k(r,e){throw new Error(`Type mismatch for argument ${e}, expected '${r}'`)}function us(r){let e=r.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?r.params.length:e}function yr(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],i=e[2];return{moduleAddress:t,moduleName:n,functionName:i}}function ps(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function ds(r){return!!r.match(/\s/)}function Fc(r){return!!r.match(/^T[0-9]+$/)}function Gc(r){return!!r.match(/^&.+$/)}function Bc(r){switch(r){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Mc(r,e){let t=e;for(;t<r.length;t+=1){let n=r[t];if(!ds(n))break}return t}var Vc=(x=>(x.InvalidTypeTag="unknown type",x.UnexpectedGenericType="unexpected generic type",x.UnexpectedTypeArgumentClose="unexpected '>'",x.UnexpectedWhitespaceCharacter="unexpected whitespace character",x.UnexpectedComma="unexpected ','",x.TypeArgumentCountMismatch="type argument count doesn't match expected amount",x.MissingTypeArgumentClose="no matching '>' for '<'",x.MissingTypeArgument="no type argument before ','",x.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",x.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",x.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",x.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",x.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",x.InvalidAddress="struct address must be valid",x))(Vc||{}),q= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Le(r,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _108 => _108.allowGenerics]), () => (!1)),n=[],i=[],o=[],s=0,a="",c=1;for(;s<r.length;){let p=r[s];if(p==="<")n.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let x=mr(a,i,t);o.push(x)}let d=n.pop();if(d===void 0)throw new q(r,"unexpected '>'");if(c!==o.length)throw new q(r,"type argument count doesn't match expected amount");let{savedStr:A,savedTypes:w,savedExpectedTypes:y}=d;i=o,o=w,a=A,c=y}else if(p===","){if(n.length===0)throw new q(r,"unexpected ','");if(a.length===0)throw new q(r,"no type argument before ','");let d=mr(a,i,t);i=[],o.push(d),a="",c+=1}else if(ds(p)){let d=!1;if(a.length!==0){let w=mr(a,i,t);i=[],o.push(w),a="",d=!0}s=Mc(r,s);let A=r[s];if(s<r.length&&d&&A!==","&&A!==">")throw new q(r,"unexpected whitespace character");continue}else a+=p;s+=1}if(n.length>0)throw new q(r,"no matching '>' for '<'");switch(o.length){case 0:return mr(a,i,t);case 1:if(a==="")return o[0];throw new q(r,"unexpected ','");default:throw new q(r,"unexpected whitespace character")}}function mr(r,e,t){let n=r.trim(),i=n.toLowerCase();if(Bc(i)&&e.length>0)throw new q(r,"primitive types not expected to have type arguments");switch(n.toLowerCase()){case"signer":return new yt;case"bool":return new G;case"address":return new X;case"u8":return new ae;case"u16":return new Ne;case"u32":return new Fe;case"u64":return new W;case"u128":return new Ge;case"u256":return new Be;case"vector":if(e.length!==1)throw new q(r,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Gc(n)){let a=n.substring(1);return new Xr(mr(a,e,t))}if(Fc(n)){if(t)return new z(Number(n.split("T")[1]));throw new q(r,"unexpected generic type")}if(!n.match(/:/))throw new q(r,"unknown type");let o=n.split("::");if(o.length!==3)throw new q(r,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch (e3){throw new q(r,"struct address must be valid")}if(!ps(o[1]))throw new q(r,"module name must only contain alphanumeric or '_' characters");if(!ps(o[2]))throw new q(r,"struct name must only contain alphanumeric or '_' characters");return new f(new Ie(s,new R(o[1]),new R(o[2]),e))}}var Lc=new TextEncoder;function Tn(r){return _nullishCoalesce(_optionalChain([r, 'optionalAccess', _109 => _109.map, 'call', _110 => _110(e=>et(e)?Le(e):e)]), () => ([]))}async function ls(r,e,t,n){let i=await ln({aptosConfig:n,accountAddress:r,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function gs(r,e,t,n){let i=await ls(r,e,t,n);if(!i)throw new Error(`Could not find entry function ABI for '${r}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${r}::${e}::${t}' is not an entry function`);let o=us(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Le(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function ys(r,e,t,n){let i=await ls(r,e,t,n);if(!i)throw new Error(`Could not find view function ABI for '${r}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${r}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Le(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Le(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Ai(r,e,t,n,i){if(n>=e.parameters.length)throw new Error(`Too many arguments for '${r}', expected ${e.parameters.length}`);let o=e.parameters[n];return Ht(t,o,n,i)}function Ht(r,e,t,n){return as(r)?(fi(e,r,t),r):qc(r,e,t,n)}function qc(r,e,t,n){if(e.isBool()){if(os(r))return new U(r);if(et(r)){if(r==="true")return new U(!0);if(r==="false")return new U(!1)}k("boolean",t)}if(e.isAddress()){if(et(r))return u.fromString(r);k("string | AccountAddress",t)}if(e.isU8()){let i=fn(r);if(i!==void 0)return new j(i);k("number | string",t)}if(e.isU16()){let i=fn(r);if(i!==void 0)return new Te(i);k("number | string",t)}if(e.isU32()){let i=fn(r);if(i!==void 0)return new be(i);k("number | string",t)}if(e.isU64()){if(An(r))return new $(BigInt(r));k("bigint | number | string",t)}if(e.isU128()){if(An(r))return new we(BigInt(r));k("bigint | number | string",t)}if(e.isU256()){if(An(r))return new de(BigInt(r));k("bigint | number | string",t)}if(e.isGeneric()){let i=e.value;if(i<0||i>=n.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Ht(r,n[i],t,n)}if(e.isVector()){if(e.value.isU8()){if(et(r))return b.U8(Lc.encode(r));if(r instanceof Uint8Array)return b.U8(r);if(r instanceof ArrayBuffer)return b.U8(new Uint8Array(r))}if(Array.isArray(r))return new b(r.map(i=>Ht(i,e.value,t,n)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(et(r))return new S(r);k("string",t)}if(e.isObject()){if(et(r))return u.fromString(r);k("string | AccountAddress",t)}if(e.isOption()){if(ss(r)){let i=e.value.typeArgs[0];return i instanceof G?new J(null):i instanceof X?new J(null):i instanceof ae?new J(null):i instanceof Ne?new J(null):i instanceof Fe?new J(null):i instanceof W?new J(null):i instanceof Ge?new J(null):i instanceof Be?new J(null):new J(null)}return new J(Ht(r,e.value.typeArgs[0],t,n))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function fi(r,e,t){if(r.isBool()){if(ci(e))return;k("Bool",t)}if(r.isAddress()){if(hn(e))return;k("AccountAddress",t)}if(r.isU8()){if(pi(e))return;k("U8",t)}if(r.isU16()){if(di(e))return;k("U16",t)}if(r.isU32()){if(li(e))return;k("U32",t)}if(r.isU64()){if(gi(e))return;k("U64",t)}if(r.isU128()){if(yi(e))return;k("U128",t)}if(r.isU256()){if(mi(e))return;k("U256",t)}if(r.isVector()){if(e instanceof b){e.values.length>0&&fi(r.value,e.values[0],t);return}k("MoveVector",t)}if(r instanceof f){if(r.isString()){if(ui(e))return;k("MoveString",t)}if(r.isObject()){if(hn(e))return;k("AccountAddress",t)}if(r.isOption()){if(e instanceof J){e.value!==void 0&&fi(r.value.typeArgs[0],e.value,t);return}k("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${r.toString()}'`)}async function wn(r){if(cs(r))return Qc(r);let{moduleAddress:e,moduleName:t,functionName:n}=yr(r.function),i=await hs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:gs});return $c({...r,abi:i})}function $c(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=yr(r.function),o=Tn(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=r.functionArguments.map((c,p)=>Ai(r.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=ft.build(`${t}::${n}`,i,o,s);if("multisigAddress"in r){let c=u.from(r.multisigAddress);return new cr(new pr(c,new dr(a)))}return new ar(a)}async function ms(r){let{moduleAddress:e,moduleName:t,functionName:n}=yr(r.function),i=await hs({key:"view-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:ys});return Wc({abi:i,...r})}function Wc(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=yr(r.function),o=Tn(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _111 => _111.functionArguments, 'optionalAccess', _112 => _112.map, 'call', _113 => _113((a,c)=>Ai(r.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);return ft.build(`${t}::${n}`,i,o,s)}function Qc(r){return new sr(new ur(g.fromHexInput(r.bytecode).toUint8Array(),Tn(r.typeArguments),r.functionArguments))}async function jc(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=async()=>$n[e.network]?{chainId:$n[e.network]}:{chainId:(await cn({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _114 => _114.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await yn({aptosConfig:e})).gas_estimate},c=async()=>{let St=async()=>_optionalChain([i, 'optionalAccess', _115 => _115.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Ce({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await St()}catch (e4){return 0}else return St()},[{chainId:p},{gasEstimate:d},A]=await Promise.all([s(),a(),c()]),{maxGasAmount:w,gasUnitPrice:y,expireTimestamp:x}={maxGasAmount:_optionalChain([i, 'optionalAccess', _116 => _116.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _117 => _117.gasUnitPrice]), () => (BigInt(d))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _118 => _118.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new me(u.from(t),BigInt(A),n,BigInt(w),BigInt(y),BigInt(x),new Dt(p))}async function hi(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=await jc({aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o});if("secondarySignerAddresses"in r){let a=_nullishCoalesce(_optionalChain([r, 'access', _119 => _119.secondarySignerAddresses, 'optionalAccess', _120 => _120.map, 'call', _121 => _121(c=>u.from(c))]), () => ([]));return new rn(s,a,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}return new tn(s,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}function fs(r){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:n,feePayerPublicKey:i}=r,o=bn(e);if(t.feePayerAddress){let a=new ht(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];if(n&&(c=n.map(A=>bn(A))),!i)throw new Error("Must provide a feePayerPublicKey argument to generate a signed fee payer transaction for simulation");let p=bn(i),d=new wt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new Ve(a.raw_txn,d).bcsToBytes()}if(t.secondarySignerAddresses){let a=new At(t.rawTransaction,t.secondarySignerAddresses),c=[];if(!n)throw new Error("Must provide a secondarySignersPublicKeys argument to generate a signed multi agent transaction for simulation");c=n.map(d=>bn(d));let p=new bt(o,t.secondarySignerAddresses,c);return new Ve(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof _e)s=new Tt(o.public_key,o.signature);else if(o instanceof ie||o instanceof ve)s=new _t(o);else throw new Error("Invalid public key");return new Ve(t.rawTransaction,s).bcsToBytes()}function bn(r){let t=D.isInstance(r)||Z.isInstance(r)||Ue.isInstance(r)?new F(r):r,n=new I(new Uint8Array(64));if(P.isInstance(t))return new _e(t,n);if(F.isInstance(t))return D.isInstance(t.publicKey)?new ie(t,new L(De.getSimulationSignature())):new ie(t,new L(n));if(Ye.isInstance(t))return new ve(t,new ze({signatures:t.publicKeys.map(()=>new L(n)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Ti(r){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:n}=r,i=ao(ee,r.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new wt(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(n, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!n)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new bt(i,e.secondarySignerAddresses,n)}else i instanceof _e?o=new Tt(i.public_key,i.signature):o=new _t(i);return new Ve(e.rawTransaction,o).bcsToBytes()}function As(r){let e=_sha3.sha3_256.create();for(let t of r)e.update(t);return e.digest()}var Jc=As(["APTOS::Transaction"]);function DT(r){let e=Ti(r);return new g(As([Jc,new Uint8Array([0]),e])).toString()}async function hs({key:r,moduleAddress:e,moduleName:t,functionName:n,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ee(async()=>s(e,t,n,i),`${r}-${i.network}-${e}-${t}-${n}`,1e3*60*5)()}async function fe(r){let{aptosConfig:e,payload:t,options:n}=r,i=await ms({...t,aptosConfig:e}),o=new H;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Xe({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([n, 'optionalAccess', _122 => _122.ledgerVersion])},body:s});return a}async function Ts(r){let{aptosConfig:e,payload:t,options:n}=r,{data:i}=await Xe({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([n, 'optionalAccess', _123 => _123.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}var fr=class{constructor(e){this.config=e}async getAccountInfo(e){return Ce({aptosConfig:this.config,...e})}async getAccountModules(e){return Vo({aptosConfig:this.config,...e})}async getAccountModule(e){return ln({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Lo({aptosConfig:this.config,...e})}async getAccountResources(e){return qo({aptosConfig:this.config,...e})}async getAccountResource(e){return oi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Lt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ho({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$o({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Wo({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Qo({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),jo({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Jo({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Xo({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:lt,faMetadataAddress:io,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:n,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
479
+ `;async function dn(r){let{aptosConfig:e}=r,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function Vo(r){let{aptosConfig:e,limit:t}=r;return(await h({aptosConfig:e,query:{query:Uo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function h(r){let{aptosConfig:e,query:t,originMethod:n}=r,{data:i}=await mo({aptosConfig:e,originMethod:_nullishCoalesce(n, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Bc(r){let{aptosConfig:e}=r;return(await h({aptosConfig:e,query:{query:ai},originMethod:"getProcessorStatuses"})).processor_status}async function ln(r){let e=await Bc({aptosConfig:r.aptosConfig});return BigInt(e[0].last_success_version)}async function gn(r){let{aptosConfig:e,processorType:t}=r;return(await h({aptosConfig:e,query:{query:ai,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function yn(r){let{aptosConfig:e,handle:t,data:n,options:i}=r;return(await Xe({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _56 => _56.ledgerVersion])},body:n})).data}async function Lo(r){let{aptosConfig:e,options:t}=r,n={query:Fo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _57 => _57.where]),offset:_optionalChain([t, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([t, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([t, 'optionalAccess', _60 => _60.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getTableItemsData"})).table_items}async function qo(r){let{aptosConfig:e,options:t}=r,n={query:Go,variables:{where_condition:_optionalChain([t, 'optionalAccess', _61 => _61.where]),offset:_optionalChain([t, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([t, 'optionalAccess', _63 => _63.limit]),order_by:_optionalChain([t, 'optionalAccess', _64 => _64.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Ce(r){let{aptosConfig:e,accountAddress:t}=r,{data:n}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return n}async function Wo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ut({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _65 => _65.ledgerVersion]),start:_optionalChain([n, 'optionalAccess', _66 => _66.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _67 => _67.limit]), () => (1e3))}})}async function mn(r){return _optionalChain([r, 'access', _68 => _68.options, 'optionalAccess', _69 => _69.ledgerVersion])!==void 0?Ho(r):Ee(async()=>Ho(r),`module-${r.accountAddress}-${r.moduleName}`,1e3*60*5)()}async function Ho(r){let{aptosConfig:e,accountAddress:t,moduleName:n,options:i}=r,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _70 => _70.ledgerVersion])}});return o}async function Qo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ut({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([n, 'optionalAccess', _71 => _71.offset]),limit:_optionalChain([n, 'optionalAccess', _72 => _72.limit])}})}async function jo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return Ut({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _73 => _73.ledgerVersion]),start:_optionalChain([n, 'optionalAccess', _74 => _74.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _75 => _75.limit]), () => (999))}})}async function ui(r){let{aptosConfig:e,accountAddress:t,resourceType:n,options:i}=r,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _76 => _76.ledgerVersion])}});return o.data}async function Wt(r){let{aptosConfig:e,authenticationKey:t,options:n}=r,i=await ui({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:n}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await yn({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:n});return u.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Jo(r){let{aptosConfig:e,accountAddress:t}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await h({aptosConfig:e,query:{query:Co,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Xo(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([n, 'optionalAccess', _77 => _77.tokenStandard])&&(o.token_standard={_eq:_optionalChain([n, 'optionalAccess', _78 => _78.tokenStandard])});let s={query:vo,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _79 => _79.offset]),limit:_optionalChain([n, 'optionalAccess', _80 => _80.limit]),order_by:_optionalChain([n, 'optionalAccess', _81 => _81.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Yo(r){let{aptosConfig:e,accountAddress:t,collectionAddress:n,options:i}=r,o=u.from(t).toStringLong(),s=u.from(n).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _82 => _82.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _83 => _83.tokenStandard])});let c={query:Io,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _84 => _84.offset]),limit:_optionalChain([i, 'optionalAccess', _85 => _85.limit]),order_by:_optionalChain([i, 'optionalAccess', _86 => _86.orderBy])}};return(await h({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Zo(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}};_optionalChain([n, 'optionalAccess', _87 => _87.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([n, 'optionalAccess', _88 => _88.tokenStandard])}});let s={query:Po,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _89 => _89.offset]),limit:_optionalChain([n, 'optionalAccess', _90 => _90.limit]),order_by:_optionalChain([n, 'optionalAccess', _91 => _91.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function es(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:Ro,variables:{address:n}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function ts(r){let{aptosConfig:e,accountAddress:t,options:n}=r,i=u.from(t).toStringLong(),o={..._optionalChain([n, 'optionalAccess', _92 => _92.where]),owner_address:{_eq:i}},s={query:Eo,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _93 => _93.offset]),limit:_optionalChain([n, 'optionalAccess', _94 => _94.limit]),order_by:_optionalChain([n, 'optionalAccess', _95 => _95.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function rs(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:xo,variables:{address:n}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function ns(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:pn,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _96 => _96.offset]),limit:_optionalChain([n, 'optionalAccess', _97 => _97.limit]),order_by:_optionalChain([n, 'optionalAccess', _98 => _98.orderBy])}};return(await h({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function is(r){let{aptosConfig:e,privateKey:t}=r,n=new F(t.publicKey());if(t instanceof pt){let o=B.fromPublicKey({publicKey:n}).derivedAddress();return et.fromPrivateKey({privateKey:t,address:o})}if(t instanceof Z){let i=B.fromPublicKey({publicKey:n});if(await $o({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return et.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=B.fromPublicKey({publicKey:n.publicKey});if(await $o({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return et.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function $o(r){let{aptosConfig:e,authKey:t}=r,n=await Wt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Ce({aptosConfig:e,accountAddress:n}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${n.toString()}`)}}async function di(r){let{aptosConfig:e,options:t}=r;return Ut({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _99 => _99.offset]),limit:_optionalChain([t, 'optionalAccess', _100 => _100.limit])}})}async function An(r){let{aptosConfig:e}=r;return Ee(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function os(r){let{aptosConfig:e,ledgerVersion:t}=r,{data:n}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return n}async function hr(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return n}async function ss(r){let{aptosConfig:e,transactionHash:t}=r;try{return(await hr({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(n){if(_optionalChain([n, 'optionalAccess', _101 => _101.status])===404)return!0;throw n}}async function Mc(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return n}async function Qt(r){let{aptosConfig:e,transactionHash:t,options:n}=r,i=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _102 => _102.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _103 => _103.checkSuccess]), () => (!0)),s=!0,a=0,c,p,d=200,A=1.5;function w(y){if(!(y instanceof ye)||(p=y,y.status!==404&&y.status>=400&&y.status<500))throw y}try{c=await hr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(y){w(y)}if(s){let y=Date.now();try{c=await Mc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(x){w(x)}a=(Date.now()-y)/1e3}for(;s&&!(a>=i);){try{if(c=await hr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(y){w(y)}await _chunkF43XVDYJjs.b.call(void 0, d),a+=d/1e3,d*=A}if(c===void 0)throw p||new fn(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new fn(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new pi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function hn(r){let{aptosConfig:e,processorType:t}=r,n=BigInt(r.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<n;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await ln({aptosConfig:e}):s=(await gn({aptosConfig:e,processorType:t})).last_success_version,s>=n)break;await _chunkF43XVDYJjs.b.call(void 0, 200)}}var fn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},pi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function as(r){let{aptosConfig:e,ledgerVersion:t,options:n}=r,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _104 => _104.withTransactions])}});return us({block:i,...r})}async function cs(r){let{aptosConfig:e,blockHeight:t,options:n}=r,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _105 => _105.withTransactions])}});return us({block:i,...r})}async function us(r){let{aptosConfig:e,block:t,options:n}=r;if(_optionalChain([n, 'optionalAccess', _106 => _106.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _107 => _107.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],d=100n;for(let w=c+1n;w<s;w+=BigInt(100))p.push(di({aptosConfig:e,options:{offset:w,limit:Math.min(Number(d),Number(s-w+1n))}}));let A=await Promise.all(p);for(let w of A)t.transactions.push(...w)}return t}async function T(r){r.minimumLedgerVersion!==void 0&&await hn({aptosConfig:r.config,minimumLedgerVersion:r.minimumLedgerVersion,processorType:r.processorType})}function ps(r){return typeof r=="boolean"}function tt(r){return typeof r=="string"}function Vc(r){return typeof r=="number"}function Tn(r){if(Vc(r))return r;if(tt(r)&&r!=="")return Number.parseInt(r,10)}function bn(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function ds(r){return r==null}function ls(r){return li(r)||yi(r)||mi(r)||fi(r)||Ai(r)||hi(r)||Ti(r)||wn(r)||gi(r)||Lc(r)||r instanceof b||r instanceof J}function li(r){return r instanceof U}function wn(r){return r instanceof u}function gi(r){return r instanceof S}function Lc(r){return r instanceof at}function yi(r){return r instanceof j}function mi(r){return r instanceof Te}function fi(r){return r instanceof be}function Ai(r){return r instanceof $}function hi(r){return r instanceof we}function Ti(r){return r instanceof de}function gs(r){return"bytecode"in r}function k(r,e){throw new Error(`Type mismatch for argument ${e}, expected '${r}'`)}function ys(r){let e=r.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?r.params.length:e}function Et(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],i=e[2];return{moduleAddress:t,moduleName:n,functionName:i}}function ms(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function fs(r){return!!r.match(/\s/)}function qc(r){return!!r.match(/^T[0-9]+$/)}function Hc(r){return!!r.match(/^&.+$/)}function $c(r){switch(r){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Wc(r,e){let t=e;for(;t<r.length;t+=1){let n=r[t];if(!fs(n))break}return t}var Qc=(x=>(x.InvalidTypeTag="unknown type",x.UnexpectedGenericType="unexpected generic type",x.UnexpectedTypeArgumentClose="unexpected '>'",x.UnexpectedWhitespaceCharacter="unexpected whitespace character",x.UnexpectedComma="unexpected ','",x.TypeArgumentCountMismatch="type argument count doesn't match expected amount",x.MissingTypeArgumentClose="no matching '>' for '<'",x.MissingTypeArgument="no type argument before ','",x.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",x.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",x.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",x.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",x.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",x.InvalidAddress="struct address must be valid",x))(Qc||{}),q= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Re(r,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _108 => _108.allowGenerics]), () => (!1)),n=[],i=[],o=[],s=0,a="",c=1;for(;s<r.length;){let p=r[s];if(p==="<")n.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let x=Tr(a,i,t);o.push(x)}let d=n.pop();if(d===void 0)throw new q(r,"unexpected '>'");if(c!==o.length)throw new q(r,"type argument count doesn't match expected amount");let{savedStr:A,savedTypes:w,savedExpectedTypes:y}=d;i=o,o=w,a=A,c=y}else if(p===","){if(n.length===0)throw new q(r,"unexpected ','");if(a.length===0)throw new q(r,"no type argument before ','");let d=Tr(a,i,t);i=[],o.push(d),a="",c+=1}else if(fs(p)){let d=!1;if(a.length!==0){let w=Tr(a,i,t);i=[],o.push(w),a="",d=!0}s=Wc(r,s);let A=r[s];if(s<r.length&&d&&A!==","&&A!==">")throw new q(r,"unexpected whitespace character");continue}else a+=p;s+=1}if(n.length>0)throw new q(r,"no matching '>' for '<'");switch(o.length){case 0:return Tr(a,i,t);case 1:if(a==="")return o[0];throw new q(r,"unexpected ','");default:throw new q(r,"unexpected whitespace character")}}function Tr(r,e,t){let n=r.trim(),i=n.toLowerCase();if($c(i)&&e.length>0)throw new q(r,"primitive types not expected to have type arguments");switch(n.toLowerCase()){case"signer":return new ft;case"bool":return new G;case"address":return new Y;case"u8":return new ae;case"u16":return new Fe;case"u32":return new Ge;case"u64":return new W;case"u128":return new Be;case"u256":return new Me;case"vector":if(e.length!==1)throw new q(r,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Hc(n)){let a=n.substring(1);return new tn(Tr(a,e,t))}if(qc(n)){if(t)return new N(Number(n.split("T")[1]));throw new q(r,"unexpected generic type")}if(!n.match(/:/))throw new q(r,"unknown type");let o=n.split("::");if(o.length!==3)throw new q(r,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch (e3){throw new q(r,"struct address must be valid")}if(!ms(o[1]))throw new q(r,"module name must only contain alphanumeric or '_' characters");if(!ms(o[2]))throw new q(r,"struct name must only contain alphanumeric or '_' characters");return new f(new Ie(s,new R(o[1]),new R(o[2]),e))}}var jc=new TextEncoder;function Jt(r){return _nullishCoalesce(_optionalChain([r, 'optionalAccess', _109 => _109.map, 'call', _110 => _110(e=>tt(e)?Re(e):e)]), () => ([]))}async function wi(r,e,t,n){let i=await mn({aptosConfig:n,accountAddress:r,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function As(r,e,t,n){let i=await wi(r,e,t,n);if(!i)throw new Error(`Could not find function ABI for '${r}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Re(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function hs(r,e,t,n){let i=await wi(r,e,t,n);if(!i)throw new Error(`Could not find entry function ABI for '${r}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${r}::${e}::${t}' is not an entry function`);let o=ys(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Re(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Ts(r,e,t,n){let i=await wi(r,e,t,n);if(!i)throw new Error(`Could not find view function ABI for '${r}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${r}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Re(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Re(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function bs(r,e,t,n,i){return r instanceof _scriptcomposerpack.CallArgument?r:_scriptcomposerpack.CallArgument.new_bytes(_n(e,t,r,n,i).bcsToBytes())}function _n(r,e,t,n,i){if(n>=e.parameters.length)throw new Error(`Too many arguments for '${r}', expected ${e.parameters.length}`);let o=e.parameters[n];return jt(t,o,n,i)}function jt(r,e,t,n){return ls(r)?(bi(e,r,t),r):Jc(r,e,t,n)}function Jc(r,e,t,n){if(e.isBool()){if(ps(r))return new U(r);if(tt(r)){if(r==="true")return new U(!0);if(r==="false")return new U(!1)}k("boolean",t)}if(e.isAddress()){if(tt(r))return u.fromString(r);k("string | AccountAddress",t)}if(e.isU8()){let i=Tn(r);if(i!==void 0)return new j(i);k("number | string",t)}if(e.isU16()){let i=Tn(r);if(i!==void 0)return new Te(i);k("number | string",t)}if(e.isU32()){let i=Tn(r);if(i!==void 0)return new be(i);k("number | string",t)}if(e.isU64()){if(bn(r))return new $(BigInt(r));k("bigint | number | string",t)}if(e.isU128()){if(bn(r))return new we(BigInt(r));k("bigint | number | string",t)}if(e.isU256()){if(bn(r))return new de(BigInt(r));k("bigint | number | string",t)}if(e.isGeneric()){let i=e.value;if(i<0||i>=n.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return jt(r,n[i],t,n)}if(e.isVector()){if(e.value.isU8()){if(tt(r))return b.U8(jc.encode(r));if(r instanceof Uint8Array)return b.U8(r);if(r instanceof ArrayBuffer)return b.U8(new Uint8Array(r))}if(Array.isArray(r))return new b(r.map(i=>jt(i,e.value,t,n)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(tt(r))return new S(r);k("string",t)}if(e.isObject()){if(tt(r))return u.fromString(r);k("string | AccountAddress",t)}if(e.isOption()){if(ds(r)){let i=e.value.typeArgs[0];return i instanceof G?new J(null):i instanceof Y?new J(null):i instanceof ae?new J(null):i instanceof Fe?new J(null):i instanceof Ge?new J(null):i instanceof W?new J(null):i instanceof Be?new J(null):i instanceof Me?new J(null):new J(null)}return new J(jt(r,e.value.typeArgs[0],t,n))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function bi(r,e,t){if(r.isBool()){if(li(e))return;k("Bool",t)}if(r.isAddress()){if(wn(e))return;k("AccountAddress",t)}if(r.isU8()){if(yi(e))return;k("U8",t)}if(r.isU16()){if(mi(e))return;k("U16",t)}if(r.isU32()){if(fi(e))return;k("U32",t)}if(r.isU64()){if(Ai(e))return;k("U64",t)}if(r.isU128()){if(hi(e))return;k("U128",t)}if(r.isU256()){if(Ti(e))return;k("U256",t)}if(r.isVector()){if(e instanceof b){e.values.length>0&&bi(r.value,e.values[0],t);return}k("MoveVector",t)}if(r instanceof f){if(r.isString()){if(gi(e))return;k("MoveString",t)}if(r.isObject()){if(wn(e))return;k("AccountAddress",t)}if(r.isOption()){if(e instanceof J){e.value!==void 0&&bi(r.value.typeArgs[0],e.value,t);return}k("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${r.toString()}'`)}async function Sn(r){if(gs(r))return eu(r);let{moduleAddress:e,moduleName:t,functionName:n}=Et(r.function),i=await xs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:hs});return Yc({...r,abi:i})}function Yc(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=Et(r.function),o=Jt(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=r.functionArguments.map((c,p)=>_n(r.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=Tt.build(`${t}::${n}`,i,o,s);if("multisigAddress"in r){let c=u.from(r.multisigAddress);return new gr(new mr(c,new fr(a)))}return new lr(a)}async function ws(r){let{moduleAddress:e,moduleName:t,functionName:n}=Et(r.function),i=await xs({key:"view-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:Ts});return Zc({abi:i,...r})}function Zc(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=Et(r.function),o=Jt(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _111 => _111.functionArguments, 'optionalAccess', _112 => _112.map, 'call', _113 => _113((a,c)=>_n(r.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);return Tt.build(`${t}::${n}`,i,o,s)}function eu(r){return new ht(new yr(g.fromHexInput(r.bytecode).toUint8Array(),Jt(r.typeArguments),r.functionArguments))}async function _i(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=async()=>Jn[e.network]?{chainId:Jn[e.network]}:{chainId:(await dn({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _114 => _114.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await An({aptosConfig:e})).gas_estimate},c=async()=>{let Pt=async()=>_optionalChain([i, 'optionalAccess', _115 => _115.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Ce({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await Pt()}catch (e4){return 0}else return Pt()},[{chainId:p},{gasEstimate:d},A]=await Promise.all([s(),a(),c()]),{maxGasAmount:w,gasUnitPrice:y,expireTimestamp:x}={maxGasAmount:_optionalChain([i, 'optionalAccess', _116 => _116.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _117 => _117.gasUnitPrice]), () => (BigInt(d))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _118 => _118.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new me(u.from(t),BigInt(A),n,BigInt(w),BigInt(y),BigInt(x),new Nt(p))}async function Si(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=await _i({aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o});if("secondarySignerAddresses"in r){let a=_nullishCoalesce(_optionalChain([r, 'access', _119 => _119.secondarySignerAddresses, 'optionalAccess', _120 => _120.map, 'call', _121 => _121(c=>u.from(c))]), () => ([]));return new sn(s,a,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}return new Ft(s,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}function _s(r){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:n,feePayerPublicKey:i}=r,o=Xt(e);if(t.feePayerAddress){let a=new wt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(n?c=n.map(A=>Xt(A)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Xt(void 0)));let p=Xt(i),d=new xt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new Le(a.raw_txn,d).bcsToBytes()}if(t.secondarySignerAddresses){let a=new bt(t.rawTransaction,t.secondarySignerAddresses),c=[];n?c=n.map(d=>Xt(d)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Xt(void 0));let p=new St(o,t.secondarySignerAddresses,c);return new Le(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof _e)s=new _t(o.public_key,o.signature);else if(o instanceof ie||o instanceof ve)s=new Ze(o);else if(o instanceof zt)s=new Ze(o);else throw new Error("Invalid public key");return new Le(t.rawTransaction,s).bcsToBytes()}function Xt(r){if(!r)return new zt;let t=O.isInstance(r)||ee.isInstance(r)||Ke.isInstance(r)?new F(r):r,n=new I(new Uint8Array(64));if(P.isInstance(t))return new _e(t,n);if(F.isInstance(t))return O.isInstance(t.publicKey)?new ie(t,new L(Oe.getSimulationSignature())):new ie(t,new L(n));if(Ye.isInstance(t))return new ve(t,new Ne({signatures:t.publicKeys.map(()=>new L(n)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function xi(r){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:n}=r,i=go(X,r.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new xt(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(n, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!n)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new St(i,e.secondarySignerAddresses,n)}else i instanceof _e?o=new _t(i.public_key,i.signature):o=new Ze(i);return new Le(e.rawTransaction,o).bcsToBytes()}function Ss(r){let e=_sha3.sha3_256.create();for(let t of r)e.update(t);return e.digest()}var tu=Ss(["APTOS::Transaction"]);function HT(r){let e=xi(r);return new g(Ss([tu,new Uint8Array([0]),e])).toString()}async function xs({key:r,moduleAddress:e,moduleName:t,functionName:n,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ee(async()=>s(e,t,n,i),`${r}-${i.network}-${e}-${t}-${n}`,1e3*60*5)()}(async()=>_scriptcomposerpack.initSync.call(void 0, {module:_scriptcomposerpack.wasm}))();var xn=class{constructor(e){this.builder=_scriptcomposerpack.TransactionComposer.single_signer(),this.config=e}async addBatchedCalls(e){let{moduleAddress:t,moduleName:n,functionName:i}=Et(e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${n}`),e.typeArguments!==void 0)for(let p of e.typeArguments)await this.builder.load_type_tag(o,p.toString());let s=Jt(e.typeArguments),a=await As(t,n,i,this.config);if(s.length!==a.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${a.typeParameters.length}, received ${s.length}`);let c=e.functionArguments.map((p,d)=>bs(p,i,a,d,s));return this.builder.add_batched_call(`${t}::${n}`,i,s.map(p=>p.toString()),c)}build(){return this.builder.generate_batched_calls(!0)}};async function fe(r){let{aptosConfig:e,payload:t,options:n}=r,i=await ws({...t,aptosConfig:e}),o=new H;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Xe({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([n, 'optionalAccess', _122 => _122.ledgerVersion])},body:s});return a}async function Es(r){let{aptosConfig:e,payload:t,options:n}=r,{data:i}=await Xe({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([n, 'optionalAccess', _123 => _123.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}var br=class{constructor(e){this.config=e}async getAccountInfo(e){return Ce({aptosConfig:this.config,...e})}async getAccountModules(e){return Wo({aptosConfig:this.config,...e})}async getAccountModule(e){return mn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Qo({aptosConfig:this.config,...e})}async getAccountResources(e){return jo({aptosConfig:this.config,...e})}async getAccountResource(e){return ui({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Wt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Jo({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Xo({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Yo({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Zo({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),es({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ts({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),rs({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:yt,faMetadataAddress:uo,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:n,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
480
480
  compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
481
- will be removed in the near future`);let s=n;n===void 0&&i!==void 0&&(s=await Ee(async()=>{try{let p=(await fe({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunkF43XVDYJjs.j.call(void 0, p.vec[0]))return _chunkF43XVDYJjs.i.call(void 0, p.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(n!==void 0&&i!==void 0)a=u.from(i).toStringLong();else if(n!==void 0&&i===void 0)n===lt?a=u.A.toStringLong():a=Jr(u.A,n).toStringLong();else if(n===void 0&&i!==void 0){let p=u.from(i);a=p.toStringLong(),p===u.A&&(s=lt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await fe({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await fe({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Yo({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Zo({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var _n=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _124 => _124.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _125 => _125.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _126 => _126.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _127 => _127.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _128 => _128.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _129 => _129.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _130 => _130.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _131 => _131.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _132 => _132.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _133 => _133.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _134 => _134.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 eo[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return to[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 Zi[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 Ln[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 qn[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Ln[this.network]===e}isProverServiceRequest(e){return qn[this.network]===e}};async function _(r){let e=await Yc(r);return Zc(r,e)}async function Yc(r){let{aptosConfig:e,data:t}=r,n,i;return"bytecode"in t?i=await wn(t):"multisigAddress"in t?(n={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await wn(n)):(n={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await wn(n)),i}async function Zc(r,e){let{aptosConfig:t,sender:n,options:i}=r,o;if(eu(r)&&(o=u.ZERO.toString()),tu(r)){let{secondarySignerAddresses:s}=r;return hi({aptosConfig:t,sender:n,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return hi({aptosConfig:t,sender:n,payload:e,options:i,feePayerAddress:o})}function eu(r){return r.withFeePayer===!0}function tu(r){return"secondarySignerAddresses"in r}function bs(r){let{transaction:e}=r;return zt(e)}function Sn(r){let{signer:e,transaction:t}=r;return e.signTransactionWithAuthenticator(t)}function xn(r){let{signer:e,transaction:t}=r;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Sn({signer:e,transaction:t})}async function bi(r){let{aptosConfig:e,transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=r,a=fs({transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Xe({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([r, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _139 => _139.options, 'optionalAccess', _140 => _140.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Ar(r){let{aptosConfig:e}=r,t=Ti({...r});try{let{data:n}=await Xe({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}catch(n){let i=Ve.deserialize(new N(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof D||i.authenticator.sender.public_key.publicKey instanceof Z)&&await ue.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),n}}async function hr(r){let{aptosConfig:e,signer:t,feePayer:n,transaction:i}=r;nn(t)&&await t.checkKeylessAccountValidity(e),nn(n)&&await n.checkKeylessAccountValidity(e);let o=r.feePayerAuthenticator||n&&xn({signer:n,transaction:i}),s=Sn({signer:t,transaction:i});return Ar({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ws(r){let{aptosConfig:e,senderAuthenticator:t,feePayer:n,transaction:i}=r;nn(n)&&await n.checkKeylessAccountValidity(e);let o=xn({signer:n,transaction:i});return Ar({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var ru={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function _s(r){let{aptosConfig:e,account:t,metadataBytes:n,moduleBytecode:i,options:o}=r,s=i.map(a=>b.U8(a));return _({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[b.U8(n),new b(s)],abi:ru},options:o})}var nu={typeParameters:[],parameters:[new ae,C.u8(),new ae,C.u8(),C.u8(),C.u8()]};async function Ss(r){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:n}=r,i=await Ce({aptosConfig:e,accountAddress:t.accountAddress}),o=Ze.fromPrivateKey({privateKey:n,legacy:!0}),a=new Zr({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),p=o.sign(a),d=await _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new j(t.signingScheme),b.U8(t.publicKey.toUint8Array()),new j(o.signingScheme),b.U8(o.publicKey.toUint8Array()),b.U8(c.toUint8Array()),b.U8(p.toUint8Array())],abi:nu}});return hr({aptosConfig:e,signer:t,transaction:d})}var iu={typeParameters:[{constraints:[]}],parameters:[new X,new W]};async function xs(r){let{aptosConfig:e,sender:t,recipient:n,amount:i,coinType:o,options:s}=r;return _({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (lt))],functionArguments:[n,i],abi:iu},options:s})}var Tr=class{constructor(e){this.config=e}async transferCoinTransaction(e){return xs({aptosConfig:this.config,...e})}};var tt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Ae="0x4::token::Token";async function Es(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()}};return(await h({aptosConfig:e,query:{query:zo,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ps(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await h({aptosConfig:e,query:{query:ii,variables:{where_condition:n}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function vs(r){let{aptosConfig:e,ownerAddress:t,options:n}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:ii,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([n, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([n, 'optionalAccess', _143 => _143.orderBy])}};return(await h({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Is(r){let{aptosConfig:e,digitalAssetAddress:t,options:n}=r,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:Oo,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([n, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([n, 'optionalAccess', _146 => _146.orderBy])}};return(await h({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var ou={typeParameters:[],parameters:[new f(v()),new W,new f(v()),new f(v()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new W,new W]};async function Cs(r){let{aptosConfig:e,options:t,creator:n}=r;return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new S(r.description),new $(_nullishCoalesce(r.maxSupply, () => (it))),new S(r.name),new S(r.uri),new U(_nullishCoalesce(r.mutableDescription, () => (!0))),new U(_nullishCoalesce(r.mutableRoyalty, () => (!0))),new U(_nullishCoalesce(r.mutableURI, () => (!0))),new U(_nullishCoalesce(r.mutableTokenDescription, () => (!0))),new U(_nullishCoalesce(r.mutableTokenName, () => (!0))),new U(_nullishCoalesce(r.mutableTokenProperties, () => (!0))),new U(_nullishCoalesce(r.mutableTokenURI, () => (!0))),new U(_nullishCoalesce(r.tokensBurnableByCreator, () => (!0))),new U(_nullishCoalesce(r.tokensFreezableByCreator, () => (!0))),new $(_nullishCoalesce(r.royaltyNumerator, () => (0))),new $(_nullishCoalesce(r.royaltyDenominator, () => (1)))],abi:ou},options:t})}async function $t(r){let{aptosConfig:e,options:t}=r,n=_optionalChain([t, 'optionalAccess', _147 => _147.where]);_optionalChain([t, 'optionalAccess', _148 => _148.tokenStandard])&&(n.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.tokenStandard]), () => ("v2"))});let i={query:vo,variables:{where_condition:n,offset:_optionalChain([t, 'optionalAccess', _150 => _150.offset]),limit:_optionalChain([t, 'optionalAccess', _151 => _151.limit])}};return(await h({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function Rs(r){let{aptosConfig:e,creatorAddress:t,collectionName:n,options:i}=r,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _152 => _152.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),$t({aptosConfig:e,options:{...i,where:s}})}async function Us(r){let{aptosConfig:e,creatorAddress:t,options:n}=r,o={creator_address:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _154 => _154.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),$t({aptosConfig:e,options:{...n,where:o}})}async function Ks(r){let{aptosConfig:e,collectionId:t,options:n}=r,o={collection_id:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _156 => _156.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _157 => _157.tokenStandard]), () => ("v2"))}),$t({aptosConfig:e,options:{...n,where:o}})}async function ks(r){let{creatorAddress:e,collectionName:t,options:n,aptosConfig:i}=r,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([n, 'optionalAccess', _158 => _158.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _159 => _159.tokenStandard]), () => ("v2"))}),(await $t({aptosConfig:i,options:{where:s}})).collection_id}var su={typeParameters:[],parameters:[new f(v()),new f(v()),new f(v()),new f(v()),new C(new f(v())),new C(new f(v())),new C(C.u8())]};async function Ds(r){let{aptosConfig:e,options:t,creator:n,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:d}=r,A=_optionalChain([p, 'optionalAccess', _160 => _160.map, 'call', _161 => _161(w=>tt[w])]);return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new S(i),new S(o),new S(s),new S(a),b.MoveString(_nullishCoalesce(c, () => ([]))),b.MoveString(_nullishCoalesce(A, () => ([]))),Qs(_nullishCoalesce(d, () => ([])),_nullishCoalesce(A, () => ([])))],abi:su},options:t})}var au={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new X]};async function Os(r){let{aptosConfig:e,sender:t,digitalAssetAddress:n,recipient:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(n),u.from(i)],abi:au},options:s})}var cu={typeParameters:[],parameters:[new f(v()),new f(v()),new f(v()),new f(v()),new C(new f(v())),new C(new f(v())),new C(C.u8()),new X]};async function zs(r){let{aptosConfig:e,account:t,collection:n,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:d,options:A}=r;if(_optionalChain([c, 'optionalAccess', _162 => _162.length])!==_optionalChain([d, 'optionalAccess', _163 => _163.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _164 => _164.length])!==_optionalChain([d, 'optionalAccess', _165 => _165.length]))throw new Error("Property types and property values counts do not match");let w=_optionalChain([p, 'optionalAccess', _166 => _166.map, 'call', _167 => _167(y=>tt[y])]);return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,i,o,s,b.MoveString(_nullishCoalesce(c, () => ([]))),b.MoveString(_nullishCoalesce(w, () => ([]))),Qs(_nullishCoalesce(d, () => ([])),_nullishCoalesce(w, () => ([]))),a],abi:cu},options:A})}var uu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0)))]};async function Ns(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[u.from(n)],abi:uu},options:o})}var pu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0)))]};async function Fs(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[n],abi:pu},options:o})}var du={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0)))]};async function Gs(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[n],abi:du},options:o})}var lu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v())]};async function Bs(r){let{aptosConfig:e,creator:t,description:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:lu},options:s})}var gu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v())]};async function Ms(r){let{aptosConfig:e,creator:t,name:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:gu},options:s})}var yu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v())]};async function Vs(r){let{aptosConfig:e,creator:t,uri:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:yu},options:s})}var mu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v()),new f(v()),C.u8()]};async function Ls(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Ae))],functionArguments:[u.from(s),new S(n),new S(tt[i]),b.U8(wi(o,tt[i]))],abi:mu},options:c})}var fu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v())]};async function qs(r){let{aptosConfig:e,creator:t,propertyKey:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:fu},options:s})}var Au={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new z(0))),new f(v()),new f(v()),C.u8()]};async function Hs(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Ae))],functionArguments:[u.from(s),new S(n),new S(tt[i]),wi(o,tt[i])],abi:Au},options:c})}var hu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ce(new z(0))),new f(v()),new z(1)]};async function $s(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ae)),tt[i]],functionArguments:[u.from(s),new S(n),o],abi:hu},options:c})}var Tu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ce(new z(0))),new f(v()),new z(1)]};async function Ws(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ae)),tt[i]],functionArguments:[u.from(s),new S(n),o],abi:Tu},options:c})}function Qs(r,e){let t=new Array;return e.forEach((n,i)=>{t.push(wi(r[i],n))}),t}function wi(r,e){let t=Le(e);return Ht(r,t,0,[]).bcsToBytes()}var br=class{constructor(e){this.config=e}async getCollectionData(e){await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:n,options:i}=e,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _168 => _168.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _169 => _169.tokenStandard]), () => ("v2"))}),$t({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Rs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Us({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ks({aptosConfig:this.config,...e})}async getCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ks({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Es({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ps({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),vs({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Is({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Cs({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Ds({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Os({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return zs({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Ns({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Fs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Gs({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Bs({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Ms({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Vs({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Ls({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return qs({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Hs({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return $s({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Ws({aptosConfig:this.config,...e})}};var js=300,bu=r=>{if(r&&r.length>js)throw new Error(`Event type length exceeds the maximum length of ${js}`)};async function Js(r){let{aptosConfig:e,eventType:t,options:n}=r,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return wr({aptosConfig:e,options:{...n,where:i}})}async function Xs(r){let{accountAddress:e,aptosConfig:t,creationNumber:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:n}};return wr({aptosConfig:t,options:{...i,where:s}})}async function Ys(r){let{accountAddress:e,aptosConfig:t,eventType:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:n}};return wr({aptosConfig:t,options:{...i,where:s}})}async function wr(r){let{aptosConfig:e,options:t}=r;bu(_optionalChain([t, 'optionalAccess', _170 => _170.where, 'optionalAccess', _171 => _171.indexed_type, 'optionalAccess', _172 => _172._eq]));let n={query:Ro,variables:{where_condition:_optionalChain([t, 'optionalAccess', _173 => _173.where]),offset:_optionalChain([t, 'optionalAccess', _174 => _174.offset]),limit:_optionalChain([t, 'optionalAccess', _175 => _175.limit]),order_by:_optionalChain([t, 'optionalAccess', _176 => _176.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getEvents"})).events}var _r=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Js({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Xs({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ys({aptosConfig:this.config,...e})}async getEvents(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _177 => _177.minimumLedgerVersion]),processorType:"events_processor"}),wr({aptosConfig:this.config,...e})}};async function Zs(r){let{aptosConfig:e,accountAddress:t,amount:n,options:i}=r,o=_optionalChain([i, 'optionalAccess', _178 => _178.timeoutSecs])||20,{data:s}=await po({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:n},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await qt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _179 => _179.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Sr=class{constructor(e){this.config=e}async fundAccount(e){let t=await Zs({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.waitForIndexer])===void 0||_optionalChain([e, 'access', _182 => _182.options, 'optionalAccess', _183 => _183.waitForIndexer]))&&await mn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function En(r){let{aptosConfig:e,options:t}=r,n={query:Ko,variables:{where_condition:_optionalChain([t, 'optionalAccess', _184 => _184.where]),limit:_optionalChain([t, 'optionalAccess', _185 => _185.limit]),offset:_optionalChain([t, 'optionalAccess', _186 => _186.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ea(r){let{aptosConfig:e,options:t}=r,n={query:Uo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _187 => _187.where]),limit:_optionalChain([t, 'optionalAccess', _188 => _188.limit]),offset:_optionalChain([t, 'optionalAccess', _189 => _189.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ta(r){let{aptosConfig:e,options:t}=r,n={query:Io,variables:{where_condition:_optionalChain([t, 'optionalAccess', _190 => _190.where]),limit:_optionalChain([t, 'optionalAccess', _191 => _191.limit]),offset:_optionalChain([t, 'optionalAccess', _192 => _192.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var wu={typeParameters:[{constraints:[]}],parameters:[Le("0x1::object::Object"),new X,new W]};async function ra(r){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:n,recipient:i,amount:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,i,o],abi:wu},options:s})}var xr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),En({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await En({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await En({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _196 => _196.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ea({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _197 => _197.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ta({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ra({aptosConfig:this.config,...e})}};var Er=class{constructor(e){this.config=e}async getLedgerInfo(){return cn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return rs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ns({aptosConfig:this.config,...e})}async view(e){return fe({aptosConfig:this.config,...e})}async viewJson(e){return Ts({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return No({aptosConfig:this.config,...e})}async queryIndexer(e){return h({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return un({aptosConfig:this.config})}async getProcessorStatus(e){return pn({aptosConfig:this.config,processorType:e})}};var na=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function ia(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function rt(r){let[e,t,...n]=r.replace(/\.apt$/,"").split(".");if(n.length>0)throw new Error(`${r} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!ia(e))throw new Error(`${e} is not valid. ${na}`);if(t&&!ia(t))throw new Error(`${t} is not valid. ${na}`);return{domainName:t||e,subdomainName:t?e:void 0}}function oa(r){if(!r)return!1;let e=new Date(r.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(r.expiration_timestamp).getTime()<Date.now();return r.subdomain&&e?!1:r.subdomain&&r.subdomain_expiration_policy===1?!0:!t}var _u="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Su={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:_u,custom:null,devnet:null};function qe(r){let e=Su[r.network];if(!e)throw new Error(`The ANS contract is not deployed to ${r.network}`);return e}var Pn=r=>{if(r&&typeof r=="object"&&"vec"in r&&Array.isArray(r.vec))return r.vec[0]};async function sa(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=rt(t),s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Pn(s[0]);return a?u.from(a):void 0}async function aa(r){let{aptosConfig:e,expiration:t,name:n,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=r,p=qe(e),{domainName:d,subdomainName:A}=rt(n),w=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(A&&!w)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(w&&!A)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let Kn=_nullishCoalesce(t.years, () => (1));if(Kn!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Pa=Kn*31536e3;return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[d,Pa,o,s]},options:a})}if(!A)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await _i({aptosConfig:e,name:d});if(!y)throw new Error("The domain does not exist");let x=t.policy==="subdomain:independent"?t.expirationDate:y;if(x>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[d,A,Math.round(x/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function _i(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=rt(t);try{let s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function ca(r){let{aptosConfig:e,address:t}=r,n=qe(e),i=await fe({aptosConfig:e,payload:{function:`${n}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=Pn(i[1]),s=Pn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function ua(r){let{aptosConfig:e,sender:t,name:n,options:i}=r,o=qe(e);if(!n)return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=rt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function pa(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=rt(t),s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_target_addr`,functionArguments:[i,o]}}),a=Pn(s[0]);return a?u.from(a):void 0}async function da(r){let{aptosConfig:e,sender:t,name:n,address:i,options:o}=r,s=qe(e),{domainName:a,subdomainName:c}=rt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function la(r){let{aptosConfig:e,name:t}=r,{domainName:n,subdomainName:i=""}=rt(t),a=(await h({aptosConfig:e,query:{query:Vt,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Pr(a)),oa(a)?a:void 0}async function ga(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Si({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountNames",query:{query:Vt,variables:{limit:_optionalChain([t, 'optionalAccess', _198 => _198.limit]),offset:_optionalChain([t, 'optionalAccess', _199 => _199.offset]),order_by:_optionalChain([t, 'optionalAccess', _200 => _200.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Pr)}async function ya(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Si({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Vt,variables:{limit:_optionalChain([t, 'optionalAccess', _203 => _203.limit]),offset:_optionalChain([t, 'optionalAccess', _204 => _204.offset]),order_by:_optionalChain([t, 'optionalAccess', _205 => _205.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _206 => _206.options, 'optionalAccess', _207 => _207.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Pr)}async function ma(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Si({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Vt,variables:{limit:_optionalChain([t, 'optionalAccess', _208 => _208.limit]),offset:_optionalChain([t, 'optionalAccess', _209 => _209.offset]),order_by:_optionalChain([t, 'optionalAccess', _210 => _210.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _211 => _211.options, 'optionalAccess', _212 => _212.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Pr)}async function fa(r){let{aptosConfig:e,options:t,domain:n}=r;return(await h({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Vt,variables:{limit:_optionalChain([t, 'optionalAccess', _213 => _213.limit]),offset:_optionalChain([t, 'optionalAccess', _214 => _214.offset]),order_by:_optionalChain([t, 'optionalAccess', _215 => _215.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _216 => _216.options, 'optionalAccess', _217 => _217.where]), () => ({})),domain:{_eq:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(Pr).filter(oa)}async function Si(r){let{aptosConfig:e}=r,t=qe(e),[n]=await fe({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=n/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Aa(r){let{aptosConfig:e,sender:t,name:n,years:i=1,options:o}=r,s=qe(e),a=i*31536e3,{domainName:c,subdomainName:p}=rt(n);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Pr(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).getTime()}}var vr=class{constructor(e){this.config=e}async getOwnerAddress(e){return sa({aptosConfig:this.config,...e})}async getExpiration(e){return _i({aptosConfig:this.config,...e})}async getTargetAddress(e){return pa({aptosConfig:this.config,...e})}async setTargetAddress(e){return da({aptosConfig:this.config,...e})}async getPrimaryName(e){return ca({aptosConfig:this.config,...e})}async setPrimaryName(e){return ua({aptosConfig:this.config,...e})}async registerName(e){return aa({aptosConfig:this.config,...e})}async renewDomain(e){return Aa({aptosConfig:this.config,...e})}async getName(e){return la({aptosConfig:this.config,...e})}async getAccountNames(e){return ga({aptosConfig:this.config,...e})}async getAccountDomains(e){return ya({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return ma({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return fa({aptosConfig:this.config,...e})}};async function ha(r){let{aptosConfig:e,poolAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:ri,variables:{where_condition:{pool_address:{_eq:n}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ta(r){let{aptosConfig:e,options:t}=r,n={query:ri,variables:{order_by:_optionalChain([t, 'optionalAccess', _218 => _218.orderBy])}};return(await h({aptosConfig:e,query:n})).num_active_delegator_per_pool}async function ba(r){let{aptosConfig:e,delegatorAddress:t,poolAddress:n}=r,i={query:Co,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(n).toStringLong()}};return(await h({aptosConfig:e,query:i})).delegated_staking_activities}var Ir=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),ha({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _220 => _220.minimumLedgerVersion]),processorType:"stake_processor"}),Ta({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _221 => _221.minimumLedgerVersion]),processorType:"stake_processor"}),ba({aptosConfig:this.config,...e})}};var vn=class{constructor(e){this.config=e}async simple(e){return _({aptosConfig:this.config,...e})}async multiAgent(e){return _({aptosConfig:this.config,...e})}};function xi(r,e,t){let n=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return n.apply(this,i)},t}function Ei(r,e,t){let n=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return n.apply(this,i)},t}var Wt=class{constructor(e){this.config=e}async simple(e){return bi({aptosConfig:this.config,...e})}async multiAgent(e){return bi({aptosConfig:this.config,...e})}};_chunkF43XVDYJjs.a.call(void 0, [Ei],Wt.prototype,"simple",1),_chunkF43XVDYJjs.a.call(void 0, [Ei],Wt.prototype,"multiAgent",1);var Qt=class{constructor(e){this.config=e}async simple(e){return Ar({aptosConfig:this.config,...e})}async multiAgent(e){return Ar({aptosConfig:this.config,...e})}};_chunkF43XVDYJjs.a.call(void 0, [xi],Qt.prototype,"simple",1),_chunkF43XVDYJjs.a.call(void 0, [xi],Qt.prototype,"multiAgent",1);var In=class{constructor(e,t,n,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=n,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkF43XVDYJjs.d.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime),_chunkF43XVDYJjs.d.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkF43XVDYJjs.d.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkF43XVDYJjs.d.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var jt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _222 => _222.pendingDequeue, 'access', _223 => _223.shift, 'call', _224 => _224(), 'optionalAccess', _225 => _225.resolve, 'call', _226 => _226(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new Jt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Jt=class extends Error{};var wa="fulfilled",_a= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(_a||{}),Cn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,n,i=30,o=100,s=10){super();this.taskQueue=new jt;this.transactionsQueue=new jt;this.outstandingTransactions=new jt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=n,this.started=!1,this.accountSequnceNumber=new In(t,n,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let n=await this.generateNextTransaction(this.account,t);if(!n)return;let i=hr({aptosConfig:this.aptosConfig,transaction:n,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Jt)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],n=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),n.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),n.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<n.length;a+=1){let c=s[a];o=n[a],c.status===wa?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Jt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,n){try{let i=[];i.push(qt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===wa?(this.executedTransactions.push([a.value.hash,n,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,n,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,n){this.transactionsQueue.enqueue([t,n])}async generateNextTransaction(t,n){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return _({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:n}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Rn=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Cn(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:n}=e;for(let i of t)this.transactionWorker.push(i,n)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.start({sender:t}),this.push({data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Cr=class{constructor(e){this.config=e,this.build=new vn(this.config),this.simulate=new Wt(this.config),this.submit=new Qt(this.config),this.batch=new Rn(this.config)}async getTransactions(e){return ai({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return es({aptosConfig:this.config,...e})}async getTransactionByHash(e){return gr({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ts({aptosConfig:this.config,...e})}async waitForTransaction(e){return qt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return yn({aptosConfig:this.config})}getSigningMessage(e){return bs(e)}async publishPackageTransaction(e){return _s({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Ss({aptosConfig:this.config,...e})}sign(e){return Sn({...e})}signAsFeePayer(e){return xn({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.batch.forSingleAccount({sender:t,data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return hr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ws({aptosConfig:this.config,...e})}};var Rr=class{constructor(e){this.config=e}async getTableItem(e){return dn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Fo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Go({aptosConfig:this.config,...e})}};async function Un(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,uidKey:i="sub",derivationPath:o}=r,s={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,epk_blinder:g.fromHexInput(n.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await lo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function Pi(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,pepper:i=await Un(r),uidKey:o="sub",maxExpHorizonSecs:s=(await ir({aptosConfig:e})).maxExpHorizonSecs}=r;if(g.fromHexInput(i).toUint8Array().length!==Mt.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Mt.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<n.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(n.blinder).toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,exp_horizon_secs:s,pepper:g.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await go({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),d=p.proof,A=new Ut({a:d.a,b:d.b,c:d.c});return new Oe({proof:new Kt(A,0),trainingWheelsSignature:xe.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function Sa(r){let{aptosConfig:e,jwt:t,jwkAddress:n,uidKey:i,proofFetchCallback:o,pepper:s=await Un(r)}=r,{verificationKey:a,maxExpHorizonSecs:c}=await ir({aptosConfig:e}),p=Pi({...r,pepper:s,maxExpHorizonSecs:c}),d=o?p:await p;if(n!==void 0){let y=Z.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:n,uidKey:i}),x=await Lt({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return on.create({...r,address:x,proof:d,pepper:s,proofFetchCallback:o,jwkAddress:n,verificationKey:a})}let A=D.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),w=await Lt({aptosConfig:e,authenticationKey:A.authKey().derivedAddress()});return Mt.create({...r,address:w,proof:d,pepper:s,proofFetchCallback:o,verificationKey:a})}async function xa(r){let{aptosConfig:e,sender:t,iss:n,options:i}=r,{jwksUrl:o}=r;o===void 0&&(so.test(n)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=n.endsWith("/")?`${n}.well-known/jwks.json`:`${n}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,K.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[n,b.MoveString(a.keys.map(c=>c.kid)),b.MoveString(a.keys.map(c=>c.alg)),b.MoveString(a.keys.map(c=>c.e)),b.MoveString(a.keys.map(c=>c.n))]},options:i})}var Ur=class{constructor(e){this.config=e}async getPepper(e){return Un({aptosConfig:this.config,...e})}async getProof(e){return Pi({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Sa({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return xa({aptosConfig:this.config,...e})}};async function vu(r){let{aptosConfig:e,options:t}=r,n={query:an,variables:{where_condition:_optionalChain([t, 'optionalAccess', _227 => _227.where]),offset:_optionalChain([t, 'optionalAccess', _228 => _228.offset]),limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),order_by:_optionalChain([t, 'optionalAccess', _230 => _230.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getObjectData"})).current_objects}async function Ea(r){let{aptosConfig:e,objectAddress:t,options:n}=r,o={object_address:{_eq:u.from(t).toStringLong()}};return(await vu({aptosConfig:e,options:{...n,where:o}}))[0]}var Kr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ea({aptosConfig:this.config,...e})}};var te=class{constructor(e){this.config=new _n(e),this.account=new fr(this.config),this.ans=new vr(this.config),this.coin=new Tr(this.config),this.digitalAsset=new br(this.config),this.event=new _r(this.config),this.faucet=new Sr(this.config),this.fungibleAsset=new xr(this.config),this.general=new Er(this.config),this.staking=new Ir(this.config),this.transaction=new Cr(this.config),this.table=new Rr(this.config),this.keyless=new Ur(this.config),this.object=new Kr(this.config)}};function pe(r,e,t){Object.getOwnPropertyNames(e.prototype).forEach(n=>{let i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&(i.value=function(...o){return this[t][n](...o)},Object.defineProperty(r.prototype,n,i))})}pe(te,fr,"account");pe(te,vr,"ans");pe(te,Tr,"coin");pe(te,br,"digitalAsset");pe(te,_r,"event");pe(te,Sr,"faucet");pe(te,xr,"fungibleAsset");pe(te,Er,"general");pe(te,Ir,"staking");pe(te,Cr,"transaction");pe(te,Rr,"table");pe(te,Ur,"keyless");pe(te,Kr,"object");exports.APTOS_BIP44_REGEX = Ga; exports.APTOS_COIN = lt; exports.APTOS_FA = io; exports.APTOS_HARDENED_REGEX = Fa; exports.AbstractKeylessAccount = ue; exports.Account = Ze; exports.AccountAddress = u; exports.AccountAuthenticator = ee; exports.AccountAuthenticatorEd25519 = _e; exports.AccountAuthenticatorMultiEd25519 = jr; exports.AccountAuthenticatorMultiKey = ve; exports.AccountAuthenticatorSingleKey = ie; exports.AccountAuthenticatorVariant = zi; exports.AccountPublicKey = ne; exports.AccountSequenceNumber = In; exports.AddressInvalidReason = Da; exports.AnyPublicKey = F; exports.AnyPublicKeyVariant = Br; exports.AnySignature = L; exports.AnySignatureVariant = Ni; exports.Aptos = te; exports.AptosApiError = ye; exports.AptosApiType = It; exports.AptosConfig = _n; exports.AuthenticationKey = B; exports.Bool = U; exports.CKDPriv = $i; exports.ChainId = Dt; exports.DEFAULT_MAX_GAS_AMOUNT = ro; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = no; exports.DEFAULT_TXN_TIMEOUT_SEC = $r; exports.DeriveScheme = Bi; exports.Deserializer = N; exports.EPK_HORIZON_SECS = Tg; exports.Ed25519Account = Nt; exports.Ed25519PrivateKey = Y; exports.Ed25519PublicKey = P; exports.Ed25519Signature = I; exports.EntryFunction = ft; exports.EntryFunctionBytes = Nr; exports.EphemeralCertificate = Rt; exports.EphemeralCertificateVariant = On; exports.EphemeralKeyPair = lr; exports.EphemeralPublicKey = dt; exports.EphemeralPublicKeyVariant = Dn; exports.EphemeralSignature = xe; exports.EphemeralSignatureVariant = Fi; exports.FIREBASE_AUTH_ISS_PATTERN = so; exports.FederatedKeylessAccount = on; exports.FederatedKeylessPublicKey = Z; exports.FeePayerRawTransaction = ht; exports.FixedBytes = st; exports.Groth16VerificationKey = Yn; exports.Groth16Zkp = Ut; exports.HARDENED_OFFSET = Li; exports.Hex = g; exports.HexInvalidReason = Ca; exports.Identifier = R; exports.KeyType = Ba; exports.KeylessAccount = Mt; exports.KeylessConfiguration = Xn; exports.KeylessError = K; exports.KeylessErrorCategory = lc; exports.KeylessErrorResolutionTip = gc; exports.KeylessErrorType = Wr; exports.KeylessPublicKey = D; exports.KeylessSignature = De; exports.MAX_AUD_VAL_BYTES = hc; exports.MAX_COMMITED_EPK_BYTES = Sg; exports.MAX_EXTRA_FIELD_BYTES = wg; exports.MAX_ISS_VAL_BYTES = bg; exports.MAX_JWT_HEADER_B64_BYTES = _g; exports.MAX_UID_KEY_BYTES = Tc; exports.MAX_UID_VAL_BYTES = bc; exports.MimeType = Fr; exports.ModuleId = or; exports.MoveAbility = Gi; exports.MoveFunctionVisibility = Ua; exports.MoveJWK = Zn; exports.MoveOption = J; exports.MoveString = S; exports.MoveVector = b; exports.MultiAgentRawTransaction = At; exports.MultiAgentTransaction = rn; exports.MultiEd25519PublicKey = Pt; exports.MultiEd25519Signature = ct; exports.MultiKey = Ye; exports.MultiKeyAccount = ho; exports.MultiKeySignature = ze; exports.MultiSig = pr; exports.MultiSigTransactionPayload = dr; exports.Network = Hn; exports.NetworkToChainId = $n; exports.NetworkToFaucetAPI = to; exports.NetworkToIndexerAPI = Zi; exports.NetworkToNetworkName = gl; exports.NetworkToNodeAPI = eo; exports.NetworkToPepperAPI = Ln; exports.NetworkToProverAPI = qn; exports.ParsingError = Q; exports.PrivateKey = Qe; exports.PrivateKeyVariants = Gr; exports.ProcessorType = Ke; exports.PublicKey = at; exports.RAW_TRANSACTION_SALT = oo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Wn; exports.RawTransaction = me; exports.RawTransactionWithData = Yr; exports.RoleType = Ka; exports.RotationProofChallenge = Zr; exports.Script = ur; exports.ScriptTransactionArgumentVariants = Yt; exports.Secp256k1PrivateKey = ut; exports.Secp256k1PublicKey = Ue; exports.Secp256k1Signature = pt; exports.Serializable = l; exports.Serialized = Zt; exports.Serializer = H; exports.Signature = M; exports.SignedTransaction = Ve; exports.SigningScheme = he; exports.SigningSchemeInput = Fn; exports.SimpleTransaction = tn; exports.SingleKeyAccount = Ft; exports.StructTag = Ie; exports.TransactionAndProof = ti; exports.TransactionAuthenticator = Me; exports.TransactionAuthenticatorEd25519 = Tt; exports.TransactionAuthenticatorFeePayer = wt; exports.TransactionAuthenticatorMultiAgent = bt; exports.TransactionAuthenticatorMultiEd25519 = en; exports.TransactionAuthenticatorSingleSender = _t; exports.TransactionAuthenticatorVariant = Oi; exports.TransactionPayload = mt; exports.TransactionPayloadEntryFunction = ar; exports.TransactionPayloadMultiSig = cr; exports.TransactionPayloadScript = sr; exports.TransactionPayloadVariants = ki; exports.TransactionResponseType = Nn; exports.TransactionVariants = Di; exports.TransactionWorker = Cn; exports.TransactionWorkerEventsEnum = _a; exports.TypeTag = O; exports.TypeTagAddress = X; exports.TypeTagBool = G; exports.TypeTagGeneric = z; exports.TypeTagParserError = q; exports.TypeTagParserErrorType = Vc; exports.TypeTagReference = Xr; exports.TypeTagSigner = yt; exports.TypeTagStruct = f; exports.TypeTagU128 = Ge; exports.TypeTagU16 = Ne; exports.TypeTagU256 = Be; exports.TypeTagU32 = Fe; exports.TypeTagU64 = W; exports.TypeTagU8 = ae; exports.TypeTagVariants = Ki; exports.TypeTagVector = C; exports.U128 = we; exports.U16 = Te; exports.U256 = de; exports.U32 = be; exports.U64 = $; exports.U8 = j; exports.ZeroKnowledgeSig = Oe; exports.ZkProof = Kt; exports.ZkpVariant = zn; exports.aptosCoinStructTag = im; exports.aptosRequest = Qr; exports.base64UrlDecode = _chunkF43XVDYJjs.f; exports.bigIntToBytesLE = Xi; exports.buildTransaction = hi; exports.bytesToBigIntLE = tr; exports.checkOrConvertArgument = Ht; exports.convertAmountFromHumanReadableToOnChain = _chunkF43XVDYJjs.g; exports.convertAmountFromOnChainToHumanReadable = _chunkF43XVDYJjs.h; exports.convertArgument = Ai; exports.convertNumber = fn; exports.createObjectAddress = Jr; exports.createResourceAddress = Dy; exports.createTokenAddress = Oy; exports.deriveKey = Gn; exports.deriveTransactionType = ei; exports.deserializeFromScriptArgument = Ec; exports.ensureBoolean = kn; exports.fetchEntryFunctionAbi = gs; exports.fetchFunctionAbi = ls; exports.fetchViewFunctionAbi = ys; exports.findFirstNonSignerArg = us; exports.floorToWholeHour = _chunkF43XVDYJjs.e; exports.generateRawTransaction = jc; exports.generateSignedTransaction = Ti; exports.generateSignedTransactionForSimulation = fs; exports.generateSigningMessage = Ot; exports.generateSigningMessageForSerializable = Af; exports.generateSigningMessageForTransaction = zt; exports.generateTransactionPayload = wn; exports.generateTransactionPayloadWithABI = $c; exports.generateUserTransactionHash = DT; exports.generateViewFunctionPayload = ms; exports.generateViewFunctionPayloadWithABI = Wc; exports.get = jn; exports.getAptosFullNode = V; exports.getAptosPepperService = Bl; exports.getAuthenticatorForSimulation = bn; exports.getErrorMessage = _chunkF43XVDYJjs.c; exports.getFunctionParts = yr; exports.getIssAudAndUidVal = kt; exports.getKeylessConfig = ir; exports.getKeylessJWKs = fo; exports.hashStrToField = qr; exports.hashValues = As; exports.hexToAsciiString = Ui; exports.isBcsAddress = hn; exports.isBcsBool = ci; exports.isBcsFixedBytes = Nc; exports.isBcsString = ui; exports.isBcsU128 = yi; exports.isBcsU16 = di; exports.isBcsU256 = mi; exports.isBcsU32 = li; exports.isBcsU64 = gi; exports.isBcsU8 = pi; exports.isBlockEpilogueTransactionResponse = ip; exports.isBlockMetadataTransactionResponse = tp; exports.isBool = os; exports.isCanonicalEd25519Signature = Va; exports.isEd25519Signature = op; exports.isEmptyOption = ss; exports.isEncodedEntryFunctionArgument = as; exports.isEncodedStruct = _chunkF43XVDYJjs.j; exports.isFeePayerSignature = cp; exports.isGenesisTransactionResponse = ep; exports.isKeylessSigner = nn; exports.isLargeNumber = An; exports.isMultiAgentSignature = ap; exports.isMultiEd25519Signature = up; exports.isNumber = zc; exports.isPendingTransactionResponse = Yu; exports.isScriptDataInput = cs; exports.isSecp256k1Signature = sp; exports.isStateCheckpointTransactionResponse = rp; exports.isString = et; exports.isUserTransactionResponse = Zu; exports.isValidBIP44Path = qi; exports.isValidHardenedPath = Hi; exports.isValidatorTransactionResponse = np; exports.mnemonicToSeed = Mr; exports.normalizeBundle = ao; exports.nowInSeconds = _chunkF43XVDYJjs.d; exports.objectStructTag = ce; exports.optionStructTag = om; exports.outOfRangeErrorMessage = Ra; exports.padAndPackBytesWithLen = Vn; exports.paginateWithCursor = Ct; exports.parseEncodedStruct = _chunkF43XVDYJjs.i; exports.parseJwtHeader = Sc; exports.parseTypeTag = Le; exports.poseidonHash = rr; exports.post = nr; exports.postAptosFaucet = po; exports.postAptosFullNode = Xe; exports.postAptosIndexer = uo; exports.postAptosPepperService = lo; exports.postAptosProvingService = go; exports.promiseFulfilledStatus = wa; exports.request = fc; exports.sleep = _chunkF43XVDYJjs.b; exports.splitPath = Wi; exports.standardizeTypeTags = Tn; exports.stringStructTag = v; exports.throwTypeMismatch = k; exports.validateNumberInRange = $e;
481
+ will be removed in the near future`);let s=n;n===void 0&&i!==void 0&&(s=await Ee(async()=>{try{let p=(await fe({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunkF43XVDYJjs.j.call(void 0, p.vec[0]))return _chunkF43XVDYJjs.i.call(void 0, p.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(n!==void 0&&i!==void 0)a=u.from(i).toStringLong();else if(n!==void 0&&i===void 0)n===yt?a=u.A.toStringLong():a=en(u.A,n).toStringLong();else if(n===void 0&&i!==void 0){let p=u.from(i);a=p.toStringLong(),p===u.A&&(s=yt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await fe({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await fe({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ns({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return is({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var En=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _124 => _124.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _125 => _125.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _126 => _126.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _127 => _127.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _128 => _128.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _129 => _129.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _130 => _130.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _131 => _131.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _132 => _132.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _133 => _133.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _134 => _134.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 oo[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return so[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 io[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 Wn[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 Qn[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Wn[this.network]===e}isProverServiceRequest(e){return Qn[this.network]===e}};async function _(r){let e=await su(r);return au(r,e)}async function su(r){let{aptosConfig:e,data:t}=r,n,i;return"bytecode"in t?i=await Sn(t):"multisigAddress"in t?(n={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Sn(n)):(n={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Sn(n)),i}async function au(r,e){let{aptosConfig:t,sender:n,options:i}=r,o;if(cu(r)&&(o=u.ZERO.toString()),uu(r)){let{secondarySignerAddresses:s}=r;return Si({aptosConfig:t,sender:n,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Si({aptosConfig:t,sender:n,payload:e,options:i,feePayerAddress:o})}function cu(r){return r.withFeePayer===!0}function uu(r){return"secondarySignerAddresses"in r}function Ps(r){let{transaction:e}=r;return Bt(e)}function Pn(r){let{signer:e,transaction:t}=r;return e.signTransactionWithAuthenticator(t)}function vn(r){let{signer:e,transaction:t}=r;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Pn({signer:e,transaction:t})}async function Ei(r){let{aptosConfig:e,transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=r,a=_s({transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Xe({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([r, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _139 => _139.options, 'optionalAccess', _140 => _140.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function wr(r){let{aptosConfig:e}=r,t=xi({...r});try{let{data:n}=await Xe({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}catch(n){let i=Le.deserialize(new D(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof O||i.authenticator.sender.public_key.publicKey instanceof ee)&&await ue.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),n}}async function _r(r){let{aptosConfig:e,signer:t,feePayer:n,transaction:i}=r;an(t)&&await t.checkKeylessAccountValidity(e),an(n)&&await n.checkKeylessAccountValidity(e);let o=r.feePayerAuthenticator||n&&vn({signer:n,transaction:i}),s=Pn({signer:t,transaction:i});return wr({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function vs(r){let{aptosConfig:e,senderAuthenticator:t,feePayer:n,transaction:i}=r;an(n)&&await n.checkKeylessAccountValidity(e);let o=vn({signer:n,transaction:i});return wr({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var pu={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Is(r){let{aptosConfig:e,account:t,metadataBytes:n,moduleBytecode:i,options:o}=r,s=i.map(a=>b.U8(a));return _({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[b.U8(n),new b(s)],abi:pu},options:o})}var du={typeParameters:[],parameters:[new ae,C.u8(),new ae,C.u8(),C.u8(),C.u8()]};async function Cs(r){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:n}=r,i=await Ce({aptosConfig:e,accountAddress:t.accountAddress}),o=et.fromPrivateKey({privateKey:n,legacy:!0}),a=new nn({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),p=o.sign(a),d=await _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new j(t.signingScheme),b.U8(t.publicKey.toUint8Array()),new j(o.signingScheme),b.U8(o.publicKey.toUint8Array()),b.U8(c.toUint8Array()),b.U8(p.toUint8Array())],abi:du}});return _r({aptosConfig:e,signer:t,transaction:d})}var lu={typeParameters:[{constraints:[]}],parameters:[new Y,new W]};async function Rs(r){let{aptosConfig:e,sender:t,recipient:n,amount:i,coinType:o,options:s}=r;return _({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (yt))],functionArguments:[n,i],abi:lu},options:s})}var Sr=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Rs({aptosConfig:this.config,...e})}};var rt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Ae="0x4::token::Token";async function Us(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()}};return(await h({aptosConfig:e,query:{query:Mo,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ks(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await h({aptosConfig:e,query:{query:ci,variables:{where_condition:n}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ks(r){let{aptosConfig:e,ownerAddress:t,options:n}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:ci,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([n, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([n, 'optionalAccess', _143 => _143.orderBy])}};return(await h({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ds(r){let{aptosConfig:e,digitalAssetAddress:t,options:n}=r,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:Bo,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([n, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([n, 'optionalAccess', _146 => _146.orderBy])}};return(await h({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var gu={typeParameters:[],parameters:[new f(v()),new W,new f(v()),new f(v()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new W,new W]};async function Os(r){let{aptosConfig:e,options:t,creator:n}=r;return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new S(r.description),new $(_nullishCoalesce(r.maxSupply, () => (ot))),new S(r.name),new S(r.uri),new U(_nullishCoalesce(r.mutableDescription, () => (!0))),new U(_nullishCoalesce(r.mutableRoyalty, () => (!0))),new U(_nullishCoalesce(r.mutableURI, () => (!0))),new U(_nullishCoalesce(r.mutableTokenDescription, () => (!0))),new U(_nullishCoalesce(r.mutableTokenName, () => (!0))),new U(_nullishCoalesce(r.mutableTokenProperties, () => (!0))),new U(_nullishCoalesce(r.mutableTokenURI, () => (!0))),new U(_nullishCoalesce(r.tokensBurnableByCreator, () => (!0))),new U(_nullishCoalesce(r.tokensFreezableByCreator, () => (!0))),new $(_nullishCoalesce(r.royaltyNumerator, () => (0))),new $(_nullishCoalesce(r.royaltyDenominator, () => (1)))],abi:gu},options:t})}async function Yt(r){let{aptosConfig:e,options:t}=r,n=_optionalChain([t, 'optionalAccess', _147 => _147.where]);_optionalChain([t, 'optionalAccess', _148 => _148.tokenStandard])&&(n.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.tokenStandard]), () => ("v2"))});let i={query:Ko,variables:{where_condition:n,offset:_optionalChain([t, 'optionalAccess', _150 => _150.offset]),limit:_optionalChain([t, 'optionalAccess', _151 => _151.limit])}};return(await h({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function zs(r){let{aptosConfig:e,creatorAddress:t,collectionName:n,options:i}=r,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _152 => _152.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),Yt({aptosConfig:e,options:{...i,where:s}})}async function Ns(r){let{aptosConfig:e,creatorAddress:t,options:n}=r,o={creator_address:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _154 => _154.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),Yt({aptosConfig:e,options:{...n,where:o}})}async function Fs(r){let{aptosConfig:e,collectionId:t,options:n}=r,o={collection_id:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _156 => _156.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _157 => _157.tokenStandard]), () => ("v2"))}),Yt({aptosConfig:e,options:{...n,where:o}})}async function Gs(r){let{creatorAddress:e,collectionName:t,options:n,aptosConfig:i}=r,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([n, 'optionalAccess', _158 => _158.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _159 => _159.tokenStandard]), () => ("v2"))}),(await Yt({aptosConfig:i,options:{where:s}})).collection_id}var yu={typeParameters:[],parameters:[new f(v()),new f(v()),new f(v()),new f(v()),new C(new f(v())),new C(new f(v())),new C(C.u8())]};async function Bs(r){let{aptosConfig:e,options:t,creator:n,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:d}=r,A=_optionalChain([p, 'optionalAccess', _160 => _160.map, 'call', _161 => _161(w=>rt[w])]);return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new S(i),new S(o),new S(s),new S(a),b.MoveString(_nullishCoalesce(c, () => ([]))),b.MoveString(_nullishCoalesce(A, () => ([]))),ea(_nullishCoalesce(d, () => ([])),_nullishCoalesce(A, () => ([])))],abi:yu},options:t})}var mu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new Y]};async function Ms(r){let{aptosConfig:e,sender:t,digitalAssetAddress:n,recipient:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(n),u.from(i)],abi:mu},options:s})}var fu={typeParameters:[],parameters:[new f(v()),new f(v()),new f(v()),new f(v()),new C(new f(v())),new C(new f(v())),new C(C.u8()),new Y]};async function Vs(r){let{aptosConfig:e,account:t,collection:n,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:d,options:A}=r;if(_optionalChain([c, 'optionalAccess', _162 => _162.length])!==_optionalChain([d, 'optionalAccess', _163 => _163.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _164 => _164.length])!==_optionalChain([d, 'optionalAccess', _165 => _165.length]))throw new Error("Property types and property values counts do not match");let w=_optionalChain([p, 'optionalAccess', _166 => _166.map, 'call', _167 => _167(y=>rt[y])]);return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,i,o,s,b.MoveString(_nullishCoalesce(c, () => ([]))),b.MoveString(_nullishCoalesce(w, () => ([]))),ea(_nullishCoalesce(d, () => ([])),_nullishCoalesce(w, () => ([]))),a],abi:fu},options:A})}var Au={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0)))]};async function Ls(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[u.from(n)],abi:Au},options:o})}var hu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0)))]};async function qs(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[n],abi:hu},options:o})}var Tu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0)))]};async function Hs(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ae))],functionArguments:[n],abi:Tu},options:o})}var bu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v())]};async function $s(r){let{aptosConfig:e,creator:t,description:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:bu},options:s})}var wu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v())]};async function Ws(r){let{aptosConfig:e,creator:t,name:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:wu},options:s})}var _u={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v())]};async function Qs(r){let{aptosConfig:e,creator:t,uri:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:_u},options:s})}var Su={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v()),new f(v()),C.u8()]};async function js(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Ae))],functionArguments:[u.from(s),new S(n),new S(rt[i]),b.U8(Pi(o,rt[i]))],abi:Su},options:c})}var xu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v())]};async function Js(r){let{aptosConfig:e,creator:t,propertyKey:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Ae))],functionArguments:[u.from(i),new S(n)],abi:xu},options:s})}var Eu={typeParameters:[{constraints:["key"]}],parameters:[new f(ce(new N(0))),new f(v()),new f(v()),C.u8()]};async function Xs(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Ae))],functionArguments:[u.from(s),new S(n),new S(rt[i]),Pi(o,rt[i])],abi:Eu},options:c})}var Pu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ce(new N(0))),new f(v()),new N(1)]};async function Ys(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ae)),rt[i]],functionArguments:[u.from(s),new S(n),o],abi:Pu},options:c})}var vu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ce(new N(0))),new f(v()),new N(1)]};async function Zs(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ae)),rt[i]],functionArguments:[u.from(s),new S(n),o],abi:vu},options:c})}function ea(r,e){let t=new Array;return e.forEach((n,i)=>{t.push(Pi(r[i],n))}),t}function Pi(r,e){let t=Re(e);return jt(r,t,0,[]).bcsToBytes()}var xr=class{constructor(e){this.config=e}async getCollectionData(e){await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:n,options:i}=e,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _168 => _168.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _169 => _169.tokenStandard]), () => ("v2"))}),Yt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),zs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ns({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Fs({aptosConfig:this.config,...e})}async getCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Gs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Us({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ks({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ks({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ds({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Os({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Bs({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Ms({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Vs({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Ls({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return qs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Hs({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return $s({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Ws({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Qs({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return js({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return Js({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Xs({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ys({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Zs({aptosConfig:this.config,...e})}};var ta=300,Iu=r=>{if(r&&r.length>ta)throw new Error(`Event type length exceeds the maximum length of ${ta}`)};async function ra(r){let{aptosConfig:e,eventType:t,options:n}=r,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Er({aptosConfig:e,options:{...n,where:i}})}async function na(r){let{accountAddress:e,aptosConfig:t,creationNumber:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:n}};return Er({aptosConfig:t,options:{...i,where:s}})}async function ia(r){let{accountAddress:e,aptosConfig:t,eventType:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:n}};return Er({aptosConfig:t,options:{...i,where:s}})}async function Er(r){let{aptosConfig:e,options:t}=r;Iu(_optionalChain([t, 'optionalAccess', _170 => _170.where, 'optionalAccess', _171 => _171.indexed_type, 'optionalAccess', _172 => _172._eq]));let n={query:Oo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _173 => _173.where]),offset:_optionalChain([t, 'optionalAccess', _174 => _174.offset]),limit:_optionalChain([t, 'optionalAccess', _175 => _175.limit]),order_by:_optionalChain([t, 'optionalAccess', _176 => _176.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getEvents"})).events}var Pr=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ra({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),na({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ia({aptosConfig:this.config,...e})}async getEvents(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _177 => _177.minimumLedgerVersion]),processorType:"events_processor"}),Er({aptosConfig:this.config,...e})}};async function oa(r){let{aptosConfig:e,accountAddress:t,amount:n,options:i}=r,o=_optionalChain([i, 'optionalAccess', _178 => _178.timeoutSecs])||20,{data:s}=await fo({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:n},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Qt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _179 => _179.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var vr=class{constructor(e){this.config=e}async fundAccount(e){let t=await oa({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.waitForIndexer])===void 0||_optionalChain([e, 'access', _182 => _182.options, 'optionalAccess', _183 => _183.waitForIndexer]))&&await hn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function In(r){let{aptosConfig:e,options:t}=r,n={query:No,variables:{where_condition:_optionalChain([t, 'optionalAccess', _184 => _184.where]),limit:_optionalChain([t, 'optionalAccess', _185 => _185.limit]),offset:_optionalChain([t, 'optionalAccess', _186 => _186.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function sa(r){let{aptosConfig:e,options:t}=r,n={query:zo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _187 => _187.where]),limit:_optionalChain([t, 'optionalAccess', _188 => _188.limit]),offset:_optionalChain([t, 'optionalAccess', _189 => _189.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function aa(r){let{aptosConfig:e,options:t}=r,n={query:ko,variables:{where_condition:_optionalChain([t, 'optionalAccess', _190 => _190.where]),limit:_optionalChain([t, 'optionalAccess', _191 => _191.limit]),offset:_optionalChain([t, 'optionalAccess', _192 => _192.offset])}};return(await h({aptosConfig:e,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Cu={typeParameters:[{constraints:[]}],parameters:[Re("0x1::object::Object"),new Y,new W]};async function ca(r){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:n,recipient:i,amount:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,i,o],abi:Cu},options:s})}var Ir=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),In({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await In({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await In({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _196 => _196.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),sa({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _197 => _197.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),aa({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ca({aptosConfig:this.config,...e})}};var Cr=class{constructor(e){this.config=e}async getLedgerInfo(){return dn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return as({aptosConfig:this.config,...e})}async getBlockByHeight(e){return cs({aptosConfig:this.config,...e})}async view(e){return fe({aptosConfig:this.config,...e})}async viewJson(e){return Es({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Vo({aptosConfig:this.config,...e})}async queryIndexer(e){return h({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return ln({aptosConfig:this.config})}async getProcessorStatus(e){return gn({aptosConfig:this.config,processorType:e})}};var ua=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function pa(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function nt(r){let[e,t,...n]=r.replace(/\.apt$/,"").split(".");if(n.length>0)throw new Error(`${r} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!pa(e))throw new Error(`${e} is not valid. ${ua}`);if(t&&!pa(t))throw new Error(`${t} is not valid. ${ua}`);return{domainName:t||e,subdomainName:t?e:void 0}}function da(r){if(!r)return!1;let e=new Date(r.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(r.expiration_timestamp).getTime()<Date.now();return r.subdomain&&e?!1:r.subdomain&&r.subdomain_expiration_policy===1?!0:!t}var Ru="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Uu={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ru,custom:null,devnet:null};function qe(r){let e=Uu[r.network];if(!e)throw new Error(`The ANS contract is not deployed to ${r.network}`);return e}var Cn=r=>{if(r&&typeof r=="object"&&"vec"in r&&Array.isArray(r.vec))return r.vec[0]};async function la(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=nt(t),s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Cn(s[0]);return a?u.from(a):void 0}async function ga(r){let{aptosConfig:e,expiration:t,name:n,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=r,p=qe(e),{domainName:d,subdomainName:A}=nt(n),w=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(A&&!w)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(w&&!A)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let On=_nullishCoalesce(t.years, () => (1));if(On!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ka=On*31536e3;return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[d,Ka,o,s]},options:a})}if(!A)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await vi({aptosConfig:e,name:d});if(!y)throw new Error("The domain does not exist");let x=t.policy==="subdomain:independent"?t.expirationDate:y;if(x>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[d,A,Math.round(x/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function vi(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=nt(t);try{let s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function ya(r){let{aptosConfig:e,address:t}=r,n=qe(e),i=await fe({aptosConfig:e,payload:{function:`${n}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=Cn(i[1]),s=Cn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function ma(r){let{aptosConfig:e,sender:t,name:n,options:i}=r,o=qe(e);if(!n)return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=nt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function fa(r){let{aptosConfig:e,name:t}=r,n=qe(e),{domainName:i,subdomainName:o}=nt(t),s=await fe({aptosConfig:e,payload:{function:`${n}::router::get_target_addr`,functionArguments:[i,o]}}),a=Cn(s[0]);return a?u.from(a):void 0}async function Aa(r){let{aptosConfig:e,sender:t,name:n,address:i,options:o}=r,s=qe(e),{domainName:a,subdomainName:c}=nt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function ha(r){let{aptosConfig:e,name:t}=r,{domainName:n,subdomainName:i=""}=nt(t),a=(await h({aptosConfig:e,query:{query:$t,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Rr(a)),da(a)?a:void 0}async function Ta(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ii({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountNames",query:{query:$t,variables:{limit:_optionalChain([t, 'optionalAccess', _198 => _198.limit]),offset:_optionalChain([t, 'optionalAccess', _199 => _199.offset]),order_by:_optionalChain([t, 'optionalAccess', _200 => _200.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Rr)}async function ba(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ii({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountDomains",query:{query:$t,variables:{limit:_optionalChain([t, 'optionalAccess', _203 => _203.limit]),offset:_optionalChain([t, 'optionalAccess', _204 => _204.offset]),order_by:_optionalChain([t, 'optionalAccess', _205 => _205.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _206 => _206.options, 'optionalAccess', _207 => _207.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Rr)}async function wa(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ii({aptosConfig:e});return(await h({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:$t,variables:{limit:_optionalChain([t, 'optionalAccess', _208 => _208.limit]),offset:_optionalChain([t, 'optionalAccess', _209 => _209.offset]),order_by:_optionalChain([t, 'optionalAccess', _210 => _210.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _211 => _211.options, 'optionalAccess', _212 => _212.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Rr)}async function _a(r){let{aptosConfig:e,options:t,domain:n}=r;return(await h({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:$t,variables:{limit:_optionalChain([t, 'optionalAccess', _213 => _213.limit]),offset:_optionalChain([t, 'optionalAccess', _214 => _214.offset]),order_by:_optionalChain([t, 'optionalAccess', _215 => _215.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _216 => _216.options, 'optionalAccess', _217 => _217.where]), () => ({})),domain:{_eq:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(Rr).filter(da)}async function Ii(r){let{aptosConfig:e}=r,t=qe(e),[n]=await fe({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=n/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Sa(r){let{aptosConfig:e,sender:t,name:n,years:i=1,options:o}=r,s=qe(e),a=i*31536e3,{domainName:c,subdomainName:p}=nt(n);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Rr(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).getTime()}}var Ur=class{constructor(e){this.config=e}async getOwnerAddress(e){return la({aptosConfig:this.config,...e})}async getExpiration(e){return vi({aptosConfig:this.config,...e})}async getTargetAddress(e){return fa({aptosConfig:this.config,...e})}async setTargetAddress(e){return Aa({aptosConfig:this.config,...e})}async getPrimaryName(e){return ya({aptosConfig:this.config,...e})}async setPrimaryName(e){return ma({aptosConfig:this.config,...e})}async registerName(e){return ga({aptosConfig:this.config,...e})}async renewDomain(e){return Sa({aptosConfig:this.config,...e})}async getName(e){return ha({aptosConfig:this.config,...e})}async getAccountNames(e){return Ta({aptosConfig:this.config,...e})}async getAccountDomains(e){return ba({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return wa({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return _a({aptosConfig:this.config,...e})}};async function xa(r){let{aptosConfig:e,poolAddress:t}=r,n=u.from(t).toStringLong(),o=await h({aptosConfig:e,query:{query:si,variables:{where_condition:{pool_address:{_eq:n}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ea(r){let{aptosConfig:e,options:t}=r,n={query:si,variables:{order_by:_optionalChain([t, 'optionalAccess', _218 => _218.orderBy])}};return(await h({aptosConfig:e,query:n})).num_active_delegator_per_pool}async function Pa(r){let{aptosConfig:e,delegatorAddress:t,poolAddress:n}=r,i={query:Do,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(n).toStringLong()}};return(await h({aptosConfig:e,query:i})).delegated_staking_activities}var Kr=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),xa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _220 => _220.minimumLedgerVersion]),processorType:"stake_processor"}),Ea({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await T({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _221 => _221.minimumLedgerVersion]),processorType:"stake_processor"}),Pa({aptosConfig:this.config,...e})}};var Rn=class{constructor(e){this.config=e}async simple(e){return _({aptosConfig:this.config,...e})}async scriptComposer(e){let n=(await e.builder(new xn(this.config))).build(),i=await _i({aptosConfig:this.config,payload:ht.load(new D(n)),...e});return new Ft(i)}async multiAgent(e){return _({aptosConfig:this.config,...e})}};function Ci(r,e,t){let n=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return n.apply(this,i)},t}function Ri(r,e,t){let n=t.value;return t.value=async function(...i){return n.apply(this,i)},t}var Zt=class{constructor(e){this.config=e}async simple(e){return Ei({aptosConfig:this.config,...e})}async multiAgent(e){return Ei({aptosConfig:this.config,...e})}};_chunkF43XVDYJjs.a.call(void 0, [Ri],Zt.prototype,"simple",1),_chunkF43XVDYJjs.a.call(void 0, [Ri],Zt.prototype,"multiAgent",1);var er=class{constructor(e){this.config=e}async simple(e){return wr({aptosConfig:this.config,...e})}async multiAgent(e){return wr({aptosConfig:this.config,...e})}};_chunkF43XVDYJjs.a.call(void 0, [Ci],er.prototype,"simple",1),_chunkF43XVDYJjs.a.call(void 0, [Ci],er.prototype,"multiAgent",1);var Un=class{constructor(e,t,n,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=n,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkF43XVDYJjs.d.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime),_chunkF43XVDYJjs.d.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkF43XVDYJjs.d.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkF43XVDYJjs.d.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkF43XVDYJjs.b.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var tr=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _222 => _222.pendingDequeue, 'access', _223 => _223.shift, 'call', _224 => _224(), 'optionalAccess', _225 => _225.resolve, 'call', _226 => _226(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new rr("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},rr=class extends Error{};var va="fulfilled",Ia= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Ia||{}),Kn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,n,i=30,o=100,s=10){super();this.taskQueue=new tr;this.transactionsQueue=new tr;this.outstandingTransactions=new tr;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=n,this.started=!1,this.accountSequnceNumber=new Un(t,n,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let n=await this.generateNextTransaction(this.account,t);if(!n)return;let i=_r({aptosConfig:this.aptosConfig,transaction:n,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof rr)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],n=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),n.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),n.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<n.length;a+=1){let c=s[a];o=n[a],c.status===va?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof rr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,n){try{let i=[];i.push(Qt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===va?(this.executedTransactions.push([a.value.hash,n,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,n,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,n){this.transactionsQueue.enqueue([t,n])}async generateNextTransaction(t,n){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return _({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:n}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var kn=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Kn(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:n}=e;for(let i of t)this.transactionWorker.push(i,n)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.start({sender:t}),this.push({data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var kr=class{constructor(e){this.config=e,this.build=new Rn(this.config),this.simulate=new Zt(this.config),this.submit=new er(this.config),this.batch=new kn(this.config)}async getTransactions(e){return di({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return os({aptosConfig:this.config,...e})}async getTransactionByHash(e){return hr({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ss({aptosConfig:this.config,...e})}async waitForTransaction(e){return Qt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return An({aptosConfig:this.config})}getSigningMessage(e){return Ps(e)}async publishPackageTransaction(e){return Is({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Cs({aptosConfig:this.config,...e})}sign(e){return Pn({...e})}signAsFeePayer(e){return vn({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.batch.forSingleAccount({sender:t,data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return _r({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return vs({aptosConfig:this.config,...e})}};var Dr=class{constructor(e){this.config=e}async getTableItem(e){return yn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Lo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),qo({aptosConfig:this.config,...e})}};async function Dn(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,uidKey:i="sub",derivationPath:o}=r,s={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,epk_blinder:g.fromHexInput(n.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Ao({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function Ui(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,pepper:i=await Dn(r),uidKey:o="sub",maxExpHorizonSecs:s=(await pr({aptosConfig:e})).maxExpHorizonSecs}=r;if(g.fromHexInput(i).toUint8Array().length!==Ht.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ht.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<n.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(n.blinder).toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,exp_horizon_secs:s,pepper:g.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await ho({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),d=p.proof,A=new kt({a:d.a,b:d.b,c:d.c});return new ze({proof:new Dt(A,0),trainingWheelsSignature:xe.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function Ca(r){let{aptosConfig:e,jwt:t,jwkAddress:n,uidKey:i,proofFetchCallback:o,pepper:s=await Dn(r)}=r,{verificationKey:a,maxExpHorizonSecs:c}=await pr({aptosConfig:e}),p=Ui({...r,pepper:s,maxExpHorizonSecs:c}),d=o?p:await p;if(n!==void 0){let y=ee.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:n,uidKey:i}),x=await Wt({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return cn.create({...r,address:x,proof:d,pepper:s,proofFetchCallback:o,jwkAddress:n,verificationKey:a})}let A=O.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),w=await Wt({aptosConfig:e,authenticationKey:A.authKey().derivedAddress()});return Ht.create({...r,address:w,proof:d,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Ra(r){let{aptosConfig:e,sender:t,iss:n,options:i}=r,{jwksUrl:o}=r;o===void 0&&(lo.test(n)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=n.endsWith("/")?`${n}.well-known/jwks.json`:`${n}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,K.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[n,b.MoveString(a.keys.map(c=>c.kid)),b.MoveString(a.keys.map(c=>c.alg)),b.MoveString(a.keys.map(c=>c.e)),b.MoveString(a.keys.map(c=>c.n))]},options:i})}var Or=class{constructor(e){this.config=e}async getPepper(e){return Dn({aptosConfig:this.config,...e})}async getProof(e){return Ui({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Ca({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Ra({aptosConfig:this.config,...e})}};async function Ou(r){let{aptosConfig:e,options:t}=r,n={query:pn,variables:{where_condition:_optionalChain([t, 'optionalAccess', _227 => _227.where]),offset:_optionalChain([t, 'optionalAccess', _228 => _228.offset]),limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),order_by:_optionalChain([t, 'optionalAccess', _230 => _230.orderBy])}};return(await h({aptosConfig:e,query:n,originMethod:"getObjectData"})).current_objects}async function Ua(r){let{aptosConfig:e,objectAddress:t,options:n}=r,o={object_address:{_eq:u.from(t).toStringLong()}};return(await Ou({aptosConfig:e,options:{...n,where:o}}))[0]}var zr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ua({aptosConfig:this.config,...e})}};var te=class{constructor(e){this.config=new En(e),this.account=new br(this.config),this.ans=new Ur(this.config),this.coin=new Sr(this.config),this.digitalAsset=new xr(this.config),this.event=new Pr(this.config),this.faucet=new vr(this.config),this.fungibleAsset=new Ir(this.config),this.general=new Cr(this.config),this.staking=new Kr(this.config),this.transaction=new kr(this.config),this.table=new Dr(this.config),this.keyless=new Or(this.config),this.object=new zr(this.config)}};function pe(r,e,t){Object.getOwnPropertyNames(e.prototype).forEach(n=>{let i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&(i.value=function(...o){return this[t][n](...o)},Object.defineProperty(r.prototype,n,i))})}pe(te,br,"account");pe(te,Ur,"ans");pe(te,Sr,"coin");pe(te,xr,"digitalAsset");pe(te,Pr,"event");pe(te,vr,"faucet");pe(te,Ir,"fungibleAsset");pe(te,Cr,"general");pe(te,Kr,"staking");pe(te,kr,"transaction");pe(te,Dr,"table");pe(te,Or,"keyless");pe(te,zr,"object");exports.APTOS_BIP44_REGEX = Ha; exports.APTOS_COIN = yt; exports.APTOS_FA = uo; exports.APTOS_HARDENED_REGEX = qa; exports.AbstractKeylessAccount = ue; exports.Account = et; exports.AccountAddress = u; exports.AccountAuthenticator = X; exports.AccountAuthenticatorEd25519 = _e; exports.AccountAuthenticatorMultiEd25519 = Zr; exports.AccountAuthenticatorMultiKey = ve; exports.AccountAuthenticatorNoAccountAuthenticator = zt; exports.AccountAuthenticatorSingleKey = ie; exports.AccountAuthenticatorVariant = Mi; exports.AccountPublicKey = ne; exports.AccountSequenceNumber = Un; exports.AddressInvalidReason = Ba; exports.AnyPublicKey = F; exports.AnyPublicKeyVariant = qr; exports.AnySignature = L; exports.AnySignatureVariant = Vi; exports.Aptos = te; exports.AptosApiError = ye; exports.AptosApiType = gt; exports.AptosConfig = En; exports.AptosScriptComposer = xn; exports.AuthenticationKey = B; exports.Bool = U; exports.CKDPriv = Xi; exports.CallArgument = _scriptcomposerpack.CallArgument; exports.ChainId = Nt; exports.DEFAULT_MAX_GAS_AMOUNT = ao; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = co; exports.DEFAULT_TXN_TIMEOUT_SEC = Jr; exports.DeriveScheme = Hi; exports.Deserializer = D; exports.EPK_HORIZON_SECS = Ig; exports.Ed25519Account = Mt; exports.Ed25519PrivateKey = Z; exports.Ed25519PublicKey = P; exports.Ed25519Signature = I; exports.EntryFunction = Tt; exports.EntryFunctionBytes = Mr; exports.EphemeralCertificate = Kt; exports.EphemeralCertificateVariant = Fn; exports.EphemeralKeyPair = Ar; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = Nn; exports.EphemeralSignature = xe; exports.EphemeralSignatureVariant = Li; exports.FIREBASE_AUTH_ISS_PATTERN = lo; exports.FederatedKeylessAccount = cn; exports.FederatedKeylessPublicKey = ee; exports.FeePayerRawTransaction = wt; exports.FixedBytes = at; exports.Groth16VerificationKey = ri; exports.Groth16Zkp = kt; exports.HARDENED_OFFSET = Qi; exports.Hex = g; exports.HexInvalidReason = Oa; exports.Identifier = R; exports.KeyType = $a; exports.KeylessAccount = Ht; exports.KeylessConfiguration = ti; exports.KeylessError = K; exports.KeylessErrorCategory = hc; exports.KeylessErrorResolutionTip = Tc; exports.KeylessErrorType = Xr; exports.KeylessPublicKey = O; exports.KeylessSignature = Oe; exports.MAX_AUD_VAL_BYTES = xc; exports.MAX_COMMITED_EPK_BYTES = Kg; exports.MAX_EXTRA_FIELD_BYTES = Rg; exports.MAX_ISS_VAL_BYTES = Cg; exports.MAX_JWT_HEADER_B64_BYTES = Ug; exports.MAX_UID_KEY_BYTES = Ec; exports.MAX_UID_VAL_BYTES = Pc; exports.MimeType = Vr; exports.ModuleId = dr; exports.MoveAbility = qi; exports.MoveFunctionVisibility = Na; exports.MoveJWK = ni; exports.MoveOption = J; exports.MoveString = S; exports.MoveVector = b; exports.MultiAgentRawTransaction = bt; exports.MultiAgentTransaction = sn; exports.MultiEd25519PublicKey = Ct; exports.MultiEd25519Signature = ut; exports.MultiKey = Ye; exports.MultiKeyAccount = So; exports.MultiKeySignature = Ne; exports.MultiSig = mr; exports.MultiSigTransactionPayload = fr; exports.Network = jn; exports.NetworkToChainId = Jn; exports.NetworkToFaucetAPI = so; exports.NetworkToIndexerAPI = io; exports.NetworkToNetworkName = _l; exports.NetworkToNodeAPI = oo; exports.NetworkToPepperAPI = Wn; exports.NetworkToProverAPI = Qn; exports.ParsingError = Q; exports.PrivateKey = Qe; exports.PrivateKeyVariants = Lr; exports.ProcessorType = ke; exports.PublicKey = ct; exports.RAW_TRANSACTION_SALT = po; exports.RAW_TRANSACTION_WITH_DATA_SALT = Xn; exports.RawTransaction = me; exports.RawTransactionWithData = rn; exports.RoleType = Fa; exports.RotationProofChallenge = nn; exports.Script = yr; exports.ScriptTransactionArgumentVariants = ir; exports.Secp256k1PrivateKey = pt; exports.Secp256k1PublicKey = Ke; exports.Secp256k1Signature = dt; exports.Serializable = l; exports.Serialized = or; exports.Serializer = H; exports.Signature = M; exports.SignedTransaction = Le; exports.SigningScheme = he; exports.SigningSchemeInput = Mn; exports.SimpleTransaction = Ft; exports.SingleKeyAccount = Vt; exports.StructTag = Ie; exports.TransactionAndProof = oi; exports.TransactionAuthenticator = Ve; exports.TransactionAuthenticatorEd25519 = _t; exports.TransactionAuthenticatorFeePayer = xt; exports.TransactionAuthenticatorMultiAgent = St; exports.TransactionAuthenticatorMultiEd25519 = on; exports.TransactionAuthenticatorSingleSender = Ze; exports.TransactionAuthenticatorVariant = Bi; exports.TransactionPayload = At; exports.TransactionPayloadEntryFunction = lr; exports.TransactionPayloadMultiSig = gr; exports.TransactionPayloadScript = ht; exports.TransactionPayloadVariants = Fi; exports.TransactionResponseType = Bn; exports.TransactionVariants = Gi; exports.TransactionWorker = Kn; exports.TransactionWorkerEventsEnum = Ia; exports.TypeTag = z; exports.TypeTagAddress = Y; exports.TypeTagBool = G; exports.TypeTagGeneric = N; exports.TypeTagParserError = q; exports.TypeTagParserErrorType = Qc; exports.TypeTagReference = tn; exports.TypeTagSigner = ft; exports.TypeTagStruct = f; exports.TypeTagU128 = Be; exports.TypeTagU16 = Fe; exports.TypeTagU256 = Me; exports.TypeTagU32 = Ge; exports.TypeTagU64 = W; exports.TypeTagU8 = ae; exports.TypeTagVariants = Ni; exports.TypeTagVector = C; exports.U128 = we; exports.U16 = Te; exports.U256 = de; exports.U32 = be; exports.U64 = $; exports.U8 = j; exports.ZeroKnowledgeSig = ze; exports.ZkProof = Dt; exports.ZkpVariant = Gn; exports.aptosCoinStructTag = gm; exports.aptosRequest = Yr; exports.base64UrlDecode = _chunkF43XVDYJjs.f; exports.bigIntToBytesLE = ro; exports.buildTransaction = Si; exports.bytesToBigIntLE = ar; exports.checkOrConvertArgument = jt; exports.convertAmountFromHumanReadableToOnChain = _chunkF43XVDYJjs.g; exports.convertAmountFromOnChainToHumanReadable = _chunkF43XVDYJjs.h; exports.convertArgument = _n; exports.convertCallArgument = bs; exports.convertNumber = Tn; exports.createObjectAddress = en; exports.createResourceAddress = Ly; exports.createTokenAddress = qy; exports.deriveKey = Ln; exports.deriveTransactionType = ii; exports.deserializeFromScriptArgument = Uc; exports.ensureBoolean = zn; exports.fetchEntryFunctionAbi = hs; exports.fetchFunctionAbi = wi; exports.fetchMoveFunctionAbi = As; exports.fetchViewFunctionAbi = Ts; exports.findFirstNonSignerArg = ys; exports.floorToWholeHour = _chunkF43XVDYJjs.e; exports.generateRawTransaction = _i; exports.generateSignedTransaction = xi; exports.generateSignedTransactionForSimulation = _s; exports.generateSigningMessage = Gt; exports.generateSigningMessageForSerializable = Pf; exports.generateSigningMessageForTransaction = Bt; exports.generateTransactionPayload = Sn; exports.generateTransactionPayloadWithABI = Yc; exports.generateUserTransactionHash = HT; exports.generateViewFunctionPayload = ws; exports.generateViewFunctionPayloadWithABI = Zc; exports.get = Zn; exports.getAptosFullNode = V; exports.getAptosPepperService = jl; exports.getAuthenticatorForSimulation = Xt; exports.getErrorMessage = _chunkF43XVDYJjs.c; exports.getFunctionParts = Et; exports.getIssAudAndUidVal = Ot; exports.getKeylessConfig = pr; exports.getKeylessJWKs = wo; exports.hashStrToField = Qr; exports.hashValues = Ss; exports.hexToAsciiString = zi; exports.isBcsAddress = wn; exports.isBcsBool = li; exports.isBcsFixedBytes = Lc; exports.isBcsString = gi; exports.isBcsU128 = hi; exports.isBcsU16 = mi; exports.isBcsU256 = Ti; exports.isBcsU32 = fi; exports.isBcsU64 = Ai; exports.isBcsU8 = yi; exports.isBlockEpilogueTransactionResponse = lp; exports.isBlockMetadataTransactionResponse = up; exports.isBool = ps; exports.isCanonicalEd25519Signature = Qa; exports.isEd25519Signature = gp; exports.isEmptyOption = ds; exports.isEncodedEntryFunctionArgument = ls; exports.isEncodedStruct = _chunkF43XVDYJjs.j; exports.isFeePayerSignature = fp; exports.isGenesisTransactionResponse = cp; exports.isKeylessSigner = an; exports.isLargeNumber = bn; exports.isMultiAgentSignature = mp; exports.isMultiEd25519Signature = Ap; exports.isNumber = Vc; exports.isPendingTransactionResponse = sp; exports.isScriptDataInput = gs; exports.isSecp256k1Signature = yp; exports.isStateCheckpointTransactionResponse = pp; exports.isString = tt; exports.isUserTransactionResponse = ap; exports.isValidBIP44Path = ji; exports.isValidHardenedPath = Ji; exports.isValidatorTransactionResponse = dp; exports.mnemonicToSeed = Hr; exports.normalizeBundle = go; exports.nowInSeconds = _chunkF43XVDYJjs.d; exports.objectStructTag = ce; exports.optionStructTag = ym; exports.outOfRangeErrorMessage = za; exports.padAndPackBytesWithLen = $n; exports.paginateWithCursor = Ut; exports.parseEncodedStruct = _chunkF43XVDYJjs.i; exports.parseJwtHeader = Cc; exports.parseTypeTag = Re; exports.poseidonHash = cr; exports.post = ur; exports.postAptosFaucet = fo; exports.postAptosFullNode = Xe; exports.postAptosIndexer = mo; exports.postAptosPepperService = Ao; exports.postAptosProvingService = ho; exports.promiseFulfilledStatus = va; exports.request = _c; exports.sleep = _chunkF43XVDYJjs.b; exports.splitPath = Yi; exports.standardizeTypeTags = Jt; exports.stringStructTag = v; exports.throwTypeMismatch = k; exports.validateNumberInRange = $e;
482
482
  //# sourceMappingURL=index.js.map