@aptos-labs/ts-sdk 1.12.1 → 1.13.0-zeta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (538) hide show
  1. package/dist/common/chunk-KSEUZTKY.js +2 -0
  2. package/dist/common/chunk-KSEUZTKY.js.map +1 -0
  3. package/dist/common/cli/index.d.ts +37 -0
  4. package/dist/common/cli/index.js +2 -0
  5. package/dist/common/cli/index.js.map +1 -0
  6. package/dist/common/index.d.ts +2131 -1432
  7. package/dist/common/index.js +26 -26
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/esm/{Ed25519Account-DHqzsb8B.d.mts → Ed25519Account-hkKk3b4Z.d.mts} +12 -14
  10. package/dist/esm/account/Account.d.mts +34 -0
  11. package/dist/esm/account/Account.mjs +2 -0
  12. package/dist/esm/account/Ed25519Account.d.mts +34 -0
  13. package/dist/esm/account/Ed25519Account.mjs +2 -0
  14. package/dist/esm/account/EphemeralKeyPair.d.mts +42 -0
  15. package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
  16. package/dist/esm/account/KeylessAccount.d.mts +85 -0
  17. package/dist/esm/account/KeylessAccount.mjs +2 -0
  18. package/dist/esm/account/MultiKeyAccount.d.mts +99 -0
  19. package/dist/esm/account/MultiKeyAccount.mjs +2 -0
  20. package/dist/esm/account/SingleKeyAccount.d.mts +34 -0
  21. package/dist/esm/account/SingleKeyAccount.mjs +2 -0
  22. package/dist/esm/account/index.d.mts +39 -0
  23. package/dist/esm/account/index.mjs +2 -0
  24. package/dist/esm/api/account.d.mts +62 -9
  25. package/dist/esm/api/account.mjs +1 -1
  26. package/dist/esm/api/ans.d.mts +20 -28
  27. package/dist/esm/api/ans.mjs +1 -1
  28. package/dist/esm/api/aptos.d.mts +20 -9
  29. package/dist/esm/api/aptos.mjs +1 -1
  30. package/dist/esm/api/aptosConfig.d.mts +24 -0
  31. package/dist/esm/api/aptosConfig.mjs +1 -1
  32. package/dist/esm/api/coin.d.mts +14 -7
  33. package/dist/esm/api/coin.mjs +1 -1
  34. package/dist/esm/api/digitalAsset.d.mts +149 -10
  35. package/dist/esm/api/digitalAsset.mjs +1 -1
  36. package/dist/esm/api/event.d.mts +13 -8
  37. package/dist/esm/api/event.mjs +1 -1
  38. package/dist/esm/api/faucet.d.mts +3 -0
  39. package/dist/esm/api/faucet.mjs +1 -1
  40. package/dist/esm/api/fungibleAsset.d.mts +36 -13
  41. package/dist/esm/api/fungibleAsset.mjs +1 -1
  42. package/dist/esm/api/general.d.mts +55 -32
  43. package/dist/esm/api/general.mjs +1 -1
  44. package/dist/esm/api/index.d.mts +15 -9
  45. package/dist/esm/api/index.mjs +1 -1
  46. package/dist/esm/api/keyless.d.mts +75 -0
  47. package/dist/esm/api/keyless.mjs +2 -0
  48. package/dist/esm/api/staking.d.mts +9 -0
  49. package/dist/esm/api/staking.mjs +1 -1
  50. package/dist/esm/api/transaction.d.mts +59 -16
  51. package/dist/esm/api/transaction.mjs +1 -1
  52. package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
  53. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  54. package/dist/esm/api/transactionSubmission/management.d.mts +9 -9
  55. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  56. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  57. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  58. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  59. package/dist/esm/api/transactionSubmission/simulate.d.mts +7 -7
  60. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  61. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  62. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  63. package/dist/esm/api/utils.mjs +1 -1
  64. package/dist/esm/bcs/index.mjs +1 -1
  65. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  66. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  67. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  68. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  69. package/dist/esm/bcs/serializer.d.mts +2 -0
  70. package/dist/esm/bcs/serializer.mjs +1 -1
  71. package/dist/esm/chunk-2HXKDHMA.mjs +2 -0
  72. package/dist/esm/chunk-2HXKDHMA.mjs.map +1 -0
  73. package/dist/esm/{chunk-O3YFCZJ5.mjs → chunk-2I2XAOH7.mjs} +2 -2
  74. package/dist/esm/{chunk-NF5OUPPU.mjs → chunk-2PW2EHCH.mjs} +2 -2
  75. package/dist/esm/chunk-2PW2EHCH.mjs.map +1 -0
  76. package/dist/esm/{chunk-CP4QCRBZ.mjs → chunk-2XIT7I5L.mjs} +2 -2
  77. package/dist/esm/chunk-3FVRXELT.mjs +2 -0
  78. package/dist/esm/{chunk-U3YYSIIT.mjs → chunk-3VGX3TXH.mjs} +2 -2
  79. package/dist/esm/{chunk-FC5MU6ZN.mjs → chunk-45D3YXLT.mjs} +2 -2
  80. package/dist/esm/chunk-4FQ63Z6Y.mjs +2 -0
  81. package/dist/esm/chunk-4FQ63Z6Y.mjs.map +1 -0
  82. package/dist/esm/{chunk-M4SQNMCW.mjs → chunk-4QWFCYP2.mjs} +2 -2
  83. package/dist/esm/chunk-4QWFCYP2.mjs.map +1 -0
  84. package/dist/esm/{chunk-KQB7A4OX.mjs → chunk-5IM5TQN4.mjs} +2 -2
  85. package/dist/esm/{chunk-5NWTYUKC.mjs → chunk-67QYMEZE.mjs} +2 -2
  86. package/dist/esm/{chunk-GHYE26Q5.mjs → chunk-6FBKUTGF.mjs} +2 -2
  87. package/dist/esm/chunk-6Q2GNDKL.mjs +2 -0
  88. package/dist/esm/chunk-6RBUXB5I.mjs +2 -0
  89. package/dist/esm/{chunk-SRDIYE3M.mjs.map → chunk-6RBUXB5I.mjs.map} +1 -1
  90. package/dist/esm/{chunk-AIPKOP3K.mjs → chunk-77MI5DFB.mjs} +2 -2
  91. package/dist/esm/chunk-77MI5DFB.mjs.map +1 -0
  92. package/dist/esm/{chunk-5EN52MUT.mjs → chunk-7STYQ5ZE.mjs} +2 -2
  93. package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
  94. package/dist/esm/{chunk-YG6YYQRG.mjs → chunk-ABBKCXG4.mjs} +2 -2
  95. package/dist/esm/chunk-ABBKCXG4.mjs.map +1 -0
  96. package/dist/esm/chunk-ACOL3VVP.mjs +2 -0
  97. package/dist/esm/chunk-ACOL3VVP.mjs.map +1 -0
  98. package/dist/esm/chunk-AFPBV2BQ.mjs +2 -0
  99. package/dist/esm/{chunk-BCUSI3N6.mjs → chunk-AOCNYMMX.mjs} +2 -2
  100. package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
  101. package/dist/esm/{chunk-SUTBXHYU.mjs → chunk-AWMOLZCX.mjs} +2 -2
  102. package/dist/esm/chunk-AWMOLZCX.mjs.map +1 -0
  103. package/dist/esm/chunk-C3L4ETUF.mjs +2 -0
  104. package/dist/esm/chunk-CITY3EV2.mjs +2 -0
  105. package/dist/esm/chunk-CITY3EV2.mjs.map +1 -0
  106. package/dist/esm/chunk-COW5IGYC.mjs +2 -0
  107. package/dist/esm/chunk-CYA2GSRV.mjs +2 -0
  108. package/dist/esm/chunk-CYA2GSRV.mjs.map +1 -0
  109. package/dist/esm/{chunk-FNLRLSGJ.mjs → chunk-CYWA4AJF.mjs} +2 -2
  110. package/dist/esm/{chunk-FVMJDRHO.mjs → chunk-DANNIPX2.mjs} +2 -2
  111. package/dist/esm/chunk-DANNIPX2.mjs.map +1 -0
  112. package/dist/esm/{chunk-6O5ZR5ME.mjs → chunk-E3YEX3FR.mjs} +2 -2
  113. package/dist/esm/{chunk-G56GPLTB.mjs → chunk-EB7AI4B4.mjs} +2 -2
  114. package/dist/esm/chunk-EMFDNUP2.mjs +2 -0
  115. package/dist/esm/chunk-EMFDNUP2.mjs.map +1 -0
  116. package/dist/esm/chunk-FBPNHF54.mjs +2 -0
  117. package/dist/esm/chunk-FCVWPGXD.mjs +2 -0
  118. package/dist/esm/chunk-FCVWPGXD.mjs.map +1 -0
  119. package/dist/esm/chunk-FLYEALDB.mjs +2 -0
  120. package/dist/esm/chunk-FLYEALDB.mjs.map +1 -0
  121. package/dist/esm/chunk-G7S2ZX5A.mjs +2 -0
  122. package/dist/esm/chunk-G7S2ZX5A.mjs.map +1 -0
  123. package/dist/esm/{chunk-KAGLWBIJ.mjs → chunk-HGZGTBA4.mjs} +2 -2
  124. package/dist/esm/{chunk-T4C6BVXK.mjs → chunk-HJVGZBKN.mjs} +2 -2
  125. package/dist/esm/chunk-HJVGZBKN.mjs.map +1 -0
  126. package/dist/esm/{chunk-25UTAIJG.mjs → chunk-INYYKAXD.mjs} +2 -2
  127. package/dist/esm/chunk-J7YWDDUB.mjs +2 -0
  128. package/dist/esm/chunk-J7YWDDUB.mjs.map +1 -0
  129. package/dist/esm/chunk-JDD6TMHU.mjs +2 -0
  130. package/dist/esm/chunk-JDD6TMHU.mjs.map +1 -0
  131. package/dist/esm/chunk-JM3W7AQP.mjs +2 -0
  132. package/dist/esm/chunk-JM3W7AQP.mjs.map +1 -0
  133. package/dist/esm/{chunk-KXFMI7RM.mjs → chunk-JNAI5UFZ.mjs} +2 -2
  134. package/dist/esm/chunk-JXCZTOYC.mjs +1 -0
  135. package/dist/esm/chunk-JXCZTOYC.mjs.map +1 -0
  136. package/dist/esm/chunk-KDTQD56P.mjs +2 -0
  137. package/dist/esm/{chunk-QRVYLV76.mjs.map → chunk-KDTQD56P.mjs.map} +1 -1
  138. package/dist/esm/{chunk-A7XZTJ3D.mjs → chunk-KOWGEMJZ.mjs} +2 -2
  139. package/dist/esm/chunk-KOWGEMJZ.mjs.map +1 -0
  140. package/dist/esm/chunk-KPAKF3K7.mjs +2 -0
  141. package/dist/esm/chunk-KPAKF3K7.mjs.map +1 -0
  142. package/dist/esm/{chunk-UEKKYJGA.mjs → chunk-KR3NQRBA.mjs} +2 -2
  143. package/dist/esm/chunk-KR3NQRBA.mjs.map +1 -0
  144. package/dist/esm/chunk-L4CV3DRL.mjs +2 -0
  145. package/dist/esm/chunk-L4CV3DRL.mjs.map +1 -0
  146. package/dist/esm/{chunk-5ID6W7XL.mjs → chunk-LFTWUMLK.mjs} +2 -2
  147. package/dist/esm/chunk-LPFIDI6C.mjs +2 -0
  148. package/dist/esm/chunk-LPFIDI6C.mjs.map +1 -0
  149. package/dist/esm/chunk-LVYKZS54.mjs +2 -0
  150. package/dist/esm/{chunk-CXR7MOBW.mjs.map → chunk-LVYKZS54.mjs.map} +1 -1
  151. package/dist/esm/chunk-MGOHPDX4.mjs +2 -0
  152. package/dist/esm/chunk-MLPJOS5C.mjs +2 -0
  153. package/dist/esm/chunk-MWUJCP27.mjs +2 -0
  154. package/dist/esm/{chunk-VLNBGWGX.mjs → chunk-MZGNUGEY.mjs} +2 -2
  155. package/dist/esm/chunk-MZGNUGEY.mjs.map +1 -0
  156. package/dist/esm/chunk-NNT3XRRO.mjs +2 -0
  157. package/dist/esm/chunk-NNT3XRRO.mjs.map +1 -0
  158. package/dist/esm/chunk-NUDRQTYI.mjs +2 -0
  159. package/dist/esm/chunk-NUR3TCTI.mjs +2 -0
  160. package/dist/esm/chunk-OOSPASLD.mjs +2 -0
  161. package/dist/esm/chunk-OOSPASLD.mjs.map +1 -0
  162. package/dist/esm/chunk-OVXWFD2N.mjs +2 -0
  163. package/dist/esm/{chunk-CAGDOGXS.mjs.map → chunk-OVXWFD2N.mjs.map} +1 -1
  164. package/dist/esm/{chunk-MJPUASSD.mjs → chunk-PFFAQZHT.mjs} +2 -2
  165. package/dist/esm/chunk-PTIZKRON.mjs +2 -0
  166. package/dist/esm/chunk-PTIZKRON.mjs.map +1 -0
  167. package/dist/esm/chunk-QREYDZ5R.mjs +2 -0
  168. package/dist/esm/chunk-RFSO3JRG.mjs +1 -0
  169. package/dist/esm/chunk-RFSO3JRG.mjs.map +1 -0
  170. package/dist/esm/chunk-S5HG2QUD.mjs +2 -0
  171. package/dist/esm/chunk-S5HG2QUD.mjs.map +1 -0
  172. package/dist/esm/chunk-SHL6OAGA.mjs +2 -0
  173. package/dist/esm/chunk-SHL6OAGA.mjs.map +1 -0
  174. package/dist/esm/chunk-SKXGYGDX.mjs +2 -0
  175. package/dist/esm/chunk-SKXGYGDX.mjs.map +1 -0
  176. package/dist/esm/chunk-STYDBDYL.mjs +2 -0
  177. package/dist/esm/{chunk-QRS4DGP3.mjs → chunk-T23OVRNF.mjs} +2 -2
  178. package/dist/esm/{chunk-QRS4DGP3.mjs.map → chunk-T23OVRNF.mjs.map} +1 -1
  179. package/dist/esm/chunk-T47T7HX4.mjs +2 -0
  180. package/dist/esm/chunk-T47T7HX4.mjs.map +1 -0
  181. package/dist/esm/chunk-TB2KXA2B.mjs +2 -0
  182. package/dist/esm/chunk-TB2KXA2B.mjs.map +1 -0
  183. package/dist/esm/{chunk-VNIABDOT.mjs → chunk-THVGZXKD.mjs} +2 -2
  184. package/dist/esm/chunk-THVGZXKD.mjs.map +1 -0
  185. package/dist/esm/chunk-TJDC5PWD.mjs +2 -0
  186. package/dist/esm/chunk-TJTZVCPS.mjs +2 -0
  187. package/dist/esm/chunk-TJTZVCPS.mjs.map +1 -0
  188. package/dist/esm/chunk-TR6Q7RSZ.mjs +2 -0
  189. package/dist/esm/chunk-TR6Q7RSZ.mjs.map +1 -0
  190. package/dist/esm/{chunk-36QXVFR5.mjs → chunk-TVRJ3M7B.mjs} +2 -2
  191. package/dist/esm/{chunk-36QXVFR5.mjs.map → chunk-TVRJ3M7B.mjs.map} +1 -1
  192. package/dist/esm/chunk-U7AY6CMF.mjs +2 -0
  193. package/dist/esm/chunk-U7AY6CMF.mjs.map +1 -0
  194. package/dist/esm/{chunk-HJYT6LDB.mjs → chunk-UYMZF37A.mjs} +2 -2
  195. package/dist/esm/chunk-VHC2KC7B.mjs +2 -0
  196. package/dist/esm/chunk-VHC2KC7B.mjs.map +1 -0
  197. package/dist/esm/chunk-VHCJCXVZ.mjs +2 -0
  198. package/dist/esm/chunk-VHCJCXVZ.mjs.map +1 -0
  199. package/dist/esm/chunk-VVGV4S24.mjs +2 -0
  200. package/dist/esm/chunk-VVGV4S24.mjs.map +1 -0
  201. package/dist/esm/{chunk-3MFILHZT.mjs → chunk-W2R2FURG.mjs} +2 -2
  202. package/dist/esm/chunk-W2R2FURG.mjs.map +1 -0
  203. package/dist/esm/chunk-W57M6DIK.mjs +2 -0
  204. package/dist/esm/chunk-WRY7462X.mjs +2 -0
  205. package/dist/esm/chunk-WRY7462X.mjs.map +1 -0
  206. package/dist/esm/chunk-X5XBBEVT.mjs +2 -0
  207. package/dist/esm/chunk-X5XBBEVT.mjs.map +1 -0
  208. package/dist/esm/{chunk-XDXI3TRT.mjs → chunk-XBQEFZD7.mjs} +2 -2
  209. package/dist/esm/{chunk-5ZQJLHJA.mjs → chunk-Y5ZK4UII.mjs} +2 -2
  210. package/dist/esm/chunk-Y5ZK4UII.mjs.map +1 -0
  211. package/dist/esm/chunk-YP3RMVL3.mjs +2 -0
  212. package/dist/esm/chunk-YP3RMVL3.mjs.map +1 -0
  213. package/dist/esm/{chunk-35EWRSDK.mjs → chunk-ZNEBMSNC.mjs} +2 -2
  214. package/dist/esm/cli/index.mjs +1 -1
  215. package/dist/esm/client/core.mjs +1 -1
  216. package/dist/esm/client/get.d.mts +2 -1
  217. package/dist/esm/client/get.mjs +1 -1
  218. package/dist/esm/client/index.d.mts +2 -2
  219. package/dist/esm/client/index.mjs +1 -1
  220. package/dist/esm/client/post.d.mts +3 -1
  221. package/dist/esm/client/post.mjs +1 -1
  222. package/dist/esm/client/types.mjs +1 -1
  223. package/dist/esm/core/account/utils/address.mjs +1 -1
  224. package/dist/esm/core/account/utils/index.mjs +1 -1
  225. package/dist/esm/core/accountAddress.mjs +1 -1
  226. package/dist/esm/core/authenticationKey.d.mts +1 -1
  227. package/dist/esm/core/authenticationKey.mjs +1 -1
  228. package/dist/esm/core/common.mjs +1 -1
  229. package/dist/esm/core/crypto/ed25519.d.mts +9 -12
  230. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  231. package/dist/esm/core/crypto/ephemeral.d.mts +76 -0
  232. package/dist/esm/core/crypto/ephemeral.mjs +2 -0
  233. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
  234. package/dist/esm/core/crypto/hdKey.d.mts +15 -1
  235. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  236. package/dist/esm/core/crypto/index.d.mts +8 -6
  237. package/dist/esm/core/crypto/index.mjs +1 -1
  238. package/dist/esm/core/crypto/keyless.d.mts +217 -0
  239. package/dist/esm/core/crypto/keyless.mjs +2 -0
  240. package/dist/esm/core/crypto/keyless.mjs.map +1 -0
  241. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  242. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  243. package/dist/esm/core/crypto/multiKey.d.mts +5 -4
  244. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  245. package/dist/esm/core/crypto/poseidon.d.mts +7 -0
  246. package/dist/esm/core/crypto/poseidon.mjs +2 -0
  247. package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
  248. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  249. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  250. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  251. package/dist/esm/core/crypto/secp256k1.d.mts +8 -1
  252. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  253. package/dist/esm/core/crypto/signature.mjs +1 -1
  254. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  255. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  256. package/dist/esm/core/crypto/utils.mjs +1 -1
  257. package/dist/esm/core/hex.mjs +1 -1
  258. package/dist/esm/core/index.d.mts +7 -8
  259. package/dist/esm/core/index.mjs +1 -1
  260. package/dist/esm/index.d.mts +16 -12
  261. package/dist/esm/index.mjs +1 -1
  262. package/dist/esm/internal/account.d.mts +14 -2
  263. package/dist/esm/internal/account.mjs +1 -1
  264. package/dist/esm/internal/ans.d.mts +4 -4
  265. package/dist/esm/internal/ans.mjs +1 -1
  266. package/dist/esm/internal/coin.d.mts +8 -8
  267. package/dist/esm/internal/coin.mjs +1 -1
  268. package/dist/esm/internal/digitalAsset.d.mts +11 -11
  269. package/dist/esm/internal/digitalAsset.mjs +1 -1
  270. package/dist/esm/internal/event.d.mts +1 -1
  271. package/dist/esm/internal/event.mjs +1 -1
  272. package/dist/esm/internal/faucet.d.mts +1 -1
  273. package/dist/esm/internal/faucet.mjs +1 -1
  274. package/dist/esm/internal/fungibleAsset.d.mts +12 -12
  275. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  276. package/dist/esm/internal/general.mjs +1 -1
  277. package/dist/esm/internal/keyless.d.mts +68 -0
  278. package/dist/esm/internal/keyless.mjs +2 -0
  279. package/dist/esm/internal/keyless.mjs.map +1 -0
  280. package/dist/esm/internal/staking.d.mts +1 -1
  281. package/dist/esm/internal/staking.mjs +1 -1
  282. package/dist/esm/internal/transaction.d.mts +5 -1
  283. package/dist/esm/internal/transaction.mjs +1 -1
  284. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  285. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  286. package/dist/esm/internal/view.d.mts +7 -7
  287. package/dist/esm/internal/view.mjs +1 -1
  288. package/dist/esm/transactions/authenticator/account.d.mts +4 -5
  289. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  290. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  291. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  292. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  293. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  294. package/dist/esm/transactions/index.d.mts +3 -3
  295. package/dist/esm/transactions/index.mjs +1 -1
  296. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  297. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  298. package/dist/esm/transactions/instances/index.d.mts +1 -1
  299. package/dist/esm/transactions/instances/index.mjs +1 -1
  300. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  301. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  302. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  303. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  304. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  305. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  306. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  307. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  308. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  309. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  310. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  311. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +14 -2
  312. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  313. package/dist/esm/transactions/management/index.d.mts +3 -3
  314. package/dist/esm/transactions/management/index.mjs +1 -1
  315. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  316. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  317. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +9 -9
  318. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  319. package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -9
  320. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  321. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +6 -6
  322. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  323. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +47 -0
  324. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +2 -0
  325. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -0
  326. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +7 -29
  327. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  328. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  329. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  330. package/dist/esm/transactions/types.d.mts +7 -7
  331. package/dist/esm/types/index.d.mts +18 -3
  332. package/dist/esm/types/index.mjs +1 -1
  333. package/dist/esm/types/keyless.d.mts +14 -0
  334. package/dist/esm/types/keyless.mjs +1 -0
  335. package/dist/esm/types/keyless.mjs.map +1 -0
  336. package/dist/esm/utils/apiEndpoints.d.mts +3 -1
  337. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  338. package/dist/esm/utils/const.d.mts +5 -3
  339. package/dist/esm/utils/const.mjs +1 -1
  340. package/dist/esm/utils/index.d.mts +1 -1
  341. package/dist/esm/utils/index.mjs +1 -1
  342. package/dist/esm/version.d.mts +1 -1
  343. package/dist/esm/version.mjs +1 -1
  344. package/package.json +13 -7
  345. package/src/{core/account → account}/Account.ts +12 -16
  346. package/src/{core/account → account}/Ed25519Account.ts +13 -7
  347. package/src/account/EphemeralKeyPair.ts +78 -0
  348. package/src/account/KeylessAccount.ts +230 -0
  349. package/src/account/MultiKeyAccount.ts +121 -0
  350. package/src/{core/account → account}/SingleKeyAccount.ts +13 -7
  351. package/src/account/index.ts +6 -0
  352. package/src/api/account.ts +50 -8
  353. package/src/api/ans.ts +10 -17
  354. package/src/api/aptos.ts +10 -0
  355. package/src/api/aptosConfig.ts +50 -1
  356. package/src/api/coin.ts +7 -0
  357. package/src/api/digitalAsset.ts +142 -2
  358. package/src/api/event.ts +13 -8
  359. package/src/api/faucet.ts +3 -0
  360. package/src/api/fungibleAsset.ts +28 -4
  361. package/src/api/general.ts +48 -25
  362. package/src/api/keyless.ts +55 -0
  363. package/src/api/staking.ts +9 -0
  364. package/src/api/transaction.ts +59 -15
  365. package/src/api/transactionSubmission/management.ts +1 -1
  366. package/src/api/transactionSubmission/sign.ts +1 -1
  367. package/src/bcs/serializer.ts +18 -0
  368. package/src/client/core.ts +10 -1
  369. package/src/client/get.ts +6 -0
  370. package/src/client/post.ts +13 -0
  371. package/src/core/crypto/ed25519.ts +50 -34
  372. package/src/core/crypto/ephemeral.ts +147 -0
  373. package/src/core/crypto/hdKey.ts +31 -0
  374. package/src/core/crypto/index.ts +2 -0
  375. package/src/core/crypto/keyless.ts +502 -0
  376. package/src/core/crypto/multiKey.ts +23 -11
  377. package/src/core/crypto/poseidon.ts +134 -0
  378. package/src/core/crypto/secp256k1.ts +9 -3
  379. package/src/core/crypto/singleKey.ts +11 -0
  380. package/src/core/index.ts +0 -1
  381. package/src/index.ts +1 -1
  382. package/src/internal/account.ts +7 -10
  383. package/src/internal/ans.ts +2 -1
  384. package/src/internal/digitalAsset.ts +3 -2
  385. package/src/internal/fungibleAsset.ts +4 -3
  386. package/src/internal/keyless.ts +205 -0
  387. package/src/internal/transaction.ts +48 -10
  388. package/src/internal/transactionSubmission.ts +8 -7
  389. package/src/transactions/authenticator/account.ts +6 -11
  390. package/src/transactions/management/accountSequenceNumber.ts +1 -1
  391. package/src/transactions/management/transactionWorker.ts +8 -2
  392. package/src/transactions/transactionBuilder/index.ts +2 -0
  393. package/src/transactions/transactionBuilder/signingMessage.ts +75 -0
  394. package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -80
  395. package/src/types/index.ts +21 -0
  396. package/src/types/keyless.ts +6 -0
  397. package/src/utils/apiEndpoints.ts +14 -0
  398. package/src/utils/const.ts +4 -2
  399. package/src/version.ts +1 -1
  400. package/dist/esm/chunk-3MFILHZT.mjs.map +0 -1
  401. package/dist/esm/chunk-3PMUIXFS.mjs +0 -2
  402. package/dist/esm/chunk-3PMUIXFS.mjs.map +0 -1
  403. package/dist/esm/chunk-3RQ5V3F3.mjs +0 -2
  404. package/dist/esm/chunk-4AVC2RCH.mjs +0 -2
  405. package/dist/esm/chunk-4AVC2RCH.mjs.map +0 -1
  406. package/dist/esm/chunk-4NHWV5AI.mjs +0 -2
  407. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  408. package/dist/esm/chunk-527DYQ3X.mjs +0 -2
  409. package/dist/esm/chunk-527DYQ3X.mjs.map +0 -1
  410. package/dist/esm/chunk-5ZQJLHJA.mjs.map +0 -1
  411. package/dist/esm/chunk-A7XZTJ3D.mjs.map +0 -1
  412. package/dist/esm/chunk-AIPKOP3K.mjs.map +0 -1
  413. package/dist/esm/chunk-ARGODLTZ.mjs +0 -2
  414. package/dist/esm/chunk-ARGODLTZ.mjs.map +0 -1
  415. package/dist/esm/chunk-ASXXZH2D.mjs +0 -2
  416. package/dist/esm/chunk-ASXXZH2D.mjs.map +0 -1
  417. package/dist/esm/chunk-B4DWWHNL.mjs +0 -2
  418. package/dist/esm/chunk-B7X6PSE7.mjs +0 -2
  419. package/dist/esm/chunk-BAYKVJBZ.mjs +0 -2
  420. package/dist/esm/chunk-C67BKZND.mjs +0 -2
  421. package/dist/esm/chunk-C67BKZND.mjs.map +0 -1
  422. package/dist/esm/chunk-CAGDOGXS.mjs +0 -2
  423. package/dist/esm/chunk-CEHCDA3G.mjs +0 -2
  424. package/dist/esm/chunk-CQS6ZCJ7.mjs +0 -2
  425. package/dist/esm/chunk-CQS6ZCJ7.mjs.map +0 -1
  426. package/dist/esm/chunk-CXR7MOBW.mjs +0 -2
  427. package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
  428. package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
  429. package/dist/esm/chunk-DGLW7OBS.mjs +0 -2
  430. package/dist/esm/chunk-DGLW7OBS.mjs.map +0 -1
  431. package/dist/esm/chunk-DUP7XY5P.mjs +0 -2
  432. package/dist/esm/chunk-DUP7XY5P.mjs.map +0 -1
  433. package/dist/esm/chunk-E7FWVXGX.mjs +0 -1
  434. package/dist/esm/chunk-EJBUUMWV.mjs +0 -2
  435. package/dist/esm/chunk-EV75CYGN.mjs +0 -2
  436. package/dist/esm/chunk-EV75CYGN.mjs.map +0 -1
  437. package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
  438. package/dist/esm/chunk-FPD4JBPV.mjs +0 -2
  439. package/dist/esm/chunk-FPD4JBPV.mjs.map +0 -1
  440. package/dist/esm/chunk-FVMJDRHO.mjs.map +0 -1
  441. package/dist/esm/chunk-FXHXOVL4.mjs +0 -2
  442. package/dist/esm/chunk-FXHXOVL4.mjs.map +0 -1
  443. package/dist/esm/chunk-GJDGR3KQ.mjs +0 -2
  444. package/dist/esm/chunk-GJDGR3KQ.mjs.map +0 -1
  445. package/dist/esm/chunk-IZF6DFAL.mjs +0 -2
  446. package/dist/esm/chunk-JOLLCFQL.mjs +0 -2
  447. package/dist/esm/chunk-JOLLCFQL.mjs.map +0 -1
  448. package/dist/esm/chunk-LG7RJQ57.mjs +0 -2
  449. package/dist/esm/chunk-LR65XHSF.mjs +0 -2
  450. package/dist/esm/chunk-LR65XHSF.mjs.map +0 -1
  451. package/dist/esm/chunk-M4SQNMCW.mjs.map +0 -1
  452. package/dist/esm/chunk-MLWIHWNH.mjs +0 -1
  453. package/dist/esm/chunk-N3U47Y6Y.mjs +0 -2
  454. package/dist/esm/chunk-NF5OUPPU.mjs.map +0 -1
  455. package/dist/esm/chunk-NJRNZEHX.mjs +0 -2
  456. package/dist/esm/chunk-NJRNZEHX.mjs.map +0 -1
  457. package/dist/esm/chunk-PF57EOJY.mjs +0 -2
  458. package/dist/esm/chunk-QJAI7DNA.mjs +0 -2
  459. package/dist/esm/chunk-QJAI7DNA.mjs.map +0 -1
  460. package/dist/esm/chunk-QRVYLV76.mjs +0 -2
  461. package/dist/esm/chunk-R7G3CLRI.mjs +0 -1
  462. package/dist/esm/chunk-RIUFW2OG.mjs +0 -2
  463. package/dist/esm/chunk-RIUFW2OG.mjs.map +0 -1
  464. package/dist/esm/chunk-SRDIYE3M.mjs +0 -2
  465. package/dist/esm/chunk-SUTBXHYU.mjs.map +0 -1
  466. package/dist/esm/chunk-SWZOGZJ6.mjs +0 -2
  467. package/dist/esm/chunk-SWZOGZJ6.mjs.map +0 -1
  468. package/dist/esm/chunk-SZKJ3TC5.mjs +0 -1
  469. package/dist/esm/chunk-T4C6BVXK.mjs.map +0 -1
  470. package/dist/esm/chunk-UEKKYJGA.mjs.map +0 -1
  471. package/dist/esm/chunk-UGPALAPN.mjs +0 -2
  472. package/dist/esm/chunk-UQCSBLD5.mjs +0 -2
  473. package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
  474. package/dist/esm/chunk-VBDMQERT.mjs +0 -2
  475. package/dist/esm/chunk-VHANL47W.mjs +0 -2
  476. package/dist/esm/chunk-VHANL47W.mjs.map +0 -1
  477. package/dist/esm/chunk-VLNBGWGX.mjs.map +0 -1
  478. package/dist/esm/chunk-VNIABDOT.mjs.map +0 -1
  479. package/dist/esm/chunk-XX5J7KKC.mjs +0 -2
  480. package/dist/esm/chunk-XX5J7KKC.mjs.map +0 -1
  481. package/dist/esm/chunk-YG6YYQRG.mjs.map +0 -1
  482. package/dist/esm/chunk-YIGDWPGM.mjs +0 -2
  483. package/dist/esm/chunk-YIGDWPGM.mjs.map +0 -1
  484. package/dist/esm/core/account/Account.d.mts +0 -20
  485. package/dist/esm/core/account/Account.mjs +0 -2
  486. package/dist/esm/core/account/Ed25519Account.d.mts +0 -20
  487. package/dist/esm/core/account/Ed25519Account.mjs +0 -2
  488. package/dist/esm/core/account/SingleKeyAccount.d.mts +0 -20
  489. package/dist/esm/core/account/SingleKeyAccount.mjs +0 -2
  490. package/dist/esm/core/account/index.d.mts +0 -21
  491. package/dist/esm/core/account/index.mjs +0 -2
  492. package/src/core/account/index.ts +0 -4
  493. /package/dist/esm/{core/account → account}/Account.mjs.map +0 -0
  494. /package/dist/esm/{core/account → account}/Ed25519Account.mjs.map +0 -0
  495. /package/dist/esm/{chunk-4QMXOWHP.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
  496. /package/dist/esm/{chunk-E7FWVXGX.mjs.map → account/KeylessAccount.mjs.map} +0 -0
  497. /package/dist/esm/{chunk-MLWIHWNH.mjs.map → account/MultiKeyAccount.mjs.map} +0 -0
  498. /package/dist/esm/{core/account → account}/SingleKeyAccount.mjs.map +0 -0
  499. /package/dist/esm/{core/account → account}/index.mjs.map +0 -0
  500. /package/dist/esm/{chunk-R7G3CLRI.mjs.map → api/keyless.mjs.map} +0 -0
  501. /package/dist/esm/{chunk-O3YFCZJ5.mjs.map → chunk-2I2XAOH7.mjs.map} +0 -0
  502. /package/dist/esm/{chunk-CP4QCRBZ.mjs.map → chunk-2XIT7I5L.mjs.map} +0 -0
  503. /package/dist/esm/{chunk-CEHCDA3G.mjs.map → chunk-3FVRXELT.mjs.map} +0 -0
  504. /package/dist/esm/{chunk-U3YYSIIT.mjs.map → chunk-3VGX3TXH.mjs.map} +0 -0
  505. /package/dist/esm/{chunk-FC5MU6ZN.mjs.map → chunk-45D3YXLT.mjs.map} +0 -0
  506. /package/dist/esm/{chunk-KQB7A4OX.mjs.map → chunk-5IM5TQN4.mjs.map} +0 -0
  507. /package/dist/esm/{chunk-5NWTYUKC.mjs.map → chunk-67QYMEZE.mjs.map} +0 -0
  508. /package/dist/esm/{chunk-GHYE26Q5.mjs.map → chunk-6FBKUTGF.mjs.map} +0 -0
  509. /package/dist/esm/{chunk-UQCSBLD5.mjs.map → chunk-6Q2GNDKL.mjs.map} +0 -0
  510. /package/dist/esm/{chunk-5EN52MUT.mjs.map → chunk-7STYQ5ZE.mjs.map} +0 -0
  511. /package/dist/esm/{chunk-SZKJ3TC5.mjs.map → chunk-7Z6DYLCA.mjs.map} +0 -0
  512. /package/dist/esm/{chunk-EJBUUMWV.mjs.map → chunk-AFPBV2BQ.mjs.map} +0 -0
  513. /package/dist/esm/{chunk-BCUSI3N6.mjs.map → chunk-AOCNYMMX.mjs.map} +0 -0
  514. /package/dist/esm/{chunk-UVSRX4SV.mjs.map → chunk-AQ4I7VVB.mjs.map} +0 -0
  515. /package/dist/esm/{chunk-N3U47Y6Y.mjs.map → chunk-C3L4ETUF.mjs.map} +0 -0
  516. /package/dist/esm/{chunk-4NHWV5AI.mjs.map → chunk-COW5IGYC.mjs.map} +0 -0
  517. /package/dist/esm/{chunk-FNLRLSGJ.mjs.map → chunk-CYWA4AJF.mjs.map} +0 -0
  518. /package/dist/esm/{chunk-6O5ZR5ME.mjs.map → chunk-E3YEX3FR.mjs.map} +0 -0
  519. /package/dist/esm/{chunk-G56GPLTB.mjs.map → chunk-EB7AI4B4.mjs.map} +0 -0
  520. /package/dist/esm/{chunk-LG7RJQ57.mjs.map → chunk-FBPNHF54.mjs.map} +0 -0
  521. /package/dist/esm/{chunk-KAGLWBIJ.mjs.map → chunk-HGZGTBA4.mjs.map} +0 -0
  522. /package/dist/esm/{chunk-25UTAIJG.mjs.map → chunk-INYYKAXD.mjs.map} +0 -0
  523. /package/dist/esm/{chunk-KXFMI7RM.mjs.map → chunk-JNAI5UFZ.mjs.map} +0 -0
  524. /package/dist/esm/{chunk-5ID6W7XL.mjs.map → chunk-LFTWUMLK.mjs.map} +0 -0
  525. /package/dist/esm/{chunk-B7X6PSE7.mjs.map → chunk-MGOHPDX4.mjs.map} +0 -0
  526. /package/dist/esm/{chunk-BAYKVJBZ.mjs.map → chunk-MLPJOS5C.mjs.map} +0 -0
  527. /package/dist/esm/{chunk-PF57EOJY.mjs.map → chunk-MWUJCP27.mjs.map} +0 -0
  528. /package/dist/esm/{chunk-VBDMQERT.mjs.map → chunk-NUDRQTYI.mjs.map} +0 -0
  529. /package/dist/esm/{chunk-B4DWWHNL.mjs.map → chunk-NUR3TCTI.mjs.map} +0 -0
  530. /package/dist/esm/{chunk-MJPUASSD.mjs.map → chunk-PFFAQZHT.mjs.map} +0 -0
  531. /package/dist/esm/{chunk-IZF6DFAL.mjs.map → chunk-QREYDZ5R.mjs.map} +0 -0
  532. /package/dist/esm/{chunk-UGPALAPN.mjs.map → chunk-STYDBDYL.mjs.map} +0 -0
  533. /package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-TJDC5PWD.mjs.map} +0 -0
  534. /package/dist/esm/{chunk-HJYT6LDB.mjs.map → chunk-UYMZF37A.mjs.map} +0 -0
  535. /package/dist/esm/{chunk-3RQ5V3F3.mjs.map → chunk-W57M6DIK.mjs.map} +0 -0
  536. /package/dist/esm/{chunk-XDXI3TRT.mjs.map → chunk-XBQEFZD7.mjs.map} +0 -0
  537. /package/dist/esm/{chunk-35EWRSDK.mjs.map → chunk-ZNEBMSNC.mjs.map} +0 -0
  538. /package/dist/esm/{publicKey-B3XRNhHO.d.mts → publicKey-lq5djCIY.d.mts} +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; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var ts=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var M=(n,e,t,r)=>{for(var o=r>1?void 0:r?ns(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ts(e,t,o),o};var ce=class extends Error{constructor(e,t,r){super(r),this.name="AptosApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data,this.request=e}};var _r="1.12.1";var Lt=(o=>(o.JSON="application/json",o.BCS="application/x-bcs",o.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",o.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",o))(Lt||{}),Sr= exports.TypeTagVariants =(g=>(g[g.Bool=0]="Bool",g[g.U8=1]="U8",g[g.U64=2]="U64",g[g.U128=3]="U128",g[g.Address=4]="Address",g[g.Signer=5]="Signer",g[g.Vector=6]="Vector",g[g.Struct=7]="Struct",g[g.U16=8]="U16",g[g.U32=9]="U32",g[g.U256=10]="U256",g[g.Reference=254]="Reference",g[g.Generic=255]="Generic",g))(Sr||{}),bt= 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))(bt||{}),xr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(xr||{}),vr= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(vr||{}),Cr= exports.TransactionAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(Cr||{}),Pr= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Pr||{}),Er= exports.AnyPublicKeyVariant =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1=1]="Secp256k1",t))(Er||{}),Ir= exports.AnySignatureVariant =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1=1]="Secp256k1",t))(Ir||{}),Dn= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(Dn||{});function Ta(n){return n.type==="pending_transaction"}function ba(n){return n.type==="user_transaction"}function wa(n){return n.type==="genesis_transaction"}function _a(n){return n.type==="block_metadata_transaction"}function Sa(n){return n.type==="state_checkpoint_transaction"}function xa(n){return n.type==="validator_transaction"}function va(n){return"signature"in n&&n.signature==="ed25519_signature"}function Ca(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function Pa(n){return n.type==="multi_agent_signature"}function Ea(n){return n.type==="fee_payer_signature"}function Ia(n){return n.type==="multi_ed25519_signature"}var rs=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(rs||{}),Ur= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Ur||{}),os= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(os||{}),Ce= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ce||{}),Gn= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Gn||{}),Rr= exports.DeriveScheme =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(Rr||{});var Nr={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},zr= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},kr= 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"},On= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(On||{}),Bn= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70},Na= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var wt=(r=>(r.FULLNODE="Fullnode",r.INDEXER="Indexer",r.FAUCET="Faucet",r))(wt||{}),Dr= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Gr= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Ht= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Qt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Or= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Fn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",He= 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))(He||{});var Br={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 is(n,e){let{url:t,method:r,body:o,contentType:i,params:s,overrides:a}=n,c={..._optionalChain([a, 'optionalAccess', _2 => _2.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${_r}`,"content-type":_nullishCoalesce(i, () => ("application/json"))};return _optionalChain([a, 'optionalAccess', _3 => _3.AUTH_TOKEN])&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _4 => _4.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _5 => _5.API_KEY])&&(c.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _6 => _6.API_KEY])}`),e.provider({url:t,method:r,body:o,params:s,headers:c,overrides:a})}async function Wt(n,e,t){let{url:r,path:o}=n,i=o?`${r}/${o}`:r,s=await is({...n,url:i},e.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:i};if(a.status===401)throw new ce(n,a,`Error: ${a.data}`);if(t==="Indexer"){let p=a.data;if(p.errors)throw new ce(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Br?c=Br[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ce(n,a,`${t} error: ${c}`)}async function Fr(n){let{aptosConfig:e,overrides:t,params:r,contentType:o,acceptType:i,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return Wt({url:p,method:"GET",originMethod:a,path:s,contentType:o,acceptType:i,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function X(n){let{aptosConfig:e}=n;return Fr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _7 => _7.clientConfig, 'optionalAccess', _8 => _8.HEADERS]),..._optionalChain([e, 'access', _9 => _9.fullnodeConfig, 'optionalAccess', _10 => _10.HEADERS])}}})}async function Qe(n){let e=[],t,r=n.params;do{let o=await Fr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.start=t}while(t!=null);return e}async function Mn(n){let{type:e,originMethod:t,path:r,body:o,acceptType:i,contentType:s,params:a,aptosConfig:c,overrides:p}=n,f=c.getRequestUrl(e);return Wt({url:f,method:"POST",originMethod:t,path:r,body:o,contentType:s,acceptType:i,params:a,overrides:p},c,n.type)}async function De(n){let{aptosConfig:e}=n;return Mn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _11 => _11.clientConfig, 'optionalAccess', _12 => _12.HEADERS]),..._optionalChain([e, 'access', _13 => _13.fullnodeConfig, 'optionalAccess', _14 => _14.HEADERS])}}})}async function Mr(n){let{aptosConfig:e}=n;return Mn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _15 => _15.clientConfig, 'optionalAccess', _16 => _16.HEADERS]),..._optionalChain([e, 'access', _17 => _17.indexerConfig, 'optionalAccess', _18 => _18.HEADERS])}}})}async function Kr(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _19 => _19.clientConfig, 'optionalAccess', _20 => delete _20.API_KEY]),Mn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([t, 'access', _23 => _23.faucetConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}var _utils = require('@noble/hashes/utils');var jt=255,Xt=65535,fe=4294967295,Ge=18446744073709551615n,_t=340282366920938463463374607431768211455n,Yt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var K=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var cs=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(cs||{}),h= exports.Hex =class n{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new K("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new K("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, t))}catch(r){throw new K(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _25 => _25.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new n(e):n.fromHexString(e)}static isValid(e){try{return n.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _26 => _26.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _27 => _27.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};var d=class{bcsToBytes(){let e=new Y;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return h.fromHexInput(e)}},Y= exports.Serializer =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,r){this.ensureBufferWillHandleSize(t);let o=new DataView(this.buffer,this.offset);e.apply(o,[0,r,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){Kn(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(fe),r=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(r))}serializeU128(e){let t=BigInt(e)&Ge,r=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(r)}serializeU256(e){let t=BigInt(e)&_t,r=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(r)}serializeU32AsUleb128(e){let t=e,r=[];for(;t>>>7;)r.push(t&127|128),t>>>=7;r.push(t),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}};M([Oe(0,jt)],Y.prototype,"serializeU8",1),M([Oe(0,Xt)],Y.prototype,"serializeU16",1),M([Oe(0,fe)],Y.prototype,"serializeU32",1),M([Oe(BigInt(0),Ge)],Y.prototype,"serializeU64",1),M([Oe(BigInt(0),_t)],Y.prototype,"serializeU128",1),M([Oe(BigInt(0),Yt)],Y.prototype,"serializeU256",1),M([Oe(0,fe)],Y.prototype,"serializeU32AsUleb128",1);function Kn(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var us=(n,e,t)=>`${n} is out of range: [${e}, ${t}]`;function Pe(n,e,t){let r=BigInt(n);if(r>BigInt(t)||r<BigInt(e))throw new Error(us(n,e,t))}function Oe(n,e){return(t,r,o)=>{let i=o.value;return o.value=function(a){return Pe(a,n,e),i.apply(this,[a])},o}}var ds=(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))(ds||{}),_=class _ extends d{constructor(e){if(super(),e.length!==_.LENGTH)throw new K("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(_.LENGTH);return new _(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new K("Hex string must start with a leading 0x.","leading_zero_x_required");let t=_.fromString(e);if(e.length!==_.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new K(`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 K(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e){let t=e;if(e.startsWith("0x")&&(t=e.slice(2)),t.length===0)throw new K("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(t.length>64)throw new K("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let r;try{r=_utils.hexToBytes.call(void 0, t.padStart(64,"0"))}catch(o){throw new K(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _28 => _28.message])}`,"invalid_hex_chars")}return new _(r)}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(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _29 => _29.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _30 => _30.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};_.LENGTH=32,_.LONG_STRING_LENGTH=64,_.ZERO=_.from("0x0"),_.ONE=_.from("0x1"),_.TWO=_.from("0x2"),_.THREE=_.from("0x3"),_.FOUR=_.from("0x4");var u=_;var $r=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<fe;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>fe)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<t;o+=1)r.push(this.deserialize(e));return r}};var Be=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,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Zt=class n extends d{constructor(e){super(),this.value=new Be(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Be.deserialize(e,t);return new n(r.value)}};var I=class n extends d{constructor(e){super(),Kn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},D= exports.U8 =class n extends d{constructor(e){super(),Pe(e,0,jt),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},re= exports.U16 =class n extends d{constructor(e){super(),Pe(e,0,Xt),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},oe= exports.U32 =class n extends d{constructor(e){super(),Pe(e,0,fe),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},k= exports.U64 =class n extends d{constructor(e){super(),Pe(e,BigInt(0),Ge),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ie= exports.U128 =class n extends d{constructor(e){super(),Pe(e,BigInt(0),_t),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},se= exports.U256 =class n extends d{constructor(e){super(),Pe(e,BigInt(0),Yt),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(!(this.values[0]instanceof D)&&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 t;if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=h.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type");return new n(t.map(r=>new D(r)))}static U16(e){return new n(e.map(t=>new re(t)))}static U32(e){return new n(e.map(t=>new oe(t)))}static U64(e){return new n(e.map(t=>new k(t)))}static U128(e){return new n(e.map(t=>new ie(t)))}static U256(e){return new n(e.map(t=>new se(t)))}static Bool(e){return new n(e.map(t=>new I(t)))}static MoveString(e){return new n(e.map(t=>new w(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),o=new Array;for(let i=0;i<r;i+=1)o.push(t.deserialize(e));return new n(o)}},w= exports.MoveString =class n extends d{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes().slice(1);T.U8(t).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Ee= 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 t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new D(e):void 0)}static U16(e){return new n(e!=null?new re(e):void 0)}static U32(e){return new n(e!=null?new oe(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 ie(e):void 0)}static U256(e){return new n(e!=null?new se(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,t){let r=T.deserialize(e,t);return new n(r.values[0])}};var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var _sha3 = require('@noble/hashes/sha3');var Ie=class Ie extends d{constructor(e){super();let{data:t}=e,r=h.fromHexInput(t);if(r.toUint8Array().length!==Ie.LENGTH)throw new Error(`Authentication Key length should be ${Ie.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(Ie.LENGTH);return new Ie({data:t})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,o=h.fromHexInput(r).toUint8Array(),i=new Uint8Array([...o,t]),s=_sha3.sha3_256.create();s.update(i);let a=s.digest();return new Ie({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};Ie.LENGTH=32;var q=Ie;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Vr = _interopRequireWildcard(_bip39);var ys=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,As= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,fs= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(fs||{}),Lr= exports.HARDENED_OFFSET =2147483648;function Hr(n){return As.test(n)}function Qr(n){return ys.test(n)}var qn=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Wr= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let o=new Uint8Array(r),i=new Uint8Array([0]),s=new Uint8Array([...i,...n,...o]);return qn(e,s)},hs=n=>n.replace("'",""),jr= exports.splitPath =n=>n.split("/").slice(1).map(hs),Jt= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return Vr.mnemonicToSeedSync(e)};var St=class extends d{toString(){let e=this.toUint8Array();return h.fromHexInput(e).toString()}},ue= exports.AccountPublicKey =class extends St{};var Z=class extends d{toString(){let e=this.toUint8Array();return h.fromHexInput(e).toString()}};var We=n=>typeof n=="string"?h.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var Fe=class Fe extends ue{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==Fe.LENGTH)throw new Error(`PublicKey length should be ${Fe.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof R))return!1;let o=We(t),i=h.fromHexInput(o).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _tweetnacl2.default.sign.detached.verify(i,s,a)}authKey(){return q.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Fe(t)}static isPublicKey(e){return e instanceof Fe}};Fe.LENGTH=32;var U=Fe,O=class O extends d{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==O.LENGTH)throw new Error(`PrivateKey length should be ${O.LENGTH}`);this.signingKeyPair=_tweetnacl2.default.sign.keyPair.fromSeed(t.toUint8Array().slice(0,O.LENGTH))}static generate(){let e=_tweetnacl2.default.sign.keyPair();return new O(e.secretKey.slice(0,O.LENGTH))}static fromDerivationPath(e,t){if(!Qr(e))throw new Error(`Invalid derivation path ${e}`);return O.fromDerivationPathInner(e,Jt(t))}static fromDerivationPathInner(e,t,r=Lr){let{key:o,chainCode:i}=qn(O.SLIP_0010_SEED,t),s=jr(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Wr(c,p+r),{key:o,chainCode:i});return new O(a)}publicKey(){let e=this.signingKeyPair.publicKey;return new U(e)}sign(e){let t=We(e),r=h.fromHexInput(t).toUint8Array(),o=_tweetnacl2.default.sign.detached(r,this.signingKeyPair.secretKey);return new R(o)}toUint8Array(){return this.signingKeyPair.secretKey.slice(0,O.LENGTH)}toString(){return h.fromHexInput(this.toUint8Array()).toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new O(t)}static isPrivateKey(e){return e instanceof O}};O.LENGTH=32,O.SLIP_0010_SEED="ed25519 seed";var J=O,je=class je extends Z{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==je.LENGTH)throw new Error(`Signature length should be ${je.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new je(t)}};je.LENGTH=64;var R=je;var ee=class ee extends ue{constructor(e){super();let{publicKeys:t,threshold:r}=e;if(t.length>ee.MAX_KEYS||t.length<ee.MIN_KEYS)throw new Error(`Must have between ${ee.MIN_KEYS} and ${ee.MAX_KEYS} public keys, inclusive`);if(r<ee.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${ee.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Me))return!1;let o=[];for(let i=0;i<4;i+=1)for(let s=0;s<8;s+=1)if((r.bitmap[i]&1<<7-s)!==0){let c=i*8+s;o.push(c)}if(o.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<o.length;i+=1)if(!this.publicKeys[o[i]].verifySignature({message:t,signature:r.signatures[i]}))return!1;return!0}authKey(){return q.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*U.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*U.LENGTH)}),e[this.publicKeys.length*U.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],o=[];for(let i=0;i<t.length-1;i+=U.LENGTH){let s=i;o.push(new U(t.subarray(s,s+U.LENGTH)))}return new ee({publicKeys:o,threshold:r})}};ee.MAX_KEYS=32,ee.MIN_KEYS=2,ee.MIN_THRESHOLD=1;var Xe=ee,L=class L extends Z{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>L.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${L.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=L.createBitmap({bits:r});else{if(r.length!==L.BITMAP_LEN)throw new Error(`"bitmap" length should be ${L.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*R.LENGTH+L.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*R.LENGTH)}),e.set(this.bitmap,this.signatures.length*R.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),o=[];for(let i=0;i<t.length-r.length;i+=R.LENGTH){let s=i;o.push(new R(t.subarray(s,s+R.LENGTH)))}return new L({signatures:o,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(s>=L.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${L.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}};L.MAX_SIGNATURES_SUPPORTED=32,L.BITMAP_LEN=4;var Me=L;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ke=class Ke extends St{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==Ke.LENGTH)throw new Error(`PublicKey length should be ${Ke.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Te))return!1;let o=We(t),i=h.fromHexInput(o).toUint8Array(),s=_sha3.sha3_256.call(void 0, i),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array())}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ke(t)}static isPublicKey(e){return e instanceof Ke}};Ke.LENGTH=65;var he=Ke,pe=class pe extends d{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==pe.LENGTH)throw new Error(`PrivateKey length should be ${pe.LENGTH}`);this.key=t}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new pe(e)}static fromDerivationPath(e,t){if(!Hr(e))throw new Error(`Invalid derivation path ${e}`);return pe.fromDerivationPathInner(e,Jt(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new pe(r)}sign(e){let t=We(e),r=h.fromHexInput(t),o=_sha3.sha3_256.call(void 0, r.toUint8Array()),i=_secp256k1.secp256k1.sign(o,this.key.toUint8Array());return new Te(i.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new he(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new pe(t)}static isPrivateKey(e){return e instanceof pe}};pe.LENGTH=32;var qe=pe,Ye=class Ye extends Z{constructor(e){super();let t=h.fromHexInput(e);if(t.toUint8Array().length!==Ye.LENGTH)throw new Error(`Signature length should be ${Ye.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ye(t)}};Ye.LENGTH=64;var Te=Ye;var $=class n extends ue{constructor(e){if(super(),this.publicKey=e,e instanceof U)this.variant=0;else if(e instanceof he)this.variant=1;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return r instanceof B?this.publicKey.verifySignature({message:t,signature:r.signature}):!1}authKey(){return q.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=U.deserialize(e);break;case 1:r=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof U}isSecp256k1PublicKey(){return this.publicKey instanceof he}},B= exports.AnySignature =class n extends Z{constructor(e){if(super(),this.signature=e,e instanceof R)this.variant=0;else if(e instanceof Te)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 t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=R.deserialize(e);break;case 1:r=Te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}};function Yr(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var nn=class n extends ue{constructor(e){super();let{publicKeys:t,signaturesRequired:r}=e;if(r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(o=>o instanceof $?o:new $(o)),this.signaturesRequired=r}verifySignature(e){throw new Error("not implemented")}authKey(){return q.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector($),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(s))throw new Error(`Duplicate bit ${s} detected.`);i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}},H=class H extends Z{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>H.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${H.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(i=>i instanceof B?i:new B(i)),!(r instanceof Uint8Array))this.bitmap=H.createBitmap({bits:r});else{if(r.length!==H.BITMAP_LEN)throw new Error(`"bitmap" length should be ${H.BITMAP_LEN}`);this.bitmap=r}let o=this.bitmap.reduce((i,s)=>i+Yr(s),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach(s=>{if(s>=H.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${H.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");i.add(s);let a=Math.floor(s/8),c=o[a];c|=r>>s%8,o[a]=c}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeBytes(),r=t.reduce((i,s)=>i+Yr(s),0),o=[];for(let i=0;i<r;i+=1){let s=B.deserialize(e);o.push(s)}return new H({signatures:o,bitmap:t})}};H.BITMAP_LEN=4,H.MAX_SIGNATURES_SUPPORTED=H.BITMAP_LEN*8;var Zr=H;var Q=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return de.load(e);case 1:return rn.load(e);case 2:return ae.load(e);case 3:return Ze.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof de}isMultiEd25519(){return this instanceof rn}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof Ze}},de= exports.AccountAuthenticatorEd25519 =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=U.deserialize(e),r=R.deserialize(e);return new n(t,r)}},rn= exports.AccountAuthenticatorMultiEd25519 =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Xe.deserialize(e),r=Me.deserialize(e);return new n(t,r)}},ae= exports.AccountAuthenticatorSingleKey =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=$.deserialize(e),r=B.deserialize(e);return new n(t,r)}},Ze= exports.AccountAuthenticatorMultiKey =class n extends Q{constructor(e,t,r){super(),this.public_keys=e,this.signatures=t,this.signatures_bitmap=r}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let t=nn.deserialize(e),r=e.deserializeVector(B),o=e.deserializeBytes();return new n(t,r,o)}};var Je=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=J.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,o=J.fromDerivationPath(t,r);return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){let t=this.privateKey.sign(e);return new de(this.publicKey,t)}sign(e){return this.signWithAuthenticator(e).signature}};var et=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new $(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=J.generate();break;case 2:r=qe.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:o}=e,i;switch(t){case 0:i=J.fromDerivationPath(r,o);break;case 2:i=qe.fromDerivationPath(r,o);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){let t=this.privateKey.sign(e),r=new B(t);return new ae(this.publicKey,r)}sign(e){return this.signWithAuthenticator(e).signature}};var Ue=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Je.generate():et.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:o=!0}=e;return t instanceof J&&o?new Je({privateKey:t,address:r}):new et({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:o,legacy:i=!0}=e;return t===0&&i?Je.fromDerivationPath({mnemonic:r,path:o}):et.fromDerivationPath({scheme:t,mnemonic:r,path:o})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var bs=(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,o=new Uint8Array([...t,...r,254]);return new u(_sha3.sha3_256.call(void 0, o))},ld= exports.createResourceAddress =(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,o=new Uint8Array([...t,...r,255]);return new u(_sha3.sha3_256.call(void 0, o))},gd= exports.createTokenAddress =(n,e,t)=>{let r=`${e}::${t}`;return bs(n,r)};var ws=`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkKSEUZTKYjs = require('./chunk-KSEUZTKY.js');var fn=255,hn=65535,Se=4294967295,$e=18446744073709551615n,Nt=340282366920938463463374607431768211455n,Tn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var bn=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<Se;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Se)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 i=0;i<e;i+=1)r.push(this.deserialize(t));return r}};var _utils = require('@noble/hashes/utils');var V=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Bs=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Bs||{}),l= 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 fromHexString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new V("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 V("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 V(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _4 => _4.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 k;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return l.fromHexInput(t)}},k= 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 i=new DataView(this.buffer,this.offset);t.apply(i,[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){cr(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(Se),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&$e,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&Nt,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)})}serializeOption(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),t.serialize(this))}serializeOptionStr(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(t))}};_chunkKSEUZTKYjs.a.call(void 0, [Ve(0,fn)],k.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(0,hn)],k.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(0,Se)],k.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(BigInt(0),$e)],k.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(BigInt(0),Nt)],k.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(BigInt(0),Tn)],k.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Ve(0,Se)],k.prototype,"serializeU32AsUleb128",1);function cr(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var Ks=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function ze(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(Ks(n,t,e))}function Ve(n,t){return(e,r,i)=>{let o=i.value;return i.value=function(a){return ze(a,n,t),o.apply(this,[a])},i}}var He=class n extends d{constructor(e){super();this.value=l.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let i=e.deserializeFixedBytes(r);return new n(i)}};var wn=class n extends d{constructor(e){super();this.value=new He(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let i=He.deserialize(e,r);return new n(i.value)}};var Sn=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(Sn||{}),Jr= exports.TypeTagVariants =(g=>(g[g.Bool=0]="Bool",g[g.U8=1]="U8",g[g.U64=2]="U64",g[g.U128=3]="U128",g[g.Address=4]="Address",g[g.Signer=5]="Signer",g[g.Vector=6]="Vector",g[g.Struct=7]="Struct",g[g.U16=8]="U16",g[g.U32=9]="U32",g[g.U256=10]="U256",g[g.Reference=254]="Reference",g[g.Generic=255]="Generic",g))(Jr||{}),Gt= 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))(Gt||{}),ei= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(ei||{}),ti= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(ti||{}),ni= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(ni||{}),ri= exports.AccountAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(ri||{}),ur= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ur||{}),ii= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ii||{}),oi= exports.EphemeralPublicKeyVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(oi||{}),si= exports.EphemeralSignatureVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(si||{}),ai= exports.EphemeralCertificate =(e=>(e[e.ZkProof=0]="ZkProof",e[e.OpenIdSignature=1]="OpenIdSignature",e))(ai||{}),pr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(pr||{});function eu(n){return n.type==="pending_transaction"}function tu(n){return n.type==="user_transaction"}function nu(n){return n.type==="genesis_transaction"}function ru(n){return n.type==="block_metadata_transaction"}function iu(n){return n.type==="state_checkpoint_transaction"}function ou(n){return n.type==="validator_transaction"}function su(n){return"signature"in n&&n.signature==="ed25519_signature"}function au(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function cu(n){return n.type==="multi_agent_signature"}function uu(n){return n.type==="fee_payer_signature"}function pu(n){return n.type==="multi_ed25519_signature"}var Os=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(Os||{}),ci= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(ci||{}),Ns= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(Ns||{}),ge= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(ge||{}),_n= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(_n||{}),Gs= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Gs||{});var R=class n extends d{constructor(e){super();cr(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())}},N= exports.U8 =class n extends d{constructor(e){super();ze(e,0,fn),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())}},se= exports.U16 =class n extends d{constructor(e){super();ze(e,0,hn),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())}},ae= exports.U32 =class n extends d{constructor(e){super();ze(e,0,Se),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();ze(e,BigInt(0),$e),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())}},ce= exports.U128 =class n extends d{constructor(e){super();ze(e,BigInt(0),Nt),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())}},ue= exports.U256 =class n extends d{constructor(e){super();ze(e,BigInt(0),Tn),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 N)&&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 i=l.fromHexInput(e);r=Array.from(i.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(i=>new N(i)))}static U16(e){return new n(e.map(r=>new se(r)))}static U32(e){return new n(e.map(r=>new ae(r)))}static U64(e){return new n(e.map(r=>new O(r)))}static U128(e){return new n(e.map(r=>new ce(r)))}static U256(e){return new n(e.map(r=>new ue(r)))}static Bool(e){return new n(e.map(r=>new R(r)))}static MoveString(e){return new n(e.map(r=>new S(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1)o.push(r.deserialize(e));return new n(o)}},S= 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())}},De= 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 N(e):void 0)}static U16(e){return new n(e!=null?new se(e):void 0)}static U32(e){return new n(e!=null?new ae(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 ce(e):void 0)}static U256(e){return new n(e!=null?new ue(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 S(e):void 0)}static deserialize(e,r){let i=T.deserialize(e,r);return new n(i.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ms=(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))(Ms||{}),_=class _ extends d{constructor(e){super();if(e.length!==_.LENGTH)throw new V("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 V("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 V(`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 V(`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 V("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new V("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let i;try{i=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(o){throw new V(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new _(i)}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', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,i)=>r===e.data[i])}};_.LENGTH=32,_.LONG_STRING_LENGTH=64,_.ZERO=_.from("0x0"),_.ONE=_.from("0x1"),_.TWO=_.from("0x2"),_.THREE=_.from("0x3"),_.FOUR=_.from("0x4");var u=_;var ke=class ke extends d{constructor(e){super();let{data:r}=e,i=l.fromHexInput(r);if(i.toUint8Array().length!==ke.LENGTH)throw new Error(`Authentication Key length should be ${ke.LENGTH}`);this.data=i}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(ke.LENGTH);return new ke({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:i}=e,o=l.fromHexInput(i).toUint8Array(),s=new Uint8Array([...o,r]),a=_sha3.sha3_256.create();a.update(s);let c=a.digest();return new ke({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())}};ke.LENGTH=32;var G=ke;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var pi = _interopRequireWildcard(_bip39);var Hs=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ls= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,di= exports.APTOS_BIP44_DEFAULT_DERIVATION_PATH ="m/44'/637'/0'/0'/0'",Qs= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(Qs||{}),dr= exports.HARDENED_OFFSET =2147483648;function lr(n){return Ls.test(n)}function gr(n){return Hs.test(n)}var li=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Ws= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return li(t,s)},js=n=>n.replace("'",""),Xs= exports.splitPath =n=>n.split("/").slice(1).map(js);function xn(n,t,e,r=dr){if(r===dr&&!gr(n))throw new Error(`Invalid hardened derivation path ${n}`);if(r!==dr&&!lr(n))throw new Error(`Invalid derivation path ${n}`);let{key:i,chainCode:o}=li(t,e),s=Xs(n).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Ws(c,p+r),{key:i,chainCode:o});return a}var vn=n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return pi.mnemonicToSeedSync(t)};var Le=class extends d{toString(){let t=this.toUint8Array();return l.fromHexInput(t).toString()}},ee= exports.AccountPublicKey =class extends Le{};var B=class extends d{toString(){let t=this.toUint8Array();return l.fromHexInput(t).toString()}};var at=n=>typeof n=="string"?l.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var gi=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16],Qe=class Qe extends ee{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==Qe.LENGTH)throw new Error(`PublicKey length should be ${Qe.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof P))return!1;let o=at(r),s=l.fromHexInput(o).toUint8Array(),a=i.toUint8Array(),c=this.key.toUint8Array();return i.isCanonicalSignature()?_ed25519.ed25519.verify(a,s,c):!1}authKey(){return G.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 Qe(r)}static isPublicKey(e){return e instanceof Qe}};Qe.LENGTH=32;var v=Qe,pe=class pe extends d{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==pe.LENGTH)throw new Error(`PrivateKey length should be ${pe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new pe(e)}static fromDerivationPath(e,r){if(!gr(e))throw new Error(`Invalid derivation path ${e}`);return new pe(xn(e,pe.SLIP_0010_SEED,vn(r)))}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new v(e)}sign(e){let r=at(e),i=l.fromHexInput(r).toUint8Array(),o=_ed25519.ed25519.sign(i,this.signingKey.toUint8Array());return new P(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new pe(r)}static isPrivateKey(e){return e instanceof pe}};pe.LENGTH=32,pe.SLIP_0010_SEED="ed25519 seed";var H=pe,ct=class ct extends B{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==ct.LENGTH)throw new Error(`Signature length should be ${ct.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 ct(r)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let r=e.length-1;r>=0;r-=1){if(e[r]<gi[r])return!0;if(e[r]>gi[r])return!1}return!1}};ct.LENGTH=64;var P=ct;var te=class te extends ee{constructor(e){super();let{publicKeys:r,threshold:i}=e;if(r.length>te.MAX_KEYS||r.length<te.MIN_KEYS)throw new Error(`Must have between ${te.MIN_KEYS} and ${te.MAX_KEYS} public keys, inclusive`);if(i<te.MIN_THRESHOLD||i>r.length)throw new Error(`Threshold must be between ${te.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=i}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof We))return!1;let o=[];for(let s=0;s<4;s+=1)for(let a=0;a<8;a+=1)if((i.bitmap[s]&1<<7-a)!==0){let p=s*8+a;o.push(p)}if(o.length!==i.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let s=0;s<o.length;s+=1)if(!this.publicKeys[o[s]].verifySignature({message:r,signature:i.signatures[s]}))return!1;return!0}authKey(){return G.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*v.LENGTH+1);return this.publicKeys.forEach((r,i)=>{e.set(r.toUint8Array(),i*v.LENGTH)}),e[this.publicKeys.length*v.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=v.LENGTH){let a=s;o.push(new v(r.subarray(a,a+v.LENGTH)))}return new te({publicKeys:o,threshold:i})}};te.MAX_KEYS=32,te.MIN_KEYS=2,te.MIN_THRESHOLD=1;var ut=te,Q=class Q extends B{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>Q.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${Q.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(i instanceof Uint8Array))this.bitmap=Q.createBitmap({bits:i});else{if(i.length!==Q.BITMAP_LEN)throw new Error(`"bitmap" length should be ${Q.BITMAP_LEN}`);this.bitmap=i}}toUint8Array(){let e=new Uint8Array(this.signatures.length*P.LENGTH+Q.BITMAP_LEN);return this.signatures.forEach((r,i)=>{e.set(r.toUint8Array(),i*P.LENGTH)}),e.set(this.bitmap,this.signatures.length*P.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r.subarray(r.length-4),o=[];for(let s=0;s<r.length-i.length;s+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new Q({signatures:o,bitmap:i})}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(a>=Q.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${Q.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.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.");s.add(a);let p=Math.floor(a/8),y=o[p];y|=i>>a%8,o[p]=y}),o}};Q.MAX_SIGNATURES_SUPPORTED=32,Q.BITMAP_LEN=4;var We=Q;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var je=class je extends Le{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==je.LENGTH)throw new Error(`PublicKey length should be ${je.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof Ze))return!1;let o=at(r),s=l.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new je(r)}static isPublicKey(e){return e instanceof je}};je.LENGTH=65;var Xe=je,ye=class ye extends d{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==ye.LENGTH)throw new Error(`PrivateKey length should be ${ye.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ye(e)}static fromDerivationPath(e,r){if(!lr(e))throw new Error(`Invalid derivation path ${e}`);return ye.fromDerivationPathInner(e,vn(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new ye(i)}sign(e){let r=at(e),i=l.fromHexInput(r),o=_sha3.sha3_256.call(void 0, i.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new Ze(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Xe(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 ye(r)}static isPrivateKey(e){return e instanceof ye}};ye.LENGTH=32;var Ye=ye,pt=class pt extends B{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==pt.LENGTH)throw new Error(`Signature length should be ${pt.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 pt(r)}};pt.LENGTH=64;var Ze=pt;var Je=class n extends Le{constructor(e){super();let r=e.constructor.name;switch(r){case v.name:this.publicKey=e;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${r}`)}}toUint8Array(){return this.bcsToBytes()}toString(){return this.bcsToHex().toString()}verifySignature(e){let{message:r,signature:i}=e;return this.publicKey.verifySignature({message:r,signature:i})}serialize(e){if(this.publicKey instanceof v)e.serializeU32AsUleb128(0),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(v.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof v}},de= exports.EphemeralSignature =class n extends B{constructor(e){super();let r=e.constructor.name;switch(r){case P.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${r}`)}}toUint8Array(){return this.signature.toUint8Array()}toString(){return this.signature.toString()}static fromHex(e){let r=l.fromHexInput(e),i=new bn(r.toUint8Array());return n.deserialize(i)}serialize(e){if(this.signature instanceof P)e.serializeU32AsUleb128(0),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(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${r}`)}}};var _poseidonlite = require('poseidon-lite');var ya=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Ai=31,ma=16,mi=(ma-1)*Ai;function En(n,t){let r=new TextEncoder().encode(n);return Aa(r,t)}function Aa(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let e=yr(n,t);return Mt(e)}function fa(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let e=ba(n,t);return ha(e)}function yr(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return fa(n,t).concat([BigInt(n.length)])}function ha(n){if(n.length>mi)throw new Error(`Can't pack more than ${mi}. Was given ${n.length} bytes`);return Ta(n,Ai).map(t=>Ft(t))}function Ta(n,t){let e=[];for(let r=0;r<n.length;r+=t)e.push(n.subarray(r,r+t));return e}function Ft(n){let t=BigInt(0);for(let e=n.length-1;e>=0;e-=1)t=t<<BigInt(8)|BigInt(n[e]);return t}function fi(n,t){let e=new Uint8Array(t);for(let r=0;r<t;r+=1)e[r]=Number(n&BigInt(255)),n>>=BigInt(8);return e}function ba(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let e=new Uint8Array(t);e.set(n);for(let r=n.length;r<t;r+=1)e[r]=0;return e}function Mt(n){let t=ya[n.length-1];if(t)return t(n);throw new Error(`Unable to hash input of length ${n.length}`)}var $t=1e7,wa= exports.MAX_AUD_VAL_BYTES =120,Sa= exports.MAX_UID_KEY_BYTES =30,_a= exports.MAX_UID_VAL_BYTES =330,ud= exports.MAX_ISS_VAL_BYTES =120,pd= exports.MAX_EXTRA_FIELD_BYTES =350,dd= exports.MAX_JWT_HEADER_B64_BYTES =300,ld= exports.MAX_COMMITED_EPK_BYTES =93,_e=class _e extends ee{constructor(e,r){super();let i=l.fromHexInput(r).toUint8Array();if(i.length!==_e.ADDRESS_SEED_LENGTH)throw new Error(`Address seed length in bytes should be ${_e.ADDRESS_SEED_LENGTH}`);this.iss=e,this.addressSeed=i}authKey(){let e=new k;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),G.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return l.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){return!0}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.addressSeed)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static load(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static isPublicKey(e){return e instanceof _e}static create(e){return qt(e),new _e(e.iss,qt(e))}};_e.ADDRESS_SEED_LENGTH=32;var xe=_e;function qt(n){let{uidKey:t,uidVal:e,aud:r,pepper:i}=n,o=[Ft(l.fromHexInput(i).toUint8Array()),En(r,wa),En(e,_a),En(t,Sa)];return fi(Mt(o),xe.ADDRESS_SEED_LENGTH)}var et=class n extends B{constructor(e){super();this.signature=e}toUint8Array(){return this.signature.toUint8Array()}toString(){return this.signature.toString()}serialize(e){if(this.signature instanceof gt)e.serializeU32AsUleb128(1),this.signature.serialize(e);else if(this.signature instanceof lt)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Not a valid OIDB signature")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(lt.load(e));case 1:return new n(gt.load(e));default:throw new Error(`Unknown variant index for EphemeralCertificate: ${r}`)}}},dt= exports.Groth16Zkp =class n extends d{constructor(e){super();let{a:r,b:i,c:o}=e;this.a=l.fromHexInput(r).toUint8Array(),this.b=l.fromHexInput(i).toUint8Array(),this.c=l.fromHexInput(o).toUint8Array()}toUint8Array(){let e=new k;return this.serialize(e),e.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeFixedBytes(this.a),e.serializeFixedBytes(this.b),e.serializeFixedBytes(this.c)}static deserialize(e){e.deserializeUleb128AsU32();let r=e.deserializeFixedBytes(32),i=e.deserializeFixedBytes(64),o=e.deserializeFixedBytes(32);return new n({a:r,b:i,c:o})}},lt= exports.SignedGroth16Signature =class n extends B{constructor(e){super();let{proof:r,expHorizonSecs:i=BigInt($t),trainingWheelsSignature:o,extraField:s,overrideAudVal:a}=e;this.proof=r,this.expHorizonSecs=i,this.trainingWheelsSignature=o,this.extraField=s,this.overrideAudVal=a}toUint8Array(){let e=new k;return this.serialize(e),e.toUint8Array()}toString(){return this.toString()}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let r=dt.deserialize(e),i=e.deserializeU64(),s=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,c=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,[p]=e.deserializeVector(de);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:p,extraField:s,overrideAudVal:c})}static load(e){let r=dt.deserialize(e),i=e.deserializeU64(),s=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,c=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,[p]=e.deserializeVector(de);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:p,extraField:s,overrideAudVal:c})}},gt= exports.OpenIdSignature =class n extends B{constructor(e){super();let{jwtSignature:r,uidKey:i,jwtPayloadJson:o,epkBlinder:s,pepper:a,overrideAudValue:c}=e;this.jwtSignature=r,this.jwtPayloadJson=o,this.uidKey=_nullishCoalesce(i, () => ("sub")),this.epkBlinder=s,this.pepper=a,this.overrideAudValue=c}toUint8Array(){return this.epkBlinder}toString(){return this.toString()}serialize(e){e.serializeStr(this.jwtSignature),e.serializeStr(this.jwtPayloadJson),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.epkBlinder),e.serializeFixedBytes(this.pepper),e.serializeOptionStr(this.overrideAudValue)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=e.deserializeFixedBytes(31),p=e.deserializeUleb128AsU32()?e.deserializeStr():void 0;return new n({jwtSignature:r,jwtPayloadJson:i,uidKey:o,epkBlinder:s,pepper:a,overrideAudValue:p})}static load(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=e.deserializeFixedBytes(31),p=e.deserializeUleb128AsU32()?e.deserializeStr():void 0;return new n({jwtSignature:r,jwtPayloadJson:i,uidKey:o,epkBlinder:s,pepper:a,overrideAudValue:p})}static isSignature(e){return e instanceof n}},Be= exports.KeylessSignature =class n extends B{constructor(e){super();let{jwtHeader:r,openIdSignatureOrZkProof:i,expiryDateSecs:o,ephemeralPublicKey:s,ephemeralSignature:a}=e;this.jwtHeader=r,this.openIdSignatureOrZkProof=i,this.expiryDateSecs=o,this.ephemeralPublicKey=s,this.ephemeralSignature=a}toUint8Array(){return this.ephemeralSignature.toUint8Array()}toString(){return this.toString()}serialize(e){this.openIdSignatureOrZkProof.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let r=et.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=Je.deserialize(e),a=de.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,openIdSignatureOrZkProof:r,ephemeralPublicKey:s,ephemeralSignature:a})}static load(e){let r=e.deserializeStr(),i=e.deserializeU64(),o=et.deserialize(e),s=Je.deserialize(e),a=de.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:i,openIdSignatureOrZkProof:o,ephemeralPublicKey:s,ephemeralSignature:a})}static isSignature(e){return e instanceof n}};var K=class n extends ee{constructor(e){super();if(this.publicKey=e,e instanceof v)this.variant=0;else if(e instanceof Xe)this.variant=1;else if(e instanceof xe)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:i}=e;return i instanceof q?this.publicKey.verifySignature({message:r,signature:i.signature}):!1}authKey(){return G.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(),i;switch(r){case 0:i=v.deserialize(e);break;case 1:i=Xe.deserialize(e);break;case 3:i=xe.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(i)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof v}isSecp256k1PublicKey(){return this.publicKey instanceof Xe}},q= exports.AnySignature =class n extends B{constructor(e){super();if(this.signature=e,e instanceof P)this.variant=0;else if(e instanceof Ze)this.variant=1;else if(e instanceof Be)this.variant=3;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(),i;switch(r){case 0:i=P.deserialize(e);break;case 1:i=Ze.deserialize(e);break;case 3:i=Be.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(i)}};function hi(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var Ke=class n extends ee{constructor(e){super();let{publicKeys:r,signaturesRequired:i}=e;if(i<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<i)throw new Error(`Provided ${r.length} public keys is smaller than the ${i} required signatures`);this.publicKeys=r.map(o=>o instanceof K?o:new K(o)),this.signaturesRequired=i}verifySignature(e){throw new Error("not implemented")}authKey(){return G.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(K),i=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:i})}createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=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(s.has(a))throw new Error(`Duplicate bit ${a} detected.`);s.add(a);let p=Math.floor(a/8),y=o[p];y|=i>>a%8,o[p]=y}),o}getIndex(e){let r=e instanceof K?e:new K(e),i=this.publicKeys.findIndex(o=>o.toString()===r.toString());if(i!==-1)return i;throw new Error("Public key not found in MultiKey")}},W=class W extends B{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>W.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${W.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(s=>s instanceof q?s:new q(s)),!(i instanceof Uint8Array))this.bitmap=W.createBitmap({bits:i});else{if(i.length!==W.BITMAP_LEN)throw new Error(`"bitmap" length should be ${W.BITMAP_LEN}`);this.bitmap=i}let o=this.bitmap.reduce((s,a)=>s+hi(a),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=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(s.has(a))throw new Error("Duplicate bits detected.");s.add(a);let c=Math.floor(a/8),p=o[c];p|=i>>a%8,o[c]=p}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeBytes(),i=r.reduce((s,a)=>s+hi(a),0),o=[];for(let s=0;s<i;s+=1){let a=q.deserialize(e);o.push(a)}return new W({signatures:o,bitmap:r})}};W.BITMAP_LEN=4,W.MAX_SIGNATURES_SUPPORTED=W.BITMAP_LEN*8;var tt=W;var j=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return me.load(t);case 1:return In.load(t);case 2:return ne.load(t);case 3:return Oe.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof me}isMultiEd25519(){return this instanceof In}isSingleKey(){return this instanceof ne}isMultiKey(){return this instanceof Oe}},me= exports.AccountAuthenticatorEd25519 =class n extends j{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=v.deserialize(e),i=P.deserialize(e);return new n(r,i)}},In= exports.AccountAuthenticatorMultiEd25519 =class n extends j{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=ut.deserialize(e),i=We.deserialize(e);return new n(r,i)}},ne= exports.AccountAuthenticatorSingleKey =class n extends j{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=K.deserialize(e),i=q.deserialize(e);return new n(r,i)}},Oe= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,r){super();this.public_keys=e,this.signatures=r}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let r=Ke.deserialize(e),i=tt.deserialize(e);return new n(r,i)}};var Vt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(Vt||{}),Ti= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,bi= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Un= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Rn= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",wi= exports.RAW_TRANSACTION_SALT ="RawTransaction",Si= exports.RAW_TRANSACTION_WITH_DATA_SALT ="RawTransactionWithData",yt= 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))(yt||{});var mt=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 Ht=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),i=U.deserialize(e);return new n(r,i)}};var z=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return F.load(t);case 1:return Ae.load(t);case 2:return L.load(t);case 3:return ht.load(t);case 4:return X.load(t);case 5:return nt.load(t);case 6:return C.load(t);case 7:return m.load(t);case 8:return At.load(t);case 9:return ft.load(t);case 10:return Tt.load(t);case 255:return D.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof F}isAddress(){return this instanceof X}isGeneric(){return this instanceof D}isSigner(){return this instanceof nt}isVector(){return this instanceof C}isStruct(){return this instanceof m}isU8(){return this instanceof Ae}isU16(){return this instanceof At}isU32(){return this instanceof ft}isU64(){return this instanceof L}isU128(){return this instanceof ht}isU256(){return this instanceof Tt}},F= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},Ae= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},At= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},ft= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},L= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},ht= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},Tt= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},X= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},nt= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},zn= 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)}},D= 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)}},C= exports.TypeTagVector =class n extends z{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new Ae)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=z.deserialize(e);return new n(r)}},m= 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=ve.deserialize(e);return new n(r)}isTypeTag(e,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&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")}},ve= exports.StructTag =class n extends d{constructor(e,r,i,o){super();this.address=e,this.moduleName=r,this.name=i,this.typeArgs=o}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),i=U.deserialize(e),o=U.deserialize(e),s=e.deserializeVector(z);return new n(r,i,o,s)}};function Sl(){return new ve(u.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function x(){return new ve(u.ONE,new U("string"),new U("String"),[])}function _l(n){return new ve(u.ONE,new U("option"),new U("Option"),[n])}function Y(n){return new ve(u.ONE,new U("object"),new U("Object"),[n])}function xa(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return N.deserialize(n);case 1:return O.deserialize(n);case 2:return ce.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,N);case 5:return R.deserialize(n);case 6:return se.deserialize(n);case 7:return ae.deserialize(n);case 8:return ue.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var rt=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Lt.load(t);case 2:return Qt.load(t);case 3:return Wt.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Lt= exports.TransactionPayloadScript =class n extends rt{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=jt.deserialize(e);return new n(r)}},Qt= exports.TransactionPayloadEntryFunction =class n extends rt{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=it.deserialize(e);return new n(r)}},Wt= exports.TransactionPayloadMultiSig =class n extends rt{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Xt.deserialize(e);return new n(r)}},it= exports.EntryFunction =class n{constructor(t,e,r,i){this.module_name=t,this.function_name=e,this.type_args=r,this.args=i}static build(t,e,r,i){return new n(Ht.fromStr(t),new U(e),r,i)}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=Ht.deserialize(t),r=U.deserialize(t),i=t.deserializeVector(z),o=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=t.deserializeUleb128AsU32(),p=wn.deserialize(t,c);s.push(p)}return new n(e,r,i,s)}},jt= 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),i=t.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=xa(t);o.push(a)}return new n(e,r,o)}},Xt= 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(),i;return r&&(i=Yt.deserialize(t)),new n(e,i)}},Yt= 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(it.deserialize(e))}};var M=class n extends d{constructor(e,r,i,o,s,a,c){super();this.sender=e,this.sequence_number=r,this.payload=i,this.max_gas_amount=o,this.gas_unit_price=s,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),i=e.deserializeU64(),o=rt.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=mt.deserialize(e);return new n(r,i,o,s,a,c,p)}},Dn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return fe.load(t);case 1:return he.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},fe= exports.MultiAgentRawTransaction =class n extends Dn{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=M.deserialize(e),i=e.deserializeVector(u);return new n(r,i)}},he= exports.FeePayerRawTransaction =class n extends Dn{constructor(e,r,i){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=i}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=M.deserialize(e),i=e.deserializeVector(u),o=u.deserialize(e);return new n(r,i,o)}};var kn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new S("account");this.structName=new S("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 Pe=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return bt.load(t);case 1:return mr.load(t);case 2:return wt.load(t);case 3:return St.load(t);case 4:return _t.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},bt= exports.TransactionAuthenticatorEd25519 =class n extends Pe{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=v.deserialize(e),i=P.deserialize(e);return new n(r,i)}},mr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Pe{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=ut.deserialize(e),i=We.deserialize(e);return new n(r,i)}},wt= exports.TransactionAuthenticatorMultiAgent =class n extends Pe{constructor(e,r,i){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i}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=j.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(j);return new n(r,i,o)}},St= exports.TransactionAuthenticatorFeePayer =class n extends Pe{constructor(e,r,i,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i,this.fee_payer=o}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=j.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(j),s=u.deserialize(e),a=j.deserialize(e),c={address:s,authenticator:a};return new n(r,i,o,c)}},_t= exports.TransactionAuthenticatorSingleSender =class n extends Pe{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=j.deserialize(e);return new n(r)}};var Te=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=M.deserialize(e),i=Pe.deserialize(e);return new n(r,i)}};var Bn=class n extends d{constructor(e,r){super();this.rawTransaction=e,this.feePayerAddress=r}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=M.deserialize(e),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(r,o)}};function xt(n){return n.feePayerAddress?new he(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new fe(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Zt(n,t){let e=_sha3.sha3_256.create();e.update(`APTOS::${t}`);let r=e.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Eg(n){return Zt(n.bcsToBytes(),n.constructor.name)}function Ne(n){let t=xt(n);if(t instanceof M)return Zt(t.bcsToBytes(),wi);if(t instanceof fe||t instanceof he)return Zt(t.bcsToBytes(),Si);throw new Error(`Unknown transaction type to sign on: ${t}`)}var vt=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=H.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,i=H.fromDerivationPath(e,r);return new n({privateKey:i})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(Ne(t));return new me(this.publicKey,e)}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(Ne(t))}};var Pt=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new K(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=H.generate();break;case 2:r=Ye.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:i}=t,o;switch(e){case 0:o=H.fromDerivationPath(r,i);break;case 2:o=Ye.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.sign(Ne(t)),r=new q(e);return new ne(this.publicKey,r)}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(Ne(t))}};var Ge=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?vt.generate():Pt.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:i=!0}=t;return e instanceof H&&i?new vt({privateKey:e,address:r}):new Pt({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:i,legacy:o=!0}=t;return e===0&&o?vt.fromDerivationPath({mnemonic:r,path:i}):Pt.fromDerivationPath({scheme:e,mnemonic:r,path:i})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var _jwtdecode = require('jwt-decode');var _base64 = require('base-64');function Ea(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=t+"==".substring(0,(3-t.length%3)%3);return _base64.decode.call(void 0, e)}var be=class be{constructor(t){let{address:e,ephemeralKeyPair:r,iss:i,uidKey:o,uidVal:s,aud:a,pepper:c,proofFetcherOrData:p,jwt:y}=t;this.ephemeralKeyPair=r;let w=qt(t);this.publicKey=new xe(i,w),this.accountAddress=e?u.from(e):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=y,p instanceof Promise?(this.proof=p,this.initialize(p)):this.proof=p,this.signingScheme=2;let f=l.fromHexInput(c).toUint8Array();if(f.length!==be.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${be.PEPPER_LENGTH}`);this.pepper=f}async initialize(t){try{this.proof=await t}catch (e2){throw new Error("Failed to fetch proof")}}signWithAuthenticator(t){let e=xt(t),r=new q(this.sign(e.bcsToBytes())),i=new K(this.publicKey);return new ne(i,r)}async waitForProofFetch(){this.proof instanceof Promise&&await this.proof}sign(t){let{expiryDateSecs:e}=this.ephemeralKeyPair,r=Math.floor(new Date().getTime()/1e3);if(e<r)throw new Error("Ephemeral key pair is expired.");if(this.proof instanceof Promise)throw new Error("Failed to fetch proof.");let i=this.jwt.split(".")[0],o=this.ephemeralKeyPair.publicKey,s=new k;s.serializeFixedBytes(l.fromHexInput(t).toUint8Array()),s.serializeOption(this.proof.proof);let a=Zt(s.toUint8Array(),"TransactionAndProof"),c=this.ephemeralKeyPair.sign(a);return new Be({jwtHeader:Ea(i),openIdSignatureOrZkProof:new et(this.proof),expiryDateSecs:e,ephemeralPublicKey:o,ephemeralSignature:c})}signTransaction(t){let e=xt(t);return this.sign(e.bcsToBytes())}signWithOpenIdSignature(t){let[e,r,i]=this.jwt.split("."),o=new gt({jwtSignature:i,jwtPayloadJson:r,uidKey:this.uidKey,epkBlinder:this.ephemeralKeyPair.blinder,pepper:this.pepper}),{expiryDateSecs:s}=this.ephemeralKeyPair,a=this.ephemeralKeyPair.publicKey,c=this.ephemeralKeyPair.sign(t);return new Be({jwtHeader:e,openIdSignatureOrZkProof:new et(o),expiryDateSecs:s,ephemeralPublicKey:a,ephemeralSignature:c})}deriveAptosConnectPublicKey(){let{uidKey:t,uidVal:e,pepper:r}=this,{iss:i}=this.publicKey,o=qt({uidKey:t,uidVal:e,aud:be.APTOS_CONNECT_CLIENT_ID,pepper:r});return new xe(i,o)}verifySignature(t){return!0}static fromJWTAndProof(t){let{proofFetcherOrData:e,jwt:r,ephemeralKeyPair:i,pepper:o}=t,s=_nullishCoalesce(t.uidKey, () => ("sub")),a=_jwtdecode.jwtDecode.call(void 0, r),c=a.iss;if(typeof a.aud!="string")throw new Error("aud was not found or an array of values");let p=a.aud,y=a[s];return new be({proofFetcherOrData:e,ephemeralKeyPair:i,iss:c,uidKey:s,uidVal:y,aud:p,pepper:o,jwt:r})}static fromDerivationPath(t,e){return xn(t,be.SLIP_0010_SEED,e)}};be.PEPPER_LENGTH=31,be.SLIP_0010_SEED="32 bytes",be.APTOS_CONNECT_CLIENT_ID="734998116548-ib6ircv72o1b6l0no9ol4spnnkr8gm69.apps.googleusercontent.com";var Ce=be;var _i=class n{constructor(t){let{privateKey:e,expiryDateSecs:r,blinder:i}=t;this.privateKey=e,this.publicKey=new Je(e.publicKey()),this.expiryDateSecs=r||BigInt(za(Ra()+$t)),this.blinder=i!==void 0?l.fromHexInput(i).toUint8Array():Ua(),this.nonce=this.generateNonce()}static generate(t){let e;switch(_optionalChain([t, 'optionalAccess', _8 => _8.scheme])){case 0:default:e=H.generate()}return new n({privateKey:e})}generateNonce(){let t=yr(this.publicKey.bcsToBytes(),93);return t.push(BigInt(this.expiryDateSecs)),t.push(Ft(this.blinder)),Mt(t).toString()}sign(t){return new de(this.privateKey.sign(t))}};function Ua(){return _utils.randomBytes.call(void 0, 31)}function Ra(){return Math.floor(new Date().getTime()/1e3)}function za(n){let t=new Date(n*1e3);return t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),Math.floor(t.getTime()/1e3)}var Ct=class n{constructor(t){let{multiKey:e,signers:r}=t;this.publicKey=e,this.signers=r,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let i=[];for(let o of r)i.push(this.publicKey.getIndex(o.publicKey));this.signaturesBitmap=this.publicKey.createBitmap({bits:i})}static fromPublicKeysAndSigners(t){let{publicKeys:e,signaturesRequired:r,signers:i}=t,o=new Ke({publicKeys:e,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(t){return t instanceof n}signWithAuthenticator(t){return new Oe(this.publicKey,this.signTransaction(t))}async waitForProofFetch(){let t=this.signers.filter(e=>e instanceof Ce);await Promise.all(t.filter(e=>e.proof instanceof Promise).map(e=>e.proof))}sign(t){let e=[];for(let r of this.signers)e.push(r.sign(t));return new tt({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(t){let e=[];for(let r of this.signers)e.push(r.signTransaction(t));return new tt({signatures:e,bitmap:this.signaturesBitmap})}verifySignature(t){return!0}};var re=class extends Error{constructor(e,r,i){super(i);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var xi="1.13.0-zeta.0";var vi={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Pi= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ci= 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"},Ar= exports.NetworkToPepperAPI ={mainnet:"mainnet not yet ready, requires sdk upgrade",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},fr= exports.NetworkToProverAPI ={mainnet:"mainnet not yet ready, requires sdk upgrade",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},hr= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(hr||{}),Tr= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70},Vy= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var Ei={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 Da(n,t){let{url:e,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _9 => _9.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${xi}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _10 => _10.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _11 => _11.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _12 => _12.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _13 => _13.API_KEY])}`),t.provider({url:e,method:r,body:i,params:s,headers:p,overrides:a})}async function Kn(n,t,e){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Da({...n,url:o},t.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new re(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new re(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;if(a.status>=500)throw new re(n,a,`${s.data}`);if(t.isPepperServiceRequest(r))throw new re(n,a,`${s.data}`);let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Ei?c=Ei[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new re(n,a,`${e} error: ${c}`)}async function br(n){let{aptosConfig:t,overrides:e,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Kn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...t.clientConfig,...e}},t,n.type)}async function Z(n){let{aptosConfig:t}=n;return br({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _14 => _14.clientConfig, 'optionalAccess', _15 => _15.HEADERS]),..._optionalChain([t, 'access', _16 => _16.fullnodeConfig, 'optionalAccess', _17 => _17.HEADERS])}}})}async function Ii(n){return br({...n,type:"Pepper"})}async function Et(n){let t=[],e,r=n.params;do{let i=await br({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=i.headers["x-aptos-cursor"],delete i.headers,t.push(...i.data),r.start=e}while(e!=null);return t}async function Jt(n){let{type:t,originMethod:e,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,y=c.getRequestUrl(t);return Kn({url:y,method:"POST",originMethod:e,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function ot(n){let{aptosConfig:t}=n;return Jt({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _18 => _18.clientConfig, 'optionalAccess', _19 => _19.HEADERS]),..._optionalChain([t, 'access', _20 => _20.fullnodeConfig, 'optionalAccess', _21 => _21.HEADERS])}}})}async function Ui(n){let{aptosConfig:t}=n;return Jt({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _22 => _22.clientConfig, 'optionalAccess', _23 => _23.HEADERS]),..._optionalChain([t, 'access', _24 => _24.indexerConfig, 'optionalAccess', _25 => _25.HEADERS])}}})}async function Ri(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _26 => _26.clientConfig, 'optionalAccess', _27 => delete _27.API_KEY]),Jt({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _28 => _28.clientConfig, 'optionalAccess', _29 => _29.HEADERS]),..._optionalChain([e, 'access', _30 => _30.faucetConfig, 'optionalAccess', _31 => _31.HEADERS])}}})}async function zi(n){return Jt({...n,type:"Pepper"})}async function Di(n){return Jt({...n,type:"Prover"})}var ka=`
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
- `,_s=`
19
+ `,Ba=`
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
- `,on=`
29
+ `,On=`
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
- `,eo=`
76
+ `,ki=`
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
- `,to=`
86
+ `,Bi=`
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
- `,no=`
119
+ `,Ki=`
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
- `,ro=`
153
+ `,Oi=`
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
- `,oo=`
170
+ `,Ni=`
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
- ${on}`,_d=`
181
+ ${On}`,fm=`
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
- ${on}`,io=`
192
+ ${On}`,Gi=`
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
- ${on}`,so=`
203
+ ${On}`,Fi=`
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
- `,ao=`
215
+ `,Mi=`
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
- `,co=`
223
+ `,qi=`
224
224
  query getChainTopUserTransactions($limit: Int) {
225
225
  user_transactions(limit: $limit, order_by: {version: desc}) {
226
226
  version
227
227
  }
228
228
  }
229
- `,$n=`
229
+ `,wr=`
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
- `,uo=`
248
+ `,$i=`
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
- `,po=`
266
+ `,Vi=`
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
- `,lo=`
279
+ `,Hi=`
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
- `,go=`
298
+ `,Li=`
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
- `,mo=`
323
+ `,Qi=`
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
- `,tt=`
340
+ `,It=`
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,14 +348,14 @@
348
348
  ...AnsTokenFragment
349
349
  }
350
350
  }
351
- ${_s}`,Vn=`
351
+ ${Ba}`,Sr=`
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
355
355
  pool_address
356
356
  }
357
357
  }
358
- `,Ln=`
358
+ `,_r=`
359
359
  query getProcessorStatus($where_condition: processor_status_bool_exp) {
360
360
  processor_status(where: $where_condition) {
361
361
  last_success_version
@@ -363,7 +363,7 @@
363
363
  last_updated
364
364
  }
365
365
  }
366
- `,yo=`
366
+ `,Wi=`
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
- ${ws}`,Hn=`
377
+ ${ka}`,xr=`
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
- ${on}`,Ao=`
388
+ ${On}`,ji=`
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 sn(n){let{aptosConfig:e}=n,{data:t}=await X({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function fo(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:o}=await X({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _31 => _31.withTransactions])}});return o}async function ho(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:o}=await X({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _32 => _32.withTransactions])}});return o}async function an(n){let{aptosConfig:e,handle:t,data:r,options:o}=n;return(await De({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _33 => _33.ledgerVersion])},body:r})).data}async function To(n){let{aptosConfig:e,limit:t}=n;return(await m({aptosConfig:e,query:{query:co,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function m(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:o}=await Mr({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return o}async function Ss(n){let{aptosConfig:e}=n;return(await m({aptosConfig:e,query:{query:Ln},originMethod:"getProcessorStatuses"})).processor_status}async function cn(n){let e=await Ss({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function un(n){let{aptosConfig:e,processorType:t}=n;return(await m({aptosConfig:e,query:{query:Ln,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Qn=new Map;function nt(n,e,t){return async(...r)=>{if(Qn.has(e)){let{value:i,timestamp:s}=Qn.get(e);if(t===void 0||Date.now()-s<=t)return i}let o=await n(...r);return Qn.set(e,{value:o,timestamp:Date.now()}),o}}async function le(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await X({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return r}async function _o(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Qe({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _34 => _34.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _35 => _35.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _36 => _36.limit]), () => (1e3))}})}async function pn(n){return _optionalChain([n, 'access', _37 => _37.options, 'optionalAccess', _38 => _38.ledgerVersion])!==void 0?bo(n):nt(async()=>bo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function bo(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:o}=n,{data:i}=await X({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _39 => _39.ledgerVersion])}});return i}async function So(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Qe({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _40 => _40.offset]),limit:_optionalChain([r, 'optionalAccess', _41 => _41.limit])}})}async function xo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Qe({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _42 => _42.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _43 => _43.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _44 => _44.limit]), () => (999))}})}async function Wn(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:o}=n,{data:i}=await X({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}async function jn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,o=await Wn({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(t);try{let a=await an({aptosConfig:e,handle:i,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ce&&a.data.error_code==="table_item_not_found")return s;throw a}}async function vo(n){let{aptosConfig:e,accountAddress:t}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await m({aptosConfig:e,query:{query:so,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Co(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _46 => _46.tokenStandard])&&(i.token_standard={_eq:_optionalChain([r, 'optionalAccess', _47 => _47.tokenStandard])});let s={query:oo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _48 => _48.offset]),limit:_optionalChain([r, 'optionalAccess', _49 => _49.limit]),order_by:_optionalChain([r, 'optionalAccess', _50 => _50.orderBy])}};return(await m({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Po(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:o}=n,i=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:i},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _51 => _51.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _52 => _52.tokenStandard])});let c={query:io,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _53 => _53.offset]),limit:_optionalChain([o, 'optionalAccess', _54 => _54.limit]),order_by:_optionalChain([o, 'optionalAccess', _55 => _55.orderBy])}};return(await m({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Eo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _56 => _56.tokenStandard])&&(i.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])}});let s={query:no,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([r, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([r, 'optionalAccess', _60 => _60.orderBy])}};return(await m({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function Io(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await m({aptosConfig:e,query:{query:ao,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function Uo(n){let{aptosConfig:e,accountAddress:t,coinType:r}=n,o=u.from(t).toStringLong(),i=await Xn({aptosConfig:e,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function Xn(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o=u.from(t).toStringLong(),i={..._optionalChain([r, 'optionalAccess', _61 => _61.where]),owner_address:{_eq:o}},s={query:to,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([r, 'optionalAccess', _63 => _63.limit]),order_by:_optionalChain([r, 'optionalAccess', _64 => _64.orderBy])}};return(await m({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ro(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await m({aptosConfig:e,query:{query:eo,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!i.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return i.current_fungible_asset_balances_aggregate.aggregate.count}async function No(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()}},s={query:ro,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([r, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([r, 'optionalAccess', _67 => _67.orderBy])}};return(await m({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function zo(n){let{aptosConfig:e,privateKey:t}=n,r=new $(t.publicKey());if(t instanceof qe){let i=q.fromPublicKeyAndScheme({publicKey:r,scheme:2}).derivedAddress();return Ue.fromPrivateKeyAndAddress({privateKey:t,address:i})}if(t instanceof J){let o=q.fromPublicKeyAndScheme({publicKey:r,scheme:2});if(await wo({authKey:o,aptosConfig:e})){let c=o.derivedAddress();return Ue.fromPrivateKeyAndAddress({privateKey:t,address:c,legacy:!1})}let s=q.fromPublicKeyAndScheme({publicKey:r.publicKey,scheme:0});if(await wo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return Ue.fromPrivateKeyAndAddress({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function wo(n){let{aptosConfig:e,authKey:t}=n,r=await jn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await le({aptosConfig:e,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 ge(n){return new Promise(e=>{setTimeout(e,n)})}async function ko(n){let{aptosConfig:e,options:t}=n;return Qe({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _68 => _68.offset]),limit:_optionalChain([t, 'optionalAccess', _69 => _69.limit])}})}async function ln(n){let{aptosConfig:e}=n;return nt(async()=>{let{data:t}=await X({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function Do(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await X({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function gn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await X({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function Go(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await gn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _70 => _70.status])===404)return!0;throw r}}async function rt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _71 => _71.timeoutSecs]), () => (20)),i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _72 => _72.checkSuccess]), () => (!0)),s=!0,a=0,c,p,f=200,C=1.5;for(;s&&!(a>=o);){try{if(c=await gn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(y){if(!(y instanceof ce)||(p=y,y.status!==404&&y.status>=400&&y.status<500))throw y}await ge(f),a+=f/1e3,f*=C}if(c===void 0)throw p||new dn(`Fetching transaction ${t} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new dn(`Transaction ${t} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Yn(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function mn(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,i=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-i>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await cn({aptosConfig:e}):s=(await un({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await ge(200)}}var dn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Yn=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function b(n){n.minimumLedgerVersion!==void 0&&await mn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var xt=class{constructor(e){this.config=e}async getAccountInfo(e){return le({aptosConfig:this.config,...e})}async getAccountModules(e){return _o({aptosConfig:this.config,...e})}async getAccountModule(e){return pn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return So({aptosConfig:this.config,...e})}async getAccountResources(e){return xo({aptosConfig:this.config,...e})}async getAccountResource(e){return Wn({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return jn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),vo({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Co({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Po({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Io({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Xn({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ro({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Qt,...e})}async getAccountCoinAmount(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Uo({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),No({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return zo({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var yn=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _73 => _73.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _74 => _74.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _75 => _75.faucet]),this.indexer=_optionalChain([e, 'optionalAccess', _76 => _76.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _77 => _77.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _78 => _78.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _79 => _79.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _80 => _80.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _81 => _81.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return zr[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return kr[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Nr[this.network];default:throw Error(`apiType ${e} is not supported`)}}};var An=class extends d{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new k(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=T.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var be=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ot.load(e);case 1:return Zn.load(e);case 2:return it.load(e);case 3:return st.load(e);case 4:return at.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}},ot= exports.TransactionAuthenticatorEd25519 =class n extends be{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=U.deserialize(e),r=R.deserialize(e);return new n(t,r)}},Zn= exports.TransactionAuthenticatorMultiEd25519 =class n extends be{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Xe.deserialize(e),r=Me.deserialize(e);return new n(t,r)}},it= exports.TransactionAuthenticatorMultiAgent =class n extends be{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=Q.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(Q);return new n(t,r,o)}},st= exports.TransactionAuthenticatorFeePayer =class n extends be{constructor(e,t,r,o){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=o}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=Q.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(Q),i=u.deserialize(e),s=Q.deserialize(e),a={address:i,authenticator:s};return new n(t,r,o,a)}},at= exports.TransactionAuthenticatorSingleSender =class n extends be{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=Q.deserialize(e);return new n(t)}};var ct=class n extends d{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var E=class n extends d{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var vt=class n extends d{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new E(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=E.deserialize(e);return new n(t,r)}};var N=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return G.load(e);case 1:return me.load(e);case 2:return V.load(e);case 3:return dt.load(e);case 4:return W.load(e);case 5:return $e.load(e);case 6:return x.load(e);case 7:return l.load(e);case 8:return ut.load(e);case 9:return pt.load(e);case 10:return lt.load(e);case 255:return z.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof W}isGeneric(){return this instanceof z}isSigner(){return this instanceof $e}isVector(){return this instanceof x}isStruct(){return this instanceof l}isU8(){return this instanceof me}isU16(){return this instanceof ut}isU32(){return this instanceof pt}isU64(){return this instanceof V}isU128(){return this instanceof dt}isU256(){return this instanceof lt}},G= exports.TypeTagBool =class n extends N{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},me= exports.TypeTagU8 =class n extends N{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},ut= exports.TypeTagU16 =class n extends N{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},pt= exports.TypeTagU32 =class n extends N{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},V= exports.TypeTagU64 =class n extends N{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},dt= exports.TypeTagU128 =class n extends N{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},lt= exports.TypeTagU256 =class n extends N{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},W= exports.TypeTagAddress =class n extends N{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},$e= exports.TypeTagSigner =class n extends N{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},fn= exports.TypeTagReference =class n extends N{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=N.deserialize(t);return new n(r)}},z= exports.TypeTagGeneric =class n extends N{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},x= exports.TypeTagVector =class n extends N{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new me)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=N.deserialize(t);return new n(r)}},l= exports.TypeTagStruct =class n extends N{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=we.deserialize(t);return new n(r)}isTypeTag(t,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},we= exports.StructTag =class n extends d{constructor(e,t,r,o){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=E.deserialize(e),o=E.deserialize(e),i=e.deserializeVector(N);return new n(t,r,o,i)}};function ag(){return new we(u.ONE,new E("aptos_coin"),new E("AptosCoin"),[])}function S(){return new we(u.ONE,new E("string"),new E("String"),[])}function cg(n){return new we(u.ONE,new E("option"),new E("Option"),[n])}function j(n){return new we(u.ONE,new E("object"),new E("Object"),[n])}function vs(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return D.deserialize(n);case 1:return k.deserialize(n);case 2:return ie.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,D);case 5:return I.deserialize(n);case 6:return re.deserialize(n);case 7:return oe.deserialize(n);case 8:return se.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Ve=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ct.load(e);case 2:return Pt.load(e);case 3:return Et.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ct= exports.TransactionPayloadScript =class n extends Ve{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=It.deserialize(e);return new n(t)}},Pt= exports.TransactionPayloadEntryFunction =class n extends Ve{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Le.deserialize(e);return new n(t)}},Et= exports.TransactionPayloadMultiSig =class n extends Ve{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Ut.deserialize(e);return new n(t)}},Le= exports.EntryFunction =class n{constructor(e,t,r,o){this.module_name=e,this.function_name=t,this.type_args=r,this.args=o}static build(e,t,r,o){return new n(vt.fromStr(e),new E(t),r,o)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=vt.deserialize(e),r=E.deserialize(e),o=e.deserializeVector(N),i=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<i;a+=1){let c=e.deserializeUleb128AsU32(),p=Zt.deserialize(e,c);s.push(p)}return new n(t,r,o,s)}},It= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(N),o=e.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<o;s+=1){let a=vs(e);i.push(a)}return new n(t,r,i)}},Ut= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),o;return r&&(o=Rt.deserialize(e)),new n(t,o)}},Rt= 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(Le.deserialize(e))}};var F=class n extends d{constructor(e,t,r,o,i,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=o,this.gas_unit_price=i,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=e.deserializeU64(),o=Ve.deserialize(e),i=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=ct.deserialize(e);return new n(t,r,o,i,s,a,c)}},hn= exports.RawTransactionWithData =class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _e.load(e);case 1:return Se.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},_e= exports.MultiAgentRawTransaction =class n extends hn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=F.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},Se= exports.FeePayerRawTransaction =class n extends hn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=F.deserialize(e),r=e.deserializeVector(u),o=u.deserialize(e);return new n(t,r,o)}};var ye=class n extends d{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=F.deserialize(e),r=be.deserialize(e);return new n(t,r)}};var Tn=class n extends d{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=F.deserialize(e),r=e.deserializeBool(),o;return r&&(o=u.deserialize(e)),new n(t,o)}};function Oo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Bo(n){return!!n.match(/\s/)}function Cs(n){return!!n.match(/^T[0-9]+$/)}function Ps(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Bo(r))break}return t}var Es=(y=>(y.InvalidTypeTag="unknown type",y.UnexpectedGenericType="unexpected generic type",y.UnexpectedTypeArgumentClose="unexpected '>'",y.UnexpectedWhitespaceCharacter="unexpected whitespace character",y.UnexpectedComma="unexpected ','",y.TypeArgumentCountMismatch="type argument count doesn't match expected amount",y.MissingTypeArgumentClose="no matching '>' for '<'",y.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",y.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",y.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",y.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",y.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",y))(Es||{}),v= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function xe(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _82 => _82.allowGenerics]), () => (!1)),r=[],o=[],i=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:i}),a="",i=[],c=1;else if(p===">"){if(a!==""){let ke=bn(a,o,t);i.push(ke)}let f=r.pop();if(f===void 0)throw new v(n,"unexpected '>'");if(c!==i.length)throw new v(n,"type argument count doesn't match expected amount");let{savedStr:C,savedTypes:y,savedExpectedTypes:g}=f;o=i,i=y,a=C,c=g}else if(p===","){if(a.length!==0){let f=bn(a,o,t);o=[],i.push(f),a="",c+=1}}else if(Bo(p)){let f=!1;if(a.length!==0){let y=bn(a,o,t);o=[],i.push(y),a="",f=!0}s=Ps(n,s);let C=n[s];if(s<n.length&&f&&C!==","&&C!==">")throw new v(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new v(n,"no matching '>' for '<'");switch(i.length){case 0:return bn(a,o,t);case 1:if(a==="")return i[0];throw new v(n,"unexpected ','");default:throw new v(n,"unexpected whitespace character")}}function bn(n,e,t){switch(n){case"&signer":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new fn(new $e);case"signer":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new $e;case"bool":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new G;case"address":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new W;case"u8":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new me;case"u16":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new ut;case"u32":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new pt;case"u64":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new V;case"u128":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new dt;case"u256":if(e.length>0)throw new v(n,"primitive types not expected to have type arguments");return new lt;case"vector":if(e.length!==1)throw new v(n,"vector type expected to have exactly one type argument");return new x(e[0]);default:if(Cs(n)){if(t)return new z(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(!Oo(r[1]))throw new v(n,"module name must only contain alphanumeric or '_' characters");if(!Oo(r[2]))throw new v(n,"struct name must only contain alphanumeric or '_' characters");return new l(new we(u.fromString(r[0]),new E(r[1]),new E(r[2]),e))}}function Fo(n){return typeof n=="boolean"}function gt(n){return typeof n=="string"}function wn(n){return typeof n=="number"}function _n(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Mo(n){return n==null}function Ko(n){return Jn(n)||tr(n)||nr(n)||rr(n)||or(n)||ir(n)||sr(n)||Sn(n)||er(n)||Is(n)||n instanceof T||n instanceof Ee}function Jn(n){return n instanceof I}function Sn(n){return n instanceof u}function er(n){return n instanceof w}function Is(n){return n instanceof Be}function tr(n){return n instanceof D}function nr(n){return n instanceof re}function rr(n){return n instanceof oe}function or(n){return n instanceof k}function ir(n){return n instanceof ie}function sr(n){return n instanceof se}function qo(n){return"bytecode"in n}function P(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function $o(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function Nt(n){let e=n.split("::");if(e.length!==3)throw new Error(`Invalid function ${n}`);let t=e[0],r=e[1],o=e[2];return{moduleAddress:t,moduleName:r,functionName:o}}var Us=new TextEncoder;function cr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _83 => _83.map, 'call', _84 => _84(e=>gt(e)?xe(e):e)]), () => ([]))}async function Vo(n,e,t,r){let o=await pn({aptosConfig:r,accountAddress:n,moduleName:e});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===t)}async function Lo(n,e,t,r){let o=await Vo(n,e,t,r);if(!o)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!o.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let i=$o(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(xe(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Ho(n,e,t,r){let o=await Vo(n,e,t,r);if(!o)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!o.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let i=[];for(let a=0;a<o.params.length;a+=1)i.push(xe(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(xe(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function ur(n,e,t,r,o){if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let i=e.parameters[r];return mt(t,i,r,o)}function mt(n,e,t,r){return Ko(n)?(ar(e,n,t),n):Rs(n,e,t,r)}function Rs(n,e,t,r){if(e.isBool()){if(Fo(n))return new I(n);P("boolean",t)}if(e.isAddress()){if(gt(n))return u.fromString(n);P("string | AccountAddress",t)}if(e.isU8()){if(wn(n))return new D(n);P("number",t)}if(e.isU16()){if(wn(n))return new re(n);P("number",t)}if(e.isU32()){if(wn(n))return new oe(n);P("number",t)}if(e.isU64()){if(_n(n))return new k(BigInt(n));P("bigint | number | string",t)}if(e.isU128()){if(_n(n))return new ie(BigInt(n));P("bigint | number | string",t)}if(e.isU256()){if(_n(n))return new se(BigInt(n));P("bigint | number | string",t)}if(e.isGeneric()){let o=e.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return mt(n,r[o],t,r)}if(e.isVector()){if(e.value.isU8()){if(gt(n))return T.U8(Us.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=>mt(o,e.value,t,r)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(gt(n))return new w(n);P("string",t)}if(e.isObject()){if(gt(n))return u.fromString(n);P("string | AccountAddress",t)}if(e.isOption())return Mo(n)?new Ee(null):new Ee(mt(n,e.value.typeArgs[0],t,r));throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function ar(n,e,t){if(n.isBool()){if(Jn(e))return;P("Bool",t)}if(n.isAddress()){if(Sn(e))return;P("AccountAddress",t)}if(n.isU8()){if(tr(e))return;P("U8",t)}if(n.isU16()){if(nr(e))return;P("U16",t)}if(n.isU32()){if(rr(e))return;P("U32",t)}if(n.isU64()){if(or(e))return;P("U64",t)}if(n.isU128()){if(ir(e))return;P("U128",t)}if(n.isU256()){if(sr(e))return;P("U256",t)}if(n.isVector()){if(e instanceof T){e.values.length>0&&ar(n.value,e.values[0],t);return}P("MoveVector",t)}if(n instanceof l){if(n.isString()){if(er(e))return;P("MoveString",t)}if(n.isObject()){if(Sn(e))return;P("AccountAddress",t)}if(n.isOption()){if(e instanceof Ee){e.value!==void 0&&ar(n.value.typeArgs[0],e.value,t);return}P("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}var xn=class n extends d{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=F.deserialize(e),r=e.deserializeVector(u),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(t,r,i)}};async function Cn(n){if(qo(n))return ks(n);let{moduleAddress:e,moduleName:t,functionName:r}=Nt(n.function),o=await Jo({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Lo});return Ns({abi:o,...n})}function Ns(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=Nt(n.function),i=cr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=n.functionArguments.map((c,p)=>ur(n.function,e,c,p,i));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);let a=Le.build(`${t}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Et(new Ut(c,new Rt(a)))}return new Pt(a)}async function Wo(n){let{moduleAddress:e,moduleName:t,functionName:r}=Nt(n.function),o=await Jo({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ho});return zs({abi:o,...n})}function zs(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=Nt(n.function),i=cr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _85 => _85.functionArguments, 'optionalAccess', _86 => _86.map, 'call', _87 => _87((a,c)=>ur(n.function,e,a,c,i))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);return Le.build(`${t}::${r}`,o,i,s)}function ks(n){return new Ct(new It(h.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function Ds(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=Bn[e.network]?Promise.resolve({chain_id:Bn[e.network]}):sn({aptosConfig:e}),a=_optionalChain([o, 'optionalAccess', _88 => _88.gasUnitPrice])?Promise.resolve({gas_estimate:o.gasUnitPrice}):ln({aptosConfig:e}),[{chain_id:c},{gas_estimate:p}]=await Promise.all([s,a]),f=_optionalChain([o, 'optionalAccess', _89 => _89.accountSequenceNumber])!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):le({aptosConfig:e,accountAddress:t}),C;if(i&&u.from(i).equals(u.ZERO))try{let{sequence_number:Tt}=await f;C=Tt}catch (e2){C="0"}else{let{sequence_number:Tt}=await f;C=Tt}let{maxGasAmount:y,gasUnitPrice:g,expireTimestamp:ke}={maxGasAmount:_optionalChain([o, 'optionalAccess', _90 => _90.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(p),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...o};return new F(u.from(t),BigInt(C),r,BigInt(y),BigInt(g),BigInt(ke),new ct(c))}async function pr(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=await Ds({aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _91 => _91.secondarySignerAddresses, 'optionalAccess', _92 => _92.map, 'call', _93 => _93(c=>u.from(c))]), () => ([]));return new xn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Tn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function jo(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=vn(e);if(t.feePayerAddress){let a=new Se(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];r&&(c=r.map(C=>vn(C)));let p=vn(o),f=new st(i,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new ye(a.raw_txn,f).bcsToBytes()}if(t.secondarySignerAddresses){let a=new _e(t.rawTransaction,t.secondarySignerAddresses),c=[];c=r.map(f=>vn(f));let p=new it(i,t.secondarySignerAddresses,c);return new ye(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof de)s=new ot(i.public_key,i.signature);else if(i instanceof ae)s=new at(i);else throw new Error("Invalid public key");return new ye(t.rawTransaction,s).bcsToBytes()}function vn(n){if(n instanceof $){if(n.publicKey instanceof U)return new ae(n,new B(new R(new Uint8Array(64))));if(n.publicKey instanceof he)return new ae(n,new B(new Te(new Uint8Array(64))))}return new de(new U(n.toUint8Array()),new R(new Uint8Array(64)))}function Xo(n){let{signer:e,transaction:t}=n,r=lr(t);return e.signWithAuthenticator(r)}function dr(n){let{transaction:e,senderAuthenticator:t,feePayerAuthenticator:r,additionalSignersAuthenticators:o}=n,i=Zo(e);if((r||o)&&(i instanceof _e||i instanceof Se))return Os(i,t,r,o);if(t instanceof de&&i instanceof F){let s=new ot(t.public_key,t.signature);return new ye(i,s).bcsToBytes()}if((t instanceof ae||t instanceof Ze)&&i instanceof F){let s=new at(t);return new ye(i,s).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${t} is not a supported account authentication scheme`)}function Yo(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Gs=Yo(["APTOS::Transaction"]);function Bm(n){let e=dr(n);return new h(Yo([Gs,new Uint8Array([0]),e])).toString()}function Zo(n){return n.feePayerAddress?new Se(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new _e(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Os(n,e,t,r){if(n instanceof Se){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new st(e,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:t});return new ye(n.raw_txn,o).bcsToBytes()}if(n instanceof _e){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new it(e,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new ye(n.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function lr(n){let e=Zo(n),t=_sha3.sha3_256.create();if(e instanceof F)t.update(Or);else if(e instanceof _e)t.update(Fn);else if(e instanceof Se)t.update(Fn);else throw new Error(`Unknown transaction type to sign on: ${e}`);let r=t.digest(),o=e.bcsToBytes(),i=new Uint8Array(r.length+o.length);return i.set(r),i.set(o,r.length),i}async function Jo({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:o,abi:i,fetch:s}){return i||nt(async()=>s(e,t,r,o),`${n}-${o.network}-${e}-${t}-${r}`,1e3*60*5)()}async function A(n){let e=await Bs(n);return Fs(n,e)}async function Bs(n){let{aptosConfig:e,data:t}=n,r,o;return"bytecode"in t?o=await Cn(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments},o=await Cn(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments},o=await Cn(r)),o}async function Fs(n,e){let{aptosConfig:t,sender:r,options:o}=n,i;if(Ms(n)&&(i=u.ZERO.toString()),Ks(n)){let{secondarySignerAddresses:s}=n;return pr({aptosConfig:t,sender:r,payload:e,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return pr({aptosConfig:t,sender:r,payload:e,options:o,feePayerAddress:i})}function Ms(n){return n.withFeePayer===!0}function Ks(n){return"secondarySignerAddresses"in n}function ei(n){let{transaction:e}=n;return lr(e)}function Pn(n){return Xo({...n})}async function gr(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=jo({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}),{data:c}=await De({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _94 => _94.options, 'optionalAccess', _95 => _95.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _96 => _96.options, 'optionalAccess', _97 => _97.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.options, 'optionalAccess', _99 => _99.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function En(n){let{aptosConfig:e}=n,t=dr({...n}),{data:r}=await De({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function zt(n){let{aptosConfig:e,signer:t,transaction:r}=n,o=Pn({signer:t,transaction:r});return En({aptosConfig:e,transaction:r,senderAuthenticator:o})}var qs={typeParameters:[],parameters:[x.u8(),new x(x.u8())]};async function ti(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:o,options:i}=n,s=o.map(a=>T.U8(a));return A({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:qs},options:i})}var $s={typeParameters:[],parameters:[new me,x.u8(),new me,x.u8(),x.u8(),x.u8()]};async function ni(n){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:r}=n,o=await le({aptosConfig:e,accountAddress:t.accountAddress}),i=Ue.fromPrivateKey({privateKey:r,legacy:!0}),a=new An({sequenceNumber:BigInt(o.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),c=t.sign(a),p=i.sign(a),f=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new D(t.signingScheme),T.U8(t.publicKey.toUint8Array()),new D(i.signingScheme),T.U8(i.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:$s}});return zt({aptosConfig:e,signer:t,transaction:f})}var Vs={typeParameters:[{constraints:[]}],parameters:[new W,new V]};async function ri(n){let{aptosConfig:e,sender:t,recipient:r,amount:o,coinType:i,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(i, () => (Qt))],functionArguments:[r,o],abi:Vs},options:s})}var kt=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ri({aptosConfig:this.config,...e})}};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>"},te="0x4::token::Token";async function oi(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await m({aptosConfig:e,query:{query:Ao,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ii(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await m({aptosConfig:e,query:{query:Hn,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function si(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},i={query:Hn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _100 => _100.offset]),limit:_optionalChain([r, 'optionalAccess', _101 => _101.limit]),order_by:_optionalChain([r, 'optionalAccess', _102 => _102.orderBy])}};return(await m({aptosConfig:e,query:i,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function ai(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,o={token_data_id:{_eq:u.from(t).toStringLong()}},i={query:yo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _103 => _103.offset]),limit:_optionalChain([r, 'optionalAccess', _104 => _104.limit]),order_by:_optionalChain([r, 'optionalAccess', _105 => _105.orderBy])}};return(await m({aptosConfig:e,query:i,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ls={typeParameters:[],parameters:[new l(S()),new V,new l(S()),new l(S()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new V,new V]};async function ci(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new k(_nullishCoalesce(n.maxSupply, () => (Ge))),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:Ls},options:t})}async function mr(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:o}=n,i=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _106 => _106.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _107 => _107.tokenStandard]), () => ("v2"))}),(await m({aptosConfig:e,query:{query:$n,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function ui(n){let{aptosConfig:e,collectionId:t}=n,o={collection_id:{_eq:u.from(t).toStringLong()}};return(await m({aptosConfig:e,query:{query:$n,variables:{where_condition:o}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function pi(n){return(await mr(n)).collection_id}var Hs={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 di(n){let{aptosConfig:e,options:t,creator:r,collection:o,description:i,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:f}=n,C=_optionalChain([p, 'optionalAccess', _108 => _108.map, 'call', _109 => _109(y=>Re[y])]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(o),new w(i),new w(s),new w(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(C, () => ([]))),vi(_nullishCoalesce(f, () => ([])),_nullishCoalesce(C, () => ([])))],abi:Hs},options:t})}var Qs={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new W]};async function li(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(r),u.from(o)],abi:Qs},options:s})}var Ws={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 W]};async function gi(n){let{aptosConfig:e,account:t,collection:r,description:o,name:i,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:f,options:C}=n;if(_optionalChain([c, 'optionalAccess', _110 => _110.length])!==_optionalChain([f, 'optionalAccess', _111 => _111.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _112 => _112.length])!==_optionalChain([f, 'optionalAccess', _113 => _113.length]))throw new Error("Property types and property values counts do not match");let y=_optionalChain([p, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(g=>Re[g])]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,i,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(y, () => ([]))),vi(_nullishCoalesce(f, () => ([])),_nullishCoalesce(y, () => ([]))),a],abi:Ws},options:C})}var js={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0)))]};async function mi(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[u.from(r)],abi:js},options:i})}var Xs={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0)))]};async function yi(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[r],abi:Xs},options:i})}var Ys={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0)))]};async function Ai(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[r],abi:Ys},options:i})}var Zs={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S())]};async function fi(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:Zs},options:s})}var Js={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S())]};async function hi(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:Js},options:s})}var ea={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S())]};async function Ti(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:ea},options:s})}var ta={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S()),new l(S()),x.u8()]};async function bi(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (te))],functionArguments:[u.from(s),new w(r),new w(Re[o]),T.U8(yr(i,Re[o]))],abi:ta},options:c})}var na={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S())]};async function wi(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:na},options:s})}var ra={typeParameters:[{constraints:["key"]}],parameters:[new l(j(new z(0))),new l(S()),new l(S()),x.u8()]};async function _i(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (te))],functionArguments:[u.from(s),new w(r),new w(Re[o]),yr(i,Re[o])],abi:ra},options:c})}var oa={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(j(new z(0))),new l(S()),new z(1)]};async function Si(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (te)),Re[o]],functionArguments:[u.from(s),new w(r),i],abi:oa},options:c})}var ia={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new l(j(new z(0))),new l(S()),new z(1)]};async function xi(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (te)),Re[o]],functionArguments:[u.from(s),new w(r),i],abi:ia},options:c})}function vi(n,e){let t=new Array;return e.forEach((r,o)=>{t.push(yr(n[o],r))}),t}function yr(n,e){let t=xe(e);return mt(n,t,0,[]).bcsToBytes()}var Dt=class{constructor(e){this.config=e}async getCollectionData(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),mr({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ui({aptosConfig:this.config,...e})}async getCollectionId(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pi({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oi({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ii({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),si({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ai({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return ci({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return di({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return li({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return gi({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return mi({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return yi({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Ai({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return fi({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return hi({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ti({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return bi({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wi({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return _i({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Si({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return xi({aptosConfig:this.config,...e})}};var Ci=300,sa=n=>{if(n&&n.length>Ci)throw new Error(`Event type length exceeds the maximum length of ${Ci}`)};async function Pi(n){let{aptosConfig:e,eventType:t,options:r}=n,i={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:t}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _116 => _116.orderBy])};return Gt({aptosConfig:e,options:i})}async function Ei(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:o}=n,a={where:{account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _117 => _117.orderBy])};return Gt({aptosConfig:t,options:a})}async function Ii(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:o}=n,a={where:{account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _118 => _118.orderBy])};return Gt({aptosConfig:t,options:a})}async function Gt(n){let{aptosConfig:e,options:t}=n;sa(_optionalChain([t, 'optionalAccess', _119 => _119.where, 'optionalAccess', _120 => _120.indexed_type, 'optionalAccess', _121 => _121._eq]));let r={query:lo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _122 => _122.where]),offset:_optionalChain([t, 'optionalAccess', _123 => _123.offset]),limit:_optionalChain([t, 'optionalAccess', _124 => _124.limit]),order_by:_optionalChain([t, 'optionalAccess', _125 => _125.orderBy])}};return(await m({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Ot=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Pi({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ei({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await b({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ii({aptosConfig:this.config,...e})}async getEvents(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _126 => _126.minimumLedgerVersion]),processorType:"events_processor"}),Gt({aptosConfig:this.config,...e})}};async function Ui(n){let{aptosConfig:e,accountAddress:t,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _127 => _127.timeoutSecs])||20,{data:s}=await Kr({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await rt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _128 => _128.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Bt=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ui({aptosConfig:this.config,...e});return _optionalChain([e, 'access', _129 => _129.options, 'optionalAccess', _130 => _130.waitForIndexer])!==!1&&await mn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version)}),t}};async function Ar(n){let{aptosConfig:e,options:t}=n,r={query:mo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _131 => _131.where]),limit:_optionalChain([t, 'optionalAccess', _132 => _132.limit]),offset:_optionalChain([t, 'optionalAccess', _133 => _133.offset])}};return(await m({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Ri(n){let{aptosConfig:e,options:t}=n,r={query:go,variables:{where_condition:_optionalChain([t, 'optionalAccess', _134 => _134.where]),limit:_optionalChain([t, 'optionalAccess', _135 => _135.limit]),offset:_optionalChain([t, 'optionalAccess', _136 => _136.offset])}};return(await m({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ni(n){let{aptosConfig:e,options:t}=n,r={query:uo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _137 => _137.where]),limit:_optionalChain([t, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([t, 'optionalAccess', _139 => _139.offset])}};return(await m({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var aa={typeParameters:[],parameters:[xe("0x1::object::Object"),new W,new V]};async function zi(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:o,amount:i,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,i],abi:aa},options:s})}var Ft=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _140 => _140.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ar({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _141 => _141.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Ar({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetActivities(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _142 => _142.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ri({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ni({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return zi({aptosConfig:this.config,...e})}};async function Ne(n){let{aptosConfig:e,payload:t,options:r}=n,o=await Wo({...t,aptosConfig:e}),i=new Y;o.serialize(i);let s=i.toUint8Array(),{data:a}=await De({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _144 => _144.ledgerVersion])},body:s});return a}var Mt=class{constructor(e){this.config=e}async getLedgerInfo(){return sn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return fo({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ho({aptosConfig:this.config,...e})}async getTableItem(e){return an({aptosConfig:this.config,...e})}async view(e){return Ne({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return To({aptosConfig:this.config,...e})}async queryIndexer(e){return m({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return cn({aptosConfig:this.config})}async getProcessorStatus(e){return un({aptosConfig:this.config,processorType:e})}};var ki=["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 Di(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function ze(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Di(e))throw new Error(`${e} is not valid. ${ki}`);if(t&&!Di(t))throw new Error(`${t} is not valid. ${ki}`);return{domainName:t||e,subdomainName:t?e:void 0}}var ca="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ua={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:ca,custom:null,devnet:null,randomnet:null};function ve(n){let e=ua[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var In=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Gi(n){let{aptosConfig:e,name:t}=n,r=ve(e),{domainName:o,subdomainName:i}=ze(t),s=await Ne({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=In(s[0]);return a?u.from(a):void 0}async function Oi(n){let{aptosConfig:e,expiration:t,name:r,sender:o,targetAddress:i,toAddress:s,options:a,transferable:c}=n,p=ve(e),{domainName:f,subdomainName:C}=ze(r),y=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(C&&!y)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(y&&!C)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let wr=_nullishCoalesce(t.years, () => (1));if(wr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let es=wr*31536e3;return await A({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[f,es,i,s]},options:a})}if(!C)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await fr({aptosConfig:e,name:f});if(!g)throw new Error("The domain does not exist");let ke=t.policy==="subdomain:independent"?t.expirationDate:g;if(ke>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[f,C,Math.round(ke/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function fr(n){let{aptosConfig:e,name:t}=n,r=ve(e),{domainName:o,subdomainName:i}=ze(t);try{let s=await Ne({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,i]}});return Number(s[0])*1e3}catch (e3){return}}async function Bi(n){let{aptosConfig:e,address:t}=n,r=ve(e),o=await Ne({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),i=In(o[1]),s=In(o[0]);if(i)return[s,i].filter(Boolean).join(".")}async function Fi(n){let{aptosConfig:e,sender:t,name:r,options:o}=n,i=ve(e);if(!r)return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:s,subdomainName:a}=ze(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::set_primary_name`,functionArguments:[s,a]},options:o})}async function Mi(n){let{aptosConfig:e,name:t}=n,r=ve(e),{domainName:o,subdomainName:i}=ze(t),s=await Ne({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=In(s[0]);return a?u.from(a):void 0}async function Ki(n){let{aptosConfig:e,sender:t,name:r,address:o,options:i}=n,s=ve(e),{domainName:a,subdomainName:c}=ze(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,o]},options:i})}async function qi(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:o=""}=ze(t),a=(await m({aptosConfig:e,query:{query:tt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Kt(a)),a}async function $i(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await hr({aptosConfig:e});return(await m({aptosConfig:e,originMethod:"getAccountNames",query:{query:tt,variables:{limit:_optionalChain([t, 'optionalAccess', _145 => _145.limit]),offset:_optionalChain([t, 'optionalAccess', _146 => _146.offset]),order_by:_optionalChain([t, 'optionalAccess', _147 => _147.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _148 => _148.options, 'optionalAccess', _149 => _149.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Kt)}async function Vi(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await hr({aptosConfig:e});return(await m({aptosConfig:e,originMethod:"getAccountDomains",query:{query:tt,variables:{limit:_optionalChain([t, 'optionalAccess', _150 => _150.limit]),offset:_optionalChain([t, 'optionalAccess', _151 => _151.offset]),order_by:_optionalChain([t, 'optionalAccess', _152 => _152.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _153 => _153.options, 'optionalAccess', _154 => _154.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Kt)}async function Li(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await hr({aptosConfig:e});return(await m({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:tt,variables:{limit:_optionalChain([t, 'optionalAccess', _155 => _155.limit]),offset:_optionalChain([t, 'optionalAccess', _156 => _156.offset]),order_by:_optionalChain([t, 'optionalAccess', _157 => _157.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _158 => _158.options, 'optionalAccess', _159 => _159.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Kt)}async function Hi(n){let{aptosConfig:e,options:t,domain:r}=n;return(await m({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:tt,variables:{limit:_optionalChain([t, 'optionalAccess', _160 => _160.limit]),offset:_optionalChain([t, 'optionalAccess', _161 => _161.offset]),order_by:_optionalChain([t, 'optionalAccess', _162 => _162.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _163 => _163.options, 'optionalAccess', _164 => _164.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(Kt)}async function hr(n){let{aptosConfig:e}=n,t=ve(e),[r]=await Ne({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-o)).toISOString()}async function Qi(n){let{aptosConfig:e,sender:t,name:r,years:o=1,options:i}=n,s=ve(e),a=o*31536e3,{domainName:c,subdomainName:p}=ze(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 A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:i})}function Kt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var qt=class{constructor(e){this.config=e}async getOwnerAddress(e){return Gi({aptosConfig:this.config,...e})}async getExpiration(e){return fr({aptosConfig:this.config,...e})}async getTargetAddress(e){return Mi({aptosConfig:this.config,...e})}async setTargetAddress(e){return Ki({aptosConfig:this.config,...e})}async getPrimaryName(e){return Bi({aptosConfig:this.config,...e})}async setPrimaryName(e){return Fi({aptosConfig:this.config,...e})}async registerName(e){return Oi({aptosConfig:this.config,...e})}async renewDomain(e){return Qi({aptosConfig:this.config,...e})}async getName(e){return qi({aptosConfig:this.config,...e})}async getAccountNames(e){return $i({aptosConfig:this.config,...e})}async getAccountDomains(e){return Vi({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Li({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Hi({aptosConfig:this.config,...e})}};async function Wi(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),i=await m({aptosConfig:e,query:{query:Vn,variables:{where_condition:{pool_address:{_eq:r}}}}});return i.num_active_delegator_per_pool[0]?i.num_active_delegator_per_pool[0].num_active_delegator:0}async function ji(n){let{aptosConfig:e,options:t}=n,r={query:Vn,variables:{order_by:_optionalChain([t, 'optionalAccess', _165 => _165.orderBy])}};return(await m({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Xi(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,o={query:po,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await m({aptosConfig:e,query:o})).delegated_staking_activities}var $t=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _166 => _166.minimumLedgerVersion]),processorType:"stake_processor"}),Wi({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _167 => _167.minimumLedgerVersion]),processorType:"stake_processor"}),ji({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await b({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _168 => _168.minimumLedgerVersion]),processorType:"stake_processor"}),Xi({aptosConfig:this.config,...e})}};var Un=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async multiAgent(e){return A({aptosConfig:this.config,...e})}};function Tr(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},t}function br(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},t}var yt=class{constructor(e){this.config=e}async simple(e){return gr({aptosConfig:this.config,...e})}async multiAgent(e){return gr({aptosConfig:this.config,...e})}};M([br],yt.prototype,"simple",1),M([br],yt.prototype,"multiAgent",1);var At=class{constructor(e){this.config=e}async simple(e){return En({aptosConfig:this.config,...e})}async multiAgent(e){return En({aptosConfig:this.config,...e})}};M([Tr],At.prototype,"simple",1),M([Tr],At.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Rn=()=>Math.floor(Date.now()/1e3),Nn= exports.AccountSequenceNumber =class{constructor(e,t,r,o,i){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=i}async nextSequenceNumber(){for(;this.lock;)await ge(this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=Rn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await ge(this.sleepTime),Rn()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await le({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await le({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await ge(this.sleepTime);this.lock=!0;try{await this.update();let e=Rn();for(;this.lastUncommintedNumber!==this.currentNumber;)Rn()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await ge(this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var ft=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _169 => _169.pendingDequeue, 'access', _170 => _170.shift, 'call', _171 => _171(), 'optionalAccess', _172 => _172.resolve, 'call', _173 => _173(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new ht("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},ht=class extends Error{};var Yi="fulfilled",Zi= exports.TransactionWorkerEventsEnum =(i=>(i.TransactionSent="transactionSent",i.TransactionSendFailed="transactionSendFailed",i.TransactionExecuted="transactionExecuted",i.TransactionExecutionFailed="transactionExecutionFailed",i.ExecutionFinish="executionFinish",i))(Zi||{}),zn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,o=30,i=100,s=10){super();this.taskQueue=new ft;this.transactionsQueue=new ft;this.outstandingTransactions=new ft;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Nn(t,r,o,i,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let o=zt({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,t])}}catch(t){if(t instanceof ht)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[o,i]=await this.outstandingTransactions.dequeue();for(t.push(o),r.push(i);!this.outstandingTransactions.isEmpty();)[o,i]=await this.outstandingTransactions.dequeue(),t.push(o),r.push(i);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];i=r[a],c.status===Yi?(this.sentTransactions.push([c.value.hash,i,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,i)):(this.sentTransactions.push([c.status,i,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof ht)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let o=[];o.push(rt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let i=await Promise.allSettled(o);for(let s=0;s<i.length;s+=1){let a=i[s];a.status===Yi?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[o,i]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:o,options:{...i,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var kn=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new zn(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let o of t)this.transactionWorker.push(o,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.start({sender:t}),this.push({data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Vt=class{constructor(e){this.config=e,this.build=new Un(this.config),this.simulate=new yt(this.config),this.submit=new At(this.config),this.batch=new kn(this.config)}async getTransactions(e){return ko({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Do({aptosConfig:this.config,...e})}async getTransactionByHash(e){return gn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return Go({aptosConfig:this.config,...e})}async waitForTransaction(e){return rt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return ln({aptosConfig:this.config})}getSigningMessage(e){return ei(e)}async publishPackageTransaction(e){return ti({aptosConfig:this.config,...e})}async rotateAuthKey(e){return ni({aptosConfig:this.config,...e})}sign(e){return Pn({...e})}signAsFeePayer(e){let{signer:t,transaction:r}=e;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=t.accountAddress,Pn({signer:t,transaction:r})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.batch.forSingleAccount({sender:t,data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){let{signer:t,transaction:r}=e;return zt({aptosConfig:this.config,signer:t,transaction:r})}};var ne=class{constructor(e){this.config=new yn(e),this.account=new xt(this.config),this.ans=new qt(this.config),this.coin=new kt(this.config),this.digitalAsset=new Dt(this.config),this.event=new Ot(this.config),this.faucet=new Bt(this.config),this.fungibleAsset=new Ft(this.config),this.general=new Mt(this.config),this.staking=new $t(this.config),this.transaction=new Vt(this.config)}};function Ae(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(e.prototype,r);o&&(o.value=function(...i){return this[t][r](...i)},Object.defineProperty(n.prototype,r,o))})}Ae(ne,xt,"account");Ae(ne,qt,"ans");Ae(ne,kt,"coin");Ae(ne,Dt,"digitalAsset");Ae(ne,Ot,"event");Ae(ne,Bt,"faucet");Ae(ne,Ft,"fungibleAsset");Ae(ne,Mt,"general");Ae(ne,$t,"staking");Ae(ne,Vt,"transaction");var _child_process = require('child_process');var _treekill = require('tree-kill'); var _treekill2 = _interopRequireDefault(_treekill);var Ji=class{constructor(){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.process=null}stop(){_optionalChain([this, 'access', _174 => _174.process, 'optionalAccess', _175 => _175.pid])&&_treekill2.default.call(void 0, this.process.pid)}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let r=_child_process.spawn.call(void 0, "npx",["aptos","node","run-local-testnet","--force-restart","--assume-yes","--with-indexer-api"]);this.process=r,_optionalChain([r, 'access', _176 => _176.stderr, 'optionalAccess', _177 => _177.on, 'call', _178 => _178("data",o=>{let i=o.toString();console.log(i)})]),_optionalChain([r, 'access', _179 => _179.stdout, 'optionalAccess', _180 => _180.on, 'call', _181 => _181("data",o=>{let i=o.toString();console.log(i)})])}async waitUntilProcessIsUp(){let e=await this.checkIfProcessIsUp(),t=Date.now()/1e3,r=t;for(;!e&&t+this.MAXIMUM_WAIT_TIME_SEC>r;)await ge(1e3),e=await this.checkIfProcessIsUp(),r=Date.now()/1e3;if(!e)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch (e4){return!1}}};exports.APTOS_BIP44_REGEX = As; exports.APTOS_COIN = Qt; exports.APTOS_HARDENED_REGEX = ys; exports.Account = Ue; exports.AccountAddress = u; exports.AccountAuthenticator = Q; exports.AccountAuthenticatorEd25519 = de; exports.AccountAuthenticatorMultiEd25519 = rn; exports.AccountAuthenticatorMultiKey = Ze; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = Pr; exports.AccountPublicKey = ue; exports.AccountSequenceNumber = Nn; exports.AddressInvalidReason = ds; exports.AnyPublicKey = $; exports.AnyPublicKeyVariant = Er; exports.AnySignature = B; exports.AnySignatureVariant = Ir; exports.Aptos = ne; exports.AptosApiError = ce; exports.AptosApiType = wt; exports.AptosConfig = yn; exports.AuthenticationKey = q; exports.Bool = I; exports.CKDPriv = Wr; exports.ChainId = ct; exports.DEFAULT_MAX_GAS_AMOUNT = Dr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Gr; exports.DEFAULT_TXN_TIMEOUT_SEC = Ht; exports.DeriveScheme = Rr; exports.Deserializer = $r; exports.Ed25519Account = Je; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = U; exports.Ed25519Signature = R; exports.EntryFunction = Le; exports.EntryFunctionBytes = Zt; exports.FeePayerRawTransaction = Se; exports.FixedBytes = Be; exports.HARDENED_OFFSET = Lr; exports.Hex = h; exports.HexInvalidReason = cs; exports.Identifier = E; exports.KeyType = fs; exports.LocalNode = Ji; exports.MimeType = Lt; exports.ModuleId = vt; exports.MoveAbility = Ur; exports.MoveFunctionVisibility = rs; exports.MoveOption = Ee; exports.MoveString = w; exports.MoveVector = T; exports.MultiAgentRawTransaction = _e; exports.MultiEd25519PublicKey = Xe; exports.MultiEd25519Signature = Me; exports.MultiKey = nn; exports.MultiKeySignature = Zr; exports.MultiSig = Ut; exports.MultiSigTransactionPayload = Rt; exports.Network = On; exports.NetworkToChainId = Bn; exports.NetworkToFaucetAPI = kr; exports.NetworkToIndexerAPI = Nr; exports.NetworkToNetworkName = Na; exports.NetworkToNodeAPI = zr; exports.ParsingError = K; exports.ProcessorType = He; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Or; exports.RAW_TRANSACTION_WITH_DATA_SALT = Fn; exports.RawTransaction = F; exports.RawTransactionWithData = hn; exports.RoleType = os; exports.RotationProofChallenge = An; exports.Script = It; exports.ScriptTransactionArgumentVariants = bt; exports.Secp256k1PrivateKey = qe; exports.Secp256k1PublicKey = he; exports.Secp256k1Signature = Te; exports.Serializable = d; exports.Serializer = Y; exports.Signature = Z; exports.SignedTransaction = ye; exports.SigningScheme = Ce; exports.SigningSchemeInput = Gn; exports.SimpleTransaction = Tn; exports.SingleKeyAccount = et; exports.StructTag = we; exports.TransactionAuthenticator = be; exports.TransactionAuthenticatorEd25519 = ot; exports.TransactionAuthenticatorFeePayer = st; exports.TransactionAuthenticatorMultiAgent = it; exports.TransactionAuthenticatorMultiEd25519 = Zn; exports.TransactionAuthenticatorSingleSender = at; exports.TransactionAuthenticatorVariant = Cr; exports.TransactionPayload = Ve; exports.TransactionPayloadEntryFunction = Pt; exports.TransactionPayloadMultiSig = Et; exports.TransactionPayloadScript = Ct; exports.TransactionPayloadVariants = xr; exports.TransactionResponseType = Dn; exports.TransactionVariants = vr; exports.TransactionWorker = zn; exports.TransactionWorkerEventsEnum = Zi; exports.TypeTag = N; exports.TypeTagAddress = W; exports.TypeTagBool = G; exports.TypeTagGeneric = z; exports.TypeTagParserError = v; exports.TypeTagParserErrorType = Es; exports.TypeTagReference = fn; exports.TypeTagSigner = $e; exports.TypeTagStruct = l; exports.TypeTagU128 = dt; exports.TypeTagU16 = ut; exports.TypeTagU256 = lt; exports.TypeTagU32 = pt; exports.TypeTagU64 = V; exports.TypeTagU8 = me; exports.TypeTagVariants = Sr; exports.TypeTagVector = x; exports.U128 = ie; exports.U16 = re; exports.U256 = se; exports.U32 = oe; exports.U64 = k; exports.U8 = D; exports.aptosCoinStructTag = ag; exports.aptosRequest = Wt; exports.buildTransaction = pr; exports.checkOrConvertArgument = mt; exports.convertArgument = ur; exports.createObjectAddress = bs; exports.createResourceAddress = ld; exports.createTokenAddress = gd; exports.deriveKey = qn; exports.deriveTransactionType = Zo; exports.deserializeFromScriptArgument = vs; exports.ensureBoolean = Kn; exports.fetchEntryFunctionAbi = Lo; exports.fetchFunctionAbi = Vo; exports.fetchViewFunctionAbi = Ho; exports.findFirstNonSignerArg = $o; exports.generateMultiSignersSignedTransaction = Os; exports.generateRawTransaction = Ds; exports.generateSignedTransaction = dr; exports.generateSignedTransactionForSimulation = jo; exports.generateSigningMessage = lr; exports.generateTransactionPayload = Cn; exports.generateTransactionPayloadWithABI = Ns; exports.generateUserTransactionHash = Bm; exports.generateViewFunctionPayload = Wo; exports.generateViewFunctionPayloadWithABI = zs; exports.get = Fr; exports.getAptosFullNode = X; exports.getAuthenticatorForSimulation = vn; exports.getFunctionParts = Nt; exports.hashValues = Yo; exports.isBcsAddress = Sn; exports.isBcsBool = Jn; exports.isBcsFixedBytes = Is; exports.isBcsString = er; exports.isBcsU128 = ir; exports.isBcsU16 = nr; exports.isBcsU256 = sr; exports.isBcsU32 = rr; exports.isBcsU64 = or; exports.isBcsU8 = tr; exports.isBlockMetadataTransactionResponse = _a; exports.isBool = Fo; exports.isEd25519Signature = va; exports.isEncodedEntryFunctionArgument = Ko; exports.isFeePayerSignature = Ea; exports.isGenesisTransactionResponse = wa; exports.isLargeNumber = _n; exports.isMultiAgentSignature = Pa; exports.isMultiEd25519Signature = Ia; exports.isNull = Mo; exports.isNumber = wn; exports.isPendingTransactionResponse = Ta; exports.isScriptDataInput = qo; exports.isSecp256k1Signature = Ca; exports.isStateCheckpointTransactionResponse = Sa; exports.isString = gt; exports.isUserTransactionResponse = ba; exports.isValidBIP44Path = Hr; exports.isValidHardenedPath = Qr; exports.isValidatorTransactionResponse = xa; exports.mnemonicToSeed = Jt; exports.objectStructTag = j; exports.optionStructTag = cg; exports.outOfRangeErrorMessage = us; exports.paginateWithCursor = Qe; exports.parseTypeTag = xe; exports.post = Mn; exports.postAptosFaucet = Kr; exports.postAptosFullNode = De; exports.postAptosIndexer = Mr; exports.promiseFulfilledStatus = Yi; exports.request = is; exports.sign = Xo; exports.splitPath = jr; exports.standardizeTypeTags = cr; exports.stringStructTag = S; exports.throwTypeMismatch = P; exports.validateNumberInRange = Pe;
428
+ `;async function Nn(n){let{aptosConfig:t}=n,{data:e}=await Z({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function Xi(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _32 => _32.withTransactions])}});return i}async function Yi(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _33 => _33.withTransactions])}});return i}async function Gn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await ot({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _34 => _34.ledgerVersion])},body:r})).data}async function Zi(n){let{aptosConfig:t,limit:e}=n;return(await A({aptosConfig:t,query:{query:qi,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function A(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Ui({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function Ka(n){let{aptosConfig:t}=n;return(await A({aptosConfig:t,query:{query:_r},originMethod:"getProcessorStatuses"})).processor_status}async function Fn(n){let t=await Ka({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function Mn(n){let{aptosConfig:t,processorType:e}=n;return(await A({aptosConfig:t,query:{query:_r,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var vr=new Map;function Ut(n,t,e){return async(...r)=>{if(vr.has(t)){let{value:o,timestamp:s}=vr.get(t);if(e===void 0||Date.now()-s<=e)return o}let i=await n(...r);return vr.set(t,{value:i,timestamp:Date.now()}),i}}async function we(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function to(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Et({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _35 => _35.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _36 => _36.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _37 => _37.limit]), () => (1e3))}})}async function qn(n){return _optionalChain([n, 'access', _38 => _38.options, 'optionalAccess', _39 => _39.ledgerVersion])!==void 0?Ji(n):Ut(async()=>Ji(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function Ji(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _40 => _40.ledgerVersion])}});return o}async function no(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Et({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _41 => _41.offset]),limit:_optionalChain([r, 'optionalAccess', _42 => _42.limit])}})}async function ro(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Et({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _43 => _43.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _44 => _44.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _45 => _45.limit]), () => (999))}})}async function Pr(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _46 => _46.ledgerVersion])}});return o.data}async function Cr(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await Pr({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Gn({aptosConfig:t,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof re&&a.data.error_code==="table_item_not_found")return s;throw a}}async function io(n){let{aptosConfig:t,accountAddress:e}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s=await A({aptosConfig:t,query:{query:Fi,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function oo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _47 => _47.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _48 => _48.tokenStandard])});let s={query:Ni,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _49 => _49.offset]),limit:_optionalChain([r, 'optionalAccess', _50 => _50.limit]),order_by:_optionalChain([r, 'optionalAccess', _51 => _51.orderBy])}};return(await A({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function so(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:i}=n,o=u.from(e).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _52 => _52.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _53 => _53.tokenStandard])});let c={query:Gi,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _54 => _54.offset]),limit:_optionalChain([i, 'optionalAccess', _55 => _55.limit]),order_by:_optionalChain([i, 'optionalAccess', _56 => _56.orderBy])}};return(await A({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _58 => _58.tokenStandard])}});let s={query:Ki,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _59 => _59.offset]),limit:_optionalChain([r, 'optionalAccess', _60 => _60.limit]),order_by:_optionalChain([r, 'optionalAccess', _61 => _61.orderBy])}};return(await A({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function co(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await A({aptosConfig:t,query:{query:Mi,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function uo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,i=u.from(e).toStringLong(),o=await Er({aptosConfig:t,accountAddress:i,options:{where:{asset_type:{_eq:r}}}});return o[0]?o[0].amount:0}async function Er(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _62 => _62.where]),owner_address:{_eq:i}},s={query:Bi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _63 => _63.offset]),limit:_optionalChain([r, 'optionalAccess', _64 => _64.limit]),order_by:_optionalChain([r, 'optionalAccess', _65 => _65.orderBy])}};return(await A({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function po(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await A({aptosConfig:t,query:{query:ki,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function lo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:Oi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _66 => _66.offset]),limit:_optionalChain([r, 'optionalAccess', _67 => _67.limit]),order_by:_optionalChain([r, 'optionalAccess', _68 => _68.orderBy])}};return(await A({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function go(n){let{aptosConfig:t,privateKey:e}=n,r=new K(e.publicKey());if(e instanceof Ye){let o=G.fromPublicKey({publicKey:r}).derivedAddress();return Ge.fromPrivateKey({privateKey:e,address:o})}if(e instanceof H){let i=G.fromPublicKey({publicKey:r});if(await eo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return Ge.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=G.fromPublicKey({publicKey:r.publicKey});if(await eo({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Ge.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function eo(n){let{aptosConfig:t,authKey:e}=n,r=await Cr({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await we({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function yo(n){let{aptosConfig:t,options:e}=n;return Et({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([e, 'optionalAccess', _70 => _70.limit])}})}async function Vn(n){let{aptosConfig:t}=n;return Ut(async()=>{let{data:e}=await Z({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function mo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function en(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Ao(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await en({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _71 => _71.status])===404)return!0;throw r}}async function Oa(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function Rt(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _72 => _72.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.checkSuccess]), () => (!0)),s=!0,a=0,c,p,y=200,w=1.5;function f(g){if(!(g instanceof re)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await en({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(g){f(g)}if(s){let g=Date.now();try{c=await Oa({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(oe){f(oe)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await en({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(g){f(g)}await _chunkKSEUZTKYjs.b.call(void 0, y),a+=y/1e3,y*=w}if(c===void 0)throw p||new $n(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new $n(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Ir(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function Hn(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await Fn({aptosConfig:t}):s=(await Mn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var $n=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Ir=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function b(n){n.minimumLedgerVersion!==void 0&&await Hn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var tn=class{constructor(t){this.config=t}async getAccountInfo(t){return we({aptosConfig:this.config,...t})}async getAccountModules(t){return to({aptosConfig:this.config,...t})}async getAccountModule(t){return qn({aptosConfig:this.config,...t})}async getAccountTransactions(t){return no({aptosConfig:this.config,...t})}async getAccountResources(t){return ro({aptosConfig:this.config,...t})}async getAccountResource(t){return Pr({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Cr({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),io({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),oo({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),so({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ao({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),co({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Er({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),po({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Rn,...t})}async getAccountCoinAmount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),uo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),lo({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return go({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Ln=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _74 => _74.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _75 => _75.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _76 => _76.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _77 => _77.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _78 => _78.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _79 => _79.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _80 => _80.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _81 => _81.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _82 => _82.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _83 => _83.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _84 => _84.faucetConfig]), () => ({}))}getRequestUrl(t){switch(t){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Pi[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Ci[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return vi[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return Ar[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return fr[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return Ar[this.network]===t}isProverServiceRequest(t){return fr[this.network]===t}};function fo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function ho(n){return!!n.match(/\s/)}function Ga(n){return!!n.match(/^T[0-9]+$/)}function Fa(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!ho(r))break}return e}var Ma=(f=>(f.InvalidTypeTag="unknown type",f.UnexpectedGenericType="unexpected generic type",f.UnexpectedTypeArgumentClose="unexpected '>'",f.UnexpectedWhitespaceCharacter="unexpected whitespace character",f.UnexpectedComma="unexpected ','",f.TypeArgumentCountMismatch="type argument count doesn't match expected amount",f.MissingTypeArgumentClose="no matching '>' for '<'",f.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",f.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",f.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",f.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",f.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",f))(Ma||{}),E= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ee(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _85 => _85.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let oe=Qn(a,i,e);o.push(oe)}let y=r.pop();if(y===void 0)throw new E(n,"unexpected '>'");if(c!==o.length)throw new E(n,"type argument count doesn't match expected amount");let{savedStr:w,savedTypes:f,savedExpectedTypes:g}=y;i=o,o=f,a=w,c=g}else if(p===","){if(a.length!==0){let y=Qn(a,i,e);i=[],o.push(y),a="",c+=1}}else if(ho(p)){let y=!1;if(a.length!==0){let f=Qn(a,i,e);i=[],o.push(f),a="",y=!0}s=Fa(n,s);let w=n[s];if(s<n.length&&y&&w!==","&&w!==">")throw new E(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new E(n,"no matching '>' for '<'");switch(o.length){case 0:return Qn(a,i,e);case 1:if(a==="")return o[0];throw new E(n,"unexpected ','");default:throw new E(n,"unexpected whitespace character")}}function Qn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new zn(new nt);case"signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new nt;case"bool":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new F;case"address":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new X;case"u8":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Ae;case"u16":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new At;case"u32":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new ft;case"u64":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new L;case"u128":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new ht;case"u256":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Tt;case"vector":if(t.length!==1)throw new E(n,"vector type expected to have exactly one type argument");return new C(t[0]);default:if(Ga(n)){if(e)return new D(Number(n.split("T")[1]));throw new E(n,"unexpected generic type")}if(!n.match(/:/))throw new E(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new E(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!fo(r[1]))throw new E(n,"module name must only contain alphanumeric or '_' characters");if(!fo(r[2]))throw new E(n,"struct name must only contain alphanumeric or '_' characters");return new m(new ve(u.fromString(r[0]),new U(r[1]),new U(r[2]),t))}}function To(n){return typeof n=="boolean"}function zt(n){return typeof n=="string"}function Wn(n){return typeof n=="number"}function jn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function bo(n){return n==null}function wo(n){return Ur(n)||zr(n)||Dr(n)||kr(n)||Br(n)||Kr(n)||Or(n)||Xn(n)||Rr(n)||qa(n)||n instanceof T||n instanceof De}function Ur(n){return n instanceof R}function Xn(n){return n instanceof u}function Rr(n){return n instanceof S}function qa(n){return n instanceof He}function zr(n){return n instanceof N}function Dr(n){return n instanceof se}function kr(n){return n instanceof ae}function Br(n){return n instanceof O}function Kr(n){return n instanceof ce}function Or(n){return n instanceof ue}function So(n){return"bytecode"in n}function I(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function _o(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function nn(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}var $a=new TextEncoder;function Gr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _86 => _86.map, 'call', _87 => _87(t=>zt(t)?Ee(t):t)]), () => ([]))}async function xo(n,t,e,r){let i=await qn({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function vo(n,t,e,r){let i=await xo(n,t,e,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!i.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let o=_o(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ee(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Po(n,t,e,r){let i=await xo(n,t,e,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${t}::${e}'`);if(!i.is_view)throw new Error(`'${n}::${t}::${e}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Ee(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ee(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Fr(n,t,e,r,i){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let o=t.parameters[r];return Dt(e,o,r,i)}function Dt(n,t,e,r){return wo(n)?(Nr(t,n,e),n):Va(n,t,e,r)}function Va(n,t,e,r){if(t.isBool()){if(To(n))return new R(n);I("boolean",e)}if(t.isAddress()){if(zt(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isU8()){if(Wn(n))return new N(n);I("number",e)}if(t.isU16()){if(Wn(n))return new se(n);I("number",e)}if(t.isU32()){if(Wn(n))return new ae(n);I("number",e)}if(t.isU64()){if(jn(n))return new O(BigInt(n));I("bigint | number | string",e)}if(t.isU128()){if(jn(n))return new ce(BigInt(n));I("bigint | number | string",e)}if(t.isU256()){if(jn(n))return new ue(BigInt(n));I("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return Dt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(zt(n))return T.U8($a.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(i=>Dt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(zt(n))return new S(n);I("string",e)}if(t.isObject()){if(zt(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isOption())return bo(n)?new De(null):new De(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 Nr(n,t,e){if(n.isBool()){if(Ur(t))return;I("Bool",e)}if(n.isAddress()){if(Xn(t))return;I("AccountAddress",e)}if(n.isU8()){if(zr(t))return;I("U8",e)}if(n.isU16()){if(Dr(t))return;I("U16",e)}if(n.isU32()){if(kr(t))return;I("U32",e)}if(n.isU64()){if(Br(t))return;I("U64",e)}if(n.isU128()){if(Kr(t))return;I("U128",e)}if(n.isU256()){if(Or(t))return;I("U256",e)}if(n.isVector()){if(t instanceof T){t.values.length>0&&Nr(n.value,t.values[0],e);return}I("MoveVector",e)}if(n instanceof m){if(n.isString()){if(Rr(t))return;I("MoveString",e)}if(n.isObject()){if(Xn(t))return;I("AccountAddress",e)}if(n.isOption()){if(t instanceof De){t.value!==void 0&&Nr(n.value.typeArgs[0],t.value,e);return}I("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}var Yn=class n extends d{constructor(e,r,i){super();this.rawTransaction=e,this.feePayerAddress=i,this.secondarySignerAddresses=r}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=M.deserialize(e),i=e.deserializeVector(u),o=e.deserializeBool(),s;return o&&(s=u.deserialize(e)),new n(r,i,s)}};async function Jn(n){if(So(n))return Wa(n);let{moduleAddress:t,moduleName:e,functionName:r}=nn(n.function),i=await Uo({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:vo});return La({abi:i,...n})}function La(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=nn(n.function),o=Gr(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>Fr(n.function,t,c,p,o));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);let a=it.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Wt(new Xt(c,new Yt(a)))}return new Qt(a)}async function Co(n){let{moduleAddress:t,moduleName:e,functionName:r}=nn(n.function),i=await Uo({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Po});return Qa({abi:i,...n})}function Qa(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=nn(n.function),o=Gr(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _88 => _88.functionArguments, 'optionalAccess', _89 => _89.map, 'call', _90 => _90((a,c)=>Fr(n.function,t,a,c,o))]), () => ([]));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);return it.build(`${e}::${r}`,i,o,s)}function Wa(n){return new Lt(new jt(l.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function ja(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=Tr[t.network]?Promise.resolve({chain_id:Tr[t.network]}):Nn({aptosConfig:t}),a=_optionalChain([i, 'optionalAccess', _91 => _91.gasUnitPrice])?Promise.resolve({gas_estimate:i.gasUnitPrice}):Vn({aptosConfig:t}),[{chain_id:c},{gas_estimate:p}]=await Promise.all([s,a]),y=_optionalChain([i, 'optionalAccess', _92 => _92.accountSequenceNumber])!==void 0?Promise.resolve({sequence_number:i.accountSequenceNumber}):we({aptosConfig:t,accountAddress:e}),w;if(o&&u.from(o).equals(u.ZERO))try{let{sequence_number:st}=await y;w=st}catch (e3){w="0"}else{let{sequence_number:st}=await y;w=st}let{maxGasAmount:f,gasUnitPrice:g,expireTimestamp:oe}={maxGasAmount:_optionalChain([i, 'optionalAccess', _93 => _93.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(p),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...i};return new M(u.from(e),BigInt(w),r,BigInt(f),BigInt(g),BigInt(oe),new mt(c))}async function Mr(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await ja({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _94 => _94.secondarySignerAddresses, 'optionalAccess', _95 => _95.map, 'call', _96 => _96(c=>u.from(c))]), () => ([]));return new Yn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Bn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Eo(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Zn(t);if(e.feePayerAddress){let a=new he(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(w=>Zn(w)));let p=Zn(i),y=new St(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new Te(a.raw_txn,y).bcsToBytes()}if(e.secondarySignerAddresses){let a=new fe(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(y=>Zn(y));let p=new wt(o,e.secondarySignerAddresses,c);return new Te(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof me)s=new bt(o.public_key,o.signature);else if(o instanceof ne)s=new _t(o);else throw new Error("Invalid public key");return new Te(e.rawTransaction,s).bcsToBytes()}function Zn(n){return n instanceof K?new ne(n,new q(new P(new Uint8Array(64)))):new me(new v(n.toUint8Array()),new P(new Uint8Array(64)))}function qr(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:i}=n,o=xt(t);if((r||i)&&(o instanceof fe||o instanceof he))return Ya(o,e,r,i);if(e instanceof me&&o instanceof M){let s=new bt(e.public_key,e.signature);return new Te(o,s).bcsToBytes()}if((e instanceof ne||e instanceof Oe)&&o instanceof M){let s=new _t(e);return new Te(o,s).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Io(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Xa=Io(["APTOS::Transaction"]);function VA(n){let t=qr(n);return new l(Io([Xa,new Uint8Array([0]),t])).toString()}function Ya(n,t,e,r){if(n instanceof he){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let i=new St(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new Te(n.raw_txn,i).bcsToBytes()}if(n instanceof fe){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let i=new wt(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new Te(n.raw_txn,i).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}async function Uo({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o||Ut(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function h(n){let t=await Za(n);return Ja(n,t)}async function Za(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await Jn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},i=await Jn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},i=await Jn(r)),i}async function Ja(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(ec(n)&&(o=u.ZERO.toString()),tc(n)){let{secondarySignerAddresses:s}=n;return Mr({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Mr({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function ec(n){return n.withFeePayer===!0}function tc(n){return"secondarySignerAddresses"in n}function Ro(n){let{transaction:t}=n;return Ne(t)}function er(n){let{signer:t,transaction:e}=n;return t.signWithAuthenticator(e)}async function $r(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Eo({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await ot({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _97 => _97.options, 'optionalAccess', _98 => _98.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _99 => _99.options, 'optionalAccess', _100 => _100.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function tr(n){let{aptosConfig:t}=n,e=qr({...n}),{data:r}=await ot({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function rn(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof Ce||e instanceof Ct)&&await e.waitForProofFetch();let i=er({signer:e,transaction:r});return tr({aptosConfig:t,transaction:r,senderAuthenticator:i})}var nc={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function zo(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>T.U8(a));return h({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:nc},options:o})}var rc={typeParameters:[],parameters:[new Ae,C.u8(),new Ae,C.u8(),C.u8(),C.u8()]};async function Do(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await we({aptosConfig:t,accountAddress:e.accountAddress}),o=Ge.fromPrivateKey({privateKey:r,legacy:!0}),a=new kn({sequenceNumber:BigInt(i.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=e.sign(a),p=o.sign(a),y=await h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new N(e.signingScheme),T.U8(e.publicKey.toUint8Array()),new N(o.signingScheme),T.U8(o.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:rc}});return rn({aptosConfig:t,signer:e,transaction:y})}var ic={typeParameters:[{constraints:[]}],parameters:[new X,new L]};async function ko(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return h({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (Rn))],functionArguments:[r,i],abi:ic},options:s})}var on=class{constructor(t){this.config=t}async transferCoinTransaction(t){return ko({aptosConfig:this.config,...t})}};var Fe={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},ie="0x4::token::Token";async function Bo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await A({aptosConfig:t,query:{query:ji,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ko(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};return(await A({aptosConfig:t,query:{query:xr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Oo(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:xr,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _103 => _103.offset]),limit:_optionalChain([r, 'optionalAccess', _104 => _104.limit]),order_by:_optionalChain([r, 'optionalAccess', _105 => _105.orderBy])}};return(await A({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function No(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:Wi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _106 => _106.offset]),limit:_optionalChain([r, 'optionalAccess', _107 => _107.limit]),order_by:_optionalChain([r, 'optionalAccess', _108 => _108.orderBy])}};return(await A({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var oc={typeParameters:[],parameters:[new m(x()),new L,new m(x()),new m(x()),new F,new F,new F,new F,new F,new F,new F,new F,new F,new L,new L]};async function Go(n){let{aptosConfig:t,options:e,creator:r}=n;return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new S(n.description),new O(_nullishCoalesce(n.maxSupply, () => ($e))),new S(n.name),new S(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:oc},options:e})}async function Vr(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:i}=n,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _109 => _109.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _110 => _110.tokenStandard]), () => ("v2"))}),(await A({aptosConfig:t,query:{query:wr,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Fo(n){let{aptosConfig:t,collectionId:e}=n,i={collection_id:{_eq:u.from(e).toStringLong()}};return(await A({aptosConfig:t,query:{query:wr,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Mo(n){return(await Vr(n)).collection_id}var sc={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new C(new m(x())),new C(new m(x())),new C(C.u8())]};async function qo(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:y}=n,w=_optionalChain([p, 'optionalAccess', _111 => _111.map, 'call', _112 => _112(f=>Fe[f])]);return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new S(i),new S(o),new S(s),new S(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(w, () => ([]))),ns(_nullishCoalesce(y, () => ([])),_nullishCoalesce(w, () => ([])))],abi:sc},options:e})}var ac={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new X]};async function $o(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(r),u.from(i)],abi:ac},options:s})}var cc={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new C(new m(x())),new C(new m(x())),new C(C.u8()),new X]};async function Vo(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:y,options:w}=n;if(_optionalChain([c, 'optionalAccess', _113 => _113.length])!==_optionalChain([y, 'optionalAccess', _114 => _114.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _115 => _115.length])!==_optionalChain([y, 'optionalAccess', _116 => _116.length]))throw new Error("Property types and property values counts do not match");let f=_optionalChain([p, 'optionalAccess', _117 => _117.map, 'call', _118 => _118(g=>Fe[g])]);return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(f, () => ([]))),ns(_nullishCoalesce(y, () => ([])),_nullishCoalesce(f, () => ([]))),a],abi:cc},options:w})}var uc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Ho(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[u.from(r)],abi:uc},options:o})}var pc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Lo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[r],abi:pc},options:o})}var dc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Qo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[r],abi:dc},options:o})}var lc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x())]};async function Wo(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new S(r)],abi:lc},options:s})}var gc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x())]};async function jo(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new S(r)],abi:gc},options:s})}var yc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x())]};async function Xo(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new S(r)],abi:yc},options:s})}var mc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x()),new m(x()),C.u8()]};async function Yo(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (ie))],functionArguments:[u.from(s),new S(r),new S(Fe[i]),T.U8(Hr(o,Fe[i]))],abi:mc},options:c})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x())]};async function Zo(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new S(r)],abi:Ac},options:s})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(x()),new m(x()),C.u8()]};async function Jo(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (ie))],functionArguments:[u.from(s),new S(r),new S(Fe[i]),Hr(o,Fe[i])],abi:fc},options:c})}var hc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(Y(new D(0))),new m(x()),new D(1)]};async function es(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (ie)),Fe[i]],functionArguments:[u.from(s),new S(r),o],abi:hc},options:c})}var Tc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(Y(new D(0))),new m(x()),new D(1)]};async function ts(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (ie)),Fe[i]],functionArguments:[u.from(s),new S(r),o],abi:Tc},options:c})}function ns(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(Hr(n[i],r))}),e}function Hr(n,t){let e=Ee(t);return Dt(n,e,0,[]).bcsToBytes()}var sn=class{constructor(t){this.config=t}async getCollectionData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Vr({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Fo({aptosConfig:this.config,...t})}async getCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Bo({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ko({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Oo({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),No({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Go({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return qo({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return $o({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Vo({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Ho({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Lo({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return Qo({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return Wo({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return jo({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return Xo({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return Yo({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return Zo({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return Jo({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return es({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return ts({aptosConfig:this.config,...t})}};var rs=300,bc=n=>{if(n&&n.length>rs)throw new Error(`Event type length exceeds the maximum length of ${rs}`)};async function is(n){let{aptosConfig:t,eventType:e,options:r}=n,o={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _119 => _119.orderBy])};return an({aptosConfig:t,options:o})}async function os(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _120 => _120.orderBy])};return an({aptosConfig:e,options:a})}async function ss(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _121 => _121.orderBy])};return an({aptosConfig:e,options:a})}async function an(n){let{aptosConfig:t,options:e}=n;bc(_optionalChain([e, 'optionalAccess', _122 => _122.where, 'optionalAccess', _123 => _123.indexed_type, 'optionalAccess', _124 => _124._eq]));let r={query:Hi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _125 => _125.where]),offset:_optionalChain([e, 'optionalAccess', _126 => _126.offset]),limit:_optionalChain([e, 'optionalAccess', _127 => _127.limit]),order_by:_optionalChain([e, 'optionalAccess', _128 => _128.orderBy])}};return(await A({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var cn=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),is({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),os({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ss({aptosConfig:this.config,...t})}async getEvents(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _129 => _129.minimumLedgerVersion]),processorType:"events_processor"}),an({aptosConfig:this.config,...t})}};async function as(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _130 => _130.timeoutSecs])||20,{data:s}=await Ri({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Rt({aptosConfig:t,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _131 => _131.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var un=class{constructor(t){this.config=t}async fundAccount(t){let e=await as({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _132 => _132.options, 'optionalAccess', _133 => _133.waitForIndexer])!==!1&&await Hn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function Lr(n){let{aptosConfig:t,options:e}=n,r={query:Qi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _134 => _134.where]),limit:_optionalChain([e, 'optionalAccess', _135 => _135.limit]),offset:_optionalChain([e, 'optionalAccess', _136 => _136.offset])}};return(await A({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function cs(n){let{aptosConfig:t,options:e}=n,r={query:Li,variables:{where_condition:_optionalChain([e, 'optionalAccess', _137 => _137.where]),limit:_optionalChain([e, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([e, 'optionalAccess', _139 => _139.offset])}};return(await A({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function us(n){let{aptosConfig:t,options:e}=n,r={query:$i,variables:{where_condition:_optionalChain([e, 'optionalAccess', _140 => _140.where]),limit:_optionalChain([e, 'optionalAccess', _141 => _141.limit]),offset:_optionalChain([e, 'optionalAccess', _142 => _142.offset])}};return(await A({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var wc={typeParameters:[],parameters:[Ee("0x1::object::Object"),new X,new L]};async function ps(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:wc},options:s})}var pn=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Lr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _144 => _144.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Lr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _145 => _145.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),cs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _146 => _146.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),us({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return ps({aptosConfig:this.config,...t})}};async function Me(n){let{aptosConfig:t,payload:e,options:r}=n,i=await Co({...e,aptosConfig:t}),o=new k;i.serialize(o);let s=o.toUint8Array(),{data:a}=await ot({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _147 => _147.ledgerVersion])},body:s});return a}var dn=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 Xi({aptosConfig:this.config,...t})}async getBlockByHeight(t){return Yi({aptosConfig:this.config,...t})}async getTableItem(t){return Gn({aptosConfig:this.config,...t})}async view(t){return Me({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return Zi({aptosConfig:this.config,...t})}async queryIndexer(t){return A({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Fn({aptosConfig:this.config})}async getProcessorStatus(t){return Mn({aptosConfig:this.config,processorType:t})}};var ds=["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 ls(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function qe(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(!ls(t))throw new Error(`${t} is not valid. ${ds}`);if(e&&!ls(e))throw new Error(`${e} is not valid. ${ds}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Sc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",_c={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Sc,custom:null,devnet:null,randomnet:null};function Ie(n){let t=_c[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var nr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function gs(n){let{aptosConfig:t,name:e}=n,r=Ie(t),{domainName:i,subdomainName:o}=qe(e),s=await Me({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=nr(s[0]);return a?u.from(a):void 0}async function ys(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=Ie(t),{domainName:y,subdomainName:w}=qe(r),f=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(w&&!f)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(f&&!w)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let Zr=_nullishCoalesce(e.years, () => (1));if(Zr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let zs=Zr*31536e3;return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[y,zs,o,s]},options:a})}if(!w)throw new Error(`${e.policy} requires a subdomain to be provided.`);let g=await Qr({aptosConfig:t,name:y});if(!g)throw new Error("The domain does not exist");let oe=e.policy==="subdomain:independent"?e.expirationDate:g;if(oe>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[y,w,Math.round(oe/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function Qr(n){let{aptosConfig:t,name:e}=n,r=Ie(t),{domainName:i,subdomainName:o}=qe(e);try{let s=await Me({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e4){return}}async function ms(n){let{aptosConfig:t,address:e}=n,r=Ie(t),i=await Me({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=nr(i[1]),s=nr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function As(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=Ie(t);if(!r)return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=qe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function fs(n){let{aptosConfig:t,name:e}=n,r=Ie(t),{domainName:i,subdomainName:o}=qe(e),s=await Me({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=nr(s[0]);return a?u.from(a):void 0}async function hs(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=Ie(t),{domainName:a,subdomainName:c}=qe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ts(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=qe(e),a=(await A({aptosConfig:t,query:{query:It,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=ln(a)),a}async function bs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Wr({aptosConfig:t});return(await A({aptosConfig:t,originMethod:"getAccountNames",query:{query:It,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]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(ln)}async function ws(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Wr({aptosConfig:t});return(await A({aptosConfig:t,originMethod:"getAccountDomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _153 => _153.limit]),offset:_optionalChain([e, 'optionalAccess', _154 => _154.offset]),order_by:_optionalChain([e, 'optionalAccess', _155 => _155.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _156 => _156.options, 'optionalAccess', _157 => _157.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(ln)}async function Ss(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Wr({aptosConfig:t});return(await A({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _158 => _158.limit]),offset:_optionalChain([e, 'optionalAccess', _159 => _159.offset]),order_by:_optionalChain([e, 'optionalAccess', _160 => _160.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _161 => _161.options, 'optionalAccess', _162 => _162.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(ln)}async function _s(n){let{aptosConfig:t,options:e,domain:r}=n;return(await A({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _163 => _163.limit]),offset:_optionalChain([e, 'optionalAccess', _164 => _164.offset]),order_by:_optionalChain([e, 'optionalAccess', _165 => _165.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _166 => _166.options, 'optionalAccess', _167 => _167.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(ln)}async function Wr(n){let{aptosConfig:t}=n,e=Ie(t),[r]=await Me({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function xs(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=Ie(t),a=i*31536e3,{domainName:c,subdomainName:p}=qe(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function ln(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var gn=class{constructor(t){this.config=t}async getOwnerAddress(t){return gs({aptosConfig:this.config,...t})}async getExpiration(t){return Qr({aptosConfig:this.config,...t})}async getTargetAddress(t){return fs({aptosConfig:this.config,...t})}async setTargetAddress(t){return hs({aptosConfig:this.config,...t})}async getPrimaryName(t){return ms({aptosConfig:this.config,...t})}async setPrimaryName(t){return As({aptosConfig:this.config,...t})}async registerName(t){return ys({aptosConfig:this.config,...t})}async renewDomain(t){return xs({aptosConfig:this.config,...t})}async getName(t){return Ts({aptosConfig:this.config,...t})}async getAccountNames(t){return bs({aptosConfig:this.config,...t})}async getAccountDomains(t){return ws({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Ss({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return _s({aptosConfig:this.config,...t})}};async function vs(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await A({aptosConfig:t,query:{query:Sr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ps(n){let{aptosConfig:t,options:e}=n,r={query:Sr,variables:{order_by:_optionalChain([e, 'optionalAccess', _168 => _168.orderBy])}};return(await A({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Cs(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:Vi,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await A({aptosConfig:t,query:i})).delegated_staking_activities}var yn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _169 => _169.minimumLedgerVersion]),processorType:"stake_processor"}),vs({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _170 => _170.minimumLedgerVersion]),processorType:"stake_processor"}),Ps({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _171 => _171.minimumLedgerVersion]),processorType:"stake_processor"}),Cs({aptosConfig:this.config,...t})}};var rr=class{constructor(t){this.config=t}async simple(t){return h({aptosConfig:this.config,...t})}async multiAgent(t){return h({aptosConfig:this.config,...t})}};function jr(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},e}function Xr(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,i)},e}var kt=class{constructor(t){this.config=t}async simple(t){return $r({aptosConfig:this.config,...t})}async multiAgent(t){return $r({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [Xr],kt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [Xr],kt.prototype,"multiAgent",1);var Bt=class{constructor(t){this.config=t}async simple(t){return tr({aptosConfig:this.config,...t})}async multiAgent(t){return tr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [jr],Bt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [jr],Bt.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var ir=()=>Math.floor(Date.now()/1e3),or= exports.AccountSequenceNumber =class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, 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=ir();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),ir()-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 we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await we({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 _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=ir();for(;this.lastUncommintedNumber!==this.currentNumber;)ir()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkKSEUZTKYjs.b.call(void 0, 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 Kt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _172 => _172.pendingDequeue, 'access', _173 => _173.shift, 'call', _174 => _174(), 'optionalAccess', _175 => _175.resolve, 'call', _176 => _176(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 Ot("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Ot=class extends Error{};var Es="fulfilled",Is= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Is||{}),sr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new Kt;this.transactionsQueue=new Kt;this.outstandingTransactions=new Kt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new or(e,r,i,o,s)}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 i=rn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Ot)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(e.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),e.push(i),r.push(o);let s=await Promise.allSettled(e);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Es?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(e){if(e instanceof Ot)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(Rt({aptosConfig:this.aptosConfig,transactionHash:e.value.hash,options:{timeoutSecs:3}}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Es?(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(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,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 ar=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new sr(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:i}=e;for(let o of r)this.transactionWorker.push(o,i)}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:i,options:o}=e;this.start({sender:r}),this.push({data:i,options:o})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var mn=class{constructor(t){this.config=t,this.build=new rr(this.config),this.simulate=new kt(this.config),this.submit=new Bt(this.config),this.batch=new ar(this.config)}async getTransactions(t){return yo({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return mo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return en({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Ao({aptosConfig:this.config,...t})}async waitForTransaction(t){return Rt({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Vn({aptosConfig:this.config})}getSigningMessage(t){return Ro(t)}async publishPackageTransaction(t){return zo({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Do({aptosConfig:this.config,...t})}sign(t){return er({...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,er({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return rn({aptosConfig:this.config,signer:e,transaction:r})}};var _bls12381 = require('@noble/curves/bls12-381');var Pc="APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST";function Cc(n){return new TextEncoder().encode(n)}var Ec=_bls12381.bls12_381.G2.hashToCurve(Cc("APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE"),{DST:Pc}).toAffine();function Ic(n){let{jwt:t,uidKey:e}=n,r=_jwtdecode.jwtDecode.call(void 0, t),i=new k;i.serializeStr(r.iss),i.serializeStr(r.aud),i.serializeStr(r[e||"sub"]),i.serializeStr(e||"sub");let o=i.toUint8Array(),s=_bls12381.bls12_381.G1.hashToCurve(o,{DST:"APTOS_PEPPER_SERVICE_BLS12381_VUF_DST"}).toAffine();return _bls12381.bls12_381.G1.ProjectivePoint.fromAffine(s)}async function Uc(n){let{aptosConfig:t,pepperInput:e,pepperBase:r}=n,{data:i}=await Ii({aptosConfig:t,path:"vrf-pub-key",originMethod:"getPepper"}),o=_bls12381.bls12_381.G2.ProjectivePoint.fromHex(i.vrf_public_key_hex_string);return _bls12381.bls12_381.verifyShortSignature(r,e,o)}async function Yr(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i,verify:o}=n,{derivationPath:s}=n,a={jwt_b64:e,epk:r.publicKey.bcsToHex().toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i},{data:c}=await zi({aptosConfig:t,path:"fetch",body:a,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}}),p=l.fromHexInput(c.signature).toUint8Array();if(o&&!Uc({aptosConfig:t,pepperBase:p,pepperInput:Ic(n)}))throw new Error("Unable to verify");let y=_bls12381.bls12_381.pairing(_bls12381.bls12_381.G1.ProjectivePoint.fromHex(p),_bls12381.bls12_381.G2.ProjectivePoint.fromAffine(Ec));return s===void 0&&(s=di),Ce.fromDerivationPath(s,_bls12381.bls12_381.fields.Fp12.toBytes(y)).slice(0,31)}async function Rc(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i,uidKey:o,extraFieldKey:s}=n,a=_jwtdecode.jwtDecode.call(void 0, e),c;if(s){let oe=a[s];c=`"${s}":"${oe}",`}let p={jwt_b64:e,epk:r.publicKey.bcsToHex().toStringWithoutPrefix(),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),exp_horizon_secs:$t,pepper:l.fromHexInput(i).toStringWithoutPrefix(),extra_field:s,uid_key:o||"sub"},{data:y}=await Di({aptosConfig:t,path:"prove",body:p,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),w=y.proof,f=new dt({a:w.a,b:w.b,c:w.c});return new lt({proof:f,extraField:c,trainingWheelsSignature:de.fromHex(y.training_wheels_signature)})}async function Rs(n){let{fetchProofAsync:t}=n,{pepper:e,disableConnect:r}=n;if((e||r)&&(r=!0),e===void 0)e=await Yr(n);else if(l.fromHexInput(e).toUint8Array().length!==31)throw new Error("Pepper needs to be 31 bytes");let i=Rc({...n,pepper:e}),o=t?i:await i,s=Ce.fromJWTAndProof({...n,proofFetcherOrData:o,pepper:e});if(r===!0)return s;let a=s.deriveAptosConnectPublicKey(),c=new Ke({publicKeys:[s.publicKey,a],signaturesRequired:1});return new Ct({multiKey:c,signers:[s]})}var An=class{constructor(t){this.config=t}async getPepper(t){return Yr({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return Rs({aptosConfig:this.config,...t})}};var J=class{constructor(t){this.config=new Ln(t),this.account=new tn(this.config),this.ans=new gn(this.config),this.coin=new on(this.config),this.digitalAsset=new sn(this.config),this.event=new cn(this.config),this.faucet=new un(this.config),this.fungibleAsset=new pn(this.config),this.general=new dn(this.config),this.staking=new yn(this.config),this.transaction=new mn(this.config),this.keyless=new An(this.config)}};function le(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(t.prototype,r);i&&(i.value=function(...o){return this[e][r](...o)},Object.defineProperty(n.prototype,r,i))})}le(J,tn,"account");le(J,gn,"ans");le(J,on,"coin");le(J,sn,"digitalAsset");le(J,cn,"event");le(J,un,"faucet");le(J,pn,"fungibleAsset");le(J,dn,"general");le(J,yn,"staking");le(J,mn,"transaction");le(J,An,"keyless");exports.APTOS_BIP44_DEFAULT_DERIVATION_PATH = di; exports.APTOS_BIP44_REGEX = Ls; exports.APTOS_COIN = Rn; exports.APTOS_HARDENED_REGEX = Hs; exports.Account = Ge; exports.AccountAddress = u; exports.AccountAuthenticator = j; exports.AccountAuthenticatorEd25519 = me; exports.AccountAuthenticatorMultiEd25519 = In; exports.AccountAuthenticatorMultiKey = Oe; exports.AccountAuthenticatorSingleKey = ne; exports.AccountAuthenticatorVariant = ri; exports.AccountPublicKey = ee; exports.AccountSequenceNumber = or; exports.AddressInvalidReason = Ms; exports.AnyPublicKey = K; exports.AnyPublicKeyVariant = ur; exports.AnySignature = q; exports.AnySignatureVariant = ii; exports.Aptos = J; exports.AptosApiError = re; exports.AptosApiType = Vt; exports.AptosConfig = Ln; exports.AuthenticationKey = G; exports.Bool = R; exports.CKDPriv = Ws; exports.ChainId = mt; exports.DEFAULT_MAX_GAS_AMOUNT = Ti; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = bi; exports.DEFAULT_TXN_TIMEOUT_SEC = Un; exports.DeriveScheme = Gs; exports.Deserializer = bn; exports.EPK_HORIZON_SECS = $t; exports.Ed25519Account = vt; exports.Ed25519PrivateKey = H; exports.Ed25519PublicKey = v; exports.Ed25519Signature = P; exports.EntryFunction = it; exports.EntryFunctionBytes = wn; exports.EphemeralCertificate = ai; exports.EphemeralKeyPair = _i; exports.EphemeralPublicKey = Je; exports.EphemeralPublicKeyVariant = oi; exports.EphemeralSignature = de; exports.EphemeralSignatureVariant = si; exports.FeePayerRawTransaction = he; exports.FixedBytes = He; exports.Groth16Zkp = dt; exports.HARDENED_OFFSET = dr; exports.Hex = l; exports.HexInvalidReason = Bs; exports.Identifier = U; exports.KeyType = Qs; exports.KeylessAccount = Ce; exports.KeylessPublicKey = xe; exports.KeylessSignature = Be; exports.MAX_AUD_VAL_BYTES = wa; exports.MAX_COMMITED_EPK_BYTES = ld; exports.MAX_EXTRA_FIELD_BYTES = pd; exports.MAX_ISS_VAL_BYTES = ud; exports.MAX_JWT_HEADER_B64_BYTES = dd; exports.MAX_UID_KEY_BYTES = Sa; exports.MAX_UID_VAL_BYTES = _a; exports.MimeType = Sn; exports.ModuleId = Ht; exports.MoveAbility = ci; exports.MoveFunctionVisibility = Os; exports.MoveOption = De; exports.MoveString = S; exports.MoveVector = T; exports.MultiAgentRawTransaction = fe; exports.MultiEd25519PublicKey = ut; exports.MultiEd25519Signature = We; exports.MultiKey = Ke; exports.MultiKeyAccount = Ct; exports.MultiSig = Xt; exports.MultiSigTransactionPayload = Yt; exports.MultiSignature = tt; exports.Network = hr; exports.NetworkToChainId = Tr; exports.NetworkToFaucetAPI = Ci; exports.NetworkToIndexerAPI = vi; exports.NetworkToNetworkName = Vy; exports.NetworkToNodeAPI = Pi; exports.NetworkToPepperAPI = Ar; exports.NetworkToProverAPI = fr; exports.OpenIdSignature = gt; exports.OpenIdSignatureOrZkProof = et; exports.ParsingError = V; exports.ProcessorType = yt; exports.PublicKey = Le; exports.RAW_TRANSACTION_SALT = wi; exports.RAW_TRANSACTION_WITH_DATA_SALT = Si; exports.RawTransaction = M; exports.RawTransactionWithData = Dn; exports.RoleType = Ns; exports.RotationProofChallenge = kn; exports.Script = jt; exports.ScriptTransactionArgumentVariants = Gt; exports.Secp256k1PrivateKey = Ye; exports.Secp256k1PublicKey = Xe; exports.Secp256k1Signature = Ze; exports.Serializable = d; exports.Serializer = k; exports.Signature = B; exports.SignedGroth16Signature = lt; exports.SignedTransaction = Te; exports.SigningScheme = ge; exports.SigningSchemeInput = _n; exports.SimpleTransaction = Bn; exports.SingleKeyAccount = Pt; exports.StructTag = ve; exports.TransactionAuthenticator = Pe; exports.TransactionAuthenticatorEd25519 = bt; exports.TransactionAuthenticatorFeePayer = St; exports.TransactionAuthenticatorMultiAgent = wt; exports.TransactionAuthenticatorMultiEd25519 = mr; exports.TransactionAuthenticatorSingleSender = _t; exports.TransactionAuthenticatorVariant = ni; exports.TransactionPayload = rt; exports.TransactionPayloadEntryFunction = Qt; exports.TransactionPayloadMultiSig = Wt; exports.TransactionPayloadScript = Lt; exports.TransactionPayloadVariants = ei; exports.TransactionResponseType = pr; exports.TransactionVariants = ti; exports.TransactionWorker = sr; exports.TransactionWorkerEventsEnum = Is; exports.TypeTag = z; exports.TypeTagAddress = X; exports.TypeTagBool = F; exports.TypeTagGeneric = D; exports.TypeTagParserError = E; exports.TypeTagParserErrorType = Ma; exports.TypeTagReference = zn; exports.TypeTagSigner = nt; exports.TypeTagStruct = m; exports.TypeTagU128 = ht; exports.TypeTagU16 = At; exports.TypeTagU256 = Tt; exports.TypeTagU32 = ft; exports.TypeTagU64 = L; exports.TypeTagU8 = Ae; exports.TypeTagVariants = Jr; exports.TypeTagVector = C; exports.U128 = ce; exports.U16 = se; exports.U256 = ue; exports.U32 = ae; exports.U64 = O; exports.U8 = N; exports.aptosCoinStructTag = Sl; exports.aptosRequest = Kn; exports.buildTransaction = Mr; exports.checkOrConvertArgument = Dt; exports.computeAddressSeed = qt; exports.convertArgument = Fr; exports.deriveKey = li; exports.deriveTransactionType = xt; exports.deserializeFromScriptArgument = xa; exports.ensureBoolean = cr; exports.fetchEntryFunctionAbi = vo; exports.fetchFunctionAbi = xo; exports.fetchViewFunctionAbi = Po; exports.findFirstNonSignerArg = _o; exports.fromDerivationPath = xn; exports.generateMultiSignersSignedTransaction = Ya; exports.generateRawTransaction = ja; exports.generateSignedTransaction = qr; exports.generateSignedTransactionForSimulation = Eo; exports.generateSigningMessage = Zt; exports.generateSigningMessageForSerializable = Eg; exports.generateSigningMessageForTransaction = Ne; exports.generateTransactionPayload = Jn; exports.generateTransactionPayloadWithABI = La; exports.generateUserTransactionHash = VA; exports.generateViewFunctionPayload = Co; exports.generateViewFunctionPayloadWithABI = Qa; exports.get = br; exports.getAptosFullNode = Z; exports.getAptosPepperService = Ii; exports.getAuthenticatorForSimulation = Zn; exports.getFunctionParts = nn; exports.hashValues = Io; exports.isBcsAddress = Xn; exports.isBcsBool = Ur; exports.isBcsFixedBytes = qa; exports.isBcsString = Rr; exports.isBcsU128 = Kr; exports.isBcsU16 = Dr; exports.isBcsU256 = Or; exports.isBcsU32 = kr; exports.isBcsU64 = Br; exports.isBcsU8 = zr; exports.isBlockMetadataTransactionResponse = ru; exports.isBool = To; exports.isEd25519Signature = su; exports.isEncodedEntryFunctionArgument = wo; exports.isFeePayerSignature = uu; exports.isGenesisTransactionResponse = nu; exports.isLargeNumber = jn; exports.isMultiAgentSignature = cu; exports.isMultiEd25519Signature = pu; exports.isNull = bo; exports.isNumber = Wn; exports.isPendingTransactionResponse = eu; exports.isScriptDataInput = So; exports.isSecp256k1Signature = au; exports.isStateCheckpointTransactionResponse = iu; exports.isString = zt; exports.isUserTransactionResponse = tu; exports.isValidBIP44Path = lr; exports.isValidHardenedPath = gr; exports.isValidatorTransactionResponse = ou; exports.mnemonicToSeed = vn; exports.objectStructTag = Y; exports.optionStructTag = _l; exports.outOfRangeErrorMessage = Ks; exports.paginateWithCursor = Et; exports.parseTypeTag = Ee; exports.post = Jt; exports.postAptosFaucet = Ri; exports.postAptosFullNode = ot; exports.postAptosIndexer = Ui; exports.postAptosPepperService = zi; exports.postAptosProvingService = Di; exports.promiseFulfilledStatus = Es; exports.request = Da; exports.splitPath = Xs; exports.standardizeTypeTags = Gr; exports.stringStructTag = x; exports.throwTypeMismatch = I; exports.validateNumberInRange = ze;
429
429
  //# sourceMappingURL=index.js.map