@aptos-labs/ts-sdk 1.33.2-sc.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/dist/common/{accountAddress-Cf1amU98.d.ts → accountAddress-CDtCLtJA.d.ts} +3 -2
  2. package/dist/common/chunk-ZYPBABLQ.js +4 -0
  3. package/dist/common/chunk-ZYPBABLQ.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +2489 -2235
  8. package/dist/common/index.js +33 -35
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  11. package/dist/esm/account/AbstractedAccount.d.mts +91 -0
  12. package/dist/esm/account/AbstractedAccount.mjs +2 -0
  13. package/dist/esm/account/Account.mjs +1 -1
  14. package/dist/esm/account/AccountUtils.d.mts +16 -16
  15. package/dist/esm/account/AccountUtils.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.mjs +1 -1
  17. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  18. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  19. package/dist/esm/account/KeylessAccount.mjs +1 -1
  20. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  21. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  22. package/dist/esm/account/index.d.mts +2 -0
  23. package/dist/esm/account/index.mjs +1 -1
  24. package/dist/esm/account/utils.mjs +1 -1
  25. package/dist/esm/api/account/abstraction.d.mts +209 -0
  26. package/dist/esm/api/account/abstraction.mjs +2 -0
  27. package/dist/esm/api/account/abstraction.mjs.map +1 -0
  28. package/dist/esm/api/account.d.mts +2 -0
  29. package/dist/esm/api/account.mjs +1 -1
  30. package/dist/esm/api/ans.mjs +1 -1
  31. package/dist/esm/api/aptos.d.mts +1 -0
  32. package/dist/esm/api/aptos.mjs +1 -1
  33. package/dist/esm/api/coin.mjs +1 -1
  34. package/dist/esm/api/digitalAsset.mjs +1 -1
  35. package/dist/esm/api/event.mjs +1 -1
  36. package/dist/esm/api/faucet.mjs +1 -1
  37. package/dist/esm/api/fungibleAsset.mjs +1 -1
  38. package/dist/esm/api/general.mjs +1 -1
  39. package/dist/esm/api/index.d.mts +1 -0
  40. package/dist/esm/api/index.mjs +1 -1
  41. package/dist/esm/api/keyless.d.mts +1 -1
  42. package/dist/esm/api/keyless.mjs +1 -1
  43. package/dist/esm/api/object.mjs +1 -1
  44. package/dist/esm/api/staking.mjs +1 -1
  45. package/dist/esm/api/table.mjs +1 -1
  46. package/dist/esm/api/transaction.mjs +1 -1
  47. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  48. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  49. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  50. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  51. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  52. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  53. package/dist/esm/api/utils.mjs +1 -1
  54. package/dist/esm/bcs/index.mjs +1 -1
  55. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  56. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  57. package/dist/esm/{chunk-CYMVZJHC.mjs → chunk-2FNFUTFJ.mjs} +2 -2
  58. package/dist/esm/{chunk-4UYVRG5Z.mjs → chunk-2GIPNLDO.mjs} +2 -2
  59. package/dist/esm/{chunk-UQ7D5CSM.mjs → chunk-33CBJFX2.mjs} +2 -2
  60. package/dist/esm/{chunk-P54RNN4V.mjs → chunk-3EY7MT2M.mjs} +2 -2
  61. package/dist/esm/{chunk-KPLWOVKG.mjs → chunk-3HFZN7L5.mjs} +2 -2
  62. package/dist/esm/chunk-42T3UGSW.mjs +2 -0
  63. package/dist/esm/chunk-42T3UGSW.mjs.map +1 -0
  64. package/dist/esm/chunk-4776UXL6.mjs +2 -0
  65. package/dist/esm/chunk-4776UXL6.mjs.map +1 -0
  66. package/dist/esm/{chunk-FC2IYWI7.mjs → chunk-4T75XRI2.mjs} +2 -2
  67. package/dist/esm/{chunk-EBS4BKER.mjs → chunk-4UK4MUSD.mjs} +2 -2
  68. package/dist/esm/{chunk-GL4OJVYH.mjs → chunk-5BSMF22B.mjs} +2 -2
  69. package/dist/esm/chunk-66HHRRIX.mjs +2 -0
  70. package/dist/esm/chunk-66HHRRIX.mjs.map +1 -0
  71. package/dist/esm/{chunk-CDYLZDD2.mjs → chunk-6JTNS5O6.mjs} +2 -2
  72. package/dist/esm/{chunk-UF6SI2QE.mjs → chunk-6LGXFXXR.mjs} +2 -2
  73. package/dist/esm/{chunk-T6NQDM7D.mjs → chunk-6PBMD2BQ.mjs} +2 -2
  74. package/dist/esm/chunk-7C2RDOWS.mjs +1 -0
  75. package/dist/esm/chunk-7C2RDOWS.mjs.map +1 -0
  76. package/dist/esm/{chunk-ECZYQTNN.mjs → chunk-7CYCKCVU.mjs} +2 -2
  77. package/dist/esm/chunk-7DPHPPMG.mjs +2 -0
  78. package/dist/esm/chunk-7DPHPPMG.mjs.map +1 -0
  79. package/dist/esm/chunk-ABXES4FS.mjs +2 -0
  80. package/dist/esm/chunk-ABXES4FS.mjs.map +1 -0
  81. package/dist/esm/{chunk-A3NEASNH.mjs → chunk-AC3BISWL.mjs} +2 -2
  82. package/dist/esm/chunk-BBUN4IO4.mjs +2 -0
  83. package/dist/esm/chunk-BBUN4IO4.mjs.map +1 -0
  84. package/dist/esm/{chunk-QHEKBHNU.mjs → chunk-BUTMGMSD.mjs} +2 -2
  85. package/dist/esm/{chunk-P4VF7BN4.mjs → chunk-BYHCW7MI.mjs} +2 -2
  86. package/dist/esm/{chunk-AD3A7DTH.mjs → chunk-CRFLR3ZY.mjs} +2 -2
  87. package/dist/esm/{chunk-CWRANLXZ.mjs → chunk-CSG67JHZ.mjs} +2 -2
  88. package/dist/esm/chunk-CSG67JHZ.mjs.map +1 -0
  89. package/dist/esm/{chunk-BFIXIXHO.mjs → chunk-CXNF73OX.mjs} +2 -2
  90. package/dist/esm/{chunk-32WLD3F3.mjs → chunk-D6T3NYOA.mjs} +2 -2
  91. package/dist/esm/chunk-DBIZE7G6.mjs +2 -0
  92. package/dist/esm/chunk-DBIZE7G6.mjs.map +1 -0
  93. package/dist/esm/{chunk-CGTHWGSJ.mjs → chunk-DLLDRANJ.mjs} +2 -2
  94. package/dist/esm/{chunk-KFGXOZ77.mjs → chunk-DMS7K76O.mjs} +2 -2
  95. package/dist/esm/{chunk-KNTAED2Z.mjs → chunk-DNJQWGB7.mjs} +2 -2
  96. package/dist/esm/{chunk-NW2WUKWV.mjs → chunk-DNWFDS7F.mjs} +2 -2
  97. package/dist/esm/{chunk-XIFIACCB.mjs → chunk-DWJ3PGWE.mjs} +2 -2
  98. package/dist/esm/chunk-EGZI6EJ2.mjs +2 -0
  99. package/dist/esm/chunk-EGZI6EJ2.mjs.map +1 -0
  100. package/dist/esm/chunk-EY2JUXEC.mjs +2 -0
  101. package/dist/esm/{chunk-AIABPCUF.mjs.map → chunk-EY2JUXEC.mjs.map} +1 -1
  102. package/dist/esm/{chunk-KG23XFU2.mjs → chunk-G6RLN6ET.mjs} +2 -2
  103. package/dist/esm/{chunk-G5ZWH5T3.mjs → chunk-GQX5KMF7.mjs} +2 -2
  104. package/dist/esm/{chunk-X3SO2LDX.mjs → chunk-H4GZWYIG.mjs} +2 -2
  105. package/dist/esm/chunk-HEAWDTLG.mjs +2 -0
  106. package/dist/esm/{chunk-XHPWHA6B.mjs.map → chunk-HEAWDTLG.mjs.map} +1 -1
  107. package/dist/esm/{chunk-SQR3AIY7.mjs → chunk-HFCWJ6QL.mjs} +2 -2
  108. package/dist/esm/{chunk-FQECACH3.mjs → chunk-HL2O3T57.mjs} +2 -2
  109. package/dist/esm/chunk-HLJE5XGE.mjs +2 -0
  110. package/dist/esm/chunk-HLJE5XGE.mjs.map +1 -0
  111. package/dist/esm/{chunk-PTS3BTOU.mjs → chunk-HT2WC3QV.mjs} +2 -2
  112. package/dist/esm/{chunk-ODEDSSQL.mjs → chunk-I7YHK6ZF.mjs} +2 -2
  113. package/dist/esm/{chunk-N4VVDQA5.mjs → chunk-IDTLNF4M.mjs} +2 -2
  114. package/dist/esm/chunk-IMTC3J2M.mjs +2 -0
  115. package/dist/esm/chunk-IMTC3J2M.mjs.map +1 -0
  116. package/dist/esm/{chunk-67ZANQ3R.mjs → chunk-J7HRQ2IH.mjs} +2 -2
  117. package/dist/esm/{chunk-H3XZ3FZY.mjs → chunk-JF66JS2R.mjs} +2 -2
  118. package/dist/esm/{chunk-I7JGKVOC.mjs → chunk-KEJAUCQF.mjs} +2 -2
  119. package/dist/esm/{chunk-Y6QTKAQO.mjs → chunk-L2AQG3G3.mjs} +2 -2
  120. package/dist/esm/{chunk-7HLNV3QL.mjs → chunk-L6FONDPA.mjs} +2 -2
  121. package/dist/esm/{chunk-ZJNPBHEI.mjs → chunk-N7C6LQPZ.mjs} +2 -2
  122. package/dist/esm/{chunk-VZELORLW.mjs → chunk-O37BZP2G.mjs} +2 -2
  123. package/dist/esm/{chunk-SOLQ5VON.mjs → chunk-OURSLL3I.mjs} +2 -2
  124. package/dist/esm/{chunk-PHJRCZQ3.mjs → chunk-P7SE5LQE.mjs} +2 -2
  125. package/dist/esm/{chunk-3XH3NNSR.mjs → chunk-PNSF3E67.mjs} +2 -2
  126. package/dist/esm/{chunk-UONSJQUV.mjs → chunk-PR3W2QEH.mjs} +2 -2
  127. package/dist/esm/{chunk-KFCLSJC3.mjs → chunk-PWYJWTEM.mjs} +2 -2
  128. package/dist/esm/{chunk-VCIJX6R4.mjs → chunk-Q7RG7KQS.mjs} +2 -2
  129. package/dist/esm/{chunk-6IIAGMDR.mjs → chunk-QBFGY74I.mjs} +2 -2
  130. package/dist/esm/{chunk-XLFX2YQA.mjs → chunk-S47HA7O7.mjs} +2 -2
  131. package/dist/esm/{chunk-6IPM5P4L.mjs → chunk-SCBYJU6K.mjs} +2 -2
  132. package/dist/esm/chunk-TDGUMBON.mjs +4 -0
  133. package/dist/esm/chunk-TDGUMBON.mjs.map +1 -0
  134. package/dist/esm/{chunk-XGF7UNEW.mjs → chunk-TM6IKHMX.mjs} +2 -2
  135. package/dist/esm/{chunk-FNXO3URE.mjs → chunk-U2SJIG2T.mjs} +2 -2
  136. package/dist/esm/{chunk-SZRZ3HIL.mjs → chunk-ULHOJ2BE.mjs} +2 -2
  137. package/dist/esm/{chunk-4ZJJINCW.mjs → chunk-UTXEW2FT.mjs} +2 -2
  138. package/dist/esm/{chunk-K2CSACQY.mjs → chunk-V2EXS6TM.mjs} +2 -2
  139. package/dist/esm/{chunk-FKJ3GCBI.mjs → chunk-V7G2EDNR.mjs} +2 -2
  140. package/dist/esm/{chunk-R7QOPBWA.mjs → chunk-VKDTI6NX.mjs} +2 -2
  141. package/dist/esm/{chunk-PNDCGNVH.mjs → chunk-VOCI2675.mjs} +2 -2
  142. package/dist/esm/{chunk-VVAKGJDN.mjs → chunk-WXDA4CCR.mjs} +2 -2
  143. package/dist/esm/{chunk-66AQ2MJ6.mjs → chunk-X24PSWCX.mjs} +2 -2
  144. package/dist/esm/chunk-X2CPDUOS.mjs +2 -0
  145. package/dist/esm/chunk-X2CPDUOS.mjs.map +1 -0
  146. package/dist/esm/{chunk-67BUAZ6O.mjs → chunk-X6IHNXWY.mjs} +2 -2
  147. package/dist/esm/{chunk-JJM6ELMS.mjs → chunk-XAPQNCTN.mjs} +2 -2
  148. package/dist/esm/{chunk-DW3ETAZB.mjs → chunk-XDIX7NIP.mjs} +2 -2
  149. package/dist/esm/{chunk-6XHBRRS6.mjs → chunk-XH3BEKII.mjs} +2 -2
  150. package/dist/esm/{chunk-PUNTBVRJ.mjs → chunk-XXHZQFYW.mjs} +2 -2
  151. package/dist/esm/{chunk-YPGI5HAA.mjs → chunk-Y3Y4DVCK.mjs} +2 -2
  152. package/dist/esm/{chunk-CNCRJ56P.mjs → chunk-YIF242TF.mjs} +2 -2
  153. package/dist/esm/{chunk-CWKNJZB6.mjs → chunk-ZCEBDPBJ.mjs} +2 -2
  154. package/dist/esm/{chunk-Q3VS6AEN.mjs → chunk-ZP5EBIBE.mjs} +2 -2
  155. package/dist/esm/cli/index.mjs +1 -1
  156. package/dist/esm/cli/localNode.mjs +1 -1
  157. package/dist/esm/client/core.mjs +1 -1
  158. package/dist/esm/client/get.mjs +1 -1
  159. package/dist/esm/client/index.mjs +1 -1
  160. package/dist/esm/client/post.mjs +1 -1
  161. package/dist/esm/core/account/index.mjs +1 -1
  162. package/dist/esm/core/account/utils/address.mjs +1 -1
  163. package/dist/esm/core/account/utils/index.mjs +1 -1
  164. package/dist/esm/core/accountAddress.mjs +1 -1
  165. package/dist/esm/core/authenticationKey.mjs +1 -1
  166. package/dist/esm/core/crypto/abstraction.d.mts +30 -0
  167. package/dist/esm/core/crypto/abstraction.mjs +2 -0
  168. package/dist/esm/core/crypto/abstraction.mjs.map +1 -0
  169. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  170. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  171. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  172. package/dist/esm/core/crypto/index.mjs +1 -1
  173. package/dist/esm/core/crypto/keyless.mjs +1 -1
  174. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  175. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  176. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  177. package/dist/esm/core/crypto/proof.mjs +1 -1
  178. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  179. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  180. package/dist/esm/core/crypto/signature.mjs +1 -1
  181. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  182. package/dist/esm/core/index.mjs +1 -1
  183. package/dist/esm/errors/index.mjs +1 -1
  184. package/dist/esm/index.d.mts +6 -3
  185. package/dist/esm/index.mjs +1 -1
  186. package/dist/esm/internal/abstraction.d.mts +55 -0
  187. package/dist/esm/internal/abstraction.mjs +2 -0
  188. package/dist/esm/internal/abstraction.mjs.map +1 -0
  189. package/dist/esm/internal/account.mjs +1 -1
  190. package/dist/esm/internal/ans.mjs +1 -1
  191. package/dist/esm/internal/coin.mjs +1 -1
  192. package/dist/esm/internal/digitalAsset.mjs +1 -1
  193. package/dist/esm/internal/event.mjs +1 -1
  194. package/dist/esm/internal/faucet.mjs +1 -1
  195. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  196. package/dist/esm/internal/general.mjs +1 -1
  197. package/dist/esm/internal/keyless.mjs +1 -1
  198. package/dist/esm/internal/object.mjs +1 -1
  199. package/dist/esm/internal/staking.mjs +1 -1
  200. package/dist/esm/internal/table.mjs +1 -1
  201. package/dist/esm/internal/transaction.mjs +1 -1
  202. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  203. package/dist/esm/internal/view.mjs +1 -1
  204. package/dist/esm/transactions/authenticator/account.d.mts +11 -3
  205. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  206. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  207. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  208. package/dist/esm/transactions/authenticator/transaction.d.mts +2 -2
  209. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  210. package/dist/esm/transactions/index.d.mts +2 -2
  211. package/dist/esm/transactions/index.mjs +1 -1
  212. package/dist/esm/transactions/instances/index.mjs +1 -1
  213. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  214. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  215. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  216. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  217. package/dist/esm/transactions/instances/signedTransaction.d.mts +4 -4
  218. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  219. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  220. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  221. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  222. package/dist/esm/transactions/management/index.mjs +1 -1
  223. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  224. package/dist/esm/transactions/scriptComposer/index.d.mts +6 -0
  225. package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
  226. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +2 -17
  227. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  228. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  229. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  230. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  231. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  232. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
  233. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  234. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  235. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  236. package/dist/esm/types/abstraction.d.mts +8 -0
  237. package/dist/esm/types/abstraction.mjs +2 -0
  238. package/dist/esm/types/abstraction.mjs.map +1 -0
  239. package/dist/esm/types/index.mjs +1 -1
  240. package/dist/esm/types/types.d.mts +2 -1
  241. package/dist/esm/types/types.mjs +1 -1
  242. package/dist/esm/utils/helpers.d.mts +18 -2
  243. package/dist/esm/utils/helpers.mjs +1 -1
  244. package/dist/esm/utils/index.d.mts +1 -1
  245. package/dist/esm/utils/index.mjs +1 -1
  246. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  247. package/dist/esm/version.d.mts +1 -1
  248. package/dist/esm/version.mjs +1 -1
  249. package/package.json +1 -1
  250. package/src/account/AbstractedAccount.ts +111 -0
  251. package/src/account/index.ts +1 -0
  252. package/src/api/account/abstraction.ts +239 -0
  253. package/src/api/account.ts +6 -1
  254. package/src/api/aptos.ts +3 -0
  255. package/src/core/crypto/abstraction.ts +47 -0
  256. package/src/internal/abstraction.ts +79 -0
  257. package/src/transactions/authenticator/account.ts +52 -1
  258. package/src/transactions/scriptComposer/index.ts +8 -7
  259. package/src/transactions/transactionBuilder/helpers.ts +1 -22
  260. package/src/transactions/transactionBuilder/remoteAbi.ts +7 -0
  261. package/src/transactions/transactionBuilder/transactionBuilder.ts +2 -1
  262. package/src/types/abstraction.ts +6 -0
  263. package/src/types/types.ts +1 -0
  264. package/src/utils/helpers.ts +28 -1
  265. package/src/version.ts +1 -1
  266. package/dist/common/chunk-IHUCZKG2.js +0 -2
  267. package/dist/common/chunk-IHUCZKG2.js.map +0 -1
  268. package/dist/esm/chunk-AIABPCUF.mjs +0 -2
  269. package/dist/esm/chunk-CWRANLXZ.mjs.map +0 -1
  270. package/dist/esm/chunk-DAFSKSZ5.mjs +0 -2
  271. package/dist/esm/chunk-DAFSKSZ5.mjs.map +0 -1
  272. package/dist/esm/chunk-FQXEX2HN.mjs +0 -2
  273. package/dist/esm/chunk-FQXEX2HN.mjs.map +0 -1
  274. package/dist/esm/chunk-GP4TLDVZ.mjs +0 -1
  275. package/dist/esm/chunk-IJ2QKE4W.mjs +0 -2
  276. package/dist/esm/chunk-IJ2QKE4W.mjs.map +0 -1
  277. package/dist/esm/chunk-NDUIXMIA.mjs +0 -2
  278. package/dist/esm/chunk-NDUIXMIA.mjs.map +0 -1
  279. package/dist/esm/chunk-Q2C6ZY5N.mjs +0 -4
  280. package/dist/esm/chunk-Q2C6ZY5N.mjs.map +0 -1
  281. package/dist/esm/chunk-U2PRGW4O.mjs +0 -2
  282. package/dist/esm/chunk-U2PRGW4O.mjs.map +0 -1
  283. package/dist/esm/chunk-UYONA6PP.mjs +0 -2
  284. package/dist/esm/chunk-UYONA6PP.mjs.map +0 -1
  285. package/dist/esm/chunk-XHPWHA6B.mjs +0 -2
  286. /package/dist/esm/{chunk-GP4TLDVZ.mjs.map → account/AbstractedAccount.mjs.map} +0 -0
  287. /package/dist/esm/{chunk-CYMVZJHC.mjs.map → chunk-2FNFUTFJ.mjs.map} +0 -0
  288. /package/dist/esm/{chunk-4UYVRG5Z.mjs.map → chunk-2GIPNLDO.mjs.map} +0 -0
  289. /package/dist/esm/{chunk-UQ7D5CSM.mjs.map → chunk-33CBJFX2.mjs.map} +0 -0
  290. /package/dist/esm/{chunk-P54RNN4V.mjs.map → chunk-3EY7MT2M.mjs.map} +0 -0
  291. /package/dist/esm/{chunk-KPLWOVKG.mjs.map → chunk-3HFZN7L5.mjs.map} +0 -0
  292. /package/dist/esm/{chunk-FC2IYWI7.mjs.map → chunk-4T75XRI2.mjs.map} +0 -0
  293. /package/dist/esm/{chunk-EBS4BKER.mjs.map → chunk-4UK4MUSD.mjs.map} +0 -0
  294. /package/dist/esm/{chunk-GL4OJVYH.mjs.map → chunk-5BSMF22B.mjs.map} +0 -0
  295. /package/dist/esm/{chunk-CDYLZDD2.mjs.map → chunk-6JTNS5O6.mjs.map} +0 -0
  296. /package/dist/esm/{chunk-UF6SI2QE.mjs.map → chunk-6LGXFXXR.mjs.map} +0 -0
  297. /package/dist/esm/{chunk-T6NQDM7D.mjs.map → chunk-6PBMD2BQ.mjs.map} +0 -0
  298. /package/dist/esm/{chunk-ECZYQTNN.mjs.map → chunk-7CYCKCVU.mjs.map} +0 -0
  299. /package/dist/esm/{chunk-A3NEASNH.mjs.map → chunk-AC3BISWL.mjs.map} +0 -0
  300. /package/dist/esm/{chunk-QHEKBHNU.mjs.map → chunk-BUTMGMSD.mjs.map} +0 -0
  301. /package/dist/esm/{chunk-P4VF7BN4.mjs.map → chunk-BYHCW7MI.mjs.map} +0 -0
  302. /package/dist/esm/{chunk-AD3A7DTH.mjs.map → chunk-CRFLR3ZY.mjs.map} +0 -0
  303. /package/dist/esm/{chunk-BFIXIXHO.mjs.map → chunk-CXNF73OX.mjs.map} +0 -0
  304. /package/dist/esm/{chunk-32WLD3F3.mjs.map → chunk-D6T3NYOA.mjs.map} +0 -0
  305. /package/dist/esm/{chunk-CGTHWGSJ.mjs.map → chunk-DLLDRANJ.mjs.map} +0 -0
  306. /package/dist/esm/{chunk-KFGXOZ77.mjs.map → chunk-DMS7K76O.mjs.map} +0 -0
  307. /package/dist/esm/{chunk-KNTAED2Z.mjs.map → chunk-DNJQWGB7.mjs.map} +0 -0
  308. /package/dist/esm/{chunk-NW2WUKWV.mjs.map → chunk-DNWFDS7F.mjs.map} +0 -0
  309. /package/dist/esm/{chunk-XIFIACCB.mjs.map → chunk-DWJ3PGWE.mjs.map} +0 -0
  310. /package/dist/esm/{chunk-KG23XFU2.mjs.map → chunk-G6RLN6ET.mjs.map} +0 -0
  311. /package/dist/esm/{chunk-G5ZWH5T3.mjs.map → chunk-GQX5KMF7.mjs.map} +0 -0
  312. /package/dist/esm/{chunk-X3SO2LDX.mjs.map → chunk-H4GZWYIG.mjs.map} +0 -0
  313. /package/dist/esm/{chunk-SQR3AIY7.mjs.map → chunk-HFCWJ6QL.mjs.map} +0 -0
  314. /package/dist/esm/{chunk-FQECACH3.mjs.map → chunk-HL2O3T57.mjs.map} +0 -0
  315. /package/dist/esm/{chunk-PTS3BTOU.mjs.map → chunk-HT2WC3QV.mjs.map} +0 -0
  316. /package/dist/esm/{chunk-ODEDSSQL.mjs.map → chunk-I7YHK6ZF.mjs.map} +0 -0
  317. /package/dist/esm/{chunk-N4VVDQA5.mjs.map → chunk-IDTLNF4M.mjs.map} +0 -0
  318. /package/dist/esm/{chunk-67ZANQ3R.mjs.map → chunk-J7HRQ2IH.mjs.map} +0 -0
  319. /package/dist/esm/{chunk-H3XZ3FZY.mjs.map → chunk-JF66JS2R.mjs.map} +0 -0
  320. /package/dist/esm/{chunk-I7JGKVOC.mjs.map → chunk-KEJAUCQF.mjs.map} +0 -0
  321. /package/dist/esm/{chunk-Y6QTKAQO.mjs.map → chunk-L2AQG3G3.mjs.map} +0 -0
  322. /package/dist/esm/{chunk-7HLNV3QL.mjs.map → chunk-L6FONDPA.mjs.map} +0 -0
  323. /package/dist/esm/{chunk-ZJNPBHEI.mjs.map → chunk-N7C6LQPZ.mjs.map} +0 -0
  324. /package/dist/esm/{chunk-VZELORLW.mjs.map → chunk-O37BZP2G.mjs.map} +0 -0
  325. /package/dist/esm/{chunk-SOLQ5VON.mjs.map → chunk-OURSLL3I.mjs.map} +0 -0
  326. /package/dist/esm/{chunk-PHJRCZQ3.mjs.map → chunk-P7SE5LQE.mjs.map} +0 -0
  327. /package/dist/esm/{chunk-3XH3NNSR.mjs.map → chunk-PNSF3E67.mjs.map} +0 -0
  328. /package/dist/esm/{chunk-UONSJQUV.mjs.map → chunk-PR3W2QEH.mjs.map} +0 -0
  329. /package/dist/esm/{chunk-KFCLSJC3.mjs.map → chunk-PWYJWTEM.mjs.map} +0 -0
  330. /package/dist/esm/{chunk-VCIJX6R4.mjs.map → chunk-Q7RG7KQS.mjs.map} +0 -0
  331. /package/dist/esm/{chunk-6IIAGMDR.mjs.map → chunk-QBFGY74I.mjs.map} +0 -0
  332. /package/dist/esm/{chunk-XLFX2YQA.mjs.map → chunk-S47HA7O7.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-6IPM5P4L.mjs.map → chunk-SCBYJU6K.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-XGF7UNEW.mjs.map → chunk-TM6IKHMX.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-FNXO3URE.mjs.map → chunk-U2SJIG2T.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-SZRZ3HIL.mjs.map → chunk-ULHOJ2BE.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-4ZJJINCW.mjs.map → chunk-UTXEW2FT.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-K2CSACQY.mjs.map → chunk-V2EXS6TM.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-FKJ3GCBI.mjs.map → chunk-V7G2EDNR.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-R7QOPBWA.mjs.map → chunk-VKDTI6NX.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-PNDCGNVH.mjs.map → chunk-VOCI2675.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-VVAKGJDN.mjs.map → chunk-WXDA4CCR.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-66AQ2MJ6.mjs.map → chunk-X24PSWCX.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-67BUAZ6O.mjs.map → chunk-X6IHNXWY.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-JJM6ELMS.mjs.map → chunk-XAPQNCTN.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-DW3ETAZB.mjs.map → chunk-XDIX7NIP.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-6XHBRRS6.mjs.map → chunk-XH3BEKII.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-PUNTBVRJ.mjs.map → chunk-XXHZQFYW.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-YPGI5HAA.mjs.map → chunk-Y3Y4DVCK.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-CNCRJ56P.mjs.map → chunk-YIF242TF.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-CWKNJZB6.mjs.map → chunk-ZCEBDPBJ.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-Q3VS6AEN.mjs.map → chunk-ZP5EBIBE.mjs.map} +0 -0
@@ -1,11 +1,9 @@
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 _chunkIHUCZKG2js = require('./chunk-IHUCZKG2.js');var qr=255,$r=65535,Fe=4294967295,gt=18446744073709551615n,cr=340282366920938463463374607431768211455n,Wr=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var _utils = require('@noble/hashes/utils');var J=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var Ha=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(Ha||{}),m= 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 J("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 J("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 J(`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])}},Vi= exports.hexToAsciiString =r=>new TextDecoder().decode(m.fromHexInput(r).toUint8Array());var R=class r{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=m.hexInputToUint8Array(e);return new r(t)}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)}deserializeOptionStr(){return this.deserializeOption("string")}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<Fe;){let n=this.deserializeU8();if(e|=BigInt(n&127)<<BigInt(t),!(n&128))break;t+=7}if(e>Fe)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 y=class{bcsToBytes(){let e=new B;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return m.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},B= 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){Mn(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(Fe),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&gt,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&cr,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))}};_chunkIHUCZKG2js.a.call(void 0, [yt(0,qr)],B.prototype,"serializeU8",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,$r)],B.prototype,"serializeU16",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,Fe)],B.prototype,"serializeU32",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),gt)],B.prototype,"serializeU64",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),cr)],B.prototype,"serializeU128",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),Wr)],B.prototype,"serializeU256",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,Fe)],B.prototype,"serializeU32AsUleb128",1);function Mn(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var qa=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function tt(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(qa(r,e,t))}function yt(r,e){return(t,n,i)=>{let o=i.value;return i.value=function(a){return tt(a,r,e),o.apply(this,[a])},i}}var mt=class r extends y{constructor(e){super(),this.value=m.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 Qr=class r extends y{constructor(e){super(),this.value=new mt(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let n=mt.deserialize(e,t);return new r(n.value)}};var jr=(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))(jr||{}),Hi= exports.TypeTagVariants =(d=>(d[d.Bool=0]="Bool",d[d.U8=1]="U8",d[d.U64=2]="U64",d[d.U128=3]="U128",d[d.Address=4]="Address",d[d.Signer=5]="Signer",d[d.Vector=6]="Vector",d[d.Struct=7]="Struct",d[d.U16=8]="U16",d[d.U32=9]="U32",d[d.U256=10]="U256",d[d.Reference=254]="Reference",d[d.Generic=255]="Generic",d))(Hi||{}),ur= exports.ScriptTransactionArgumentVariants =(l=>(l[l.U8=0]="U8",l[l.U64=1]="U64",l[l.U128=2]="U128",l[l.Address=3]="Address",l[l.U8Vector=4]="U8Vector",l[l.Bool=5]="Bool",l[l.U16=6]="U16",l[l.U32=7]="U32",l[l.U256=8]="U256",l[l.Serialized=9]="Serialized",l))(ur||{}),qi= exports.TransactionPayloadVariants =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(qi||{}),$i= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))($i||{}),Wi= 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))(Wi||{}),Qi= 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))(Qi||{}),Jr= exports.PrivateKeyVariants =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(Jr||{}),pr= exports.AnyPublicKeyVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.Secp256k1=1]="Secp256k1",i[i.Keyless=3]="Keyless",i[i.FederatedKeyless=4]="FederatedKeyless",i))(pr||{}),ji= exports.AnySignatureVariant =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))(ji||{}),Ln= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Ln||{}),Ji= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Ji||{}),Vn= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(Vn||{}),Hn= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(Hn||{}),qn= 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))(qn||{});function dp(r){return r.type==="pending_transaction"}function lp(r){return r.type==="user_transaction"}function gp(r){return r.type==="genesis_transaction"}function yp(r){return r.type==="block_metadata_transaction"}function mp(r){return r.type==="state_checkpoint_transaction"}function fp(r){return r.type==="validator_transaction"}function Ap(r){return r.type==="block_epilogue_transaction"}function hp(r){return"signature"in r&&r.signature==="ed25519_signature"}function Tp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function bp(r){return r.type==="multi_agent_signature"}function wp(r){return r.type==="fee_payer_signature"}function Sp(r){return r.type==="multi_ed25519_signature"}var $a=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))($a||{}),Xi= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(Xi||{}),Wa= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(Wa||{}),oe= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(oe||{}),$n= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))($n||{}),Yi= 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))(Yi||{});var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var k=class r extends y{constructor(e){super(),Mn(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 ye(e.deserializeU256())}static deserialize(e){return new r(e.deserializeBool())}},X= exports.U8 =class r extends y{constructor(e){super(),tt(e,0,qr),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())}},_e= exports.U16 =class r extends y{constructor(e){super(),tt(e,0,$r),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())}},xe= exports.U32 =class r extends y{constructor(e){super(),tt(e,0,Fe),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())}},Q= exports.U64 =class r extends y{constructor(e){super(),tt(e,BigInt(0),gt),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())}},Ee= exports.U128 =class r extends y{constructor(e){super(),tt(e,BigInt(0),cr),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())}},ye= exports.U256 =class r extends y{constructor(e){super(),tt(e,BigInt(0),Wr),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 S=class r extends y{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 X)){new dr(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=m.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 X(n)))}static U16(e){return new r(e.map(t=>new _e(t)))}static U32(e){return new r(e.map(t=>new xe(t)))}static U64(e){return new r(e.map(t=>new Q(t)))}static U128(e){return new r(e.map(t=>new Ee(t)))}static U256(e){return new r(e.map(t=>new ye(t)))}static Bool(e){return new r(e.map(t=>new k(t)))}static MoveString(e){return new r(e.map(t=>new x(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)}},dr= exports.Serialized =class r extends y{constructor(e){super(),this.value=m.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 R(this.bcsToBytes());t.deserializeUleb128AsU32();let n=t.deserializeVector(e);return new S(n)}},x= exports.MoveString =class r extends y{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);S.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},Y= exports.MoveOption =class r extends y{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[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 X(e):void 0)}static U16(e){return new r(e!=null?new _e(e):void 0)}static U32(e){return new r(e!=null?new xe(e):void 0)}static U64(e){return new r(e!=null?new Q(e):void 0)}static U128(e){return new r(e!=null?new Ee(e):void 0)}static U256(e){return new r(e!=null?new ye(e):void 0)}static Bool(e){return new r(e!=null?new k(e):void 0)}static MoveString(e){return new r(e!=null?new x(e):void 0)}static deserialize(e,t){let n=S.deserialize(e,t);return new r(n.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var ja=(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))(ja||{}),E=class E extends y{constructor(e){if(super(),e.length!==E.LENGTH)throw new J("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 J("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 J(`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 J(`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 J("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new J("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 J(`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 J(`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 J(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
2
- the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
3
- Received ${e}`,"too_short");return 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 rt=class rt extends y{constructor(e){super();let{data:t}=e,n=m.fromHexInput(t);if(n.toUint8Array().length!==rt.LENGTH)throw new Error(`Authentication Key length should be ${rt.LENGTH}`);this.data=n}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(rt.LENGTH);return new rt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:n}=e,i=m.fromHexInput(n).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new rt({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())}};rt.LENGTH=32;var L=rt;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var eo = _interopRequireWildcard(_bip39);var Za=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,ec= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,tc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(tc||{}),to= exports.HARDENED_OFFSET =2147483648;function ro(r){return ec.test(r)}function no(r){return Za.test(r)}var Qn=(r,e)=>{let t=_hmac.hmac.create(_sha512.sha512,r).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},io= 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 Qn(e,s)},rc=r=>r.replace(/'/g,""),oo= exports.splitPath =r=>r.split("/").slice(1).map(rc),Xr= exports.mnemonicToSeed =r=>{let e=r.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return eo.mnemonicToSeedSync(e)};var lr=class lr{static formatPrivateKey(e,t){let n=lr.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(n)&&(i=i.split("-")[2]),`${n}${m.fromHexInput(i).toString()}`}static parseHexInput(e,t,n){let i,o=lr.AIP80_PREFIXES[t];if(typeof e=="string")if(!n&&!e.startsWith(o))i=m.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=m.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=m.fromHexInput(e);return i}};lr.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var nt=lr;var ft=class extends y{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return m.fromHexInput(e).toString()}},se= exports.AccountPublicKey =class extends ft{};var V=class extends y{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return m.fromHexInput(e).toString()}};var Nt=r=>typeof r=="string"?m.isValid(r).valid?r:new TextEncoder().encode(r):r;var jn=[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 nc(r){let e=r.toUint8Array().slice(32);for(let t=jn.length-1;t>=0;t-=1){if(e[t]<jn[t])return!0;if(e[t]>jn[t])return!1}return!1}var it=class it extends se{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==it.LENGTH)throw new Error(`PublicKey length should be ${it.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!nc(n))return!1;let i=Nt(t),o=m.fromHexInput(i).toUint8Array(),s=n.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}authKey(){return L.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 it(t)}static isPublicKey(e){return e instanceof it}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _8 => _8.key, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.length])===it.LENGTH}};it.LENGTH=32;var P=it,me=class me extends y{constructor(e,t){super();let n=nt.parseHexInput(e,"ed25519",t);if(n.toUint8Array().length!==me.LENGTH)throw new Error(`PrivateKey length should be ${me.LENGTH}`);this.signingKey=n}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new me(e,!1)}static fromDerivationPath(e,t){if(!no(e))throw new Error(`Invalid derivation path ${e}`);return me.fromDerivationPathInner(e,Xr(t))}static fromDerivationPathInner(e,t,n=to){let{key:i,chainCode:o}=Qn(me.SLIP_0010_SEED,t),s=oo(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>io(c,p+n),{key:i,chainCode:o});return new me(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let t=Nt(e),n=m.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 nt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new me(t,!1)}static isPrivateKey(e){return e instanceof me}};me.LENGTH=32,me.SLIP_0010_SEED="ed25519 seed";var H=me,Ft=class Ft extends V{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Ft.LENGTH)throw new Error(`Signature length should be ${Ft.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 Ft(t)}};Ft.LENGTH=64;var I=Ft;var fe=class fe extends se{constructor(e){super();let{publicKeys:t,threshold:n}=e;if(t.length>fe.MAX_KEYS||t.length<fe.MIN_KEYS)throw new Error(`Must have between ${fe.MIN_KEYS} and ${fe.MAX_KEYS} public keys, inclusive`);if(n<fe.MIN_THRESHOLD||n>t.length)throw new Error(`Threshold must be between ${fe.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=n}verifySignature(e){let{message:t,signature:n}=e;if(!(n instanceof At))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 L.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 fe({publicKeys:i,threshold:n})}};fe.MAX_KEYS=32,fe.MIN_KEYS=2,fe.MIN_THRESHOLD=1;var Gt=fe,ce=class ce extends V{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ce.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(n instanceof Uint8Array))this.bitmap=ce.createBitmap({bits:n});else{if(n.length!==ce.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ce.BITMAP_LEN}`);this.bitmap=n}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+ce.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 ce({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>=ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ce.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}};ce.MAX_SIGNATURES_SUPPORTED=32,ce.BITMAP_LEN=4;var At=ce;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Pe=class Pe extends ft{constructor(e){super();let t=m.fromHexInput(e),{length:n}=t.toUint8Array();if(n===Pe.LENGTH)this.key=t;else if(n===Pe.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=m.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${n}`)}verifySignature(e){let{message:t,signature:n}=e,i=Nt(t),o=m.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 ht(t)}static deserialize(e){let t=e.deserializeBytes();return new Pe(t)}static isPublicKey(e){return e instanceof Pe}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _11 => _11.key, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.length])===Pe.LENGTH}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Ge=Pe,Ce=class Ce extends y{constructor(e,t){super();let n=nt.parseHexInput(e,"secp256k1",t);if(n.toUint8Array().length!==Ce.LENGTH)throw new Error(`PrivateKey length should be ${Ce.LENGTH}`);this.key=n}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ce(e,!1)}static fromDerivationPath(e,t){if(!ro(e))throw new Error(`Invalid derivation path ${e}`);return Ce.fromDerivationPathInner(e,Xr(t))}static fromDerivationPathInner(e,t){let{privateKey:n}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(n===null)throw new Error("Invalid key");return new Ce(n,!1)}sign(e){let t=Nt(e),n=m.fromHexInput(t),i=_sha3.sha3_256.call(void 0, n.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new ht(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Ge(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return nt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ce(t,!1)}static isPrivateKey(e){return e instanceof Ce}};Ce.LENGTH=32;var Be=Ce,Bt=class Bt extends V{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Bt.LENGTH)throw new Error(`Signature length should be ${Bt.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 Bt(t)}};Bt.LENGTH=64;var ht=Bt;var _jwtdecode = require('jwt-decode');var Tt=class r extends ft{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}},Re= exports.EphemeralSignature =class r extends V{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=m.fromHexInput(e),n=new R(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 Jn=[_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],co=31,wc=16,ao=(wc-1)*co;function Zr(r,e){let n=new TextEncoder().encode(r);return Sc(n,e)}function Sc(r,e){if(r.length>e)throw new Error(`Inputted bytes of length ${r} is longer than ${e}`);let t=Xn(r,e);return mr(t)}function _c(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);let t=Pc(r,e);return xc(t)}function Xn(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);return _c(r,e).concat([BigInt(r.length)])}function xc(r){if(r.length>ao)throw new Error(`Can't pack more than ${ao}. Was given ${r.length} bytes`);return Ec(r,co).map(e=>yr(e))}function Ec(r,e){let t=[];for(let n=0;n<r.length;n+=e)t.push(r.subarray(n,n+e));return t}function yr(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 uo(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 Pc(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 mr(r){if(r.length>Jn.length)throw new Error(`Unable to hash input of length ${r.length}. Max input length is ${Jn.length}`);return Jn[r.length-1](r)}var en=class extends y{};var po="1.33.2-sc.0";var lo={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"},go= 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"},yo= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Yn= 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"},Zn= 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"},ei= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(ei||{}),ti= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},vl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var bt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(bt||{}),mo= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,fo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,tn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,wt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Ao= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",ho= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",ri= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Me= 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))(Me||{}),To= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function bo(r,e){let t=e.bcsToBytes(),n=new R(t);return r.deserialize(n)}var vc=(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))(vc||{}),Ic= 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))(Ic||{}),rn= exports.KeylessErrorType =(f=>(f[f.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",f[f.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",f[f.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",f[f.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",f[f.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",f[f.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",f[f.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",f[f.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",f[f.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",f[f.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",f[f.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",f[f.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",f[f.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",f[f.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",f[f.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",f[f.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",f[f.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",f[f.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",f[f.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",f[f.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",f[f.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",f[f.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",f[f.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",f[f.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",f[f.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",f[f.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",f[f.UNKNOWN=26]="UNKNOWN",f))(rn||{}),wo={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"]},z= exports.KeylessError =class r extends Error{constructor(e){let{innerError:t,category:n,resolutionTip:i,type:o,message:s=wo[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=`
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 _chunkZYPBABLQjs = require('./chunk-ZYPBABLQ.js');var C=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunkZYPBABLQjs.j.hexInputToUint8Array(e);return new n(t)}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)}deserializeOptionStr(){return this.deserializeOption("string")}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<_chunkZYPBABLQjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunkZYPBABLQjs.d)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(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var pt=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Hn=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=new pt(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=pt.deserialize(e,t);return new n(r.value)}};var U=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.n.call(void 0, 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 le(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},J= exports.U8 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.b),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 n(e.deserializeU8())}},we= exports.U16 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.c),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 n(e.deserializeU16())}},Se= exports.U32 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.d),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 n(e.deserializeU32())}},W= exports.U64 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.e),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 n(e.deserializeU64())}},_e= exports.U128 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.f),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 n(e.deserializeU128())}},le= exports.U256 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.g),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 n(e.deserializeU256())}};var _=class n extends _chunkZYPBABLQjs.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 sn(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 r=_chunkZYPBABLQjs.j.fromHexInput(e);t=Array.from(r.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 n(t.map(r=>new J(r)))}static U16(e){return new n(e.map(t=>new we(t)))}static U32(e){return new n(e.map(t=>new Se(t)))}static U64(e){return new n(e.map(t=>new W(t)))}static U128(e){return new n(e.map(t=>new _e(t)))}static U256(e){return new n(e.map(t=>new le(t)))}static Bool(e){return new n(e.map(t=>new U(t)))}static MoveString(e){return new n(e.map(t=>new E(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},sn= exports.Serialized =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.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 n(e.deserializeBytes())}toMoveVector(e){let t=new C(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new _(r)}},E= exports.MoveString =class n extends _chunkZYPBABLQjs.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 r=new TextEncoder().encode(this.value);_.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},X= exports.MoveOption =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new _([e]):this.vec=new _([]),[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 n(e!=null?new J(e):void 0)}static U16(e){return new n(e!=null?new we(e):void 0)}static U32(e){return new n(e!=null?new Se(e):void 0)}static U64(e){return new n(e!=null?new W(e):void 0)}static U128(e){return new n(e!=null?new _e(e):void 0)}static U256(e){return new n(e!=null?new le(e):void 0)}static Bool(e){return new n(e!=null?new U(e):void 0)}static MoveString(e){return new n(e!=null?new E(e):void 0)}static deserialize(e,t){let r=_.deserialize(e,t);return new n(r.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var tt=class tt extends _chunkZYPBABLQjs.l{constructor(e){super();let{data:t}=e,r=_chunkZYPBABLQjs.j.fromHexInput(t);if(r.toUint8Array().length!==tt.LENGTH)throw new Error(`Authentication Key length should be ${tt.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(tt.LENGTH);return new tt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunkZYPBABLQjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new tt({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 (0, _chunkZYPBABLQjs.Z)(this.data.toUint8Array())}};tt.LENGTH=32;var B=tt;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var $i = _interopRequireWildcard(_bip39);var Xa=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ya= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Za= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Za||{}),Wi= exports.HARDENED_OFFSET =2147483648;function Qi(n){return Ya.test(n)}function ji(n){return Xa.test(n)}var Br=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Ji= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Br(e,s)},ec=n=>n.replace(/'/g,""),Xi= exports.splitPath =n=>n.split("/").slice(1).map(ec),$n= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return $i.mnemonicToSeedSync(e)};var an=class an{static formatPrivateKey(e,t){let r=an.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunkZYPBABLQjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=an.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunkZYPBABLQjs.j.fromHexInput(e),r!==!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=_chunkZYPBABLQjs.j.fromHexString(e.split("-")[2]);else throw r?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=_chunkZYPBABLQjs.j.fromHexInput(e);return i}};an.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var nt=an;var lt=class extends _chunkZYPBABLQjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkZYPBABLQjs.j.fromHexInput(e).toString()}},Y= exports.AccountPublicKey =class extends lt{};var M=class extends _chunkZYPBABLQjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkZYPBABLQjs.j.fromHexInput(e).toString()}};var kt=n=>typeof n=="string"?_chunkZYPBABLQjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var Mr=[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 tc(n){let e=n.toUint8Array().slice(32);for(let t=Mr.length-1;t>=0;t-=1){if(e[t]<Mr[t])return!0;if(e[t]>Mr[t])return!1}return!1}var rt=class rt extends Y{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==rt.LENGTH)throw new Error(`PublicKey length should be ${rt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!tc(r))return!1;let i=kt(t),o=_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array(),s=r.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 rt(t)}static isPublicKey(e){return e instanceof rt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===rt.LENGTH}};rt.LENGTH=32;var x=rt,ge=class ge extends _chunkZYPBABLQjs.l{constructor(e,t){super();let r=nt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==ge.LENGTH)throw new Error(`PrivateKey length should be ${ge.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new ge(e,!1)}static fromDerivationPath(e,t){if(!ji(e))throw new Error(`Invalid derivation path ${e}`);return ge.fromDerivationPathInner(e,$n(t))}static fromDerivationPathInner(e,t,r=Wi){let{key:i,chainCode:o}=Br(ge.SLIP_0010_SEED,t),s=Xi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>Ji(c,d+r),{key:i,chainCode:o});return new ge(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new x(e)}sign(e){let t=kt(e),r=_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new I(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return nt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new ge(t,!1)}static isPrivateKey(e){return e instanceof ge}};ge.LENGTH=32,ge.SLIP_0010_SEED="ed25519 seed";var q=ge,Ot=class Ot extends M{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==Ot.LENGTH)throw new Error(`Signature length should be ${Ot.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 Ot(t)}};Ot.LENGTH=64;var I=Ot;var me=class me extends Y{constructor(e){super();let{publicKeys:t,threshold:r}=e;if(t.length>me.MAX_KEYS||t.length<me.MIN_KEYS)throw new Error(`Must have between ${me.MIN_KEYS} and ${me.MAX_KEYS} public keys, inclusive`);if(r<me.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${me.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof gt))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.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:r.signatures[o]}))return!1;return!0}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*x.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*x.LENGTH)}),e[this.publicKeys.length*x.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=x.LENGTH){let s=o;i.push(new x(t.subarray(s,s+x.LENGTH)))}return new me({publicKeys:i,threshold:r})}};me.MAX_KEYS=32,me.MIN_KEYS=2,me.MIN_THRESHOLD=1;var Ft=me,ae=class ae extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ae.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=ae.createBitmap({bits:r});else{if(r.length!==ae.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ae.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+ae.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*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(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new ae({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ae.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),d=i[c];d|=r>>s%8,i[c]=d}),i}};ae.MAX_SIGNATURES_SUPPORTED=32,ae.BITMAP_LEN=4;var gt=ae;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Pe=class Pe extends lt{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Pe.LENGTH)this.key=t;else if(r===Pe.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunkZYPBABLQjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=kt(t),o=_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.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 mt(t)}static deserialize(e){let t=e.deserializeBytes();return new Pe(t)}static isPublicKey(e){return e instanceof Pe}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _5 => _5.key, 'optionalAccess', _6 => _6.data, 'optionalAccess', _7 => _7.length])===Pe.LENGTH}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Fe=Pe,Ie=class Ie extends _chunkZYPBABLQjs.l{constructor(e,t){super();let r=nt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Ie.LENGTH)throw new Error(`PrivateKey length should be ${Ie.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ie(e,!1)}static fromDerivationPath(e,t){if(!Qi(e))throw new Error(`Invalid derivation path ${e}`);return Ie.fromDerivationPathInner(e,$n(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Ie(r,!1)}sign(e){let t=kt(e),r=_chunkZYPBABLQjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new mt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return nt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ie(t,!1)}static isPrivateKey(e){return e instanceof Ie}};Ie.LENGTH=32;var Ne=Ie,Nt=class Nt extends M{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==Nt.LENGTH)throw new Error(`Signature length should be ${Nt.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 Nt(t)}};Nt.LENGTH=64;var mt=Nt;var _jwtdecode = require('jwt-decode');var yt=class n extends lt{constructor(e){super();let t=e.constructor.name;switch(t){case x.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}serialize(e){if(this.publicKey instanceof x)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 n(x.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},ve= exports.EphemeralSignature =class n 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=_chunkZYPBABLQjs.j.fromHexInput(e),r=new C(t.toUint8Array());return n.deserialize(r)}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 n(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Vr=[_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],eo=31,Tc=16,Zi=(Tc-1)*eo;function Qn(n,e){let r=new TextEncoder().encode(n);return bc(r,e)}function bc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=qr(n,e);return dn(t)}function wc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Pc(n,e);return Sc(t)}function qr(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return wc(n,e).concat([BigInt(n.length)])}function Sc(n){if(n.length>Zi)throw new Error(`Can't pack more than ${Zi}. Was given ${n.length} bytes`);return _c(n,eo).map(e=>un(e))}function _c(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function un(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function to(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Pc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function dn(n){if(n.length>Vr.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${Vr.length}`);return Vr[n.length-1](n)}var jn=class extends _chunkZYPBABLQjs.l{};var no="1.34.0";var ro={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"},io= 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"},oo= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Lr= 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"},Hr= 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"},$r= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))($r||{}),Wr= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},cl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var ft=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(ft||{}),so= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,ao= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Jn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,At= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",co= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",uo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Qr= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ge= 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))(Ge||{}),po= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function lo(n,e){let t=e.bcsToBytes(),r=new C(t);return n.deserialize(r)}var Ec=(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))(Ec||{}),xc= exports.KeylessErrorResolutionTip =(d=>(d.REAUTHENTICATE="Re-authentiate to continue using your keyless account",d.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",d.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",d.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.",d.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",d.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",d.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d))(xc||{}),Xn= exports.KeylessErrorType =(f=>(f[f.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",f[f.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",f[f.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",f[f.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",f[f.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",f[f.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",f[f.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",f[f.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",f[f.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",f[f.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",f[f.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",f[f.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",f[f.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",f[f.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",f[f.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",f[f.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",f[f.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",f[f.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",f[f.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",f[f.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",f[f.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",f[f.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",f[f.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",f[f.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",f[f.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",f[f.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",f[f.UNKNOWN=26]="UNKNOWN",f))(Xn||{}),go={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"]},z= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=go[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
4
2
  Message: ${e}`;return i&&(o+=`
5
- Details: ${i}`),n instanceof Ae?o+=`
6
- AptosApiError: ${n.message}`:n!==void 0&&(o+=`
7
- Error: ${_chunkIHUCZKG2js.c.call(void 0, n)}`),o+=`
8
- KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,details:i}=e,[o,s,a]=wo[n];return new r({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:n})}},Ae= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:n}){super(Cc({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 Cc({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: ${Rc(t.data)}`}var ni=400;function Rc(r){let e=JSON.stringify(r);return e.length<=ni?e:`truncated(original_size:${e.length}): ${e.slice(0,ni/2)}...${e.slice(-ni/2)}`}async function Kc(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/${po}`,"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 nn(r,e,t){let{url:n,path:i}=r,o=i?`${n}/${i}`:n,s=await Kc({...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 Ae({apiType:t,aptosRequest:r,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a})}async function on(r){let{aptosConfig:e,overrides:t,params:n,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=r,p=e.getRequestUrl(c);return nn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:n,overrides:{...e.clientConfig,...t}},e,r.type)}async function q(r){let{aptosConfig:e}=r;return on({...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 eg(r){return on({...r,type:"Pepper"})}async function sn(r){let e=[],t,n=r.params;do{let i=await on({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 ii(r){let e=[],t,n=r.params,i=n.limit;do{let o=await on({type:"Fullnode",aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});if(t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),n.offset=t,i!==void 0){let s=i-e.length;if(s<=0)break;n.limit=s}}while(t!=null);return e}async function fr(r){let{type:e,originMethod:t,path:n,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=r,l=c.getRequestUrl(e);return nn({url:l,method:"POST",originMethod:t,path:n,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,r.type)}async function ot(r){let{aptosConfig:e}=r;return fr({...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 So(r){let{aptosConfig:e}=r;return fr({...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 _o(r){let{aptosConfig:e}=r,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _44 => _44.clientConfig, 'optionalAccess', _45 => delete _45.API_KEY]),fr({...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 xo(r){return fr({...r,type:"Pepper"})}async function Eo(r){return fr({...r,type:"Prover"})}var oi=new Map;function Ke(r,e,t){return async(...n)=>{if(oi.has(e)){let{value:o,timestamp:s}=oi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await r(...n);return oi.set(e,{value:i,timestamp:Date.now()}),i}}var kg=1e7,kc= exports.MAX_AUD_VAL_BYTES =120,zc= exports.MAX_UID_KEY_BYTES =30,Dc= exports.MAX_UID_VAL_BYTES =330,zg= exports.MAX_ISS_VAL_BYTES =120,Dg= exports.MAX_EXTRA_FIELD_BYTES =350,Og= exports.MAX_JWT_HEADER_B64_BYTES =300,Ng= exports.MAX_COMMITED_EPK_BYTES =93,Ue=class Ue extends se{constructor(e,t){super();let n=m.fromHexInput(t).toUint8Array();if(n.length!==Ue.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ue.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=n}authKey(){let e=new B;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),L.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 Ue(t,n)}static load(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Ue(t,n)}static isPublicKey(e){return e instanceof Ue}static create(e){return Po(e),new Ue(e.iss,Po(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 Ue.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}};Ue.ID_COMMITMENT_LENGTH=32;var O=Ue;function Po(r){let{uidKey:e,uidVal:t,aud:n,pepper:i}=r,o=[yr(m.fromHexInput(i).toUint8Array()),Zr(n,kc),Zr(t,Dc),Zr(e,zc)];return uo(mr(o),O.ID_COMMITMENT_LENGTH)}var Ve=class r extends V{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 Fc(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=Mt.deserialize(e),n=e.deserializeStr(),i=e.deserializeU64(),o=Tt.deserialize(e),s=Re.deserialize(e);return new r({jwtHeader:n,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new r({jwtHeader:"{}",ephemeralCertificate:new Mt(new ve({proof:new Vt(new Lt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Tt(new P(new Uint8Array(32))),ephemeralSignature:new Re(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof r}},Mt= exports.EphemeralCertificate =class r extends V{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(ve.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Le=class r extends y{constructor(e){if(super(),this.data=m.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)}},St=class r extends y{constructor(e){if(super(),this.data=m.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)}},Lt= exports.Groth16Zkp =class r extends en{constructor(e){super();let{a:t,b:n,c:i}=e;this.a=new Le(t),this.b=new St(n),this.c=new Le(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Le.deserialize(e).bcsToBytes(),n=St.deserialize(e).bcsToBytes(),i=Le.deserialize(e).bcsToBytes();return new r({a:t,b:n,c:i})}},Vt= exports.ZkProof =class r extends y{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(Lt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ve= exports.ZeroKnowledgeSig =class r extends V{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 R(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=Vt.deserialize(e),n=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Re);return new r({proof:t,expHorizonSecs:n,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},si= exports.KeylessConfiguration =class r{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new r(new ai({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},ai= exports.Groth16VerificationKey =class r{constructor(e){let{alphaG1:t,betaG2:n,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Le(t),this.betaG2=new St(n),this.deltaG2=new St(i),this.gammaAbcG1=[new Le(o[0]),new Le(o[1])],this.gammaG2=new St(s)}hash(){let e=new B;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 Ar(r){let{aptosConfig:e}=r;try{return await Ke(async()=>{let t=await Oc(r),n=await Nc(r);return si.create(n,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof z?t:z.fromErrorType({type:25,error:t})}}function He(r){let{jwt:e,uidKey:t="sub"}=r,n;try{n=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw z.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkIHUCZKG2js.c.call(void 0, o)}`})}if(typeof n.iss!="string")throw z.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof n.aud!="string")throw z.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 Oc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Configuration";try{let{data:i}=await q({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 z.fromErrorType({type:22,error:i})}}async function Nc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await q({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 z.fromErrorType({type:23,error:i})}}async function Io(r){let{aptosConfig:e,jwkAddr:t,options:n}=r,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await q({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 q({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,l=new R(m.fromHexInput(p).toUint8Array()),h=ci.deserialize(l);a.push(h)}o.set(Vi(s.issuer),a)}return o}var ci=class r extends y{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 R(m.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 Fc(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 re=class r extends se{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new B;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),L.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 N=class r extends se{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof Ge)this.variant=1;else if(e instanceof O)this.variant=3;else if(e instanceof re)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:n}=e;return $.isInstance(n)?this.publicKey.verifySignature({message:t,signature:n.signature}):!1}authKey(){return L.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=Ge.deserialize(e);break;case 3:n=O.deserialize(e);break;case 4:n=re.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 Ge}static isInstance(e){return"publicKey"in e&&"variant"in e}},$= exports.AnySignature =class r extends V{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof ht)this.variant=1;else if(e instanceof Ve)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=ht.deserialize(e);break;case 3:n=Ve.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 Gc(r){let e=r;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var ke=class r extends se{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 N?i:new N(i)),this.signaturesRequired=n}verifySignature(e){throw new Error("not implemented")}authKey(){return L.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(N),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 N?e:new N(e),n=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(n!==-1)return n;throw new Error(`Public key ${e} not found in MultiKey ${this.publicKeys}`)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},ue=class ue extends V{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ue.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof $?o:new $(o)),!(n instanceof Uint8Array))this.bitmap=ue.createBitmap({bits:n});else{if(n.length!==ue.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ue.BITMAP_LEN}`);this.bitmap=n}let i=this.bitmap.reduce((o,s)=>o+Gc(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>=ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ue.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($),n=e.deserializeBytes();return new ue({signatures:t,bitmap:n})}};ue.BITMAP_LEN=4,ue.MAX_SIGNATURES_SUPPORTED=ue.BITMAP_LEN*8;var qe=ue;var Z=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ie.load(e);case 1:return an.load(e);case 2:return ae.load(e);case 3:return ze.load(e);case 4:return Ht.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ie}isMultiEd25519(){return this instanceof an}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof ze}},Ie= exports.AccountAuthenticatorEd25519 =class r extends Z{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)}},an= exports.AccountAuthenticatorMultiEd25519 =class r extends Z{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=Gt.deserialize(e),n=At.deserialize(e);return new r(t,n)}},ae= exports.AccountAuthenticatorSingleKey =class r extends Z{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=N.deserialize(e),n=$.deserialize(e);return new r(t,n)}},ze= exports.AccountAuthenticatorMultiKey =class r extends Z{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=ke.deserialize(e),n=qe.deserialize(e);return new r(t,n)}},Ht= exports.AccountAuthenticatorNoAccountAuthenticator =class r extends Z{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}};var qt=class r extends y{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new r(t)}};var K=class r extends y{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new r(t)}};var cn=(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))},Jy= 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))},Xy= exports.createTokenAddress =(r,e,t)=>{let n=`${e}::${t}`;return cn(r,n)};var hr=class r extends y{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 K(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=K.deserialize(e);return new r(t,n)}};var F=class r extends y{deserialize(e){let t=u.deserialize(e),n=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(r);return new De(t,n,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return M.load(e);case 1:return pe.load(e);case 2:return j.load(e);case 3:return Qe.load(e);case 4:return ee.load(e);case 5:return _t.load(e);case 6:return C.load(e);case 7:return A.load(e);case 8:return $e.load(e);case 9:return We.load(e);case 10:return je.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof M}isAddress(){return this instanceof ee}isGeneric(){return this instanceof G}isSigner(){return this instanceof _t}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof pe}isU16(){return this instanceof $e}isU32(){return this instanceof We}isU64(){return this instanceof j}isU128(){return this instanceof Qe}isU256(){return this instanceof je}isPrimitive(){return this instanceof _t||this instanceof ee||this instanceof M||this instanceof pe||this instanceof $e||this instanceof We||this instanceof j||this instanceof Qe||this instanceof je}},M= exports.TypeTagBool =class r extends F{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new r}},pe= exports.TypeTagU8 =class r extends F{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new r}},$e= exports.TypeTagU16 =class r extends F{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new r}},We= exports.TypeTagU32 =class r extends F{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new r}},j= exports.TypeTagU64 =class r extends F{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new r}},Qe= exports.TypeTagU128 =class r extends F{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new r}},je= exports.TypeTagU256 =class r extends F{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new r}},ee= exports.TypeTagAddress =class r extends F{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}},_t= exports.TypeTagSigner =class r extends F{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new r}},un= exports.TypeTagReference =class r extends F{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let n=F.deserialize(t);return new r(n)}},G= exports.TypeTagGeneric =class r extends F{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 F{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new r(new pe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let n=F.deserialize(t);return new r(n)}},A= exports.TypeTagStruct =class r extends F{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=De.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")}},De= exports.StructTag =class r extends y{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=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(F);return new r(t,n,i,o)}};function bm(){return new De(u.ONE,new K("aptos_coin"),new K("AptosCoin"),[])}function v(){return new De(u.ONE,new K("string"),new K("String"),[])}function wm(r){return new De(u.ONE,new K("option"),new K("Option"),[r])}function de(r){return new De(u.ONE,new K("object"),new K("Object"),[r])}function Bc(r){let e=r.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(r);case 1:return Q.deserialize(r);case 2:return Ee.deserialize(r);case 3:return u.deserialize(r);case 4:return S.deserialize(r,X);case 5:return k.deserialize(r);case 6:return _e.deserialize(r);case 7:return xe.deserialize(r);case 8:return ye.deserialize(r);case 9:return dr.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var xt=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Et.load(e);case 2:return Tr.load(e);case 3:return br.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Et= exports.TransactionPayloadScript =class r extends xt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=wr.deserialize(e);return new r(t)}},Tr= exports.TransactionPayloadEntryFunction =class r extends xt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Pt.deserialize(e);return new r(t)}},br= exports.TransactionPayloadMultiSig =class r extends xt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Sr.deserialize(e);return new r(t)}},Pt= 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(hr.fromStr(e),new K(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=hr.deserialize(e),n=K.deserialize(e),i=e.deserializeVector(F),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=Qr.deserialize(e,c);s.push(p)}return new r(t,n,i,s)}},wr= 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(F),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Bc(e);o.push(a)}return new r(t,n,o)}},Sr= 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=_r.deserialize(e)),new r(t,i)}},_r= exports.MultiSigTransactionPayload =class r extends y{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(Pt.deserialize(e))}};var he=class r extends y{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=xt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=qt.deserialize(e);return new r(t,n,i,o,s,a,c)}},pn= exports.RawTransactionWithData =class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return vt.load(e);case 1:return It.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},vt= exports.MultiAgentRawTransaction =class r extends pn{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=he.deserialize(e),n=e.deserializeVector(u);return new r(t,n)}},It= exports.FeePayerRawTransaction =class r extends pn{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=he.deserialize(e),n=e.deserializeVector(u),i=u.deserialize(e);return new r(t,n,i)}};var dn=class extends y{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new x("account");this.structName=new x("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.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 Je=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ct.load(e);case 1:return ln.load(e);case 2:return Rt.load(e);case 3:return Kt.load(e);case 4:return st.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ct}isMultiEd25519(){return this instanceof ln}isMultiAgent(){return this instanceof Rt}isFeePayer(){return this instanceof Kt}isSingleSender(){return this instanceof st}},Ct= exports.TransactionAuthenticatorEd25519 =class r extends Je{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)}},ln= exports.TransactionAuthenticatorMultiEd25519 =class r extends Je{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=Gt.deserialize(e),n=At.deserialize(e);return new r(t,n)}},Rt= exports.TransactionAuthenticatorMultiAgent =class r extends Je{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=Z.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(Z);return new r(t,n,i)}},Kt= exports.TransactionAuthenticatorFeePayer =class r extends Je{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=Z.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(Z),o=u.deserialize(e),s=Z.deserialize(e),a={address:o,authenticator:s};return new r(t,n,i,a)}},st= exports.TransactionAuthenticatorSingleSender =class r extends Je{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=Z.deserialize(e);return new r(t)}};var Xe=class r extends y{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=he.deserialize(e),n=Je.deserialize(e);return new r(t,n)}};var $t=class r extends y{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=he.deserialize(e),n=e.deserializeBool(),i;return n&&(i=u.deserialize(e)),new r(t,i)}};var gn=class r extends y{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=he.deserialize(e),n=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new r(t,n,o)}};function ui(r){return r.feePayerAddress?new It(r.rawTransaction,_nullishCoalesce(r.secondarySignerAddresses, () => ([])),r.feePayerAddress):r.secondarySignerAddresses?new vt(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Wt(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 kf(r){return Wt(r.bcsToBytes(),`APTOS::${r.constructor.name}`)}function Qt(r){let e=ui(r);return r.feePayerAddress?Wt(e.bcsToBytes(),ri):r.secondarySignerAddresses?Wt(e.bcsToBytes(),ri):Wt(e.bcsToBytes(),ho)}var Te=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=H.generate();return new r({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:n}=e,i=H.fromDerivationPath(t,n);return new r({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new Ie(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ie(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Qt(e))}};function pi(r){return typeof r=="object"&&r!==null&&"getAnyPublicKey"in r&&typeof r.getAnyPublicKey=="function"}var be=class r{constructor(e){this.signingScheme=2;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=new N(t.publicKey()),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,n;switch(t){case 0:n=H.generate();break;case 2:n=Be.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=H.fromDerivationPath(n,i);break;case 2:o=Be.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 ae(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ae(this.publicKey,this.signTransaction(e))}sign(e){return new $(this.privateKey.sign(e))}signTransaction(e){return this.sign(Qt(e))}static fromEd25519Account(e){return new r({privateKey:e.privateKey,address:e.accountAddress})}};var at=class{static generate(e={}){let{scheme:t=0,legacy:n=!0}=e;return t===0&&n?Te.generate():be.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:n,legacy:i=!0}=e;return t instanceof H&&i?new Te({privateKey:t,address:n}):new be({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?Te.fromDerivationPath({mnemonic:n,path:i}):be.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 Vc=1209600,jt=class jt extends y{constructor(e){super();let{privateKey:t,expiryDateSecs:n,blinder:i}=e;this.privateKey=t,this.publicKey=new Tt(t.publicKey()),this.expiryDateSecs=n||_chunkIHUCZKG2js.e.call(void 0, _chunkIHUCZKG2js.d.call(void 0, )+Vc),this.blinder=i!==void 0?m.fromHexInput(i).toUint8Array():Hc();let o=Xn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(yr(this.blinder));let s=mr(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=H.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new jt({privateKey:n,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return jt.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _54 => _54.scheme])){case 0:default:t=H.generate()}return new jt({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _55 => _55.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Re(this.privateKey.sign(e))}};jt.BLINDER_LENGTH=31;var Ut=jt;function Hc(){return _utils.randomBytes.call(void 0, Ut.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function yn(r){return r!=null&&typeof r.checkKeylessAccountValidity=="function"}var Jt=class Jt extends y{constructor(t){super();this.signingScheme=2;let{address:n,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:p,proof:l,proofFetchCallback:h,jwt:g,verificationKeyHash:d}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=g,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof ve)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async U=>{await h(U),this.emitter.removeAllListeners()}),this.init(l)}let b=m.fromHexInput(p).toUint8Array();if(b.length!==Jt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Jt.PEPPER_LENGTH}`);if(this.pepper=b,d!==void 0){if(m.hexInputToUint8Array(d).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=m.hexInputToUint8Array(d)}}getAnyPublicKey(){return new N(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(n){n instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:n.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let n=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Ut.deserialize(t),c=ve.deserialize(t),p=t.deserializeOption("fixedBytes",32);return{address:n,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:p}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let n=new $(this.sign(t)),i=new N(this.publicKey);return new ae(i,n)}signTransactionWithAuthenticator(t){let n=new $(this.signTransaction(t)),i=new N(this.publicKey);return new ae(i,n)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw z.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw z.fromErrorType({type:2});let n=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(n.kid===void 0)throw z.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Ar({aptosConfig:t});if(m.hexInputToString(i.hash())!==m.hexInputToString(this.verificationKeyHash))throw z.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 Jt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:n.kid})}sign(t){let{expiryDateSecs:n}=this.ephemeralKeyPair;if(this.isExpired())throw z.fromErrorType({type:0});if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new Ve({jwtHeader:_chunkIHUCZKG2js.f.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Mt(this.proof,0),expiryDateSecs:n,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let n=ui(t),o=new di(n,this.proof.proof).hash();return this.sign(o)}verifySignature(t){let{message:n,signature:i}=t;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:n,signature:i.ephemeralSignature}))}static async fetchJWK(t){let{aptosConfig:n,publicKey:i,kid:o}=t,s=i instanceof O?i:i.keylessPublicKey,{iss:a}=s,c,p=i instanceof re?i.jwkAddress:void 0;try{c=await Io({aptosConfig:n,jwkAddr:p})}catch(g){throw z.fromErrorType({type:24,error:g,details:`Failed to fetch ${p?"Federated":"Patched"}JWKs ${p?`for address ${p}`:"0x1"}`})}let l=c.get(a);if(l===void 0)throw z.fromErrorType({type:7,details:`JWKs for issuer ${a} not found.`});let h=l.find(g=>g.kid===o);if(h===void 0)throw z.fromErrorType({type:6,details:`JWK with kid '${o}' for issuer '${a}' not found.`});return h}};Jt.PEPPER_LENGTH=31;var le=Jt,di= exports.TransactionAndProof =class extends y{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 Wt(this.bcsToBytes(),this.domainSeparator)}};var Ye=class r extends le{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}=le.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=He({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:h,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return r.deserialize(new R(m.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:l,aud:h,uidVal:g}=He({jwt:i,uidKey:a});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:g,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var kt=class r extends le{constructor(e){let t=re.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}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}=le.partialDeserialize(e),p=u.deserialize(e),{iss:l,aud:h,uidVal:g}=He({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:g,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return r.deserialize(R.fromHex(e))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:l}=e,{iss:h,aud:g,uidVal:d}=He({jwt:i,uidKey:c});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:d,aud:g,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var xr=class r{constructor(e){this.signingScheme=3;let{multiKey:t,address:n}=e,i=e.signers.map(a=>a instanceof Te?be.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.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 ke({publicKeys:t,signaturesRequired:n});return new r({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof r}signWithAuthenticator(e){return new ze(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ze(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(n=>n instanceof le).map(async n=>n.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let n=this.signers.filter(i=>i instanceof le).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 qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let n of this.signers)t.push(n.signTransaction(e));return new qe({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}};function Ro(r){let e=r.deserializeUleb128AsU32();if(!Object.values(oe).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(r),signingScheme:e}}function Ko(r,e){if(e.serializeStr(r.jwt),e.serializeStr(r.uidKey),e.serializeFixedBytes(r.pepper),r.ephemeralKeyPair.serialize(e),r.proof===void 0)throw new Error("Cannot serialize - proof undefined");r.proof.serialize(e),e.serializeOption(r.verificationKeyHash,32)}function Uo(r){let e=r.deserializeStr(),t=r.deserializeStr(),n=r.deserializeFixedBytes(31),i=Ut.deserialize(r),o=ve.deserialize(r),s=r.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:n,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var ko;(h=>{function r(g){let d=new B;switch(d.serializeU32AsUleb128(g.signingScheme),g.accountAddress.serialize(d),g.signingScheme){case 0:return g.privateKey.serialize(d),d.toUint8Array();case 2:{if(!pi(g))throw new Error("Account is not a SingleKeySigner");let b=g.getAnyPublicKey();switch(d.serializeU32AsUleb128(b.variant),b.variant){case 3:return Ko(g,d),d.toUint8Array();case 4:{let U=g;return Ko(U,d),U.publicKey.jwkAddress.serialize(d),d.serializeBool(U.audless),d.toUint8Array()}case 1:case 0:return g.privateKey.serialize(d),d.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=g;return b.publicKey.serialize(d),d.serializeU32AsUleb128(b.signers.length),b.signers.forEach(U=>{d.serializeFixedBytes(r(U))}),d.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${g.signingScheme}`)}}h.toBytes=r;function e(g){return m.hexInputToStringWithoutPrefix(r(g))}h.toHexStringWithoutPrefix=e;function t(g){return m.hexInputToString(r(g))}h.toHexString=t;function n(g){let{address:d,signingScheme:b}=Ro(g);switch(b){case 0:{let U=H.deserialize(g);return new Te({privateKey:U,address:d})}case 2:{let U=g.deserializeUleb128AsU32();switch(U){case 0:{let te=H.deserialize(g);return new be({privateKey:te,address:d})}case 1:{let te=Be.deserialize(g);return new be({privateKey:te,address:d})}case 3:{let te=Uo(g),dt=He(te);return new Ye({...te,...dt})}case 4:{let te=Uo(g),dt=u.deserialize(g),Dt=g.deserializeBool(),Ot=He(te);return new kt({...te,...Ot,jwkAddress:dt,audless:Dt})}default:throw new Error(`Unsupported public key variant ${U}`)}}case 3:{let U=ke.deserialize(g),te=g.deserializeUleb128AsU32(),dt=new Array;for(let Dt=0;Dt<te;Dt+=1){let Ot=n(g);if(!pi(Ot)&&!(Ot instanceof Te))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");dt.push(Ot)}return new xr({multiKey:U,signers:dt,address:d})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=n;function i(g){let d=p(g);if(!(d instanceof Ye))throw new Error("Deserialization of KeylessAccount failed");return d}h.keylessAccountFromHex=i;function o(g){let d=p(g);if(!(d instanceof kt))throw new Error("Deserialization of FederatedKeylessAccount failed");return d}h.federatedKeylessAccountFromHex=o;function s(g){let d=p(g);if(!(d instanceof xr))throw new Error("Deserialization of MultiKeyAccount failed");return d}h.multiKeyAccountFromHex=s;function a(g){let d=p(g);if(!(d instanceof be))throw new Error("Deserialization of SingleKeyAccount failed");return d}h.singleKeyAccountFromHex=a;function c(g){let d=p(g);if(!(d instanceof Te))throw new Error("Deserialization of Ed25519Account failed");return d}h.ed25519AccountFromHex=c;function p(g){return n(R.fromHex(g))}h.fromHex=p;function l(g){return p(g)}h.fromBytes=l})(ko||(ko= exports.AccountUtils ={}));var Wc=`
3
+ Details: ${i}`),r instanceof ye?o+=`
4
+ AptosApiError: ${r.message}`:r!==void 0&&(o+=`
5
+ Error: ${_chunkZYPBABLQjs.$.call(void 0, r)}`),o+=`
6
+ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=go[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},ye= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Ic({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function Ic({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _8 => _8.headers, 'optionalAccess', _9 => _9.traceparent, 'optionalAccess', _10 => _10.split, 'call', _11 => _11("-"), 'access', _12 => _12[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.errors, 'optionalAccess', _15 => _15[0], 'optionalAccess', _16 => _16.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.message])!=null&&_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${vc(t.data)}`}var jr=400;function vc(n){let e=JSON.stringify(n);return e.length<=jr?e:`truncated(original_size:${e.length}): ${e.slice(0,jr/2)}...${e.slice(-jr/2)}`}async function Cc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _21 => _21.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', _22 => _22.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _23 => _23.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _24 => _24.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _25 => _25.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a})}async function Yn(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Cc({...n,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:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ye({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ye({apiType:t,aptosRequest:n,aptosResponse:a})}async function Zn(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return Yn({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function L(n){let{aptosConfig:e}=n;return Zn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _26 => _26.clientConfig, 'optionalAccess', _27 => _27.HEADERS]),..._optionalChain([e, 'access', _28 => _28.fullnodeConfig, 'optionalAccess', _29 => _29.HEADERS])}}})}async function kl(n){return Zn({...n,type:"Pepper"})}async function er(n){let e=[],t,r=n.params;do{let i=await Zn({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function Jr(n){let e=[],t,r=n.params,i=r.limit;do{let o=await Zn({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});if(t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.offset=t,i!==void 0){let s=i-e.length;if(s<=0)break;r.limit=s}}while(t!=null);return e}async function pn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:d}=n,y=c.getRequestUrl(e);return Yn({url:y,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function it(n){let{aptosConfig:e}=n;return pn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _30 => _30.clientConfig, 'optionalAccess', _31 => _31.HEADERS]),..._optionalChain([e, 'access', _32 => _32.fullnodeConfig, 'optionalAccess', _33 => _33.HEADERS])}}})}async function mo(n){let{aptosConfig:e}=n;return pn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _34 => _34.clientConfig, 'optionalAccess', _35 => _35.HEADERS]),..._optionalChain([e, 'access', _36 => _36.indexerConfig, 'optionalAccess', _37 => _37.HEADERS])}}})}async function yo(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _38 => _38.clientConfig, 'optionalAccess', _39 => delete _39.API_KEY]),pn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([t, 'access', _42 => _42.faucetConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function fo(n){return pn({...n,type:"Pepper"})}async function Ao(n){return pn({...n,type:"Prover"})}var Xr=new Map;function Ce(n,e,t){return async(...r)=>{if(Xr.has(e)){let{value:o,timestamp:s}=Xr.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return Xr.set(e,{value:i,timestamp:Date.now()}),i}}var mg=1e7,Rc= exports.MAX_AUD_VAL_BYTES =120,Uc= exports.MAX_UID_KEY_BYTES =30,zc= exports.MAX_UID_VAL_BYTES =330,yg= exports.MAX_ISS_VAL_BYTES =120,fg= exports.MAX_EXTRA_FIELD_BYTES =350,Ag= exports.MAX_JWT_HEADER_B64_BYTES =300,hg= exports.MAX_COMMITED_EPK_BYTES =93,Ke=class Ke extends Y{constructor(e,t){super();let r=_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array();if(r.length!==Ke.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ke.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunkZYPBABLQjs.m;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(),r=e.deserializeBytes();return new Ke(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ke(t,r)}static isPublicKey(e){return e instanceof Ke}static create(e){return ho(e),new Ke(e.iss,ho(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,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 Ke.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ke.ID_COMMITMENT_LENGTH=32;var k=Ke;function ho(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[un(_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array()),Qn(r,Rc),Qn(t,zc),Qn(e,Uc)];return to(dn(o),k.ID_COMMITMENT_LENGTH)}var Me=class n extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Oc(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=Gt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=yt.deserialize(e),s=ve.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Gt(new Ee({proof:new Mt(new Bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new yt(new x(new Uint8Array(32))),ephemeralSignature:new ve(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Gt= exports.EphemeralCertificate =class n 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 n(Ee.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Be=class n extends _chunkZYPBABLQjs.l{constructor(e){if(super(),this.data=_chunkZYPBABLQjs.j.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 n(t)}},ht=class n extends _chunkZYPBABLQjs.l{constructor(e){if(super(),this.data=_chunkZYPBABLQjs.j.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 n(t)}},Bt= exports.Groth16Zkp =class n extends jn{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Be(t),this.b=new ht(r),this.c=new Be(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Be.deserialize(e).bcsToBytes(),r=ht.deserialize(e).bcsToBytes(),i=Be.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}},Mt= exports.ZkProof =class n extends _chunkZYPBABLQjs.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 n(Bt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},Ee= exports.ZeroKnowledgeSig =class n extends M{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new C(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=Mt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(ve);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Yr= exports.KeylessConfiguration =class n{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new n(new Zr({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},Zr= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Be(t),this.betaG2=new ht(r),this.deltaG2=new ht(i),this.gammaAbcG1=[new Be(o[0]),new Be(o[1])],this.gammaG2=new ht(s)}hash(){let e=new _chunkZYPBABLQjs.m;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 n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function ln(n){let{aptosConfig:e}=n;try{return await Ce(async()=>{let t=await Dc(n),r=await kc(n);return Yr.create(r,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof z?t:z.fromErrorType({type:25,error:t})}}function Ve(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw z.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkZYPBABLQjs.$.call(void 0, o)}`})}if(typeof r.iss!="string")throw z.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw z.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function Dc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await L({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunkZYPBABLQjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _44 => _44.ledgerVersion])}});return i.data}catch(i){throw z.fromErrorType({type:22,error:i})}}async function kc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await L({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunkZYPBABLQjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw z.fromErrorType({type:23,error:i})}}async function bo(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await L({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _46 => _46.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await L({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _47 => _47.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:d}=c.variant,y=new C(_chunkZYPBABLQjs.j.fromHexInput(d).toUint8Array()),h=ei.deserialize(y);a.push(h)}o.set(_chunkZYPBABLQjs.k.call(void 0, s.issuer),a)}return o}var ei=class n extends _chunkZYPBABLQjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,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,r=new C(_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:o,e:s})}};function Oc(n){try{let e=JSON.parse(n);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 te=class n extends Y{constructor(e,t){super(),this.jwkAddress=_chunkZYPBABLQjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunkZYPBABLQjs.m;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=_chunkZYPBABLQjs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}static create(e){return new n(e.jwkAddress,k.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,k.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunkZYPBABLQjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof k}};var O=class n extends Y{constructor(e){if(super(),this.publicKey=e,e instanceof x)this.variant=0;else if(e instanceof Fe)this.variant=1;else if(e instanceof k)this.variant=3;else if(e instanceof te)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return H.isInstance(r)?this.publicKey.verifySignature({message:t,signature:r.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(),r;switch(t){case 0:r=x.deserialize(e);break;case 1:r=Fe.deserialize(e);break;case 3:r=k.deserialize(e);break;case 4:r=te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof x}isSecp256k1PublicKey(){return this.publicKey instanceof Fe}static isInstance(e){return"publicKey"in e&&"variant"in e}},H= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof mt)this.variant=1;else if(e instanceof Me)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(),r;switch(t){case 0:r=I.deserialize(e);break;case 1:r=mt.deserialize(e);break;case 3:r=Me.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Fc(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Re=class n extends Y{constructor(e){super();let{publicKeys:t,signaturesRequired:r}=e;if(r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof O?i:new O(i)),this.signaturesRequired=r}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(O),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}createBitmap(e){let{bits:t}=e,r=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),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=e instanceof O?e:new O(e),r=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(r!==-1)return r;throw new Error(`Public key ${e} not found in MultiKey ${this.publicKeys}`)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},ce=class ce extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ce.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof H?o:new H(o)),!(r instanceof Uint8Array))this.bitmap=ce.createBitmap({bits:r});else{if(r.length!==ce.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ce.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Fc(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,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ce.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|=r>>s%8,i[a]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(H),r=e.deserializeBytes();return new ce({signatures:t,bitmap:r})}};ce.BITMAP_LEN=4,ce.MAX_SIGNATURES_SUPPORTED=ce.BITMAP_LEN*8;var qe=ce;var tr=(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,254]);return new (0, _chunkZYPBABLQjs.Z)(_sha3.sha3_256.call(void 0, i))},Am= exports.createResourceAddress =(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,255]);return new (0, _chunkZYPBABLQjs.Z)(_sha3.sha3_256.call(void 0, i))},hm= exports.createTokenAddress =(n,e,t)=>{let r=`${e}::${t}`;return tr(n,r)};var Q=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return xe.load(e);case 1:return nr.load(e);case 2:return ie.load(e);case 3:return Ue.load(e);case 4:return Vt.load(e);case 5:return gn.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof xe}isMultiEd25519(){return this instanceof nr}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof Ue}},xe= exports.AccountAuthenticatorEd25519 =class n extends Q{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=x.deserialize(e),r=I.deserialize(e);return new n(t,r)}},nr= exports.AccountAuthenticatorMultiEd25519 =class n extends Q{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=Ft.deserialize(e),r=gt.deserialize(e);return new n(t,r)}},ie= exports.AccountAuthenticatorSingleKey =class n extends Q{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=O.deserialize(e),r=H.deserialize(e);return new n(t,r)}},Ue= exports.AccountAuthenticatorMultiKey =class n extends Q{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=Re.deserialize(e),r=qe.deserialize(e);return new n(t,r)}},Vt= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends Q{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},gn= exports.AccountAuthenticatorAbstraction =class n extends Q{constructor(e,t,r){if(super(),!_chunkZYPBABLQjs.ia.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=_chunkZYPBABLQjs.j.fromHexInput(r),this.signingMessageDigest=_chunkZYPBABLQjs.j.fromHexInput(_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array())}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, this.functionInfo);_chunkZYPBABLQjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),e.serializeFixedBytes(this.authenticator.toUint8Array())}static load(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var qt=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var K=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var mn=class n extends _chunkZYPBABLQjs.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 n(_chunkZYPBABLQjs.Z.fromString(t[0]),new K(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e);return new n(t,r)}};var N=class n extends _chunkZYPBABLQjs.l{deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(n);return new ze(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return V.load(e);case 1:return ue.load(e);case 2:return j.load(e);case 3:return $e.load(e);case 4:return F.load(e);case 5:return Tt.load(e);case 6:return v.load(e);case 7:return A.load(e);case 8:return Le.load(e);case 9:return He.load(e);case 10:return We.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof V}isAddress(){return this instanceof F}isGeneric(){return this instanceof G}isSigner(){return this instanceof Tt}isVector(){return this instanceof v}isStruct(){return this instanceof A}isU8(){return this instanceof ue}isU16(){return this instanceof Le}isU32(){return this instanceof He}isU64(){return this instanceof j}isU128(){return this instanceof $e}isU256(){return this instanceof We}isPrimitive(){return this instanceof Tt||this instanceof F||this instanceof V||this instanceof ue||this instanceof Le||this instanceof He||this instanceof j||this instanceof $e||this instanceof We}},V= exports.TypeTagBool =class n extends N{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ue= exports.TypeTagU8 =class n extends N{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Le= exports.TypeTagU16 =class n extends N{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},He= exports.TypeTagU32 =class n extends N{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},j= exports.TypeTagU64 =class n extends N{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},$e= exports.TypeTagU128 =class n extends N{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},We= exports.TypeTagU256 =class n extends N{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},F= exports.TypeTagAddress =class n extends N{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Tt= exports.TypeTagSigner =class n extends N{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},rr= exports.TypeTagReference =class n extends N{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=N.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends N{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 r=t.deserializeU32();return new n(r)}},v= exports.TypeTagVector =class n extends N{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ue)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=N.deserialize(t);return new n(r)}},A= exports.TypeTagStruct =class n extends N{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.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 r=ze.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"object","Object")}},ze= exports.StructTag =class n extends _chunkZYPBABLQjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,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=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(N);return new n(t,r,i,o)}};function cy(){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("aptos_coin"),new K("AptosCoin"),[])}function P(){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("string"),new K("String"),[])}function uy(n){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("option"),new K("Option"),[n])}function de(n){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("object"),new K("Object"),[n])}function Nc(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return J.deserialize(n);case 1:return W.deserialize(n);case 2:return _e.deserialize(n);case 3:return _chunkZYPBABLQjs.Z.deserialize(n);case 4:return _.deserialize(n,J);case 5:return U.deserialize(n);case 6:return we.deserialize(n);case 7:return Se.deserialize(n);case 8:return le.deserialize(n);case 9:return sn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var bt=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return wt.load(e);case 2:return yn.load(e);case 3:return fn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},wt= exports.TransactionPayloadScript =class n extends bt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=An.deserialize(e);return new n(t)}},yn= exports.TransactionPayloadEntryFunction =class n extends bt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=St.deserialize(e);return new n(t)}},fn= exports.TransactionPayloadMultiSig =class n extends bt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=hn.deserialize(e);return new n(t)}},St= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(mn.fromStr(e),new K(t),r,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=mn.deserialize(e),r=K.deserialize(e),i=e.deserializeVector(N),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=Hn.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},An= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}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(),r=e.deserializeVector(N),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Nc(e);o.push(a)}return new n(t,r,o)}},hn= exports.MultiSig =class n{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=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Tn.deserialize(e)),new n(t,i)}},Tn= exports.MultiSigTransactionPayload =class n extends _chunkZYPBABLQjs.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 n(St.deserialize(e))}};var fe=class n extends _chunkZYPBABLQjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,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=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeU64(),i=bt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=qt.deserialize(e);return new n(t,r,i,o,s,a,c)}},ir= exports.RawTransactionWithData =class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _t.load(e);case 1:return Pt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},_t= exports.MultiAgentRawTransaction =class n extends ir{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=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z);return new n(t,r)}},Pt= exports.FeePayerRawTransaction =class n extends ir{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}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=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=_chunkZYPBABLQjs.Z.deserialize(e);return new n(t,r,i)}};var or=class extends _chunkZYPBABLQjs.l{constructor(t){super();this.accountAddress=_chunkZYPBABLQjs.Z.ONE;this.moduleName=new E("account");this.structName=new E("RotationProofChallenge");this.sequenceNumber=new W(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=_.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 Qe=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Et.load(e);case 1:return sr.load(e);case 2:return xt.load(e);case 3:return It.load(e);case 4:return ot.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Et}isMultiEd25519(){return this instanceof sr}isMultiAgent(){return this instanceof xt}isFeePayer(){return this instanceof It}isSingleSender(){return this instanceof ot}},Et= exports.TransactionAuthenticatorEd25519 =class n extends Qe{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=x.deserialize(e),r=I.deserialize(e);return new n(t,r)}},sr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Qe{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=Ft.deserialize(e),r=gt.deserialize(e);return new n(t,r)}},xt= exports.TransactionAuthenticatorMultiAgent =class n extends Qe{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}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=Q.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeVector(Q);return new n(t,r,i)}},It= exports.TransactionAuthenticatorFeePayer =class n extends Qe{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,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=Q.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeVector(Q),o=_chunkZYPBABLQjs.Z.deserialize(e),s=Q.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ot= exports.TransactionAuthenticatorSingleSender =class n extends Qe{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=Q.deserialize(e);return new n(t)}};var je=class n extends _chunkZYPBABLQjs.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=fe.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}};var Lt=class n extends _chunkZYPBABLQjs.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=fe.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunkZYPBABLQjs.Z.deserialize(e)),new n(t,i)}};var ar=class n extends _chunkZYPBABLQjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,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=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunkZYPBABLQjs.Z.deserialize(e)),new n(t,r,o)}};function ti(n){return n.feePayerAddress?new Pt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new _t(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Ht(n,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 r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function wf(n){return Ht(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Je(n){let e=ti(n);return n.feePayerAddress?Ht(e.bcsToBytes(),Qr):n.secondarySignerAddresses?Ht(e.bcsToBytes(),Qr):Ht(e.bcsToBytes(),uo)}var Ae=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new xe(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new xe(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Je(e))}};function ni(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var he=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new O(t.publicKey()),this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=Ne.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=Ne.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({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 H(this.privateKey.sign(e))}signTransaction(e){return this.sign(Je(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var De=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Ae.generate():he.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new Ae({privateKey:t,address:r}):new he({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?Ae.fromDerivationPath({mnemonic:r,path:i}):he.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var _utils = require('@noble/hashes/utils');var Mc=1209600,$t=class $t extends _chunkZYPBABLQjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new yt(t.publicKey()),this.expiryDateSecs=r||_chunkZYPBABLQjs.ba.call(void 0, _chunkZYPBABLQjs.aa.call(void 0, )+Mc),this.blinder=i!==void 0?_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array():Vc();let o=qr(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(un(this.blinder));let s=dn(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(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new $t({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return $t.deserialize(new C(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _48 => _48.scheme])){case 0:default:t=q.generate()}return new $t({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _49 => _49.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new ve(this.privateKey.sign(e))}};$t.BLINDER_LENGTH=31;var vt=$t;function Vc(){return _utils.randomBytes.call(void 0, vt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function cr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Wt=class Wt extends _chunkZYPBABLQjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:y,proofFetchCallback:h,jwt:p,verificationKeyHash:l}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new _eventemitter32.default,this.proofOrPromise=y,y instanceof Ee)this.proof=y;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async R=>{await h(R),this.emitter.removeAllListeners()}),this.init(y)}let b=_chunkZYPBABLQjs.j.fromHexInput(d).toUint8Array();if(b.length!==Wt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Wt.PEPPER_LENGTH}`);if(this.pepper=b,l!==void 0){if(_chunkZYPBABLQjs.j.hexInputToUint8Array(l).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunkZYPBABLQjs.j.hexInputToUint8Array(l)}}getAnyPublicKey(){return new O(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunkZYPBABLQjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=vt.deserialize(t),c=Ee.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new H(this.sign(t)),i=new O(this.publicKey);return new ie(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new O(this.publicKey);return new ie(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw z.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw z.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw z.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await ln({aptosConfig:t});if(_chunkZYPBABLQjs.j.hexInputToString(i.hash())!==_chunkZYPBABLQjs.j.hexInputToString(this.verificationKeyHash))throw z.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 Wt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw z.fromErrorType({type:0});if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new Me({jwtHeader:_chunkZYPBABLQjs.ca.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Gt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=ti(t),o=new ri(r,this.proof.proof).hash();return this.sign(o)}verifySignature(t){let{message:r,signature:i}=t;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:r,signature:i.ephemeralSignature}))}static async fetchJWK(t){let{aptosConfig:r,publicKey:i,kid:o}=t,s=i instanceof k?i:i.keylessPublicKey,{iss:a}=s,c,d=i instanceof te?i.jwkAddress:void 0;try{c=await bo({aptosConfig:r,jwkAddr:d})}catch(p){throw z.fromErrorType({type:24,error:p,details:`Failed to fetch ${d?"Federated":"Patched"}JWKs ${d?`for address ${d}`:"0x1"}`})}let y=c.get(a);if(y===void 0)throw z.fromErrorType({type:7,details:`JWKs for issuer ${a} not found.`});let h=y.find(p=>p.kid===o);if(h===void 0)throw z.fromErrorType({type:6,details:`JWK with kid '${o}' for issuer '${a}' not found.`});return h}};Wt.PEPPER_LENGTH=31;var pe=Wt,ri= exports.TransactionAndProof =class extends _chunkZYPBABLQjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Ht(this.bcsToBytes(),this.domainSeparator)}};var Xe=class n extends pe{constructor(e){let t=k.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=pe.partialDeserialize(e),{iss:d,aud:y,uidVal:h}=Ve({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:h,aud:y,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new C(_chunkZYPBABLQjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d}=e,{iss:y,aud:h,uidVal:p}=Ve({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:y,uidKey:a,uidVal:p,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:d?d.hash():void 0})}};var Ct=class n extends pe{constructor(e){let t=te.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=pe.partialDeserialize(e),d=_chunkZYPBABLQjs.Z.deserialize(e),{iss:y,aud:h,uidVal:p}=Ve({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:y,uidKey:s,uidVal:p,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(C.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:y}=e,{iss:h,aud:p,uidVal:l}=Ve({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:l,aud:p,pepper:s,jwkAddress:_chunkZYPBABLQjs.Z.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:y?y.hash():void 0})}};var bn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof Ae?he.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.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:r,signers:i}=e,o=new Re({publicKeys:t,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ue(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ue(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof pe).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof pe).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new qe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:r}=e;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:t,signature:s}))return!1}return!0}};function So(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunkZYPBABLQjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunkZYPBABLQjs.Z.deserialize(n),signingScheme:e}}function _o(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Po(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=vt.deserialize(n),o=Ee.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Eo;(h=>{function n(p){let l=new _chunkZYPBABLQjs.m;switch(l.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(l),p.signingScheme){case 0:return p.privateKey.serialize(l),l.toUint8Array();case 2:{if(!ni(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(l.serializeU32AsUleb128(b.variant),b.variant){case 3:return _o(p,l),l.toUint8Array();case 4:{let R=p;return _o(R,l),R.publicKey.jwkAddress.serialize(l),l.serializeBool(R.audless),l.toUint8Array()}case 1:case 0:return p.privateKey.serialize(l),l.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(l),l.serializeU32AsUleb128(b.signers.length),b.signers.forEach(R=>{l.serializeFixedBytes(n(R))}),l.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}h.toBytes=n;function e(p){return _chunkZYPBABLQjs.j.hexInputToStringWithoutPrefix(n(p))}h.toHexStringWithoutPrefix=e;function t(p){return _chunkZYPBABLQjs.j.hexInputToString(n(p))}h.toHexString=t;function r(p){let{address:l,signingScheme:b}=So(p);switch(b){case 0:{let R=q.deserialize(p);return new Ae({privateKey:R,address:l})}case 2:{let R=p.deserializeUleb128AsU32();switch(R){case 0:{let ee=q.deserialize(p);return new he({privateKey:ee,address:l})}case 1:{let ee=Ne.deserialize(p);return new he({privateKey:ee,address:l})}case 3:{let ee=Po(p),ct=Ve(ee);return new Xe({...ee,...ct})}case 4:{let ee=Po(p),ct=_chunkZYPBABLQjs.Z.deserialize(p),Ut=p.deserializeBool(),zt=Ve(ee);return new Ct({...ee,...zt,jwkAddress:ct,audless:Ut})}default:throw new Error(`Unsupported public key variant ${R}`)}}case 3:{let R=Re.deserialize(p),ee=p.deserializeUleb128AsU32(),ct=new Array;for(let Ut=0;Ut<ee;Ut+=1){let zt=r(p);if(!ni(zt)&&!(zt instanceof Ae))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");ct.push(zt)}return new bn({multiKey:R,signers:ct,address:l})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=r;function i(p){let l=d(p);if(!(l instanceof Xe))throw new Error("Deserialization of KeylessAccount failed");return l}h.keylessAccountFromHex=i;function o(p){let l=d(p);if(!(l instanceof Ct))throw new Error("Deserialization of FederatedKeylessAccount failed");return l}h.federatedKeylessAccountFromHex=o;function s(p){let l=d(p);if(!(l instanceof bn))throw new Error("Deserialization of MultiKeyAccount failed");return l}h.multiKeyAccountFromHex=s;function a(p){let l=d(p);if(!(l instanceof he))throw new Error("Deserialization of SingleKeyAccount failed");return l}h.singleKeyAccountFromHex=a;function c(p){let l=d(p);if(!(l instanceof Ae))throw new Error("Deserialization of Ed25519Account failed");return l}h.ed25519AccountFromHex=c;function d(p){return r(C.fromHex(p))}h.fromHex=d;function y(p){return d(p)}h.fromBytes=y})(Eo||(Eo= exports.AccountUtils ={}));var wn=class n extends M{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.fromHexInput(e)}serialize(e){e.serializeBytes(this.value.toUint8Array())}static deserialize(e){return new n(e.deserializeBytes())}},ur=class extends Y{constructor(e){super(),this.accountAddress=e}authKey(){return new B({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var Io=class n extends De{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunkZYPBABLQjs.ia.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new ur(this.accountAddress),this.sign=o=>new wn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunkZYPBABLQjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new gn(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Je(t))}signTransaction(t){return this.sign(Je(t))}setSigner(t){this.sign=r=>new wn(t(r))}};var Hc=`
9
7
  fragment TokenActivitiesFields on token_activities_v2 {
10
8
  after_value
11
9
  before_value
@@ -23,7 +21,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
23
21
  transaction_version
24
22
  type
25
23
  }
26
- `,Qc=`
24
+ `,$c=`
27
25
  fragment AnsTokenFragment on current_aptos_names {
28
26
  domain
29
27
  expiration_timestamp
@@ -35,7 +33,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
35
33
  subdomain_expiration_policy
36
34
  domain_expiration_timestamp
37
35
  }
38
- `,mn=`
36
+ `,dr=`
39
37
  fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
40
38
  token_standard
41
39
  token_properties_mutated_v1
@@ -82,7 +80,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
82
80
  }
83
81
  }
84
82
  }
85
- `,zo=`
83
+ `,vo=`
86
84
  query getAccountCoinsCount($address: String) {
87
85
  current_fungible_asset_balances_aggregate(
88
86
  where: {owner_address: {_eq: $address}}
@@ -92,7 +90,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
92
90
  }
93
91
  }
94
92
  }
95
- `,Do=`
93
+ `,Co=`
96
94
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
97
95
  current_fungible_asset_balances(
98
96
  where: $where_condition
@@ -125,7 +123,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
125
123
  }
126
124
  }
127
125
  }
128
- `,Oo=`
126
+ `,Ko=`
129
127
  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
128
  current_collection_ownership_v2_view(
131
129
  where: $where_condition
@@ -159,7 +157,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
159
157
  single_token_uri
160
158
  }
161
159
  }
162
- `,No=`
160
+ `,Ro=`
163
161
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
164
162
  current_token_ownerships_v2(
165
163
  where: $where_condition
@@ -170,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
170
168
  ...CurrentTokenOwnershipFields
171
169
  }
172
170
  }
173
- ${mn}`,qh=`
171
+ ${dr}`,Jh=`
174
172
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
175
173
  current_token_ownerships_v2(
176
174
  where: $where_condition
@@ -181,7 +179,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
181
179
  ...CurrentTokenOwnershipFields
182
180
  }
183
181
  }
184
- ${mn}`,Fo=`
182
+ ${dr}`,Uo=`
185
183
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
186
184
  current_token_ownerships_v2(
187
185
  where: $where_condition
@@ -192,7 +190,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
192
190
  ...CurrentTokenOwnershipFields
193
191
  }
194
192
  }
195
- ${mn}`,Go=`
193
+ ${dr}`,zo=`
196
194
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
197
195
  current_token_ownerships_v2_aggregate(
198
196
  where: $where_condition
@@ -204,7 +202,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
204
202
  }
205
203
  }
206
204
  }
207
- `,Bo=`
205
+ `,Do=`
208
206
  query getAccountTransactionsCount($address: String) {
209
207
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
210
208
  aggregate {
@@ -212,13 +210,13 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
212
210
  }
213
211
  }
214
212
  }
215
- `,Mo=`
213
+ `,ko=`
216
214
  query getChainTopUserTransactions($limit: Int) {
217
215
  user_transactions(limit: $limit, order_by: {version: desc}) {
218
216
  version
219
217
  }
220
218
  }
221
- `,Lo=`
219
+ `,Oo=`
222
220
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
223
221
  current_collections_v2(where: $where_condition) {
224
222
  uri
@@ -248,7 +246,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
248
246
  }
249
247
  }
250
248
  }
251
- `,Vo=`
249
+ `,Fo=`
252
250
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
253
251
  current_fungible_asset_balances(
254
252
  where: $where_condition
@@ -266,7 +264,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
266
264
  token_standard
267
265
  }
268
266
  }
269
- `,Ho=`
267
+ `,No=`
270
268
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
271
269
  delegated_staking_activities(
272
270
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -279,7 +277,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
279
277
  transaction_version
280
278
  }
281
279
  }
282
- `,qo=`
280
+ `,Go=`
283
281
  query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
284
282
  events(
285
283
  where: $where_condition
@@ -298,7 +296,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
298
296
  indexed_type
299
297
  }
300
298
  }
301
- `,$o=`
299
+ `,Bo=`
302
300
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
303
301
  fungible_asset_activities(
304
302
  where: $where_condition
@@ -323,7 +321,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
323
321
  type
324
322
  }
325
323
  }
326
- `,Wo=`
324
+ `,Mo=`
327
325
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
328
326
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
329
327
  icon_uri
@@ -342,7 +340,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
342
340
  maximum_v2
343
341
  }
344
342
  }
345
- `,Xt=`
343
+ `,Qt=`
346
344
  query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
347
345
  current_aptos_names(
348
346
  limit: $limit
@@ -353,14 +351,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
353
351
  ...AnsTokenFragment
354
352
  }
355
353
  }
356
- ${Qc}`,li=`
354
+ ${$c}`,ii=`
357
355
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
358
356
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
359
357
  num_active_delegator
360
358
  pool_address
361
359
  }
362
360
  }
363
- `,fn=`
361
+ `,pr=`
364
362
  query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
365
363
  current_objects(
366
364
  where: $where_condition
@@ -377,7 +375,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
377
375
  is_deleted
378
376
  }
379
377
  }
380
- `,gi=`
378
+ `,oi=`
381
379
  query getProcessorStatus($where_condition: processor_status_bool_exp) {
382
380
  processor_status(where: $where_condition) {
383
381
  last_success_version
@@ -385,7 +383,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
385
383
  last_updated
386
384
  }
387
385
  }
388
- `,Qo=`
386
+ `,Vo=`
389
387
  query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
390
388
  table_items(
391
389
  where: $where_condition
@@ -401,7 +399,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
401
399
  write_set_change_index
402
400
  }
403
401
  }
404
- `,jo=`
402
+ `,qo=`
405
403
  query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
406
404
  table_metadatas(
407
405
  where: $where_condition
@@ -414,7 +412,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
414
412
  value_type
415
413
  }
416
414
  }
417
- `,Jo=`
415
+ `,Lo=`
418
416
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
419
417
  token_activities_v2(
420
418
  where: $where_condition
@@ -425,7 +423,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
425
423
  ...TokenActivitiesFields
426
424
  }
427
425
  }
428
- ${Wc}`,yi=`
426
+ ${Hc}`,si=`
429
427
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
430
428
  current_token_ownerships_v2(
431
429
  where: $where_condition
@@ -436,7 +434,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
436
434
  ...CurrentTokenOwnershipFields
437
435
  }
438
436
  }
439
- ${mn}`,Xo=`
437
+ ${dr}`,Ho=`
440
438
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
441
439
  current_token_datas_v2(
442
440
  where: $where_condition
@@ -476,7 +474,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
476
474
  }
477
475
  }
478
476
  }
479
- `;async function An(r){let{aptosConfig:e}=r,{data:t}=await q({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function Yo(r){let{aptosConfig:e,limit:t}=r;return(await T({aptosConfig:e,query:{query:Mo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function T(r){let{aptosConfig:e,query:t,originMethod:n}=r,{data:i}=await So({aptosConfig:e,originMethod:_nullishCoalesce(n, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function jc(r){let{aptosConfig:e}=r;return(await T({aptosConfig:e,query:{query:gi},originMethod:"getProcessorStatuses"})).processor_status}async function hn(r){let e=await jc({aptosConfig:r.aptosConfig});return BigInt(e[0].last_success_version)}async function Tn(r){let{aptosConfig:e,processorType:t}=r;return(await T({aptosConfig:e,query:{query:gi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function bn(r){let{aptosConfig:e,handle:t,data:n,options:i}=r;return(await ot({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _56 => _56.ledgerVersion])},body:n})).data}async function Zo(r){let{aptosConfig:e,options:t}=r,n={query:Qo,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 T({aptosConfig:e,query:n,originMethod:"getTableItemsData"})).table_items}async function es(r){let{aptosConfig:e,options:t}=r,n={query:jo,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 T({aptosConfig:e,query:n,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Oe(r){let{aptosConfig:e,accountAddress:t}=r,{data:n}=await q({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return n}async function ns(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return ii({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _65 => _65.ledgerVersion]),offset:_optionalChain([n, 'optionalAccess', _66 => _66.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _67 => _67.limit]), () => (1e3))}})}async function wn(r){return _optionalChain([r, 'access', _68 => _68.options, 'optionalAccess', _69 => _69.ledgerVersion])!==void 0?ts(r):Ke(async()=>ts(r),`module-${r.accountAddress}-${r.moduleName}`,1e3*60*5)()}async function ts(r){let{aptosConfig:e,accountAddress:t,moduleName:n,options:i}=r,{data:o}=await q({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 is(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return sn({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 os(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return ii({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _73 => _73.ledgerVersion]),offset:_optionalChain([n, 'optionalAccess', _74 => _74.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _75 => _75.limit]), () => (999))}})}async function mi(r){let{aptosConfig:e,accountAddress:t,resourceType:n,options:i}=r,{data:o}=await q({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 Yt(r){let{aptosConfig:e,authenticationKey:t,options:n}=r,i=await mi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:n}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await bn({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 Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function ss(r){let{aptosConfig:e,accountAddress:t}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await T({aptosConfig:e,query:{query:Go,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 as(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:No,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 T({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function cs(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:Fo,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 T({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function us(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:Oo,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 T({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function ps(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:Bo,variables:{address:n}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function ds(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:Do,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 T({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function ls(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:zo,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 gs(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:fn,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 T({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function ys(r){let{aptosConfig:e,privateKey:t}=r,n=new N(t.publicKey());if(t instanceof Be){let o=L.fromPublicKey({publicKey:n}).derivedAddress();return at.fromPrivateKey({privateKey:t,address:o})}if(t instanceof H){let i=L.fromPublicKey({publicKey:n});if(await rs({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return at.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=L.fromPublicKey({publicKey:n.publicKey});if(await rs({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return at.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function rs(r){let{aptosConfig:e,authKey:t}=r,n=await Yt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Oe({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 sn({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _99 => _99.offset]),limit:_optionalChain([t, 'optionalAccess', _100 => _100.limit])}})}async function _n(r){let{aptosConfig:e}=r;return Ke(async()=>{let{data:t}=await q({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ms(r){let{aptosConfig:e,ledgerVersion:t}=r,{data:n}=await q({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return n}async function Er(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await q({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return n}async function fs(r){let{aptosConfig:e,transactionHash:t}=r;try{return(await Er({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(n){if(_optionalChain([n, 'optionalAccess', _101 => _101.status])===404)return!0;throw n}}async function Jc(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await q({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return n}async function Zt(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,l=200,h=1.5;function g(d){if(!(d instanceof Ae)||(p=d,d.status!==404&&d.status>=400&&d.status<500))throw d}try{c=await Er({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(d){g(d)}if(s){let d=Date.now();try{c=await Jc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){g(b)}a=(Date.now()-d)/1e3}for(;s&&!(a>=i);){try{if(c=await Er({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(d){g(d)}await _chunkIHUCZKG2js.b.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Sn(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Sn(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new fi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function xn(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 hn({aptosConfig:e}):s=(await Tn({aptosConfig:e,processorType:t})).last_success_version,s>=n)break;await _chunkIHUCZKG2js.b.call(void 0, 200)}}var Sn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},fi=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 q({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _104 => _104.withTransactions])}});return Ts({block:i,...r})}async function hs(r){let{aptosConfig:e,blockHeight:t,options:n}=r,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _105 => _105.withTransactions])}});return Ts({block:i,...r})}async function Ts(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=[],l=100n;for(let g=c+1n;g<s;g+=BigInt(100))p.push(Ai({aptosConfig:e,options:{offset:g,limit:Math.min(Number(l),Number(s-g+1n))}}));let h=await Promise.all(p);for(let g of h)t.transactions.push(...g)}return t}async function w(r){r.minimumLedgerVersion!==void 0&&await xn({aptosConfig:r.config,minimumLedgerVersion:r.minimumLedgerVersion,processorType:r.processorType})}function bs(r){return typeof r=="boolean"}function ct(r){return typeof r=="string"}function Xc(r){return typeof r=="number"}function En(r){if(Xc(r))return r;if(ct(r)&&r!=="")return Number.parseInt(r,10)}function Pn(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function ws(r){return r==null}function Ss(r){return hi(r)||bi(r)||wi(r)||Si(r)||_i(r)||xi(r)||Ei(r)||vn(r)||Ti(r)||Yc(r)||r instanceof S||r instanceof Y}function hi(r){return r instanceof k}function vn(r){return r instanceof u}function Ti(r){return r instanceof x}function Yc(r){return r instanceof mt}function bi(r){return r instanceof X}function wi(r){return r instanceof _e}function Si(r){return r instanceof xe}function _i(r){return r instanceof Q}function xi(r){return r instanceof Ee}function Ei(r){return r instanceof ye}function _s(r){return"bytecode"in r}function D(r,e){throw new Error(`Type mismatch for argument ${e}, expected '${r}'`)}function xs(r){let e=r.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?r.params.length:e}function zt(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 Es(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function Ps(r){return!!r.match(/\s/)}function Zc(r){return!!r.match(/^T[0-9]+$/)}function eu(r){return!!r.match(/^&.+$/)}function tu(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 ru(r,e){let t=e;for(;t<r.length;t+=1){let n=r[t];if(!Ps(n))break}return t}var nu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(nu||{}),W= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ne(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 b=Pr(a,i,t);o.push(b)}let l=n.pop();if(l===void 0)throw new W(r,"unexpected '>'");if(c!==o.length)throw new W(r,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:g,savedExpectedTypes:d}=l;i=o,o=g,a=h,c=d}else if(p===","){if(n.length===0)throw new W(r,"unexpected ','");if(a.length===0)throw new W(r,"no type argument before ','");let l=Pr(a,i,t);i=[],o.push(l),a="",c+=1}else if(Ps(p)){let l=!1;if(a.length!==0){let g=Pr(a,i,t);i=[],o.push(g),a="",l=!0}s=ru(r,s);let h=r[s];if(s<r.length&&l&&h!==","&&h!==">")throw new W(r,"unexpected whitespace character");continue}else a+=p;s+=1}if(n.length>0)throw new W(r,"no matching '>' for '<'");switch(o.length){case 0:return Pr(a,i,t);case 1:if(a==="")return o[0];throw new W(r,"unexpected ','");default:throw new W(r,"unexpected whitespace character")}}function Pr(r,e,t){let n=r.trim(),i=n.toLowerCase();if(tu(i)&&e.length>0)throw new W(r,"primitive types not expected to have type arguments");switch(n.toLowerCase()){case"signer":return new _t;case"bool":return new M;case"address":return new ee;case"u8":return new pe;case"u16":return new $e;case"u32":return new We;case"u64":return new j;case"u128":return new Qe;case"u256":return new je;case"vector":if(e.length!==1)throw new W(r,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(eu(n)){let a=n.substring(1);return new un(Pr(a,e,t))}if(Zc(n)){if(t)return new G(Number(n.split("T")[1]));throw new W(r,"unexpected generic type")}if(!n.match(/:/))throw new W(r,"unknown type");let o=n.split("::");if(o.length!==3)throw new W(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 W(r,"struct address must be valid")}if(!Es(o[1]))throw new W(r,"module name must only contain alphanumeric or '_' characters");if(!Es(o[2]))throw new W(r,"struct name must only contain alphanumeric or '_' characters");return new A(new De(s,new K(o[1]),new K(o[2]),e))}}var iu=new TextEncoder;function tr(r){return _nullishCoalesce(_optionalChain([r, 'optionalAccess', _109 => _109.map, 'call', _110 => _110(e=>ct(e)?Ne(e):e)]), () => ([]))}async function vi(r,e,t,n){let i=await wn({aptosConfig:n,accountAddress:r,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function vs(r,e,t,n){let i=await vi(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(Ne(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Is(r,e,t,n){let i=await vi(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=xs(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ne(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Cs(r,e,t,n){let i=await vi(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(Ne(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ne(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Rs(r,e,t,n,i){return r instanceof _scriptcomposerpack.CallArgument?r:_scriptcomposerpack.CallArgument.newBytes(In(e,t,r,n,i).bcsToBytes())}function In(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 er(t,o,n,i)}function er(r,e,t,n){return Ss(r)?(Pi(e,r,t),r):ou(r,e,t,n)}function ou(r,e,t,n){if(e.isBool()){if(bs(r))return new k(r);if(ct(r)){if(r==="true")return new k(!0);if(r==="false")return new k(!1)}D("boolean",t)}if(e.isAddress()){if(ct(r))return u.fromString(r);D("string | AccountAddress",t)}if(e.isU8()){let i=En(r);if(i!==void 0)return new X(i);D("number | string",t)}if(e.isU16()){let i=En(r);if(i!==void 0)return new _e(i);D("number | string",t)}if(e.isU32()){let i=En(r);if(i!==void 0)return new xe(i);D("number | string",t)}if(e.isU64()){if(Pn(r))return new Q(BigInt(r));D("bigint | number | string",t)}if(e.isU128()){if(Pn(r))return new Ee(BigInt(r));D("bigint | number | string",t)}if(e.isU256()){if(Pn(r))return new ye(BigInt(r));D("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 er(r,n[i],t,n)}if(e.isVector()){if(e.value.isU8()){if(ct(r))return S.U8(iu.encode(r));if(r instanceof Uint8Array)return S.U8(r);if(r instanceof ArrayBuffer)return S.U8(new Uint8Array(r))}if(Array.isArray(r))return new S(r.map(i=>er(i,e.value,t,n)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(ct(r))return new x(r);D("string",t)}if(e.isObject()){if(ct(r))return u.fromString(r);D("string | AccountAddress",t)}if(e.isOption()){if(ws(r)){let i=e.value.typeArgs[0];return i instanceof M?new Y(null):i instanceof ee?new Y(null):i instanceof pe?new Y(null):i instanceof $e?new Y(null):i instanceof We?new Y(null):i instanceof j?new Y(null):i instanceof Qe?new Y(null):i instanceof je?new Y(null):new Y(null)}return new Y(er(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 Pi(r,e,t){if(r.isBool()){if(hi(e))return;D("Bool",t)}if(r.isAddress()){if(vn(e))return;D("AccountAddress",t)}if(r.isU8()){if(bi(e))return;D("U8",t)}if(r.isU16()){if(wi(e))return;D("U16",t)}if(r.isU32()){if(Si(e))return;D("U32",t)}if(r.isU64()){if(_i(e))return;D("U64",t)}if(r.isU128()){if(xi(e))return;D("U128",t)}if(r.isU256()){if(Ei(e))return;D("U256",t)}if(r.isVector()){if(e instanceof S){e.values.length>0&&Pi(r.value,e.values[0],t);return}D("MoveVector",t)}if(r instanceof A){if(r.isString()){if(Ti(e))return;D("MoveString",t)}if(r.isObject()){if(vn(e))return;D("AccountAddress",t)}if(r.isOption()){if(e instanceof Y){e.value!==void 0&&Pi(r.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${r.toString()}'`)}async function Cn(r){if(_s(r))return uu(r);let{moduleAddress:e,moduleName:t,functionName:n}=zt(r.function),i=await zs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:Is});return au({...r,abi:i})}function au(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=zt(r.function),o=tr(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)=>In(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=Pt.build(`${t}::${n}`,i,o,s);if("multisigAddress"in r){let c=u.from(r.multisigAddress);return new br(new Sr(c,new _r(a)))}return new Tr(a)}async function Ks(r){let{moduleAddress:e,moduleName:t,functionName:n}=zt(r.function),i=await zs({key:"view-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:Cs});return cu({abi:i,...r})}function cu(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=zt(r.function),o=tr(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)=>In(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 Pt.build(`${t}::${n}`,i,o,s)}function uu(r){return new Et(new wr(m.fromHexInput(r.bytecode).toUint8Array(),tr(r.typeArguments),r.functionArguments))}async function Ii(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=async()=>ti[e.network]?{chainId:ti[e.network]}:{chainId:(await An({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _114 => _114.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await _n({aptosConfig:e})).gas_estimate},c=async()=>{let U=async()=>_optionalChain([i, 'optionalAccess', _115 => _115.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Oe({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await U()}catch (e4){return 0}else return U()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:g,gasUnitPrice:d,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _116 => _116.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _117 => _117.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _118 => _118.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new he(u.from(t),BigInt(h),n,BigInt(g),BigInt(d),BigInt(b),new qt(p))}async function Ci(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=await Ii({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 gn(s,a,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}return new $t(s,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}function Us(r){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:n,feePayerPublicKey:i}=r,o=rr(e);if(t.feePayerAddress){let a=new It(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(n?c=n.map(h=>rr(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>rr(void 0)));let p=rr(i),l=new Kt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new Xe(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new vt(t.rawTransaction,t.secondarySignerAddresses),c=[];n?c=n.map(l=>rr(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>rr(void 0));let p=new Rt(o,t.secondarySignerAddresses,c);return new Xe(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof Ie)s=new Ct(o.public_key,o.signature);else if(o instanceof ae||o instanceof ze)s=new st(o);else if(o instanceof Ht)s=new st(o);else throw new Error("Invalid public key");return new Xe(t.rawTransaction,s).bcsToBytes()}function rr(r){if(!r)return new Ht;let t=O.isInstance(r)||re.isInstance(r)||Ge.isInstance(r)?new N(r):r,n=new I(new Uint8Array(64));if(P.isInstance(t))return new Ie(t,n);if(N.isInstance(t))return O.isInstance(t.publicKey)?new ae(t,new $(Ve.getSimulationSignature())):new ae(t,new $(n));if(ke.isInstance(t))return new ze(t,new qe({signatures:t.publicKeys.map(()=>new $(n)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Ri(r){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:n}=r,i=bo(Z,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 Kt(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 Rt(i,e.secondarySignerAddresses,n)}else i instanceof Ie?o=new Ct(i.public_key,i.signature):o=new st(i);return new Xe(e.rawTransaction,o).bcsToBytes()}function ks(r){let e=_sha3.sha3_256.create();for(let t of r)e.update(t);return e.digest()}var pu=ks(["APTOS::Transaction"]);function hb(r){let e=Ri(r);return new m(ks([pu,new Uint8Array([0]),e])).toString()}async function zs({key:r,moduleAddress:e,moduleName:t,functionName:n,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ke(async()=>s(e,t,n,i),`${r}-${i.network}-${e}-${t}-${n}`,1e3*60*5)()}var Rn=class r{constructor(e){this.config=e,this.builder=void 0}async init(){if(!r.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:n}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),n({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),r.transactionComposer=t}this.builder=r.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:n,functionName:i}=zt(e.function),o=this.config.getRequestUrl("Fullnode");await this.builder.load_module(o,`${t}::${n}`),e.typeArguments!==void 0&&await Promise.all(e.typeArguments.map(p=>this.builder.load_type_tag(o,p.toString())));let s=tr(e.typeArguments),a=await vs(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,l)=>Rs(p,i,a,l,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 we(r){let{aptosConfig:e,payload:t,options:n}=r,i=await Ks({...t,aptosConfig:e}),o=new B;i.serialize(o);let s=o.toUint8Array(),{data:a}=await ot({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 Ds(r){let{aptosConfig:e,payload:t,options:n}=r,{data:i}=await ot({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 vr=class{constructor(e){this.config=e}async getAccountInfo(e){return Oe({aptosConfig:this.config,...e})}async getAccountModules(e){return ns({aptosConfig:this.config,...e})}async getAccountModule(e){return wn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return is({aptosConfig:this.config,...e})}async getAccountResources(e){return os({aptosConfig:this.config,...e})}async getAccountResource(e){return mi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Yt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),ss({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),as({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),cs({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),us({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),ps({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ds({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ls({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:wt,faMetadataAddress:Ao,...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
477
+ `;async function lr(n){let{aptosConfig:e}=n,{data:t}=await L({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function $o(n){let{aptosConfig:e,limit:t}=n;return(await T({aptosConfig:e,query:{query:ko,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function T(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await mo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Wc(n){let{aptosConfig:e}=n;return(await T({aptosConfig:e,query:{query:oi},originMethod:"getProcessorStatuses"})).processor_status}async function gr(n){let e=await Wc({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function mr(n){let{aptosConfig:e,processorType:t}=n;return(await T({aptosConfig:e,query:{query:oi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function yr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await it({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _50 => _50.ledgerVersion])},body:r})).data}async function Wo(n){let{aptosConfig:e,options:t}=n,r={query:Vo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _51 => _51.where]),offset:_optionalChain([t, 'optionalAccess', _52 => _52.offset]),limit:_optionalChain([t, 'optionalAccess', _53 => _53.limit]),order_by:_optionalChain([t, 'optionalAccess', _54 => _54.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function Qo(n){let{aptosConfig:e,options:t}=n,r={query:qo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _55 => _55.where]),offset:_optionalChain([t, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([t, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([t, 'optionalAccess', _58 => _58.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function ke(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await L({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}`});return r}async function Xo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Jr({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _59 => _59.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _60 => _60.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _61 => _61.limit]), () => (1e3))}})}async function fr(n){return _optionalChain([n, 'access', _62 => _62.options, 'optionalAccess', _63 => _63.ledgerVersion])!==void 0?jo(n):Ce(async()=>jo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function jo(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await L({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _64 => _64.ledgerVersion])}});return o}async function Yo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return er({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([r, 'optionalAccess', _66 => _66.limit])}})}async function Zo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Jr({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _67 => _67.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _68 => _68.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _69 => _69.limit]), () => (999))}})}async function ai(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await L({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _70 => _70.ledgerVersion])}});return o.data}async function jt(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await ai({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunkZYPBABLQjs.Z.from(t);try{let a=await yr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunkZYPBABLQjs.Z.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function es(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await T({aptosConfig:e,query:{query:zo,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 ts(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _71 => _71.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _72 => _72.tokenStandard])});let s={query:Ro,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _73 => _73.offset]),limit:_optionalChain([r, 'optionalAccess', _74 => _74.limit]),order_by:_optionalChain([r, 'optionalAccess', _75 => _75.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ns(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunkZYPBABLQjs.Z.from(t).toStringLong(),s=_chunkZYPBABLQjs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _76 => _76.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _77 => _77.tokenStandard])});let c={query:Uo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([i, 'optionalAccess', _79 => _79.limit]),order_by:_optionalChain([i, 'optionalAccess', _80 => _80.orderBy])}};return(await T({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function rs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _81 => _81.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _82 => _82.tokenStandard])}});let s={query:Ko,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _83 => _83.offset]),limit:_optionalChain([r, 'optionalAccess', _84 => _84.limit]),order_by:_optionalChain([r, 'optionalAccess', _85 => _85.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function is(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:Do,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function os(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _86 => _86.where]),owner_address:{_eq:i}},s={query:Co,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _87 => _87.offset]),limit:_optionalChain([r, 'optionalAccess', _88 => _88.limit]),order_by:_optionalChain([r, 'optionalAccess', _89 => _89.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function ss(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:vo,variables:{address:r}},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 as(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}},s={query:pr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _90 => _90.offset]),limit:_optionalChain([r, 'optionalAccess', _91 => _91.limit]),order_by:_optionalChain([r, 'optionalAccess', _92 => _92.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function cs(n){let{aptosConfig:e,privateKey:t}=n,r=new O(t.publicKey());if(t instanceof Ne){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return De.fromPrivateKey({privateKey:t,address:o})}if(t instanceof q){let i=B.fromPublicKey({publicKey:r});if(await Jo({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return De.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=B.fromPublicKey({publicKey:r.publicKey});if(await Jo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return De.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function Jo(n){let{aptosConfig:e,authKey:t}=n,r=await jt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await ke({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function ui(n){let{aptosConfig:e,options:t}=n;return er({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _93 => _93.offset]),limit:_optionalChain([t, 'optionalAccess', _94 => _94.limit])}})}async function hr(n){let{aptosConfig:e}=n;return Ce(async()=>{let{data:t}=await L({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function us(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await L({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function Sn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await L({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ds(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await Sn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _95 => _95.status])===404)return!0;throw r}}async function Qc(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await L({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Jt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _96 => _96.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _97 => _97.checkSuccess]), () => (!0)),s=!0,a=0,c,d,y=200,h=1.5;function p(l){if(!(l instanceof ye)||(d=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await Sn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(l){p(l)}if(s){let l=Date.now();try{c=await Qc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-l)/1e3}for(;s&&!(a>=i);){try{if(c=await Sn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(l){p(l)}await _chunkZYPBABLQjs._.call(void 0, y),a+=y/1e3,y*=h}if(c===void 0)throw d||new Ar(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Ar(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new ci(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Tr(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await gr({aptosConfig:e}):s=(await mr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkZYPBABLQjs._.call(void 0, 200)}}var Ar=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},ci=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function ps(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await L({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _98 => _98.withTransactions])}});return gs({block:i,...n})}async function ls(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await L({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _99 => _99.withTransactions])}});return gs({block:i,...n})}async function gs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _100 => _100.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', _101 => _101.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let d=[],y=100n;for(let p=c+1n;p<s;p+=BigInt(100))d.push(ui({aptosConfig:e,options:{offset:p,limit:Math.min(Number(y),Number(s-p+1n))}}));let h=await Promise.all(d);for(let p of h)t.transactions.push(...p)}return t}async function S(n){n.minimumLedgerVersion!==void 0&&await Tr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}function ms(n){return typeof n=="boolean"}function Ye(n){return typeof n=="string"}function jc(n){return typeof n=="number"}function br(n){if(jc(n))return n;if(Ye(n)&&n!=="")return Number.parseInt(n,10)}function wr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function ys(n){return n==null}function fs(n){return di(n)||li(n)||gi(n)||mi(n)||yi(n)||fi(n)||Ai(n)||Sr(n)||pi(n)||Jc(n)||n instanceof _||n instanceof X}function di(n){return n instanceof U}function Sr(n){return n instanceof _chunkZYPBABLQjs.Z}function pi(n){return n instanceof E}function Jc(n){return n instanceof pt}function li(n){return n instanceof J}function gi(n){return n instanceof we}function mi(n){return n instanceof Se}function yi(n){return n instanceof W}function fi(n){return n instanceof _e}function Ai(n){return n instanceof le}function As(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function hs(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function Ts(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function bs(n){return!!n.match(/\s/)}function Xc(n){return!!n.match(/^T[0-9]+$/)}function Yc(n){return!!n.match(/^&.+$/)}function Zc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function eu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!bs(r))break}return t}var tu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(tu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Oe(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _102 => _102.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let b=_n(a,i,t);o.push(b)}let y=r.pop();if(y===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:p,savedExpectedTypes:l}=y;i=o,o=p,a=h,c=l}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let y=_n(a,i,t);i=[],o.push(y),a="",c+=1}else if(bs(d)){let y=!1;if(a.length!==0){let p=_n(a,i,t);i=[],o.push(p),a="",y=!0}s=eu(n,s);let h=n[s];if(s<n.length&&y&&h!==","&&h!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return _n(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function _n(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Zc(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Tt;case"bool":return new V;case"address":return new F;case"u8":return new ue;case"u16":return new Le;case"u32":return new He;case"u64":return new j;case"u128":return new $e;case"u256":return new We;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new v(e[0]);default:if(Yc(r)){let a=r.substring(1);return new rr(_n(a,e,t))}if(Xc(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunkZYPBABLQjs.Z.fromString(o[0])}catch (e3){throw new $(n,"struct address must be valid")}if(!Ts(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ts(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new ze(s,new K(o[1]),new K(o[2]),e))}}var nu=new TextEncoder;function Xt(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(e=>Ye(e)?Oe(e):e)]), () => ([]))}async function Ti(n,e,t,r){let i=await fr({aptosConfig:r,accountAddress:n,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function ws(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Oe(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Ss(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=hs(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Oe(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function _s(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Oe(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Oe(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Ps(n,e,t,r,i){return n instanceof _chunkZYPBABLQjs.X?n:_chunkZYPBABLQjs.X.newBytes(_r(e,t,n,r,i).bcsToBytes())}function _r(n,e,t,r,i){if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let o=e.parameters[r];return Kt(t,o,r,i)}function Kt(n,e,t,r){return fs(n)?(hi(e,n,t),n):ru(n,e,t,r)}function ru(n,e,t,r){if(e.isBool()){if(ms(n))return new U(n);if(Ye(n)){if(n==="true")return new U(!0);if(n==="false")return new U(!1)}D("boolean",t)}if(e.isAddress()){if(Ye(n))return _chunkZYPBABLQjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let i=br(n);if(i!==void 0)return new J(i);D("number | string",t)}if(e.isU16()){let i=br(n);if(i!==void 0)return new we(i);D("number | string",t)}if(e.isU32()){let i=br(n);if(i!==void 0)return new Se(i);D("number | string",t)}if(e.isU64()){if(wr(n))return new W(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(wr(n))return new _e(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(wr(n))return new le(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let i=e.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Kt(n,r[i],t,r)}if(e.isVector()){if(e.value.isU8()){if(Ye(n))return _.U8(nu.encode(n));if(n instanceof Uint8Array)return _.U8(n);if(n instanceof ArrayBuffer)return _.U8(new Uint8Array(n))}if(Ye(n)&&n.startsWith("["))return Kt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new _(n.map(i=>Kt(i,e.value,t,r)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(Ye(n))return new E(n);D("string",t)}if(e.isObject()){if(Ye(n))return _chunkZYPBABLQjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isOption()){if(ys(n)){let i=e.value.typeArgs[0];return i instanceof V?new X(null):i instanceof F?new X(null):i instanceof ue?new X(null):i instanceof Le?new X(null):i instanceof He?new X(null):i instanceof j?new X(null):i instanceof $e?new X(null):i instanceof We?new X(null):new X(null)}return new X(Kt(n,e.value.typeArgs[0],t,r))}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 hi(n,e,t){if(n.isBool()){if(di(e))return;D("Bool",t)}if(n.isAddress()){if(Sr(e))return;D("AccountAddress",t)}if(n.isU8()){if(li(e))return;D("U8",t)}if(n.isU16()){if(gi(e))return;D("U16",t)}if(n.isU32()){if(mi(e))return;D("U32",t)}if(n.isU64()){if(yi(e))return;D("U64",t)}if(n.isU128()){if(fi(e))return;D("U128",t)}if(n.isU256()){if(Ai(e))return;D("U256",t)}if(n.isVector()){if(e instanceof _){e.values.length>0&&hi(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(pi(e))return;D("MoveString",t)}if(n.isObject()){if(Sr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof X){e.value!==void 0&&hi(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Pr(n){if(As(n))return au(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunkZYPBABLQjs.ha.call(void 0, n.function),i=await vs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ss});return ou({...n,abi:i})}function ou(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, n.function),o=Xt(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>_r(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=St.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunkZYPBABLQjs.Z.from(n.multisigAddress);return new fn(new hn(c,new Tn(a)))}return new yn(a)}async function Es(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunkZYPBABLQjs.ha.call(void 0, n.function),i=await vs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:_s});return su({abi:i,...n})}function su(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, n.function),o=Xt(n.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([n, 'optionalAccess', _105 => _105.functionArguments, 'optionalAccess', _106 => _106.map, 'call', _107 => _107((a,c)=>_r(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return St.build(`${t}::${r}`,i,o,s)}function au(n){return new wt(new An(_chunkZYPBABLQjs.j.fromHexInput(n.bytecode).toUint8Array(),Xt(n.typeArguments),n.functionArguments))}async function bi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>Wr[e.network]?{chainId:Wr[e.network]}:{chainId:(await lr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _108 => _108.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await hr({aptosConfig:e})).gas_estimate},c=async()=>{let R=async()=>_optionalChain([i, 'optionalAccess', _109 => _109.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await ke({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunkZYPBABLQjs.Z.from(o).equals(_chunkZYPBABLQjs.Z.ZERO))try{return await R()}catch (e4){return 0}else return R()},[{chainId:d},{gasEstimate:y},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:l,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _110 => _110.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _111 => _111.gasUnitPrice]), () => (BigInt(y))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _112 => _112.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new fe(_chunkZYPBABLQjs.Z.from(t),BigInt(h),r,BigInt(p),BigInt(l),BigInt(b),new qt(d))}async function wi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await bi({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _113 => _113.secondarySignerAddresses, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(c=>_chunkZYPBABLQjs.Z.from(c))]), () => ([]));return new ar(s,a,n.feePayerAddress?_chunkZYPBABLQjs.Z.from(n.feePayerAddress):void 0)}return new Lt(s,n.feePayerAddress?_chunkZYPBABLQjs.Z.from(n.feePayerAddress):void 0)}function xs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Yt(e);if(t.feePayerAddress){let a=new Pt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>Yt(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0)));let d=Yt(i),y=new It(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new je(a.raw_txn,y).bcsToBytes()}if(t.secondarySignerAddresses){let a=new _t(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(y=>Yt(y)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0));let d=new xt(o,t.secondarySignerAddresses,c);return new je(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof xe)s=new Et(o.public_key,o.signature);else if(o instanceof ie||o instanceof Ue)s=new ot(o);else if(o instanceof Vt)s=new ot(o);else throw new Error("Invalid public key");return new je(t.rawTransaction,s).bcsToBytes()}function Yt(n){if(!n)return new Vt;let t=k.isInstance(n)||te.isInstance(n)||Fe.isInstance(n)?new O(n):n,r=new I(new Uint8Array(64));if(x.isInstance(t))return new xe(t,r);if(O.isInstance(t))return k.isInstance(t.publicKey)?new ie(t,new H(Me.getSimulationSignature())):new ie(t,new H(r));if(Re.isInstance(t))return new Ue(t,new qe({signatures:t.publicKeys.map(()=>new H(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Si(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=lo(Q,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new It(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new xt(i,e.secondarySignerAddresses,r)}else i instanceof xe?o=new Et(i.public_key,i.signature):o=new ot(i);return new je(e.rawTransaction,o).bcsToBytes()}function Is(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var cu=Is(["APTOS::Transaction"]);function Pb(n){let e=Si(n);return new (0, _chunkZYPBABLQjs.j)(Is([cu,new Uint8Array([0]),e])).toString()}async function vs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ce(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Er=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:r}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),r({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, e.function),o=this.config.getRequestUrl("Fullnode");await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0&&await Promise.all(e.typeArguments.map(d=>this.builder.load_type_tag(o,d.toString())));let s=Xt(e.typeArguments),a=await ws(t,r,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((d,y)=>Ps(d,i,a,y,s));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(d=>d.toString()),c)}build(){return this.builder.generate_batched_calls(!0)}};async function oe(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Es({...t,aptosConfig:e}),o=new _chunkZYPBABLQjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await it({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _116 => _116.ledgerVersion])},body:s});return a}async function Cs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await it({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _117 => _117.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function w(n){let e=await uu(n);return du(n,e)}async function uu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Pr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)),i}async function du(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(pu(n)&&(o=_chunkZYPBABLQjs.Z.ZERO.toString()),lu(n)){let{secondarySignerAddresses:s}=n;return wi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return wi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function pu(n){return n.withFeePayer===!0}function lu(n){return"secondarySignerAddresses"in n}function Ks(n){let{transaction:e}=n;return Je(e)}function xr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Ir(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,xr({signer:e,transaction:t})}async function Pi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=xs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await it({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _118 => _118.options, 'optionalAccess', _119 => _119.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _120 => _120.options, 'optionalAccess', _121 => _121.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _122 => _122.options, 'optionalAccess', _123 => _123.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Pn(n){let{aptosConfig:e}=n,t=Si({...n});try{let{data:r}=await it({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=je.deserialize(new C(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof k||i.authenticator.sender.public_key.publicKey instanceof te)&&await pe.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function En(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;cr(t)&&await t.checkKeylessAccountValidity(e),cr(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Ir({signer:r,transaction:i}),s=xr({signer:t,transaction:i});return Pn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Rs(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;cr(r)&&await r.checkKeylessAccountValidity(e);let o=Ir({signer:r,transaction:i});return Pn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var gu={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Us(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>_.U8(a));return w({aptosConfig:e,sender:_chunkZYPBABLQjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[_.U8(r),new _(s)],abi:gu},options:o})}var mu={typeParameters:[],parameters:[new ue,v.u8(),new ue,v.u8(),v.u8(),v.u8()]};async function zs(n){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:r}=n,i=await ke({aptosConfig:e,accountAddress:t.accountAddress}),o=De.fromPrivateKey({privateKey:r,legacy:!0}),a=new or({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunkZYPBABLQjs.Z.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a),y=await w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new J(t.signingScheme),_.U8(t.publicKey.toUint8Array()),new J(o.signingScheme),_.U8(o.publicKey.toUint8Array()),_.U8(c.toUint8Array()),_.U8(d.toUint8Array())],abi:mu}});return En({aptosConfig:e,signer:t,transaction:y})}async function Ds(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkZYPBABLQjs.ha.call(void 0, r);return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(P()),new A(P())]}},options:i})}async function ks(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkZYPBABLQjs.ha.call(void 0, r);return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(P()),new A(P())]}},options:i})}async function Os(n){let{aptosConfig:e,sender:t,options:r}=n;return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Rt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunkZYPBABLQjs.ha.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _124 => _124.some, 'call', _125 => _125(s=>_chunkZYPBABLQjs.Z.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ds({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return ks({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Os({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await oe({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunkZYPBABLQjs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunkZYPBABLQjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var xn=class{constructor(e){this.config=e;this.abstraction=new Rt(e)}async getAccountInfo(e){return ke({aptosConfig:this.config,...e})}async getAccountModules(e){return Xo({aptosConfig:this.config,...e})}async getAccountModule(e){return fr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Yo({aptosConfig:this.config,...e})}async getAccountResources(e){return Zo({aptosConfig:this.config,...e})}async getAccountResource(e){return ai({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return jt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),es({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ts({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ns({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rs({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),is({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),os({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ss({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:At,faMetadataAddress:co,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
480
478
  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 Ke(async()=>{try{let p=(await we({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunkIHUCZKG2js.j.call(void 0, p.vec[0]))return _chunkIHUCZKG2js.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===wt?a=u.A.toStringLong():a=cn(u.A,n).toStringLong();else if(n===void 0&&i!==void 0){let p=u.from(i);a=p.toStringLong(),p===u.A&&(s=wt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await we({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await we({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 w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gs({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return ys({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Kn=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 go[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return yo[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 lo[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 Yn[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 Zn[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Yn[this.network]===e}isProverServiceRequest(e){return Zn[this.network]===e}};async function _(r){let e=await lu(r);return gu(r,e)}async function lu(r){let{aptosConfig:e,data:t}=r,n,i;return"bytecode"in t?i=await Cn(t):"multisigAddress"in t?(n={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Cn(n)):(n={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Cn(n)),i}async function gu(r,e){let{aptosConfig:t,sender:n,options:i}=r,o;if(yu(r)&&(o=u.ZERO.toString()),mu(r)){let{secondarySignerAddresses:s}=r;return Ci({aptosConfig:t,sender:n,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Ci({aptosConfig:t,sender:n,payload:e,options:i,feePayerAddress:o})}function yu(r){return r.withFeePayer===!0}function mu(r){return"secondarySignerAddresses"in r}function Os(r){let{transaction:e}=r;return Qt(e)}function Un(r){let{signer:e,transaction:t}=r;return e.signTransactionWithAuthenticator(t)}function kn(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,Un({signer:e,transaction:t})}async function Ui(r){let{aptosConfig:e,transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=r,a=Us({transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await ot({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 Ir(r){let{aptosConfig:e}=r,t=Ri({...r});try{let{data:n}=await ot({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}catch(n){let i=Xe.deserialize(new R(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof O||i.authenticator.sender.public_key.publicKey instanceof re)&&await le.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),n}}async function Cr(r){let{aptosConfig:e,signer:t,feePayer:n,transaction:i}=r;yn(t)&&await t.checkKeylessAccountValidity(e),yn(n)&&await n.checkKeylessAccountValidity(e);let o=r.feePayerAuthenticator||n&&kn({signer:n,transaction:i}),s=Un({signer:t,transaction:i});return Ir({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Ns(r){let{aptosConfig:e,senderAuthenticator:t,feePayer:n,transaction:i}=r;yn(n)&&await n.checkKeylessAccountValidity(e);let o=kn({signer:n,transaction:i});return Ir({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var fu={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Fs(r){let{aptosConfig:e,account:t,metadataBytes:n,moduleBytecode:i,options:o}=r,s=i.map(a=>S.U8(a));return _({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(n),new S(s)],abi:fu},options:o})}var Au={typeParameters:[],parameters:[new pe,C.u8(),new pe,C.u8(),C.u8(),C.u8()]};async function Gs(r){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:n}=r,i=await Oe({aptosConfig:e,accountAddress:t.accountAddress}),o=at.fromPrivateKey({privateKey:n,legacy:!0}),a=new dn({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),l=await _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new X(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(p.toUint8Array())],abi:Au}});return Cr({aptosConfig:e,signer:t,transaction:l})}var hu={typeParameters:[{constraints:[]}],parameters:[new ee,new j]};async function Bs(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, () => (wt))],functionArguments:[n,i],abi:hu},options:s})}var Rr=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Bs({aptosConfig:this.config,...e})}};var ut={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Se="0x4::token::Token";async function Ms(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()}};return(await T({aptosConfig:e,query:{query:Xo,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ls(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await T({aptosConfig:e,query:{query:yi,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:yi,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 T({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Hs(r){let{aptosConfig:e,digitalAssetAddress:t,options:n}=r,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:Jo,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 T({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Tu={typeParameters:[],parameters:[new A(v()),new j,new A(v()),new A(v()),new M,new M,new M,new M,new M,new M,new M,new M,new M,new j,new j]};async function qs(r){let{aptosConfig:e,options:t,creator:n}=r;return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(r.description),new Q(_nullishCoalesce(r.maxSupply, () => (gt))),new x(r.name),new x(r.uri),new k(_nullishCoalesce(r.mutableDescription, () => (!0))),new k(_nullishCoalesce(r.mutableRoyalty, () => (!0))),new k(_nullishCoalesce(r.mutableURI, () => (!0))),new k(_nullishCoalesce(r.mutableTokenDescription, () => (!0))),new k(_nullishCoalesce(r.mutableTokenName, () => (!0))),new k(_nullishCoalesce(r.mutableTokenProperties, () => (!0))),new k(_nullishCoalesce(r.mutableTokenURI, () => (!0))),new k(_nullishCoalesce(r.tokensBurnableByCreator, () => (!0))),new k(_nullishCoalesce(r.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(r.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(r.royaltyDenominator, () => (1)))],abi:Tu},options:t})}async function nr(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:Lo,variables:{where_condition:n,offset:_optionalChain([t, 'optionalAccess', _150 => _150.offset]),limit:_optionalChain([t, 'optionalAccess', _151 => _151.limit])}};return(await T({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function $s(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"))}),nr({aptosConfig:e,options:{...i,where:s}})}async function Ws(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"))}),nr({aptosConfig:e,options:{...n,where:o}})}async function Qs(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"))}),nr({aptosConfig:e,options:{...n,where:o}})}async function js(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 nr({aptosConfig:i,options:{where:s}})).collection_id}var bu={typeParameters:[],parameters:[new A(v()),new A(v()),new A(v()),new A(v()),new C(new A(v())),new C(new A(v())),new C(C.u8())]};async function Js(r){let{aptosConfig:e,options:t,creator:n,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:l}=r,h=_optionalChain([p, 'optionalAccess', _160 => _160.map, 'call', _161 => _161(g=>ut[g])]);return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(i),new x(o),new x(s),new x(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(h, () => ([]))),pa(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:bu},options:t})}var wu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new ee]};async function Xs(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, () => (Se))],functionArguments:[u.from(n),u.from(i)],abi:wu},options:s})}var Su={typeParameters:[],parameters:[new A(v()),new A(v()),new A(v()),new A(v()),new C(new A(v())),new C(new A(v())),new C(C.u8()),new ee]};async function Ys(r){let{aptosConfig:e,account:t,collection:n,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:l,options:h}=r;if(_optionalChain([c, 'optionalAccess', _162 => _162.length])!==_optionalChain([l, 'optionalAccess', _163 => _163.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _164 => _164.length])!==_optionalChain([l, 'optionalAccess', _165 => _165.length]))throw new Error("Property types and property values counts do not match");let g=_optionalChain([p, 'optionalAccess', _166 => _166.map, 'call', _167 => _167(d=>ut[d])]);return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(g, () => ([]))),pa(_nullishCoalesce(l, () => ([])),_nullishCoalesce(g, () => ([]))),a],abi:Su},options:h})}var _u={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Zs(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, () => (Se))],functionArguments:[u.from(n)],abi:_u},options:o})}var xu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function ea(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, () => (Se))],functionArguments:[n],abi:xu},options:o})}var Eu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function ta(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, () => (Se))],functionArguments:[n],abi:Eu},options:o})}var Pu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function ra(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, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:Pu},options:s})}var vu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function na(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, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:vu},options:s})}var Iu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function ia(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, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:Iu},options:s})}var Cu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v()),new A(v()),C.u8()]};async function oa(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, () => (Se))],functionArguments:[u.from(s),new x(n),new x(ut[i]),S.U8(ki(o,ut[i]))],abi:Cu},options:c})}var Ru={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function sa(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, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:Ru},options:s})}var Ku={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v()),new A(v()),C.u8()]};async function aa(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, () => (Se))],functionArguments:[u.from(s),new x(n),new x(ut[i]),ki(o,ut[i])],abi:Ku},options:c})}var Uu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(v()),new G(1)]};async function ca(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, () => (Se)),ut[i]],functionArguments:[u.from(s),new x(n),o],abi:Uu},options:c})}var ku={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(v()),new G(1)]};async function ua(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, () => (Se)),ut[i]],functionArguments:[u.from(s),new x(n),o],abi:ku},options:c})}function pa(r,e){let t=new Array;return e.forEach((n,i)=>{t.push(ki(r[i],n))}),t}function ki(r,e){let t=Ne(e);return er(r,t,0,[]).bcsToBytes()}var Kr=class{constructor(e){this.config=e}async getCollectionData(e){await w({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"))}),nr({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$s({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ws({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Qs({aptosConfig:this.config,...e})}async getCollectionId(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),js({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ms({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return qs({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Js({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Xs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Ys({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Zs({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ea({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return ta({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return ra({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return na({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ia({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return oa({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return sa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return aa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return ca({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return ua({aptosConfig:this.config,...e})}};var da=300,zu=r=>{if(r&&r.length>da)throw new Error(`Event type length exceeds the maximum length of ${da}`)};async function la(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 Ur({aptosConfig:e,options:{...n,where:i}})}async function ga(r){let{accountAddress:e,aptosConfig:t,creationNumber:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:n}};return Ur({aptosConfig:t,options:{...i,where:s}})}async function ya(r){let{accountAddress:e,aptosConfig:t,eventType:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:n}};return Ur({aptosConfig:t,options:{...i,where:s}})}async function Ur(r){let{aptosConfig:e,options:t}=r;zu(_optionalChain([t, 'optionalAccess', _170 => _170.where, 'optionalAccess', _171 => _171.indexed_type, 'optionalAccess', _172 => _172._eq]));let n={query:qo,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 T({aptosConfig:e,query:n,originMethod:"getEvents"})).events}var kr=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),la({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ga({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ya({aptosConfig:this.config,...e})}async getEvents(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _177 => _177.minimumLedgerVersion]),processorType:"events_processor"}),Ur({aptosConfig:this.config,...e})}};async function ma(r){let{aptosConfig:e,accountAddress:t,amount:n,options:i}=r,o=_optionalChain([i, 'optionalAccess', _178 => _178.timeoutSecs])||20,{data:s}=await _o({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:n},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Zt({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 zr=class{constructor(e){this.config=e}async fundAccount(e){let t=await ma({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 xn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function zn(r){let{aptosConfig:e,options:t}=r,n={query:Wo,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 T({aptosConfig:e,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function fa(r){let{aptosConfig:e,options:t}=r,n={query:$o,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 T({aptosConfig:e,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Aa(r){let{aptosConfig:e,options:t}=r,n={query:Vo,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 T({aptosConfig:e,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Du={typeParameters:[{constraints:[]}],parameters:[Ne("0x1::object::Object"),new ee,new j]};async function ha(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:Du},options:s})}var Dr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),zn({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await zn({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await zn({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _196 => _196.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),fa({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _197 => _197.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Aa({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ha({aptosConfig:this.config,...e})}};var Or=class{constructor(e){this.config=e}async getLedgerInfo(){return An({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return As({aptosConfig:this.config,...e})}async getBlockByHeight(e){return hs({aptosConfig:this.config,...e})}async view(e){return we({aptosConfig:this.config,...e})}async viewJson(e){return Ds({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Yo({aptosConfig:this.config,...e})}async queryIndexer(e){return T({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return hn({aptosConfig:this.config})}async getProcessorStatus(e){return Tn({aptosConfig:this.config,processorType:e})}};var Ta=["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 ba(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function pt(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(!ba(e))throw new Error(`${e} is not valid. ${Ta}`);if(t&&!ba(t))throw new Error(`${t} is not valid. ${Ta}`);return{domainName:t||e,subdomainName:t?e:void 0}}function wa(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 Ou="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Nu={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ou,custom:null,devnet:null};function Ze(r){let e=Nu[r.network];if(!e)throw new Error(`The ANS contract is not deployed to ${r.network}`);return e}var Dn=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=Ze(e),{domainName:i,subdomainName:o}=pt(t),s=await we({aptosConfig:e,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Dn(s[0]);return a?u.from(a):void 0}async function _a(r){let{aptosConfig:e,expiration:t,name:n,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=r,p=Ze(e),{domainName:l,subdomainName:h}=pt(n),g=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!g)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(g&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let te=_nullishCoalesce(t.years, () => (1));if(te!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Dt=te*31536e3;return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[l,Dt,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let d=await zi({aptosConfig:e,name:l});if(!d)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:d;if(b>d)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:[l,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function zi(r){let{aptosConfig:e,name:t}=r,n=Ze(e),{domainName:i,subdomainName:o}=pt(t);try{let s=await we({aptosConfig:e,payload:{function:`${n}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function xa(r){let{aptosConfig:e,address:t}=r,n=Ze(e),i=await we({aptosConfig:e,payload:{function:`${n}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=Dn(i[1]),s=Dn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ea(r){let{aptosConfig:e,sender:t,name:n,options:i}=r,o=Ze(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}=pt(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=Ze(e),{domainName:i,subdomainName:o}=pt(t),s=await we({aptosConfig:e,payload:{function:`${n}::router::get_target_addr`,functionArguments:[i,o]}}),a=Dn(s[0]);return a?u.from(a):void 0}async function va(r){let{aptosConfig:e,sender:t,name:n,address:i,options:o}=r,s=Ze(e),{domainName:a,subdomainName:c}=pt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ia(r){let{aptosConfig:e,name:t}=r,{domainName:n,subdomainName:i=""}=pt(t),a=(await T({aptosConfig:e,query:{query:Xt,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Nr(a)),wa(a)?a:void 0}async function Ca(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Di({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountNames",query:{query:Xt,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(Nr)}async function Ra(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Di({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Xt,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(Nr)}async function Ka(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Di({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Xt,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(Nr)}async function Ua(r){let{aptosConfig:e,options:t,domain:n}=r;return(await T({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Xt,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(Nr).filter(wa)}async function Di(r){let{aptosConfig:e}=r,t=Ze(e),[n]=await we({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 ka(r){let{aptosConfig:e,sender:t,name:n,years:i=1,options:o}=r,s=Ze(e),a=i*31536e3,{domainName:c,subdomainName:p}=pt(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 Nr(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).getTime()}}var Fr=class{constructor(e){this.config=e}async getOwnerAddress(e){return Sa({aptosConfig:this.config,...e})}async getExpiration(e){return zi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Pa({aptosConfig:this.config,...e})}async setTargetAddress(e){return va({aptosConfig:this.config,...e})}async getPrimaryName(e){return xa({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ea({aptosConfig:this.config,...e})}async registerName(e){return _a({aptosConfig:this.config,...e})}async renewDomain(e){return ka({aptosConfig:this.config,...e})}async getName(e){return Ia({aptosConfig:this.config,...e})}async getAccountNames(e){return Ca({aptosConfig:this.config,...e})}async getAccountDomains(e){return Ra({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Ka({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Ua({aptosConfig:this.config,...e})}};async function za(r){let{aptosConfig:e,poolAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:li,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 Da(r){let{aptosConfig:e,options:t}=r,n={query:li,variables:{order_by:_optionalChain([t, 'optionalAccess', _218 => _218.orderBy])}};return(await T({aptosConfig:e,query:n})).num_active_delegator_per_pool}async function Oa(r){let{aptosConfig:e,delegatorAddress:t,poolAddress:n}=r,i={query:Ho,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(n).toStringLong()}};return(await T({aptosConfig:e,query:i})).delegated_staking_activities}var Gr=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),za({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _220 => _220.minimumLedgerVersion]),processorType:"stake_processor"}),Da({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _221 => _221.minimumLedgerVersion]),processorType:"stake_processor"}),Oa({aptosConfig:this.config,...e})}};var On=class{constructor(e){this.config=e}async simple(e){return _({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Rn(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Ii({aptosConfig:this.config,payload:Et.load(new R(i)),...e});return new $t(o,e.withFeePayer===!0?u.ZERO:void 0)}async multiAgent(e){return _({aptosConfig:this.config,...e})}};function Oi(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 Ni(r,e,t){let n=t.value;return t.value=async function(...i){return n.apply(this,i)},t}var ir=class{constructor(e){this.config=e}async simple(e){return Ui({aptosConfig:this.config,...e})}async multiAgent(e){return Ui({aptosConfig:this.config,...e})}};_chunkIHUCZKG2js.a.call(void 0, [Ni],ir.prototype,"simple",1),_chunkIHUCZKG2js.a.call(void 0, [Ni],ir.prototype,"multiAgent",1);var or=class{constructor(e){this.config=e}async simple(e){return Ir({aptosConfig:this.config,...e})}async multiAgent(e){return Ir({aptosConfig:this.config,...e})}};_chunkIHUCZKG2js.a.call(void 0, [Oi],or.prototype,"simple",1),_chunkIHUCZKG2js.a.call(void 0, [Oi],or.prototype,"multiAgent",1);var Nn=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 _chunkIHUCZKG2js.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=_chunkIHUCZKG2js.d.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkIHUCZKG2js.b.call(void 0, this.sleepTime),_chunkIHUCZKG2js.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 Oe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Oe({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 _chunkIHUCZKG2js.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkIHUCZKG2js.d.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkIHUCZKG2js.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 _chunkIHUCZKG2js.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 sr=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 ar("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},ar=class extends Error{};var Na="fulfilled",Fa= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Fa||{}),Fn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,n,i=30,o=100,s=10){super();this.taskQueue=new sr;this.transactionsQueue=new sr;this.outstandingTransactions=new sr;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=n,this.started=!1,this.accountSequnceNumber=new Nn(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=Cr({aptosConfig:this.aptosConfig,transaction:n,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof ar)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===Na?(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 ar)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,n){try{let i=[];i.push(Zt({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===Na?(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 Gn=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Fn(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 Br=class{constructor(e){this.config=e,this.build=new On(this.config),this.simulate=new ir(this.config),this.submit=new or(this.config),this.batch=new Gn(this.config)}async getTransactions(e){return Ai({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ms({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Er({aptosConfig:this.config,...e})}async isPendingTransaction(e){return fs({aptosConfig:this.config,...e})}async waitForTransaction(e){return Zt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return _n({aptosConfig:this.config})}getSigningMessage(e){return Os(e)}async publishPackageTransaction(e){return Fs({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Gs({aptosConfig:this.config,...e})}sign(e){return Un({...e})}signAsFeePayer(e){return kn({...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 Cr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Ns({aptosConfig:this.config,...e})}};var Mr=class{constructor(e){this.config=e}async getTableItem(e){return bn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Zo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),es({aptosConfig:this.config,...e})}};async function Bn(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:m.fromHexInput(n.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await xo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return m.fromHexInput(a.pepper).toUint8Array()}async function Fi(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,pepper:i=await Bn(r),uidKey:o="sub",maxExpHorizonSecs:s=(await Ar({aptosConfig:e})).maxExpHorizonSecs}=r;if(m.fromHexInput(i).toUint8Array().length!==Ye.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ye.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:m.fromHexInput(n.blinder).toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,exp_horizon_secs:s,pepper:m.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await Eo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=p.proof,h=new Lt({a:l.a,b:l.b,c:l.c});return new ve({proof:new Vt(h,0),trainingWheelsSignature:Re.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function Ga(r){let{aptosConfig:e,jwt:t,jwkAddress:n,uidKey:i,proofFetchCallback:o,pepper:s=await Bn(r)}=r,{verificationKey:a,maxExpHorizonSecs:c}=await Ar({aptosConfig:e}),p=Fi({...r,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(n!==void 0){let d=re.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:n,uidKey:i}),b=await Yt({aptosConfig:e,authenticationKey:d.authKey().derivedAddress()});return kt.create({...r,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:n,verificationKey:a})}let h=O.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),g=await Yt({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return Ye.create({...r,address:g,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Ba(r){let{aptosConfig:e,sender:t,iss:n,options:i}=r,{jwksUrl:o}=r;o===void 0&&(To.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}`,z.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,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var Lr=class{constructor(e){this.config=e}async getPepper(e){return Bn({aptosConfig:this.config,...e})}async getProof(e){return Fi({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Ga({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Ba({aptosConfig:this.config,...e})}};async function Mu(r){let{aptosConfig:e,options:t}=r,n={query:fn,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 T({aptosConfig:e,query:n,originMethod:"getObjectData"})).current_objects}async function Ma(r){let{aptosConfig:e,objectAddress:t,options:n}=r,o={object_address:{_eq:u.from(t).toStringLong()}};return(await Mu({aptosConfig:e,options:{...n,where:o}}))[0]}var Vr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ma({aptosConfig:this.config,...e})}};var ne=class{constructor(e){this.config=new Kn(e),this.account=new vr(this.config),this.ans=new Fr(this.config),this.coin=new Rr(this.config),this.digitalAsset=new Kr(this.config),this.event=new kr(this.config),this.faucet=new zr(this.config),this.fungibleAsset=new Dr(this.config),this.general=new Or(this.config),this.staking=new Gr(this.config),this.transaction=new Br(this.config),this.table=new Mr(this.config),this.keyless=new Lr(this.config),this.object=new Vr(this.config)}};function ge(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))})}ge(ne,vr,"account");ge(ne,Fr,"ans");ge(ne,Rr,"coin");ge(ne,Kr,"digitalAsset");ge(ne,kr,"event");ge(ne,zr,"faucet");ge(ne,Dr,"fungibleAsset");ge(ne,Or,"general");ge(ne,Gr,"staking");ge(ne,Br,"transaction");ge(ne,Mr,"table");ge(ne,Lr,"keyless");ge(ne,Vr,"object");exports.APTOS_BIP44_REGEX = ec; exports.APTOS_COIN = wt; exports.APTOS_FA = Ao; exports.APTOS_HARDENED_REGEX = Za; exports.AbstractKeylessAccount = le; exports.Account = at; exports.AccountAddress = u; exports.AccountAuthenticator = Z; exports.AccountAuthenticatorEd25519 = Ie; exports.AccountAuthenticatorMultiEd25519 = an; exports.AccountAuthenticatorMultiKey = ze; exports.AccountAuthenticatorNoAccountAuthenticator = Ht; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = Qi; exports.AccountPublicKey = se; exports.AccountSequenceNumber = Nn; exports.AccountUtils = ko; exports.AddressInvalidReason = ja; exports.AnyPublicKey = N; exports.AnyPublicKeyVariant = pr; exports.AnySignature = $; exports.AnySignatureVariant = ji; exports.Aptos = ne; exports.AptosApiError = Ae; exports.AptosApiType = bt; exports.AptosConfig = Kn; exports.AptosScriptComposer = Rn; exports.AuthenticationKey = L; exports.Bool = k; exports.CKDPriv = io; exports.CallArgument = _scriptcomposerpack.CallArgument; exports.ChainId = qt; exports.DEFAULT_MAX_GAS_AMOUNT = mo; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = fo; exports.DEFAULT_TXN_TIMEOUT_SEC = tn; exports.DeriveScheme = Yi; exports.Deserializer = R; exports.EPK_HORIZON_SECS = kg; exports.Ed25519Account = Te; exports.Ed25519PrivateKey = H; exports.Ed25519PublicKey = P; exports.Ed25519Signature = I; exports.EntryFunction = Pt; exports.EntryFunctionBytes = Qr; exports.EphemeralCertificate = Mt; exports.EphemeralCertificateVariant = Vn; exports.EphemeralKeyPair = Ut; exports.EphemeralPublicKey = Tt; exports.EphemeralPublicKeyVariant = Ln; exports.EphemeralSignature = Re; exports.EphemeralSignatureVariant = Ji; exports.FIREBASE_AUTH_ISS_PATTERN = To; exports.FederatedKeylessAccount = kt; exports.FederatedKeylessPublicKey = re; exports.FeePayerRawTransaction = It; exports.FixedBytes = mt; exports.Groth16VerificationKey = ai; exports.Groth16Zkp = Lt; exports.HARDENED_OFFSET = to; exports.Hex = m; exports.HexInvalidReason = Ha; exports.Identifier = K; exports.KeyType = tc; exports.KeylessAccount = Ye; exports.KeylessConfiguration = si; exports.KeylessError = z; exports.KeylessErrorCategory = vc; exports.KeylessErrorResolutionTip = Ic; exports.KeylessErrorType = rn; exports.KeylessPublicKey = O; exports.KeylessSignature = Ve; exports.MAX_AUD_VAL_BYTES = kc; exports.MAX_COMMITED_EPK_BYTES = Ng; exports.MAX_EXTRA_FIELD_BYTES = Dg; exports.MAX_ISS_VAL_BYTES = zg; exports.MAX_JWT_HEADER_B64_BYTES = Og; exports.MAX_UID_KEY_BYTES = zc; exports.MAX_UID_VAL_BYTES = Dc; exports.MimeType = jr; exports.ModuleId = hr; exports.MoveAbility = Xi; exports.MoveFunctionVisibility = $a; exports.MoveJWK = ci; exports.MoveOption = Y; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = vt; exports.MultiAgentTransaction = gn; exports.MultiEd25519PublicKey = Gt; exports.MultiEd25519Signature = At; exports.MultiKey = ke; exports.MultiKeyAccount = xr; exports.MultiKeySignature = qe; exports.MultiSig = Sr; exports.MultiSigTransactionPayload = _r; exports.Network = ei; exports.NetworkToChainId = ti; exports.NetworkToFaucetAPI = yo; exports.NetworkToIndexerAPI = lo; exports.NetworkToNetworkName = vl; exports.NetworkToNodeAPI = go; exports.NetworkToPepperAPI = Yn; exports.NetworkToProverAPI = Zn; exports.ParsingError = J; exports.PrivateKey = nt; exports.PrivateKeyVariants = Jr; exports.ProcessorType = Me; exports.PublicKey = ft; exports.RAW_TRANSACTION_SALT = ho; exports.RAW_TRANSACTION_WITH_DATA_SALT = ri; exports.RawTransaction = he; exports.RawTransactionWithData = pn; exports.RoleType = Wa; exports.RotationProofChallenge = dn; exports.Script = wr; exports.ScriptTransactionArgumentVariants = ur; exports.Secp256k1PrivateKey = Be; exports.Secp256k1PublicKey = Ge; exports.Secp256k1Signature = ht; exports.Serializable = y; exports.Serialized = dr; exports.Serializer = B; exports.Signature = V; exports.SignedTransaction = Xe; exports.SigningScheme = oe; exports.SigningSchemeInput = $n; exports.SimpleTransaction = $t; exports.SingleKeyAccount = be; exports.StructTag = De; exports.TransactionAndProof = di; exports.TransactionAuthenticator = Je; exports.TransactionAuthenticatorEd25519 = Ct; exports.TransactionAuthenticatorFeePayer = Kt; exports.TransactionAuthenticatorMultiAgent = Rt; exports.TransactionAuthenticatorMultiEd25519 = ln; exports.TransactionAuthenticatorSingleSender = st; exports.TransactionAuthenticatorVariant = Wi; exports.TransactionPayload = xt; exports.TransactionPayloadEntryFunction = Tr; exports.TransactionPayloadMultiSig = br; exports.TransactionPayloadScript = Et; exports.TransactionPayloadVariants = qi; exports.TransactionResponseType = qn; exports.TransactionVariants = $i; exports.TransactionWorker = Fn; exports.TransactionWorkerEventsEnum = Fa; exports.TypeTag = F; exports.TypeTagAddress = ee; exports.TypeTagBool = M; exports.TypeTagGeneric = G; exports.TypeTagParserError = W; exports.TypeTagParserErrorType = nu; exports.TypeTagReference = un; exports.TypeTagSigner = _t; exports.TypeTagStruct = A; exports.TypeTagU128 = Qe; exports.TypeTagU16 = $e; exports.TypeTagU256 = je; exports.TypeTagU32 = We; exports.TypeTagU64 = j; exports.TypeTagU8 = pe; exports.TypeTagVariants = Hi; exports.TypeTagVector = C; exports.U128 = Ee; exports.U16 = _e; exports.U256 = ye; exports.U32 = xe; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = ve; exports.ZkProof = Vt; exports.ZkpVariant = Hn; exports.aptosCoinStructTag = bm; exports.aptosRequest = nn; exports.base64UrlDecode = _chunkIHUCZKG2js.f; exports.bigIntToBytesLE = uo; exports.buildTransaction = Ci; exports.bytesToBigIntLE = yr; exports.checkOrConvertArgument = er; exports.convertAmountFromHumanReadableToOnChain = _chunkIHUCZKG2js.g; exports.convertAmountFromOnChainToHumanReadable = _chunkIHUCZKG2js.h; exports.convertArgument = In; exports.convertCallArgument = Rs; exports.convertNumber = En; exports.createObjectAddress = cn; exports.createResourceAddress = Jy; exports.createTokenAddress = Xy; exports.deriveKey = Qn; exports.deriveTransactionType = ui; exports.deserializeFromScriptArgument = Bc; exports.ensureBoolean = Mn; exports.fetchEntryFunctionAbi = Is; exports.fetchFunctionAbi = vi; exports.fetchMoveFunctionAbi = vs; exports.fetchViewFunctionAbi = Cs; exports.findFirstNonSignerArg = xs; exports.floorToWholeHour = _chunkIHUCZKG2js.e; exports.generateRawTransaction = Ii; exports.generateSignedTransaction = Ri; exports.generateSignedTransactionForSimulation = Us; exports.generateSigningMessage = Wt; exports.generateSigningMessageForSerializable = kf; exports.generateSigningMessageForTransaction = Qt; exports.generateTransactionPayload = Cn; exports.generateTransactionPayloadWithABI = au; exports.generateUserTransactionHash = hb; exports.generateViewFunctionPayload = Ks; exports.generateViewFunctionPayloadWithABI = cu; exports.get = on; exports.getAptosFullNode = q; exports.getAptosPepperService = eg; exports.getAuthenticatorForSimulation = rr; exports.getErrorMessage = _chunkIHUCZKG2js.c; exports.getFunctionParts = zt; exports.getIssAudAndUidVal = He; exports.getKeylessConfig = Ar; exports.getKeylessJWKs = Io; exports.hashStrToField = Zr; exports.hashValues = ks; exports.hexToAsciiString = Vi; exports.isBcsAddress = vn; exports.isBcsBool = hi; exports.isBcsFixedBytes = Yc; exports.isBcsString = Ti; exports.isBcsU128 = xi; exports.isBcsU16 = wi; exports.isBcsU256 = Ei; exports.isBcsU32 = Si; exports.isBcsU64 = _i; exports.isBcsU8 = bi; exports.isBlockEpilogueTransactionResponse = Ap; exports.isBlockMetadataTransactionResponse = yp; exports.isBool = bs; exports.isCanonicalEd25519Signature = nc; exports.isEd25519Signature = hp; exports.isEmptyOption = ws; exports.isEncodedEntryFunctionArgument = Ss; exports.isEncodedStruct = _chunkIHUCZKG2js.j; exports.isFeePayerSignature = wp; exports.isGenesisTransactionResponse = gp; exports.isKeylessSigner = yn; exports.isLargeNumber = Pn; exports.isMultiAgentSignature = bp; exports.isMultiEd25519Signature = Sp; exports.isNumber = Xc; exports.isPendingTransactionResponse = dp; exports.isScriptDataInput = _s; exports.isSecp256k1Signature = Tp; exports.isSingleKeySigner = pi; exports.isStateCheckpointTransactionResponse = mp; exports.isString = ct; exports.isUserTransactionResponse = lp; exports.isValidBIP44Path = ro; exports.isValidHardenedPath = no; exports.isValidatorTransactionResponse = fp; exports.mnemonicToSeed = Xr; exports.normalizeBundle = bo; exports.nowInSeconds = _chunkIHUCZKG2js.d; exports.objectStructTag = de; exports.optionStructTag = wm; exports.outOfRangeErrorMessage = qa; exports.padAndPackBytesWithLen = Xn; exports.paginateWithCursor = sn; exports.paginateWithObfuscatedCursor = ii; exports.parseEncodedStruct = _chunkIHUCZKG2js.i; exports.parseJwtHeader = Fc; exports.parseTypeTag = Ne; exports.poseidonHash = mr; exports.post = fr; exports.postAptosFaucet = _o; exports.postAptosFullNode = ot; exports.postAptosIndexer = So; exports.postAptosPepperService = xo; exports.postAptosProvingService = Eo; exports.promiseFulfilledStatus = Na; exports.request = Kc; exports.sleep = _chunkIHUCZKG2js.b; exports.splitPath = oo; exports.standardizeTypeTags = tr; exports.stringStructTag = v; exports.throwTypeMismatch = D; exports.validateNumberInRange = tt;
479
+ will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await Ce(async()=>{try{let d=(await oe({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(d.vec.length>0&&_chunkZYPBABLQjs.ga.call(void 0, d.vec[0]))return _chunkZYPBABLQjs.fa.call(void 0, d.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunkZYPBABLQjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===At?a=_chunkZYPBABLQjs.Z.A.toStringLong():a=tr(_chunkZYPBABLQjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=_chunkZYPBABLQjs.Z.from(i);a=d.toStringLong(),d===_chunkZYPBABLQjs.Z.A&&(s=At)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[d]=await oe({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(d,10)}let[c]=await oe({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 S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),as({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return cs({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var vr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _126 => _126.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _127 => _127.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _128 => _128.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _129 => _129.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _130 => _130.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _131 => _131.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _132 => _132.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _133 => _133.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _134 => _134.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _135 => _135.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _136 => _136.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 io[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return oo[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 ro[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 Lr[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 Hr[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Lr[this.network]===e}isProverServiceRequest(e){return Hr[this.network]===e}};var fu={typeParameters:[{constraints:[]}],parameters:[new F,new j]};async function Fs(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return w({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (At))],functionArguments:[r,i],abi:fu},options:s})}var In=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Fs({aptosConfig:this.config,...e})}};var st={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Te="0x4::token::Token";async function Ns(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return(await T({aptosConfig:e,query:{query:Ho,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Gs(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await T({aptosConfig:e,query:{query:si,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Bs(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:si,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _137 => _137.offset]),limit:_optionalChain([r, 'optionalAccess', _138 => _138.limit]),order_by:_optionalChain([r, 'optionalAccess', _139 => _139.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ms(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}},o={query:Lo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _140 => _140.offset]),limit:_optionalChain([r, 'optionalAccess', _141 => _141.limit]),order_by:_optionalChain([r, 'optionalAccess', _142 => _142.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Au={typeParameters:[],parameters:[new A(P()),new j,new A(P()),new A(P()),new V,new V,new V,new V,new V,new V,new V,new V,new V,new j,new j]};async function Vs(n){let{aptosConfig:e,options:t,creator:r}=n;return w({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new E(n.description),new W(_nullishCoalesce(n.maxSupply, () => (_chunkZYPBABLQjs.e))),new E(n.name),new E(n.uri),new U(_nullishCoalesce(n.mutableDescription, () => (!0))),new U(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new U(_nullishCoalesce(n.mutableURI, () => (!0))),new U(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new U(_nullishCoalesce(n.mutableTokenName, () => (!0))),new U(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new U(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new U(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new U(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new W(_nullishCoalesce(n.royaltyNumerator, () => (0))),new W(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Au},options:t})}async function Zt(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _143 => _143.where]);_optionalChain([t, 'optionalAccess', _144 => _144.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _145 => _145.tokenStandard]), () => ("v2"))});let i={query:Oo,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _146 => _146.offset]),limit:_optionalChain([t, 'optionalAccess', _147 => _147.limit])}};return(await T({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function qs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunkZYPBABLQjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _148 => _148.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _149 => _149.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...i,where:s}})}async function Ls(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _150 => _150.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _151 => _151.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...r,where:o}})}async function Hs(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _152 => _152.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...r,where:o}})}async function $s(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunkZYPBABLQjs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _154 => _154.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),(await Zt({aptosConfig:i,options:{where:s}})).collection_id}var hu={typeParameters:[],parameters:[new A(P()),new A(P()),new A(P()),new A(P()),new v(new A(P())),new v(new A(P())),new v(v.u8())]};async function Ws(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:y}=n,h=_optionalChain([d, 'optionalAccess', _156 => _156.map, 'call', _157 => _157(p=>st[p])]);return w({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new E(i),new E(o),new E(s),new E(a),_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(h, () => ([]))),aa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(h, () => ([])))],abi:hu},options:t})}var Tu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new F]};async function Qs(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(r),_chunkZYPBABLQjs.Z.from(i)],abi:Tu},options:s})}var bu={typeParameters:[],parameters:[new A(P()),new A(P()),new A(P()),new A(P()),new v(new A(P())),new v(new A(P())),new v(v.u8()),new F]};async function js(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:y,options:h}=n;if(_optionalChain([c, 'optionalAccess', _158 => _158.length])!==_optionalChain([y, 'optionalAccess', _159 => _159.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _160 => _160.length])!==_optionalChain([y, 'optionalAccess', _161 => _161.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _162 => _162.map, 'call', _163 => _163(l=>st[l])]);return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(p, () => ([]))),aa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:bu},options:h})}var wu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Js(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(r)],abi:wu},options:o})}var Su={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Xs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[r],abi:Su},options:o})}var _u={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Ys(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[r],abi:_u},options:o})}var Pu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function Zs(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:Pu},options:s})}var Eu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ea(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:Eu},options:s})}var xu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ta(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:xu},options:s})}var Iu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P()),new A(P()),v.u8()]};async function na(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),new E(st[i]),_.U8(Ei(o,st[i]))],abi:Iu},options:c})}var vu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ra(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:vu},options:s})}var Cu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P()),new A(P()),v.u8()]};async function ia(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),new E(st[i]),Ei(o,st[i])],abi:Cu},options:c})}var Ku={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(P()),new G(1)]};async function oa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Te)),st[i]],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),o],abi:Ku},options:c})}var Ru={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(P()),new G(1)]};async function sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Te)),st[i]],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),o],abi:Ru},options:c})}function aa(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Ei(n[i],r))}),t}function Ei(n,e){let t=Oe(e);return Kt(n,t,0,[]).bcsToBytes()}var vn=class{constructor(e){this.config=e}async getCollectionData(e){await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunkZYPBABLQjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _164 => _164.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _165 => _165.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$s({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ns({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Gs({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Bs({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ms({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Vs({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Ws({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Qs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return js({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Js({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Xs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Ys({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Zs({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ea({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ta({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return na({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return ra({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return ia({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return oa({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return sa({aptosConfig:this.config,...e})}};var ca=300,Uu=n=>{if(n&&n.length>ca)throw new Error(`Event type length exceeds the maximum length of ${ca}`)};async function ua(n){let{aptosConfig:e,eventType:t,options:r}=n,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 Cn({aptosConfig:e,options:{...r,where:i}})}async function da(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunkZYPBABLQjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Cn({aptosConfig:t,options:{...i,where:s}})}async function pa(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunkZYPBABLQjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Cn({aptosConfig:t,options:{...i,where:s}})}async function Cn(n){let{aptosConfig:e,options:t}=n;Uu(_optionalChain([t, 'optionalAccess', _166 => _166.where, 'optionalAccess', _167 => _167.indexed_type, 'optionalAccess', _168 => _168._eq]));let r={query:Go,variables:{where_condition:_optionalChain([t, 'optionalAccess', _169 => _169.where]),offset:_optionalChain([t, 'optionalAccess', _170 => _170.offset]),limit:_optionalChain([t, 'optionalAccess', _171 => _171.limit]),order_by:_optionalChain([t, 'optionalAccess', _172 => _172.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Kn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ua({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),da({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),pa({aptosConfig:this.config,...e})}async getEvents(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _173 => _173.minimumLedgerVersion]),processorType:"events_processor"}),Cn({aptosConfig:this.config,...e})}};async function la(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _174 => _174.timeoutSecs])||20,{data:s}=await yo({aptosConfig:e,path:"fund",body:{address:_chunkZYPBABLQjs.Z.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Jt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _175 => _175.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Rn=class{constructor(e){this.config=e}async fundAccount(e){let t=await la({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _176 => _176.options, 'optionalAccess', _177 => _177.waitForIndexer])===void 0||_optionalChain([e, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.waitForIndexer]))&&await Tr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Cr(n){let{aptosConfig:e,options:t}=n,r={query:Mo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _180 => _180.where]),limit:_optionalChain([t, 'optionalAccess', _181 => _181.limit]),offset:_optionalChain([t, 'optionalAccess', _182 => _182.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ga(n){let{aptosConfig:e,options:t}=n,r={query:Bo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _183 => _183.where]),limit:_optionalChain([t, 'optionalAccess', _184 => _184.limit]),offset:_optionalChain([t, 'optionalAccess', _185 => _185.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ma(n){let{aptosConfig:e,options:t}=n,r={query:Fo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _186 => _186.where]),limit:_optionalChain([t, 'optionalAccess', _187 => _187.limit]),offset:_optionalChain([t, 'optionalAccess', _188 => _188.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var zu={typeParameters:[{constraints:[]}],parameters:[Oe("0x1::object::Object"),new F,new j]};async function ya(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:zu},options:s})}var Un=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _189 => _189.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Cr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _190 => _190.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Cr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _191 => _191.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Cr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunkZYPBABLQjs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _192 => _192.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ga({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ma({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ya({aptosConfig:this.config,...e})}};var zn=class{constructor(e){this.config=e}async getLedgerInfo(){return lr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return ps({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ls({aptosConfig:this.config,...e})}async view(e){return oe({aptosConfig:this.config,...e})}async viewJson(e){return Cs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return $o({aptosConfig:this.config,...e})}async queryIndexer(e){return T({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return gr({aptosConfig:this.config})}async getProcessorStatus(e){return mr({aptosConfig:this.config,processorType:e})}};var fa=["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 Aa(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function at(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Aa(e))throw new Error(`${e} is not valid. ${fa}`);if(t&&!Aa(t))throw new Error(`${t} is not valid. ${fa}`);return{domainName:t||e,subdomainName:t?e:void 0}}function ha(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Du="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ku={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Du,custom:null,devnet:null};function Ze(n){let e=ku[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Kr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ta(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t),s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Kr(s[0]);return a?_chunkZYPBABLQjs.Z.from(a):void 0}async function ba(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=Ze(e),{domainName:y,subdomainName:h}=at(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let ee=_nullishCoalesce(t.years, () => (1));if(ee!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ut=ee*31536e3;return await w({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[y,Ut,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let l=await xi({aptosConfig:e,name:y});if(!l)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:l;if(b>l)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await w({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[y,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function xi(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t);try{let s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function wa(n){let{aptosConfig:e,address:t}=n,r=Ze(e),i=await oe({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunkZYPBABLQjs.Z.from(t).toString()]}}),o=Kr(i[1]),s=Kr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Sa(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Ze(e);if(!r)return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=at(r);return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function _a(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t),s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Kr(s[0]);return a?_chunkZYPBABLQjs.Z.from(a):void 0}async function Pa(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=Ze(e),{domainName:a,subdomainName:c}=at(r);return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ea(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=at(t),a=(await T({aptosConfig:e,query:{query:Qt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Dn(a)),ha(a)?a:void 0}async function xa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountNames",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _194 => _194.limit]),offset:_optionalChain([t, 'optionalAccess', _195 => _195.offset]),order_by:_optionalChain([t, 'optionalAccess', _196 => _196.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _197 => _197.options, 'optionalAccess', _198 => _198.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Dn)}async function Ia(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _199 => _199.limit]),offset:_optionalChain([t, 'optionalAccess', _200 => _200.offset]),order_by:_optionalChain([t, 'optionalAccess', _201 => _201.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Dn)}async function va(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _204 => _204.limit]),offset:_optionalChain([t, 'optionalAccess', _205 => _205.offset]),order_by:_optionalChain([t, 'optionalAccess', _206 => _206.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _207 => _207.options, 'optionalAccess', _208 => _208.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dn)}async function Ca(n){let{aptosConfig:e,options:t,domain:r}=n;return(await T({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),offset:_optionalChain([t, 'optionalAccess', _210 => _210.offset]),order_by:_optionalChain([t, 'optionalAccess', _211 => _211.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dn).filter(ha)}async function Ii(n){let{aptosConfig:e}=n,t=Ze(e),[r]=await oe({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Ka(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=Ze(e),a=i*31536e3,{domainName:c,subdomainName:d}=at(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Dn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var kn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ta({aptosConfig:this.config,...e})}async getExpiration(e){return xi({aptosConfig:this.config,...e})}async getTargetAddress(e){return _a({aptosConfig:this.config,...e})}async setTargetAddress(e){return Pa({aptosConfig:this.config,...e})}async getPrimaryName(e){return wa({aptosConfig:this.config,...e})}async setPrimaryName(e){return Sa({aptosConfig:this.config,...e})}async registerName(e){return ba({aptosConfig:this.config,...e})}async renewDomain(e){return Ka({aptosConfig:this.config,...e})}async getName(e){return Ea({aptosConfig:this.config,...e})}async getAccountNames(e){return xa({aptosConfig:this.config,...e})}async getAccountDomains(e){return Ia({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return va({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Ca({aptosConfig:this.config,...e})}};async function Ra(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:ii,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:ii,variables:{order_by:_optionalChain([t, 'optionalAccess', _214 => _214.orderBy])}};return(await T({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:No,variables:{delegatorAddress:_chunkZYPBABLQjs.Z.from(t).toStringLong(),poolAddress:_chunkZYPBABLQjs.Z.from(r).toStringLong()}};return(await T({aptosConfig:e,query:i})).delegated_staking_activities}var On=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _215 => _215.minimumLedgerVersion]),processorType:"stake_processor"}),Ra({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _216 => _216.minimumLedgerVersion]),processorType:"stake_processor"}),Ua({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"stake_processor"}),za({aptosConfig:this.config,...e})}};var Rr=class{constructor(e){this.config=e}async simple(e){return w({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Er(this.config);await t.init();let i=(await e.builder(t)).build(),o=await bi({aptosConfig:this.config,payload:wt.load(new C(i)),...e});return new Lt(o,e.withFeePayer===!0?_chunkZYPBABLQjs.Z.ZERO:void 0)}async multiAgent(e){return w({aptosConfig:this.config,...e})}};function vi(n,e,t){let r=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 r.apply(this,i)},t}function Ci(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var en=class{constructor(e){this.config=e}async simple(e){return Pi({aptosConfig:this.config,...e})}async multiAgent(e){return Pi({aptosConfig:this.config,...e})}};_chunkZYPBABLQjs.a.call(void 0, [Ci],en.prototype,"simple",1),_chunkZYPBABLQjs.a.call(void 0, [Ci],en.prototype,"multiAgent",1);var tn=class{constructor(e){this.config=e}async simple(e){return Pn({aptosConfig:this.config,...e})}async multiAgent(e){return Pn({aptosConfig:this.config,...e})}};_chunkZYPBABLQjs.a.call(void 0, [vi],tn.prototype,"simple",1),_chunkZYPBABLQjs.a.call(void 0, [vi],tn.prototype,"multiAgent",1);var Ur=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkZYPBABLQjs._.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=_chunkZYPBABLQjs.aa.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkZYPBABLQjs._.call(void 0, this.sleepTime),_chunkZYPBABLQjs.aa.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 ke({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await ke({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 _chunkZYPBABLQjs._.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkZYPBABLQjs.aa.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkZYPBABLQjs.aa.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 _chunkZYPBABLQjs._.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 nn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _218 => _218.pendingDequeue, 'access', _219 => _219.shift, 'call', _220 => _220(), 'optionalAccess', _221 => _221.resolve, 'call', _222 => _222(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 rn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},rn=class extends Error{};var Da="fulfilled",ka= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(ka||{}),zr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new nn;this.transactionsQueue=new nn;this.outstandingTransactions=new nn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Ur(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=En({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof rn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Da?(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 rn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Jt({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===Da?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,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,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return w({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}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 Dr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new zr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}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:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Fn=class{constructor(e){this.config=e,this.build=new Rr(this.config),this.simulate=new en(this.config),this.submit=new tn(this.config),this.batch=new Dr(this.config)}async getTransactions(e){return ui({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return us({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Sn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ds({aptosConfig:this.config,...e})}async waitForTransaction(e){return Jt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return hr({aptosConfig:this.config})}getSigningMessage(e){return Ks(e)}async publishPackageTransaction(e){return Us({aptosConfig:this.config,...e})}async rotateAuthKey(e){return zs({aptosConfig:this.config,...e})}sign(e){return xr({...e})}signAsFeePayer(e){return Ir({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return En({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Rs({aptosConfig:this.config,...e})}};var Nn=class{constructor(e){this.config=e}async getTableItem(e){return yr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Wo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qo({aptosConfig:this.config,...e})}};async function kr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunkZYPBABLQjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await fo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunkZYPBABLQjs.j.fromHexInput(a.pepper).toUint8Array()}async function Ki(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await kr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await ln({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array().length!==Xe.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Xe.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<r.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:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunkZYPBABLQjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunkZYPBABLQjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await Ao({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),y=d.proof,h=new Bt({a:y.a,b:y.b,c:y.c});return new Ee({proof:new Mt(h,0),trainingWheelsSignature:ve.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Oa(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await kr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await ln({aptosConfig:e}),d=Ki({...n,pepper:s,maxExpHorizonSecs:c}),y=o?d:await d;if(r!==void 0){let l=te.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await jt({aptosConfig:e,authenticationKey:l.authKey().derivedAddress()});return Ct.create({...n,address:b,proof:y,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=k.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await jt({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return Xe.create({...n,address:p,proof:y,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Fa(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(po.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,z.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,_.MoveString(a.keys.map(c=>c.kid)),_.MoveString(a.keys.map(c=>c.alg)),_.MoveString(a.keys.map(c=>c.e)),_.MoveString(a.keys.map(c=>c.n))]},options:i})}var Gn=class{constructor(e){this.config=e}async getPepper(e){return kr({aptosConfig:this.config,...e})}async getProof(e){return Ki({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Oa({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Fa({aptosConfig:this.config,...e})}};async function Gu(n){let{aptosConfig:e,options:t}=n,r={query:pr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _223 => _223.where]),offset:_optionalChain([t, 'optionalAccess', _224 => _224.offset]),limit:_optionalChain([t, 'optionalAccess', _225 => _225.limit]),order_by:_optionalChain([t, 'optionalAccess', _226 => _226.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Na(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return(await Gu({aptosConfig:e,options:{...r,where:o}}))[0]}var Bn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Na({aptosConfig:this.config,...e})}};var Z=class{constructor(e){this.config=new vr(e),this.account=new xn(this.config),this.abstraction=new Rt(this.config),this.ans=new kn(this.config),this.coin=new In(this.config),this.digitalAsset=new vn(this.config),this.event=new Kn(this.config),this.faucet=new Rn(this.config),this.fungibleAsset=new Un(this.config),this.general=new zn(this.config),this.staking=new On(this.config),this.transaction=new Fn(this.config),this.table=new Nn(this.config),this.keyless=new Gn(this.config),this.object=new Bn(this.config)}};function se(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}se(Z,xn,"account");se(Z,Rt,"abstraction");se(Z,kn,"ans");se(Z,In,"coin");se(Z,vn,"digitalAsset");se(Z,Kn,"event");se(Z,Rn,"faucet");se(Z,Un,"fungibleAsset");se(Z,zn,"general");se(Z,On,"staking");se(Z,Fn,"transaction");se(Z,Nn,"table");se(Z,Gn,"keyless");se(Z,Bn,"object");exports.APTOS_BIP44_REGEX = Ya; exports.APTOS_COIN = At; exports.APTOS_FA = co; exports.APTOS_HARDENED_REGEX = Xa; exports.AbstractKeylessAccount = pe; exports.AbstractedAccount = Io; exports.Account = De; exports.AccountAddress = _chunkZYPBABLQjs.Z; exports.AccountAuthenticator = Q; exports.AccountAuthenticatorAbstraction = gn; exports.AccountAuthenticatorEd25519 = xe; exports.AccountAuthenticatorMultiEd25519 = nr; exports.AccountAuthenticatorMultiKey = Ue; exports.AccountAuthenticatorNoAccountAuthenticator = Vt; exports.AccountAuthenticatorSingleKey = ie; exports.AccountAuthenticatorVariant = _chunkZYPBABLQjs.w; exports.AccountPublicKey = Y; exports.AccountSequenceNumber = Ur; exports.AccountUtils = Eo; exports.AddressInvalidReason = _chunkZYPBABLQjs.Y; exports.AnyPublicKey = O; exports.AnyPublicKeyVariant = _chunkZYPBABLQjs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunkZYPBABLQjs.z; exports.Aptos = Z; exports.AptosApiError = ye; exports.AptosApiType = ft; exports.AptosConfig = vr; exports.AptosScriptComposer = Er; exports.AuthenticationKey = B; exports.Bool = U; exports.CKDPriv = Ji; exports.CallArgument = _chunkZYPBABLQjs.X; exports.ChainId = qt; exports.DEFAULT_MAX_GAS_AMOUNT = so; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = ao; exports.DEFAULT_TXN_TIMEOUT_SEC = Jn; exports.DeriveScheme = _chunkZYPBABLQjs.W; exports.Deserializer = C; exports.EPK_HORIZON_SECS = mg; exports.Ed25519Account = Ae; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = x; exports.Ed25519Signature = I; exports.EntryFunction = St; exports.EntryFunctionBytes = Hn; exports.EphemeralCertificate = Gt; exports.EphemeralCertificateVariant = _chunkZYPBABLQjs.C; exports.EphemeralKeyPair = vt; exports.EphemeralPublicKey = yt; exports.EphemeralPublicKeyVariant = _chunkZYPBABLQjs.A; exports.EphemeralSignature = ve; exports.EphemeralSignatureVariant = _chunkZYPBABLQjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = po; exports.FederatedKeylessAccount = Ct; exports.FederatedKeylessPublicKey = te; exports.FeePayerRawTransaction = Pt; exports.FixedBytes = pt; exports.Groth16VerificationKey = Zr; exports.Groth16Zkp = Bt; exports.HARDENED_OFFSET = Wi; exports.Hex = _chunkZYPBABLQjs.j; exports.HexInvalidReason = _chunkZYPBABLQjs.i; exports.Identifier = K; exports.KeyType = Za; exports.KeylessAccount = Xe; exports.KeylessConfiguration = Yr; exports.KeylessError = z; exports.KeylessErrorCategory = Ec; exports.KeylessErrorResolutionTip = xc; exports.KeylessErrorType = Xn; exports.KeylessPublicKey = k; exports.KeylessSignature = Me; exports.MAX_AUD_VAL_BYTES = Rc; exports.MAX_COMMITED_EPK_BYTES = hg; exports.MAX_EXTRA_FIELD_BYTES = fg; exports.MAX_ISS_VAL_BYTES = yg; exports.MAX_JWT_HEADER_B64_BYTES = Ag; exports.MAX_UID_KEY_BYTES = Uc; exports.MAX_UID_VAL_BYTES = zc; exports.MimeType = _chunkZYPBABLQjs.q; exports.ModuleId = mn; exports.MoveAbility = _chunkZYPBABLQjs.S; exports.MoveFunctionVisibility = _chunkZYPBABLQjs.R; exports.MoveJWK = ei; exports.MoveOption = X; exports.MoveString = E; exports.MoveVector = _; exports.MultiAgentRawTransaction = _t; exports.MultiAgentTransaction = ar; exports.MultiEd25519PublicKey = Ft; exports.MultiEd25519Signature = gt; exports.MultiKey = Re; exports.MultiKeyAccount = bn; exports.MultiKeySignature = qe; exports.MultiSig = hn; exports.MultiSigTransactionPayload = Tn; exports.Network = $r; exports.NetworkToChainId = Wr; exports.NetworkToFaucetAPI = oo; exports.NetworkToIndexerAPI = ro; exports.NetworkToNetworkName = cl; exports.NetworkToNodeAPI = io; exports.NetworkToPepperAPI = Lr; exports.NetworkToProverAPI = Hr; exports.ParsingError = _chunkZYPBABLQjs.h; exports.PrivateKey = nt; exports.PrivateKeyVariants = _chunkZYPBABLQjs.x; exports.ProcessorType = Ge; exports.PublicKey = lt; exports.RAW_TRANSACTION_SALT = uo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Qr; exports.RawTransaction = fe; exports.RawTransactionWithData = ir; exports.RoleType = _chunkZYPBABLQjs.T; exports.RotationProofChallenge = or; exports.Script = An; exports.ScriptTransactionArgumentVariants = _chunkZYPBABLQjs.s; exports.Secp256k1PrivateKey = Ne; exports.Secp256k1PublicKey = Fe; exports.Secp256k1Signature = mt; exports.Serializable = _chunkZYPBABLQjs.l; exports.Serialized = sn; exports.Serializer = _chunkZYPBABLQjs.m; exports.Signature = M; exports.SignedTransaction = je; exports.SigningScheme = _chunkZYPBABLQjs.U; exports.SigningSchemeInput = _chunkZYPBABLQjs.V; exports.SimpleTransaction = Lt; exports.SingleKeyAccount = he; exports.StructTag = ze; exports.TransactionAndProof = ri; exports.TransactionAuthenticator = Qe; exports.TransactionAuthenticatorEd25519 = Et; exports.TransactionAuthenticatorFeePayer = It; exports.TransactionAuthenticatorMultiAgent = xt; exports.TransactionAuthenticatorMultiEd25519 = sr; exports.TransactionAuthenticatorSingleSender = ot; exports.TransactionAuthenticatorVariant = _chunkZYPBABLQjs.v; exports.TransactionPayload = bt; exports.TransactionPayloadEntryFunction = yn; exports.TransactionPayloadMultiSig = fn; exports.TransactionPayloadScript = wt; exports.TransactionPayloadVariants = _chunkZYPBABLQjs.t; exports.TransactionResponseType = _chunkZYPBABLQjs.E; exports.TransactionVariants = _chunkZYPBABLQjs.u; exports.TransactionWorker = zr; exports.TransactionWorkerEventsEnum = ka; exports.TypeTag = N; exports.TypeTagAddress = F; exports.TypeTagBool = V; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = tu; exports.TypeTagReference = rr; exports.TypeTagSigner = Tt; exports.TypeTagStruct = A; exports.TypeTagU128 = $e; exports.TypeTagU16 = Le; exports.TypeTagU256 = We; exports.TypeTagU32 = He; exports.TypeTagU64 = j; exports.TypeTagU8 = ue; exports.TypeTagVariants = _chunkZYPBABLQjs.r; exports.TypeTagVector = v; exports.U128 = _e; exports.U16 = we; exports.U256 = le; exports.U32 = Se; exports.U64 = W; exports.U8 = J; exports.ZeroKnowledgeSig = Ee; exports.ZkProof = Mt; exports.ZkpVariant = _chunkZYPBABLQjs.D; exports.aptosCoinStructTag = cy; exports.aptosRequest = Yn; exports.base64UrlDecode = _chunkZYPBABLQjs.ca; exports.bigIntToBytesLE = to; exports.buildTransaction = wi; exports.bytesToBigIntLE = un; exports.checkOrConvertArgument = Kt; exports.convertAmountFromHumanReadableToOnChain = _chunkZYPBABLQjs.da; exports.convertAmountFromOnChainToHumanReadable = _chunkZYPBABLQjs.ea; exports.convertArgument = _r; exports.convertCallArgument = Ps; exports.convertNumber = br; exports.createObjectAddress = tr; exports.createResourceAddress = Am; exports.createTokenAddress = hm; exports.deriveKey = Br; exports.deriveTransactionType = ti; exports.deserializeFromScriptArgument = Nc; exports.ensureBoolean = _chunkZYPBABLQjs.n; exports.fetchEntryFunctionAbi = Ss; exports.fetchFunctionAbi = Ti; exports.fetchMoveFunctionAbi = ws; exports.fetchViewFunctionAbi = _s; exports.findFirstNonSignerArg = hs; exports.floorToWholeHour = _chunkZYPBABLQjs.ba; exports.generateRawTransaction = bi; exports.generateSignedTransaction = Si; exports.generateSignedTransactionForSimulation = xs; exports.generateSigningMessage = Ht; exports.generateSigningMessageForSerializable = wf; exports.generateSigningMessageForTransaction = Je; exports.generateTransactionPayload = Pr; exports.generateTransactionPayloadWithABI = ou; exports.generateUserTransactionHash = Pb; exports.generateViewFunctionPayload = Es; exports.generateViewFunctionPayloadWithABI = su; exports.get = Zn; exports.getAptosFullNode = L; exports.getAptosPepperService = kl; exports.getAuthenticatorForSimulation = Yt; exports.getErrorMessage = _chunkZYPBABLQjs.$; exports.getFunctionParts = _chunkZYPBABLQjs.ha; exports.getIssAudAndUidVal = Ve; exports.getKeylessConfig = ln; exports.getKeylessJWKs = bo; exports.hashStrToField = Qn; exports.hashValues = Is; exports.hexToAsciiString = _chunkZYPBABLQjs.k; exports.isBcsAddress = Sr; exports.isBcsBool = di; exports.isBcsFixedBytes = Jc; exports.isBcsString = pi; exports.isBcsU128 = fi; exports.isBcsU16 = gi; exports.isBcsU256 = Ai; exports.isBcsU32 = mi; exports.isBcsU64 = yi; exports.isBcsU8 = li; exports.isBlockEpilogueTransactionResponse = _chunkZYPBABLQjs.L; exports.isBlockMetadataTransactionResponse = _chunkZYPBABLQjs.I; exports.isBool = ms; exports.isCanonicalEd25519Signature = tc; exports.isEd25519Signature = _chunkZYPBABLQjs.M; exports.isEmptyOption = ys; exports.isEncodedEntryFunctionArgument = fs; exports.isEncodedStruct = _chunkZYPBABLQjs.ga; exports.isFeePayerSignature = _chunkZYPBABLQjs.P; exports.isGenesisTransactionResponse = _chunkZYPBABLQjs.H; exports.isKeylessSigner = cr; exports.isLargeNumber = wr; exports.isMultiAgentSignature = _chunkZYPBABLQjs.O; exports.isMultiEd25519Signature = _chunkZYPBABLQjs.Q; exports.isNumber = jc; exports.isPendingTransactionResponse = _chunkZYPBABLQjs.F; exports.isScriptDataInput = As; exports.isSecp256k1Signature = _chunkZYPBABLQjs.N; exports.isSingleKeySigner = ni; exports.isStateCheckpointTransactionResponse = _chunkZYPBABLQjs.J; exports.isString = Ye; exports.isUserTransactionResponse = _chunkZYPBABLQjs.G; exports.isValidBIP44Path = Qi; exports.isValidFunctionInfo = _chunkZYPBABLQjs.ia; exports.isValidHardenedPath = ji; exports.isValidatorTransactionResponse = _chunkZYPBABLQjs.K; exports.mnemonicToSeed = $n; exports.normalizeBundle = lo; exports.nowInSeconds = _chunkZYPBABLQjs.aa; exports.objectStructTag = de; exports.optionStructTag = uy; exports.outOfRangeErrorMessage = _chunkZYPBABLQjs.o; exports.padAndPackBytesWithLen = qr; exports.paginateWithCursor = er; exports.paginateWithObfuscatedCursor = Jr; exports.parseEncodedStruct = _chunkZYPBABLQjs.fa; exports.parseJwtHeader = Oc; exports.parseTypeTag = Oe; exports.poseidonHash = dn; exports.post = pn; exports.postAptosFaucet = yo; exports.postAptosFullNode = it; exports.postAptosIndexer = mo; exports.postAptosPepperService = fo; exports.postAptosProvingService = Ao; exports.promiseFulfilledStatus = Da; exports.request = Cc; exports.sleep = _chunkZYPBABLQjs._; exports.splitPath = Xi; exports.standardizeTypeTags = Xt; exports.stringStructTag = P; exports.throwTypeMismatch = D; exports.validateNumberInRange = _chunkZYPBABLQjs.p;
482
480
  //# sourceMappingURL=index.js.map