@aptos-labs/ts-sdk 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/dist/browser/index.d.ts +1131 -989
  2. package/dist/browser/index.global.js +30 -30
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/common/index.d.ts +1131 -989
  5. package/dist/common/index.js +25 -25
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/api/account.d.mts +12 -6
  8. package/dist/esm/api/account.mjs +1 -1
  9. package/dist/esm/api/ans.d.mts +11 -12
  10. package/dist/esm/api/ans.mjs +1 -1
  11. package/dist/esm/api/aptos.d.mts +13 -14
  12. package/dist/esm/api/aptos.mjs +1 -1
  13. package/dist/esm/api/aptosConfig.mjs +1 -1
  14. package/dist/esm/api/coin.d.mts +13 -13
  15. package/dist/esm/api/coin.mjs +1 -1
  16. package/dist/esm/api/digitalAsset.d.mts +20 -10
  17. package/dist/esm/api/digitalAsset.mjs +1 -1
  18. package/dist/esm/api/event.mjs +1 -1
  19. package/dist/esm/api/faucet.mjs +1 -1
  20. package/dist/esm/api/fungibleAsset.d.mts +9 -10
  21. package/dist/esm/api/fungibleAsset.mjs +1 -1
  22. package/dist/esm/api/general.mjs +1 -1
  23. package/dist/esm/api/index.d.mts +13 -14
  24. package/dist/esm/api/index.mjs +1 -1
  25. package/dist/esm/api/staking.mjs +1 -1
  26. package/dist/esm/api/transaction.d.mts +5 -6
  27. package/dist/esm/api/transaction.mjs +1 -1
  28. package/dist/esm/api/transactionSubmission/build.d.mts +8 -8
  29. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  30. package/dist/esm/api/transactionSubmission/management.d.mts +11 -12
  31. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  32. package/dist/esm/api/transactionSubmission/sign.d.mts +11 -12
  33. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  34. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  35. package/dist/esm/api/transactionSubmission/simulate.d.mts +11 -11
  36. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  37. package/dist/esm/api/transactionSubmission/submit.d.mts +6 -6
  38. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  39. package/dist/esm/api/utils.mjs +1 -1
  40. package/dist/esm/bcs/index.mjs +1 -1
  41. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  42. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  43. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  44. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  45. package/dist/esm/bcs/serializer.mjs +1 -1
  46. package/dist/esm/{chunk-GD5TZLBF.mjs → chunk-27XWZ5HH.mjs} +2 -2
  47. package/dist/esm/{chunk-VPQ46CAO.mjs → chunk-2CZ7RDU5.mjs} +2 -2
  48. package/dist/esm/{chunk-SXIFL5DQ.mjs → chunk-2LRDOYKF.mjs} +2 -2
  49. package/dist/esm/chunk-2YB3QA6V.mjs +2 -0
  50. package/dist/esm/chunk-2YB3QA6V.mjs.map +1 -0
  51. package/dist/esm/{chunk-F7CR75CJ.mjs → chunk-3BWYI3KO.mjs} +2 -2
  52. package/dist/esm/chunk-3E4BKDQU.mjs +2 -0
  53. package/dist/esm/chunk-3E4BKDQU.mjs.map +1 -0
  54. package/dist/esm/chunk-3FGD73JA.mjs +2 -0
  55. package/dist/esm/chunk-3FGD73JA.mjs.map +1 -0
  56. package/dist/esm/{chunk-GD4ULEBC.mjs → chunk-4H3C3V6D.mjs} +2 -2
  57. package/dist/esm/{chunk-W4UDMBMU.mjs → chunk-4M3DGBX6.mjs} +2 -2
  58. package/dist/esm/chunk-53HSYUXO.mjs +2 -0
  59. package/dist/esm/chunk-53HSYUXO.mjs.map +1 -0
  60. package/dist/esm/chunk-5VWG45IO.mjs +2 -0
  61. package/dist/esm/chunk-5VWG45IO.mjs.map +1 -0
  62. package/dist/esm/chunk-5ZWEKLOT.mjs +2 -0
  63. package/dist/esm/chunk-5ZWEKLOT.mjs.map +1 -0
  64. package/dist/esm/chunk-637CGNKQ.mjs +2 -0
  65. package/dist/esm/chunk-637CGNKQ.mjs.map +1 -0
  66. package/dist/esm/chunk-6CSXIJR4.mjs +2 -0
  67. package/dist/esm/chunk-6CSXIJR4.mjs.map +1 -0
  68. package/dist/esm/{chunk-4OI7MPFH.mjs → chunk-AKBRO5YS.mjs} +2 -2
  69. package/dist/esm/{chunk-F7MOQC7Z.mjs → chunk-BMDNUQIP.mjs} +2 -2
  70. package/dist/esm/{chunk-EUHPML5E.mjs → chunk-BR6FLUGH.mjs} +2 -2
  71. package/dist/esm/{chunk-6SRENFWH.mjs → chunk-CARQVN57.mjs} +2 -2
  72. package/dist/esm/{chunk-Q5HK3U64.mjs → chunk-DGZIRX6Z.mjs} +2 -2
  73. package/dist/esm/{chunk-2DNPRIS5.mjs → chunk-DWRBQ52O.mjs} +2 -2
  74. package/dist/esm/{chunk-XBVORX5O.mjs → chunk-DZNEBO5A.mjs} +2 -2
  75. package/dist/esm/{chunk-Q3HAJVCM.mjs → chunk-FI2B5BQ2.mjs} +2 -2
  76. package/dist/esm/chunk-FWDKABRW.mjs +2 -0
  77. package/dist/esm/chunk-FWDKABRW.mjs.map +1 -0
  78. package/dist/esm/chunk-G542XORT.mjs +2 -0
  79. package/dist/esm/chunk-G542XORT.mjs.map +1 -0
  80. package/dist/esm/{chunk-4M46AWXX.mjs → chunk-HE4FXVC4.mjs} +2 -2
  81. package/dist/esm/chunk-HEPV52CH.mjs +2 -0
  82. package/dist/esm/chunk-HEPV52CH.mjs.map +1 -0
  83. package/dist/esm/chunk-HIUJDWMR.mjs +2 -0
  84. package/dist/esm/{chunk-MEPX7Z2Z.mjs.map → chunk-HIUJDWMR.mjs.map} +1 -1
  85. package/dist/esm/chunk-HK6O5AUH.mjs +2 -0
  86. package/dist/esm/chunk-HK6O5AUH.mjs.map +1 -0
  87. package/dist/esm/chunk-HWL7DK5X.mjs +2 -0
  88. package/dist/esm/chunk-HWL7DK5X.mjs.map +1 -0
  89. package/dist/esm/{chunk-QKTV6AZ7.mjs → chunk-HZO2FSG5.mjs} +2 -2
  90. package/dist/esm/{chunk-VRSUCKJA.mjs → chunk-IKKFQZDP.mjs} +2 -2
  91. package/dist/esm/{chunk-SPOHAEHR.mjs → chunk-J2P6ERQF.mjs} +2 -2
  92. package/dist/esm/chunk-JK2QAXF2.mjs +2 -0
  93. package/dist/esm/{chunk-XZYPAQCU.mjs.map → chunk-JK2QAXF2.mjs.map} +1 -1
  94. package/dist/esm/{chunk-S64WKSMI.mjs → chunk-JOYBEFKL.mjs} +2 -2
  95. package/dist/esm/{chunk-KJGQ4ILY.mjs → chunk-JW65YQSF.mjs} +2 -2
  96. package/dist/esm/chunk-KUX6GQ2E.mjs +1 -0
  97. package/dist/esm/chunk-L4CAATRY.mjs +2 -0
  98. package/dist/esm/chunk-L4CAATRY.mjs.map +1 -0
  99. package/dist/esm/{chunk-PJNPLRPR.mjs → chunk-L5WL2GGI.mjs} +2 -2
  100. package/dist/esm/chunk-L6NGU7XZ.mjs +2 -0
  101. package/dist/esm/chunk-L6NGU7XZ.mjs.map +1 -0
  102. package/dist/esm/{chunk-QRQAR6XO.mjs → chunk-LF67MEQF.mjs} +2 -2
  103. package/dist/esm/{chunk-AFPJ2XXN.mjs → chunk-M4DLGIKP.mjs} +2 -2
  104. package/dist/esm/{chunk-7D5LHQNS.mjs → chunk-MX5RTG3J.mjs} +2 -2
  105. package/dist/esm/{chunk-B2ZKW23W.mjs → chunk-NL6SHGNC.mjs} +2 -2
  106. package/dist/esm/chunk-ODJTKMBB.mjs +2 -0
  107. package/dist/esm/{chunk-SRZTA6QH.mjs.map → chunk-ODJTKMBB.mjs.map} +1 -1
  108. package/dist/esm/chunk-ODSW4WOX.mjs +2 -0
  109. package/dist/esm/chunk-ODSW4WOX.mjs.map +1 -0
  110. package/dist/esm/chunk-QE4ASJ5K.mjs +1 -0
  111. package/dist/esm/{chunk-ENKMOALS.mjs → chunk-QIKGTKEF.mjs} +2 -2
  112. package/dist/esm/chunk-QIKGTKEF.mjs.map +1 -0
  113. package/dist/esm/{chunk-M3WNE7MU.mjs → chunk-QT4YHSGZ.mjs} +2 -2
  114. package/dist/esm/{chunk-PMWH5IGI.mjs → chunk-QTKWCACE.mjs} +2 -2
  115. package/dist/esm/{chunk-QGIJNA37.mjs → chunk-RD4HGTGK.mjs} +2 -2
  116. package/dist/esm/{chunk-IHCIKE42.mjs → chunk-RG527TGB.mjs} +2 -2
  117. package/dist/esm/{chunk-ENDUXRTK.mjs → chunk-RSV64IPI.mjs} +2 -2
  118. package/dist/esm/{chunk-VKZCIGKY.mjs → chunk-SMND5Q5T.mjs} +2 -2
  119. package/dist/esm/chunk-SPF6BCNU.mjs +2 -0
  120. package/dist/esm/chunk-SPF6BCNU.mjs.map +1 -0
  121. package/dist/esm/{chunk-Y4AKS4CY.mjs → chunk-TCXBCK5T.mjs} +2 -2
  122. package/dist/esm/{chunk-PIXE7MN5.mjs → chunk-UCA6JL25.mjs} +2 -2
  123. package/dist/esm/{chunk-2WFMD6C6.mjs → chunk-UJB36GIR.mjs} +2 -2
  124. package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
  125. package/dist/esm/{chunk-JJ6Y35DF.mjs → chunk-V5AIOBTO.mjs} +2 -2
  126. package/dist/esm/{chunk-O57QZZF2.mjs → chunk-VEBKGHUV.mjs} +2 -2
  127. package/dist/esm/chunk-VEBKGHUV.mjs.map +1 -0
  128. package/dist/esm/{chunk-PPTG6BDV.mjs → chunk-VRSSKMX4.mjs} +2 -2
  129. package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-X2OCPM7P.mjs} +2 -2
  130. package/dist/esm/{chunk-LATJGGVX.mjs → chunk-X34ZBPWT.mjs} +2 -2
  131. package/dist/esm/{chunk-V2FPYAK7.mjs → chunk-XA37GN3W.mjs} +2 -2
  132. package/dist/esm/{chunk-N4RBQZ2B.mjs → chunk-XGWFFSQ6.mjs} +2 -2
  133. package/dist/esm/{chunk-R56OJ4XC.mjs → chunk-YGW3VAPT.mjs} +2 -2
  134. package/dist/esm/{chunk-2H5Z5EHH.mjs → chunk-YNSKIECV.mjs} +2 -2
  135. package/dist/esm/{chunk-FRLPX47J.mjs → chunk-YXBNTR7V.mjs} +2 -2
  136. package/dist/esm/{chunk-JQVT2K7G.mjs → chunk-ZSPPXKRC.mjs} +2 -2
  137. package/dist/esm/client/core.mjs +1 -1
  138. package/dist/esm/client/get.mjs +1 -1
  139. package/dist/esm/client/index.mjs +1 -1
  140. package/dist/esm/client/post.mjs +1 -1
  141. package/dist/esm/core/account/Account.d.mts +20 -0
  142. package/dist/esm/core/account/Account.mjs +2 -0
  143. package/dist/esm/core/account/Ed25519Account.d.mts +20 -0
  144. package/dist/esm/core/account/Ed25519Account.mjs +2 -0
  145. package/dist/esm/core/account/SingleKeyAccount.d.mts +20 -0
  146. package/dist/esm/core/account/SingleKeyAccount.mjs +2 -0
  147. package/dist/esm/core/account/SingleKeyAccount.mjs.map +1 -0
  148. package/dist/esm/core/account/index.d.mts +305 -0
  149. package/dist/esm/core/account/index.mjs +2 -0
  150. package/dist/esm/core/account/index.mjs.map +1 -0
  151. package/dist/esm/core/accountAddress.mjs +1 -1
  152. package/dist/esm/core/authenticationKey.d.mts +7 -68
  153. package/dist/esm/core/authenticationKey.mjs +1 -1
  154. package/dist/esm/core/crypto/ed25519.d.mts +49 -61
  155. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  156. package/dist/esm/core/crypto/index.d.mts +9 -6
  157. package/dist/esm/core/crypto/index.mjs +1 -1
  158. package/dist/esm/core/crypto/multiEd25519.d.mts +17 -14
  159. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  160. package/dist/esm/core/crypto/multiKey.d.mts +70 -17
  161. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  162. package/dist/esm/core/crypto/privateKey.d.mts +35 -0
  163. package/dist/esm/core/crypto/privateKey.mjs +2 -0
  164. package/dist/esm/core/crypto/privateKey.mjs.map +1 -0
  165. package/dist/esm/core/crypto/publicKey.d.mts +13 -0
  166. package/dist/esm/core/crypto/publicKey.mjs +2 -0
  167. package/dist/esm/core/crypto/publicKey.mjs.map +1 -0
  168. package/dist/esm/core/crypto/secp256k1.d.mts +43 -67
  169. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  170. package/dist/esm/core/crypto/signature.d.mts +28 -0
  171. package/dist/esm/core/crypto/signature.mjs +2 -0
  172. package/dist/esm/core/crypto/signature.mjs.map +1 -0
  173. package/dist/esm/core/crypto/singleKey.d.mts +68 -0
  174. package/dist/esm/core/crypto/singleKey.mjs +2 -0
  175. package/dist/esm/core/crypto/singleKey.mjs.map +1 -0
  176. package/dist/esm/core/index.d.mts +9 -8
  177. package/dist/esm/core/index.mjs +1 -1
  178. package/dist/esm/index.d.mts +8 -8
  179. package/dist/esm/index.mjs +1 -1
  180. package/dist/esm/internal/account.d.mts +10 -4
  181. package/dist/esm/internal/account.mjs +1 -1
  182. package/dist/esm/internal/ans.d.mts +11 -12
  183. package/dist/esm/internal/ans.mjs +1 -1
  184. package/dist/esm/internal/coin.d.mts +12 -12
  185. package/dist/esm/internal/coin.mjs +1 -1
  186. package/dist/esm/internal/digitalAsset.d.mts +17 -14
  187. package/dist/esm/internal/digitalAsset.mjs +1 -1
  188. package/dist/esm/internal/event.d.mts +2 -2
  189. package/dist/esm/internal/event.mjs +1 -1
  190. package/dist/esm/internal/faucet.d.mts +4 -4
  191. package/dist/esm/internal/faucet.mjs +1 -1
  192. package/dist/esm/internal/fungibleAsset.d.mts +10 -11
  193. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  194. package/dist/esm/internal/general.mjs +1 -1
  195. package/dist/esm/internal/staking.d.mts +3 -3
  196. package/dist/esm/internal/staking.mjs +1 -1
  197. package/dist/esm/internal/transaction.mjs +1 -1
  198. package/dist/esm/internal/transactionSubmission.d.mts +12 -13
  199. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  200. package/dist/esm/publicKey-lq5djCIY.d.mts +113 -0
  201. package/dist/esm/transactions/authenticator/account.d.mts +6 -4
  202. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  203. package/dist/esm/transactions/authenticator/index.d.mts +6 -6
  204. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  205. package/dist/esm/transactions/authenticator/transaction.d.mts +5 -5
  206. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  207. package/dist/esm/transactions/index.d.mts +6 -7
  208. package/dist/esm/transactions/index.mjs +1 -1
  209. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  210. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  211. package/dist/esm/transactions/instances/index.d.mts +4 -4
  212. package/dist/esm/transactions/instances/index.mjs +1 -1
  213. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  214. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  215. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  216. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +2 -1
  217. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  218. package/dist/esm/transactions/instances/signedTransaction.d.mts +8 -8
  219. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  220. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  221. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  222. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +11 -5
  223. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  224. package/dist/esm/transactions/management/index.d.mts +11 -12
  225. package/dist/esm/transactions/management/index.mjs +1 -1
  226. package/dist/esm/transactions/management/transactionWorker.d.mts +11 -12
  227. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  228. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +10 -10
  229. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  230. package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -10
  231. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  232. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +8 -8
  233. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  234. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +9 -10
  235. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  236. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  237. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  238. package/dist/esm/transactions/types.d.mts +9 -9
  239. package/dist/esm/utils/const.d.mts +1 -2
  240. package/dist/esm/utils/const.mjs +1 -1
  241. package/dist/esm/utils/index.d.mts +1 -1
  242. package/dist/esm/utils/index.mjs +1 -1
  243. package/dist/esm/version.d.mts +1 -1
  244. package/dist/esm/version.mjs +1 -1
  245. package/package.json +1 -1
  246. package/src/api/aptosConfig.ts +2 -2
  247. package/src/api/digitalAsset.ts +20 -0
  248. package/src/core/account/Account.ts +245 -0
  249. package/src/core/account/Ed25519Account.ts +88 -0
  250. package/src/core/account/SingleKeyAccount.ts +120 -0
  251. package/src/core/account/index.ts +3 -0
  252. package/src/core/authenticationKey.ts +18 -52
  253. package/src/core/crypto/ed25519.ts +118 -104
  254. package/src/core/crypto/index.ts +6 -5
  255. package/src/core/crypto/multiEd25519.ts +98 -44
  256. package/src/core/crypto/multiKey.ts +192 -34
  257. package/src/core/crypto/privateKey.ts +25 -0
  258. package/src/core/crypto/publicKey.ts +52 -0
  259. package/src/core/crypto/secp256k1.ts +108 -111
  260. package/src/core/crypto/signature.ts +46 -0
  261. package/src/core/crypto/singleKey.ts +180 -0
  262. package/src/internal/account.ts +5 -3
  263. package/src/internal/digitalAsset.ts +26 -0
  264. package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +0 -1
  265. package/src/transactions/authenticator/account.ts +1 -2
  266. package/src/transactions/instances/rotationProofChallenge.ts +1 -1
  267. package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -21
  268. package/src/transactions/types.ts +1 -1
  269. package/src/utils/const.ts +0 -4
  270. package/src/version.ts +1 -1
  271. package/dist/esm/chunk-2QV6HI3M.mjs +0 -2
  272. package/dist/esm/chunk-2QV6HI3M.mjs.map +0 -1
  273. package/dist/esm/chunk-7IGH7N52.mjs +0 -2
  274. package/dist/esm/chunk-7IGH7N52.mjs.map +0 -1
  275. package/dist/esm/chunk-CCUD52OF.mjs +0 -2
  276. package/dist/esm/chunk-CCUD52OF.mjs.map +0 -1
  277. package/dist/esm/chunk-ENKMOALS.mjs.map +0 -1
  278. package/dist/esm/chunk-ERWQOVBF.mjs +0 -2
  279. package/dist/esm/chunk-ERWQOVBF.mjs.map +0 -1
  280. package/dist/esm/chunk-FBFMQZTM.mjs +0 -2
  281. package/dist/esm/chunk-FBFMQZTM.mjs.map +0 -1
  282. package/dist/esm/chunk-FP5DPRYL.mjs +0 -2
  283. package/dist/esm/chunk-FP5DPRYL.mjs.map +0 -1
  284. package/dist/esm/chunk-HHJBCGAQ.mjs +0 -2
  285. package/dist/esm/chunk-HHJBCGAQ.mjs.map +0 -1
  286. package/dist/esm/chunk-I7WRJY7K.mjs +0 -2
  287. package/dist/esm/chunk-I7WRJY7K.mjs.map +0 -1
  288. package/dist/esm/chunk-LHJSG5NE.mjs +0 -2
  289. package/dist/esm/chunk-LHJSG5NE.mjs.map +0 -1
  290. package/dist/esm/chunk-MEPX7Z2Z.mjs +0 -2
  291. package/dist/esm/chunk-O57QZZF2.mjs.map +0 -1
  292. package/dist/esm/chunk-S3FBGS3W.mjs +0 -2
  293. package/dist/esm/chunk-S3FBGS3W.mjs.map +0 -1
  294. package/dist/esm/chunk-SBMJNU2O.mjs +0 -2
  295. package/dist/esm/chunk-SBMJNU2O.mjs.map +0 -1
  296. package/dist/esm/chunk-SRZTA6QH.mjs +0 -2
  297. package/dist/esm/chunk-UCHGKGCF.mjs +0 -2
  298. package/dist/esm/chunk-UCHGKGCF.mjs.map +0 -1
  299. package/dist/esm/chunk-UIVJXLRM.mjs +0 -1
  300. package/dist/esm/chunk-V6JFR2CB.mjs +0 -2
  301. package/dist/esm/chunk-V6JFR2CB.mjs.map +0 -1
  302. package/dist/esm/chunk-XZYPAQCU.mjs +0 -2
  303. package/dist/esm/chunk-YL2EDK5M.mjs +0 -2
  304. package/dist/esm/chunk-YL2EDK5M.mjs.map +0 -1
  305. package/dist/esm/chunk-ZFIMVSCR.mjs +0 -2
  306. package/dist/esm/chunk-ZFIMVSCR.mjs.map +0 -1
  307. package/dist/esm/core/account.d.mts +0 -184
  308. package/dist/esm/core/account.mjs +0 -2
  309. package/dist/esm/core/crypto/anyPublicKey.d.mts +0 -59
  310. package/dist/esm/core/crypto/anyPublicKey.mjs +0 -2
  311. package/dist/esm/core/crypto/anySignature.d.mts +0 -31
  312. package/dist/esm/core/crypto/anySignature.mjs +0 -2
  313. package/dist/esm/core/crypto/asymmetricCrypto.d.mts +0 -74
  314. package/dist/esm/core/crypto/asymmetricCrypto.mjs +0 -2
  315. package/src/core/account.ts +0 -282
  316. package/src/core/crypto/anyPublicKey.ts +0 -92
  317. package/src/core/crypto/anySignature.ts +0 -56
  318. package/src/core/crypto/asymmetricCrypto.ts +0 -77
  319. /package/dist/esm/{chunk-GD5TZLBF.mjs.map → chunk-27XWZ5HH.mjs.map} +0 -0
  320. /package/dist/esm/{chunk-VPQ46CAO.mjs.map → chunk-2CZ7RDU5.mjs.map} +0 -0
  321. /package/dist/esm/{chunk-SXIFL5DQ.mjs.map → chunk-2LRDOYKF.mjs.map} +0 -0
  322. /package/dist/esm/{chunk-F7CR75CJ.mjs.map → chunk-3BWYI3KO.mjs.map} +0 -0
  323. /package/dist/esm/{chunk-GD4ULEBC.mjs.map → chunk-4H3C3V6D.mjs.map} +0 -0
  324. /package/dist/esm/{chunk-W4UDMBMU.mjs.map → chunk-4M3DGBX6.mjs.map} +0 -0
  325. /package/dist/esm/{chunk-4OI7MPFH.mjs.map → chunk-AKBRO5YS.mjs.map} +0 -0
  326. /package/dist/esm/{chunk-F7MOQC7Z.mjs.map → chunk-BMDNUQIP.mjs.map} +0 -0
  327. /package/dist/esm/{chunk-EUHPML5E.mjs.map → chunk-BR6FLUGH.mjs.map} +0 -0
  328. /package/dist/esm/{chunk-6SRENFWH.mjs.map → chunk-CARQVN57.mjs.map} +0 -0
  329. /package/dist/esm/{chunk-Q5HK3U64.mjs.map → chunk-DGZIRX6Z.mjs.map} +0 -0
  330. /package/dist/esm/{chunk-2DNPRIS5.mjs.map → chunk-DWRBQ52O.mjs.map} +0 -0
  331. /package/dist/esm/{chunk-XBVORX5O.mjs.map → chunk-DZNEBO5A.mjs.map} +0 -0
  332. /package/dist/esm/{chunk-Q3HAJVCM.mjs.map → chunk-FI2B5BQ2.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-4M46AWXX.mjs.map → chunk-HE4FXVC4.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-QKTV6AZ7.mjs.map → chunk-HZO2FSG5.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-VRSUCKJA.mjs.map → chunk-IKKFQZDP.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-SPOHAEHR.mjs.map → chunk-J2P6ERQF.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-S64WKSMI.mjs.map → chunk-JOYBEFKL.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-KJGQ4ILY.mjs.map → chunk-JW65YQSF.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-UIVJXLRM.mjs.map → chunk-KUX6GQ2E.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-PJNPLRPR.mjs.map → chunk-L5WL2GGI.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-QRQAR6XO.mjs.map → chunk-LF67MEQF.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-AFPJ2XXN.mjs.map → chunk-M4DLGIKP.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-7D5LHQNS.mjs.map → chunk-MX5RTG3J.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-B2ZKW23W.mjs.map → chunk-NL6SHGNC.mjs.map} +0 -0
  345. /package/dist/esm/{core/account.mjs.map → chunk-QE4ASJ5K.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-M3WNE7MU.mjs.map → chunk-QT4YHSGZ.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-PMWH5IGI.mjs.map → chunk-QTKWCACE.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-QGIJNA37.mjs.map → chunk-RD4HGTGK.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-IHCIKE42.mjs.map → chunk-RG527TGB.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-ENDUXRTK.mjs.map → chunk-RSV64IPI.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-VKZCIGKY.mjs.map → chunk-SMND5Q5T.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-Y4AKS4CY.mjs.map → chunk-TCXBCK5T.mjs.map} +0 -0
  353. /package/dist/esm/{chunk-PIXE7MN5.mjs.map → chunk-UCA6JL25.mjs.map} +0 -0
  354. /package/dist/esm/{chunk-2WFMD6C6.mjs.map → chunk-UJB36GIR.mjs.map} +0 -0
  355. /package/dist/esm/{core/crypto/anyPublicKey.mjs.map → chunk-UVSRX4SV.mjs.map} +0 -0
  356. /package/dist/esm/{chunk-JJ6Y35DF.mjs.map → chunk-V5AIOBTO.mjs.map} +0 -0
  357. /package/dist/esm/{chunk-PPTG6BDV.mjs.map → chunk-VRSSKMX4.mjs.map} +0 -0
  358. /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-X2OCPM7P.mjs.map} +0 -0
  359. /package/dist/esm/{chunk-LATJGGVX.mjs.map → chunk-X34ZBPWT.mjs.map} +0 -0
  360. /package/dist/esm/{chunk-V2FPYAK7.mjs.map → chunk-XA37GN3W.mjs.map} +0 -0
  361. /package/dist/esm/{chunk-N4RBQZ2B.mjs.map → chunk-XGWFFSQ6.mjs.map} +0 -0
  362. /package/dist/esm/{chunk-R56OJ4XC.mjs.map → chunk-YGW3VAPT.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-2H5Z5EHH.mjs.map → chunk-YNSKIECV.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-FRLPX47J.mjs.map → chunk-YXBNTR7V.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-JQVT2K7G.mjs.map → chunk-ZSPPXKRC.mjs.map} +0 -0
  366. /package/dist/esm/core/{crypto/anySignature.mjs.map → account/Account.mjs.map} +0 -0
  367. /package/dist/esm/core/{crypto/asymmetricCrypto.mjs.map → account/Ed25519Account.mjs.map} +0 -0
@@ -1,4 +1,4 @@
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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var Fs=Object.defineProperty;var qs=Object.getOwnPropertyDescriptor;var M=(n,t,e,r)=>{for(var o=r>1?void 0:r?qs(t,e):t,s=n.length-1,i;s>=0;s--)(i=n[s])&&(o=(r?i(t,e,o):i(o))||o);return r&&o&&Fs(t,e,o),o};var ge=class extends Error{constructor(e,r,o){super(o);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var Ar="1.8.0";var In=(r=>(r.JSON="application/json",r.BCS="application/x-bcs",r.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",r))(In||{}),fr= exports.TypeTagVariants =(m=>(m[m.Bool=0]="Bool",m[m.U8=1]="U8",m[m.U64=2]="U64",m[m.U128=3]="U128",m[m.Address=4]="Address",m[m.Signer=5]="Signer",m[m.Vector=6]="Vector",m[m.Struct=7]="Struct",m[m.U16=8]="U16",m[m.U32=9]="U32",m[m.U256=10]="U256",m[m.Reference=254]="Reference",m[m.Generic=255]="Generic",m))(fr||{}),ft= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(ft||{}),hr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(hr||{}),Tr= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(Tr||{}),br= exports.TransactionAuthenticatorVariant =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.MultiAgent=2]="MultiAgent",s[s.FeePayer=3]="FeePayer",s[s.SingleSender=4]="SingleSender",s))(br||{}),wr= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(wr||{}),_r= exports.AnyPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(_r||{}),Sr= exports.AnySignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Sr||{}),Un= exports.TransactionResponseType =(i=>(i.Pending="pending_transaction",i.User="user_transaction",i.Genesis="genesis_transaction",i.BlockMetadata="block_metadata_transaction",i.StateCheckpoint="state_checkpoint_transaction",i.Validator="validator_transaction",i))(Un||{});function na(n){return n.type==="pending_transaction"}function ra(n){return n.type==="user_transaction"}function oa(n){return n.type==="genesis_transaction"}function sa(n){return n.type==="block_metadata_transaction"}function ia(n){return n.type==="state_checkpoint_transaction"}function aa(n){return n.type==="validator_transaction"}function ca(n){return"signature"in n&&n.signature==="ed25519_signature"}function ua(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function pa(n){return n.type==="multi_agent_signature"}function da(n){return n.type==="fee_payer_signature"}function la(n){return n.type==="multi_ed25519_signature"}var Ks=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(Ks||{}),xr= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(xr||{}),$s= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))($s||{}),ht= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(ht||{}),vr= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(vr||{}),Ls= exports.DeriveScheme =(s=>(s[s.DeriveAuid=251]="DeriveAuid",s[s.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",s[s.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",s[s.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",s[s.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",s))(Ls||{});var Cr={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Vs(n,t){let{url:e,method:r,body:o,contentType:s,params:i,overrides:a}=n,c={..._optionalChain([a, 'optionalAccess', _2 => _2.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Ar}`,"content-type":_nullishCoalesce(s, () => ("application/json"))};return _optionalChain([a, 'optionalAccess', _3 => _3.AUTH_TOKEN])&&e.includes("faucet")&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _4 => _4.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _5 => _5.API_KEY])&&!e.includes("faucet")&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _6 => _6.API_KEY])}`),t.provider({url:e,method:r,body:o,params:i,headers:c,overrides:a})}async function Ft(n,t){let{url:e,path:r}=n,o=r?`${e}/${r}`:e,s=await Vs({...n,url:o},t.client),i={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(t.isIndexerRequest(e)){let c=i.data;if(c.errors)throw new ge(n,i,_nullishCoalesce(`Indexer error: ${c.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));i.data=c.data}if(i.status>=200&&i.status<300)return i;let a;throw i&&i.data&&"message"in i.data&&"error_code"in i.data?a=JSON.stringify(i.data):i.status in Cr?a=Cr[i.status]:a=`Unhandled Error ${i.status} : ${i.statusText}`,new ge(n,i,`${t.isFullnodeRequest(e)?"Fullnode":"Faucet"} error: ${a}`)}var Rn={mainnet:"https://indexer.mainnet.aptoslabs.com/v1/graphql",testnet:"https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql",devnet:"https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},kn= exports.NetworkToNodeAPI ={mainnet:"https://fullnode.mainnet.aptoslabs.com/v1",testnet:"https://fullnode.testnet.aptoslabs.com/v1",devnet:"https://fullnode.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},zn= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",randomnet:"https://faucet.random.aptoslabs.com",local:"http://127.0.0.1:8081"},qt= exports.Network =(i=>(i.MAINNET="mainnet",i.TESTNET="testnet",i.DEVNET="devnet",i.RANDOMNET="randomnet",i.LOCAL="local",i.CUSTOM="custom",i))(qt||{}),Nn= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70},va= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var Kt=(r=>(r[r.FULLNODE=0]="FULLNODE",r[r.INDEXER=1]="INDEXER",r[r.FAUCET=2]="FAUCET",r))(Kt||{}),Pr= exports.DEFAULT_NETWORK ="devnet",Er= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Ir= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,$t= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Lt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Ur= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",On= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Le= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(Le||{});async function Rr(n){let{aptosConfig:t,overrides:e,params:r,contentType:o,acceptType:s,path:i,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Ft({url:p,method:"GET",originMethod:a,path:i,contentType:_optionalChain([o, 'optionalAccess', _7 => _7.valueOf, 'call', _8 => _8()]),acceptType:_optionalChain([s, 'optionalAccess', _9 => _9.valueOf, 'call', _10 => _10()]),params:r,overrides:{...t.clientConfig,...e}},t)}async function V(n){return Rr({...n,type:0})}async function Ve(n){let t=[],e,r=n.params;do{let o=await Rr({type:0,aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),r.start=e}while(e!=null);return t}async function Gn(n){let{type:t,originMethod:e,path:r,body:o,acceptType:s,contentType:i,params:a,aptosConfig:c,overrides:p}=n,g=c.getRequestUrl(t);return Ft({url:g,method:"POST",originMethod:e,path:r,body:o,contentType:_optionalChain([i, 'optionalAccess', _11 => _11.valueOf, 'call', _12 => _12()]),acceptType:_optionalChain([s, 'optionalAccess', _13 => _13.valueOf, 'call', _14 => _14()]),params:a,overrides:{...c.clientConfig,...p}},c)}async function He(n){return Gn({...n,type:0})}async function kr(n){return Gn({...n,type:1})}async function zr(n){return Gn({...n,type:2})}var _utils = require('@noble/hashes/utils');var Vt=255,Ht=65535,me=4294967295,Be=18446744073709551615n,Tt=340282366920938463463374607431768211455n,Qt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var F=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Ws=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Ws||{}),h= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new F("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new F("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new F(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _15 => _15.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromString(t)}static isValid(t){try{return n.fromString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _16 => _16.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _17 => _17.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new re;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return h.fromHexInput(t)}},re= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let o=new DataView(this.buffer,this.offset);t.apply(o,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){Dn(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(me),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&Be,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&Tt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}};M([Me(0,Vt)],re.prototype,"serializeU8",1),M([Me(0,Ht)],re.prototype,"serializeU16",1),M([Me(0,me)],re.prototype,"serializeU32",1),M([Me(BigInt(0),Be)],re.prototype,"serializeU64",1),M([Me(BigInt(0),Tt)],re.prototype,"serializeU128",1),M([Me(BigInt(0),Qt)],re.prototype,"serializeU256",1),M([Me(0,me)],re.prototype,"serializeU32AsUleb128",1);function Dn(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var js=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function Se(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(js(n,t,e))}function Me(n,t){return(e,r,o)=>{let s=o.value;return o.value=function(a){return Se(a,n,t),s.apply(this,[a])},o}}var Ys=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(Ys||{}),_=class _ extends d{constructor(e){super();if(e.length!==_.LENGTH)throw new F("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 r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(_.LENGTH);return new _(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new F("Hex string must start with a leading 0x.","leading_zero_x_required");let r=_.fromString(e);if(e.length!==_.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new F(`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 F(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new F("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new F("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let o;try{o=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(s){throw new F(`Hex characters are invalid: ${_optionalChain([s, 'optionalAccess', _18 => _18.message])}`,"invalid_hex_chars")}return new _(o)}static from(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromString(e)}static fromStrict(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromStringStrict(e)}static isValid(e){try{return e.strict?_.fromStrict(e.input):_.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _19 => _19.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _20 => _20.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,o)=>r===e.data[o])}};_.LENGTH=32,_.LONG_STRING_LENGTH=64,_.ZERO=_.from("0x0"),_.ONE=_.from("0x1"),_.TWO=_.from("0x2"),_.THREE=_.from("0x3"),_.FOUR=_.from("0x4");var u=_;var _sha3 = require('@noble/hashes/sha3');var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var Or=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===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 t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<me;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>me)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<e;o+=1)r.push(this.deserialize(t));return r}};var Fe=class n extends d{constructor(e){super();this.value=h.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let o=e.deserializeFixedBytes(r);return new n(o)}};var Wt=class n extends d{constructor(e){super();this.value=new Fe(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let o=Fe.deserialize(e,r);return new n(o.value)}};var R=class n extends d{constructor(e){super();Dn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},G= exports.U8 =class n extends d{constructor(e){super();Se(e,0,Vt),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Y= exports.U16 =class n extends d{constructor(e){super();Se(e,0,Ht),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},Z= exports.U32 =class n extends d{constructor(e){super();Se(e,0,me),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},O= exports.U64 =class n extends d{constructor(e){super();Se(e,BigInt(0),Be),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},J= exports.U128 =class n extends d{constructor(e){super();Se(e,BigInt(0),Tt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},ee= exports.U256 =class n extends d{constructor(e){super();Se(e,BigInt(0),Qt),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof G)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let o=h.fromHexInput(e);r=Array.from(o.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(o=>new G(o)))}static U16(e){return new n(e.map(r=>new Y(r)))}static U32(e){return new n(e.map(r=>new Z(r)))}static U64(e){return new n(e.map(r=>new O(r)))}static U128(e){return new n(e.map(r=>new J(r)))}static U256(e){return new n(e.map(r=>new ee(r)))}static Bool(e){return new n(e.map(r=>new R(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let o=e.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1)s.push(r.deserialize(e));return new n(s)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);T.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},xe= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}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 G(e):void 0)}static U16(e){return new n(e!=null?new Y(e):void 0)}static U32(e){return new n(e!=null?new Z(e):void 0)}static U64(e){return new n(e!=null?new O(e):void 0)}static U128(e){return new n(e!=null?new J(e):void 0)}static U256(e){return new n(e!=null?new ee(e):void 0)}static Bool(e){return new n(e!=null?new R(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let o=T.deserialize(e,r);return new n(o.values[0])}};var H=class extends d{},Qe= exports.PrivateKey =class extends d{},oe= exports.Signature =class extends d{};var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Gr = _interopRequireWildcard(_bip39);var ei=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,ti= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ni= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(ni||{}),Dr= exports.HARDENED_OFFSET =2147483648;function Br(n){return ti.test(n)}function Mr(n){return ei.test(n)}var Bn=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Fr= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let o=new Uint8Array(r),s=new Uint8Array([0]),i=new Uint8Array([...s,...n,...o]);return Bn(t,i)},ri=n=>n.replace("'",""),qr= exports.splitPath =n=>n.split("/").slice(1).map(ri),jt= exports.mnemonicToSeed =n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return Gr.mnemonicToSeedSync(t)};var ve=class ve extends H{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==ve.LENGTH)throw new Error(`PublicKey length should be ${ve.LENGTH}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:r,signature:o}=e,s=h.fromHexInput(r).toUint8Array(),i=o.toUint8Array();return _tweetnacl2.default.sign.detached.verify(s,i,this.key.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ve(r)}static load(e){let r=e.deserializeBytes();return new ve(r)}static isPublicKey(e){return e instanceof ve}};ve.LENGTH=32;var S=ve,B=class B extends Qe{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==B.LENGTH)throw new Error(`PrivateKey length should be ${B.LENGTH}`);this.signingKeyPair=_tweetnacl2.default.sign.keyPair.fromSeed(r.toUint8Array().slice(0,B.LENGTH))}toUint8Array(){return this.signingKeyPair.secretKey.slice(0,B.LENGTH)}toString(){return h.fromHexInput(this.toUint8Array()).toString()}sign(e){let r=h.fromHexInput(e),o=_tweetnacl2.default.sign.detached(r.toUint8Array(),this.signingKeyPair.secretKey);return new k(o)}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new B(r)}static generate(){let e=_tweetnacl2.default.sign.keyPair();return new B(e.secretKey.slice(0,B.LENGTH))}publicKey(){let e=this.signingKeyPair.publicKey;return new S(e)}static fromDerivationPath(e,r){if(!Mr(e))throw new Error(`Invalid derivation path ${e}`);return B.fromDerivationPathInner(e,jt(r))}static fromDerivationPathInner(e,r,o=Dr){let{key:s,chainCode:i}=Bn(B.SLIP_0010_SEED,r),a=qr(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,g)=>Fr(p,g+o),{key:s,chainCode:i});return new B(c)}static isPrivateKey(e){return e instanceof B}};B.LENGTH=32,B.SLIP_0010_SEED="ed25519 seed";var Pe=B,Ce=class Ce extends oe{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==Ce.LENGTH)throw new Error(`Signature length should be ${Ce.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ce(r)}static load(e){let r=e.deserializeBytes();return new Ce(r)}static isSignature(e){return e instanceof Ce}};Ce.LENGTH=64;var k=Ce;var Q=class Q extends H{constructor(e){super();let{publicKeys:r,threshold:o}=e;if(r.length>Q.MAX_KEYS||r.length<Q.MIN_KEYS)throw new Error(`Must have between ${Q.MIN_KEYS} and ${Q.MAX_KEYS} public keys, inclusive`);if(o<Q.MIN_THRESHOLD||o>r.length)throw new Error(`Threshold must be between ${Q.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=o}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*S.LENGTH+1);return this.publicKeys.forEach((r,o)=>{e.set(r.toUint8Array(),o*S.LENGTH)}),e[this.publicKeys.length*S.LENGTH]=this.threshold,e}toString(){return h.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("TODO - Method not implemented.")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r[r.length-1],s=[];for(let i=0;i<r.length-1;i+=S.LENGTH){let a=i;s.push(new S(r.subarray(a,a+S.LENGTH)))}return new Q({publicKeys:s,threshold:o})}};Q.MAX_KEYS=32,Q.MIN_KEYS=2,Q.MIN_THRESHOLD=1;var se=Q,W=class W extends oe{constructor(e){super();let{signatures:r,bitmap:o}=e;if(o.length!==W.BITMAP_LEN)throw new Error(`"bitmap" length should be ${W.BITMAP_LEN}`);if(r.length>W.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${W.MAX_SIGNATURES_SUPPORTED}`);this.signatures=r,this.bitmap=o}toUint8Array(){let e=new Uint8Array(this.signatures.length*k.LENGTH+W.BITMAP_LEN);return this.signatures.forEach((r,o)=>{e.set(r.toUint8Array(),o*k.LENGTH)}),e.set(this.bitmap,this.signatures.length*k.LENGTH),e}toString(){return h.fromHexInput(this.toUint8Array()).toString()}static createBitmap(e){let{bits:r}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return r.forEach(a=>{if(a>=W.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${W.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(a))throw new Error("Duplicate bits detected.");i.add(a);let c=Math.floor(a/8),p=s[c];p|=o>>a%8,s[c]=p}),s}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r.subarray(r.length-4),s=[];for(let i=0;i<r.length-o.length;i+=k.LENGTH){let a=i;s.push(new k(r.subarray(a,a+k.LENGTH)))}return new W({signatures:s,bitmap:o})}};W.MAX_SIGNATURES_SUPPORTED=32,W.BITMAP_LEN=4;var We=W;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ee=class Ee extends H{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==Ee.LENGTH)throw new Error(`PublicKey length should be ${Ee.LENGTH}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:r,signature:o}=e,s=h.fromHexInput(r).toUint8Array(),i=_sha3.sha3_256.call(void 0, s),a=o.toUint8Array();return _secp256k1.secp256k1.verify(a,i,this.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ee(r)}static load(e){let r=e.deserializeBytes();return new Ee(r)}static isPublicKey(e){return e instanceof Ee}};Ee.LENGTH=65;var te=Ee,ie=class ie extends Qe{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==ie.LENGTH)throw new Error(`PrivateKey length should be ${ie.LENGTH}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}sign(e){let r=h.fromHexInput(e),o=_sha3.sha3_256.call(void 0, r.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array());return new Re(s.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ie(r)}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ie(e)}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new te(e)}static fromDerivationPath(e,r){if(!Br(e))throw new Error(`Invalid derivation path ${e}`);return ie.fromDerivationPathInner(e,jt(r))}static fromDerivationPathInner(e,r){let{privateKey:o}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(o===null)throw new Error("Invalid key");return new ie(o)}static isPrivateKey(e){return e instanceof ie}};ie.LENGTH=32;var Ue=ie,Ie=class Ie extends oe{constructor(e){super();let r=h.fromHexInput(e);if(r.toUint8Array().length!==Ie.LENGTH)throw new Error(`Signature length should be ${Ie.LENGTH}, recieved ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ie(r)}static load(e){let r=e.deserializeBytes();return new Ie(r)}static isSignature(e){return e instanceof Ie}};Ie.LENGTH=64;var Re=Ie;var I=class n extends H{constructor(e){super();this.publicKey=e}toUint8Array(){return this.publicKey.toUint8Array()}toString(){return this.publicKey.toString()}verifySignature(e){let{message:r,signature:o}=e;return this.publicKey.verifySignature({message:r,signature:o})}serialize(e){if(this.publicKey instanceof S)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else if(this.publicKey instanceof te)e.serializeU32AsUleb128(1),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(S.load(e));case 1:return new n(te.load(e));default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof S}isSecp256k1PublicKey(){return this.publicKey instanceof te}};var je=class n extends H{constructor(e){super();let{publicKeys:r,signaturesRequired:o}=e;if(o<1)throw new Error("The number of required signatures needs to be greater then 0");if(r.length<o)throw new Error(`Provided ${r.length} public keys is smaller than the ${o} required signatures`);let s=[];r.forEach(i=>{i instanceof I?s.push(i):s.push(new I(i))}),this.publicKeys=s,this.signaturesRequired=o}toUint8Array(){return this.bcsToBytes()}createBitmap(e){let{bits:r}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(a))throw new Error(`Duplicate bit ${a} detected.`);i.add(a);let p=Math.floor(a/8),g=s[p];g|=o>>a%8,s[p]=g}),s}toString(){return h.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("not implemented")}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(I),o=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:o})}};var ye=class ye extends d{constructor(e){super();let{data:r}=e,o=h.fromHexInput(r);if(o.toUint8Array().length!==ye.LENGTH)throw new Error(`Authentication Key length should be ${ye.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(ye.LENGTH);return new ye({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromPublicKeyAndScheme(e){let{publicKey:r,scheme:o}=e,s;switch(o){case 3:case 2:{let c=r.bcsToBytes();s=new Uint8Array([...c,o]);break}case 0:case 1:{let c=r.toUint8Array(),p=h.fromHexInput(c).toUint8Array();s=new Uint8Array([...p,o]);break}default:throw new Error(`Scheme ${o} is not supported`)}let i=_sha3.sha3_256.create();i.update(s);let a=i.digest();return new ye({data:a})}static fromPublicKey(e){let{publicKey:r}=e,o;if(r instanceof S)o=0 .valueOf();else if(r instanceof se)o=1 .valueOf();else if(r instanceof I)o=2 .valueOf();else if(r instanceof je)o=3 .valueOf();else throw new Error("No supported authentication scheme for public key");return ye.fromPublicKeyAndScheme({publicKey:r,scheme:o})}derivedAddress(){return new u(this.data.toUint8Array())}};ye.LENGTH=32;var ae=ye;var ke=class n{constructor(t){let{privateKey:e,address:r,legacy:o}=t,s=_nullishCoalesce(o, () => (!0));if(this.publicKey=e.publicKey(),this.publicKey instanceof S)s?this.signingScheme=0:(this.publicKey=new I(this.publicKey),this.signingScheme=2);else if(this.publicKey instanceof se)this.signingScheme=1;else if(this.publicKey instanceof te)this.publicKey=new I(this.publicKey),this.signingScheme=2;else throw new Error("Can not create new Account, unsupported public key type");this.privateKey=e,this.accountAddress=r}static generate(t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _21 => _21.legacy]), () => (!0)),r,o;switch(_optionalChain([t, 'optionalAccess', _22 => _22.scheme])){case 2:r=Ue.generate(),o=new I(r.publicKey());break;default:r=Pe.generate(),e===!1?o=new I(r.publicKey()):o=r.publicKey()}let i=ae.fromPublicKey({publicKey:o}).derivedAddress();return new n({privateKey:r,address:i,legacy:_optionalChain([t, 'optionalAccess', _23 => _23.legacy])})}static fromPrivateKey(t){let{privateKey:e,legacy:r}=t,o=_nullishCoalesce(r, () => (!0)),s;if(e instanceof Ue)s=new I(e.publicKey());else if(e instanceof Pe)o?s=e.publicKey():s=new I(e.publicKey());else throw new Error(`Unsupported private key ${e}`);let a=ae.fromPublicKey({publicKey:s}).derivedAddress();return new n({privateKey:e,address:a,legacy:o})}static fromPrivateKeyAndAddress(t){let{privateKey:e,address:r,legacy:o}=t;return new n({privateKey:e,address:r,legacy:o})}static fromDerivationPath(t){let{path:e,mnemonic:r,scheme:o,legacy:s}=t,i;switch(o){case 2:i=Ue.fromDerivationPath(e,r);break;case 0:i=Pe.fromDerivationPath(e,r);break;default:throw new Error(`Unsupported scheme ${o}`)}return n.fromPrivateKey({privateKey:i,legacy:s})}static authKey(t){let{publicKey:e}=t;return ae.fromPublicKey({publicKey:e})}sign(t){return this.privateKey.sign(t)}verifySignature(t){let{message:e,signature:r}=t,o=h.fromHexInput(e).toUint8Array();return this.publicKey.verifySignature({message:o,signature:r})}};var ii=`
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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var Vs=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var M=(n,t,e,r)=>{for(var o=r>1?void 0:r?Hs(t,e):t,s=n.length-1,i;s>=0;s--)(i=n[s])&&(o=(r?i(t,e,o):i(o))||o);return r&&o&&Vs(t,e,o),o};var ye=class extends Error{constructor(e,r,o){super(o);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var wr="1.9.1";var Rn=(r=>(r.JSON="application/json",r.BCS="application/x-bcs",r.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",r))(Rn||{}),_r= exports.TypeTagVariants =(m=>(m[m.Bool=0]="Bool",m[m.U8=1]="U8",m[m.U64=2]="U64",m[m.U128=3]="U128",m[m.Address=4]="Address",m[m.Signer=5]="Signer",m[m.Vector=6]="Vector",m[m.Struct=7]="Struct",m[m.U16=8]="U16",m[m.U32=9]="U32",m[m.U256=10]="U256",m[m.Reference=254]="Reference",m[m.Generic=255]="Generic",m))(_r||{}),Tt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Tt||{}),Sr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(Sr||{}),xr= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(xr||{}),vr= exports.TransactionAuthenticatorVariant =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.MultiAgent=2]="MultiAgent",s[s.FeePayer=3]="FeePayer",s[s.SingleSender=4]="SingleSender",s))(vr||{}),Cr= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Cr||{}),Pr= exports.AnyPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Pr||{}),Er= exports.AnySignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Er||{}),Nn= exports.TransactionResponseType =(i=>(i.Pending="pending_transaction",i.User="user_transaction",i.Genesis="genesis_transaction",i.BlockMetadata="block_metadata_transaction",i.StateCheckpoint="state_checkpoint_transaction",i.Validator="validator_transaction",i))(Nn||{});function aa(n){return n.type==="pending_transaction"}function ca(n){return n.type==="user_transaction"}function ua(n){return n.type==="genesis_transaction"}function pa(n){return n.type==="block_metadata_transaction"}function da(n){return n.type==="state_checkpoint_transaction"}function la(n){return n.type==="validator_transaction"}function ga(n){return"signature"in n&&n.signature==="ed25519_signature"}function ma(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function ya(n){return n.type==="multi_agent_signature"}function Aa(n){return n.type==="fee_payer_signature"}function fa(n){return n.type==="multi_ed25519_signature"}var Qs=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(Qs||{}),Ir= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Ir||{}),Ws= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(Ws||{}),xe= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(xe||{}),Gn= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(Gn||{}),js= exports.DeriveScheme =(s=>(s[s.DeriveAuid=251]="DeriveAuid",s[s.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",s[s.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",s[s.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",s[s.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",s))(js||{});var Ur={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Xs(n,t){let{url:e,method:r,body:o,contentType:s,params:i,overrides:a}=n,c={..._optionalChain([a, 'optionalAccess', _2 => _2.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${wr}`,"content-type":_nullishCoalesce(s, () => ("application/json"))};return _optionalChain([a, 'optionalAccess', _3 => _3.AUTH_TOKEN])&&e.includes("faucet")&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _4 => _4.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _5 => _5.API_KEY])&&!e.includes("faucet")&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _6 => _6.API_KEY])}`),t.provider({url:e,method:r,body:o,params:i,headers:c,overrides:a})}async function qt(n,t){let{url:e,path:r}=n,o=r?`${e}/${r}`:e,s=await Xs({...n,url:o},t.client),i={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(t.isIndexerRequest(e)){let c=i.data;if(c.errors)throw new ye(n,i,_nullishCoalesce(`Indexer error: ${c.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));i.data=c.data}if(i.status>=200&&i.status<300)return i;let a;throw i&&i.data&&"message"in i.data&&"error_code"in i.data?a=JSON.stringify(i.data):i.status in Ur?a=Ur[i.status]:a=`Unhandled Error ${i.status} : ${i.statusText}`,new ye(n,i,`${t.isFullnodeRequest(e)?"Fullnode":"Faucet"} error: ${a}`)}var $t=(r=>(r[r.FULLNODE=0]="FULLNODE",r[r.INDEXER=1]="INDEXER",r[r.FAUCET=2]="FAUCET",r))($t||{}),Rr= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Nr= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Lt= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Vt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Gr= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",kn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Le= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(Le||{});async function kr(n){let{aptosConfig:t,overrides:e,params:r,contentType:o,acceptType:s,path:i,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return qt({url:p,method:"GET",originMethod:a,path:i,contentType:_optionalChain([o, 'optionalAccess', _7 => _7.valueOf, 'call', _8 => _8()]),acceptType:_optionalChain([s, 'optionalAccess', _9 => _9.valueOf, 'call', _10 => _10()]),params:r,overrides:{...t.clientConfig,...e}},t)}async function j(n){return kr({...n,type:0})}async function Ve(n){let t=[],e,r=n.params;do{let o=await kr({type:0,aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),r.start=e}while(e!=null);return t}async function zn(n){let{type:t,originMethod:e,path:r,body:o,acceptType:s,contentType:i,params:a,aptosConfig:c,overrides:p}=n,g=c.getRequestUrl(t);return qt({url:g,method:"POST",originMethod:e,path:r,body:o,contentType:_optionalChain([i, 'optionalAccess', _11 => _11.valueOf, 'call', _12 => _12()]),acceptType:_optionalChain([s, 'optionalAccess', _13 => _13.valueOf, 'call', _14 => _14()]),params:a,overrides:{...c.clientConfig,...p}},c)}async function He(n){return zn({...n,type:0})}async function zr(n){return zn({...n,type:1})}async function Or(n){return zn({...n,type:2})}var _utils = require('@noble/hashes/utils');var Ht=255,Qt=65535,Ae=4294967295,ke=18446744073709551615n,bt=340282366920938463463374607431768211455n,Wt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var F=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Js=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Js||{}),b= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new F("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new F("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new F(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _15 => _15.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromString(t)}static isValid(t){try{return n.fromString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _16 => _16.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _17 => _17.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new ae;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return b.fromHexInput(t)}},ae= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let o=new DataView(this.buffer,this.offset);t.apply(o,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){On(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(Ae),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&ke,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&bt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}};M([ze(0,Ht)],ae.prototype,"serializeU8",1),M([ze(0,Qt)],ae.prototype,"serializeU16",1),M([ze(0,Ae)],ae.prototype,"serializeU32",1),M([ze(BigInt(0),ke)],ae.prototype,"serializeU64",1),M([ze(BigInt(0),bt)],ae.prototype,"serializeU128",1),M([ze(BigInt(0),Wt)],ae.prototype,"serializeU256",1),M([ze(0,Ae)],ae.prototype,"serializeU32AsUleb128",1);function On(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var ei=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function ve(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(ei(n,t,e))}function ze(n,t){return(e,r,o)=>{let s=o.value;return o.value=function(a){return ve(a,n,t),s.apply(this,[a])},o}}var ni=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(ni||{}),_=class _ extends d{constructor(e){super();if(e.length!==_.LENGTH)throw new F("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 r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(_.LENGTH);return new _(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new F("Hex string must start with a leading 0x.","leading_zero_x_required");let r=_.fromString(e);if(e.length!==_.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new F(`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 F(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new F("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new F("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let o;try{o=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(s){throw new F(`Hex characters are invalid: ${_optionalChain([s, 'optionalAccess', _18 => _18.message])}`,"invalid_hex_chars")}return new _(o)}static from(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromString(e)}static fromStrict(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromStringStrict(e)}static isValid(e){try{return e.strict?_.fromStrict(e.input):_.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _19 => _19.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _20 => _20.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,o)=>r===e.data[o])}};_.LENGTH=32,_.LONG_STRING_LENGTH=64,_.ZERO=_.from("0x0"),_.ONE=_.from("0x1"),_.TWO=_.from("0x2"),_.THREE=_.from("0x3"),_.FOUR=_.from("0x4");var u=_;var Br=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===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 t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<Ae;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Ae)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<e;o+=1)r.push(this.deserialize(t));return r}};var Oe=class n extends d{constructor(e){super();this.value=b.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let o=e.deserializeFixedBytes(r);return new n(o)}};var jt=class n extends d{constructor(e){super();this.value=new Oe(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let o=Oe.deserialize(e,r);return new n(o.value)}};var I=class n extends d{constructor(e){super();On(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},z= exports.U8 =class n extends d{constructor(e){super();ve(e,0,Ht),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},te= exports.U16 =class n extends d{constructor(e){super();ve(e,0,Qt),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},ne= exports.U32 =class n extends d{constructor(e){super();ve(e,0,Ae),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},k= exports.U64 =class n extends d{constructor(e){super();ve(e,BigInt(0),ke),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},re= exports.U128 =class n extends d{constructor(e){super();ve(e,BigInt(0),bt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},oe= exports.U256 =class n extends d{constructor(e){super();ve(e,BigInt(0),Wt),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var h=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof z)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let o=b.fromHexInput(e);r=Array.from(o.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(o=>new z(o)))}static U16(e){return new n(e.map(r=>new te(r)))}static U32(e){return new n(e.map(r=>new ne(r)))}static U64(e){return new n(e.map(r=>new k(r)))}static U128(e){return new n(e.map(r=>new re(r)))}static U256(e){return new n(e.map(r=>new oe(r)))}static Bool(e){return new n(e.map(r=>new I(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let o=e.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1)s.push(r.deserialize(e));return new n(s)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);h.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Ce= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new h([e]):this.vec=new h([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}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 z(e):void 0)}static U16(e){return new n(e!=null?new te(e):void 0)}static U32(e){return new n(e!=null?new ne(e):void 0)}static U64(e){return new n(e!=null?new k(e):void 0)}static U128(e){return new n(e!=null?new re(e):void 0)}static U256(e){return new n(e!=null?new oe(e):void 0)}static Bool(e){return new n(e!=null?new I(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let o=h.deserialize(e,r);return new n(o.values[0])}};var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var _sha3 = require('@noble/hashes/sha3');var Pe=class Pe extends d{constructor(e){super();let{data:r}=e,o=b.fromHexInput(r);if(o.toUint8Array().length!==Pe.LENGTH)throw new Error(`Authentication Key length should be ${Pe.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(Pe.LENGTH);return new Pe({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:o}=e,s=b.fromHexInput(o).toUint8Array(),i=new Uint8Array([...s,r]),a=_sha3.sha3_256.create();a.update(i);let c=a.digest();return new Pe({data:c})}static fromPublicKeyAndScheme(e){let{publicKey:r}=e;return r.authKey()}static fromPublicKey(e){let{publicKey:r}=e;return r.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};Pe.LENGTH=32;var K=Pe;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Mr = _interopRequireWildcard(_bip39);var ii=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,ai= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ci= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(ci||{}),Fr= exports.HARDENED_OFFSET =2147483648;function Kr(n){return ai.test(n)}function qr(n){return ii.test(n)}var Dn=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},$r= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let o=new Uint8Array(r),s=new Uint8Array([0]),i=new Uint8Array([...s,...n,...o]);return Dn(t,i)},ui=n=>n.replace("'",""),Lr= exports.splitPath =n=>n.split("/").slice(1).map(ui),Xt= exports.mnemonicToSeed =n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return Mr.mnemonicToSeedSync(t)};var wt=class extends d{toString(){let t=this.toUint8Array();return b.fromHexInput(t).toString()}},ce= exports.AccountPublicKey =class extends wt{};var X=class extends d{toString(){let t=this.toUint8Array();return b.fromHexInput(t).toString()}};var De=class De extends ce{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==De.LENGTH)throw new Error(`PublicKey length should be ${De.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof R))return!1;let s=b.fromHexInput(r).toUint8Array(),i=o.toUint8Array(),a=this.key.toUint8Array();return _tweetnacl2.default.sign.detached.verify(s,i,a)}authKey(){return K.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new De(r)}static isPublicKey(e){return e instanceof De}};De.LENGTH=32;var U=De,D=class D extends d{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==D.LENGTH)throw new Error(`PrivateKey length should be ${D.LENGTH}`);this.signingKeyPair=_tweetnacl2.default.sign.keyPair.fromSeed(r.toUint8Array().slice(0,D.LENGTH))}static generate(){let e=_tweetnacl2.default.sign.keyPair();return new D(e.secretKey.slice(0,D.LENGTH))}static fromDerivationPath(e,r){if(!qr(e))throw new Error(`Invalid derivation path ${e}`);return D.fromDerivationPathInner(e,Xt(r))}static fromDerivationPathInner(e,r,o=Fr){let{key:s,chainCode:i}=Dn(D.SLIP_0010_SEED,r),a=Lr(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,g)=>$r(p,g+o),{key:s,chainCode:i});return new D(c)}publicKey(){let e=this.signingKeyPair.publicKey;return new U(e)}sign(e){let r=b.fromHexInput(e).toUint8Array(),o=_tweetnacl2.default.sign.detached(r,this.signingKeyPair.secretKey);return new R(o)}toUint8Array(){return this.signingKeyPair.secretKey.slice(0,D.LENGTH)}toString(){return b.fromHexInput(this.toUint8Array()).toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new D(r)}static isPrivateKey(e){return e instanceof D}};D.LENGTH=32,D.SLIP_0010_SEED="ed25519 seed";var Y=D,Qe=class Qe extends X{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==Qe.LENGTH)throw new Error(`Signature length should be ${Qe.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Qe(r)}};Qe.LENGTH=64;var R=Qe;var Z=class Z extends ce{constructor(e){super();let{publicKeys:r,threshold:o}=e;if(r.length>Z.MAX_KEYS||r.length<Z.MIN_KEYS)throw new Error(`Must have between ${Z.MIN_KEYS} and ${Z.MAX_KEYS} public keys, inclusive`);if(o<Z.MIN_THRESHOLD||o>r.length)throw new Error(`Threshold must be between ${Z.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=o}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof Be))return!1;let s=[];for(let i=0;i<4;i+=1)for(let a=0;a<8;a+=1)if((o.bitmap[i]&1<<7-a)!==0){let p=i*8+a;s.push(p)}if(s.length!==o.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(s.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<s.length;i+=1)if(!this.publicKeys[s[i]].verifySignature({message:r,signature:o.signatures[i]}))return!1;return!0}authKey(){return K.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*U.LENGTH+1);return this.publicKeys.forEach((r,o)=>{e.set(r.toUint8Array(),o*U.LENGTH)}),e[this.publicKeys.length*U.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r[r.length-1],s=[];for(let i=0;i<r.length-1;i+=U.LENGTH){let a=i;s.push(new U(r.subarray(a,a+U.LENGTH)))}return new Z({publicKeys:s,threshold:o})}};Z.MAX_KEYS=32,Z.MIN_KEYS=2,Z.MIN_THRESHOLD=1;var We=Z,L=class L extends X{constructor(e){super();let{signatures:r,bitmap:o}=e;if(r.length>L.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${L.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(o instanceof Uint8Array))this.bitmap=L.createBitmap({bits:o});else{if(o.length!==L.BITMAP_LEN)throw new Error(`"bitmap" length should be ${L.BITMAP_LEN}`);this.bitmap=o}}toUint8Array(){let e=new Uint8Array(this.signatures.length*R.LENGTH+L.BITMAP_LEN);return this.signatures.forEach((r,o)=>{e.set(r.toUint8Array(),o*R.LENGTH)}),e.set(this.bitmap,this.signatures.length*R.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r.subarray(r.length-4),s=[];for(let i=0;i<r.length-o.length;i+=R.LENGTH){let a=i;s.push(new R(r.subarray(a,a+R.LENGTH)))}return new L({signatures:s,bitmap:o})}static createBitmap(e){let{bits:r}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return r.forEach((a,c)=>{if(a>=L.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${L.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(a))throw new Error("Duplicate bits detected.");if(c>0&&a<=r[c-1])throw new Error("The bits need to be sorted in ascending order.");i.add(a);let p=Math.floor(a/8),g=s[p];g|=o>>a%8,s[p]=g}),s}};L.MAX_SIGNATURES_SUPPORTED=32,L.BITMAP_LEN=4;var Be=L;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Me=class Me extends wt{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==Me.LENGTH)throw new Error(`PublicKey length should be ${Me.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof he))return!1;let s=b.fromHexInput(r).toUint8Array(),i=_sha3.sha3_256.call(void 0, s),a=o.toUint8Array();return _secp256k1.secp256k1.verify(a,i,this.key.toUint8Array())}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Me(r)}static isPublicKey(e){return e instanceof Me}};Me.LENGTH=65;var fe=Me,ue=class ue extends d{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==ue.LENGTH)throw new Error(`PrivateKey length should be ${ue.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ue(e)}static fromDerivationPath(e,r){if(!Kr(e))throw new Error(`Invalid derivation path ${e}`);return ue.fromDerivationPathInner(e,Xt(r))}static fromDerivationPathInner(e,r){let{privateKey:o}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(o===null)throw new Error("Invalid key");return new ue(o)}sign(e){let r=b.fromHexInput(e),o=_sha3.sha3_256.call(void 0, r.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array());return new he(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ue(r)}static isPrivateKey(e){return e instanceof ue}};ue.LENGTH=32;var Fe=ue,je=class je extends X{constructor(e){super();let r=b.fromHexInput(e);if(r.toUint8Array().length!==je.LENGTH)throw new Error(`Signature length should be ${je.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new je(r)}};je.LENGTH=64;var he=je;var q=class n extends ce{constructor(e){super();if(this.publicKey=e,e instanceof U)this.variant=0;else if(e instanceof fe)this.variant=1;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:o}=e;return o instanceof B?this.publicKey.verifySignature({message:r,signature:o.signature}):!1}authKey(){return K.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),o;switch(r){case 0:o=U.deserialize(e);break;case 1:o=fe.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(o)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof U}isSecp256k1PublicKey(){return this.publicKey instanceof fe}},B= exports.AnySignature =class n extends X{constructor(e){super();if(this.signature=e,e instanceof R)this.variant=0;else if(e instanceof he)this.variant=1;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),o;switch(r){case 0:o=R.deserialize(e);break;case 1:o=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(o)}};function Hr(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var Jt=class n extends ce{constructor(e){super();let{publicKeys:r,signaturesRequired:o}=e;if(o<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<o)throw new Error(`Provided ${r.length} public keys is smaller than the ${o} required signatures`);this.publicKeys=r.map(s=>s instanceof q?s:new q(s)),this.signaturesRequired=o}verifySignature(e){throw new Error("not implemented")}authKey(){return K.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(q),o=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:o})}createBitmap(e){let{bits:r}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(a))throw new Error(`Duplicate bit ${a} detected.`);i.add(a);let p=Math.floor(a/8),g=s[p];g|=o>>a%8,s[p]=g}),s}},V=class V extends X{constructor(e){super();let{signatures:r,bitmap:o}=e;if(r.length>V.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${V.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(i=>i instanceof B?i:new B(i)),!(o instanceof Uint8Array))this.bitmap=V.createBitmap({bits:o});else{if(o.length!==V.BITMAP_LEN)throw new Error(`"bitmap" length should be ${V.BITMAP_LEN}`);this.bitmap=o}let s=this.bitmap.reduce((i,a)=>i+Hr(a),0);if(s!==this.signatures.length)throw new Error(`Expecting ${s} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return r.forEach(a=>{if(a>=V.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${V.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(a))throw new Error("Duplicate bits detected.");i.add(a);let c=Math.floor(a/8),p=s[c];p|=o>>a%8,s[c]=p}),s}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeBytes(),o=r.reduce((i,a)=>i+Hr(a),0),s=[];for(let i=0;i<o;i+=1){let a=B.deserialize(e);s.push(a)}return new V({signatures:s,bitmap:r})}};V.BITMAP_LEN=4,V.MAX_SIGNATURES_SUPPORTED=V.BITMAP_LEN*8;var Qr=V;var H=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return pe.load(t);case 1:return en.load(t);case 2:return se.load(t);case 3:return Xe.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof pe}isMultiEd25519(){return this instanceof en}isSingleKey(){return this instanceof se}isMultiKey(){return this instanceof Xe}},pe= exports.AccountAuthenticatorEd25519 =class n extends H{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=U.deserialize(e),o=R.deserialize(e);return new n(r,o)}},en= exports.AccountAuthenticatorMultiEd25519 =class n extends H{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=We.deserialize(e),o=Be.deserialize(e);return new n(r,o)}},se= exports.AccountAuthenticatorSingleKey =class n extends H{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=q.deserialize(e),o=B.deserialize(e);return new n(r,o)}},Xe= exports.AccountAuthenticatorMultiKey =class n extends H{constructor(e,r,o){super();this.public_keys=e,this.signatures=r,this.signatures_bitmap=o}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let r=Jt.deserialize(e),o=e.deserializeVector(B),s=e.deserializeBytes();return new n(r,o,s)}};var Ye=class n{constructor(t){this.signingScheme=0;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let t=Y.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,o=Y.fromDerivationPath(e,r);return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(t);return new pe(this.publicKey,e)}sign(t){return this.signWithAuthenticator(t).signature}};var Ze=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new q(e.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(t={}){let{scheme:e=0}=t,r;switch(e){case 0:r=Y.generate();break;case 2:r=Fe.generate();break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:r})}static fromDerivationPath(t){let{scheme:e=0,path:r,mnemonic:o}=t,s;switch(e){case 0:s=Y.fromDerivationPath(r,o);break;case 2:s=Fe.fromDerivationPath(r,o);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:s})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(t),r=new B(e);return new se(this.publicKey,r)}sign(t){return this.signWithAuthenticator(t).signature}};var Ee=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?Ye.generate():Ze.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:o=!0}=t;return e instanceof Y&&o?new Ye({privateKey:e,address:r}):new Ze({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:o,legacy:s=!0}=t;return e===0&&s?Ye.fromDerivationPath({mnemonic:r,path:o}):Ze.fromDerivationPath({scheme:e,mnemonic:r,path:o})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var di=`
2
2
  fragment TokenActivitiesFields on token_activities_v2 {
3
3
  after_value
4
4
  before_value
@@ -16,7 +16,7 @@
16
16
  transaction_version
17
17
  type
18
18
  }
19
- `,ai=`
19
+ `,li=`
20
20
  fragment AnsTokenFragment on current_aptos_names {
21
21
  domain
22
22
  expiration_timestamp
@@ -26,7 +26,7 @@
26
26
  is_primary
27
27
  owner_address
28
28
  }
29
- `,Zt=`
29
+ `,tn=`
30
30
  fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
31
31
  token_standard
32
32
  token_properties_mutated_v1
@@ -73,7 +73,7 @@
73
73
  }
74
74
  }
75
75
  }
76
- `,$r=`
76
+ `,Wr=`
77
77
  query getAccountCoinsCount($address: String) {
78
78
  current_fungible_asset_balances_aggregate(
79
79
  where: {owner_address: {_eq: $address}}
@@ -83,7 +83,7 @@
83
83
  }
84
84
  }
85
85
  }
86
- `,Lr=`
86
+ `,jr=`
87
87
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
88
88
  current_fungible_asset_balances(
89
89
  where: $where_condition
@@ -116,7 +116,7 @@
116
116
  }
117
117
  }
118
118
  }
119
- `,Vr=`
119
+ `,Xr=`
120
120
  query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
121
121
  current_collection_ownership_v2_view(
122
122
  where: $where_condition
@@ -150,7 +150,7 @@
150
150
  single_token_uri
151
151
  }
152
152
  }
153
- `,Hr=`
153
+ `,Yr=`
154
154
  query getAccountOwnedObjects($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
155
155
  current_objects(
156
156
  where: $where_condition
@@ -167,7 +167,7 @@
167
167
  is_deleted
168
168
  }
169
169
  }
170
- `,Qr=`
170
+ `,Zr=`
171
171
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
172
172
  current_token_ownerships_v2(
173
173
  where: $where_condition
@@ -178,7 +178,7 @@
178
178
  ...CurrentTokenOwnershipFields
179
179
  }
180
180
  }
181
- ${Zt}`,Mu=`
181
+ ${tn}`,Vp=`
182
182
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
183
183
  current_token_ownerships_v2(
184
184
  where: $where_condition
@@ -189,7 +189,7 @@
189
189
  ...CurrentTokenOwnershipFields
190
190
  }
191
191
  }
192
- ${Zt}`,Wr=`
192
+ ${tn}`,Jr=`
193
193
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
194
194
  current_token_ownerships_v2(
195
195
  where: $where_condition
@@ -200,7 +200,7 @@
200
200
  ...CurrentTokenOwnershipFields
201
201
  }
202
202
  }
203
- ${Zt}`,jr=`
203
+ ${tn}`,eo=`
204
204
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
205
205
  current_token_ownerships_v2_aggregate(
206
206
  where: $where_condition
@@ -212,7 +212,7 @@
212
212
  }
213
213
  }
214
214
  }
215
- `,Xr=`
215
+ `,to=`
216
216
  query getAccountTransactionsCount($address: String) {
217
217
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
218
218
  aggregate {
@@ -220,13 +220,13 @@
220
220
  }
221
221
  }
222
222
  }
223
- `,Yr=`
223
+ `,no=`
224
224
  query getChainTopUserTransactions($limit: Int) {
225
225
  user_transactions(limit: $limit, order_by: {version: desc}) {
226
226
  version
227
227
  }
228
228
  }
229
- `,Zr=`
229
+ `,Bn=`
230
230
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
231
231
  current_collections_v2(where: $where_condition) {
232
232
  collection_id
@@ -245,7 +245,7 @@
245
245
  uri
246
246
  }
247
247
  }
248
- `,Jr=`
248
+ `,ro=`
249
249
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
250
250
  current_fungible_asset_balances(
251
251
  where: $where_condition
@@ -263,7 +263,7 @@
263
263
  token_standard
264
264
  }
265
265
  }
266
- `,eo=`
266
+ `,oo=`
267
267
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
268
268
  delegated_staking_activities(
269
269
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -276,7 +276,7 @@
276
276
  transaction_version
277
277
  }
278
278
  }
279
- `,to=`
279
+ `,so=`
280
280
  query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
281
281
  events(
282
282
  where: $where_condition
@@ -295,7 +295,7 @@
295
295
  indexed_type
296
296
  }
297
297
  }
298
- `,no=`
298
+ `,io=`
299
299
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
300
300
  fungible_asset_activities(
301
301
  where: $where_condition
@@ -320,7 +320,7 @@
320
320
  type
321
321
  }
322
322
  }
323
- `,ro=`
323
+ `,ao=`
324
324
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
325
325
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
326
326
  icon_uri
@@ -337,7 +337,7 @@
337
337
  token_standard
338
338
  }
339
339
  }
340
- `,Xe=`
340
+ `,Je=`
341
341
  query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
342
342
  current_aptos_names(
343
343
  limit: $limit
@@ -348,7 +348,7 @@
348
348
  ...AnsTokenFragment
349
349
  }
350
350
  }
351
- ${ai}`,Mn=`
351
+ ${li}`,Mn=`
352
352
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
353
353
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
354
354
  num_active_delegator
@@ -363,7 +363,7 @@
363
363
  last_updated
364
364
  }
365
365
  }
366
- `,oo=`
366
+ `,co=`
367
367
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
368
368
  token_activities_v2(
369
369
  where: $where_condition
@@ -374,7 +374,7 @@
374
374
  ...TokenActivitiesFields
375
375
  }
376
376
  }
377
- ${ii}`,qn=`
377
+ ${di}`,Kn=`
378
378
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
379
379
  current_token_ownerships_v2(
380
380
  where: $where_condition
@@ -385,7 +385,7 @@
385
385
  ...CurrentTokenOwnershipFields
386
386
  }
387
387
  }
388
- ${Zt}`,so=`
388
+ ${tn}`,uo=`
389
389
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
390
390
  current_token_datas_v2(
391
391
  where: $where_condition
@@ -425,5 +425,5 @@
425
425
  }
426
426
  }
427
427
  }
428
- `;async function Jt(n){let{aptosConfig:t}=n,{data:e}=await V({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function io(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:o}=await V({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _24 => _24.withTransactions])}});return o}async function ao(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:o}=await V({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _25 => _25.withTransactions])}});return o}async function en(n){let{aptosConfig:t,handle:e,data:r,options:o}=n;return(await He({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _26 => _26.ledgerVersion])},body:r})).data}async function ze(n){let{aptosConfig:t,payload:e,options:r}=n,{data:o}=await He({aptosConfig:t,originMethod:"view",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _27 => _27.ledgerVersion])},body:{function:e.function,type_arguments:_nullishCoalesce(e.typeArguments, () => ([])),arguments:_nullishCoalesce(e.functionArguments, () => ([]))}});return o}async function co(n){let{aptosConfig:t,limit:e}=n;return(await y({aptosConfig:t,query:{query:Yr,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function y(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:o}=await kr({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return o}async function ci(n){let{aptosConfig:t}=n;return(await y({aptosConfig:t,query:{query:Fn},originMethod:"getProcessorStatuses"})).processor_status}async function tn(n){let t=await ci({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function nn(n){let{aptosConfig:t,processorType:e}=n,r={processor:{_eq:e.valueOf()}};return(await y({aptosConfig:t,query:{query:Fn,variables:{where_condition:r}},originMethod:"getProcessorStatus"})).processor_status[0]}var Kn=new Map;function Ye(n,t,e){return async(...r)=>{if(Kn.has(t)){let{value:s,timestamp:i}=Kn.get(t);if(e===void 0||Date.now()-i<=e)return s}let o=await n(...r);return Kn.set(t,{value:o,timestamp:Date.now()}),o}}var Ae=class n extends oe{constructor(e){super();this.signature=e}toUint8Array(){return this.signature.toUint8Array()}toString(){return this.signature.toString()}serialize(e){if(this.signature instanceof k)e.serializeU32AsUleb128(0),this.signature.serialize(e);else if(this.signature instanceof Re)e.serializeU32AsUleb128(1),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(k.load(e));case 1:return new n(Re.load(e));default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}}};async function ce(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function lo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _28 => _28.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _29 => _29.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _30 => _30.limit]), () => (1e3))}})}async function rn(n){return _optionalChain([n, 'access', _31 => _31.options, 'optionalAccess', _32 => _32.ledgerVersion])!==void 0?uo(n):Ye(async()=>uo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function uo(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:o}=n,{data:s}=await V({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _33 => _33.ledgerVersion])}});return s}async function go(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _34 => _34.offset]),limit:_optionalChain([r, 'optionalAccess', _35 => _35.limit])}})}async function mo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _36 => _36.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _37 => _37.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _38 => _38.limit]), () => (999))}})}async function $n(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:o}=n,{data:s}=await V({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _39 => _39.ledgerVersion])}});return s.data}async function Ln(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,o=await $n({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:s}}=o,i=u.from(e);try{let a=await en({aptosConfig:t,handle:s,data:{key:i.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ge&&a.data.error_code==="table_item_not_found")return i;throw a}}async function yo(n){let{aptosConfig:t,accountAddress:e}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},i=await y({aptosConfig:t,query:{query:jr,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return i.current_token_ownerships_v2_aggregate.aggregate?i.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _40 => _40.tokenStandard])&&(s.token_standard={_eq:_optionalChain([r, 'optionalAccess', _41 => _41.tokenStandard])});let i={query:Qr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _42 => _42.offset]),limit:_optionalChain([r, 'optionalAccess', _43 => _43.limit]),order_by:_optionalChain([r, 'optionalAccess', _44 => _44.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function fo(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:o}=n,s=u.from(e).toStringLong(),i=u.from(r).toStringLong(),a={owner_address:{_eq:s},current_token_data:{collection_id:{_eq:i}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _45 => _45.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _46 => _46.tokenStandard])});let c={query:Wr,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _47 => _47.offset]),limit:_optionalChain([o, 'optionalAccess', _48 => _48.limit]),order_by:_optionalChain([o, 'optionalAccess', _49 => _49.orderBy])}};return(await y({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function ho(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _50 => _50.tokenStandard])&&(s.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _51 => _51.tokenStandard])}});let i={query:Vr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _52 => _52.offset]),limit:_optionalChain([r, 'optionalAccess', _53 => _53.limit]),order_by:_optionalChain([r, 'optionalAccess', _54 => _54.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function To(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:Xr,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return s.account_transactions_aggregate.aggregate?s.account_transactions_aggregate.aggregate.count:0}async function bo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,o=u.from(e).toStringLong(),s=await Vn({aptosConfig:t,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return s[0]?s[0].amount:0}async function Vn(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o=u.from(e).toStringLong(),s={..._optionalChain([r, 'optionalAccess', _55 => _55.where]),owner_address:{_eq:o}},i={query:Lr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([r, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([r, 'optionalAccess', _58 => _58.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function wo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:$r,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!s.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return s.current_fungible_asset_balances_aggregate.aggregate.count}async function _o(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()}},i={query:Hr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _59 => _59.offset]),limit:_optionalChain([r, 'optionalAccess', _60 => _60.limit]),order_by:_optionalChain([r, 'optionalAccess', _61 => _61.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountOwnedObjects"})).current_objects}async function So(n){let{aptosConfig:t,privateKey:e}=n,r=new I(e.publicKey());if(e instanceof Ue){let s=ae.fromPublicKeyAndScheme({publicKey:r,scheme:2}).derivedAddress();return ke.fromPrivateKeyAndAddress({privateKey:e,address:s})}if(e instanceof Pe){let o=ae.fromPublicKeyAndScheme({publicKey:r,scheme:2});if(await po({authKey:o,aptosConfig:t})){let c=o.derivedAddress();return ke.fromPrivateKeyAndAddress({privateKey:e,address:c,legacy:!1})}let i=ae.fromPublicKeyAndScheme({publicKey:r,scheme:0});if(await po({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return ke.fromPrivateKeyAndAddress({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function po(n){let{aptosConfig:t,authKey:e}=n,r=await Ln({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await ce({aptosConfig:t,accountAddress:r}),!0}catch(o){if(o.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function Ne(n){return new Promise(t=>{setTimeout(t,n)})}async function xo(n){let{aptosConfig:t,options:e}=n;return Ve({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([e, 'optionalAccess', _63 => _63.limit])}})}async function sn(n){let{aptosConfig:t}=n;return Ye(async()=>{let{data:e}=await V({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function vo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function an(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await V({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Co(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await an({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _64 => _64.status])===404)return!0;throw r}}async function Ze(n){let{aptosConfig:t,transactionHash:e,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _65 => _65.timeoutSecs]), () => ($t)),s=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _66 => _66.checkSuccess]), () => (!0)),i=!0,a=0,c,p,g=200,P=1.5;for(;i&&!(a>=o);){try{if(c=await an({aptosConfig:t,transactionHash:e}),i=c.type==="pending_transaction",!i)break}catch(A){if(!(A instanceof ge)||(p=A,A.status!==404&&A.status>=400&&A.status<500))throw A}await Ne(g),a+=g/1e3,g*=P}if(c===void 0)throw p||new on(`Fetching transaction ${e} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new on(`Transaction ${e} timed out in pending state after ${o} seconds`,c);if(!s)return c;if(!c.success)throw new Hn(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function cn(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,s=new Date().getTime(),i=BigInt(-1);for(;i<r;){if(new Date().getTime()-s>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?i=await tn({aptosConfig:t}):i=(await nn({aptosConfig:t,processorType:e})).last_success_version,i>=r)break;await Ne(200)}}var on=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Hn=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function b(n){n.minimumLedgerVersion!==void 0&&await cn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var bt=class{constructor(t){this.config=t}async getAccountInfo(t){return ce({aptosConfig:this.config,...t})}async getAccountModules(t){return lo({aptosConfig:this.config,...t})}async getAccountModule(t){return rn({aptosConfig:this.config,...t})}async getAccountTransactions(t){return go({aptosConfig:this.config,...t})}async getAccountResources(t){return mo({aptosConfig:this.config,...t})}async getAccountResource(t){return $n({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Ln({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),yo({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ao({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),fo({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ho({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),To({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Vn({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),wo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Lt,...t})}async getAccountCoinAmount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),bo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),_o({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return So({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var un=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _67 => _67.network]), () => (Pr)),this.fullnode=_optionalChain([t, 'optionalAccess', _68 => _68.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _69 => _69.faucet]),this.indexer=_optionalChain([t, 'optionalAccess', _70 => _70.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _71 => _71.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _72 => _72.clientConfig]), () => ({}))}getRequestUrl(t){switch(t){case 0:if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return kn[this.network];case 2:if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return zn[this.network];case 1:if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Rn[this.network];default:throw Error(`apiType ${t} is not supported`)}}isIndexerRequest(t){return Rn[this.network]===t}isFullnodeRequest(t){return kn[this.network]===t}isFaucetRequest(t){return zn[this.network]===t}};var pn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new O(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=T.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var K=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return fe.load(t);case 1:return dn.load(t);case 2:return ue.load(t);case 3:return Je.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof fe}isMultiEd25519(){return this instanceof dn}isSingleKey(){return this instanceof ue}isMultiKey(){return this instanceof Je}},fe= exports.AccountAuthenticatorEd25519 =class n extends K{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=S.deserialize(e),o=k.deserialize(e);return new n(r,o)}},dn= exports.AccountAuthenticatorMultiEd25519 =class n extends K{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=se.deserialize(e),o=We.deserialize(e);return new n(r,o)}},ue= exports.AccountAuthenticatorSingleKey =class n extends K{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=I.deserialize(e),o=Ae.deserialize(e);return new n(r,o)}},Je= exports.AccountAuthenticatorMultiKey =class n extends K{constructor(e,r,o){super();this.public_keys=e,this.signatures=r,this.signatures_bitmap=o}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let r=je.deserialize(e),o=e.deserializeVector(Ae),s=e.deserializeBytes();return new n(r,o,s)}};var he=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return et.load(t);case 1:return Qn.load(t);case 2:return tt.load(t);case 3:return nt.load(t);case 4:return rt.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},et= exports.TransactionAuthenticatorEd25519 =class n extends he{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=S.deserialize(e),o=k.deserialize(e);return new n(r,o)}},Qn= exports.TransactionAuthenticatorMultiEd25519 =class n extends he{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=se.deserialize(e),o=We.deserialize(e);return new n(r,o)}},tt= exports.TransactionAuthenticatorMultiAgent =class n extends he{constructor(e,r,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=K.deserialize(e),o=e.deserializeVector(u),s=e.deserializeVector(K);return new n(r,o,s)}},nt= exports.TransactionAuthenticatorFeePayer =class n extends he{constructor(e,r,o,s){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o,this.fee_payer=s}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=K.deserialize(e),o=e.deserializeVector(u),s=e.deserializeVector(K),i=u.deserialize(e),a=K.deserialize(e),c={address:i,authenticator:a};return new n(r,o,s,c)}},rt= exports.TransactionAuthenticatorSingleSender =class n extends he{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=K.deserialize(e);return new n(r)}};var ot=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var U=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var wt=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new U(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),o=U.deserialize(e);return new n(r,o)}};var z=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return D.load(t);case 1:return pe.load(t);case 2:return q.load(t);case 3:return at.load(t);case 4:return $.load(t);case 5:return qe.load(t);case 6:return v.load(t);case 7:return l.load(t);case 8:return st.load(t);case 9:return it.load(t);case 10:return ct.load(t);case 255:return N.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof D}isAddress(){return this instanceof $}isGeneric(){return this instanceof N}isSigner(){return this instanceof qe}isVector(){return this instanceof v}isStruct(){return this instanceof l}isU8(){return this instanceof pe}isU16(){return this instanceof st}isU32(){return this instanceof it}isU64(){return this instanceof q}isU128(){return this instanceof at}isU256(){return this instanceof ct}},D= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},pe= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},st= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},it= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},q= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},at= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},ct= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},$= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},qe= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},ln= exports.TypeTagReference =class n extends z{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=z.deserialize(e);return new n(r)}},N= exports.TypeTagGeneric =class n extends z{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},v= exports.TypeTagVector =class n extends z{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new pe)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=z.deserialize(e);return new n(r)}},l= exports.TypeTagStruct =class n extends z{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=Te.deserialize(e);return new n(r)}isTypeTag(e,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},Te= exports.StructTag =class n extends d{constructor(e,r,o,s){super();this.address=e,this.moduleName=r,this.name=o,this.typeArgs=s}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=u.deserialize(e),o=U.deserialize(e),s=U.deserialize(e),i=e.deserializeVector(z);return new n(r,o,s,i)}};function Hd(){return new Te(u.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function x(){return new Te(u.ONE,new U("string"),new U("String"),[])}function Qd(n){return new Te(u.ONE,new U("option"),new U("Option"),[n])}function L(n){return new Te(u.ONE,new U("object"),new U("Object"),[n])}function pi(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return G.deserialize(n);case 1:return O.deserialize(n);case 2:return J.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,G);case 5:return R.deserialize(n);case 6:return Y.deserialize(n);case 7:return Z.deserialize(n);case 8:return ee.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var Ke=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return _t.load(t);case 2:return St.load(t);case 3:return xt.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},_t= exports.TransactionPayloadScript =class n extends Ke{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=vt.deserialize(e);return new n(r)}},St= exports.TransactionPayloadEntryFunction =class n extends Ke{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=ut.deserialize(e);return new n(r)}},xt= exports.TransactionPayloadMultiSig =class n extends Ke{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Ct.deserialize(e);return new n(r)}},ut= exports.EntryFunction =class n{constructor(t,e,r,o){this.module_name=t,this.function_name=e,this.type_args=r,this.args=o}static build(t,e,r,o){return new n(wt.fromStr(t),new U(e),r,o)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=wt.deserialize(t),r=U.deserialize(t),o=t.deserializeVector(z),s=t.deserializeUleb128AsU32(),i=new Array;for(let a=0;a<s;a+=1){let c=t.deserializeUleb128AsU32(),p=Wt.deserialize(t,c);i.push(p)}return new n(e,r,o,i)}},vt= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(z),o=t.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1){let a=pi(t);s.push(a)}return new n(e,r,s)}},Ct= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),o;return r&&(o=Pt.deserialize(t)),new n(e,o)}},Pt= exports.MultiSigTransactionPayload =class n extends d{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(ut.deserialize(e))}};var ne=class n extends d{constructor(e,r,o,s,i,a,c){super();this.sender=e,this.sequence_number=r,this.payload=o,this.max_gas_amount=s,this.gas_unit_price=i,this.expiration_timestamp_secs=a,this.chain_id=c}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 r=u.deserialize(e),o=e.deserializeU64(),s=Ke.deserialize(e),i=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=ot.deserialize(e);return new n(r,o,s,i,a,c,p)}},gn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return be.load(t);case 1:return we.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},be= exports.MultiAgentRawTransaction =class n extends gn{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=ne.deserialize(e),o=e.deserializeVector(u);return new n(r,o)}},we= exports.FeePayerRawTransaction =class n extends gn{constructor(e,r,o){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=o}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 r=ne.deserialize(e),o=e.deserializeVector(u),s=u.deserialize(e);return new n(r,o,s)}};var de=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=ne.deserialize(e),o=he.deserialize(e);return new n(r,o)}};function Po(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Eo(n){return!!n.match(/\s/)}function di(n){return!!n.match(/^T[0-9]+$/)}function li(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!Eo(r))break}return e}var gi=(A=>(A.InvalidTypeTag="unknown type",A.UnexpectedGenericType="unexpected generic type",A.UnexpectedTypeArgumentClose="unexpected '>'",A.UnexpectedWhitespaceCharacter="unexpected whitespace character",A.UnexpectedComma="unexpected ','",A.TypeArgumentCountMismatch="type argument count doesn't match expected amount",A.MissingTypeArgumentClose="no matching '>' for '<'",A.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",A.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",A.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",A.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",A.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",A))(gi||{}),C= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function $e(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _73 => _73.allowGenerics]), () => (!1)),r=[],o=[],s=[],i=0,a="",c=1;for(;i<n.length;){let p=n[i];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:s}),a="",s=[],c=1;else if(p===">"){if(a!==""){let De=mn(a,o,e);s.push(De)}let g=r.pop();if(g===void 0)throw new C(n,"unexpected '>'");if(c!==s.length)throw new C(n,"type argument count doesn't match expected amount");let{savedStr:P,savedTypes:A,savedExpectedTypes:m}=g;o=s,s=A,a=P,c=m}else if(p===","){if(a.length!==0){let g=mn(a,o,e);o=[],s.push(g),a="",c+=1}}else if(Eo(p)){let g=!1;if(a.length!==0){let A=mn(a,o,e);o=[],s.push(A),a="",g=!0}i=li(n,i);let P=n[i];if(i<n.length&&g&&P!==","&&P!==">")throw new C(n,"unexpected whitespace character");continue}else a+=p;i+=1}if(r.length>0)throw new C(n,"no matching '>' for '<'");switch(s.length){case 0:return mn(a,o,e);case 1:if(a==="")return s[0];throw new C(n,"unexpected ','");default:throw new C(n,"unexpected whitespace character")}}function mn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new ln(new qe);case"signer":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new qe;case"bool":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new D;case"address":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new $;case"u8":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new pe;case"u16":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new st;case"u32":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new it;case"u64":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new q;case"u128":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new at;case"u256":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new ct;case"vector":if(t.length!==1)throw new C(n,"vector type expected to have exactly one type argument");return new v(t[0]);default:if(di(n)){if(e)return new N(Number(n.split("T")[1]));throw new C(n,"unexpected generic type")}if(!n.match(/:/))throw new C(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new C(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Po(r[1]))throw new C(n,"module name must only contain alphanumeric or '_' characters");if(!Po(r[2]))throw new C(n,"struct name must only contain alphanumeric or '_' characters");return new l(new Te(u.fromString(r[0]),new U(r[1]),new U(r[2]),t))}}function Io(n){return typeof n=="boolean"}function pt(n){return typeof n=="string"}function yn(n){return typeof n=="number"}function An(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Uo(n){return n==null}function Ro(n){return Wn(n)||Xn(n)||Yn(n)||Zn(n)||Jn(n)||er(n)||tr(n)||fn(n)||jn(n)||mi(n)||n instanceof T||n instanceof xe}function Wn(n){return n instanceof R}function fn(n){return n instanceof u}function jn(n){return n instanceof w}function mi(n){return n instanceof Fe}function Xn(n){return n instanceof G}function Yn(n){return n instanceof Y}function Zn(n){return n instanceof Z}function Jn(n){return n instanceof O}function er(n){return n instanceof J}function tr(n){return n instanceof ee}function ko(n){return"bytecode"in n}function E(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function zo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function nr(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],o=t[2];return{moduleAddress:e,moduleName:r,functionName:o}}var yi=new TextEncoder;function No(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _74 => _74.map, 'call', _75 => _75(t=>pt(t)?$e(t):t)]), () => ([]))}async function Oo(n,t,e,r){let s=await _asyncOptionalChain([(await rn({aptosConfig:r,accountAddress:n,moduleName:t})), 'access', async _76 => _76.abi, 'optionalAccess', async _77 => _77.exposed_functions, 'access', async _78 => _78.find, 'call', async _79 => _79(c=>c.name===e)]);if(!s)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!s.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let i=zo(s),a=[];for(let c=i;c<s.params.length;c+=1)a.push($e(s.params[c],{allowGenerics:!0}));return{typeParameters:s.generic_type_params,parameters:a}}function Go(n,t,e,r,o){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let s=t.parameters[r];return dt(e,s,r,o)}function dt(n,t,e,r){return Ro(n)?(rr(t,n,e),n):Ai(n,t,e,r)}function Ai(n,t,e,r){if(t.isBool()){if(Io(n))return new R(n);E("boolean",e)}if(t.isAddress()){if(pt(n))return u.fromString(n);E("string | AccountAddress",e)}if(t.isU8()){if(yn(n))return new G(n);E("number",e)}if(t.isU16()){if(yn(n))return new Y(n);E("number",e)}if(t.isU32()){if(yn(n))return new Z(n);E("number",e)}if(t.isU64()){if(An(n))return new O(BigInt(n));E("bigint | number | string",e)}if(t.isU128()){if(An(n))return new J(BigInt(n));E("bigint | number | string",e)}if(t.isU256()){if(An(n))return new ee(BigInt(n));E("bigint | number | string",e)}if(t.isGeneric()){let o=t.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return dt(n,r[o],e,r)}if(t.isVector()){if(t.value.isU8()){if(pt(n))return T.U8(yi.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(o=>dt(o,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(pt(n))return new w(n);E("string",e)}if(t.isObject()){if(pt(n))return u.fromString(n);E("string | AccountAddress",e)}if(t.isOption())return Uo(n)?new xe(null):new xe(dt(n,t.value.typeArgs[0],e,r));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function rr(n,t,e){if(n.isBool()){if(Wn(t))return;E("Bool",e)}if(n.isAddress()){if(fn(t))return;E("AccountAddress",e)}if(n.isU8()){if(Xn(t))return;E("U8",e)}if(n.isU16()){if(Yn(t))return;E("U16",e)}if(n.isU32()){if(Zn(t))return;E("U32",e)}if(n.isU64()){if(Jn(t))return;E("U64",e)}if(n.isU128()){if(er(t))return;E("U128",e)}if(n.isU256()){if(tr(t))return;E("U256",e)}if(n.isVector()){if(t instanceof T){t.values.length>0&&rr(n.value,t.values[0],e);return}E("MoveVector",e)}if(n instanceof l){if(n.isString()){if(jn(t))return;E("MoveString",e)}if(n.isObject()){if(fn(t))return;E("AccountAddress",e)}if(n.isOption()){if(t instanceof xe){t.value!==void 0&&rr(n.value.typeArgs[0],t.value,e);return}E("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function Tn(n){if(ko(n))return hi(n);let{moduleAddress:t,moduleName:e,functionName:r}=nr(n.function),o=await Ye(async()=>Oo(t,e,r,n.aptosConfig),`entry-function-${n.aptosConfig.network}-${t}-${e}-${r}`,1e3*60*5)();return bn({abi:o,...n})}function bn(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=nr(n.function),s=No(n.typeArguments);if(s.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let i=n.functionArguments.map((c,p)=>Go(n.function,t,c,p,s));if(i.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${o}', expected ${t.parameters.length} but got ${i.length}`);let a=ut.build(`${e}::${r}`,o,s,i);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new xt(new Ct(c,new Pt(a)))}return new St(a)}function hi(n){return new _t(new vt(h.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function Ti(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s}=n,i=Nn[t.network]?Promise.resolve({chain_id:Nn[t.network]}):Jt({aptosConfig:t}),a=_optionalChain([o, 'optionalAccess', _80 => _80.gasUnitPrice])?Promise.resolve({gas_estimate:o.gasUnitPrice}):sn({aptosConfig:t}),[{chain_id:c},{gas_estimate:p}]=await Promise.all([i,a]),g=_optionalChain([o, 'optionalAccess', _81 => _81.accountSequenceNumber])!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):ce({aptosConfig:t,accountAddress:e}),P;if(s&&u.from(s).equals(u.ZERO))try{let{sequence_number:At}=await g;P=At}catch (e2){P="0"}else{let{sequence_number:At}=await g;P=At}let{maxGasAmount:A,gasUnitPrice:m,expireTimestamp:De}={maxGasAmount:_optionalChain([o, 'optionalAccess', _82 => _82.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(Er),gasUnitPrice:BigInt(p),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+Ir),...o};return new ne(u.from(e),BigInt(P),r,BigInt(A),BigInt(m),BigInt(De),new ot(c))}async function or(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s}=n,i=await Ti({aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _83 => _83.secondarySignerAddresses, 'optionalAccess', _84 => _84.map, 'call', _85 => _85(c=>u.from(c))]), () => ([]));return{rawTransaction:i,secondarySignerAddresses:a,feePayerAddress:n.feePayerAddress?u.from(n.feePayerAddress):void 0}}return{rawTransaction:i,feePayerAddress:n.feePayerAddress?u.from(n.feePayerAddress):void 0}}function Do(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,s=hn(t);if(e.feePayerAddress){let a=new we(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(P=>hn(P)));let p=hn(o),g=new nt(s,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new de(a.raw_txn,g).bcsToBytes()}if(e.secondarySignerAddresses){let a=new be(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(g=>hn(g));let p=new tt(s,e.secondarySignerAddresses,c);return new de(a.raw_txn,p).bcsToBytes()}let i;if(s instanceof fe)i=new et(s.public_key,s.signature);else if(s instanceof ue)i=new rt(s);else throw new Error("Invalid public key");return new de(e.rawTransaction,i).bcsToBytes()}function hn(n){if(n instanceof I){if(n.publicKey instanceof S)return new ue(n,new Ae(new k(new Uint8Array(64))));if(n.publicKey instanceof te)return new ue(n,new Ae(new Re(new Uint8Array(64))))}return new fe(new S(n.toUint8Array()),new k(new Uint8Array(64)))}function Bo(n){let{signer:t,transaction:e}=n,r=sr(e),o=t.sign(r);switch(t.signingScheme){case 0:return new fe(new S(t.publicKey.toUint8Array()),new k(o.toUint8Array()));case 2:if(!I.isPublicKey(t.publicKey))throw new Error(`Cannot sign transaction, public key does not match ${t.signingScheme}`);return new ue(t.publicKey,new Ae(o));default:throw new Error(`Cannot sign transaction, signing scheme ${t.signingScheme} not supported`)}}function Mo(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:o}=n,s=Fo(t);if((r||o)&&(s instanceof be||s instanceof we))return bi(s,e,r,o);if(e instanceof fe&&s instanceof ne){let i=new et(e.public_key,e.signature);return new de(s,i).bcsToBytes()}if((e instanceof ue||e instanceof Je)&&s instanceof ne){let i=new rt(e);return new de(s,i).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Fo(n){return n.feePayerAddress?new we(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new be(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function bi(n,t,e,r){if(n instanceof we){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new nt(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new de(n.raw_txn,o).bcsToBytes()}if(n instanceof be){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new tt(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new de(n.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function sr(n){let t=Fo(n),e=_sha3.sha3_256.create();if(t instanceof ne)e.update(Ur);else if(t instanceof be)e.update(On);else if(t instanceof we)e.update(On);else throw new Error(`Unknown transaction type to sign on: ${t}`);let r=e.digest(),o=t.bcsToBytes(),s=new Uint8Array(r.length+o.length);return s.set(r),s.set(o,r.length),s}async function f(n){let t=await wi(n);return _i(n,t)}async function wi(n){let{aptosConfig:t,data:e}=n,r,o;return"bytecode"in e?o=await Tn(e):"multisigAddress"in e?e.abi?o=bn({abi:e.abi,...e}):(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await Tn(r)):e.abi?o=bn({abi:e.abi,...e}):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await Tn(r)),o}async function _i(n,t){let{aptosConfig:e,sender:r,options:o}=n,s;if(Si(n)&&(s=u.ZERO.toString()),xi(n)){let{secondarySignerAddresses:i}=n;return or({aptosConfig:e,sender:r,payload:t,options:o,secondarySignerAddresses:i,feePayerAddress:s})}return or({aptosConfig:e,sender:r,payload:t,options:o,feePayerAddress:s})}function Si(n){return n.withFeePayer===!0}function xi(n){return"secondarySignerAddresses"in n}function qo(n){let{transaction:t}=n;return sr(t)}function wn(n){return Bo({...n})}async function ir(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}=n,a=Do({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}),{data:c}=await He({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _86 => _86.options, 'optionalAccess', _87 => _87.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _88 => _88.options, 'optionalAccess', _89 => _89.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _90 => _90.options, 'optionalAccess', _91 => _91.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function _n(n){let{aptosConfig:t}=n,e=Mo({...n}),{data:r}=await He({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function Et(n){let{aptosConfig:t,signer:e,transaction:r}=n,o=wn({signer:e,transaction:r});return _n({aptosConfig:t,transaction:r,senderAuthenticator:o})}var vi={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Ko(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:o,options:s}=n,i=o.map(a=>T.U8(a));return f({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(i)],abi:vi},options:s})}var Ci={typeParameters:[],parameters:[new pe,v.u8(),new pe,v.u8(),v.u8(),v.u8()]};async function $o(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,o=await ce({aptosConfig:t,accountAddress:e.accountAddress}),s=ke.fromPrivateKey({privateKey:r,legacy:!0}),a=new pn({sequenceNumber:BigInt(o.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:s.publicKey}).bcsToBytes(),c=e.sign(a),p=s.sign(a),g=await f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new G(e.signingScheme.valueOf()),T.U8(e.publicKey.toUint8Array()),new G(s.signingScheme.valueOf()),T.U8(s.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:Ci}});return Et({aptosConfig:t,signer:e,transaction:g})}var Pi={typeParameters:[{constraints:[]}],parameters:[new $,new q]};async function Lo(n){let{aptosConfig:t,sender:e,recipient:r,amount:o,coinType:s,options:i}=n;return f({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(s, () => (Lt))],functionArguments:[r,o],abi:Pi},options:i})}var It=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Lo({aptosConfig:this.config,...t})}};var Oe={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},j="0x4::token::Token";async function Vo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:so,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ho(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:qn,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Qo(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s={query:qn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _92 => _92.offset]),limit:_optionalChain([r, 'optionalAccess', _93 => _93.limit]),order_by:_optionalChain([r, 'optionalAccess', _94 => _94.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Wo(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,o={token_data_id:{_eq:u.from(e).toStringLong()}},s={query:oo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _95 => _95.offset]),limit:_optionalChain([r, 'optionalAccess', _96 => _96.limit]),order_by:_optionalChain([r, 'optionalAccess', _97 => _97.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ei={typeParameters:[],parameters:[new l(x()),new q,new l(x()),new l(x()),new D,new D,new D,new D,new D,new D,new D,new D,new D,new q,new q]};async function jo(n){let{aptosConfig:t,options:e,creator:r}=n;return f({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new O(_nullishCoalesce(n.maxSupply, () => (Be))),new w(n.name),new w(n.uri),new R(_nullishCoalesce(n.mutableDescription, () => (!0))),new R(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new R(_nullishCoalesce(n.mutableURI, () => (!0))),new R(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new R(_nullishCoalesce(n.mutableTokenName, () => (!0))),new R(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new R(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new R(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new R(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new O(_nullishCoalesce(n.royaltyNumerator, () => (0))),new O(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Ei},options:e})}async function ar(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:o}=n,s=u.from(e),i={collection_name:{_eq:r},creator_address:{_eq:s.toStringLong()}};return _optionalChain([o, 'optionalAccess', _98 => _98.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _99 => _99.tokenStandard]), () => ("v2"))}),(await y({aptosConfig:t,query:{query:Zr,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Xo(n){return(await ar(n)).collection_id}var Ii={typeParameters:[],parameters:[new l(x()),new l(x()),new l(x()),new l(x()),new v(new l(x())),new v(new l(x())),new v(v.u8())]};async function Yo(n){let{aptosConfig:t,options:e,creator:r,collection:o,description:s,name:i,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:g}=n,P=_optionalChain([p, 'optionalAccess', _100 => _100.map, 'call', _101 => _101(A=>Oe[A])]);return f({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(o),new w(s),new w(i),new w(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(P, () => ([]))),ds(_nullishCoalesce(g, () => ([])),_nullishCoalesce(P, () => ([])))],abi:Ii},options:e})}var Ui={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new $]};async function Zo(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(s, () => (j))],functionArguments:[u.from(r),u.from(o)],abi:Ui},options:i})}var Ri={typeParameters:[],parameters:[new l(x()),new l(x()),new l(x()),new l(x()),new v(new l(x())),new v(new l(x())),new v(v.u8()),new $]};async function Jo(n){let{aptosConfig:t,account:e,collection:r,description:o,name:s,uri:i,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:g,options:P}=n;if(_optionalChain([c, 'optionalAccess', _102 => _102.length])!==_optionalChain([g, 'optionalAccess', _103 => _103.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _104 => _104.length])!==_optionalChain([g, 'optionalAccess', _105 => _105.length]))throw new Error("Property types and property values counts do not match");let A=_optionalChain([p, 'optionalAccess', _106 => _106.map, 'call', _107 => _107(m=>Oe[m])]);return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,s,i,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(A, () => ([]))),ds(_nullishCoalesce(g, () => ([])),_nullishCoalesce(A, () => ([]))),a],abi:Ri},options:P})}var ki={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0)))]};async function es(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (j))],functionArguments:[u.from(r)],abi:ki},options:s})}var zi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0)))]};async function ts(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (j))],functionArguments:[r],abi:zi},options:s})}var Ni={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0)))]};async function ns(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (j))],functionArguments:[r],abi:Ni},options:s})}var Oi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x())]};async function rs(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(s, () => (j))],functionArguments:[u.from(o),new w(r)],abi:Oi},options:i})}var Gi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x())]};async function os(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(s, () => (j))],functionArguments:[u.from(o),new w(r)],abi:Gi},options:i})}var Di={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x())]};async function ss(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(s, () => (j))],functionArguments:[u.from(o),new w(r)],abi:Di},options:i})}var Bi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x()),new l(x()),v.u8()]};async function is(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (j))],functionArguments:[u.from(i),new w(r),new w(Oe[o]),T.U8(cr(s,Oe[o]))],abi:Bi},options:c})}var Mi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x())]};async function as(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(s, () => (j))],functionArguments:[u.from(o),new w(r)],abi:Mi},options:i})}var Fi={typeParameters:[{constraints:["key"]}],parameters:[new l(L(new N(0))),new l(x()),new l(x()),v.u8()]};async function cs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (j))],functionArguments:[u.from(i),new w(r),new w(Oe[o]),cr(s,Oe[o])],abi:Fi},options:c})}var qi={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(L(new N(0))),new l(x()),new N(1)]};async function us(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (j)),Oe[o]],functionArguments:[u.from(i),new w(r),s],abi:qi},options:c})}var Ki={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(L(new N(0))),new l(x()),new N(1)]};async function ps(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (j)),Oe[o]],functionArguments:[u.from(i),new w(r),s],abi:Ki},options:c})}function ds(n,t){let e=new Array;return t.forEach((r,o)=>{e.push(cr(n[o],r))}),e}function cr(n,t){let e=$e(t);return dt(n,e,0,[]).bcsToBytes()}var Ut=class{constructor(t){this.config=t}async getCollectionData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ar({aptosConfig:this.config,...t})}async getCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Xo({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Vo({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ho({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Qo({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Wo({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return jo({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return Yo({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return Zo({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Jo({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return es({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return ts({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return ns({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return rs({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return os({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return ss({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return is({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return as({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return cs({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return us({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return ps({aptosConfig:this.config,...t})}};var ls=300,$i=n=>{if(n&&n.length>ls)throw new Error(`Event type length exceeds the maximum length of ${ls}`)};async function gs(n){let{aptosConfig:t,eventType:e,options:r}=n,s={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _108 => _108.orderBy])};return Rt({aptosConfig:t,options:s})}async function ms(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _109 => _109.orderBy])};return Rt({aptosConfig:e,options:a})}async function ys(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _110 => _110.orderBy])};return Rt({aptosConfig:e,options:a})}async function Rt(n){let{aptosConfig:t,options:e}=n;$i(_optionalChain([e, 'optionalAccess', _111 => _111.where, 'optionalAccess', _112 => _112.indexed_type, 'optionalAccess', _113 => _113._eq]));let r={query:to,variables:{where_condition:_optionalChain([e, 'optionalAccess', _114 => _114.where]),offset:_optionalChain([e, 'optionalAccess', _115 => _115.offset]),limit:_optionalChain([e, 'optionalAccess', _116 => _116.limit]),order_by:_optionalChain([e, 'optionalAccess', _117 => _117.orderBy])}};return(await y({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var kt=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),gs({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ms({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ys({aptosConfig:this.config,...t})}async getEvents(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _118 => _118.minimumLedgerVersion]),processorType:"events_processor"}),Rt({aptosConfig:this.config,...t})}};async function As(n){let{aptosConfig:t,accountAddress:e,amount:r,options:o}=n,s=_optionalChain([o, 'optionalAccess', _119 => _119.timeoutSecs])||$t,{data:i}=await zr({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=i.txn_hashes[0],c=await Ze({aptosConfig:t,transactionHash:a,options:{timeoutSecs:s,checkSuccess:_optionalChain([o, 'optionalAccess', _120 => _120.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var zt=class{constructor(t){this.config=t}async fundAccount(t){let e=await As({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _121 => _121.options, 'optionalAccess', _122 => _122.waitForIndexer])!==!1&&await cn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function ur(n){let{aptosConfig:t,options:e}=n,r={query:ro,variables:{where_condition:_optionalChain([e, 'optionalAccess', _123 => _123.where]),limit:_optionalChain([e, 'optionalAccess', _124 => _124.limit]),offset:_optionalChain([e, 'optionalAccess', _125 => _125.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function fs(n){let{aptosConfig:t,options:e}=n,r={query:no,variables:{where_condition:_optionalChain([e, 'optionalAccess', _126 => _126.where]),limit:_optionalChain([e, 'optionalAccess', _127 => _127.limit]),offset:_optionalChain([e, 'optionalAccess', _128 => _128.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function hs(n){let{aptosConfig:t,options:e}=n,r={query:Jr,variables:{where_condition:_optionalChain([e, 'optionalAccess', _129 => _129.where]),limit:_optionalChain([e, 'optionalAccess', _130 => _130.limit]),offset:_optionalChain([e, 'optionalAccess', _131 => _131.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Li={typeParameters:[],parameters:[$e("0x1::object::Object"),new $,new q]};async function Ts(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:o,amount:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,s],abi:Li},options:i})}var Nt=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _132 => _132.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ur({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _133 => _133.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await ur({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _134 => _134.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),fs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _135 => _135.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),hs({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Ts({aptosConfig:this.config,...t})}};var Ot=class{constructor(t){this.config=t}async getLedgerInfo(){return Jt({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return io({aptosConfig:this.config,...t})}async getBlockByHeight(t){return ao({aptosConfig:this.config,...t})}async getTableItem(t){return en({aptosConfig:this.config,...t})}async view(t){return ze({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return co({aptosConfig:this.config,...t})}async queryIndexer(t){return y({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return tn({aptosConfig:this.config})}async getProcessorStatus(t){return nn({aptosConfig:this.config,processorType:t})}};var bs=["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 ws(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Ge(n){let[t,e,...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(!ws(t))throw new Error(`${t} is not valid. ${bs}`);if(e&&!ws(e))throw new Error(`${e} is not valid. ${bs}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Vi="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Hi={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Vi,custom:null,devnet:null,randomnet:null};function _e(n){let t=Hi[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var Qi=n=>({vec:[n]}),Wi=()=>({vec:[]}),pr=n=>n!=null?Qi(n):Wi(),Sn=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function _s(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:s}=Ge(e),i=await ze({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,pr(s)]}}),a=Sn(i[0]);return a?u.from(a).toString():void 0}async function Ss(n){let{aptosConfig:t,expiration:e,name:r,sender:o,targetAddress:s,toAddress:i,options:a,transferable:c}=n,p=_e(t),{domainName:g,subdomainName:P}=Ge(r),A=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(P&&!A)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(A&&!P)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let yr=_nullishCoalesce(e.years, () => (1));if(yr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ms=yr*31536e3;return await f({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[g,Ms,s,i]},options:a})}if(!P)throw new Error(`${e.policy} requires a subdomain to be provided.`);let m=await dr({aptosConfig:t,name:g});if(!m)throw new Error("The domain does not exist");let De=e.policy==="subdomain:independent"?e.expirationDate:m;if(De>m)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await f({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[g,P,Math.round(De/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,s,i]},options:a})}async function dr(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:s}=Ge(e);try{let i=await ze({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,pr(s)]}});return Number(i[0])*1e3}catch (e3){return}}async function xs(n){let{aptosConfig:t,address:e}=n,r=_e(t),o=await ze({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),s=Sn(o[1]),i=Sn(o[0]);if(s)return[i,s].filter(Boolean).join(".")}async function vs(n){let{aptosConfig:t,sender:e,name:r,options:o}=n,s=_e(t);if(!r)return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:i,subdomainName:a}=Ge(r);return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_primary_name`,functionArguments:[i,a]},options:o})}async function Cs(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:s}=Ge(e),i=await ze({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,pr(s)]}}),a=Sn(i[0]);return a?u.from(a).toString():void 0}async function Ps(n){let{aptosConfig:t,sender:e,name:r,address:o,options:s}=n,i=_e(t),{domainName:a,subdomainName:c}=Ge(r);return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::set_target_addr`,functionArguments:[a,c,o]},options:s})}async function Es(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:o=""}=Ge(e),a=(await y({aptosConfig:t,query:{query:Xe,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Gt(a)),a}async function Is(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await lr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountNames",query:{query:Xe,variables:{limit:_optionalChain([e, 'optionalAccess', _136 => _136.limit]),offset:_optionalChain([e, 'optionalAccess', _137 => _137.offset]),order_by:_optionalChain([e, 'optionalAccess', _138 => _138.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _139 => _139.options, 'optionalAccess', _140 => _140.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Gt)}async function Us(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await lr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Xe,variables:{limit:_optionalChain([e, 'optionalAccess', _141 => _141.limit]),offset:_optionalChain([e, 'optionalAccess', _142 => _142.offset]),order_by:_optionalChain([e, 'optionalAccess', _143 => _143.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _144 => _144.options, 'optionalAccess', _145 => _145.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Gt)}async function Rs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await lr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Xe,variables:{limit:_optionalChain([e, 'optionalAccess', _146 => _146.limit]),offset:_optionalChain([e, 'optionalAccess', _147 => _147.offset]),order_by:_optionalChain([e, 'optionalAccess', _148 => _148.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _149 => _149.options, 'optionalAccess', _150 => _150.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Gt)}async function ks(n){let{aptosConfig:t,options:e,domain:r}=n;return(await y({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Xe,variables:{limit:_optionalChain([e, 'optionalAccess', _151 => _151.limit]),offset:_optionalChain([e, 'optionalAccess', _152 => _152.offset]),order_by:_optionalChain([e, 'optionalAccess', _153 => _153.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _154 => _154.options, 'optionalAccess', _155 => _155.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Gt)}async function lr(n){let{aptosConfig:t}=n,e=_e(t),[r]=await ze({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,s=()=>new Date;return new Date(s().setDate(s().getDate()-o)).toISOString()}async function zs(n){let{aptosConfig:t,sender:e,name:r,years:o=1,options:s}=n,i=_e(t),a=o*31536e3,{domainName:c,subdomainName:p}=Ge(r);if(p)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::renew_domain`,functionArguments:[c,a]},options:s})}function Gt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).valueOf()}}var Dt=class{constructor(t){this.config=t}async getOwnerAddress(t){return _s({aptosConfig:this.config,...t})}async getExpiration(t){return dr({aptosConfig:this.config,...t})}async getTargetAddress(t){return Cs({aptosConfig:this.config,...t})}async setTargetAddress(t){return Ps({aptosConfig:this.config,...t})}async getPrimaryName(t){return xs({aptosConfig:this.config,...t})}async setPrimaryName(t){return vs({aptosConfig:this.config,...t})}async registerName(t){return Ss({aptosConfig:this.config,...t})}async renewDomain(t){return zs({aptosConfig:this.config,...t})}async getName(t){return Es({aptosConfig:this.config,...t})}async getAccountNames(t){return Is({aptosConfig:this.config,...t})}async getAccountDomains(t){return Us({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Rs({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return ks({aptosConfig:this.config,...t})}};async function Ns(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:Mn,variables:{where_condition:{pool_address:{_eq:r}}}}});return s.num_active_delegator_per_pool[0]?s.num_active_delegator_per_pool[0].num_active_delegator:0}async function Os(n){let{aptosConfig:t,options:e}=n,r={query:Mn,variables:{order_by:_optionalChain([e, 'optionalAccess', _156 => _156.orderBy])}};return(await y({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Gs(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,o={query:eo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await y({aptosConfig:t,query:o})).delegated_staking_activities}var Bt=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _157 => _157.minimumLedgerVersion]),processorType:"stake_processor"}),Ns({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _158 => _158.minimumLedgerVersion]),processorType:"stake_processor"}),Os({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _159 => _159.minimumLedgerVersion]),processorType:"stake_processor"}),Gs({aptosConfig:this.config,...t})}};var xn=class{constructor(t){this.config=t}async simple(t){return f({aptosConfig:this.config,...t})}async multiAgent(t){return f({aptosConfig:this.config,...t})}};function gr(n,t,e){let r=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},e}function mr(n,t,e){let r=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},e}var lt=class{constructor(t){this.config=t}async simple(t){return ir({aptosConfig:this.config,...t})}async multiAgent(t){return ir({aptosConfig:this.config,...t})}};M([mr],lt.prototype,"simple",1),M([mr],lt.prototype,"multiAgent",1);var gt=class{constructor(t){this.config=t}async simple(t){return _n({aptosConfig:this.config,...t})}async multiAgent(t){return _n({aptosConfig:this.config,...t})}};M([gr],gt.prototype,"simple",1),M([gr],gt.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var vn=()=>Math.floor(Date.now()/1e3),Cn= exports.AccountSequenceNumber =class{constructor(t,e,r,o,s){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=s}async nextSequenceNumber(){for(;this.lock;)await Ne(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=vn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await Ne(this.sleepTime),vn()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await ce({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await Ne(this.sleepTime);this.lock=!0;try{await this.update();let t=vn();for(;this.lastUncommintedNumber!==this.currentNumber;)vn()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await Ne(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var mt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _160 => _160.pendingDequeue, 'access', _161 => _161.shift, 'call', _162 => _162(), 'optionalAccess', _163 => _163.resolve, 'call', _164 => _164(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new yt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},yt=class extends Error{};var Ds="fulfilled",Bs= exports.TransactionWorkerEventsEnum =(s=>(s.TransactionSent="transactionSent",s.TransactionSendFailed="transactionSendFailed",s.TransactionExecuted="transactionExecuted",s.TransactionExecutionFailed="transactionExecutionFailed",s.ExecutionFinish="executionFinish",s))(Bs||{}),Pn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,o=30,s=100,i=10){super();this.taskQueue=new mt;this.transactionsQueue=new mt;this.outstandingTransactions=new mt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new Cn(e,r,o,s,i)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let o=Et({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,e])}}catch(e){if(e instanceof yt)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[o,s]=await this.outstandingTransactions.dequeue();for(e.push(o),r.push(s);!this.outstandingTransactions.isEmpty();)[o,s]=await this.outstandingTransactions.dequeue(),e.push(o),r.push(s);let i=await Promise.allSettled(e);for(let a=0;a<i.length&&a<r.length;a+=1){let c=i[a];s=r[a],c.status===Ds?(this.sentTransactions.push([c.value.hash,s,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,s)):(this.sentTransactions.push([c.status,s,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 ${i.length} transactions finished`})}}catch(e){if(e instanceof yt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let o=[];o.push(Ze({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let s=await Promise.allSettled(o);for(let i=0;i<s.length;i+=1){let a=s[i];a.status===Ds?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.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(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[o,s]=await this.transactionsQueue.dequeue();return f({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:o,options:{...s,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}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 En=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Pn(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:o}=e;for(let s of r)this.transactionWorker.push(s,o)}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:r,data:o,options:s}=e;this.start({sender:r}),this.push({data:o,options:s})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var Mt=class{constructor(t){this.config=t,this.build=new xn(this.config),this.simulate=new lt(this.config),this.submit=new gt(this.config),this.batch=new En(this.config)}async getTransactions(t){return xo({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return vo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return an({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Co({aptosConfig:this.config,...t})}async waitForTransaction(t){return Ze({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return sn({aptosConfig:this.config})}getSigningMessage(t){return qo(t)}async publishPackageTransaction(t){return Ko({aptosConfig:this.config,...t})}async rotateAuthKey(t){return $o({aptosConfig:this.config,...t})}sign(t){return wn({...t})}signAsFeePayer(t){let{signer:e,transaction:r}=t;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=e.accountAddress,wn({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:o}=t;this.batch.forSingleAccount({sender:e,data:r,options:o})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return Et({aptosConfig:this.config,signer:e,transaction:r})}};var X=class{constructor(t){this.config=new un(t),this.account=new bt(this.config),this.ans=new Dt(this.config),this.coin=new It(this.config),this.digitalAsset=new Ut(this.config),this.event=new kt(this.config),this.faucet=new zt(this.config),this.fungibleAsset=new Nt(this.config),this.general=new Ot(this.config),this.staking=new Bt(this.config),this.transaction=new Mt(this.config)}};function le(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(t.prototype,r);o&&(o.value=function(...s){return this[e][r](...s)},Object.defineProperty(n.prototype,r,o))})}le(X,bt,"account");le(X,Dt,"ans");le(X,It,"coin");le(X,Ut,"digitalAsset");le(X,kt,"event");le(X,zt,"faucet");le(X,Nt,"fungibleAsset");le(X,Ot,"general");le(X,Bt,"staking");le(X,Mt,"transaction");exports.APTOS_BIP44_REGEX = ti; exports.APTOS_COIN = Lt; exports.APTOS_HARDENED_REGEX = ei; exports.Account = ke; exports.AccountAddress = u; exports.AccountAuthenticator = K; exports.AccountAuthenticatorEd25519 = fe; exports.AccountAuthenticatorMultiEd25519 = dn; exports.AccountAuthenticatorMultiKey = Je; exports.AccountAuthenticatorSingleKey = ue; exports.AccountAuthenticatorVariant = wr; exports.AccountSequenceNumber = Cn; exports.AddressInvalidReason = Ys; exports.AnyPublicKey = I; exports.AnyPublicKeyVariant = _r; exports.AnySignature = Ae; exports.AnySignatureVariant = Sr; exports.Aptos = X; exports.AptosApiError = ge; exports.AptosApiType = Kt; exports.AptosConfig = un; exports.AuthenticationKey = ae; exports.Bool = R; exports.CKDPriv = Fr; exports.ChainId = ot; exports.DEFAULT_MAX_GAS_AMOUNT = Er; exports.DEFAULT_NETWORK = Pr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Ir; exports.DEFAULT_TXN_TIMEOUT_SEC = $t; exports.DeriveScheme = Ls; exports.Deserializer = Or; exports.Ed25519PrivateKey = Pe; exports.Ed25519PublicKey = S; exports.Ed25519Signature = k; exports.EntryFunction = ut; exports.EntryFunctionBytes = Wt; exports.FeePayerRawTransaction = we; exports.FixedBytes = Fe; exports.HARDENED_OFFSET = Dr; exports.Hex = h; exports.HexInvalidReason = Ws; exports.Identifier = U; exports.KeyType = ni; exports.MimeType = In; exports.ModuleId = wt; exports.MoveAbility = xr; exports.MoveFunctionVisibility = Ks; exports.MoveOption = xe; exports.MoveString = w; exports.MoveVector = T; exports.MultiAgentRawTransaction = be; exports.MultiEd25519PublicKey = se; exports.MultiEd25519Signature = We; exports.MultiKey = je; exports.MultiSig = Ct; exports.MultiSigTransactionPayload = Pt; exports.Network = qt; exports.NetworkToChainId = Nn; exports.NetworkToFaucetAPI = zn; exports.NetworkToIndexerAPI = Rn; exports.NetworkToNetworkName = va; exports.NetworkToNodeAPI = kn; exports.ParsingError = F; exports.PrivateKey = Qe; exports.ProcessorType = Le; exports.PublicKey = H; exports.RAW_TRANSACTION_SALT = Ur; exports.RAW_TRANSACTION_WITH_DATA_SALT = On; exports.RawTransaction = ne; exports.RawTransactionWithData = gn; exports.RoleType = $s; exports.RotationProofChallenge = pn; exports.Script = vt; exports.ScriptTransactionArgumentVariants = ft; exports.Secp256k1PrivateKey = Ue; exports.Secp256k1PublicKey = te; exports.Secp256k1Signature = Re; exports.Serializable = d; exports.Serializer = re; exports.Signature = oe; exports.SignedTransaction = de; exports.SigningScheme = ht; exports.SigningSchemeInput = vr; exports.StructTag = Te; exports.TransactionAuthenticator = he; exports.TransactionAuthenticatorEd25519 = et; exports.TransactionAuthenticatorFeePayer = nt; exports.TransactionAuthenticatorMultiAgent = tt; exports.TransactionAuthenticatorMultiEd25519 = Qn; exports.TransactionAuthenticatorSingleSender = rt; exports.TransactionAuthenticatorVariant = br; exports.TransactionPayload = Ke; exports.TransactionPayloadEntryFunction = St; exports.TransactionPayloadMultiSig = xt; exports.TransactionPayloadScript = _t; exports.TransactionPayloadVariants = hr; exports.TransactionResponseType = Un; exports.TransactionVariants = Tr; exports.TransactionWorker = Pn; exports.TransactionWorkerEventsEnum = Bs; exports.TypeTag = z; exports.TypeTagAddress = $; exports.TypeTagBool = D; exports.TypeTagGeneric = N; exports.TypeTagParserError = C; exports.TypeTagParserErrorType = gi; exports.TypeTagReference = ln; exports.TypeTagSigner = qe; exports.TypeTagStruct = l; exports.TypeTagU128 = at; exports.TypeTagU16 = st; exports.TypeTagU256 = ct; exports.TypeTagU32 = it; exports.TypeTagU64 = q; exports.TypeTagU8 = pe; exports.TypeTagVariants = fr; exports.TypeTagVector = v; exports.U128 = J; exports.U16 = Y; exports.U256 = ee; exports.U32 = Z; exports.U64 = O; exports.U8 = G; exports.aptosCoinStructTag = Hd; exports.aptosRequest = Ft; exports.buildTransaction = or; exports.checkOrConvertArgument = dt; exports.convertArgument = Go; exports.deriveKey = Bn; exports.deriveTransactionType = Fo; exports.deserializeFromScriptArgument = pi; exports.ensureBoolean = Dn; exports.fetchEntryFunctionAbi = Oo; exports.findFirstNonSignerArg = zo; exports.generateMultiSignersSignedTransaction = bi; exports.generateRawTransaction = Ti; exports.generateSignedTransaction = Mo; exports.generateSignedTransactionForSimulation = Do; exports.generateSigningMessage = sr; exports.generateTransactionPayload = Tn; exports.generateTransactionPayloadWithABI = bn; exports.get = Rr; exports.getAptosFullNode = V; exports.getAuthenticatorForSimulation = hn; exports.getFunctionParts = nr; exports.isBcsAddress = fn; exports.isBcsBool = Wn; exports.isBcsFixedBytes = mi; exports.isBcsString = jn; exports.isBcsU128 = er; exports.isBcsU16 = Yn; exports.isBcsU256 = tr; exports.isBcsU32 = Zn; exports.isBcsU64 = Jn; exports.isBcsU8 = Xn; exports.isBlockMetadataTransactionResponse = sa; exports.isBool = Io; exports.isEd25519Signature = ca; exports.isEncodedEntryFunctionArgument = Ro; exports.isFeePayerSignature = da; exports.isGenesisTransactionResponse = oa; exports.isLargeNumber = An; exports.isMultiAgentSignature = pa; exports.isMultiEd25519Signature = la; exports.isNull = Uo; exports.isNumber = yn; exports.isPendingTransactionResponse = na; exports.isScriptDataInput = ko; exports.isSecp256k1Signature = ua; exports.isStateCheckpointTransactionResponse = ia; exports.isString = pt; exports.isUserTransactionResponse = ra; exports.isValidBIP44Path = Br; exports.isValidHardenedPath = Mr; exports.isValidatorTransactionResponse = aa; exports.mnemonicToSeed = jt; exports.objectStructTag = L; exports.optionStructTag = Qd; exports.outOfRangeErrorMessage = js; exports.paginateWithCursor = Ve; exports.parseTypeTag = $e; exports.post = Gn; exports.postAptosFaucet = zr; exports.postAptosFullNode = He; exports.postAptosIndexer = kr; exports.promiseFulfilledStatus = Ds; exports.request = Vs; exports.sign = Bo; exports.splitPath = qr; exports.standardizeTypeTags = No; exports.stringStructTag = x; exports.throwTypeMismatch = E; exports.validateNumberInRange = Se;
428
+ `;async function nn(n){let{aptosConfig:t}=n,{data:e}=await j({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function po(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:o}=await j({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _21 => _21.withTransactions])}});return o}async function lo(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:o}=await j({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _22 => _22.withTransactions])}});return o}async function rn(n){let{aptosConfig:t,handle:e,data:r,options:o}=n;return(await He({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _23 => _23.ledgerVersion])},body:r})).data}async function Ie(n){let{aptosConfig:t,payload:e,options:r}=n,{data:o}=await He({aptosConfig:t,originMethod:"view",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _24 => _24.ledgerVersion])},body:{function:e.function,type_arguments:_nullishCoalesce(e.typeArguments, () => ([])),arguments:_nullishCoalesce(e.functionArguments, () => ([]))}});return o}async function go(n){let{aptosConfig:t,limit:e}=n;return(await y({aptosConfig:t,query:{query:no,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function y(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:o}=await zr({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return o}async function gi(n){let{aptosConfig:t}=n;return(await y({aptosConfig:t,query:{query:Fn},originMethod:"getProcessorStatuses"})).processor_status}async function on(n){let t=await gi({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function sn(n){let{aptosConfig:t,processorType:e}=n,r={processor:{_eq:e.valueOf()}};return(await y({aptosConfig:t,query:{query:Fn,variables:{where_condition:r}},originMethod:"getProcessorStatus"})).processor_status[0]}var qn=new Map;function et(n,t,e){return async(...r)=>{if(qn.has(t)){let{value:s,timestamp:i}=qn.get(t);if(e===void 0||Date.now()-i<=e)return s}let o=await n(...r);return qn.set(t,{value:o,timestamp:Date.now()}),o}}async function de(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await j({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function Ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _25 => _25.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _26 => _26.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _27 => _27.limit]), () => (1e3))}})}async function an(n){return _optionalChain([n, 'access', _28 => _28.options, 'optionalAccess', _29 => _29.ledgerVersion])!==void 0?mo(n):et(async()=>mo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function mo(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:o}=n,{data:s}=await j({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _30 => _30.ledgerVersion])}});return s}async function fo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _31 => _31.offset]),limit:_optionalChain([r, 'optionalAccess', _32 => _32.limit])}})}async function ho(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ve({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _33 => _33.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _34 => _34.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _35 => _35.limit]), () => (999))}})}async function $n(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:o}=n,{data:s}=await j({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _36 => _36.ledgerVersion])}});return s.data}async function Ln(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,o=await $n({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:s}}=o,i=u.from(e);try{let a=await rn({aptosConfig:t,handle:s,data:{key:i.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return i;throw a}}async function To(n){let{aptosConfig:t,accountAddress:e}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},i=await y({aptosConfig:t,query:{query:eo,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return i.current_token_ownerships_v2_aggregate.aggregate?i.current_token_ownerships_v2_aggregate.aggregate.count:0}async function bo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _37 => _37.tokenStandard])&&(s.token_standard={_eq:_optionalChain([r, 'optionalAccess', _38 => _38.tokenStandard])});let i={query:Zr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _39 => _39.offset]),limit:_optionalChain([r, 'optionalAccess', _40 => _40.limit]),order_by:_optionalChain([r, 'optionalAccess', _41 => _41.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function wo(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:o}=n,s=u.from(e).toStringLong(),i=u.from(r).toStringLong(),a={owner_address:{_eq:s},current_token_data:{collection_id:{_eq:i}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _42 => _42.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _43 => _43.tokenStandard])});let c={query:Jr,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _44 => _44.offset]),limit:_optionalChain([o, 'optionalAccess', _45 => _45.limit]),order_by:_optionalChain([o, 'optionalAccess', _46 => _46.orderBy])}};return(await y({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function _o(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _47 => _47.tokenStandard])&&(s.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _48 => _48.tokenStandard])}});let i={query:Xr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _49 => _49.offset]),limit:_optionalChain([r, 'optionalAccess', _50 => _50.limit]),order_by:_optionalChain([r, 'optionalAccess', _51 => _51.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function So(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:to,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return s.account_transactions_aggregate.aggregate?s.account_transactions_aggregate.aggregate.count:0}async function xo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,o=u.from(e).toStringLong(),s=await Vn({aptosConfig:t,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return s[0]?s[0].amount:0}async function Vn(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o=u.from(e).toStringLong(),s={..._optionalChain([r, 'optionalAccess', _52 => _52.where]),owner_address:{_eq:o}},i={query:jr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _53 => _53.offset]),limit:_optionalChain([r, 'optionalAccess', _54 => _54.limit]),order_by:_optionalChain([r, 'optionalAccess', _55 => _55.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function vo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:Wr,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!s.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return s.current_fungible_asset_balances_aggregate.aggregate.count}async function Co(n){let{aptosConfig:t,accountAddress:e,options:r}=n,s={owner_address:{_eq:u.from(e).toStringLong()}},i={query:Yr,variables:{where_condition:s,offset:_optionalChain([r, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([r, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([r, 'optionalAccess', _58 => _58.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getAccountOwnedObjects"})).current_objects}async function Po(n){let{aptosConfig:t,privateKey:e}=n,r=new q(e.publicKey());if(e instanceof Fe){let s=K.fromPublicKeyAndScheme({publicKey:r,scheme:2}).derivedAddress();return Ee.fromPrivateKeyAndAddress({privateKey:e,address:s})}if(e instanceof Y){let o=K.fromPublicKeyAndScheme({publicKey:r,scheme:2});if(await yo({authKey:o,aptosConfig:t})){let c=o.derivedAddress();return Ee.fromPrivateKeyAndAddress({privateKey:e,address:c,legacy:!1})}let i=K.fromPublicKeyAndScheme({publicKey:r.publicKey,scheme:0});if(await yo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return Ee.fromPrivateKeyAndAddress({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function yo(n){let{aptosConfig:t,authKey:e}=n,r=await Ln({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await de({aptosConfig:t,accountAddress:r}),!0}catch(o){if(o.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function Ue(n){return new Promise(t=>{setTimeout(t,n)})}async function Eo(n){let{aptosConfig:t,options:e}=n;return Ve({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _59 => _59.offset]),limit:_optionalChain([e, 'optionalAccess', _60 => _60.limit])}})}async function un(n){let{aptosConfig:t}=n;return et(async()=>{let{data:e}=await j({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function Io(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await j({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function pn(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await j({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Uo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await pn({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _61 => _61.status])===404)return!0;throw r}}async function tt(n){let{aptosConfig:t,transactionHash:e,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _62 => _62.timeoutSecs]), () => (20)),s=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _63 => _63.checkSuccess]), () => (!0)),i=!0,a=0,c,p,g=200,C=1.5;for(;i&&!(a>=o);){try{if(c=await pn({aptosConfig:t,transactionHash:e}),i=c.type==="pending_transaction",!i)break}catch(A){if(!(A instanceof ye)||(p=A,A.status!==404&&A.status>=400&&A.status<500))throw A}await Ue(g),a+=g/1e3,g*=C}if(c===void 0)throw p||new cn(`Fetching transaction ${e} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new cn(`Transaction ${e} timed out in pending state after ${o} seconds`,c);if(!s)return c;if(!c.success)throw new Hn(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function dn(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,s=new Date().getTime(),i=BigInt(-1);for(;i<r;){if(new Date().getTime()-s>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?i=await on({aptosConfig:t}):i=(await sn({aptosConfig:t,processorType:e})).last_success_version,i>=r)break;await Ue(200)}}var cn=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Hn=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function T(n){n.minimumLedgerVersion!==void 0&&await dn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var _t=class{constructor(t){this.config=t}async getAccountInfo(t){return de({aptosConfig:this.config,...t})}async getAccountModules(t){return Ao({aptosConfig:this.config,...t})}async getAccountModule(t){return an({aptosConfig:this.config,...t})}async getAccountTransactions(t){return fo({aptosConfig:this.config,...t})}async getAccountResources(t){return ho({aptosConfig:this.config,...t})}async getAccountResource(t){return $n({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Ln({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),To({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),bo({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),wo({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),_o({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),So({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Vn({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Vt,...t})}async getAccountCoinAmount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),xo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),Co({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Po({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Qn={mainnet:"https://indexer.mainnet.aptoslabs.com/v1/graphql",testnet:"https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql",devnet:"https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Wn= exports.NetworkToNodeAPI ={mainnet:"https://fullnode.mainnet.aptoslabs.com/v1",testnet:"https://fullnode.testnet.aptoslabs.com/v1",devnet:"https://fullnode.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},jn= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",randomnet:"https://faucet.random.aptoslabs.com",local:"http://127.0.0.1:8081"},Xn= exports.Network =(i=>(i.MAINNET="mainnet",i.TESTNET="testnet",i.DEVNET="devnet",i.RANDOMNET="randomnet",i.LOCAL="local",i.CUSTOM="custom",i))(Xn||{}),Yn= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70},jd= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var ln=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _64 => _64.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _65 => _65.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _66 => _66.faucet]),this.indexer=_optionalChain([t, 'optionalAccess', _67 => _67.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _68 => _68.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _69 => _69.clientConfig]), () => ({}))}getRequestUrl(t){switch(t){case 0:if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Wn[this.network];case 2:if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return jn[this.network];case 1:if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Qn[this.network];default:throw Error(`apiType ${t} is not supported`)}}isIndexerRequest(t){return Qn[this.network]===t}isFullnodeRequest(t){return Wn[this.network]===t}isFaucetRequest(t){return jn[this.network]===t}};var gn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new k(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=h.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var Te=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return nt.load(t);case 1:return Zn.load(t);case 2:return rt.load(t);case 3:return ot.load(t);case 4:return st.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},nt= exports.TransactionAuthenticatorEd25519 =class n extends Te{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=U.deserialize(e),o=R.deserialize(e);return new n(r,o)}},Zn= exports.TransactionAuthenticatorMultiEd25519 =class n extends Te{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=We.deserialize(e),o=Be.deserialize(e);return new n(r,o)}},rt= exports.TransactionAuthenticatorMultiAgent =class n extends Te{constructor(e,r,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=H.deserialize(e),o=e.deserializeVector(u),s=e.deserializeVector(H);return new n(r,o,s)}},ot= exports.TransactionAuthenticatorFeePayer =class n extends Te{constructor(e,r,o,s){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o,this.fee_payer=s}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=H.deserialize(e),o=e.deserializeVector(u),s=e.deserializeVector(H),i=u.deserialize(e),a=H.deserialize(e),c={address:i,authenticator:a};return new n(r,o,s,c)}},st= exports.TransactionAuthenticatorSingleSender =class n extends Te{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=H.deserialize(e);return new n(r)}};var it=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var E=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var St=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new E(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),o=E.deserialize(e);return new n(r,o)}};var N=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return O.load(t);case 1:return le.load(t);case 2:return $.load(t);case 3:return ut.load(t);case 4:return Q.load(t);case 5:return Ke.load(t);case 6:return x.load(t);case 7:return l.load(t);case 8:return at.load(t);case 9:return ct.load(t);case 10:return pt.load(t);case 255:return G.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof O}isAddress(){return this instanceof Q}isGeneric(){return this instanceof G}isSigner(){return this instanceof Ke}isVector(){return this instanceof x}isStruct(){return this instanceof l}isU8(){return this instanceof le}isU16(){return this instanceof at}isU32(){return this instanceof ct}isU64(){return this instanceof $}isU128(){return this instanceof ut}isU256(){return this instanceof pt}},O= exports.TypeTagBool =class n extends N{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},le= exports.TypeTagU8 =class n extends N{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},at= exports.TypeTagU16 =class n extends N{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},ct= exports.TypeTagU32 =class n extends N{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},$= exports.TypeTagU64 =class n extends N{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},ut= exports.TypeTagU128 =class n extends N{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},pt= exports.TypeTagU256 =class n extends N{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},Q= exports.TypeTagAddress =class n extends N{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},Ke= exports.TypeTagSigner =class n extends N{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},mn= exports.TypeTagReference =class n extends N{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=N.deserialize(e);return new n(r)}},G= exports.TypeTagGeneric =class n extends N{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},x= exports.TypeTagVector =class n extends N{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new le)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=N.deserialize(e);return new n(r)}},l= exports.TypeTagStruct =class n extends N{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=be.deserialize(e);return new n(r)}isTypeTag(e,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},be= exports.StructTag =class n extends d{constructor(e,r,o,s){super();this.address=e,this.moduleName=r,this.name=o,this.typeArgs=s}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=u.deserialize(e),o=E.deserialize(e),s=E.deserialize(e),i=e.deserializeVector(N);return new n(r,o,s,i)}};function Nl(){return new be(u.ONE,new E("aptos_coin"),new E("AptosCoin"),[])}function S(){return new be(u.ONE,new E("string"),new E("String"),[])}function Gl(n){return new be(u.ONE,new E("option"),new E("Option"),[n])}function W(n){return new be(u.ONE,new E("object"),new E("Object"),[n])}function yi(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return z.deserialize(n);case 1:return k.deserialize(n);case 2:return re.deserialize(n);case 3:return u.deserialize(n);case 4:return h.deserialize(n,z);case 5:return I.deserialize(n);case 6:return te.deserialize(n);case 7:return ne.deserialize(n);case 8:return oe.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var qe=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return xt.load(t);case 2:return vt.load(t);case 3:return Ct.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},xt= exports.TransactionPayloadScript =class n extends qe{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Pt.deserialize(e);return new n(r)}},vt= exports.TransactionPayloadEntryFunction =class n extends qe{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=dt.deserialize(e);return new n(r)}},Ct= exports.TransactionPayloadMultiSig =class n extends qe{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Et.deserialize(e);return new n(r)}},dt= exports.EntryFunction =class n{constructor(t,e,r,o){this.module_name=t,this.function_name=e,this.type_args=r,this.args=o}static build(t,e,r,o){return new n(St.fromStr(t),new E(e),r,o)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=St.deserialize(t),r=E.deserialize(t),o=t.deserializeVector(N),s=t.deserializeUleb128AsU32(),i=new Array;for(let a=0;a<s;a+=1){let c=t.deserializeUleb128AsU32(),p=jt.deserialize(t,c);i.push(p)}return new n(e,r,o,i)}},Pt= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(N),o=t.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1){let a=yi(t);s.push(a)}return new n(e,r,s)}},Et= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),o;return r&&(o=It.deserialize(t)),new n(e,o)}},It= exports.MultiSigTransactionPayload =class n extends d{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(dt.deserialize(e))}};var ie=class n extends d{constructor(e,r,o,s,i,a,c){super();this.sender=e,this.sequence_number=r,this.payload=o,this.max_gas_amount=s,this.gas_unit_price=i,this.expiration_timestamp_secs=a,this.chain_id=c}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 r=u.deserialize(e),o=e.deserializeU64(),s=qe.deserialize(e),i=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=it.deserialize(e);return new n(r,o,s,i,a,c,p)}},yn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return we.load(t);case 1:return _e.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},we= exports.MultiAgentRawTransaction =class n extends yn{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=ie.deserialize(e),o=e.deserializeVector(u);return new n(r,o)}},_e= exports.FeePayerRawTransaction =class n extends yn{constructor(e,r,o){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=o}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 r=ie.deserialize(e),o=e.deserializeVector(u),s=u.deserialize(e);return new n(r,o,s)}};var ge=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=ie.deserialize(e),o=Te.deserialize(e);return new n(r,o)}};function Ro(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function No(n){return!!n.match(/\s/)}function Ai(n){return!!n.match(/^T[0-9]+$/)}function fi(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!No(r))break}return e}var hi=(A=>(A.InvalidTypeTag="unknown type",A.UnexpectedGenericType="unexpected generic type",A.UnexpectedTypeArgumentClose="unexpected '>'",A.UnexpectedWhitespaceCharacter="unexpected whitespace character",A.UnexpectedComma="unexpected ','",A.TypeArgumentCountMismatch="type argument count doesn't match expected amount",A.MissingTypeArgumentClose="no matching '>' for '<'",A.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",A.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",A.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",A.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",A.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",A))(hi||{}),v= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function $e(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _70 => _70.allowGenerics]), () => (!1)),r=[],o=[],s=[],i=0,a="",c=1;for(;i<n.length;){let p=n[i];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:s}),a="",s=[],c=1;else if(p===">"){if(a!==""){let Ge=An(a,o,e);s.push(Ge)}let g=r.pop();if(g===void 0)throw new v(n,"unexpected '>'");if(c!==s.length)throw new v(n,"type argument count doesn't match expected amount");let{savedStr:C,savedTypes:A,savedExpectedTypes:m}=g;o=s,s=A,a=C,c=m}else if(p===","){if(a.length!==0){let g=An(a,o,e);o=[],s.push(g),a="",c+=1}}else if(No(p)){let g=!1;if(a.length!==0){let A=An(a,o,e);o=[],s.push(A),a="",g=!0}i=fi(n,i);let C=n[i];if(i<n.length&&g&&C!==","&&C!==">")throw new v(n,"unexpected whitespace character");continue}else a+=p;i+=1}if(r.length>0)throw new v(n,"no matching '>' for '<'");switch(s.length){case 0:return An(a,o,e);case 1:if(a==="")return s[0];throw new v(n,"unexpected ','");default:throw new v(n,"unexpected whitespace character")}}function An(n,t,e){switch(n){case"&signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new mn(new Ke);case"signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new Ke;case"bool":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new O;case"address":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new Q;case"u8":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new le;case"u16":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new at;case"u32":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new ct;case"u64":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new $;case"u128":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new ut;case"u256":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new pt;case"vector":if(t.length!==1)throw new v(n,"vector type expected to have exactly one type argument");return new x(t[0]);default:if(Ai(n)){if(e)return new G(Number(n.split("T")[1]));throw new v(n,"unexpected generic type")}if(!n.match(/:/))throw new v(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new v(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Ro(r[1]))throw new v(n,"module name must only contain alphanumeric or '_' characters");if(!Ro(r[2]))throw new v(n,"struct name must only contain alphanumeric or '_' characters");return new l(new be(u.fromString(r[0]),new E(r[1]),new E(r[2]),t))}}function Go(n){return typeof n=="boolean"}function lt(n){return typeof n=="string"}function fn(n){return typeof n=="number"}function hn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function ko(n){return n==null}function zo(n){return Jn(n)||tr(n)||nr(n)||rr(n)||or(n)||sr(n)||ir(n)||Tn(n)||er(n)||Ti(n)||n instanceof h||n instanceof Ce}function Jn(n){return n instanceof I}function Tn(n){return n instanceof u}function er(n){return n instanceof w}function Ti(n){return n instanceof Oe}function tr(n){return n instanceof z}function nr(n){return n instanceof te}function rr(n){return n instanceof ne}function or(n){return n instanceof k}function sr(n){return n instanceof re}function ir(n){return n instanceof oe}function Oo(n){return"bytecode"in n}function P(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Do(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function ar(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],o=t[2];return{moduleAddress:e,moduleName:r,functionName:o}}var bi=new TextEncoder;function Bo(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _71 => _71.map, 'call', _72 => _72(t=>lt(t)?$e(t):t)]), () => ([]))}async function Mo(n,t,e,r){let s=await _asyncOptionalChain([(await an({aptosConfig:r,accountAddress:n,moduleName:t})), 'access', async _73 => _73.abi, 'optionalAccess', async _74 => _74.exposed_functions, 'access', async _75 => _75.find, 'call', async _76 => _76(c=>c.name===e)]);if(!s)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!s.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let i=Do(s),a=[];for(let c=i;c<s.params.length;c+=1)a.push($e(s.params[c],{allowGenerics:!0}));return{typeParameters:s.generic_type_params,parameters:a}}function Fo(n,t,e,r,o){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let s=t.parameters[r];return gt(e,s,r,o)}function gt(n,t,e,r){return zo(n)?(cr(t,n,e),n):wi(n,t,e,r)}function wi(n,t,e,r){if(t.isBool()){if(Go(n))return new I(n);P("boolean",e)}if(t.isAddress()){if(lt(n))return u.fromString(n);P("string | AccountAddress",e)}if(t.isU8()){if(fn(n))return new z(n);P("number",e)}if(t.isU16()){if(fn(n))return new te(n);P("number",e)}if(t.isU32()){if(fn(n))return new ne(n);P("number",e)}if(t.isU64()){if(hn(n))return new k(BigInt(n));P("bigint | number | string",e)}if(t.isU128()){if(hn(n))return new re(BigInt(n));P("bigint | number | string",e)}if(t.isU256()){if(hn(n))return new oe(BigInt(n));P("bigint | number | string",e)}if(t.isGeneric()){let o=t.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return gt(n,r[o],e,r)}if(t.isVector()){if(t.value.isU8()){if(lt(n))return h.U8(bi.encode(n));if(n instanceof Uint8Array)return h.U8(n);if(n instanceof ArrayBuffer)return h.U8(new Uint8Array(n))}if(Array.isArray(n))return new h(n.map(o=>gt(o,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(lt(n))return new w(n);P("string",e)}if(t.isObject()){if(lt(n))return u.fromString(n);P("string | AccountAddress",e)}if(t.isOption())return ko(n)?new Ce(null):new Ce(gt(n,t.value.typeArgs[0],e,r));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function cr(n,t,e){if(n.isBool()){if(Jn(t))return;P("Bool",e)}if(n.isAddress()){if(Tn(t))return;P("AccountAddress",e)}if(n.isU8()){if(tr(t))return;P("U8",e)}if(n.isU16()){if(nr(t))return;P("U16",e)}if(n.isU32()){if(rr(t))return;P("U32",e)}if(n.isU64()){if(or(t))return;P("U64",e)}if(n.isU128()){if(sr(t))return;P("U128",e)}if(n.isU256()){if(ir(t))return;P("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&cr(n.value,t.values[0],e);return}P("MoveVector",e)}if(n instanceof l){if(n.isString()){if(er(t))return;P("MoveString",e)}if(n.isObject()){if(Tn(t))return;P("AccountAddress",e)}if(n.isOption()){if(t instanceof Ce){t.value!==void 0&&cr(n.value.typeArgs[0],t.value,e);return}P("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function wn(n){if(Oo(n))return Si(n);let{moduleAddress:t,moduleName:e,functionName:r}=ar(n.function),o=await et(async()=>Mo(t,e,r,n.aptosConfig),`entry-function-${n.aptosConfig.network}-${t}-${e}-${r}`,1e3*60*5)();return _n({abi:o,...n})}function _n(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=ar(n.function),s=Bo(n.typeArguments);if(s.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let i=n.functionArguments.map((c,p)=>Fo(n.function,t,c,p,s));if(i.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${o}', expected ${t.parameters.length} but got ${i.length}`);let a=dt.build(`${e}::${r}`,o,s,i);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Ct(new Et(c,new It(a)))}return new vt(a)}function Si(n){return new xt(new Pt(b.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function xi(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s}=n,i=Yn[t.network]?Promise.resolve({chain_id:Yn[t.network]}):nn({aptosConfig:t}),a=_optionalChain([o, 'optionalAccess', _77 => _77.gasUnitPrice])?Promise.resolve({gas_estimate:o.gasUnitPrice}):un({aptosConfig:t}),[{chain_id:c},{gas_estimate:p}]=await Promise.all([i,a]),g=_optionalChain([o, 'optionalAccess', _78 => _78.accountSequenceNumber])!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):de({aptosConfig:t,accountAddress:e}),C;if(s&&u.from(s).equals(u.ZERO))try{let{sequence_number:ht}=await g;C=ht}catch (e2){C="0"}else{let{sequence_number:ht}=await g;C=ht}let{maxGasAmount:A,gasUnitPrice:m,expireTimestamp:Ge}={maxGasAmount:_optionalChain([o, 'optionalAccess', _79 => _79.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(p),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...o};return new ie(u.from(e),BigInt(C),r,BigInt(A),BigInt(m),BigInt(Ge),new it(c))}async function ur(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s}=n,i=await xi({aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:s});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _80 => _80.secondarySignerAddresses, 'optionalAccess', _81 => _81.map, 'call', _82 => _82(c=>u.from(c))]), () => ([]));return{rawTransaction:i,secondarySignerAddresses:a,feePayerAddress:n.feePayerAddress?u.from(n.feePayerAddress):void 0}}return{rawTransaction:i,feePayerAddress:n.feePayerAddress?u.from(n.feePayerAddress):void 0}}function Ko(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,s=bn(t);if(e.feePayerAddress){let a=new _e(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(C=>bn(C)));let p=bn(o),g=new ot(s,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new ge(a.raw_txn,g).bcsToBytes()}if(e.secondarySignerAddresses){let a=new we(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(g=>bn(g));let p=new rt(s,e.secondarySignerAddresses,c);return new ge(a.raw_txn,p).bcsToBytes()}let i;if(s instanceof pe)i=new nt(s.public_key,s.signature);else if(s instanceof se)i=new st(s);else throw new Error("Invalid public key");return new ge(e.rawTransaction,i).bcsToBytes()}function bn(n){if(n instanceof q){if(n.publicKey instanceof U)return new se(n,new B(new R(new Uint8Array(64))));if(n.publicKey instanceof fe)return new se(n,new B(new he(new Uint8Array(64))))}return new pe(new U(n.toUint8Array()),new R(new Uint8Array(64)))}function qo(n){let{signer:t,transaction:e}=n,r=pr(e);return t.signWithAuthenticator(r)}function $o(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:o}=n,s=Lo(t);if((r||o)&&(s instanceof we||s instanceof _e))return vi(s,e,r,o);if(e instanceof pe&&s instanceof ie){let i=new nt(e.public_key,e.signature);return new ge(s,i).bcsToBytes()}if((e instanceof se||e instanceof Xe)&&s instanceof ie){let i=new st(e);return new ge(s,i).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Lo(n){return n.feePayerAddress?new _e(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new we(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function vi(n,t,e,r){if(n instanceof _e){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new ot(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new ge(n.raw_txn,o).bcsToBytes()}if(n instanceof we){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new rt(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new ge(n.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function pr(n){let t=Lo(n),e=_sha3.sha3_256.create();if(t instanceof ie)e.update(Gr);else if(t instanceof we)e.update(kn);else if(t instanceof _e)e.update(kn);else throw new Error(`Unknown transaction type to sign on: ${t}`);let r=e.digest(),o=t.bcsToBytes(),s=new Uint8Array(r.length+o.length);return s.set(r),s.set(o,r.length),s}async function f(n){let t=await Ci(n);return Pi(n,t)}async function Ci(n){let{aptosConfig:t,data:e}=n,r,o;return"bytecode"in e?o=await wn(e):"multisigAddress"in e?e.abi?o=_n({abi:e.abi,...e}):(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await wn(r)):e.abi?o=_n({abi:e.abi,...e}):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await wn(r)),o}async function Pi(n,t){let{aptosConfig:e,sender:r,options:o}=n,s;if(Ei(n)&&(s=u.ZERO.toString()),Ii(n)){let{secondarySignerAddresses:i}=n;return ur({aptosConfig:e,sender:r,payload:t,options:o,secondarySignerAddresses:i,feePayerAddress:s})}return ur({aptosConfig:e,sender:r,payload:t,options:o,feePayerAddress:s})}function Ei(n){return n.withFeePayer===!0}function Ii(n){return"secondarySignerAddresses"in n}function Vo(n){let{transaction:t}=n;return pr(t)}function Sn(n){return qo({...n})}async function dr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}=n,a=Ko({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}),{data:c}=await He({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _83 => _83.options, 'optionalAccess', _84 => _84.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _85 => _85.options, 'optionalAccess', _86 => _86.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _87 => _87.options, 'optionalAccess', _88 => _88.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function xn(n){let{aptosConfig:t}=n,e=$o({...n}),{data:r}=await He({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function Ut(n){let{aptosConfig:t,signer:e,transaction:r}=n,o=Sn({signer:e,transaction:r});return xn({aptosConfig:t,transaction:r,senderAuthenticator:o})}var Ui={typeParameters:[],parameters:[x.u8(),new x(x.u8())]};async function Ho(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:o,options:s}=n,i=o.map(a=>h.U8(a));return f({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[h.U8(r),new h(i)],abi:Ui},options:s})}var Ri={typeParameters:[],parameters:[new le,x.u8(),new le,x.u8(),x.u8(),x.u8()]};async function Qo(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,o=await de({aptosConfig:t,accountAddress:e.accountAddress}),s=Ee.fromPrivateKey({privateKey:r,legacy:!0}),a=new gn({sequenceNumber:BigInt(o.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:s.publicKey}).bcsToBytes(),c=e.sign(a),p=s.sign(a),g=await f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new z(e.signingScheme.valueOf()),h.U8(e.publicKey.toUint8Array()),new z(s.signingScheme.valueOf()),h.U8(s.publicKey.toUint8Array()),h.U8(c.toUint8Array()),h.U8(p.toUint8Array())],abi:Ri}});return Ut({aptosConfig:t,signer:e,transaction:g})}var Ni={typeParameters:[{constraints:[]}],parameters:[new Q,new $]};async function Wo(n){let{aptosConfig:t,sender:e,recipient:r,amount:o,coinType:s,options:i}=n;return f({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(s, () => (Vt))],functionArguments:[r,o],abi:Ni},options:i})}var Rt=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Wo({aptosConfig:this.config,...t})}};var Re={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},J="0x4::token::Token";async function jo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:uo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Xo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:Kn,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Yo(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s={query:Kn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _89 => _89.offset]),limit:_optionalChain([r, 'optionalAccess', _90 => _90.limit]),order_by:_optionalChain([r, 'optionalAccess', _91 => _91.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Zo(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,o={token_data_id:{_eq:u.from(e).toStringLong()}},s={query:co,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _92 => _92.offset]),limit:_optionalChain([r, 'optionalAccess', _93 => _93.limit]),order_by:_optionalChain([r, 'optionalAccess', _94 => _94.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Gi={typeParameters:[],parameters:[new l(S()),new $,new l(S()),new l(S()),new O,new O,new O,new O,new O,new O,new O,new O,new O,new $,new $]};async function Jo(n){let{aptosConfig:t,options:e,creator:r}=n;return f({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new k(_nullishCoalesce(n.maxSupply, () => (ke))),new w(n.name),new w(n.uri),new I(_nullishCoalesce(n.mutableDescription, () => (!0))),new I(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new I(_nullishCoalesce(n.mutableURI, () => (!0))),new I(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new I(_nullishCoalesce(n.mutableTokenName, () => (!0))),new I(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new I(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new I(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new I(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new k(_nullishCoalesce(n.royaltyNumerator, () => (0))),new k(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Gi},options:e})}async function lr(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:o}=n,s=u.from(e),i={collection_name:{_eq:r},creator_address:{_eq:s.toStringLong()}};return _optionalChain([o, 'optionalAccess', _95 => _95.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _96 => _96.tokenStandard]), () => ("v2"))}),(await y({aptosConfig:t,query:{query:Bn,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function es(n){let{aptosConfig:t,collectionId:e}=n,o={collection_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:Bn,variables:{where_condition:o}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function ts(n){return(await lr(n)).collection_id}var ki={typeParameters:[],parameters:[new l(S()),new l(S()),new l(S()),new l(S()),new x(new l(S())),new x(new l(S())),new x(x.u8())]};async function ns(n){let{aptosConfig:t,options:e,creator:r,collection:o,description:s,name:i,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:g}=n,C=_optionalChain([p, 'optionalAccess', _97 => _97.map, 'call', _98 => _98(A=>Re[A])]);return f({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(o),new w(s),new w(i),new w(a),h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(C, () => ([]))),As(_nullishCoalesce(g, () => ([])),_nullishCoalesce(C, () => ([])))],abi:ki},options:e})}var zi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new Q]};async function rs(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(s, () => (J))],functionArguments:[u.from(r),u.from(o)],abi:zi},options:i})}var Oi={typeParameters:[],parameters:[new l(S()),new l(S()),new l(S()),new l(S()),new x(new l(S())),new x(new l(S())),new x(x.u8()),new Q]};async function os(n){let{aptosConfig:t,account:e,collection:r,description:o,name:s,uri:i,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:g,options:C}=n;if(_optionalChain([c, 'optionalAccess', _99 => _99.length])!==_optionalChain([g, 'optionalAccess', _100 => _100.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _101 => _101.length])!==_optionalChain([g, 'optionalAccess', _102 => _102.length]))throw new Error("Property types and property values counts do not match");let A=_optionalChain([p, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(m=>Re[m])]);return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,s,i,h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(A, () => ([]))),As(_nullishCoalesce(g, () => ([])),_nullishCoalesce(A, () => ([]))),a],abi:Oi},options:C})}var Di={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0)))]};async function ss(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (J))],functionArguments:[u.from(r)],abi:Di},options:s})}var Bi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0)))]};async function is(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (J))],functionArguments:[r],abi:Bi},options:s})}var Mi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0)))]};async function as(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:s}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (J))],functionArguments:[r],abi:Mi},options:s})}var Fi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S())]};async function cs(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(s, () => (J))],functionArguments:[u.from(o),new w(r)],abi:Fi},options:i})}var Ki={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S())]};async function us(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(s, () => (J))],functionArguments:[u.from(o),new w(r)],abi:Ki},options:i})}var qi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S())]};async function ps(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(s, () => (J))],functionArguments:[u.from(o),new w(r)],abi:qi},options:i})}var $i={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S()),new l(S()),x.u8()]};async function ds(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (J))],functionArguments:[u.from(i),new w(r),new w(Re[o]),h.U8(gr(s,Re[o]))],abi:$i},options:c})}var Li={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S())]};async function ls(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:o,digitalAssetType:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(s, () => (J))],functionArguments:[u.from(o),new w(r)],abi:Li},options:i})}var Vi={typeParameters:[{constraints:["key"]}],parameters:[new l(W(new G(0))),new l(S()),new l(S()),x.u8()]};async function gs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (J))],functionArguments:[u.from(i),new w(r),new w(Re[o]),gr(s,Re[o])],abi:Vi},options:c})}var Hi={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(W(new G(0))),new l(S()),new G(1)]};async function ms(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (J)),Re[o]],functionArguments:[u.from(i),new w(r),s],abi:Hi},options:c})}var Qi={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(W(new G(0))),new l(S()),new G(1)]};async function ys(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:a,options:c}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (J)),Re[o]],functionArguments:[u.from(i),new w(r),s],abi:Qi},options:c})}function As(n,t){let e=new Array;return t.forEach((r,o)=>{e.push(gr(n[o],r))}),e}function gr(n,t){let e=$e(t);return gt(n,e,0,[]).bcsToBytes()}var Nt=class{constructor(t){this.config=t}async getCollectionData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),lr({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),es({aptosConfig:this.config,...t})}async getCollectionId(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ts({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),jo({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Xo({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Yo({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Zo({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Jo({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return ns({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return rs({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return os({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return ss({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return is({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return as({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return cs({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return us({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return ps({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return ds({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return ls({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return gs({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return ms({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return ys({aptosConfig:this.config,...t})}};var fs=300,Wi=n=>{if(n&&n.length>fs)throw new Error(`Event type length exceeds the maximum length of ${fs}`)};async function hs(n){let{aptosConfig:t,eventType:e,options:r}=n,s={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _105 => _105.orderBy])};return Gt({aptosConfig:t,options:s})}async function Ts(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _106 => _106.orderBy])};return Gt({aptosConfig:e,options:a})}async function bs(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _107 => _107.orderBy])};return Gt({aptosConfig:e,options:a})}async function Gt(n){let{aptosConfig:t,options:e}=n;Wi(_optionalChain([e, 'optionalAccess', _108 => _108.where, 'optionalAccess', _109 => _109.indexed_type, 'optionalAccess', _110 => _110._eq]));let r={query:so,variables:{where_condition:_optionalChain([e, 'optionalAccess', _111 => _111.where]),offset:_optionalChain([e, 'optionalAccess', _112 => _112.offset]),limit:_optionalChain([e, 'optionalAccess', _113 => _113.limit]),order_by:_optionalChain([e, 'optionalAccess', _114 => _114.orderBy])}};return(await y({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var kt=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),hs({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ts({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),bs({aptosConfig:this.config,...t})}async getEvents(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _115 => _115.minimumLedgerVersion]),processorType:"events_processor"}),Gt({aptosConfig:this.config,...t})}};async function ws(n){let{aptosConfig:t,accountAddress:e,amount:r,options:o}=n,s=_optionalChain([o, 'optionalAccess', _116 => _116.timeoutSecs])||20,{data:i}=await Or({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=i.txn_hashes[0],c=await tt({aptosConfig:t,transactionHash:a,options:{timeoutSecs:s,checkSuccess:_optionalChain([o, 'optionalAccess', _117 => _117.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var zt=class{constructor(t){this.config=t}async fundAccount(t){let e=await ws({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _118 => _118.options, 'optionalAccess', _119 => _119.waitForIndexer])!==!1&&await dn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function mr(n){let{aptosConfig:t,options:e}=n,r={query:ao,variables:{where_condition:_optionalChain([e, 'optionalAccess', _120 => _120.where]),limit:_optionalChain([e, 'optionalAccess', _121 => _121.limit]),offset:_optionalChain([e, 'optionalAccess', _122 => _122.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function _s(n){let{aptosConfig:t,options:e}=n,r={query:io,variables:{where_condition:_optionalChain([e, 'optionalAccess', _123 => _123.where]),limit:_optionalChain([e, 'optionalAccess', _124 => _124.limit]),offset:_optionalChain([e, 'optionalAccess', _125 => _125.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ss(n){let{aptosConfig:t,options:e}=n,r={query:ro,variables:{where_condition:_optionalChain([e, 'optionalAccess', _126 => _126.where]),limit:_optionalChain([e, 'optionalAccess', _127 => _127.limit]),offset:_optionalChain([e, 'optionalAccess', _128 => _128.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ji={typeParameters:[],parameters:[$e("0x1::object::Object"),new Q,new $]};async function xs(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:o,amount:s,options:i}=n;return f({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,s],abi:ji},options:i})}var Ot=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _129 => _129.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),mr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _130 => _130.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await mr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _131 => _131.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),_s({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _132 => _132.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ss({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return xs({aptosConfig:this.config,...t})}};var Dt=class{constructor(t){this.config=t}async getLedgerInfo(){return nn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return po({aptosConfig:this.config,...t})}async getBlockByHeight(t){return lo({aptosConfig:this.config,...t})}async getTableItem(t){return rn({aptosConfig:this.config,...t})}async view(t){return Ie({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return go({aptosConfig:this.config,...t})}async queryIndexer(t){return y({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return on({aptosConfig:this.config})}async getProcessorStatus(t){return sn({aptosConfig:this.config,processorType:t})}};var vs=["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 Cs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Ne(n){let[t,e,...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(!Cs(t))throw new Error(`${t} is not valid. ${vs}`);if(e&&!Cs(e))throw new Error(`${e} is not valid. ${vs}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Xi="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Yi={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Xi,custom:null,devnet:null,randomnet:null};function Se(n){let t=Yi[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var Zi=n=>({vec:[n]}),Ji=()=>({vec:[]}),yr=n=>n!=null?Zi(n):Ji(),vn=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ps(n){let{aptosConfig:t,name:e}=n,r=Se(t),{domainName:o,subdomainName:s}=Ne(e),i=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,yr(s)]}}),a=vn(i[0]);return a?u.from(a).toString():void 0}async function Es(n){let{aptosConfig:t,expiration:e,name:r,sender:o,targetAddress:s,toAddress:i,options:a,transferable:c}=n,p=Se(t),{domainName:g,subdomainName:C}=Ne(r),A=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(C&&!A)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(A&&!C)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let br=_nullishCoalesce(e.years, () => (1));if(br!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ls=br*31536e3;return await f({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[g,Ls,s,i]},options:a})}if(!C)throw new Error(`${e.policy} requires a subdomain to be provided.`);let m=await Ar({aptosConfig:t,name:g});if(!m)throw new Error("The domain does not exist");let Ge=e.policy==="subdomain:independent"?e.expirationDate:m;if(Ge>m)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await f({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[g,C,Math.round(Ge/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,s,i]},options:a})}async function Ar(n){let{aptosConfig:t,name:e}=n,r=Se(t),{domainName:o,subdomainName:s}=Ne(e);try{let i=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,yr(s)]}});return Number(i[0])*1e3}catch (e3){return}}async function Is(n){let{aptosConfig:t,address:e}=n,r=Se(t),o=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),s=vn(o[1]),i=vn(o[0]);if(s)return[i,s].filter(Boolean).join(".")}async function Us(n){let{aptosConfig:t,sender:e,name:r,options:o}=n,s=Se(t);if(!r)return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:i,subdomainName:a}=Ne(r);return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_primary_name`,functionArguments:[i,a]},options:o})}async function Rs(n){let{aptosConfig:t,name:e}=n,r=Se(t),{domainName:o,subdomainName:s}=Ne(e),i=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,yr(s)]}}),a=vn(i[0]);return a?u.from(a).toString():void 0}async function Ns(n){let{aptosConfig:t,sender:e,name:r,address:o,options:s}=n,i=Se(t),{domainName:a,subdomainName:c}=Ne(r);return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::set_target_addr`,functionArguments:[a,c,o]},options:s})}async function Gs(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:o=""}=Ne(e),a=(await y({aptosConfig:t,query:{query:Je,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Bt(a)),a}async function ks(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await fr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountNames",query:{query:Je,variables:{limit:_optionalChain([e, 'optionalAccess', _133 => _133.limit]),offset:_optionalChain([e, 'optionalAccess', _134 => _134.offset]),order_by:_optionalChain([e, 'optionalAccess', _135 => _135.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _136 => _136.options, 'optionalAccess', _137 => _137.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Bt)}async function zs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await fr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Je,variables:{limit:_optionalChain([e, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([e, 'optionalAccess', _139 => _139.offset]),order_by:_optionalChain([e, 'optionalAccess', _140 => _140.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _141 => _141.options, 'optionalAccess', _142 => _142.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Bt)}async function Os(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await fr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Je,variables:{limit:_optionalChain([e, 'optionalAccess', _143 => _143.limit]),offset:_optionalChain([e, 'optionalAccess', _144 => _144.offset]),order_by:_optionalChain([e, 'optionalAccess', _145 => _145.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _146 => _146.options, 'optionalAccess', _147 => _147.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Bt)}async function Ds(n){let{aptosConfig:t,options:e,domain:r}=n;return(await y({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Je,variables:{limit:_optionalChain([e, 'optionalAccess', _148 => _148.limit]),offset:_optionalChain([e, 'optionalAccess', _149 => _149.offset]),order_by:_optionalChain([e, 'optionalAccess', _150 => _150.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _151 => _151.options, 'optionalAccess', _152 => _152.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Bt)}async function fr(n){let{aptosConfig:t}=n,e=Se(t),[r]=await Ie({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,s=()=>new Date;return new Date(s().setDate(s().getDate()-o)).toISOString()}async function Bs(n){let{aptosConfig:t,sender:e,name:r,years:o=1,options:s}=n,i=Se(t),a=o*31536e3,{domainName:c,subdomainName:p}=Ne(r);if(p)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await f({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::renew_domain`,functionArguments:[c,a]},options:s})}function Bt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).valueOf()}}var Mt=class{constructor(t){this.config=t}async getOwnerAddress(t){return Ps({aptosConfig:this.config,...t})}async getExpiration(t){return Ar({aptosConfig:this.config,...t})}async getTargetAddress(t){return Rs({aptosConfig:this.config,...t})}async setTargetAddress(t){return Ns({aptosConfig:this.config,...t})}async getPrimaryName(t){return Is({aptosConfig:this.config,...t})}async setPrimaryName(t){return Us({aptosConfig:this.config,...t})}async registerName(t){return Es({aptosConfig:this.config,...t})}async renewDomain(t){return Bs({aptosConfig:this.config,...t})}async getName(t){return Gs({aptosConfig:this.config,...t})}async getAccountNames(t){return ks({aptosConfig:this.config,...t})}async getAccountDomains(t){return zs({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Os({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Ds({aptosConfig:this.config,...t})}};async function Ms(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),s=await y({aptosConfig:t,query:{query:Mn,variables:{where_condition:{pool_address:{_eq:r}}}}});return s.num_active_delegator_per_pool[0]?s.num_active_delegator_per_pool[0].num_active_delegator:0}async function Fs(n){let{aptosConfig:t,options:e}=n,r={query:Mn,variables:{order_by:_optionalChain([e, 'optionalAccess', _153 => _153.orderBy])}};return(await y({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Ks(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,o={query:oo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await y({aptosConfig:t,query:o})).delegated_staking_activities}var Ft=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _154 => _154.minimumLedgerVersion]),processorType:"stake_processor"}),Ms({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _155 => _155.minimumLedgerVersion]),processorType:"stake_processor"}),Fs({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _156 => _156.minimumLedgerVersion]),processorType:"stake_processor"}),Ks({aptosConfig:this.config,...t})}};var Cn=class{constructor(t){this.config=t}async simple(t){return f({aptosConfig:this.config,...t})}async multiAgent(t){return f({aptosConfig:this.config,...t})}};function hr(n,t,e){let r=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},e}function Tr(n,t,e){let r=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},e}var mt=class{constructor(t){this.config=t}async simple(t){return dr({aptosConfig:this.config,...t})}async multiAgent(t){return dr({aptosConfig:this.config,...t})}};M([Tr],mt.prototype,"simple",1),M([Tr],mt.prototype,"multiAgent",1);var yt=class{constructor(t){this.config=t}async simple(t){return xn({aptosConfig:this.config,...t})}async multiAgent(t){return xn({aptosConfig:this.config,...t})}};M([hr],yt.prototype,"simple",1),M([hr],yt.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Pn=()=>Math.floor(Date.now()/1e3),En= exports.AccountSequenceNumber =class{constructor(t,e,r,o,s){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=s}async nextSequenceNumber(){for(;this.lock;)await Ue(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=Pn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await Ue(this.sleepTime),Pn()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await de({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await de({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await Ue(this.sleepTime);this.lock=!0;try{await this.update();let t=Pn();for(;this.lastUncommintedNumber!==this.currentNumber;)Pn()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await Ue(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var At=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _157 => _157.pendingDequeue, 'access', _158 => _158.shift, 'call', _159 => _159(), 'optionalAccess', _160 => _160.resolve, 'call', _161 => _161(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new ft("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},ft=class extends Error{};var qs="fulfilled",$s= exports.TransactionWorkerEventsEnum =(s=>(s.TransactionSent="transactionSent",s.TransactionSendFailed="transactionSendFailed",s.TransactionExecuted="transactionExecuted",s.TransactionExecutionFailed="transactionExecutionFailed",s.ExecutionFinish="executionFinish",s))($s||{}),In= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,o=30,s=100,i=10){super();this.taskQueue=new At;this.transactionsQueue=new At;this.outstandingTransactions=new At;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new En(e,r,o,s,i)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let o=Ut({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,e])}}catch(e){if(e instanceof ft)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[o,s]=await this.outstandingTransactions.dequeue();for(e.push(o),r.push(s);!this.outstandingTransactions.isEmpty();)[o,s]=await this.outstandingTransactions.dequeue(),e.push(o),r.push(s);let i=await Promise.allSettled(e);for(let a=0;a<i.length&&a<r.length;a+=1){let c=i[a];s=r[a],c.status===qs?(this.sentTransactions.push([c.value.hash,s,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,s)):(this.sentTransactions.push([c.status,s,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 ${i.length} transactions finished`})}}catch(e){if(e instanceof ft)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let o=[];o.push(tt({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let s=await Promise.allSettled(o);for(let i=0;i<s.length;i+=1){let a=s[i];a.status===qs?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.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(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[o,s]=await this.transactionsQueue.dequeue();return f({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:o,options:{...s,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}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 Un=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new In(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:o}=e;for(let s of r)this.transactionWorker.push(s,o)}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:r,data:o,options:s}=e;this.start({sender:r}),this.push({data:o,options:s})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var Kt=class{constructor(t){this.config=t,this.build=new Cn(this.config),this.simulate=new mt(this.config),this.submit=new yt(this.config),this.batch=new Un(this.config)}async getTransactions(t){return Eo({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return Io({aptosConfig:this.config,...t})}async getTransactionByHash(t){return pn({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Uo({aptosConfig:this.config,...t})}async waitForTransaction(t){return tt({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return un({aptosConfig:this.config})}getSigningMessage(t){return Vo(t)}async publishPackageTransaction(t){return Ho({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Qo({aptosConfig:this.config,...t})}sign(t){return Sn({...t})}signAsFeePayer(t){let{signer:e,transaction:r}=t;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=e.accountAddress,Sn({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:o}=t;this.batch.forSingleAccount({sender:e,data:r,options:o})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return Ut({aptosConfig:this.config,signer:e,transaction:r})}};var ee=class{constructor(t){this.config=new ln(t),this.account=new _t(this.config),this.ans=new Mt(this.config),this.coin=new Rt(this.config),this.digitalAsset=new Nt(this.config),this.event=new kt(this.config),this.faucet=new zt(this.config),this.fungibleAsset=new Ot(this.config),this.general=new Dt(this.config),this.staking=new Ft(this.config),this.transaction=new Kt(this.config)}};function me(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(t.prototype,r);o&&(o.value=function(...s){return this[e][r](...s)},Object.defineProperty(n.prototype,r,o))})}me(ee,_t,"account");me(ee,Mt,"ans");me(ee,Rt,"coin");me(ee,Nt,"digitalAsset");me(ee,kt,"event");me(ee,zt,"faucet");me(ee,Ot,"fungibleAsset");me(ee,Dt,"general");me(ee,Ft,"staking");me(ee,Kt,"transaction");exports.APTOS_BIP44_REGEX = ai; exports.APTOS_COIN = Vt; exports.APTOS_HARDENED_REGEX = ii; exports.Account = Ee; exports.AccountAddress = u; exports.AccountAuthenticator = H; exports.AccountAuthenticatorEd25519 = pe; exports.AccountAuthenticatorMultiEd25519 = en; exports.AccountAuthenticatorMultiKey = Xe; exports.AccountAuthenticatorSingleKey = se; exports.AccountAuthenticatorVariant = Cr; exports.AccountPublicKey = ce; exports.AccountSequenceNumber = En; exports.AddressInvalidReason = ni; exports.AnyPublicKey = q; exports.AnyPublicKeyVariant = Pr; exports.AnySignature = B; exports.AnySignatureVariant = Er; exports.Aptos = ee; exports.AptosApiError = ye; exports.AptosApiType = $t; exports.AptosConfig = ln; exports.AuthenticationKey = K; exports.Bool = I; exports.CKDPriv = $r; exports.ChainId = it; exports.DEFAULT_MAX_GAS_AMOUNT = Rr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Nr; exports.DEFAULT_TXN_TIMEOUT_SEC = Lt; exports.DeriveScheme = js; exports.Deserializer = Br; exports.Ed25519Account = Ye; exports.Ed25519PrivateKey = Y; exports.Ed25519PublicKey = U; exports.Ed25519Signature = R; exports.EntryFunction = dt; exports.EntryFunctionBytes = jt; exports.FeePayerRawTransaction = _e; exports.FixedBytes = Oe; exports.HARDENED_OFFSET = Fr; exports.Hex = b; exports.HexInvalidReason = Js; exports.Identifier = E; exports.KeyType = ci; exports.MimeType = Rn; exports.ModuleId = St; exports.MoveAbility = Ir; exports.MoveFunctionVisibility = Qs; exports.MoveOption = Ce; exports.MoveString = w; exports.MoveVector = h; exports.MultiAgentRawTransaction = we; exports.MultiEd25519PublicKey = We; exports.MultiEd25519Signature = Be; exports.MultiKey = Jt; exports.MultiKeySignature = Qr; exports.MultiSig = Et; exports.MultiSigTransactionPayload = It; exports.Network = Xn; exports.NetworkToChainId = Yn; exports.NetworkToFaucetAPI = jn; exports.NetworkToIndexerAPI = Qn; exports.NetworkToNetworkName = jd; exports.NetworkToNodeAPI = Wn; exports.ParsingError = F; exports.ProcessorType = Le; exports.PublicKey = wt; exports.RAW_TRANSACTION_SALT = Gr; exports.RAW_TRANSACTION_WITH_DATA_SALT = kn; exports.RawTransaction = ie; exports.RawTransactionWithData = yn; exports.RoleType = Ws; exports.RotationProofChallenge = gn; exports.Script = Pt; exports.ScriptTransactionArgumentVariants = Tt; exports.Secp256k1PrivateKey = Fe; exports.Secp256k1PublicKey = fe; exports.Secp256k1Signature = he; exports.Serializable = d; exports.Serializer = ae; exports.Signature = X; exports.SignedTransaction = ge; exports.SigningScheme = xe; exports.SigningSchemeInput = Gn; exports.SingleKeyAccount = Ze; exports.StructTag = be; exports.TransactionAuthenticator = Te; exports.TransactionAuthenticatorEd25519 = nt; exports.TransactionAuthenticatorFeePayer = ot; exports.TransactionAuthenticatorMultiAgent = rt; exports.TransactionAuthenticatorMultiEd25519 = Zn; exports.TransactionAuthenticatorSingleSender = st; exports.TransactionAuthenticatorVariant = vr; exports.TransactionPayload = qe; exports.TransactionPayloadEntryFunction = vt; exports.TransactionPayloadMultiSig = Ct; exports.TransactionPayloadScript = xt; exports.TransactionPayloadVariants = Sr; exports.TransactionResponseType = Nn; exports.TransactionVariants = xr; exports.TransactionWorker = In; exports.TransactionWorkerEventsEnum = $s; exports.TypeTag = N; exports.TypeTagAddress = Q; exports.TypeTagBool = O; exports.TypeTagGeneric = G; exports.TypeTagParserError = v; exports.TypeTagParserErrorType = hi; exports.TypeTagReference = mn; exports.TypeTagSigner = Ke; exports.TypeTagStruct = l; exports.TypeTagU128 = ut; exports.TypeTagU16 = at; exports.TypeTagU256 = pt; exports.TypeTagU32 = ct; exports.TypeTagU64 = $; exports.TypeTagU8 = le; exports.TypeTagVariants = _r; exports.TypeTagVector = x; exports.U128 = re; exports.U16 = te; exports.U256 = oe; exports.U32 = ne; exports.U64 = k; exports.U8 = z; exports.aptosCoinStructTag = Nl; exports.aptosRequest = qt; exports.buildTransaction = ur; exports.checkOrConvertArgument = gt; exports.convertArgument = Fo; exports.deriveKey = Dn; exports.deriveTransactionType = Lo; exports.deserializeFromScriptArgument = yi; exports.ensureBoolean = On; exports.fetchEntryFunctionAbi = Mo; exports.findFirstNonSignerArg = Do; exports.generateMultiSignersSignedTransaction = vi; exports.generateRawTransaction = xi; exports.generateSignedTransaction = $o; exports.generateSignedTransactionForSimulation = Ko; exports.generateSigningMessage = pr; exports.generateTransactionPayload = wn; exports.generateTransactionPayloadWithABI = _n; exports.get = kr; exports.getAptosFullNode = j; exports.getAuthenticatorForSimulation = bn; exports.getFunctionParts = ar; exports.isBcsAddress = Tn; exports.isBcsBool = Jn; exports.isBcsFixedBytes = Ti; exports.isBcsString = er; exports.isBcsU128 = sr; exports.isBcsU16 = nr; exports.isBcsU256 = ir; exports.isBcsU32 = rr; exports.isBcsU64 = or; exports.isBcsU8 = tr; exports.isBlockMetadataTransactionResponse = pa; exports.isBool = Go; exports.isEd25519Signature = ga; exports.isEncodedEntryFunctionArgument = zo; exports.isFeePayerSignature = Aa; exports.isGenesisTransactionResponse = ua; exports.isLargeNumber = hn; exports.isMultiAgentSignature = ya; exports.isMultiEd25519Signature = fa; exports.isNull = ko; exports.isNumber = fn; exports.isPendingTransactionResponse = aa; exports.isScriptDataInput = Oo; exports.isSecp256k1Signature = ma; exports.isStateCheckpointTransactionResponse = da; exports.isString = lt; exports.isUserTransactionResponse = ca; exports.isValidBIP44Path = Kr; exports.isValidHardenedPath = qr; exports.isValidatorTransactionResponse = la; exports.mnemonicToSeed = Xt; exports.objectStructTag = W; exports.optionStructTag = Gl; exports.outOfRangeErrorMessage = ei; exports.paginateWithCursor = Ve; exports.parseTypeTag = $e; exports.post = zn; exports.postAptosFaucet = Or; exports.postAptosFullNode = He; exports.postAptosIndexer = zr; exports.promiseFulfilledStatus = qs; exports.request = Xs; exports.sign = qo; exports.splitPath = Lr; exports.standardizeTypeTags = Bo; exports.stringStructTag = S; exports.throwTypeMismatch = P; exports.validateNumberInRange = ve;
429
429
  //# sourceMappingURL=index.js.map