@aptos-labs/ts-sdk 1.39.0 → 2.0.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 (396) hide show
  1. package/dist/common/{accountAddress-D0xKX-UM.d.ts → accountAddress-B3Y4WI-E.d.ts} +47 -11
  2. package/dist/common/chunk-BNN2XWNR.js +4 -0
  3. package/dist/common/chunk-BNN2XWNR.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +121 -110
  8. package/dist/common/index.js +53 -32
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-D9XrCLfE.d.mts → Ed25519Account-D2MdV8Av.d.mts} +2 -2
  11. package/dist/esm/account/AbstractKeylessAccount.d.mts +2 -3
  12. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractedAccount.d.mts +1 -2
  14. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  15. package/dist/esm/account/Account.d.mts +1 -2
  16. package/dist/esm/account/Account.mjs +1 -1
  17. package/dist/esm/account/AccountUtils.d.mts +2 -3
  18. package/dist/esm/account/AccountUtils.mjs +1 -1
  19. package/dist/esm/account/DerivableAbstractedAccount.d.mts +1 -2
  20. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  21. package/dist/esm/account/Ed25519Account.d.mts +1 -2
  22. package/dist/esm/account/Ed25519Account.mjs +1 -1
  23. package/dist/esm/account/EphemeralKeyPair.d.mts +0 -1
  24. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  25. package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
  26. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  27. package/dist/esm/account/KeylessAccount.d.mts +3 -3
  28. package/dist/esm/account/KeylessAccount.mjs +1 -1
  29. package/dist/esm/account/MultiEd25519Account.d.mts +1 -2
  30. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  31. package/dist/esm/account/MultiKeyAccount.d.mts +2 -3
  32. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  33. package/dist/esm/account/SingleKeyAccount.d.mts +1 -2
  34. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  35. package/dist/esm/account/index.d.mts +2 -3
  36. package/dist/esm/account/index.mjs +1 -1
  37. package/dist/esm/account/utils.d.mts +0 -1
  38. package/dist/esm/account/utils.mjs +1 -1
  39. package/dist/esm/api/account/abstraction.d.mts +0 -1
  40. package/dist/esm/api/account/abstraction.mjs +1 -1
  41. package/dist/esm/api/account.d.mts +97 -7
  42. package/dist/esm/api/account.mjs +1 -1
  43. package/dist/esm/api/ans.d.mts +1 -2
  44. package/dist/esm/api/ans.mjs +1 -1
  45. package/dist/esm/api/aptos.d.mts +7 -8
  46. package/dist/esm/api/aptos.mjs +1 -1
  47. package/dist/esm/api/aptosConfig.d.mts +0 -1
  48. package/dist/esm/api/aptosConfig.mjs +1 -1
  49. package/dist/esm/api/coin.d.mts +0 -1
  50. package/dist/esm/api/coin.mjs +1 -1
  51. package/dist/esm/api/digitalAsset.d.mts +1 -2
  52. package/dist/esm/api/digitalAsset.mjs +1 -1
  53. package/dist/esm/api/event.d.mts +0 -1
  54. package/dist/esm/api/event.mjs +1 -1
  55. package/dist/esm/api/faucet.d.mts +0 -1
  56. package/dist/esm/api/faucet.mjs +1 -1
  57. package/dist/esm/api/fungibleAsset.d.mts +1 -2
  58. package/dist/esm/api/fungibleAsset.mjs +1 -1
  59. package/dist/esm/api/general.d.mts +0 -1
  60. package/dist/esm/api/general.mjs +1 -1
  61. package/dist/esm/api/index.d.mts +7 -8
  62. package/dist/esm/api/index.mjs +1 -1
  63. package/dist/esm/api/keyless.d.mts +2 -3
  64. package/dist/esm/api/keyless.mjs +1 -1
  65. package/dist/esm/api/object.d.mts +0 -1
  66. package/dist/esm/api/object.mjs +1 -1
  67. package/dist/esm/api/staking.d.mts +0 -1
  68. package/dist/esm/api/staking.mjs +1 -1
  69. package/dist/esm/api/table.d.mts +0 -1
  70. package/dist/esm/api/table.mjs +1 -1
  71. package/dist/esm/api/transaction.d.mts +2 -3
  72. package/dist/esm/api/transaction.mjs +1 -1
  73. package/dist/esm/api/transactionSubmission/build.d.mts +0 -66
  74. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  75. package/dist/esm/api/transactionSubmission/management.d.mts +1 -2
  76. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  77. package/dist/esm/api/transactionSubmission/sign.d.mts +1 -2
  78. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  79. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  80. package/dist/esm/api/transactionSubmission/simulate.d.mts +0 -1
  81. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  82. package/dist/esm/api/transactionSubmission/submit.d.mts +0 -1
  83. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  84. package/dist/esm/api/utils.d.mts +0 -1
  85. package/dist/esm/api/utils.mjs +1 -1
  86. package/dist/esm/bcs/consts.d.mts +0 -1
  87. package/dist/esm/bcs/deserializer.d.mts +0 -1
  88. package/dist/esm/bcs/deserializer.mjs +1 -1
  89. package/dist/esm/bcs/index.d.mts +0 -1
  90. package/dist/esm/bcs/index.mjs +1 -1
  91. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +0 -1
  92. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  93. package/dist/esm/bcs/serializable/fixedBytes.d.mts +0 -1
  94. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  95. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -2
  96. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  97. package/dist/esm/bcs/serializable/moveStructs.d.mts +0 -1
  98. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  99. package/dist/esm/bcs/serializer.d.mts +0 -1
  100. package/dist/esm/bcs/serializer.mjs +1 -1
  101. package/dist/esm/{chunk-ARNW34PP.mjs → chunk-2DYSBAZ7.mjs} +2 -2
  102. package/dist/esm/{chunk-3IHKQH5O.mjs → chunk-34R7FSQF.mjs} +2 -2
  103. package/dist/esm/{chunk-XF6BISPI.mjs → chunk-3BUKTQDX.mjs} +2 -2
  104. package/dist/esm/chunk-3FEFJIVT.mjs +2 -0
  105. package/dist/esm/chunk-3FEFJIVT.mjs.map +1 -0
  106. package/dist/esm/{chunk-KAYKTT4S.mjs → chunk-4F5EECVQ.mjs} +2 -2
  107. package/dist/esm/chunk-4YLUM62M.mjs +2 -0
  108. package/dist/esm/chunk-5HXLZHDW.mjs +1 -0
  109. package/dist/esm/{chunk-25O4L7YR.mjs → chunk-6UZHMEK3.mjs} +2 -2
  110. package/dist/esm/{chunk-6Y6ZO7TS.mjs → chunk-6WDVDEQZ.mjs} +2 -2
  111. package/dist/esm/{chunk-YFFDF22R.mjs → chunk-7DQDJ2SA.mjs} +2 -2
  112. package/dist/esm/{chunk-ZMT2M6YT.mjs → chunk-B563XRSZ.mjs} +2 -2
  113. package/dist/esm/{chunk-V7U5Y4AU.mjs → chunk-CO67Y6YE.mjs} +2 -2
  114. package/dist/esm/{chunk-V7U5Y4AU.mjs.map → chunk-CO67Y6YE.mjs.map} +1 -1
  115. package/dist/esm/{chunk-WTLQD6MR.mjs → chunk-CQJLK4WE.mjs} +2 -2
  116. package/dist/esm/{chunk-NJN3EAOM.mjs → chunk-EBMEXURY.mjs} +2 -2
  117. package/dist/esm/chunk-FD6FGKYY.mjs +1 -0
  118. package/dist/esm/chunk-FD6FGKYY.mjs.map +1 -0
  119. package/dist/esm/{chunk-6PKBXYG3.mjs → chunk-FGFLPH5K.mjs} +2 -2
  120. package/dist/esm/{chunk-GLFZJNF3.mjs → chunk-GPNNEHW4.mjs} +2 -2
  121. package/dist/esm/chunk-GRPSFJ3N.mjs +4 -0
  122. package/dist/esm/chunk-GRPSFJ3N.mjs.map +1 -0
  123. package/dist/esm/chunk-HLF3U7IS.mjs +2 -0
  124. package/dist/esm/{chunk-L33JDCWL.mjs.map → chunk-HLF3U7IS.mjs.map} +1 -1
  125. package/dist/esm/{chunk-BUUV6B4P.mjs → chunk-HNBVYE3N.mjs} +2 -2
  126. package/dist/esm/{chunk-GJ7STZEW.mjs → chunk-HW7TSJI2.mjs} +2 -2
  127. package/dist/esm/chunk-JCFTAG5Z.mjs +2 -0
  128. package/dist/esm/{chunk-RJ7F4JDV.mjs.map → chunk-JCFTAG5Z.mjs.map} +1 -1
  129. package/dist/esm/{chunk-WLUXOUZH.mjs → chunk-MT2RJ7H3.mjs} +2 -2
  130. package/dist/esm/{chunk-SOJ3OG6X.mjs → chunk-N4VVDQA5.mjs} +2 -2
  131. package/dist/esm/{chunk-PRUQZNAP.mjs → chunk-N6YTF76Q.mjs} +2 -2
  132. package/dist/esm/{chunk-C6JRJNK3.mjs → chunk-ORMOQWWH.mjs} +2 -2
  133. package/dist/esm/{chunk-GYVSI3TS.mjs → chunk-RGKRCZ36.mjs} +2 -2
  134. package/dist/esm/{chunk-FBCXUC7J.mjs → chunk-RQX6JOEN.mjs} +2 -2
  135. package/dist/esm/{chunk-BXRBOMHW.mjs → chunk-SVMCNLFC.mjs} +2 -2
  136. package/dist/esm/{chunk-GQ557FEA.mjs → chunk-TDGLYA35.mjs} +2 -2
  137. package/dist/esm/{chunk-IXYGZ57N.mjs → chunk-TOBQ5UE6.mjs} +2 -2
  138. package/dist/esm/{chunk-VHNX2NUR.mjs → chunk-UL777LTI.mjs} +47 -26
  139. package/dist/esm/chunk-UL777LTI.mjs.map +1 -0
  140. package/dist/esm/{chunk-YQIAWAPY.mjs → chunk-UQWF24SS.mjs} +2 -2
  141. package/dist/esm/{chunk-YQIAWAPY.mjs.map → chunk-UQWF24SS.mjs.map} +1 -1
  142. package/dist/esm/{chunk-P237G6YB.mjs → chunk-V7NWNNBI.mjs} +2 -2
  143. package/dist/esm/{chunk-Z6KQX6VX.mjs → chunk-WCMW2L3P.mjs} +2 -2
  144. package/dist/esm/{chunk-BYINW7I2.mjs → chunk-WSR5EBJM.mjs} +2 -2
  145. package/dist/esm/chunk-XJJVJOX5.mjs +2 -0
  146. package/dist/esm/{chunk-OYH2T6V5.mjs → chunk-XKUIMGKU.mjs} +2 -2
  147. package/dist/esm/chunk-XTMUMN74.mjs +2 -0
  148. package/dist/esm/chunk-XTMUMN74.mjs.map +1 -0
  149. package/dist/esm/{chunk-JGFKIUG5.mjs → chunk-XTOIL6MB.mjs} +2 -2
  150. package/dist/esm/{chunk-JGFKIUG5.mjs.map → chunk-XTOIL6MB.mjs.map} +1 -1
  151. package/dist/esm/cli/index.d.mts +0 -1
  152. package/dist/esm/cli/index.mjs +1 -1
  153. package/dist/esm/cli/localNode.mjs +1 -1
  154. package/dist/esm/cli/move.d.mts +0 -1
  155. package/dist/esm/client/core.d.mts +0 -1
  156. package/dist/esm/client/core.mjs +1 -1
  157. package/dist/esm/client/get.d.mts +0 -1
  158. package/dist/esm/client/get.mjs +1 -1
  159. package/dist/esm/client/index.d.mts +0 -1
  160. package/dist/esm/client/index.mjs +1 -1
  161. package/dist/esm/client/post.d.mts +0 -1
  162. package/dist/esm/client/post.mjs +1 -1
  163. package/dist/esm/core/account/index.d.mts +0 -1
  164. package/dist/esm/core/account/index.mjs +1 -1
  165. package/dist/esm/core/account/utils/address.d.mts +0 -1
  166. package/dist/esm/core/account/utils/address.mjs +1 -1
  167. package/dist/esm/core/account/utils/index.d.mts +0 -1
  168. package/dist/esm/core/account/utils/index.mjs +1 -1
  169. package/dist/esm/core/accountAddress.d.mts +0 -1
  170. package/dist/esm/core/accountAddress.mjs +1 -1
  171. package/dist/esm/core/authenticationKey.d.mts +0 -1
  172. package/dist/esm/core/authenticationKey.mjs +1 -1
  173. package/dist/esm/core/crypto/abstraction.d.mts +0 -1
  174. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  175. package/dist/esm/core/crypto/ed25519.d.mts +1 -2
  176. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  177. package/dist/esm/core/crypto/ephemeral.d.mts +0 -1
  178. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  179. package/dist/esm/core/crypto/federatedKeyless.d.mts +1 -2
  180. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  181. package/dist/esm/core/crypto/index.d.mts +2 -2
  182. package/dist/esm/core/crypto/index.mjs +1 -1
  183. package/dist/esm/core/crypto/keyless.d.mts +1 -2
  184. package/dist/esm/core/crypto/keyless.mjs +1 -1
  185. package/dist/esm/core/crypto/multiEd25519.d.mts +10 -1
  186. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  187. package/dist/esm/core/crypto/multiKey.d.mts +2 -1
  188. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  189. package/dist/esm/core/crypto/privateKey.d.mts +0 -1
  190. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  191. package/dist/esm/core/crypto/proof.d.mts +0 -1
  192. package/dist/esm/core/crypto/proof.mjs +1 -1
  193. package/dist/esm/core/crypto/publicKey.d.mts +0 -1
  194. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  195. package/dist/esm/core/crypto/secp256k1.d.mts +1 -2
  196. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  197. package/dist/esm/core/crypto/signature.d.mts +0 -1
  198. package/dist/esm/core/crypto/signature.mjs +1 -1
  199. package/dist/esm/core/crypto/singleKey.d.mts +0 -1
  200. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  201. package/dist/esm/core/crypto/types.d.mts +25 -0
  202. package/dist/esm/core/crypto/types.mjs +2 -0
  203. package/dist/esm/core/crypto/types.mjs.map +1 -0
  204. package/dist/esm/core/crypto/utils.d.mts +0 -1
  205. package/dist/esm/core/hex.d.mts +0 -1
  206. package/dist/esm/core/index.d.mts +2 -2
  207. package/dist/esm/core/index.mjs +1 -1
  208. package/dist/esm/errors/index.d.mts +0 -1
  209. package/dist/esm/errors/index.mjs +1 -1
  210. package/dist/esm/{federatedKeyless-DAYXjY2Y.d.mts → federatedKeyless-BelAZrlM.d.mts} +2 -2
  211. package/dist/esm/index.d.mts +7 -8
  212. package/dist/esm/index.mjs +1 -1
  213. package/dist/esm/internal/abstraction.d.mts +0 -1
  214. package/dist/esm/internal/abstraction.mjs +1 -1
  215. package/dist/esm/internal/account.d.mts +43 -15
  216. package/dist/esm/internal/account.mjs +1 -1
  217. package/dist/esm/internal/ans.d.mts +2 -3
  218. package/dist/esm/internal/ans.mjs +1 -1
  219. package/dist/esm/internal/coin.d.mts +0 -1
  220. package/dist/esm/internal/coin.mjs +1 -1
  221. package/dist/esm/internal/digitalAsset.d.mts +2 -3
  222. package/dist/esm/internal/digitalAsset.mjs +1 -1
  223. package/dist/esm/internal/event.d.mts +0 -1
  224. package/dist/esm/internal/event.mjs +1 -1
  225. package/dist/esm/internal/faucet.d.mts +0 -1
  226. package/dist/esm/internal/faucet.mjs +1 -1
  227. package/dist/esm/internal/fungibleAsset.d.mts +1 -2
  228. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  229. package/dist/esm/internal/general.d.mts +0 -1
  230. package/dist/esm/internal/general.mjs +1 -1
  231. package/dist/esm/internal/keyless.d.mts +11 -3
  232. package/dist/esm/internal/keyless.mjs +1 -1
  233. package/dist/esm/internal/object.d.mts +0 -1
  234. package/dist/esm/internal/object.mjs +1 -1
  235. package/dist/esm/internal/staking.d.mts +0 -1
  236. package/dist/esm/internal/staking.mjs +1 -1
  237. package/dist/esm/internal/table.d.mts +0 -1
  238. package/dist/esm/internal/table.mjs +1 -1
  239. package/dist/esm/internal/transaction.d.mts +0 -1
  240. package/dist/esm/internal/transaction.mjs +1 -1
  241. package/dist/esm/internal/transactionSubmission.d.mts +1 -2
  242. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  243. package/dist/esm/internal/utils/index.d.mts +0 -1
  244. package/dist/esm/internal/utils/index.mjs +1 -1
  245. package/dist/esm/internal/utils/utils.d.mts +0 -1
  246. package/dist/esm/internal/utils/utils.mjs +1 -1
  247. package/dist/esm/internal/view.d.mts +0 -1
  248. package/dist/esm/internal/view.mjs +1 -1
  249. package/dist/esm/transactions/authenticator/account.d.mts +0 -1
  250. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  251. package/dist/esm/transactions/authenticator/index.d.mts +0 -1
  252. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  253. package/dist/esm/transactions/authenticator/transaction.d.mts +0 -1
  254. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  255. package/dist/esm/transactions/index.d.mts +2 -4
  256. package/dist/esm/transactions/index.mjs +1 -1
  257. package/dist/esm/transactions/instances/chainId.d.mts +0 -1
  258. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  259. package/dist/esm/transactions/instances/identifier.d.mts +0 -1
  260. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  261. package/dist/esm/transactions/instances/index.d.mts +0 -1
  262. package/dist/esm/transactions/instances/index.mjs +1 -1
  263. package/dist/esm/transactions/instances/moduleId.d.mts +0 -1
  264. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  265. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +0 -1
  266. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  267. package/dist/esm/transactions/instances/rawTransaction.d.mts +0 -1
  268. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  269. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +0 -1
  270. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  271. package/dist/esm/transactions/instances/signedTransaction.d.mts +0 -1
  272. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  273. package/dist/esm/transactions/instances/simpleTransaction.d.mts +0 -1
  274. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  275. package/dist/esm/transactions/instances/transactionArgument.d.mts +0 -1
  276. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -2
  277. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  278. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -2
  279. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  280. package/dist/esm/transactions/management/index.d.mts +1 -2
  281. package/dist/esm/transactions/management/index.mjs +1 -1
  282. package/dist/esm/transactions/management/transactionWorker.d.mts +1 -2
  283. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  284. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +0 -1
  285. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  286. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -2
  287. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  288. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -13
  289. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  290. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +0 -1
  291. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  292. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -3
  293. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  294. package/dist/esm/transactions/typeTag/index.d.mts +0 -1
  295. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  296. package/dist/esm/transactions/typeTag/parser.d.mts +0 -1
  297. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  298. package/dist/esm/transactions/types.d.mts +2 -11
  299. package/dist/esm/types/generated/operations.d.mts +37 -10
  300. package/dist/esm/types/generated/queries.d.mts +6 -2
  301. package/dist/esm/types/generated/queries.mjs +1 -1
  302. package/dist/esm/types/generated/types.d.mts +584 -1172
  303. package/dist/esm/types/generated/types.mjs +1 -1
  304. package/dist/esm/types/generated/types.mjs.map +1 -1
  305. package/dist/esm/types/index.d.mts +2 -3
  306. package/dist/esm/types/index.mjs +1 -1
  307. package/dist/esm/types/indexer.d.mts +8 -2
  308. package/dist/esm/types/types.d.mts +25 -4
  309. package/dist/esm/types/types.mjs +1 -1
  310. package/dist/esm/utils/const.d.mts +1 -0
  311. package/dist/esm/utils/const.mjs +1 -1
  312. package/dist/esm/utils/helpers.d.mts +0 -1
  313. package/dist/esm/utils/helpers.mjs +1 -1
  314. package/dist/esm/utils/index.d.mts +0 -1
  315. package/dist/esm/utils/index.mjs +1 -1
  316. package/dist/esm/utils/normalizeBundle.d.mts +0 -1
  317. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  318. package/dist/esm/version.d.mts +1 -1
  319. package/dist/esm/version.mjs +1 -1
  320. package/package.json +3 -4
  321. package/src/account/FederatedKeylessAccount.ts +7 -1
  322. package/src/account/KeylessAccount.ts +17 -2
  323. package/src/api/account.ts +122 -2
  324. package/src/api/aptosConfig.ts +9 -0
  325. package/src/api/transaction.ts +1 -0
  326. package/src/api/transactionSubmission/build.ts +2 -85
  327. package/src/core/crypto/ed25519.ts +1 -1
  328. package/src/core/crypto/index.ts +1 -0
  329. package/src/core/crypto/multiEd25519.ts +26 -0
  330. package/src/core/crypto/multiKey.ts +6 -0
  331. package/src/core/crypto/secp256k1.ts +1 -1
  332. package/src/core/crypto/types.ts +9 -0
  333. package/src/internal/account.ts +523 -53
  334. package/src/internal/keyless.ts +10 -0
  335. package/src/internal/queries/getAccountAddressesForAuthKey.graphql +8 -0
  336. package/src/internal/queries/getAuthKeysForPublicKey.graphql +11 -0
  337. package/src/transactions/index.ts +0 -1
  338. package/src/transactions/transactionBuilder/remoteAbi.ts +1 -26
  339. package/src/transactions/types.ts +0 -11
  340. package/src/types/codegen.yaml +1 -1
  341. package/src/types/generated/operations.ts +39 -8
  342. package/src/types/generated/queries.ts +53 -0
  343. package/src/types/generated/types.ts +620 -1239
  344. package/src/types/index.ts +0 -1
  345. package/src/types/indexer.ts +8 -0
  346. package/src/types/types.ts +40 -3
  347. package/src/utils/const.ts +1 -0
  348. package/src/version.ts +1 -1
  349. package/dist/common/chunk-66TIRJFD.js +0 -4
  350. package/dist/common/chunk-66TIRJFD.js.map +0 -1
  351. package/dist/esm/chunk-3OLFJ65O.mjs +0 -2
  352. package/dist/esm/chunk-3OLFJ65O.mjs.map +0 -1
  353. package/dist/esm/chunk-F2ZTBAJJ.mjs +0 -2
  354. package/dist/esm/chunk-F2ZTBAJJ.mjs.map +0 -1
  355. package/dist/esm/chunk-L33JDCWL.mjs +0 -2
  356. package/dist/esm/chunk-ODAAZLPK.mjs +0 -2
  357. package/dist/esm/chunk-ODAAZLPK.mjs.map +0 -1
  358. package/dist/esm/chunk-OYUW6ZN2.mjs +0 -2
  359. package/dist/esm/chunk-RJ7F4JDV.mjs +0 -2
  360. package/dist/esm/chunk-TAEOFYOF.mjs +0 -4
  361. package/dist/esm/chunk-TAEOFYOF.mjs.map +0 -1
  362. package/dist/esm/chunk-TUZHLTDU.mjs +0 -2
  363. package/dist/esm/chunk-VHNX2NUR.mjs.map +0 -1
  364. package/dist/esm/transactions/scriptComposer/index.d.mts +0 -53
  365. package/dist/esm/transactions/scriptComposer/index.mjs +0 -2
  366. package/src/transactions/scriptComposer/index.ts +0 -102
  367. /package/dist/esm/{chunk-ARNW34PP.mjs.map → chunk-2DYSBAZ7.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-3IHKQH5O.mjs.map → chunk-34R7FSQF.mjs.map} +0 -0
  369. /package/dist/esm/{chunk-XF6BISPI.mjs.map → chunk-3BUKTQDX.mjs.map} +0 -0
  370. /package/dist/esm/{chunk-KAYKTT4S.mjs.map → chunk-4F5EECVQ.mjs.map} +0 -0
  371. /package/dist/esm/{chunk-TUZHLTDU.mjs.map → chunk-4YLUM62M.mjs.map} +0 -0
  372. /package/dist/esm/{transactions/scriptComposer/index.mjs.map → chunk-5HXLZHDW.mjs.map} +0 -0
  373. /package/dist/esm/{chunk-25O4L7YR.mjs.map → chunk-6UZHMEK3.mjs.map} +0 -0
  374. /package/dist/esm/{chunk-6Y6ZO7TS.mjs.map → chunk-6WDVDEQZ.mjs.map} +0 -0
  375. /package/dist/esm/{chunk-YFFDF22R.mjs.map → chunk-7DQDJ2SA.mjs.map} +0 -0
  376. /package/dist/esm/{chunk-ZMT2M6YT.mjs.map → chunk-B563XRSZ.mjs.map} +0 -0
  377. /package/dist/esm/{chunk-WTLQD6MR.mjs.map → chunk-CQJLK4WE.mjs.map} +0 -0
  378. /package/dist/esm/{chunk-NJN3EAOM.mjs.map → chunk-EBMEXURY.mjs.map} +0 -0
  379. /package/dist/esm/{chunk-6PKBXYG3.mjs.map → chunk-FGFLPH5K.mjs.map} +0 -0
  380. /package/dist/esm/{chunk-GLFZJNF3.mjs.map → chunk-GPNNEHW4.mjs.map} +0 -0
  381. /package/dist/esm/{chunk-BUUV6B4P.mjs.map → chunk-HNBVYE3N.mjs.map} +0 -0
  382. /package/dist/esm/{chunk-GJ7STZEW.mjs.map → chunk-HW7TSJI2.mjs.map} +0 -0
  383. /package/dist/esm/{chunk-WLUXOUZH.mjs.map → chunk-MT2RJ7H3.mjs.map} +0 -0
  384. /package/dist/esm/{chunk-SOJ3OG6X.mjs.map → chunk-N4VVDQA5.mjs.map} +0 -0
  385. /package/dist/esm/{chunk-PRUQZNAP.mjs.map → chunk-N6YTF76Q.mjs.map} +0 -0
  386. /package/dist/esm/{chunk-C6JRJNK3.mjs.map → chunk-ORMOQWWH.mjs.map} +0 -0
  387. /package/dist/esm/{chunk-GYVSI3TS.mjs.map → chunk-RGKRCZ36.mjs.map} +0 -0
  388. /package/dist/esm/{chunk-FBCXUC7J.mjs.map → chunk-RQX6JOEN.mjs.map} +0 -0
  389. /package/dist/esm/{chunk-BXRBOMHW.mjs.map → chunk-SVMCNLFC.mjs.map} +0 -0
  390. /package/dist/esm/{chunk-GQ557FEA.mjs.map → chunk-TDGLYA35.mjs.map} +0 -0
  391. /package/dist/esm/{chunk-IXYGZ57N.mjs.map → chunk-TOBQ5UE6.mjs.map} +0 -0
  392. /package/dist/esm/{chunk-P237G6YB.mjs.map → chunk-V7NWNNBI.mjs.map} +0 -0
  393. /package/dist/esm/{chunk-Z6KQX6VX.mjs.map → chunk-WCMW2L3P.mjs.map} +0 -0
  394. /package/dist/esm/{chunk-BYINW7I2.mjs.map → chunk-WSR5EBJM.mjs.map} +0 -0
  395. /package/dist/esm/{chunk-OYUW6ZN2.mjs.map → chunk-XJJVJOX5.mjs.map} +0 -0
  396. /package/dist/esm/{chunk-OYH2T6V5.mjs.map → chunk-XKUIMGKU.mjs.map} +0 -0
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunk66TIRJFDjs = require('./chunk-66TIRJFD.js');var R=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunk66TIRJFDjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunk66TIRJFDjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),(r&128)===0)break;t+=7}if(e>_chunk66TIRJFDjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Ee=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var nr=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=new Ee(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ee.deserialize(e,t);return new n(r.value)}};var z=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new ye(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},X= exports.U8 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Pe= exports.U16 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},_e= exports.U32 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},Q= exports.U64 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},xe= exports.U128 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},ye= exports.U256 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var S=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof X)){new hn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunk66TIRJFDjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new X(r)))}static U16(e){return new n(e.map(t=>new Pe(t)))}static U32(e){return new n(e.map(t=>new _e(t)))}static U64(e){return new n(e.map(t=>new Q(t)))}static U128(e){return new n(e.map(t=>new xe(t)))}static U256(e){return new n(e.map(t=>new ye(t)))}static Bool(e){return new n(e.map(t=>new z(t)))}static MoveString(e){return new n(e.map(t=>new x(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},hn= exports.Serialized =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new R(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new S(r)}},x= exports.MoveString =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Y= exports.MoveOption =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new X(e):void 0)}static U16(e){return new n(e!=null?new Pe(e):void 0)}static U32(e){return new n(e!=null?new _e(e):void 0)}static U64(e){return new n(e!=null?new Q(e):void 0)}static U128(e){return new n(e!=null?new xe(e):void 0)}static U256(e){return new n(e!=null?new ye(e):void 0)}static Bool(e){return new n(e!=null?new z(e):void 0)}static MoveString(e){return new n(e!=null?new x(e):void 0)}static deserialize(e,t){let r=S.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var ut=class ut extends _chunk66TIRJFDjs.l{constructor(e){super();let{data:t}=e,r=_chunk66TIRJFDjs.j.fromHexInput(t);if(r.toUint8Array().length!==ut.LENGTH)throw new Error(`Authentication Key length should be ${ut.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(ut.LENGTH);return new ut({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new ut({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunk66TIRJFDjs.Z)(this.data.toUint8Array())}};ut.LENGTH=32;var B=ut;var St=class extends _chunk66TIRJFDjs.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}},ie= exports.AccountPublicKey =class extends St{};var M=class extends _chunk66TIRJFDjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}};var Tn=class n extends M{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},rr= exports.AbstractPublicKey =class extends ie{constructor(e){super(),this.accountAddress=e}authKey(){return new B({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var go = _interopRequireWildcard(_bip39);var fc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ac= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,hc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(hc||{}),mo= exports.HARDENED_OFFSET =2147483648;function yo(n){return Ac.test(n)}function fo(n){return fc.test(n)}var Zr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Ao= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Zr(e,s)},Tc=n=>n.replace(/'/g,""),ho= exports.splitPath =n=>n.split("/").slice(1).map(Tc),ir= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return go.mnemonicToSeedSync(e)};var bn=class bn{static formatPrivateKey(e,t){let r=bn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk66TIRJFDjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=bn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunk66TIRJFDjs.j.fromHexInput(e);return i}};bn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var pt=bn;var Wt=n=>typeof n=="string"?_chunk66TIRJFDjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var ei=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function bc(n){let e=n.toUint8Array().slice(32);for(let t=ei.length-1;t>=0;t-=1){if(e[t]<ei[t])return!0;if(e[t]>ei[t])return!1}return!1}var dt=class dt extends ie{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==dt.LENGTH)throw new Error(`PublicKey length should be ${dt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!bc(r))return!1;let i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new dt(t)}static isPublicKey(e){return e instanceof dt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===dt.LENGTH}};dt.LENGTH=32;var I=dt,fe=class fe extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==fe.LENGTH)throw new Error(`PrivateKey length should be ${fe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new fe(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return fe.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t,r=mo){let{key:i,chainCode:o}=Zr(fe.SLIP_0010_SEED,t),s=ho(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Ao(c,p+r),{key:i,chainCode:o});return new fe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new K(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return pt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new fe(t,!1)}static isPrivateKey(e){return e instanceof fe}};fe.LENGTH=32,fe.SLIP_0010_SEED="ed25519 seed";var q=fe,Qt=class Qt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Qt.LENGTH)throw new Error(`Signature length should be ${Qt.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 Qt(t)}};Qt.LENGTH=64;var K=Qt;var lt=class n extends St{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof I)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ue= exports.EphemeralSignature =class n extends M{constructor(e){super();let t=e.constructor.name;switch(t){case K.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunk66TIRJFDjs.j.fromHexInput(e),r=new R(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof K)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(K.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _jwtdecode = require('jwt-decode');var _poseidonlite = require('poseidon-lite');var ti=[_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],bo=31,Fc=16,To=(Fc-1)*bo;function ke(n,e){let r=new TextEncoder().encode(n);return Oc(r,e)}function Oc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=wn(n,e);return Pt(t)}function Gc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Vc(n,e);return Bc(t)}function wn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Gc(n,e).concat([BigInt(n.length)])}function Bc(n){if(n.length>To)throw new Error(`Can't pack more than ${To}. Was given ${n.length} bytes`);return Mc(n,bo).map(e=>Et(e))}function Mc(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function Et(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function ni(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Vc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Pt(n){if(n.length>ti.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${ti.length}`);return ti[n.length-1](n)}var sr=class extends _chunk66TIRJFDjs.l{};var wo="1.39.0";var So={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Eo= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Po= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},ri= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ii= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},oi= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(oi||{}),si= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Il= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var _t=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(_t||{}),_o= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,xo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,ar= exports.DEFAULT_TXN_TIMEOUT_SEC =20,xt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Io= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Co= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",ai= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",He= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(He||{}),vo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Ko(n,e){let t=e.bcsToBytes(),r=new R(t);return n.deserialize(r)}var Hc=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(Hc||{}),Lc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(Lc||{}),cr= exports.KeylessErrorType =(y=>(y[y.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",y[y.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",y[y.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",y[y.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",y[y.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",y[y.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",y[y.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",y[y.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",y[y.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",y[y.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",y[y.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",y[y.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",y[y.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",y[y.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",y[y.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",y[y.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",y[y.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",y[y.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",y[y.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",y[y.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",y[y.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",y[y.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",y[y.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",y[y.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",y[y.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",y[y.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",y[y.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",y[y.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",y[y.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",y[y.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",y[y.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",y[y.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",y[y.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",y[y.UNKNOWN=33]="UNKNOWN",y))(cr||{}),Ro={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},P= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Ro[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
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 _chunkBNN2XWNRjs = require('./chunk-BNN2XWNR.js');var K=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunkBNN2XWNRjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunkBNN2XWNRjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunkBNN2XWNRjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Ee=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.value=_chunkBNN2XWNRjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Zn=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.value=new Ee(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ee.deserialize(e,t);return new n(r.value)}};var N=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new he(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},X= exports.U8 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,0,_chunkBNN2XWNRjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},xe= exports.U16 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,0,_chunkBNN2XWNRjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},Ie= exports.U32 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,0,_chunkBNN2XWNRjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},Q= exports.U64 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,BigInt(0),_chunkBNN2XWNRjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ve= exports.U128 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,BigInt(0),_chunkBNN2XWNRjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},he= exports.U256 =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),_chunkBNN2XWNRjs.p.call(void 0, e,BigInt(0),_chunkBNN2XWNRjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var _=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof X)){new mn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunkBNN2XWNRjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new X(r)))}static U16(e){return new n(e.map(t=>new xe(t)))}static U32(e){return new n(e.map(t=>new Ie(t)))}static U64(e){return new n(e.map(t=>new Q(t)))}static U128(e){return new n(e.map(t=>new ve(t)))}static U256(e){return new n(e.map(t=>new he(t)))}static Bool(e){return new n(e.map(t=>new N(t)))}static MoveString(e){return new n(e.map(t=>new I(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},mn= exports.Serialized =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.value=_chunkBNN2XWNRjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new K(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new _(r)}},I= exports.MoveString =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);_.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Y= exports.MoveOption =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new _([e]):this.vec=new _([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new X(e):void 0)}static U16(e){return new n(e!=null?new xe(e):void 0)}static U32(e){return new n(e!=null?new Ie(e):void 0)}static U64(e){return new n(e!=null?new Q(e):void 0)}static U128(e){return new n(e!=null?new ve(e):void 0)}static U256(e){return new n(e!=null?new he(e):void 0)}static Bool(e){return new n(e!=null?new N(e):void 0)}static MoveString(e){return new n(e!=null?new I(e):void 0)}static deserialize(e,t){let r=_.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var gt=class gt extends _chunkBNN2XWNRjs.l{constructor(e){super();let{data:t}=e,r=_chunkBNN2XWNRjs.j.fromHexInput(t);if(r.toUint8Array().length!==gt.LENGTH)throw new Error(`Authentication Key length should be ${gt.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(gt.LENGTH);return new gt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunkBNN2XWNRjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new gt({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunkBNN2XWNRjs._)(this.data.toUint8Array())}};gt.LENGTH=32;var L=gt;var xt=class extends _chunkBNN2XWNRjs.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkBNN2XWNRjs.j.fromHexInput(e).toString()}},oe= exports.AccountPublicKey =class extends xt{};var B=class extends _chunkBNN2XWNRjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkBNN2XWNRjs.j.fromHexInput(e).toString()}};var fn=class n extends B{constructor(e){super(),this.value=_chunkBNN2XWNRjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},er= exports.AbstractPublicKey =class extends oe{constructor(e){super(),this.accountAddress=e}authKey(){return new L({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var yo = _interopRequireWildcard(_bip39);var fc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ac= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,hc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(hc||{}),mo= exports.HARDENED_OFFSET =2147483648;function fo(n){return Ac.test(n)}function Ao(n){return fc.test(n)}var Yr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},ho= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Yr(e,s)},bc=n=>n.replace(/'/g,""),bo= exports.splitPath =n=>n.split("/").slice(1).map(bc),tr= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return yo.mnemonicToSeedSync(e)};var An=class An{static formatPrivateKey(e,t){let r=An.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunkBNN2XWNRjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=An.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunkBNN2XWNRjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunkBNN2XWNRjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunkBNN2XWNRjs.j.fromHexInput(e);return i}};An.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var yt=An;var $t=n=>typeof n=="string"?_chunkBNN2XWNRjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var Zr=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Tc(n){let e=n.toUint8Array().slice(32);for(let t=Zr.length-1;t>=0;t-=1){if(e[t]<Zr[t])return!0;if(e[t]>Zr[t])return!1}return!1}var mt=class mt extends oe{constructor(e){super();let t=_chunkBNN2XWNRjs.j.fromHexInput(e);if(t.toUint8Array().length!==mt.LENGTH)throw new Error(`PublicKey length should be ${mt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!Tc(r))return!1;let i=$t(t),o=_chunkBNN2XWNRjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return L.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new mt(t)}static isPublicKey(e){return e instanceof mt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===mt.LENGTH}};mt.LENGTH=32;var E=mt,be=class be extends _chunkBNN2XWNRjs.l{constructor(e,t){super();let r=yt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==be.LENGTH)throw new Error(`PrivateKey length should be ${be.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new be(e,!1)}static fromDerivationPath(e,t){if(!Ao(e))throw new Error(`Invalid derivation path ${e}`);return be.fromDerivationPathInner(e,tr(t))}static fromDerivationPathInner(e,t,r=mo){let{key:i,chainCode:o}=Yr(be.SLIP_0010_SEED,t),s=bo(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>ho(c,d+r),{key:i,chainCode:o});return new be(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new E(e)}sign(e){let t=$t(e),r=_chunkBNN2XWNRjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new R(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return yt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new be(t,!1)}static isPrivateKey(e){return e instanceof be}};be.LENGTH=32,be.SLIP_0010_SEED="ed25519 seed";var q=be,Wt=class Wt extends B{constructor(e){super();let t=_chunkBNN2XWNRjs.j.fromHexInput(e);if(t.toUint8Array().length!==Wt.LENGTH)throw new Error(`Signature length should be ${Wt.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 Wt(t)}};Wt.LENGTH=64;var R=Wt;var ft=class n extends xt{constructor(e){super();let t=e.constructor.name;switch(t){case E.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof E)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(E.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ne= exports.EphemeralSignature =class n extends B{constructor(e){super();let t=e.constructor.name;switch(t){case R.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunkBNN2XWNRjs.j.fromHexInput(e),r=new K(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof R)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(R.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _jwtdecode = require('jwt-decode');var _poseidonlite = require('poseidon-lite');var ei=[_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],wo=31,Oc=16,To=(Oc-1)*wo;function Oe(n,e){let r=new TextEncoder().encode(n);return zc(r,e)}function zc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=hn(n,e);return vt(t)}function Gc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Vc(n,e);return Bc(t)}function hn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Gc(n,e).concat([BigInt(n.length)])}function Bc(n){if(n.length>To)throw new Error(`Can't pack more than ${To}. Was given ${n.length} bytes`);return Mc(n,wo).map(e=>It(e))}function Mc(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function It(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function ti(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Vc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function vt(n){if(n.length>ei.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${ei.length}`);return ei[n.length-1](n)}var rr=class extends _chunkBNN2XWNRjs.l{};var So="2.0.0";var _o={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Po= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Eo= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},ni= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ri= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},ii= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(ii||{}),oi= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Nl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Qt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(Qt||{}),xo= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Io= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,ir= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Ct= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",vo= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Co= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",si= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",We= exports.ProcessorType =(d=>(d.ACCOUNT_RESTORATION_PROCESSOR="account_restoration_processor",d.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",d.DEFAULT="default_processor",d.EVENTS_PROCESSOR="events_processor",d.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",d.STAKE_PROCESSOR="stake_processor",d.TOKEN_V2_PROCESSOR="token_v2_processor",d.USER_TRANSACTION_PROCESSOR="user_transaction_processor",d.OBJECT_PROCESSOR="objects_processor",d))(We||{}),Ko= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Ro(n,e){let t=e.bcsToBytes(),r=new K(t);return n.deserialize(r)}var Hc=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(Hc||{}),Lc= exports.KeylessErrorResolutionTip =(d=>(d.REAUTHENTICATE="Re-authentiate to continue using your keyless account",d.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",d.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",d.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",d.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",d.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",d.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d))(Lc||{}),or= exports.KeylessErrorType =(m=>(m[m.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",m[m.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",m[m.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",m[m.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",m[m.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",m[m.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",m[m.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",m[m.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",m[m.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",m[m.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",m[m.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",m[m.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",m[m.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",m[m.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",m[m.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",m[m.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",m[m.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",m[m.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",m[m.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",m[m.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",m[m.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",m[m.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",m[m.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",m[m.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",m[m.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",m[m.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",m[m.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",m[m.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",m[m.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",m[m.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",m[m.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",m[m.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",m[m.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",m[m.UNKNOWN=33]="UNKNOWN",m))(or||{}),Uo={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},P= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Uo[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
2
2
  Message: ${e}`;return i&&(o+=`
3
- Details: ${i}`),r instanceof Ae?o+=`
3
+ Details: ${i}`),r instanceof Te?o+=`
4
4
  AptosApiError: ${r.message}`:r!==void 0&&(o+=`
5
- Error: ${_chunk66TIRJFDjs.ca.call(void 0, r)}`),o+=`
6
- KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Ro[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Ae= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(qc({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function qc({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _5 => _5.headers, 'optionalAccess', _6 => _6.traceparent, 'optionalAccess', _7 => _7.split, 'call', _8 => _8("-"), 'access', _9 => _9[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.errors, 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _14 => _14.data, 'optionalAccess', _15 => _15.message])!=null&&_optionalChain([t, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${$c(t.data)}`}var ci=400;function $c(n){let e=JSON.stringify(n);return e.length<=ci?e:`truncated(original_size:${e.length}): ${e.slice(0,ci/2)}...${e.slice(-ci/2)}`}async function Wc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _18 => _18.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${wo}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _19 => _19.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _20 => _20.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _21 => _21.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _22 => _22.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:p,overrides:a})}async function ur(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Wc({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a})}async function pr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return ur({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function V(n){let{aptosConfig:e}=n;return pr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([e, 'access', _25 => _25.fullnodeConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function eg(n){return pr({...n,type:"Pepper"})}async function dr(n){let e=new Array(0),t,r=n.params;do{let i=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function ui(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await lr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _27 => _27.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function lr(n){let e,t={};typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _30 => _30.params, 'optionalAccess', _31 => _31.limit])=="number"&&(t.limit=n.params.limit);let r=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function Sn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,l=c.getRequestUrl(e);return ur({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function gt(n){let{aptosConfig:e}=n;return Sn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function Uo(n){let{aptosConfig:e}=n;return Sn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.indexerConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _40 => _40.clientConfig, 'optionalAccess', _41 => delete _41.API_KEY]),Sn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _42 => _42.clientConfig, 'optionalAccess', _43 => _43.HEADERS]),..._optionalChain([t, 'access', _44 => _44.faucetConfig, 'optionalAccess', _45 => _45.HEADERS])}}})}async function Do(n){return Sn({...n,type:"Pepper"})}async function zo(n){return Sn({...n,type:"Prover"})}var pi=new Map;function De(n,e,t){return async(...r)=>{if(pi.has(e)){let{value:o,timestamp:s}=pi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return pi.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var Xc=1e7,di= exports.MAX_AUD_VAL_BYTES =120,Yc= exports.MAX_UID_KEY_BYTES =30,Zc= exports.MAX_UID_VAL_BYTES =330,eu= exports.MAX_ISS_VAL_BYTES =120,tu= exports.MAX_EXTRA_FIELD_BYTES =350,nu= exports.MAX_JWT_HEADER_B64_BYTES =300,ru= exports.MAX_COMMITED_EPK_BYTES =93,ze=class ze extends ie{constructor(e,t){super();let r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array();if(r.length!==ze.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${ze.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch(t){if(t instanceof P)return!1;throw t}}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static isPublicKey(e){return e instanceof ze}static create(e){return No(e),new ze(e.iss,No(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return ze.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};ze.ID_COMMITMENT_LENGTH=32;var U=ze;async function Ai(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});return gr({message:r,publicKey:t,signature:i,jwk:o||await hi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _46 => _46.throwErrorWithReason]))throw c;return!1}}function gr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ue))throw P.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let p=r.ephemeralCertificate.signature;if(!(p.proof.proof instanceof mt))throw P.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=p.proof.proof;if(r.expiryDateSecs<_chunk66TIRJFDjs.da.call(void 0, ))throw P.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(p.expHorizonSecs>a)throw P.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw P.fromErrorType({type:29});let h=iu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:h,groth16Proof:l}))throw P.fromErrorType({type:32});if(c){if(!p.trainingWheelsSignature)throw P.fromErrorType({type:30});let d=new gi(l,h);if(!c.verifySignature({message:d.hash(),signature:p.trainingWheelsSignature}))throw P.fromErrorType({type:31})}}function iu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof U?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ue))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...wn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Et(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(ke(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(ke(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(ke(" ",i.maxExtraFieldBytes))),a.push(ke(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(ke(s.overrideAudVal,di)),a.push(1n)):(a.push(ke("",di)),a.push(0n)),Pt(a)}async function hi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof U?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof Z?t.jwkAddress:void 0;try{s=await au({aptosConfig:e,jwkAddr:a})}catch(l){throw P.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw P.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let p=c.find(l=>l.kid===r);if(p===void 0)throw P.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return p}function No(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array()),ke(r,di),ke(t,Zc),ke(e,Yc)];return ni(Pt(o),U.ID_COMMITMENT_LENGTH)}var he=class n extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return uu(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=jt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=lt.deserialize(e),s=Ue.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new jt(new ue({proof:new Jt(new mt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new lt(new I(new Uint8Array(32))),ephemeralSignature:new Ue(new K(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},jt= exports.EphemeralCertificate =class n extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ue.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},En=class En extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new En(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=_bn254.bn254.fields,i=r.create(li(e)),o=r.sqrt(r.add(r.pow(i,3n),En.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};En.B=_bn254.bn254.fields.Fp.create(3n);var Le=En;function li(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var Pn=class Pn extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Pn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=_bn254.bn254.fields,s=o.fromBigTuple([li(t),li(r)]),a=o.sqrt(o.add(o.pow(s,3n),Pn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Pn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Pn,mt= exports.Groth16Zkp =class n extends sr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Le(t),this.b=new It(r),this.c=new Le(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Le.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=Le.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},gi= exports.Groth16ProofAndStatement =class n extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ni(r,32):_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(mt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}},Jt= exports.ZkProof =class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(mt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ue= exports.ZeroKnowledgeSig =class n extends M{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new R(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ue);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},mi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Xc,maxExtraFieldBytes:o=tu,maxJwtHeaderB64Bytes:s=nu,maxIssValBytes:a=eu,maxCommitedEpkBytes:c=ru}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new lt(new I(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new yi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},yi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Le(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new Le(o[0]),new Le(o[1])],this.gammaG2=new It(s)}hash(){let e=new _chunk66TIRJFDjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),p=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),h=this.gammaAbcG1.map(at=>at.toProjectivePoint()),{Fp12:d}=_bn254.bn254.fields,g=h[0].add(h[1].multiply(t)),b=_bn254.bn254.pairing(g,p),v=_bn254.bn254.pairing(i,o),W=_bn254.bn254.pairing(a,c),Me=_bn254.bn254.pairing(s,l),st=d.mul(W,d.mul(b,Me));return d.eql(v,st)}catch(i){throw P.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await De(async()=>{let[t,r]=await Promise.all([ou(n),su(n)]);return mi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof P?t:P.fromErrorType({type:25,error:t})}}function qe(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw P.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunk66TIRJFDjs.ca.call(void 0, o)}`})}if(typeof r.iss!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function ou(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _47 => _47.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function su(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _48 => _48.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function au(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _49 => _49.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _50 => _50.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,l=new R(_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array()),h=fi.deserialize(l);a.push(h)}o.set(_chunk66TIRJFDjs.k.call(void 0, s.issuer),a)}return o}var fi=class n extends _chunk66TIRJFDjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new R(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw P.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk66TIRJFDjs.ga.call(void 0, this.n),r=cu(e.reverse()).map(i=>Et(i));return r.push(256n),Pt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function cu(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function uu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var Z=class n extends ie{constructor(e,t){super(),this.jwkAddress=_chunk66TIRJFDjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=U.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,U.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,U.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk66TIRJFDjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof U}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ce=class Ce extends St{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Ce.LENGTH)this.key=t;else if(r===Ce.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunk66TIRJFDjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ce.LENGTH} or ${Ce.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new Ct(t)}static deserialize(e){let t=e.deserializeBytes();return new Ce(t)}static isPublicKey(e){return e instanceof Ce}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===Ce.LENGTH}};Ce.LENGTH=65,Ce.COMPRESSED_LENGTH=33;var $e=Ce,Ne=class Ne extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Ne.LENGTH)throw new Error(`PrivateKey length should be ${Ne.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ne(e,!1)}static fromDerivationPath(e,t){if(!yo(e))throw new Error(`Invalid derivation path ${e}`);return Ne.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Ne(r,!1)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new Ct(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new $e(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return pt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ne(t,!1)}static isPrivateKey(e){return e instanceof Ne}};Ne.LENGTH=32;var We=Ne,Yt=class Yt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Yt.LENGTH)throw new Error(`Signature length should be ${Yt.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 Yt(t)}};Yt.LENGTH=64;var Ct=Yt;var N=class n extends ie{constructor(e){if(super(),this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof $e)this.variant=1;else if(e instanceof U)this.variant=3;else if(e instanceof Z)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof U)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof H)){if(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.throwErrorWithReason]))throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=I.deserialize(e);break;case 1:r=$e.deserialize(e);break;case 3:r=U.deserialize(e);break;case 4:r=Z.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 I}isSecp256k1PublicKey(){return this.publicKey instanceof $e}static isInstance(e){return"publicKey"in e&&"variant"in e}},H= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof K)this.variant=0;else if(e instanceof Ct)this.variant=1;else if(e instanceof he)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=K.deserialize(e);break;case 1:r=Ct.deserialize(e);break;case 3:r=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function du(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var xn=class extends ie{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},Fe= exports.MultiKey =class n extends xn{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof N?i:new N(i)),this.signaturesRequired=r}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Oe))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(N),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof N?e:new N(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},pe=class pe extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${pe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof H?o:new H(o)),!(r instanceof Uint8Array))this.bitmap=pe.createBitmap({bits:r});else{if(r.length!==pe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${pe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+du(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${pe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(H),r=e.deserializeBytes();return new pe({signatures:t,bitmap:r})}};pe.BITMAP_LEN=4,pe.MAX_SIGNATURES_SUPPORTED=pe.BITMAP_LEN*8;var Oe=pe;var Te=class Te extends xn{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>Te.MAX_KEYS||t.length<Te.MIN_KEYS)throw new Error(`Must have between ${Te.MIN_KEYS} and ${Te.MAX_KEYS} public keys, inclusive`);if(r<Te.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${Te.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Qe))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*I.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*I.LENGTH)}),e[this.publicKeys.length*I.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new Te({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};Te.MAX_KEYS=32,Te.MIN_KEYS=2,Te.MIN_THRESHOLD=1;var Zt=Te,de=class de extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>de.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${de.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=de.createBitmap({bits:r});else{if(r.length!==de.BITMAP_LEN)throw new Error(`"bitmap" length should be ${de.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*K.LENGTH+de.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*K.LENGTH)}),e.set(this.bitmap,this.signatures.length*K.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=K.LENGTH){let s=o;i.push(new K(t.subarray(s,s+K.LENGTH)))}return new de({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=de.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${de.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}};de.MAX_SIGNATURES_SUPPORTED=32,de.BITMAP_LEN=4;var Qe=de;var j=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ve.load(e);case 1:return je.load(e);case 2:return oe.load(e);case 3:return Ge.load(e);case 4:return en.load(e);case 5:return vt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof ve}isMultiEd25519(){return this instanceof je}isSingleKey(){return this instanceof oe}isMultiKey(){return this instanceof Ge}},ve= exports.AccountAuthenticatorEd25519 =class n extends j{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=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},je= exports.AccountAuthenticatorMultiEd25519 =class n extends j{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=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},oe= exports.AccountAuthenticatorSingleKey =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=N.deserialize(e),r=H.deserialize(e);return new n(t,r)}},Ge= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Fe.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}},en= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},vt= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r,i){if(super(),!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=r,this.signingMessageDigest=_chunk66TIRJFDjs.j.fromHexInput(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, this.functionInfo);_chunk66TIRJFDjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let s=e.deserializeBytes(),a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var tn=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var k=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var In=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunk66TIRJFDjs.Z.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var O=class n extends _chunk66TIRJFDjs.l{deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(n);return new Be(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return L.load(e);case 1:return le.load(e);case 2:return J.load(e);case 3:return Ye.load(e);case 4:return F.load(e);case 5:return Kt.load(e);case 6:return C.load(e);case 7:return A.load(e);case 8:return Je.load(e);case 9:return Xe.load(e);case 10:return Ze.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof L}isAddress(){return this instanceof F}isGeneric(){return this instanceof G}isSigner(){return this instanceof Kt}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof le}isU16(){return this instanceof Je}isU32(){return this instanceof Xe}isU64(){return this instanceof J}isU128(){return this instanceof Ye}isU256(){return this instanceof Ze}isPrimitive(){return this instanceof Kt||this instanceof F||this instanceof L||this instanceof le||this instanceof Je||this instanceof Xe||this instanceof J||this instanceof Ye||this instanceof Ze}},L= exports.TypeTagBool =class n extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},le= exports.TypeTagU8 =class n extends O{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Je= exports.TypeTagU16 =class n extends O{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Xe= exports.TypeTagU32 =class n extends O{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},J= exports.TypeTagU64 =class n extends O{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Ye= exports.TypeTagU128 =class n extends O{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Ze= exports.TypeTagU256 =class n extends O{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},F= exports.TypeTagAddress =class n extends O{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Kt= exports.TypeTagSigner =class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},mr= exports.TypeTagReference =class n extends O{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=O.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends O{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new le)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=O.deserialize(t);return new n(r)}},A= exports.TypeTagStruct =class n extends O{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=Be.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"rate_limiter","RateLimiter")}},Be= exports.StructTag =class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function Wy(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function _(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("string"),new k("String"),[])}function Qy(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("option"),new k("Option"),[n])}function ge(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("object"),new k("Object"),[n])}function lu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(n);case 1:return Q.deserialize(n);case 2:return xe.deserialize(n);case 3:return _chunk66TIRJFDjs.Z.deserialize(n);case 4:return S.deserialize(n,X);case 5:return z.deserialize(n);case 6:return Pe.deserialize(n);case 7:return _e.deserialize(n);case 8:return ye.deserialize(n);case 9:return hn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Rt=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ut.load(e);case 2:return Cn.load(e);case 3:return vn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ut= 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 t=Kn.deserialize(e);return new n(t)}},Cn= 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 t=kt.deserialize(e);return new n(t)}},vn= 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 t=Rn.deserialize(e);return new n(t)}},kt= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(In.fromStr(e),new k(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=In.deserialize(e),r=k.deserialize(e),i=e.deserializeVector(O),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=nr.deserialize(e,c);s.push(p)}return new n(t,r,i,s)}},Kn= 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(O),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=lu(e);o.push(a)}return new n(t,r,o)}},Rn= 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=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Un.deserialize(e)),new n(t,i)}},Un= exports.MultiSigTransactionPayload =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(kt.deserialize(e))}};var be=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeU64(),i=Rt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=tn.deserialize(e);return new n(t,r,i,o,s,a,c)}},yr= exports.RawTransactionWithData =class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Dt.load(e);case 1:return zt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Dt= exports.MultiAgentRawTransaction =class n extends yr{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z);return new n(t,r)}},zt= exports.FeePayerRawTransaction =class n extends yr{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=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=_chunk66TIRJFDjs.Z.deserialize(e);return new n(t,r,i)}};var fr=class extends _chunk66TIRJFDjs.l{constructor(t){super();this.accountAddress=_chunk66TIRJFDjs.Z.ONE;this.moduleName=new x("account");this.structName=new x("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var et=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return nn.load(e);case 2:return Ft.load(e);case 3:return Ot.load(e);case 4:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Nt}isMultiEd25519(){return this instanceof nn}isMultiAgent(){return this instanceof Ft}isFeePayer(){return this instanceof Ot}isSingleSender(){return this instanceof ft}},Nt= exports.TransactionAuthenticatorEd25519 =class n extends et{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=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},nn= exports.TransactionAuthenticatorMultiEd25519 =class n extends et{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=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},Ft= exports.TransactionAuthenticatorMultiAgent =class n extends et{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=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j);return new n(t,r,i)}},Ot= exports.TransactionAuthenticatorFeePayer =class n extends et{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j),o=_chunk66TIRJFDjs.Z.deserialize(e),s=j.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ft= exports.TransactionAuthenticatorSingleSender =class n extends et{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=j.deserialize(e);return new n(t)}};var tt=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=be.deserialize(e),r=et.deserialize(e);return new n(t,r)}};var rn=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,i)}};var Ar=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,r,o)}};function hr(n){return n.feePayerAddress?new zt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Dt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function yt(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function sA(n){return yt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ke(n){let e=hr(n);return n.feePayerAddress?yt(e.bcsToBytes(),ai):n.secondarySignerAddresses?yt(e.bcsToBytes(),ai):yt(e.bcsToBytes(),Co)}var se=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ve(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new ve(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ke(e))}};function Ti(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var we=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new N(t.publicKey()),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=We.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=We.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new oe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new oe(this.publicKey,this.signTransaction(e))}sign(e){return new H(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ke(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var nt=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?se.generate():we.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new se({privateKey:t,address:r}):new we({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?se.fromDerivationPath({mnemonic:r,path:i}):we.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};var _utils3 = require('@noble/hashes/utils');var yu=1209600,on=class on extends _chunk66TIRJFDjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=r||_chunk66TIRJFDjs.ea.call(void 0, _chunk66TIRJFDjs.da.call(void 0, )+yu),this.blinder=i!==void 0?_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array():fu();let o=wn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Et(this.blinder));let s=Pt(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new on({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return on.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _58 => _58.scheme])){case 0:default:t=q.generate()}return new on({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _59 => _59.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ue(this.privateKey.sign(e))}};on.BLINDER_LENGTH=31;var Gt=on;function fu(){return _utils3.randomBytes.call(void 0, Gt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function br(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var sn=class sn extends _chunk66TIRJFDjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:p,proof:l,proofFetchCallback:h,jwt:d,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=d,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof ue)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async v=>{await h(v),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array();if(b.length!==sn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${sn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunk66TIRJFDjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk66TIRJFDjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new N(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunk66TIRJFDjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Gt.deserialize(t),c=ue.deserialize(t),p=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:p}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new H(this.sign(t)),i=new N(this.publicKey);return new oe(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new N(this.publicKey);return new oe(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw P.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw P.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw P.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(_chunk66TIRJFDjs.j.hexInputToString(i.hash())!==_chunk66TIRJFDjs.j.hexInputToString(this.verificationKeyHash))throw P.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await sn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw P.fromErrorType({type:0});if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new he({jwtHeader:_chunk66TIRJFDjs.fa.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new jt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t),o=new Tr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t);return new Tr(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return hi(t)}};sn.PEPPER_LENGTH=31;var me=sn,Tr= exports.TransactionAndProof =class extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}};var rt=class n extends me{constructor(e){let t=U.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:h,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new R(_chunk66TIRJFDjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:l,aud:h,uidVal:d}=qe({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:d,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var Bt=class n extends me{constructor(e){let t=Z.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),p=_chunk66TIRJFDjs.Z.deserialize(e),{iss:l,aud:h,uidVal:d}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:d,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return n.deserialize(R.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:l}=e,{iss:h,aud:d,uidVal:g}=qe({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:g,aud:d,pepper:s,jwkAddress:_chunk66TIRJFDjs.Z.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var kn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof se?we.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new Fe({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ge(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ge(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof me).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof me).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Oe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Oe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var wr=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk66TIRJFDjs.Z.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new je(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Ke(e))}};function Go(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk66TIRJFDjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk66TIRJFDjs.Z.deserialize(n),signingScheme:e}}function Bo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Mo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Gt.deserialize(n),o=ue.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Vo;(h=>{function n(d){let g=new _chunk66TIRJFDjs.m;switch(g.serializeU32AsUleb128(d.signingScheme),d.accountAddress.serialize(g),d.signingScheme){case 0:return d.privateKey.serialize(g),g.toUint8Array();case 2:{if(!Ti(d))throw new Error("Account is not a SingleKeySigner");let b=d.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Bo(d,g),g.toUint8Array();case 4:{let v=d;return Bo(v,g),v.publicKey.jwkAddress.serialize(g),g.serializeBool(v.audless),g.toUint8Array()}case 1:case 0:return d.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=d;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(v=>{g.serializeFixedBytes(n(v))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${d.signingScheme}`)}}h.toBytes=n;function e(d){return _chunk66TIRJFDjs.j.hexInputToStringWithoutPrefix(n(d))}h.toHexStringWithoutPrefix=e;function t(d){return _chunk66TIRJFDjs.j.hexInputToString(n(d))}h.toHexString=t;function r(d){let{address:g,signingScheme:b}=Go(d);switch(b){case 0:{let v=q.deserialize(d);return new se({privateKey:v,address:g})}case 2:{let v=d.deserializeUleb128AsU32();switch(v){case 0:{let W=q.deserialize(d);return new we({privateKey:W,address:g})}case 1:{let W=We.deserialize(d);return new we({privateKey:W,address:g})}case 3:{let W=Mo(d),Me=qe(W);return new rt({...W,...Me})}case 4:{let W=Mo(d),Me=_chunk66TIRJFDjs.Z.deserialize(d),st=d.deserializeBool(),at=qe(W);return new Bt({...W,...at,jwkAddress:Me,audless:st})}default:throw new Error(`Unsupported public key variant ${v}`)}}case 3:{let v=Fe.deserialize(d),W=d.deserializeUleb128AsU32(),Me=new Array;for(let st=0;st<W;st+=1){let at=r(d);if(!Ti(at)&&!(at instanceof se))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Me.push(at)}return new kn({multiKey:v,signers:Me,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=r;function i(d){let g=p(d);if(!(g instanceof rt))throw new Error("Deserialization of KeylessAccount failed");return g}h.keylessAccountFromHex=i;function o(d){let g=p(d);if(!(g instanceof Bt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}h.federatedKeylessAccountFromHex=o;function s(d){let g=p(d);if(!(g instanceof kn))throw new Error("Deserialization of MultiKeyAccount failed");return g}h.multiKeyAccountFromHex=s;function a(d){let g=p(d);if(!(g instanceof we))throw new Error("Deserialization of SingleKeyAccount failed");return g}h.singleKeyAccountFromHex=a;function c(d){let g=p(d);if(!(g instanceof se))throw new Error("Deserialization of Ed25519Account failed");return g}h.ed25519AccountFromHex=c;function p(d){return r(R.fromHex(d))}h.fromHex=p;function l(d){return p(d)}h.fromBytes=l})(Vo||(Vo= exports.AccountUtils ={}));var Sr=class n extends nt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk66TIRJFDjs.ma.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new rr(this.accountAddress),this.sign=o=>new Tn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk66TIRJFDjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Ke(t))}signTransaction(t){return this.sign(Ke(t))}setSigner(t){this.sign=r=>new Tn(t(r))}};var Dn=class Dn extends Sr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk66TIRJFDjs.Z)(Dn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunk66TIRJFDjs.m;_chunk66TIRJFDjs.Z.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk66TIRJFDjs.m;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Dn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};Dn.ADDRESS_DOMAIN_SEPERATOR=5;var Lo=Dn;var Tu=`
5
+ Error: ${_chunkBNN2XWNRjs.da.call(void 0, r)}`),o+=`
6
+ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Uo[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Te= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(qc({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function qc({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _5 => _5.headers, 'optionalAccess', _6 => _6.traceparent, 'optionalAccess', _7 => _7.split, 'call', _8 => _8("-"), 'access', _9 => _9[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.errors, 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _14 => _14.data, 'optionalAccess', _15 => _15.message])!=null&&_optionalChain([t, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${$c(t.data)}`}var ai=400;function $c(n){let e=JSON.stringify(n);return e.length<=ai?e:`truncated(original_size:${e.length}): ${e.slice(0,ai/2)}...${e.slice(-ai/2)}`}async function Wc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _18 => _18.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${So}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _19 => _19.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _20 => _20.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _21 => _21.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _22 => _22.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a})}async function sr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Wc({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Te({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Te({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Te({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Te({apiType:t,aptosRequest:n,aptosResponse:a})}async function ar(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return sr({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function M(n){let{aptosConfig:e}=n;return ar({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([e, 'access', _25 => _25.fullnodeConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function ug(n){return ar({...n,type:"Pepper"})}async function cr(n){let e=new Array(0),t,r=n.params;do{let i=await ar({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function ci(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await ur({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _27 => _27.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function ur(n){let e,t={};typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _30 => _30.params, 'optionalAccess', _31 => _31.limit])=="number"&&(t.limit=n.params.limit);let r=await ar({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function bn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:d}=n,l=c.getRequestUrl(e);return sr({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function At(n){let{aptosConfig:e}=n;return bn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n;return bn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.indexerConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function Fo(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _40 => _40.clientConfig, 'optionalAccess', _41 => delete _41.API_KEY]),bn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _42 => _42.clientConfig, 'optionalAccess', _43 => _43.HEADERS]),..._optionalChain([t, 'access', _44 => _44.faucetConfig, 'optionalAccess', _45 => _45.HEADERS])}}})}async function Do(n){return bn({...n,type:"Pepper"})}async function No(n){return bn({...n,type:"Prover"})}var ui=new Map;function ze(n,e,t){return async(...r)=>{if(ui.has(e)){let{value:o,timestamp:s}=ui.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return ui.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var Xc=1e7,di= exports.MAX_AUD_VAL_BYTES =120,Yc= exports.MAX_UID_KEY_BYTES =30,Zc= exports.MAX_UID_VAL_BYTES =330,eu= exports.MAX_ISS_VAL_BYTES =120,tu= exports.MAX_EXTRA_FIELD_BYTES =350,nu= exports.MAX_JWT_HEADER_B64_BYTES =300,ru= exports.MAX_COMMITED_EPK_BYTES =93,Ge=class Ge extends oe{constructor(e,t){super();let r=_chunkBNN2XWNRjs.j.fromHexInput(t).toUint8Array();if(r.length!==Ge.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ge.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunkBNN2XWNRjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),L.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return dr({...e,publicKey:this}),!0}catch(t){if(t instanceof P)return!1;throw t}}async verifySignatureAsync(e){return fi({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static isPublicKey(e){return e instanceof Ge}static create(e){return Oo(e),new Ge(e.iss,Oo(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ge.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ge.ID_COMMITMENT_LENGTH=32;var k=Ge;async function fi(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof we))throw P.fromErrorType({type:26,details:"Not a keyless signature"});return dr({message:r,publicKey:t,signature:i,jwk:o||await Ai({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _46 => _46.throwErrorWithReason]))throw c;return!1}}function dr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof we))throw P.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof de))throw P.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof ht))throw P.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<_chunkBNN2XWNRjs.ea.call(void 0, ))throw P.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw P.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw P.fromErrorType({type:29});let f=iu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:f,groth16Proof:l}))throw P.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw P.fromErrorType({type:30});let p=new li(l,f);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw P.fromErrorType({type:31})}}function iu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof k?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof de))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...hn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(It(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Oe(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Oe(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Oe(" ",i.maxExtraFieldBytes))),a.push(Oe(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Oe(s.overrideAudVal,di)),a.push(1n)):(a.push(Oe("",di)),a.push(0n)),vt(a)}async function Ai(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof k?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof Z?t.jwkAddress:void 0;try{s=await au({aptosConfig:e,jwkAddr:a})}catch(l){throw P.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw P.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw P.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Oo(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[It(_chunkBNN2XWNRjs.j.fromHexInput(i).toUint8Array()),Oe(r,di),Oe(t,Zc),Oe(e,Yc)];return ti(vt(o),k.ID_COMMITMENT_LENGTH)}var we=class n extends B{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return uu(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=jt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=ft.deserialize(e),s=Ne.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new jt(new de({proof:new Jt(new ht({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new ft(new E(new Uint8Array(32))),ephemeralSignature:new Ne(new R(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},jt= exports.EphemeralCertificate =class n extends B{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(de.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Tn=class Tn extends _chunkBNN2XWNRjs.l{constructor(e){if(super(),this.data=_chunkBNN2XWNRjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new Tn(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=_bn254.bn254.fields,i=r.create(pi(e)),o=r.sqrt(r.add(r.pow(i,3n),Tn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Tn.B=_bn254.bn254.fields.Fp.create(3n);var Qe=Tn;function pi(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var wn=class wn extends _chunkBNN2XWNRjs.l{constructor(e){if(super(),this.data=_chunkBNN2XWNRjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new wn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=_bn254.bn254.fields,s=o.fromBigTuple([pi(t),pi(r)]),a=o.sqrt(o.add(o.pow(s,3n),wn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y:l})}};wn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var Kt=wn,ht= exports.Groth16Zkp =class n extends rr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Qe(t),this.b=new Kt(r),this.c=new Qe(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Qe.deserialize(e).bcsToBytes(),r=Kt.deserialize(e).bcsToBytes(),i=Qe.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},li= exports.Groth16ProofAndStatement =class n extends _chunkBNN2XWNRjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ti(r,32):_chunkBNN2XWNRjs.j.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(ht.deserialize(t),t.deserializeFixedBytes(32))}hash(){return bt(this.bcsToBytes(),this.domainSeparator)}},Jt= exports.ZkProof =class n extends _chunkBNN2XWNRjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ht.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},de= exports.ZeroKnowledgeSig =class n extends B{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new K(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ne);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},gi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Xc,maxExtraFieldBytes:o=tu,maxJwtHeaderB64Bytes:s=nu,maxIssValBytes:a=eu,maxCommitedEpkBytes:c=ru}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new ft(new E(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new yi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},yi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Qe(t),this.betaG2=new Kt(r),this.deltaG2=new Kt(i),this.gammaAbcG1=[new Qe(o[0]),new Qe(o[1])],this.gammaG2=new Kt(s)}hash(){let e=new _chunkBNN2XWNRjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),f=this.gammaAbcG1.map(pt=>pt.toProjectivePoint()),{Fp12:p}=_bn254.bn254.fields,g=f[0].add(f[1].multiply(t)),b=_bn254.bn254.pairing(g,d),C=_bn254.bn254.pairing(i,o),W=_bn254.bn254.pairing(a,c),qe=_bn254.bn254.pairing(s,l),dt=p.mul(W,p.mul(b,qe));return p.eql(C,dt)}catch(i){throw P.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await ze(async()=>{let[t,r]=await Promise.all([ou(n),su(n)]);return gi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof P?t:P.fromErrorType({type:25,error:t})}}function je(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw P.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkBNN2XWNRjs.da.call(void 0, o)}`})}if(typeof r.iss!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function ou(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await M({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunkBNN2XWNRjs._.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _47 => _47.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function su(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await M({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunkBNN2XWNRjs._.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _48 => _48.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function au(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await M({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _49 => _49.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await M({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _50 => _50.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,l=new K(_chunkBNN2XWNRjs.j.fromHexInput(d).toUint8Array()),f=mi.deserialize(l);a.push(f)}o.set(_chunkBNN2XWNRjs.k.call(void 0, s.issuer),a)}return o}var mi=class n extends _chunkBNN2XWNRjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new K(_chunkBNN2XWNRjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw P.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunkBNN2XWNRjs.ha.call(void 0, this.n),r=cu(e.reverse()).map(i=>It(i));return r.push(256n),vt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function cu(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function uu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var Z=class n extends oe{constructor(e,t){super(),this.jwkAddress=_chunkBNN2XWNRjs._.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunkBNN2XWNRjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),L.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return dr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=k.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return fi({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,k.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,k.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunkBNN2XWNRjs._&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof k}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ke=class Ke extends xt{constructor(e){super();let t=_chunkBNN2XWNRjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Ke.LENGTH)this.key=t;else if(r===Ke.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunkBNN2XWNRjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ke.LENGTH} or ${Ke.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=$t(t),o=_chunkBNN2XWNRjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new Rt(t)}static deserialize(e){let t=e.deserializeBytes();return new Ke(t)}static isPublicKey(e){return e instanceof Ke}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===Ke.LENGTH}};Ke.LENGTH=65,Ke.COMPRESSED_LENGTH=33;var Je=Ke,Be=class Be extends _chunkBNN2XWNRjs.l{constructor(e,t){super();let r=yt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Be.LENGTH)throw new Error(`PrivateKey length should be ${Be.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Be(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return Be.fromDerivationPathInner(e,tr(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Be(r,!1)}sign(e){let t=$t(e),r=_chunkBNN2XWNRjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new Rt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Je(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return yt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Be(t,!1)}static isPrivateKey(e){return e instanceof Be}};Be.LENGTH=32;var Xe=Be,Yt=class Yt extends B{constructor(e){super();let t=_chunkBNN2XWNRjs.j.fromHexInput(e);if(t.toUint8Array().length!==Yt.LENGTH)throw new Error(`Signature length should be ${Yt.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 Yt(t)}};Yt.LENGTH=64;var Rt=Yt;var U=class n extends oe{constructor(e){if(super(),this.publicKey=e,e instanceof E)this.variant=0;else if(e instanceof Je)this.variant=1;else if(e instanceof k)this.variant=3;else if(e instanceof Z)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof k)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof V)){if(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.throwErrorWithReason]))throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return L.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=E.deserialize(e);break;case 1:r=Je.deserialize(e);break;case 3:r=k.deserialize(e);break;case 4:r=Z.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 E}isSecp256k1PublicKey(){return this.publicKey instanceof Je}static isInstance(e){return"publicKey"in e&&"variant"in e}},V= exports.AnySignature =class n extends B{constructor(e){if(super(),this.signature=e,e instanceof R)this.variant=0;else if(e instanceof Rt)this.variant=1;else if(e instanceof we)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=R.deserialize(e);break;case 1:r=Rt.deserialize(e);break;case 3:r=we.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function pu(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Re=class extends oe{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},se= exports.MultiKey =class n extends Re{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof U?i:new U(i)),this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Me))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return L.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(U),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof U?e:new U(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},pe=class pe extends B{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${pe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof V?o:new V(o)),!(r instanceof Uint8Array))this.bitmap=pe.createBitmap({bits:r});else{if(r.length!==pe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${pe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+pu(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${pe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)r&128>>i&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(V),r=e.deserializeBytes();return new pe({signatures:t,bitmap:r})}};pe.BITMAP_LEN=4,pe.MAX_SIGNATURES_SUPPORTED=pe.BITMAP_LEN*8;var Me=pe;var le=class le extends Re{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>le.MAX_KEYS||t.length<le.MIN_KEYS)throw new Error(`Must have between ${le.MIN_KEYS} and ${le.MAX_KEYS} public keys, inclusive`);if(r<le.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${le.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Ye))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return L.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*E.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*E.LENGTH)}),e[this.publicKeys.length*E.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=E.LENGTH){let s=o;i.push(new E(t.subarray(s,s+E.LENGTH)))}return new le({publicKeys:i,threshold:r})}static deserializeWithoutLength(e){let t=e.remaining(),r=e.deserializeFixedBytes(t),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=E.LENGTH){let a=s;o.push(new E(r.subarray(a,a+E.LENGTH)))}return new le({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};le.MAX_KEYS=32,le.MIN_KEYS=2,le.MIN_THRESHOLD=1;var Ve=le,ge=class ge extends B{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ge.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ge.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=ge.createBitmap({bits:r});else{if(r.length!==ge.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ge.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*R.LENGTH+ge.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),i=[];for(let o=0;o<t.length-r.length;o+=R.LENGTH){let s=o;i.push(new R(t.subarray(s,s+R.LENGTH)))}return new ge({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=ge.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ge.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};ge.MAX_SIGNATURES_SUPPORTED=32,ge.BITMAP_LEN=4;var Ye=ge;var j=class extends _chunkBNN2XWNRjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ue.load(e);case 1:return Ze.load(e);case 2:return ae.load(e);case 3:return He.load(e);case 4:return Zt.load(e);case 5:return Ut.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ue}isMultiEd25519(){return this instanceof Ze}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof He}},Ue= exports.AccountAuthenticatorEd25519 =class n extends j{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},Ze= exports.AccountAuthenticatorMultiEd25519 =class n extends j{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=Ve.deserialize(e),r=Ye.deserialize(e);return new n(t,r)}},ae= exports.AccountAuthenticatorSingleKey =class n extends j{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=U.deserialize(e),r=V.deserialize(e);return new n(t,r)}},He= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=se.deserialize(e),r=Me.deserialize(e);return new n(t,r)}},Zt= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Ut= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r,i){if(super(),!_chunkBNN2XWNRjs.na.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=r,this.signingMessageDigest=_chunkBNN2XWNRjs.j.fromHexInput(_chunkBNN2XWNRjs.j.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunkBNN2XWNRjs.ma.call(void 0, this.functionInfo);_chunkBNN2XWNRjs._.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let s=e.deserializeBytes(),a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var en=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var F=class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var _n=class n extends _chunkBNN2XWNRjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunkBNN2XWNRjs._.fromString(t[0]),new F(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=F.deserialize(e);return new n(t,r)}};var z=class n extends _chunkBNN2XWNRjs.l{deserialize(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=F.deserialize(e),i=F.deserialize(e),o=e.deserializeVector(n);return new Le(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return H.load(e);case 1:return ye.load(e);case 2:return J.load(e);case 3:return nt.load(e);case 4:return O.load(e);case 5:return kt.load(e);case 6:return v.load(e);case 7:return h.load(e);case 8:return et.load(e);case 9:return tt.load(e);case 10:return rt.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof H}isAddress(){return this instanceof O}isGeneric(){return this instanceof G}isSigner(){return this instanceof kt}isVector(){return this instanceof v}isStruct(){return this instanceof h}isU8(){return this instanceof ye}isU16(){return this instanceof et}isU32(){return this instanceof tt}isU64(){return this instanceof J}isU128(){return this instanceof nt}isU256(){return this instanceof rt}isPrimitive(){return this instanceof kt||this instanceof O||this instanceof H||this instanceof ye||this instanceof et||this instanceof tt||this instanceof J||this instanceof nt||this instanceof rt}},H= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ye= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},et= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},tt= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},J= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},nt= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},rt= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},O= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},kt= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},pr= exports.TypeTagReference =class n extends z{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=z.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends z{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},v= exports.TypeTagVector =class n extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ye)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=z.deserialize(t);return new n(r)}},h= exports.TypeTagStruct =class n extends z{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=Le.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunkBNN2XWNRjs._.ONE,"string","String")}isOption(){return this.isTypeTag(_chunkBNN2XWNRjs._.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunkBNN2XWNRjs._.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunkBNN2XWNRjs._.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunkBNN2XWNRjs._.ONE,"rate_limiter","RateLimiter")}},Le= exports.StructTag =class n extends _chunkBNN2XWNRjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=F.deserialize(e),i=F.deserialize(e),o=e.deserializeVector(z);return new n(t,r,i,o)}};function rf(){return new Le(_chunkBNN2XWNRjs._.ONE,new F("aptos_coin"),new F("AptosCoin"),[])}function x(){return new Le(_chunkBNN2XWNRjs._.ONE,new F("string"),new F("String"),[])}function of(n){return new Le(_chunkBNN2XWNRjs._.ONE,new F("option"),new F("Option"),[n])}function me(n){return new Le(_chunkBNN2XWNRjs._.ONE,new F("object"),new F("Object"),[n])}function lu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(n);case 1:return Q.deserialize(n);case 2:return ve.deserialize(n);case 3:return _chunkBNN2XWNRjs._.deserialize(n);case 4:return _.deserialize(n,X);case 5:return N.deserialize(n);case 6:return xe.deserialize(n);case 7:return Ie.deserialize(n);case 8:return he.deserialize(n);case 9:return mn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Ft=class extends _chunkBNN2XWNRjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Pn.load(e);case 2:return En.load(e);case 3:return xn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Pn= exports.TransactionPayloadScript =class n extends Ft{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=In.deserialize(e);return new n(t)}},En= exports.TransactionPayloadEntryFunction =class n extends Ft{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Dt.deserialize(e);return new n(t)}},xn= exports.TransactionPayloadMultiSig =class n extends Ft{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=vn.deserialize(e);return new n(t)}},Dt= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(_n.fromStr(e),new F(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=_n.deserialize(e),r=F.deserialize(e),i=e.deserializeVector(z),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=Zn.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},In= 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(z),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=lu(e);o.push(a)}return new n(t,r,o)}},vn= 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=_chunkBNN2XWNRjs._.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Cn.deserialize(e)),new n(t,i)}},Cn= exports.MultiSigTransactionPayload =class n extends _chunkBNN2XWNRjs.l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(Dt.deserialize(e))}};var Se=class n extends _chunkBNN2XWNRjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunkBNN2XWNRjs._.deserialize(e),r=e.deserializeU64(),i=Ft.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=en.deserialize(e);return new n(t,r,i,o,s,a,c)}},lr= exports.RawTransactionWithData =class extends _chunkBNN2XWNRjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return Ot.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Nt= exports.MultiAgentRawTransaction =class n extends lr{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=Se.deserialize(e),r=e.deserializeVector(_chunkBNN2XWNRjs._);return new n(t,r)}},Ot= exports.FeePayerRawTransaction =class n extends lr{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=Se.deserialize(e),r=e.deserializeVector(_chunkBNN2XWNRjs._),i=_chunkBNN2XWNRjs._.deserialize(e);return new n(t,r,i)}};var gr=class extends _chunkBNN2XWNRjs.l{constructor(t){super();this.accountAddress=_chunkBNN2XWNRjs._.ONE;this.moduleName=new I("account");this.structName=new I("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=_.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var it=class extends _chunkBNN2XWNRjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return zt.load(e);case 1:return tn.load(e);case 2:return Gt.load(e);case 3:return Bt.load(e);case 4:return Tt.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof zt}isMultiEd25519(){return this instanceof tn}isMultiAgent(){return this instanceof Gt}isFeePayer(){return this instanceof Bt}isSingleSender(){return this instanceof Tt}},zt= exports.TransactionAuthenticatorEd25519 =class n extends it{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},tn= exports.TransactionAuthenticatorMultiEd25519 =class n extends it{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=Ve.deserialize(e),r=Ye.deserialize(e);return new n(t,r)}},Gt= exports.TransactionAuthenticatorMultiAgent =class n extends it{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=j.deserialize(e),r=e.deserializeVector(_chunkBNN2XWNRjs._),i=e.deserializeVector(j);return new n(t,r,i)}},Bt= exports.TransactionAuthenticatorFeePayer =class n extends it{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunkBNN2XWNRjs._),i=e.deserializeVector(j),o=_chunkBNN2XWNRjs._.deserialize(e),s=j.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},Tt= exports.TransactionAuthenticatorSingleSender =class n extends it{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=j.deserialize(e);return new n(t)}};var ot=class n extends _chunkBNN2XWNRjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=Se.deserialize(e),r=it.deserialize(e);return new n(t,r)}};var yr=class n extends _chunkBNN2XWNRjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=Se.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunkBNN2XWNRjs._.deserialize(e)),new n(t,i)}};var mr=class n extends _chunkBNN2XWNRjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=Se.deserialize(e),r=e.deserializeVector(_chunkBNN2XWNRjs._),i=e.deserializeBool(),o;return i&&(o=_chunkBNN2XWNRjs._.deserialize(e)),new n(t,r,o)}};function fr(n){return n.feePayerAddress?new Ot(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Nt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function bt(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function fA(n){return bt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function ke(n){let e=fr(n);return n.feePayerAddress?bt(e.bcsToBytes(),si):n.secondarySignerAddresses?bt(e.bcsToBytes(),si):bt(e.bcsToBytes(),Co)}var re=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunkBNN2XWNRjs._.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new Ue(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ue(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(ke(e))}};function hi(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var ce=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new U(t.publicKey()),this.accountAddress=r?_chunkBNN2XWNRjs._.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=Xe.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=Xe.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ae(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ae(this.publicKey,this.signTransaction(e))}sign(e){return new V(this.privateKey.sign(e))}signTransaction(e){return this.sign(ke(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var st=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?re.generate():ce.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new re({privateKey:t,address:r}):new ce({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?re.fromDerivationPath({mnemonic:r,path:i}):ce.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};var _utils3 = require('@noble/hashes/utils');var mu=1209600,nn=class nn extends _chunkBNN2XWNRjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new ft(t.publicKey()),this.expiryDateSecs=r||_chunkBNN2XWNRjs.fa.call(void 0, _chunkBNN2XWNRjs.ea.call(void 0, )+mu),this.blinder=i!==void 0?_chunkBNN2XWNRjs.j.fromHexInput(i).toUint8Array():fu();let o=hn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(It(this.blinder));let s=vt(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new nn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return nn.deserialize(new K(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _58 => _58.scheme])){case 0:default:t=q.generate()}return new nn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _59 => _59.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ne(this.privateKey.sign(e))}};nn.BLINDER_LENGTH=31;var Mt=nn;function fu(){return _utils3.randomBytes.call(void 0, Mt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function hr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var rn=class rn extends _chunkBNN2XWNRjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:l,proofFetchCallback:f,jwt:p,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunkBNN2XWNRjs._.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof de)this.proof=l;else{if(f===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async C=>{await f(C),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunkBNN2XWNRjs.j.fromHexInput(d).toUint8Array();if(b.length!==rn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${rn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunkBNN2XWNRjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunkBNN2XWNRjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new U(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunkBNN2XWNRjs._.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Mt.deserialize(t),c=de.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new V(this.sign(t)),i=new U(this.publicKey);return new ae(i,r)}signTransactionWithAuthenticator(t){let r=new V(this.signTransaction(t)),i=new U(this.publicKey);return new ae(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw P.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw P.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw P.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(_chunkBNN2XWNRjs.j.hexInputToString(i.hash())!==_chunkBNN2XWNRjs.j.hexInputToString(this.verificationKeyHash))throw P.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await rn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw P.fromErrorType({type:0});if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new we({jwtHeader:_chunkBNN2XWNRjs.ga.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new jt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=fr(t),o=new Ar(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=fr(t);return new Ar(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return Ai(t)}};rn.PEPPER_LENGTH=31;var fe=rn,Ar= exports.TransactionAndProof =class extends _chunkBNN2XWNRjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return bt(this.bcsToBytes(),this.domainSeparator)}};var _e=class n extends fe{constructor(e){let t=k.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=fe.partialDeserialize(e),{iss:d,aud:l,uidVal:f}=je({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:f,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new K(_chunkBNN2XWNRjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:l}=e;if(l&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:f,aud:p,uidVal:g}=je({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:f,uidKey:a,uidVal:g,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:_nullishCoalesce(l, () => ((d?d.hash():void 0)))})}};var Fe=class n extends fe{constructor(e){let t=Z.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=fe.partialDeserialize(e),d=_chunkBNN2XWNRjs._.deserialize(e),{iss:l,aud:f,uidVal:p}=je({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:f,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(K.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:l,verificationKeyHash:f}=e;if(f&&l)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:g,uidVal:b}=je({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:b,aud:g,pepper:s,jwkAddress:_chunkBNN2XWNRjs._.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:_nullishCoalesce(f, () => ((l?l.hash():void 0)))})}};var at=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof re?ce.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunkBNN2XWNRjs._.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new se({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new He(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new He(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof fe).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof fe).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Me({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Me({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var on=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunkBNN2XWNRjs._.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new Ze(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ze(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ye({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(ke(e))}};function Bo(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunkBNN2XWNRjs.W).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunkBNN2XWNRjs._.deserialize(n),signingScheme:e}}function Mo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Vo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Mt.deserialize(n),o=de.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Ho;(f=>{function n(p){let g=new _chunkBNN2XWNRjs.m;switch(g.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(g),p.signingScheme){case 0:return p.privateKey.serialize(g),g.toUint8Array();case 2:{if(!hi(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Mo(p,g),g.toUint8Array();case 4:{let C=p;return Mo(C,g),C.publicKey.jwkAddress.serialize(g),g.serializeBool(C.audless),g.toUint8Array()}case 1:case 0:return p.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(C=>{g.serializeFixedBytes(n(C))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}f.toBytes=n;function e(p){return _chunkBNN2XWNRjs.j.hexInputToStringWithoutPrefix(n(p))}f.toHexStringWithoutPrefix=e;function t(p){return _chunkBNN2XWNRjs.j.hexInputToString(n(p))}f.toHexString=t;function r(p){let{address:g,signingScheme:b}=Bo(p);switch(b){case 0:{let C=q.deserialize(p);return new re({privateKey:C,address:g})}case 2:{let C=p.deserializeUleb128AsU32();switch(C){case 0:{let W=q.deserialize(p);return new ce({privateKey:W,address:g})}case 1:{let W=Xe.deserialize(p);return new ce({privateKey:W,address:g})}case 3:{let W=Vo(p),qe=je(W);return new _e({...W,...qe})}case 4:{let W=Vo(p),qe=_chunkBNN2XWNRjs._.deserialize(p),dt=p.deserializeBool(),pt=je(W);return new Fe({...W,...pt,jwkAddress:qe,audless:dt})}default:throw new Error(`Unsupported public key variant ${C}`)}}case 3:{let C=se.deserialize(p),W=p.deserializeUleb128AsU32(),qe=new Array;for(let dt=0;dt<W;dt+=1){let pt=r(p);if(!hi(pt)&&!(pt instanceof re))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");qe.push(pt)}return new at({multiKey:C,signers:qe,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}f.deserialize=r;function i(p){let g=d(p);if(!(g instanceof _e))throw new Error("Deserialization of KeylessAccount failed");return g}f.keylessAccountFromHex=i;function o(p){let g=d(p);if(!(g instanceof Fe))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}f.federatedKeylessAccountFromHex=o;function s(p){let g=d(p);if(!(g instanceof at))throw new Error("Deserialization of MultiKeyAccount failed");return g}f.multiKeyAccountFromHex=s;function a(p){let g=d(p);if(!(g instanceof ce))throw new Error("Deserialization of SingleKeyAccount failed");return g}f.singleKeyAccountFromHex=a;function c(p){let g=d(p);if(!(g instanceof re))throw new Error("Deserialization of Ed25519Account failed");return g}f.ed25519AccountFromHex=c;function d(p){return r(K.fromHex(p))}f.fromHex=d;function l(p){return d(p)}f.fromBytes=l})(Ho||(Ho= exports.AccountUtils ={}));var br=class n extends st{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunkBNN2XWNRjs.na.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new er(this.accountAddress),this.sign=o=>new fn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunkBNN2XWNRjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new Ut(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(ke(t))}signTransaction(t){return this.sign(ke(t))}setSigner(t){this.sign=r=>new fn(t(r))}};var Kn=class Kn extends br{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunkBNN2XWNRjs._)(Kn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunkBNN2XWNRjs.na.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunkBNN2XWNRjs.m;_chunkBNN2XWNRjs._.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunkBNN2XWNRjs.m;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Kn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new Ut(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};Kn.ADDRESS_DOMAIN_SEPERATOR=5;var qo=Kn;var bu=`
7
7
  fragment TokenActivitiesFields on token_activities_v2 {
8
8
  after_value
9
9
  before_value
@@ -21,7 +21,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
21
21
  transaction_version
22
22
  type
23
23
  }
24
- `,bu=`
24
+ `,Tu=`
25
25
  fragment AnsTokenFragment on current_aptos_names {
26
26
  domain
27
27
  expiration_timestamp
@@ -33,7 +33,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
33
33
  subdomain_expiration_policy
34
34
  domain_expiration_timestamp
35
35
  }
36
- `,Er=`
36
+ `,Tr=`
37
37
  fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
38
38
  token_standard
39
39
  token_properties_mutated_v1
@@ -80,7 +80,16 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
80
80
  }
81
81
  }
82
82
  }
83
- `,qo=`
83
+ `,$o=`
84
+ query getAccountAddressesForAuthKey($where_condition: auth_key_account_addresses_bool_exp, $order_by: [auth_key_account_addresses_order_by!]) {
85
+ auth_key_account_addresses(where: $where_condition, order_by: $order_by) {
86
+ auth_key
87
+ account_address
88
+ last_transaction_version
89
+ is_auth_key_used
90
+ }
91
+ }
92
+ `,Wo=`
84
93
  query getAccountCoinsCount($address: String) {
85
94
  current_fungible_asset_balances_aggregate(
86
95
  where: {owner_address: {_eq: $address}}
@@ -90,7 +99,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
90
99
  }
91
100
  }
92
101
  }
93
- `,$o=`
102
+ `,Qo=`
94
103
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
95
104
  current_fungible_asset_balances(
96
105
  where: $where_condition
@@ -123,7 +132,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
123
132
  }
124
133
  }
125
134
  }
126
- `,Wo=`
135
+ `,jo=`
127
136
  query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
128
137
  current_collection_ownership_v2_view(
129
138
  where: $where_condition
@@ -157,7 +166,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
157
166
  single_token_uri
158
167
  }
159
168
  }
160
- `,Qo=`
169
+ `,Jo=`
161
170
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
162
171
  current_token_ownerships_v2(
163
172
  where: $where_condition
@@ -168,7 +177,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
168
177
  ...CurrentTokenOwnershipFields
169
178
  }
170
179
  }
171
- ${Er}`,XT=`
180
+ ${Tr}`,aT=`
172
181
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
173
182
  current_token_ownerships_v2(
174
183
  where: $where_condition
@@ -179,7 +188,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
179
188
  ...CurrentTokenOwnershipFields
180
189
  }
181
190
  }
182
- ${Er}`,jo=`
191
+ ${Tr}`,Xo=`
183
192
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
184
193
  current_token_ownerships_v2(
185
194
  where: $where_condition
@@ -190,7 +199,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
190
199
  ...CurrentTokenOwnershipFields
191
200
  }
192
201
  }
193
- ${Er}`,Jo=`
202
+ ${Tr}`,Yo=`
194
203
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
195
204
  current_token_ownerships_v2_aggregate(
196
205
  where: $where_condition
@@ -202,7 +211,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
202
211
  }
203
212
  }
204
213
  }
205
- `,Xo=`
214
+ `,Zo=`
206
215
  query getAccountTransactionsCount($address: String) {
207
216
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
208
217
  aggregate {
@@ -210,13 +219,25 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
210
219
  }
211
220
  }
212
221
  }
213
- `,Yo=`
222
+ `,es=`
223
+ query getAuthKeysForPublicKey($where_condition: public_key_auth_keys_bool_exp, $order_by: [public_key_auth_keys_order_by!]) {
224
+ public_key_auth_keys(where: $where_condition, order_by: $order_by) {
225
+ public_key
226
+ public_key_type
227
+ auth_key
228
+ account_public_key
229
+ last_transaction_version
230
+ is_public_key_used
231
+ signature_type
232
+ }
233
+ }
234
+ `,ts=`
214
235
  query getChainTopUserTransactions($limit: Int) {
215
236
  user_transactions(limit: $limit, order_by: {version: desc}) {
216
237
  version
217
238
  }
218
239
  }
219
- `,Zo=`
240
+ `,ns=`
220
241
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
221
242
  current_collections_v2(where: $where_condition) {
222
243
  uri
@@ -246,7 +267,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
246
267
  }
247
268
  }
248
269
  }
249
- `,es=`
270
+ `,rs=`
250
271
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
251
272
  current_fungible_asset_balances(
252
273
  where: $where_condition
@@ -264,7 +285,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
264
285
  token_standard
265
286
  }
266
287
  }
267
- `,ts=`
288
+ `,is=`
268
289
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
269
290
  delegated_staking_activities(
270
291
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -277,7 +298,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
277
298
  transaction_version
278
299
  }
279
300
  }
280
- `,ns=`
301
+ `,os=`
281
302
  query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
282
303
  events(
283
304
  where: $where_condition
@@ -296,7 +317,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
296
317
  indexed_type
297
318
  }
298
319
  }
299
- `,rs=`
320
+ `,ss=`
300
321
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
301
322
  fungible_asset_activities(
302
323
  where: $where_condition
@@ -321,7 +342,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
321
342
  type
322
343
  }
323
344
  }
324
- `,is=`
345
+ `,as=`
325
346
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
326
347
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
327
348
  icon_uri
@@ -340,7 +361,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
340
361
  maximum_v2
341
362
  }
342
363
  }
343
- `,an=`
364
+ `,sn=`
344
365
  query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
345
366
  current_aptos_names(
346
367
  limit: $limit
@@ -351,14 +372,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
351
372
  ...AnsTokenFragment
352
373
  }
353
374
  }
354
- ${bu}`,wi=`
375
+ ${Tu}`,Ti=`
355
376
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
356
377
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
357
378
  num_active_delegator
358
379
  pool_address
359
380
  }
360
381
  }
361
- `,Pr=`
382
+ `,wr=`
362
383
  query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
363
384
  current_objects(
364
385
  where: $where_condition
@@ -375,7 +396,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
375
396
  is_deleted
376
397
  }
377
398
  }
378
- `,Si=`
399
+ `,wi=`
379
400
  query getProcessorStatus($where_condition: processor_status_bool_exp) {
380
401
  processor_status(where: $where_condition) {
381
402
  last_success_version
@@ -383,7 +404,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
383
404
  last_updated
384
405
  }
385
406
  }
386
- `,os=`
407
+ `,cs=`
387
408
  query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
388
409
  table_items(
389
410
  where: $where_condition
@@ -399,7 +420,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
399
420
  write_set_change_index
400
421
  }
401
422
  }
402
- `,ss=`
423
+ `,us=`
403
424
  query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
404
425
  table_metadatas(
405
426
  where: $where_condition
@@ -412,7 +433,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
412
433
  value_type
413
434
  }
414
435
  }
415
- `,as=`
436
+ `,ds=`
416
437
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
417
438
  token_activities_v2(
418
439
  where: $where_condition
@@ -423,7 +444,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
423
444
  ...TokenActivitiesFields
424
445
  }
425
446
  }
426
- ${Tu}`,Ei=`
447
+ ${bu}`,Si=`
427
448
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
428
449
  current_token_ownerships_v2(
429
450
  where: $where_condition
@@ -434,7 +455,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
434
455
  ...CurrentTokenOwnershipFields
435
456
  }
436
457
  }
437
- ${Er}`,cs=`
458
+ ${Tr}`,ps=`
438
459
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
439
460
  current_token_datas_v2(
440
461
  where: $where_condition
@@ -474,7 +495,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
474
495
  }
475
496
  }
476
497
  }
477
- `;async function _r(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function us(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Yo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Uo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function wu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Si},originMethod:"getProcessorStatuses"})).processor_status}async function xr(n){let e=await wu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Ir(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Si,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Cr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}`});return r}async function ds(n){return _optionalChain([n, 'access', _60 => _60.options, 'optionalAccess', _61 => _61.ledgerVersion])!==void 0?ps(n):De(async()=>ps(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ps(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _62 => _62.ledgerVersion])}});return o}async function vr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await gt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _63 => _63.ledgerVersion])},body:r})).data}async function ls(n){let{aptosConfig:e,options:t}=n,r={query:os,variables:{where_condition:_optionalChain([t, 'optionalAccess', _64 => _64.where]),offset:_optionalChain([t, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([t, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([t, 'optionalAccess', _67 => _67.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function gs(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function _i(n){let{aptosConfig:e,options:t}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([t, 'optionalAccess', _73 => _73.limit])}})}async function Rr(n){let{aptosConfig:e}=n;return De(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ms(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function zn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ys(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await zn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _74 => _74.status])===404)return!0;throw r}}async function Su(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function At(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _75 => _75.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _76 => _76.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function d(g){if(!(g instanceof Ae)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){d(g)}if(s){let g=Date.now();try{c=await Su({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){d(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){d(g)}await _chunk66TIRJFDjs.ba.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Kr(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Kr(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Pi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Ur(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await xr({aptosConfig:e}):s=(await Ir({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk66TIRJFDjs.ba.call(void 0, 200)}}var Kr=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Pi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function fs(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _77 => _77.withTransactions])}});return hs({block:i,...n})}async function As(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _78 => _78.withTransactions])}});return hs({block:i,...n})}async function hs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _79 => _79.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _80 => _80.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],l=100n;for(let d=c+1n;d<s;d+=BigInt(100))p.push(_i({aptosConfig:e,options:{offset:d,limit:Math.min(Number(l),Number(s-d+1n))}}));let h=await Promise.all(p);for(let d of h)t.transactions.push(...d)}return t}function Ts(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function bs(n){return!!n.match(/\s/)}function Eu(n){return!!n.match(/^T[0-9]+$/)}function Pu(n){return!!n.match(/^&.+$/)}function _u(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function xu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!bs(r))break}return t}var Iu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(Iu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Re(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _81 => _81.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 b=Nn(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:d,savedExpectedTypes:g}=l;i=o,o=d,a=h,c=g}else if(p===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=Nn(a,i,t);i=[],o.push(l),a="",c+=1}else if(bs(p)){let l=!1;if(a.length!==0){let d=Nn(a,i,t);i=[],o.push(d),a="",l=!0}s=xu(n,s);let h=n[s];if(s<n.length&&l&&h!==","&&h!==">")throw new $(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return Nn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Nn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(_u(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Kt;case"bool":return new L;case"address":return new F;case"u8":return new le;case"u16":return new Je;case"u32":return new Xe;case"u64":return new J;case"u128":return new Ye;case"u256":return new Ze;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Pu(r)){let a=r.substring(1);return new mr(Nn(a,e,t))}if(Eu(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk66TIRJFDjs.Z.fromString(o[0])}catch (e4){throw new $(n,"struct address must be valid")}if(!Ts(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ts(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new Be(s,new k(o[1]),new k(o[2]),e))}}function ws(n){return typeof n=="boolean"}function it(n){return typeof n=="string"}function Cu(n){return typeof n=="number"}function kr(n){if(Cu(n))return n;if(it(n)&&n!=="")return Number.parseInt(n,10)}function Dr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ss(n){return n==null}function Es(n){return xi(n)||Ci(n)||vi(n)||Ki(n)||Ri(n)||Ui(n)||ki(n)||zr(n)||Ii(n)||vu(n)||n instanceof S||n instanceof Y}function xi(n){return n instanceof z}function zr(n){return n instanceof _chunk66TIRJFDjs.Z}function Ii(n){return n instanceof x}function vu(n){return n instanceof Ee}function Ci(n){return n instanceof X}function vi(n){return n instanceof Pe}function Ki(n){return n instanceof _e}function Ri(n){return n instanceof Q}function Ui(n){return n instanceof xe}function ki(n){return n instanceof ye}function Ps(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function _s(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ku=new TextEncoder;function cn(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _82 => _82.map, 'call', _83 => _83(e=>it(e)?Re(e):e)]), () => ([]))}async function zi(n,e,t){return(await Nr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Ni(n,e,t,r){let i=await zi(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function Hb(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Re(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function xs(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=_s(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Re(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Is(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Re(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Re(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Lb(n,e,t,r,i){return n instanceof _chunk66TIRJFDjs.X?n:_chunk66TIRJFDjs.X.newBytes(un(e,t,n,r,i).bcsToBytes())}function un(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=Re(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Mt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Mt(n,e,t,r,i,o){return Es(n)?(Di(e,n,t),n):Ru(n,e,t,r,i,o)}function Ru(n,e,t,r,i,o){if(e.isBool()){if(ws(n))return new z(n);if(it(n)){if(n==="true")return new z(!0);if(n==="false")return new z(!1)}D("boolean",t)}if(e.isAddress()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let s=kr(n);if(s!==void 0)return new X(s);D("number | string",t)}if(e.isU16()){let s=kr(n);if(s!==void 0)return new Pe(s);D("number | string",t)}if(e.isU32()){let s=kr(n);if(s!==void 0)return new _e(s);D("number | string",t)}if(e.isU64()){if(Dr(n))return new Q(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(Dr(n))return new xe(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(Dr(n))return new ye(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Mt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(it(n))return S.U8(Ku.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(it(n)&&n.startsWith("["))return Mt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Mt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(it(n))return new x(n);D("string",t)}if(e.isObject()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Ee(n);D("Uint8Array",t)}if(e.isOption()){if(Ss(n)){let a=e.value.typeArgs[0];return a instanceof L?new Y(null):a instanceof F?new Y(null):a instanceof le?new Y(null):a instanceof Je?new Y(null):a instanceof Xe?new Y(null):a instanceof J?new Y(null):a instanceof Ye?new Y(null):a instanceof Ze?new Y(null):new Y(null)}return new Y(Mt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _84 => _84.structs, 'access', _85 => _85.find, 'call', _86 => _86(a=>a.name===e.value.name.identifier), 'optionalAccess', _87 => _87.fields, 'access', _88 => _88.length])===0&&n instanceof Uint8Array)return new Ee(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _89 => _89.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Ee(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Di(n,e,t){if(n.isBool()){if(xi(e))return;D("Bool",t)}if(n.isAddress()){if(zr(e))return;D("AccountAddress",t)}if(n.isU8()){if(Ci(e))return;D("U8",t)}if(n.isU16()){if(vi(e))return;D("U16",t)}if(n.isU32()){if(Ki(e))return;D("U32",t)}if(n.isU64()){if(Ri(e))return;D("U64",t)}if(n.isU128()){if(Ui(e))return;D("U128",t)}if(n.isU256()){if(ki(e))return;D("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Di(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(Ii(e))return;D("MoveString",t)}if(n.isObject()){if(zr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof Y){e.value!==void 0&&Di(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Fr(n){if(Ps(n))return zu(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:xs});return ku({...n,abi:i})}function ku(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>un(n.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=kt.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunk66TIRJFDjs.Z.from(n.multisigAddress);return new vn(new Rn(c,new Un(a)))}return new Cn(a)}async function Cs(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Is});return Du({abi:i,...n})}function Du(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _90 => _90.functionArguments, 'optionalAccess', _91 => _91.map, 'call', _92 => _92((a,c)=>un(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return kt.build(`${t}::${r}`,i,o,s)}function zu(n){return new Ut(new Kn(_chunk66TIRJFDjs.j.fromHexInput(n.bytecode).toUint8Array(),cn(n.typeArguments),n.functionArguments))}async function Fi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>si[e.network]?{chainId:si[e.network]}:{chainId:(await _r({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Rr({aptosConfig:e})).gas_estimate},c=async()=>{let v=async()=>_optionalChain([i, 'optionalAccess', _94 => _94.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Cr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk66TIRJFDjs.Z.from(o).equals(_chunk66TIRJFDjs.Z.ZERO))try{return await v()}catch (e5){return 0}else return v()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:d,gasUnitPrice:g,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _95 => _95.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _97 => _97.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new be(_chunk66TIRJFDjs.Z.from(t),BigInt(h),r,BigInt(d),BigInt(g),BigInt(b),new tn(p))}async function Oi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Fi({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.secondarySignerAddresses, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(c=>_chunk66TIRJFDjs.Z.from(c))]), () => ([]));return new Ar(s,a,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}return new rn(s,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}function vs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=pn(e);if(t.feePayerAddress){let a=new zt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>pn(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0)));let p=pn(i),l=new Ot(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new tt(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Dt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>pn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0));let p=new Ft(o,t.secondarySignerAddresses,c);return new tt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof ve)s=new Nt(o.public_key,o.signature);else if(o instanceof oe||o instanceof Ge)s=new ft(o);else if(o instanceof en)s=new ft(o);else throw new Error("Invalid public key");return new tt(t.rawTransaction,s).bcsToBytes()}function pn(n){if(!n)return new en;let t=U.isInstance(n)||Z.isInstance(n)||$e.isInstance(n)?new N(n):n,r=new K(new Uint8Array(64));if(I.isInstance(t))return new ve(t,r);if(N.isInstance(t))return U.isInstance(t.publicKey)?new oe(t,new H(he.getSimulationSignature())):new oe(t,new H(r));if(Fe.isInstance(t))return new Ge(t,new Oe({signatures:t.publicKeys.map(i=>U.isInstance(i.publicKey)||Z.isInstance(i.publicKey)?new H(he.getSimulationSignature()):new H(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Gi(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Ko(j,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Ot(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Ft(i,e.secondarySignerAddresses,r)}else i instanceof ve?o=new Nt(i.public_key,i.signature):i instanceof je?o=new nn(i.public_key,i.signature):o=new ft(i);return new tt(e.rawTransaction,o).bcsToBytes()}function Ks(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Nu=Ks(["APTOS::Transaction"]);function yw(n){let e=Gi(n);return new (0, _chunk66TIRJFDjs.j)(Ks([Nu,new Uint8Array([0]),e])).toString()}async function Rs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:De(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Or=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:r}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),r({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0)for(let l of e.typeArguments)await this.builder.load_type_tag(o,l.toString());let s=cn(e.typeArguments),a=await zi(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let c=_optionalChain([a, 'optionalAccess', _101 => _101.exposed_functions, 'access', _102 => _102.find, 'call', _103 => _103(l=>l.name===i)]);if(!c)throw new Error(`Could not find function ABI for '${t}::${r}::${i}'`);if(s.length!==c.generic_type_params.length)throw new Error(`Type argument count mismatch, expected ${_optionalChain([c, 'optionalAccess', _104 => _104.generic_type_params, 'access', _105 => _105.length])}, received ${s.length}`);let p=e.functionArguments.map((l,h)=>l instanceof _chunk66TIRJFDjs.X?l:_chunk66TIRJFDjs.X.newBytes(un(i,a,l,h,s,{allowUnknownStructs:!0}).bcsToBytes()));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(l=>l.toString()),p)}build(){return this.builder.generate_batched_calls(!0)}};async function T(n){let e=await Fu(n);return Ou(n,e)}async function Fu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Fr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Fr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Fr(r)),i}async function Ou(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Gu(n)&&(o=_chunk66TIRJFDjs.Z.ZERO.toString()),Bu(n)){let{secondarySignerAddresses:s}=n;return Oi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Oi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Gu(n){return n.withFeePayer===!0}function Bu(n){return"secondarySignerAddresses"in n}function Us(n){let{transaction:e}=n;return Ke(e)}function Gr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Br(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Gr({signer:e,transaction:t})}async function Mi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=vs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await gt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _106 => _106.options, 'optionalAccess', _107 => _107.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _108 => _108.options, 'optionalAccess', _109 => _109.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Fn(n){let{aptosConfig:e}=n,t=Gi({...n});try{let{data:r}=await gt({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=tt.deserialize(new R(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof U||i.authenticator.sender.public_key.publicKey instanceof Z)&&await me.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function ht(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;br(t)&&await t.checkKeylessAccountValidity(e),br(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Br({signer:r,transaction:i}),s=Gr({signer:t,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ks(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;br(r)&&await r.checkKeylessAccountValidity(e);let o=Br({signer:r,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Mu={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Ds(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return T({aptosConfig:e,sender:_chunk66TIRJFDjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Mu},options:o})}async function Vt(n){return Cr(n)}async function Ns(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _112 => _112.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _113 => _113.limit]), () => (1e3))}})}async function Fs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _114 => _114.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _115 => _115.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _116 => _116.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Nr(n){return ds(n)}async function Os(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _117 => _117.offset]),limit:_optionalChain([r, 'optionalAccess', _118 => _118.limit])}})}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _119 => _119.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (999))}})}async function Bs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _122 => _122.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _123 => _123.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Hi(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _124 => _124.ledgerVersion])}});return o.data}async function dn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Hi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk66TIRJFDjs.Z.from(t);try{let a=await vr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk66TIRJFDjs.Z.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ms(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Jo,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 Vs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _125 => _125.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _126 => _126.tokenStandard])});let s={query:Qo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([r, 'optionalAccess', _128 => _128.limit]),order_by:_optionalChain([r, 'optionalAccess', _129 => _129.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Hs(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t).toStringLong(),s=_chunk66TIRJFDjs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _130 => _130.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _131 => _131.tokenStandard])});let c={query:jo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _132 => _132.offset]),limit:_optionalChain([i, 'optionalAccess', _133 => _133.limit]),order_by:_optionalChain([i, 'optionalAccess', _134 => _134.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard])}});let s={query:Wo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _137 => _137.offset]),limit:_optionalChain([r, 'optionalAccess', _138 => _138.limit]),order_by:_optionalChain([r, 'optionalAccess', _139 => _139.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function qs(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Xo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function $s(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _140 => _140.where]),owner_address:{_eq:i}},s={query:$o,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ws(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:qo,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 Qs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},s={query:Pr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([r, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([r, 'optionalAccess', _146 => _146.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function js(n){let{aptosConfig:e,privateKey:t}=n,r=new N(t.publicKey());if(t instanceof We){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return nt.fromPrivateKey({privateKey:t,address:o})}if(t instanceof q){let i=B.fromPublicKey({publicKey:r.publicKey});if(await zs({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!0})}let s=B.fromPublicKey({publicKey:r});if(await zs({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!1})}}throw new Error(`Can't derive account from private key ${t}`)}async function zs(n){let{aptosConfig:e,authKey:t}=n,r=await dn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Vt({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}var Vu={typeParameters:[],parameters:[new le,C.u8(),new le,C.u8(),C.u8(),C.u8()]};async function Js(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof se)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof wr)return Vi({aptosConfig:e,fromAccount:t,toAccount:n.toAccount});i=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)i=n.toAuthKey;else throw new Error("Invalid arguments");let o=await Lu({aptosConfig:e,fromAccount:t,toAuthKey:i});if(r===!0)return o;let s=await At({aptosConfig:e,transactionHash:o.hash});if(!s.success)throw new Error(`Failed to rotate authentication key - ${s}`);let a=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return ht({aptosConfig:e,signer:n.toAccount,transaction:a})}async function Vi(n){let{aptosConfig:e,fromAccount:t}=n,r=await Vt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=nt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new fr({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk66TIRJFDjs.Z.from(r.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),a=t.sign(s),c=i.sign(s),p=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new X(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:Vu}});return ht({aptosConfig:e,signer:t,transaction:p})}var Hu={typeParameters:[],parameters:[C.u8()]};async function Lu(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r}=n,i=r,o=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[S.U8(i.toUint8Array())],abi:Hu}});return ht({aptosConfig:e,signer:t,transaction:o})}async function E(n){n.minimumLedgerVersion!==void 0&&await Ur({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Cs({...t,aptosConfig:e}),o=new _chunk66TIRJFDjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await gt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _147 => _147.ledgerVersion])},body:s});return a}async function Xs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await gt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _148 => _148.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function Ys(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(_()),new A(_())]}},options:i})}async function Zs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(_()),new A(_())]}},options:i})}async function ea(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Ht=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk66TIRJFDjs.la.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.some, 'call', _150 => _150(s=>_chunk66TIRJFDjs.Z.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ys({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Zs({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ea({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk66TIRJFDjs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk66TIRJFDjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var On=class{constructor(e){this.config=e;this.abstraction=new Ht(e)}async getAccountInfo(e){return Vt({aptosConfig:this.config,...e})}async getAccountModules(e){return Ns({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Fs({aptosConfig:this.config,...e})}async getAccountModule(e){return Nr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Os({aptosConfig:this.config,...e})}async getAccountResources(e){return Gs({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Bs({aptosConfig:this.config,...e})}async getAccountResource(e){return Hi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return dn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ms({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),qs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ws({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:xt,faMetadataAddress:Io,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
498
+ `;async function Sr(n){let{aptosConfig:e}=n,{data:t}=await M({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function ls(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:ts,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await ko({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function wu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:wi},originMethod:"getProcessorStatuses"})).processor_status}async function _r(n){let e=await wu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Pr(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:wi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Er(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await M({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}`});return r}async function ys(n){return _optionalChain([n, 'access', _60 => _60.options, 'optionalAccess', _61 => _61.ledgerVersion])!==void 0?gs(n):ze(async()=>gs(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function gs(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await M({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _62 => _62.ledgerVersion])}});return o}async function xr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await At({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _63 => _63.ledgerVersion])},body:r})).data}async function ms(n){let{aptosConfig:e,options:t}=n,r={query:cs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _64 => _64.where]),offset:_optionalChain([t, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([t, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([t, 'optionalAccess', _67 => _67.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function fs(n){let{aptosConfig:e,options:t}=n,r={query:us,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Pi(n){let{aptosConfig:e,options:t}=n;return cr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([t, 'optionalAccess', _73 => _73.limit])}})}async function vr(n){let{aptosConfig:e}=n;return ze(async()=>{let{data:t}=await M({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function As(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await M({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function Rn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await M({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function hs(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await Rn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _74 => _74.status])===404)return!0;throw r}}async function Su(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await M({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function wt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _75 => _75.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _76 => _76.checkSuccess]), () => (!0)),s=!0,a=0,c,d,l=200,f=1.5;function p(g){if(!(g instanceof Te)||(d=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await Rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){p(g)}if(s){let g=Date.now();try{c=await Su({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await Rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){p(g)}await _chunkBNN2XWNRjs.ca.call(void 0, l),a+=l/1e3,l*=f}if(c===void 0)throw d||new Ir(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Ir(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new _i(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Cr(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await _r({aptosConfig:e}):s=(await Pr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkBNN2XWNRjs.ca.call(void 0, 200)}}var Ir=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},_i=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function bs(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await M({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _77 => _77.withTransactions])}});return ws({block:i,...n})}async function Ts(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await M({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _78 => _78.withTransactions])}});return ws({block:i,...n})}async function ws(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _79 => _79.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _80 => _80.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let d=[],l=100n;for(let p=c+1n;p<s;p+=BigInt(100))d.push(Pi({aptosConfig:e,options:{offset:p,limit:Math.min(Number(l),Number(s-p+1n))}}));let f=await Promise.all(d);for(let p of f)t.transactions.push(...p)}return t}function Ss(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function _s(n){return!!n.match(/\s/)}function _u(n){return!!n.match(/^T[0-9]+$/)}function Pu(n){return!!n.match(/^&.+$/)}function Eu(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function xu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!_s(r))break}return t}var Iu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(Iu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function De(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _81 => _81.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let b=Un(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:f,savedTypes:p,savedExpectedTypes:g}=l;i=o,o=p,a=f,c=g}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=Un(a,i,t);i=[],o.push(l),a="",c+=1}else if(_s(d)){let l=!1;if(a.length!==0){let p=Un(a,i,t);i=[],o.push(p),a="",l=!0}s=xu(n,s);let f=n[s];if(s<n.length&&l&&f!==","&&f!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return Un(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Un(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Eu(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new kt;case"bool":return new H;case"address":return new O;case"u8":return new ye;case"u16":return new et;case"u32":return new tt;case"u64":return new J;case"u128":return new nt;case"u256":return new rt;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new v(e[0]);default:if(Pu(r)){let a=r.substring(1);return new pr(Un(a,e,t))}if(_u(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunkBNN2XWNRjs._.fromString(o[0])}catch (e4){throw new $(n,"struct address must be valid")}if(!Ss(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ss(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new h(new Le(s,new F(o[1]),new F(o[2]),e))}}function Ps(n){return typeof n=="boolean"}function ct(n){return typeof n=="string"}function vu(n){return typeof n=="number"}function Kr(n){if(vu(n))return n;if(ct(n)&&n!=="")return Number.parseInt(n,10)}function Rr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Es(n){return n==null}function xs(n){return Ei(n)||Ii(n)||vi(n)||Ci(n)||Ki(n)||Ri(n)||Ui(n)||Ur(n)||xi(n)||Cu(n)||n instanceof _||n instanceof Y}function Ei(n){return n instanceof N}function Ur(n){return n instanceof _chunkBNN2XWNRjs._}function xi(n){return n instanceof I}function Cu(n){return n instanceof Ee}function Ii(n){return n instanceof X}function vi(n){return n instanceof xe}function Ci(n){return n instanceof Ie}function Ki(n){return n instanceof Q}function Ri(n){return n instanceof ve}function Ui(n){return n instanceof he}function Is(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function vs(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ku=new TextEncoder;function kr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _82 => _82.map, 'call', _83 => _83(e=>ct(e)?De(e):e)]), () => ([]))}async function Ru(n,e,t){return(await Fr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Fi(n,e,t,r){let i=await Ru(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function JT(n,e,t,r){let i=await Fi(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(De(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Cs(n,e,t,r){let i=await Fi(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=vs(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(De(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Ks(n,e,t,r){let i=await Fi(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(De(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(De(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Di(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=De(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Vt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Vt(n,e,t,r,i,o){return xs(n)?(ki(e,n,t),n):Uu(n,e,t,r,i,o)}function Uu(n,e,t,r,i,o){if(e.isBool()){if(Ps(n))return new N(n);if(ct(n)){if(n==="true")return new N(!0);if(n==="false")return new N(!1)}D("boolean",t)}if(e.isAddress()){if(ct(n))return _chunkBNN2XWNRjs._.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let s=Kr(n);if(s!==void 0)return new X(s);D("number | string",t)}if(e.isU16()){let s=Kr(n);if(s!==void 0)return new xe(s);D("number | string",t)}if(e.isU32()){let s=Kr(n);if(s!==void 0)return new Ie(s);D("number | string",t)}if(e.isU64()){if(Rr(n))return new Q(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(Rr(n))return new ve(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(Rr(n))return new he(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Vt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(ct(n))return _.U8(Ku.encode(n));if(n instanceof Uint8Array)return _.U8(n);if(n instanceof ArrayBuffer)return _.U8(new Uint8Array(n))}if(ct(n)&&n.startsWith("["))return Vt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new _(n.map(s=>Vt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(ct(n))return new I(n);D("string",t)}if(e.isObject()){if(ct(n))return _chunkBNN2XWNRjs._.fromString(n);D("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Ee(n);D("Uint8Array",t)}if(e.isOption()){if(Es(n)){let a=e.value.typeArgs[0];return a instanceof H?new Y(null):a instanceof O?new Y(null):a instanceof ye?new Y(null):a instanceof et?new Y(null):a instanceof tt?new Y(null):a instanceof J?new Y(null):a instanceof nt?new Y(null):a instanceof rt?new Y(null):new Y(null)}return new Y(Vt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _84 => _84.structs, 'access', _85 => _85.find, 'call', _86 => _86(a=>a.name===e.value.name.identifier), 'optionalAccess', _87 => _87.fields, 'access', _88 => _88.length])===0&&n instanceof Uint8Array)return new Ee(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _89 => _89.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Ee(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function ki(n,e,t){if(n.isBool()){if(Ei(e))return;D("Bool",t)}if(n.isAddress()){if(Ur(e))return;D("AccountAddress",t)}if(n.isU8()){if(Ii(e))return;D("U8",t)}if(n.isU16()){if(vi(e))return;D("U16",t)}if(n.isU32()){if(Ci(e))return;D("U32",t)}if(n.isU64()){if(Ki(e))return;D("U64",t)}if(n.isU128()){if(Ri(e))return;D("U128",t)}if(n.isU256()){if(Ui(e))return;D("U256",t)}if(n.isVector()){if(e instanceof _){e.values.length>0&&ki(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof h){if(n.isString()){if(xi(e))return;D("MoveString",t)}if(n.isObject()){if(Ur(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof Y){e.value!==void 0&&ki(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Dr(n){if(Is(n))return Nu(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunkBNN2XWNRjs.ma.call(void 0, n.function),i=await Fs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Cs});return Fu({...n,abi:i})}function Fu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkBNN2XWNRjs.ma.call(void 0, n.function),o=kr(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>Di(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=Dt.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunkBNN2XWNRjs._.from(n.multisigAddress);return new xn(new vn(c,new Cn(a)))}return new En(a)}async function Rs(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunkBNN2XWNRjs.ma.call(void 0, n.function),i=await Fs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ks});return Du({abi:i,...n})}function Du(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkBNN2XWNRjs.ma.call(void 0, n.function),o=kr(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _90 => _90.functionArguments, 'optionalAccess', _91 => _91.map, 'call', _92 => _92((a,c)=>Di(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return Dt.build(`${t}::${r}`,i,o,s)}function Nu(n){return new Pn(new In(_chunkBNN2XWNRjs.j.fromHexInput(n.bytecode).toUint8Array(),kr(n.typeArguments),n.functionArguments))}async function Ou(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>oi[e.network]?{chainId:oi[e.network]}:{chainId:(await Sr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await vr({aptosConfig:e})).gas_estimate},c=async()=>{let C=async()=>_optionalChain([i, 'optionalAccess', _94 => _94.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Er({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunkBNN2XWNRjs._.from(o).equals(_chunkBNN2XWNRjs._.ZERO))try{return await C()}catch (e5){return 0}else return C()},[{chainId:d},{gasEstimate:l},f]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:g,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _95 => _95.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _97 => _97.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new Se(_chunkBNN2XWNRjs._.from(t),BigInt(f),r,BigInt(p),BigInt(g),BigInt(b),new en(d))}async function Ni(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Ou({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.secondarySignerAddresses, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(c=>_chunkBNN2XWNRjs._.from(c))]), () => ([]));return new mr(s,a,n.feePayerAddress?_chunkBNN2XWNRjs._.from(n.feePayerAddress):void 0)}return new yr(s,n.feePayerAddress?_chunkBNN2XWNRjs._.from(n.feePayerAddress):void 0)}function Us(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=an(e);if(t.feePayerAddress){let a=new Ot(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(f=>an(f)):c=Array.from({length:t.secondarySignerAddresses.length},()=>an(void 0)));let d=an(i),l=new Bt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new ot(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Nt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>an(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>an(void 0));let d=new Gt(o,t.secondarySignerAddresses,c);return new ot(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ue)s=new zt(o.public_key,o.signature);else if(o instanceof ae||o instanceof He)s=new Tt(o);else if(o instanceof Zt)s=new Tt(o);else throw new Error("Invalid public key");return new ot(t.rawTransaction,s).bcsToBytes()}function an(n){if(!n)return new Zt;let t=k.isInstance(n)||Z.isInstance(n)||Je.isInstance(n)?new U(n):n,r=new R(new Uint8Array(64));if(E.isInstance(t))return new Ue(t,r);if(U.isInstance(t))return k.isInstance(t.publicKey)?new ae(t,new V(we.getSimulationSignature())):new ae(t,new V(r));if(se.isInstance(t))return new He(t,new Me({signatures:t.publicKeys.map(i=>k.isInstance(i.publicKey)||Z.isInstance(i.publicKey)?new V(we.getSimulationSignature()):new V(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Oi(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Ro(j,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Bt(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Gt(i,e.secondarySignerAddresses,r)}else i instanceof Ue?o=new zt(i.public_key,i.signature):i instanceof Ze?o=new tn(i.public_key,i.signature):o=new Tt(i);return new ot(e.rawTransaction,o).bcsToBytes()}function ks(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var zu=ks(["APTOS::Transaction"]);function ww(n){let e=Oi(n);return new (0, _chunkBNN2XWNRjs.j)(ks([zu,new Uint8Array([0]),e])).toString()}async function Fs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:ze(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function T(n){let e=await Gu(n);return Bu(n,e)}async function Gu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Dr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Dr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Dr(r)),i}async function Bu(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Mu(n)&&(o=_chunkBNN2XWNRjs._.ZERO.toString()),Vu(n)){let{secondarySignerAddresses:s}=n;return Ni({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Ni({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Mu(n){return n.withFeePayer===!0}function Vu(n){return"secondarySignerAddresses"in n}function Ds(n){let{transaction:e}=n;return ke(e)}function Nr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Or(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Nr({signer:e,transaction:t})}async function zi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Us({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await At({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _103 => _103.options, 'optionalAccess', _104 => _104.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _105 => _105.options, 'optionalAccess', _106 => _106.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function kn(n){let{aptosConfig:e}=n,t=Oi({...n});try{let{data:r}=await At({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=ot.deserialize(new K(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof k||i.authenticator.sender.public_key.publicKey instanceof Z)&&await fe.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function St(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;hr(t)&&await t.checkKeylessAccountValidity(e),hr(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Or({signer:r,transaction:i}),s=Nr({signer:t,transaction:i});return kn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Ns(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;hr(r)&&await r.checkKeylessAccountValidity(e);let o=Or({signer:r,transaction:i});return kn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Hu={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Os(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>_.U8(a));return T({aptosConfig:e,sender:_chunkBNN2XWNRjs._.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[_.U8(r),new _(s)],abi:Hu},options:o})}async function ee(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Rs({...t,aptosConfig:e}),o=new _chunkBNN2XWNRjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await At({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _107 => _107.ledgerVersion])},body:s});return a}async function zs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await At({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _108 => _108.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function cn(n){return Er(n)}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ci({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _109 => _109.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _110 => _110.limit]), () => (1e3))}})}async function Bs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await ur({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _111 => _111.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _112 => _112.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _113 => _113.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Fr(n){return ys(n)}async function Bi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return cr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _114 => _114.offset]),limit:_optionalChain([r, 'optionalAccess', _115 => _115.limit])}})}async function Mi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ci({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _116 => _116.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _117 => _117.limit]), () => (999))}})}async function Ms(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await ur({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _118 => _118.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _119 => _119.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Vi(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await M({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunkBNN2XWNRjs._.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _121 => _121.ledgerVersion])}});return o.data}async function Fn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Vi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunkBNN2XWNRjs._.from(t);try{let a=await xr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunkBNN2XWNRjs._.from(a)}catch(a){if(a instanceof Te&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Vs(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Yo,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 Hs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _122 => _122.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _123 => _123.tokenStandard])});let s={query:Jo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _124 => _124.offset]),limit:_optionalChain([r, 'optionalAccess', _125 => _125.limit]),order_by:_optionalChain([r, 'optionalAccess', _126 => _126.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Ls(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunkBNN2XWNRjs._.from(t).toStringLong(),s=_chunkBNN2XWNRjs._.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _127 => _127.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _128 => _128.tokenStandard])});let c={query:Xo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _129 => _129.offset]),limit:_optionalChain([i, 'optionalAccess', _130 => _130.limit]),order_by:_optionalChain([i, 'optionalAccess', _131 => _131.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function qs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _132 => _132.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _133 => _133.tokenStandard])}});let s={query:jo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _134 => _134.offset]),limit:_optionalChain([r, 'optionalAccess', _135 => _135.limit]),order_by:_optionalChain([r, 'optionalAccess', _136 => _136.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function $s(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkBNN2XWNRjs._.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Zo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Ws(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunkBNN2XWNRjs._.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _137 => _137.where]),owner_address:{_eq:i}},s={query:Qo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _138 => _138.offset]),limit:_optionalChain([r, 'optionalAccess', _139 => _139.limit]),order_by:_optionalChain([r, 'optionalAccess', _140 => _140.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Qs(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkBNN2XWNRjs._.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Wo,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 js(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}},s={query:wr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Js(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _144 => _144.throwIfNoAccountFound]), () => (!1)),o=await zr({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return st.fromPrivateKey({privateKey:t})}return o[0]}async function Lu(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,[o]]=await Promise.all([Mi({aptosConfig:e,accountAddress:t}),ee({aptosConfig:e,payload:{function:"0x1::coin::balance",typeArguments:["0x1::aptos_coin::AptosCoin"],functionArguments:[t]}})]),s=parseInt(o,10),a=i.find(d=>d.type==="0x1::account::Account");if(!a&&s===0)return!1;if(!_optionalChain([r, 'optionalAccess', _145 => _145.withAuthKey]))return!0;let c;return a?c=a.data.authentication_key:c=t.toStringLong(),c===r.withAuthKey.toString()}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${t.toString()}`)}}var qu={typeParameters:[],parameters:[new ye,v.u8(),new ye,v.u8(),v.u8(),v.u8()]};async function Xs(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r,options:i}=n;if("toNewPrivateKey"in n)return Gi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:i});let o;if("toAccount"in n){if(n.toAccount instanceof re)return Gi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:i});if(n.toAccount instanceof on)return Gi({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:i});o=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)o=n.toAuthKey;else throw new Error("Invalid arguments");let s=await Wu({aptosConfig:e,fromAccount:t,toAuthKey:o,options:i});if(r===!0)return s;let a=await wt({aptosConfig:e,transactionHash:s.hash});if(!a.success)throw new Error(`Failed to rotate authentication key - ${a}`);let c=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return St({aptosConfig:e,signer:n.toAccount,transaction:c})}async function Gi(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await cn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=st.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new gr({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunkBNN2XWNRjs._.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a),l=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),_.U8(t.publicKey.toUint8Array()),new X(o.signingScheme),_.U8(o.publicKey.toUint8Array()),_.U8(c.toUint8Array()),_.U8(d.toUint8Array())],abi:qu},options:r});return St({aptosConfig:e,signer:t,transaction:l})}var $u={typeParameters:[],parameters:[v.u8()]};async function Wu(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r,options:i}=n,o=r,s=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[_.U8(o.toUint8Array())],abi:$u},options:i});return St({aptosConfig:e,signer:t,transaction:s})}async function Gr(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _146 => _146.noMultiKey]), () => (!1));if(i&&t instanceof Re)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof U&&t.publicKey instanceof E?o.push(t.publicKey):t instanceof E&&o.push(new U(t));let[s,a]=await Promise.all([Promise.all(o.map(async f=>{let p=await Yu({aptosConfig:e,publicKey:f});if(p)return{...p,publicKey:f}})),!(t instanceof Re)&&!i?ju({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let f of s)f&&c.push(f);o.push(...a);let d=new Map(o.map(f=>[f.authKey().toString(),f])),l=await Ju({aptosConfig:e,authKeys:o.map(f=>f.authKey()),options:r});for(let f of l){if(c.find(g=>g.accountAddress===f.accountAddress))continue;let p=d.get(f.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${f.authKey}. This should never happen.`);c.push({accountAddress:f.accountAddress,publicKey:p,lastTransactionVersion:f.lastTransactionVersion})}return c.sort((f,p)=>p.lastTransactionVersion-f.lastTransactionVersion)}async function Hi(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof q||t instanceof Xe)return zr({aptosConfig:e,privateKey:t,options:r});if(t instanceof re||t instanceof ce)return zr({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof _e||t instanceof Fe)return Qu({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof at&&t.signers.length===1)return Hi({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof on&&t.signers.length===1)return zr({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function Qu(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await Gr({aptosConfig:e,publicKey:t.getAnyPublicKey(),options:r}),o={proof:t.proofOrPromise,jwt:t.jwt,ephemeralKeyPair:t.ephemeralKeyPair,pepper:t.pepper,verificationKeyHash:t.verificationKeyHash},s=[];for(let{accountAddress:a,publicKey:c}of i)if(c instanceof Re){if(c.getSignaturesRequired()>1)continue;if(c instanceof Ve)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof se&&s.push(new at({multiKey:c,signers:[t],address:a}))}else t instanceof Fe?s.push(Fe.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(_e.create({...o,address:a}));return s}async function zr(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=st.fromPrivateKey({privateKey:t,legacy:!1}),o=await Gr({aptosConfig:e,publicKey:new U(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof Re){if(c.getSignaturesRequired()>1)continue;c instanceof Ve?s.push(new on({publicKey:c,signers:[t],address:a})):c instanceof se&&s.push(new at({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof E;s.push(st.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function ju(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof Re)throw new Error("Public key is a multi-key.");let i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _147 => _147.includeUnverified]), () => (!1)),o=t instanceof U?t:new U(t),s=o.publicKey,a=_chunkBNN2XWNRjs.z.call(void 0, o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:es,variables:{where_condition:c}},{public_key_auth_keys:l}=await w({aptosConfig:e,query:d,originMethod:"getAuthKeysForPublicKey"});return l.map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return Ve.deserializeWithoutLength(K.fromHex(p.account_public_key));case"multi_key_signature":return se.deserialize(K.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function Ju(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _148 => _148.includeUnverified]), () => (!1));if(t.length===0)throw new Error("No authentication keys provided");let o={auth_key:{_in:t.map(c=>c.toString())},...i?{}:{is_auth_key_used:{_eq:!0}}},s={query:$o,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await w({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new L({data:c.auth_key}),accountAddress:new (0, _chunkBNN2XWNRjs._)(_chunkBNN2XWNRjs.j.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function Xu(n){let{aptosConfig:e,accountAddress:t}=n,r=await Bi({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function Yu(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([Xu({aptosConfig:e,accountAddress:r}),Lu({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function S(n){n.minimumLedgerVersion!==void 0&&await Cr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function Ys(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkBNN2XWNRjs.ma.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new O,new h(x()),new h(x())]}},options:i})}async function Zs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkBNN2XWNRjs.ma.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new O,new h(x()),new h(x())]}},options:i})}async function ea(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Ht=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunkBNN2XWNRjs.ma.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.some, 'call', _150 => _150(s=>_chunkBNN2XWNRjs._.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ys({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Zs({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ea({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ee({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunkBNN2XWNRjs._.from(t)],abi:{typeParameters:[],parameters:[new O],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunkBNN2XWNRjs._.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var Dn=class{constructor(e){this.config=e;this.abstraction=new Ht(e)}async getAccountInfo(e){return cn({aptosConfig:this.config,...e})}async getAccountModules(e){return Gs({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Bs({aptosConfig:this.config,...e})}async getAccountModule(e){return Fr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Bi({aptosConfig:this.config,...e})}async getAccountResources(e){return Mi({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Ms({aptosConfig:this.config,...e})}async getAccountResource(e){return Vi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Fn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Vs({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qs({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),$s({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ws({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Qs({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Ct,faMetadataAddress:vo,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
478
499
  compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
479
- will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await De(async()=>{try{let p=(await ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunk66TIRJFDjs.ka.call(void 0, p.vec[0]))return _chunk66TIRJFDjs.ja.call(void 0, p.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunk66TIRJFDjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===xt?a=_chunk66TIRJFDjs.Z.A.toStringLong():a=_chunk66TIRJFDjs._.call(void 0, _chunk66TIRJFDjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let p=_chunk66TIRJFDjs.Z.from(i);a=p.toStringLong(),p===_chunk66TIRJFDjs.Z.A&&(s=xt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qs({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return js({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Mr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _151 => _151.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _152 => _152.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _153 => _153.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _154 => _154.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _155 => _155.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _156 => _156.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _157 => _157.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _158 => _158.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _159 => _159.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _160 => _160.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _161 => _161.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Eo[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Po[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 So[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 ri[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 ii[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return ri[this.network]===e}isProverServiceRequest(e){return ii[this.network]===e}};var $u={typeParameters:[{constraints:[]}],parameters:[new F,new J]};async function ta(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (xt))],functionArguments:[r,i],abi:$u},options:s})}var Gn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ta({aptosConfig:this.config,...e})}};var Tt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Se="0x4::token::Token";async function na(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:cs,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ra(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Ei,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ia(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:Ei,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _162 => _162.offset]),limit:_optionalChain([r, 'optionalAccess', _163 => _163.limit]),order_by:_optionalChain([r, 'optionalAccess', _164 => _164.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function oa(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},o={query:as,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _165 => _165.offset]),limit:_optionalChain([r, 'optionalAccess', _166 => _166.limit]),order_by:_optionalChain([r, 'optionalAccess', _167 => _167.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Wu={typeParameters:[],parameters:[new A(_()),new J,new A(_()),new A(_()),new L,new L,new L,new L,new L,new L,new L,new L,new L,new J,new J]};async function sa(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(n.description),new Q(_nullishCoalesce(n.maxSupply, () => (_chunk66TIRJFDjs.e))),new x(n.name),new x(n.uri),new z(_nullishCoalesce(n.mutableDescription, () => (!0))),new z(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new z(_nullishCoalesce(n.mutableURI, () => (!0))),new z(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new z(_nullishCoalesce(n.mutableTokenName, () => (!0))),new z(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new z(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new z(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new z(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Wu},options:t})}async function ln(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _168 => _168.where]);_optionalChain([t, 'optionalAccess', _169 => _169.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _170 => _170.tokenStandard]), () => ("v2"))});let i={query:Zo,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _171 => _171.offset]),limit:_optionalChain([t, 'optionalAccess', _172 => _172.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function aa(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _173 => _173.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _174 => _174.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...i,where:s}})}async function ca(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _175 => _175.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _176 => _176.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _177 => _177.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _178 => _178.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function pa(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk66TIRJFDjs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _179 => _179.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _180 => _180.tokenStandard]), () => ("v2"))}),(await ln({aptosConfig:i,options:{where:s}})).collection_id}var Qu={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8())]};async function da(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:l}=n,h=_optionalChain([p, 'optionalAccess', _181 => _181.map, 'call', _182 => _182(d=>Tt[d])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(i),new x(o),new x(s),new x(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(h, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:Qu},options:t})}var ju={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new F]};async function la(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r),_chunk66TIRJFDjs.Z.from(i)],abi:ju},options:s})}var Ju={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8()),new F]};async function ga(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:l,options:h}=n;if(_optionalChain([c, 'optionalAccess', _183 => _183.length])!==_optionalChain([l, 'optionalAccess', _184 => _184.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _185 => _185.length])!==_optionalChain([l, 'optionalAccess', _186 => _186.length]))throw new Error("Property types and property values counts do not match");let d=_optionalChain([p, 'optionalAccess', _187 => _187.map, 'call', _188 => _188(g=>Tt[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(d, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(d, () => ([]))),a],abi:Ju},options:h})}var Xu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ma(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r)],abi:Xu},options:o})}var Yu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ya(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Yu},options:o})}var Zu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function fa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Zu},options:o})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Aa(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:ep},options:s})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function ha(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:tp},options:s})}var np={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Ta(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:np},options:s})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function ba(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),S.U8(Li(o,Tt[i]))],abi:rp},options:c})}var ip={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function wa(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:ip},options:s})}var op={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function Sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),Li(o,Tt[i])],abi:op},options:c})}var sp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Ea(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:sp},options:c})}var ap={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Pa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:ap},options:c})}function _a(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Li(n[i],r))}),t}function Li(n,e){let t=Re(e);return Mt(n,t,0,[]).bcsToBytes()}var Bn=class{constructor(e){this.config=e}async getCollectionData(e){await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _189 => _189.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _190 => _190.tokenStandard]), () => ("v2"))}),ln({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),aa({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ca({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pa({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),na({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ra({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ia({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oa({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sa({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return da({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return la({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return ga({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ma({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ya({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return fa({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Aa({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ha({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ta({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return ba({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Sa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ea({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Pa({aptosConfig:this.config,...e})}};var xa=300,cp=n=>{if(n&&n.length>xa)throw new Error(`Event type length exceeds the maximum length of ${xa}`)};async function Ia(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Mn({aptosConfig:e,options:{...r,where:i}})}async function Ca(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function va(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function Mn(n){let{aptosConfig:e,options:t}=n;cp(_optionalChain([t, 'optionalAccess', _191 => _191.where, 'optionalAccess', _192 => _192.indexed_type, 'optionalAccess', _193 => _193._eq]));let r={query:ns,variables:{where_condition:_optionalChain([t, 'optionalAccess', _194 => _194.where]),offset:_optionalChain([t, 'optionalAccess', _195 => _195.offset]),limit:_optionalChain([t, 'optionalAccess', _196 => _196.limit]),order_by:_optionalChain([t, 'optionalAccess', _197 => _197.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Vn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ia({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ca({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),va({aptosConfig:this.config,...e})}async getEvents(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _198 => _198.minimumLedgerVersion]),processorType:"events_processor"}),Mn({aptosConfig:this.config,...e})}};async function Ka(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _199 => _199.timeoutSecs])||20,{data:s}=await ko({aptosConfig:e,path:"fund",body:{address:_chunk66TIRJFDjs.Z.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await At({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _200 => _200.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Hn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ka({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.waitForIndexer])===void 0||_optionalChain([e, 'access', _203 => _203.options, 'optionalAccess', _204 => _204.waitForIndexer]))&&await Ur({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Vr(n){let{aptosConfig:e,options:t}=n,r={query:is,variables:{where_condition:_optionalChain([t, 'optionalAccess', _205 => _205.where]),limit:_optionalChain([t, 'optionalAccess', _206 => _206.limit]),offset:_optionalChain([t, 'optionalAccess', _207 => _207.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Ra(n){let{aptosConfig:e,options:t}=n,r={query:rs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _208 => _208.where]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),offset:_optionalChain([t, 'optionalAccess', _210 => _210.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:es,variables:{where_condition:_optionalChain([t, 'optionalAccess', _211 => _211.where]),limit:_optionalChain([t, 'optionalAccess', _212 => _212.limit]),offset:_optionalChain([t, 'optionalAccess', _213 => _213.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ka={typeParameters:[{constraints:[]}],parameters:[Re("0x1::object::Object"),new F,new J]};async function Da(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ka},options:s})}async function za(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:ka},options:s})}var Ln=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _214 => _214.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Vr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _215 => _215.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Vr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _216 => _216.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Vr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk66TIRJFDjs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ua({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Da({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return za({aptosConfig:this.config,...e})}};var qn=class{constructor(e){this.config=e}async getLedgerInfo(){return _r({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return fs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return As({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return Xs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return us({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return xr({aptosConfig:this.config})}async getProcessorStatus(e){return Ir({aptosConfig:this.config,processorType:e})}};var Na=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Fa(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function bt(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(!Fa(e))throw new Error(`${e} is not valid. ${Na}`);if(t&&!Fa(t))throw new Error(`${t} is not valid. ${Na}`);return{domainName:t||e,subdomainName:t?e:void 0}}function Oa(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var up="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",pp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:up,custom:null,devnet:null};function ot(n){let e=pp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Hr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ga(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function Ba(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=ot(e),{domainName:l,subdomainName:h}=bt(r),d=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!d)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(d&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let W=_nullishCoalesce(t.years, () => (1));if(W!==1)throw new Error("For now, names can only be registered for 1 year at a time");let st=W*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[l,st,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await qi({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[l,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function qi(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Ma(n){let{aptosConfig:e,address:t}=n,r=ot(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk66TIRJFDjs.Z.from(t).toString()]}}),o=Hr(i[1]),s=Hr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Va(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=ot(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ha(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function La(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=ot(e),{domainName:a,subdomainName:c}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function qa(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=bt(t),a=(await w({aptosConfig:e,query:{query:an,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=$n(a)),Oa(a)?a:void 0}async function $a(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _219 => _219.limit]),offset:_optionalChain([t, 'optionalAccess', _220 => _220.offset]),order_by:_optionalChain([t, 'optionalAccess', _221 => _221.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _222 => _222.options, 'optionalAccess', _223 => _223.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map($n)}async function Wa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _224 => _224.limit]),offset:_optionalChain([t, 'optionalAccess', _225 => _225.offset]),order_by:_optionalChain([t, 'optionalAccess', _226 => _226.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map($n)}async function Qa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),offset:_optionalChain([t, 'optionalAccess', _230 => _230.offset]),order_by:_optionalChain([t, 'optionalAccess', _231 => _231.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map($n)}async function ja(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _234 => _234.limit]),offset:_optionalChain([t, 'optionalAccess', _235 => _235.offset]),order_by:_optionalChain([t, 'optionalAccess', _236 => _236.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _237 => _237.options, 'optionalAccess', _238 => _238.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map($n).filter(Oa)}async function $i(n){let{aptosConfig:e}=n,t=ot(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Ja(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=ot(e),a=i*31536e3,{domainName:c,subdomainName:p}=bt(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 T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function $n(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var Wn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ga({aptosConfig:this.config,...e})}async getExpiration(e){return qi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ha({aptosConfig:this.config,...e})}async setTargetAddress(e){return La({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ma({aptosConfig:this.config,...e})}async setPrimaryName(e){return Va({aptosConfig:this.config,...e})}async registerName(e){return Ba({aptosConfig:this.config,...e})}async renewDomain(e){return Ja({aptosConfig:this.config,...e})}async getName(e){return qa({aptosConfig:this.config,...e})}async getAccountNames(e){return $a({aptosConfig:this.config,...e})}async getAccountDomains(e){return Wa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Qa({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return ja({aptosConfig:this.config,...e})}};async function Xa(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:wi,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 Ya(n){let{aptosConfig:e,options:t}=n,r={query:wi,variables:{order_by:_optionalChain([t, 'optionalAccess', _239 => _239.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ts,variables:{delegatorAddress:_chunk66TIRJFDjs.Z.from(t).toStringLong(),poolAddress:_chunk66TIRJFDjs.Z.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var Qn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _240 => _240.minimumLedgerVersion]),processorType:"stake_processor"}),Xa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _241 => _241.minimumLedgerVersion]),processorType:"stake_processor"}),Ya({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _242 => _242.minimumLedgerVersion]),processorType:"stake_processor"}),Za({aptosConfig:this.config,...e})}};var Lr=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Or(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Fi({aptosConfig:this.config,payload:Ut.load(new R(i)),...e});return new rn(o,e.withFeePayer===!0?_chunk66TIRJFDjs.Z.ZERO:void 0)}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function Wi(n,e,t){let r=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},t}function Qi(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var gn=class{constructor(e){this.config=e}async simple(e){return Mi({aptosConfig:this.config,...e})}async multiAgent(e){return Mi({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"multiAgent",1);var mn=class{constructor(e){this.config=e}async simple(e){return Fn({aptosConfig:this.config,...e})}async multiAgent(e){return Fn({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"multiAgent",1);var qr=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunk66TIRJFDjs.da.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),_chunk66TIRJFDjs.da.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Vt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Vt({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 _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk66TIRJFDjs.da.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk66TIRJFDjs.da.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var yn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _243 => _243.pendingDequeue, 'access', _244 => _244.shift, 'call', _245 => _245(), 'optionalAccess', _246 => _246.resolve, 'call', _247 => _247(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 fn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},fn=class extends Error{};var ec="fulfilled",tc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(tc||{}),$r= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new yn;this.transactionsQueue=new yn;this.outstandingTransactions=new yn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new qr(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=ht({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof fn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===ec?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof fn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(At({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===ec?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Wr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new $r(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var jn=class{constructor(e){this.config=e,this.build=new Lr(this.config),this.simulate=new gn(this.config),this.submit=new mn(this.config),this.batch=new Wr(this.config)}async getTransactions(e){return _i({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ms({aptosConfig:this.config,...e})}async getTransactionByHash(e){return zn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ys({aptosConfig:this.config,...e})}async waitForTransaction(e){return At({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Rr({aptosConfig:this.config})}getSigningMessage(e){return Us(e)}async publishPackageTransaction(e){return Ds({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Js({aptosConfig:this.config,...e})}sign(e){return Gr({...e})}signAsFeePayer(e){return Br({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return ht({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ks({aptosConfig:this.config,...e})}};var Jn=class{constructor(e){this.config=e}async getTableItem(e){return vr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ls({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gs({aptosConfig:this.config,...e})}};async function Qr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Do({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk66TIRJFDjs.j.fromHexInput(a.pepper).toUint8Array()}async function ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Qr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array().length!==rt.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${rt.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk66TIRJFDjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await zo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=p.proof,h=new mt({a:l.a,b:l.b,c:l.c});return new ue({proof:new Jt(h,0),trainingWheelsSignature:Ue.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function nc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Qr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),p=ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(r!==void 0){let g=Z.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await dn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Bt.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=U.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),d=await dn({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return rt.create({...n,address:d,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function rc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(vo.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,P.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var Xn=class{constructor(e){this.config=e}async getPepper(e){return Qr({aptosConfig:this.config,...e})}async getProof(e){return ji({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return nc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return rc({aptosConfig:this.config,...e})}};async function mp(n){let{aptosConfig:e,options:t}=n,r={query:Pr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _248 => _248.where]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),limit:_optionalChain([t, 'optionalAccess', _250 => _250.limit]),order_by:_optionalChain([t, 'optionalAccess', _251 => _251.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function ic(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await mp({aptosConfig:e,options:{...r,where:o}}))[0]}var Yn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ic({aptosConfig:this.config,...e})}};var ee=class{constructor(e){this.config=new Mr(e),this.account=new On(this.config),this.abstraction=new Ht(this.config),this.ans=new Wn(this.config),this.coin=new Gn(this.config),this.digitalAsset=new Bn(this.config),this.event=new Vn(this.config),this.faucet=new Hn(this.config),this.fungibleAsset=new Ln(this.config),this.general=new qn(this.config),this.staking=new Qn(this.config),this.transaction=new jn(this.config),this.table=new Jn(this.config),this.keyless=new Xn(this.config),this.object=new Yn(this.config)}};function ce(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}ce(ee,On,"account");ce(ee,Ht,"abstraction");ce(ee,Wn,"ans");ce(ee,Gn,"coin");ce(ee,Bn,"digitalAsset");ce(ee,Vn,"event");ce(ee,Hn,"faucet");ce(ee,Ln,"fungibleAsset");ce(ee,qn,"general");ce(ee,Qn,"staking");ce(ee,jn,"transaction");ce(ee,Jn,"table");ce(ee,Xn,"keyless");ce(ee,Yn,"object");exports.APTOS_BIP44_REGEX = Ac; exports.APTOS_COIN = xt; exports.APTOS_FA = Io; exports.APTOS_HARDENED_REGEX = fc; exports.AbstractKeylessAccount = me; exports.AbstractMultiKey = xn; exports.AbstractPublicKey = rr; exports.AbstractSignature = Tn; exports.AbstractedAccount = Sr; exports.Account = nt; exports.AccountAddress = _chunk66TIRJFDjs.Z; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = vt; exports.AccountAuthenticatorEd25519 = ve; exports.AccountAuthenticatorMultiEd25519 = je; exports.AccountAuthenticatorMultiKey = Ge; exports.AccountAuthenticatorNoAccountAuthenticator = en; exports.AccountAuthenticatorSingleKey = oe; exports.AccountAuthenticatorVariant = _chunk66TIRJFDjs.w; exports.AccountPublicKey = ie; exports.AccountSequenceNumber = qr; exports.AccountUtils = Vo; exports.AddressInvalidReason = _chunk66TIRJFDjs.Y; exports.AnyPublicKey = N; exports.AnyPublicKeyVariant = _chunk66TIRJFDjs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunk66TIRJFDjs.z; exports.Aptos = ee; exports.AptosApiError = Ae; exports.AptosApiType = _t; exports.AptosConfig = Mr; exports.AptosScriptComposer = Or; exports.AuthenticationKey = B; exports.Bool = z; exports.CKDPriv = Ao; exports.CallArgument = _chunk66TIRJFDjs.X; exports.ChainId = tn; exports.DEFAULT_MAX_GAS_AMOUNT = _o; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = xo; exports.DEFAULT_TXN_TIMEOUT_SEC = ar; exports.DerivableAbstractedAccount = Lo; exports.DeriveScheme = _chunk66TIRJFDjs.W; exports.Deserializer = R; exports.EPK_HORIZON_SECS = Xc; exports.Ed25519Account = se; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = I; exports.Ed25519Signature = K; exports.EntryFunction = kt; exports.EntryFunctionBytes = nr; exports.EphemeralCertificate = jt; exports.EphemeralCertificateVariant = _chunk66TIRJFDjs.C; exports.EphemeralKeyPair = Gt; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = _chunk66TIRJFDjs.A; exports.EphemeralSignature = Ue; exports.EphemeralSignatureVariant = _chunk66TIRJFDjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = vo; exports.FederatedKeylessAccount = Bt; exports.FederatedKeylessPublicKey = Z; exports.FeePayerRawTransaction = zt; exports.FixedBytes = Ee; exports.Groth16ProofAndStatement = gi; exports.Groth16VerificationKey = yi; exports.Groth16Zkp = mt; exports.HARDENED_OFFSET = mo; exports.Hex = _chunk66TIRJFDjs.j; exports.HexInvalidReason = _chunk66TIRJFDjs.i; exports.Identifier = k; exports.KeyType = hc; exports.KeylessAccount = rt; exports.KeylessConfiguration = mi; exports.KeylessError = P; exports.KeylessErrorCategory = Hc; exports.KeylessErrorResolutionTip = Lc; exports.KeylessErrorType = cr; exports.KeylessPublicKey = U; exports.KeylessSignature = he; exports.MAX_AUD_VAL_BYTES = di; exports.MAX_COMMITED_EPK_BYTES = ru; exports.MAX_EXTRA_FIELD_BYTES = tu; exports.MAX_ISS_VAL_BYTES = eu; exports.MAX_JWT_HEADER_B64_BYTES = nu; exports.MAX_UID_KEY_BYTES = Yc; exports.MAX_UID_VAL_BYTES = Zc; exports.MimeType = _chunk66TIRJFDjs.q; exports.ModuleId = In; exports.MoveAbility = _chunk66TIRJFDjs.S; exports.MoveFunctionVisibility = _chunk66TIRJFDjs.R; exports.MoveJWK = fi; exports.MoveOption = Y; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = Dt; exports.MultiAgentTransaction = Ar; exports.MultiEd25519Account = wr; exports.MultiEd25519PublicKey = Zt; exports.MultiEd25519Signature = Qe; exports.MultiKey = Fe; exports.MultiKeyAccount = kn; exports.MultiKeySignature = Oe; exports.MultiSig = Rn; exports.MultiSigTransactionPayload = Un; exports.Network = oi; exports.NetworkToChainId = si; exports.NetworkToFaucetAPI = Po; exports.NetworkToIndexerAPI = So; exports.NetworkToNetworkName = Il; exports.NetworkToNodeAPI = Eo; exports.NetworkToPepperAPI = ri; exports.NetworkToProverAPI = ii; exports.ParsingError = _chunk66TIRJFDjs.h; exports.PrivateKey = pt; exports.PrivateKeyVariants = _chunk66TIRJFDjs.x; exports.ProcessorType = He; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Co; exports.RAW_TRANSACTION_WITH_DATA_SALT = ai; exports.RawTransaction = be; exports.RawTransactionWithData = yr; exports.RoleType = _chunk66TIRJFDjs.T; exports.RotationProofChallenge = fr; exports.Script = Kn; exports.ScriptTransactionArgumentVariants = _chunk66TIRJFDjs.s; exports.Secp256k1PrivateKey = We; exports.Secp256k1PublicKey = $e; exports.Secp256k1Signature = Ct; exports.Serializable = _chunk66TIRJFDjs.l; exports.Serialized = hn; exports.Serializer = _chunk66TIRJFDjs.m; exports.Signature = M; exports.SignedTransaction = tt; exports.SigningScheme = _chunk66TIRJFDjs.U; exports.SigningSchemeInput = _chunk66TIRJFDjs.V; exports.SimpleTransaction = rn; exports.SingleKeyAccount = we; exports.StructTag = Be; exports.TransactionAndProof = Tr; exports.TransactionAuthenticator = et; exports.TransactionAuthenticatorEd25519 = Nt; exports.TransactionAuthenticatorFeePayer = Ot; exports.TransactionAuthenticatorMultiAgent = Ft; exports.TransactionAuthenticatorMultiEd25519 = nn; exports.TransactionAuthenticatorSingleSender = ft; exports.TransactionAuthenticatorVariant = _chunk66TIRJFDjs.v; exports.TransactionPayload = Rt; exports.TransactionPayloadEntryFunction = Cn; exports.TransactionPayloadMultiSig = vn; exports.TransactionPayloadScript = Ut; exports.TransactionPayloadVariants = _chunk66TIRJFDjs.t; exports.TransactionResponseType = _chunk66TIRJFDjs.E; exports.TransactionVariants = _chunk66TIRJFDjs.u; exports.TransactionWorker = $r; exports.TransactionWorkerEventsEnum = tc; exports.TypeTag = O; exports.TypeTagAddress = F; exports.TypeTagBool = L; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = Iu; exports.TypeTagReference = mr; exports.TypeTagSigner = Kt; exports.TypeTagStruct = A; exports.TypeTagU128 = Ye; exports.TypeTagU16 = Je; exports.TypeTagU256 = Ze; exports.TypeTagU32 = Xe; exports.TypeTagU64 = J; exports.TypeTagU8 = le; exports.TypeTagVariants = _chunk66TIRJFDjs.r; exports.TypeTagVector = C; exports.U128 = xe; exports.U16 = Pe; exports.U256 = ye; exports.U32 = _e; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = ue; exports.ZkProof = Jt; exports.ZkpVariant = _chunk66TIRJFDjs.D; exports.aptosCoinStructTag = Wy; exports.aptosRequest = ur; exports.base64UrlDecode = _chunk66TIRJFDjs.fa; exports.base64UrlToBytes = _chunk66TIRJFDjs.ga; exports.bigIntToBytesLE = ni; exports.buildTransaction = Oi; exports.bytesToBigIntLE = Et; exports.checkOrConvertArgument = Mt; exports.convertAmountFromHumanReadableToOnChain = _chunk66TIRJFDjs.ha; exports.convertAmountFromOnChainToHumanReadable = _chunk66TIRJFDjs.ia; exports.convertArgument = un; exports.convertCallArgument = Lb; exports.convertNumber = kr; exports.createObjectAddress = _chunk66TIRJFDjs._; exports.createResourceAddress = _chunk66TIRJFDjs.$; exports.createTokenAddress = _chunk66TIRJFDjs.aa; exports.deriveKey = Zr; exports.deriveTransactionType = hr; exports.deserializeFromScriptArgument = lu; exports.ensureBoolean = _chunk66TIRJFDjs.n; exports.fetchEntryFunctionAbi = xs; exports.fetchFunctionAbi = Ni; exports.fetchJWK = hi; exports.fetchModuleAbi = zi; exports.fetchMoveFunctionAbi = Hb; exports.fetchViewFunctionAbi = Is; exports.findFirstNonSignerArg = _s; exports.floorToWholeHour = _chunk66TIRJFDjs.ea; exports.generateRawTransaction = Fi; exports.generateSignedTransaction = Gi; exports.generateSignedTransactionForSimulation = vs; exports.generateSigningMessage = yt; exports.generateSigningMessageForSerializable = sA; exports.generateSigningMessageForTransaction = Ke; exports.generateTransactionPayload = Fr; exports.generateTransactionPayloadWithABI = ku; exports.generateUserTransactionHash = yw; exports.generateViewFunctionPayload = Cs; exports.generateViewFunctionPayloadWithABI = Du; exports.get = pr; exports.getAptosFullNode = V; exports.getAptosPepperService = eg; exports.getAuthenticatorForSimulation = pn; exports.getErrorMessage = _chunk66TIRJFDjs.ca; exports.getFunctionParts = _chunk66TIRJFDjs.la; exports.getIssAudAndUidVal = qe; exports.getKeylessConfig = Xt; exports.getKeylessJWKs = au; exports.getPageWithObfuscatedCursor = lr; exports.hashStrToField = ke; exports.hashValues = Ks; exports.hexToAsciiString = _chunk66TIRJFDjs.k; exports.isBcsAddress = zr; exports.isBcsBool = xi; exports.isBcsFixedBytes = vu; exports.isBcsString = Ii; exports.isBcsU128 = Ui; exports.isBcsU16 = vi; exports.isBcsU256 = ki; exports.isBcsU32 = Ki; exports.isBcsU64 = Ri; exports.isBcsU8 = Ci; exports.isBlockEpilogueTransactionResponse = _chunk66TIRJFDjs.L; exports.isBlockMetadataTransactionResponse = _chunk66TIRJFDjs.I; exports.isBool = ws; exports.isCanonicalEd25519Signature = bc; exports.isEd25519Signature = _chunk66TIRJFDjs.M; exports.isEmptyOption = Ss; exports.isEncodedEntryFunctionArgument = Es; exports.isEncodedStruct = _chunk66TIRJFDjs.ka; exports.isFeePayerSignature = _chunk66TIRJFDjs.P; exports.isGenesisTransactionResponse = _chunk66TIRJFDjs.H; exports.isKeylessSigner = br; exports.isLargeNumber = Dr; exports.isMultiAgentSignature = _chunk66TIRJFDjs.O; exports.isMultiEd25519Signature = _chunk66TIRJFDjs.Q; exports.isNumber = Cu; exports.isPendingTransactionResponse = _chunk66TIRJFDjs.F; exports.isScriptDataInput = Ps; exports.isSecp256k1Signature = _chunk66TIRJFDjs.N; exports.isSingleKeySigner = Ti; exports.isStateCheckpointTransactionResponse = _chunk66TIRJFDjs.J; exports.isString = it; exports.isUserTransactionResponse = _chunk66TIRJFDjs.G; exports.isValidBIP44Path = yo; exports.isValidFunctionInfo = _chunk66TIRJFDjs.ma; exports.isValidHardenedPath = fo; exports.isValidatorTransactionResponse = _chunk66TIRJFDjs.K; exports.mnemonicToSeed = ir; exports.normalizeBundle = Ko; exports.nowInSeconds = _chunk66TIRJFDjs.da; exports.objectStructTag = ge; exports.optionStructTag = Qy; exports.outOfRangeErrorMessage = _chunk66TIRJFDjs.o; exports.padAndPackBytesWithLen = wn; exports.paginateWithCursor = dr; exports.paginateWithObfuscatedCursor = ui; exports.pairedFaMetadataAddress = _chunk66TIRJFDjs.oa; exports.parseEncodedStruct = _chunk66TIRJFDjs.ja; exports.parseJwtHeader = uu; exports.parseTypeTag = Re; exports.poseidonHash = Pt; exports.post = Sn; exports.postAptosFaucet = ko; exports.postAptosFullNode = gt; exports.postAptosIndexer = Uo; exports.postAptosPepperService = Do; exports.postAptosProvingService = zo; exports.promiseFulfilledStatus = ec; exports.request = Wc; exports.sleep = _chunk66TIRJFDjs.ba; exports.splitPath = ho; exports.standardizeTypeTags = cn; exports.stringStructTag = _; exports.throwTypeMismatch = D; exports.truncateAddress = _chunk66TIRJFDjs.na; exports.validateNumberInRange = _chunk66TIRJFDjs.p; exports.verifyKeylessSignature = Ai; exports.verifyKeylessSignatureWithJwkAndConfig = gr;
500
+ will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await ze(async()=>{try{let d=(await ee({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(d.vec.length>0&&_chunkBNN2XWNRjs.la.call(void 0, d.vec[0]))return _chunkBNN2XWNRjs.ka.call(void 0, d.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunkBNN2XWNRjs._.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ct?a=_chunkBNN2XWNRjs._.A.toStringLong():a=_chunkBNN2XWNRjs.$.call(void 0, _chunkBNN2XWNRjs._.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=_chunkBNN2XWNRjs._.from(i);a=d.toStringLong(),d===_chunkBNN2XWNRjs._.A&&(s=Ct)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[d]=await ee({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(d,10)}let[c]=await ee({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),js({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),Js({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),Hi({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),Gr({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Br=class{constructor(e){if(_optionalChain([e, 'optionalAccess', _151 => _151.fullnode])||_optionalChain([e, 'optionalAccess', _152 => _152.indexer])||_optionalChain([e, 'optionalAccess', _153 => _153.faucet])||_optionalChain([e, 'optionalAccess', _154 => _154.pepper])||_optionalChain([e, 'optionalAccess', _155 => _155.prover])){if(_optionalChain([e, 'optionalAccess', _156 => _156.network])==="custom")console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!_optionalChain([e, 'optionalAccess', _157 => _157.network]))throw new Error("Custom endpoints require a network to be specified")}this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _158 => _158.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _159 => _159.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _160 => _160.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _161 => _161.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _162 => _162.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _163 => _163.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _164 => _164.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _165 => _165.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _166 => _166.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _167 => _167.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _168 => _168.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 Po[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Eo[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return _o[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return ni[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 ri[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return ni[this.network]===e}isProverServiceRequest(e){return ri[this.network]===e}};var ed={typeParameters:[{constraints:[]}],parameters:[new O,new J]};async function ta(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (Ct))],functionArguments:[r,i],abi:ed},options:s})}var Nn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ta({aptosConfig:this.config,...e})}};var _t={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Pe="0x4::token::Token";async function na(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:ps,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ra(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Si,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ia(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()},amount:{_gt:0}},o={query:Si,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _169 => _169.offset]),limit:_optionalChain([r, 'optionalAccess', _170 => _170.limit]),order_by:_optionalChain([r, 'optionalAccess', _171 => _171.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function oa(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}},o={query:ds,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _172 => _172.offset]),limit:_optionalChain([r, 'optionalAccess', _173 => _173.limit]),order_by:_optionalChain([r, 'optionalAccess', _174 => _174.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var td={typeParameters:[],parameters:[new h(x()),new J,new h(x()),new h(x()),new H,new H,new H,new H,new H,new H,new H,new H,new H,new J,new J]};async function sa(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new I(n.description),new Q(_nullishCoalesce(n.maxSupply, () => (_chunkBNN2XWNRjs.e))),new I(n.name),new I(n.uri),new N(_nullishCoalesce(n.mutableDescription, () => (!0))),new N(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new N(_nullishCoalesce(n.mutableURI, () => (!0))),new N(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new N(_nullishCoalesce(n.mutableTokenName, () => (!0))),new N(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new N(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new N(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new N(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:td},options:t})}async function un(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _175 => _175.where]);_optionalChain([t, 'optionalAccess', _176 => _176.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _177 => _177.tokenStandard]), () => ("v2"))});let i={query:ns,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _178 => _178.offset]),limit:_optionalChain([t, 'optionalAccess', _179 => _179.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function aa(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunkBNN2XWNRjs._.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _180 => _180.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _181 => _181.tokenStandard]), () => ("v2"))}),un({aptosConfig:e,options:{...i,where:s}})}async function ca(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _182 => _182.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _183 => _183.tokenStandard]), () => ("v2"))}),un({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _184 => _184.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _185 => _185.tokenStandard]), () => ("v2"))}),un({aptosConfig:e,options:{...r,where:o}})}async function da(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunkBNN2XWNRjs._.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _186 => _186.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _187 => _187.tokenStandard]), () => ("v2"))}),(await un({aptosConfig:i,options:{where:s}})).collection_id}var nd={typeParameters:[],parameters:[new h(x()),new h(x()),new h(x()),new h(x()),new v(new h(x())),new v(new h(x())),new v(v.u8())]};async function pa(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:l}=n,f=_optionalChain([d, 'optionalAccess', _188 => _188.map, 'call', _189 => _189(p=>_t[p])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new I(i),new I(o),new I(s),new I(a),_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(f, () => ([]))),Ea(_nullishCoalesce(l, () => ([])),_nullishCoalesce(f, () => ([])))],abi:nd},options:t})}var rd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new O]};async function la(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(r),_chunkBNN2XWNRjs._.from(i)],abi:rd},options:s})}var id={typeParameters:[],parameters:[new h(x()),new h(x()),new h(x()),new h(x()),new v(new h(x())),new v(new h(x())),new v(v.u8()),new O]};async function ga(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:l,options:f}=n;if(_optionalChain([c, 'optionalAccess', _190 => _190.length])!==_optionalChain([l, 'optionalAccess', _191 => _191.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _192 => _192.length])!==_optionalChain([l, 'optionalAccess', _193 => _193.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _194 => _194.map, 'call', _195 => _195(g=>_t[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(p, () => ([]))),Ea(_nullishCoalesce(l, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:id},options:f})}var od={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0)))]};async function ya(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(r)],abi:od},options:o})}var sd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0)))]};async function ma(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Pe))],functionArguments:[r],abi:sd},options:o})}var ad={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0)))]};async function fa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Pe))],functionArguments:[r],abi:ad},options:o})}var cd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x())]};async function Aa(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(i),new I(r)],abi:cd},options:s})}var ud={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x())]};async function ha(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(i),new I(r)],abi:ud},options:s})}var dd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x())]};async function ba(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(i),new I(r)],abi:dd},options:s})}var pd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x()),new h(x()),v.u8()]};async function Ta(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(s),new I(r),new I(_t[i]),_.U8(Li(o,_t[i]))],abi:pd},options:c})}var ld={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x())]};async function wa(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(i),new I(r)],abi:ld},options:s})}var gd={typeParameters:[{constraints:["key"]}],parameters:[new h(me(new G(0))),new h(x()),new h(x()),v.u8()]};async function Sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Pe))],functionArguments:[_chunkBNN2XWNRjs._.from(s),new I(r),new I(_t[i]),Li(o,_t[i])],abi:gd},options:c})}var yd={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(me(new G(0))),new h(x()),new G(1)]};async function _a(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Pe)),_t[i]],functionArguments:[_chunkBNN2XWNRjs._.from(s),new I(r),o],abi:yd},options:c})}var md={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(me(new G(0))),new h(x()),new G(1)]};async function Pa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Pe)),_t[i]],functionArguments:[_chunkBNN2XWNRjs._.from(s),new I(r),o],abi:md},options:c})}function Ea(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Li(n[i],r))}),t}function Li(n,e){let t=De(e);return Vt(n,t,0,[]).bcsToBytes()}var On=class{constructor(e){this.config=e}async getCollectionData(e){await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunkBNN2XWNRjs._.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _196 => _196.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _197 => _197.tokenStandard]), () => ("v2"))}),un({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),aa({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ca({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),da({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),na({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ra({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ia({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oa({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sa({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return pa({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return la({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return ga({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ya({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ma({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return fa({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Aa({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ha({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ba({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Ta({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Sa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return _a({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Pa({aptosConfig:this.config,...e})}};var xa=300,fd=n=>{if(n&&n.length>xa)throw new Error(`Event type length exceeds the maximum length of ${xa}`)};async function Ia(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return zn({aptosConfig:e,options:{...r,where:i}})}async function va(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunkBNN2XWNRjs._.from(e).toStringLong()},creation_number:{_eq:r}};return zn({aptosConfig:t,options:{...i,where:s}})}async function Ca(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunkBNN2XWNRjs._.from(e).toStringLong()},indexed_type:{_eq:r}};return zn({aptosConfig:t,options:{...i,where:s}})}async function zn(n){let{aptosConfig:e,options:t}=n;fd(_optionalChain([t, 'optionalAccess', _198 => _198.where, 'optionalAccess', _199 => _199.indexed_type, 'optionalAccess', _200 => _200._eq]));let r={query:os,variables:{where_condition:_optionalChain([t, 'optionalAccess', _201 => _201.where]),offset:_optionalChain([t, 'optionalAccess', _202 => _202.offset]),limit:_optionalChain([t, 'optionalAccess', _203 => _203.limit]),order_by:_optionalChain([t, 'optionalAccess', _204 => _204.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Gn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ia({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),va({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ca({aptosConfig:this.config,...e})}async getEvents(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _205 => _205.minimumLedgerVersion]),processorType:"events_processor"}),zn({aptosConfig:this.config,...e})}};async function Ka(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _206 => _206.timeoutSecs])||20,{data:s}=await Fo({aptosConfig:e,path:"fund",body:{address:_chunkBNN2XWNRjs._.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await wt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _207 => _207.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Bn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ka({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _208 => _208.options, 'optionalAccess', _209 => _209.waitForIndexer])===void 0||_optionalChain([e, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.waitForIndexer]))&&await Cr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Mr(n){let{aptosConfig:e,options:t}=n,r={query:as,variables:{where_condition:_optionalChain([t, 'optionalAccess', _212 => _212.where]),limit:_optionalChain([t, 'optionalAccess', _213 => _213.limit]),offset:_optionalChain([t, 'optionalAccess', _214 => _214.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Ra(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _215 => _215.where]),limit:_optionalChain([t, 'optionalAccess', _216 => _216.limit]),offset:_optionalChain([t, 'optionalAccess', _217 => _217.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:rs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _218 => _218.where]),limit:_optionalChain([t, 'optionalAccess', _219 => _219.limit]),offset:_optionalChain([t, 'optionalAccess', _220 => _220.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ka={typeParameters:[{constraints:[]}],parameters:[De("0x1::object::Object"),new O,new J]};async function Fa(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ka},options:s})}async function Da(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:ka},options:s})}var Mn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _221 => _221.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Mr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _222 => _222.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Mr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _223 => _223.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Mr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunkBNN2XWNRjs._.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _224 => _224.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _225 => _225.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ua({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Fa({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Da({aptosConfig:this.config,...e})}};var Vn=class{constructor(e){this.config=e}async getLedgerInfo(){return Sr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return bs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Ts({aptosConfig:this.config,...e})}async view(e){return ee({aptosConfig:this.config,...e})}async viewJson(e){return zs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ls({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return _r({aptosConfig:this.config})}async getProcessorStatus(e){return Pr({aptosConfig:this.config,processorType:e})}};var Na=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Oa(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Pt(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(!Oa(e))throw new Error(`${e} is not valid. ${Na}`);if(t&&!Oa(t))throw new Error(`${t} is not valid. ${Na}`);return{domainName:t||e,subdomainName:t?e:void 0}}function za(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Ad="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",hd={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ad,custom:null,devnet:null};function ut(n){let e=hd[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Vr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ga(n){let{aptosConfig:e,name:t}=n,r=ut(e),{domainName:i,subdomainName:o}=Pt(t),s=await ee({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Vr(s[0]);return a?_chunkBNN2XWNRjs._.from(a):void 0}async function Ba(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=ut(e),{domainName:l,subdomainName:f}=Pt(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(f&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!f)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let W=_nullishCoalesce(t.years, () => (1));if(W!==1)throw new Error("For now, names can only be registered for 1 year at a time");let dt=W*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[l,dt,o,s]},options:a})}if(!f)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await qi({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[l,f,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function qi(n){let{aptosConfig:e,name:t}=n,r=ut(e),{domainName:i,subdomainName:o}=Pt(t);try{let s=await ee({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Ma(n){let{aptosConfig:e,address:t}=n,r=ut(e),i=await ee({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunkBNN2XWNRjs._.from(t).toString()]}}),o=Vr(i[1]),s=Vr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Va(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=ut(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Pt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ha(n){let{aptosConfig:e,name:t}=n,r=ut(e),{domainName:i,subdomainName:o}=Pt(t),s=await ee({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Vr(s[0]);return a?_chunkBNN2XWNRjs._.from(a):void 0}async function La(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=ut(e),{domainName:a,subdomainName:c}=Pt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function qa(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=Pt(t),a=(await w({aptosConfig:e,query:{query:sn,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Hn(a)),za(a)?a:void 0}async function $a(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:sn,variables:{limit:_optionalChain([t, 'optionalAccess', _226 => _226.limit]),offset:_optionalChain([t, 'optionalAccess', _227 => _227.offset]),order_by:_optionalChain([t, 'optionalAccess', _228 => _228.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _229 => _229.options, 'optionalAccess', _230 => _230.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Hn)}async function Wa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:sn,variables:{limit:_optionalChain([t, 'optionalAccess', _231 => _231.limit]),offset:_optionalChain([t, 'optionalAccess', _232 => _232.offset]),order_by:_optionalChain([t, 'optionalAccess', _233 => _233.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _234 => _234.options, 'optionalAccess', _235 => _235.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Hn)}async function Qa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:sn,variables:{limit:_optionalChain([t, 'optionalAccess', _236 => _236.limit]),offset:_optionalChain([t, 'optionalAccess', _237 => _237.offset]),order_by:_optionalChain([t, 'optionalAccess', _238 => _238.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _239 => _239.options, 'optionalAccess', _240 => _240.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Hn)}async function ja(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:sn,variables:{limit:_optionalChain([t, 'optionalAccess', _241 => _241.limit]),offset:_optionalChain([t, 'optionalAccess', _242 => _242.offset]),order_by:_optionalChain([t, 'optionalAccess', _243 => _243.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _244 => _244.options, 'optionalAccess', _245 => _245.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Hn).filter(za)}async function $i(n){let{aptosConfig:e}=n,t=ut(e),[r]=await ee({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Ja(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=ut(e),a=i*31536e3,{domainName:c,subdomainName:d}=Pt(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Hn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var Ln=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ga({aptosConfig:this.config,...e})}async getExpiration(e){return qi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ha({aptosConfig:this.config,...e})}async setTargetAddress(e){return La({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ma({aptosConfig:this.config,...e})}async setPrimaryName(e){return Va({aptosConfig:this.config,...e})}async registerName(e){return Ba({aptosConfig:this.config,...e})}async renewDomain(e){return Ja({aptosConfig:this.config,...e})}async getName(e){return qa({aptosConfig:this.config,...e})}async getAccountNames(e){return $a({aptosConfig:this.config,...e})}async getAccountDomains(e){return Wa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Qa({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return ja({aptosConfig:this.config,...e})}};async function Xa(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunkBNN2XWNRjs._.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ti,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 Ya(n){let{aptosConfig:e,options:t}=n,r={query:Ti,variables:{order_by:_optionalChain([t, 'optionalAccess', _246 => _246.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:is,variables:{delegatorAddress:_chunkBNN2XWNRjs._.from(t).toStringLong(),poolAddress:_chunkBNN2XWNRjs._.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var qn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _247 => _247.minimumLedgerVersion]),processorType:"stake_processor"}),Xa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _248 => _248.minimumLedgerVersion]),processorType:"stake_processor"}),Ya({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _249 => _249.minimumLedgerVersion]),processorType:"stake_processor"}),Za({aptosConfig:this.config,...e})}};var Hr=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function Wi(n,e,t){let r=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},t}function Qi(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var dn=class{constructor(e){this.config=e}async simple(e){return zi({aptosConfig:this.config,...e})}async multiAgent(e){return zi({aptosConfig:this.config,...e})}};_chunkBNN2XWNRjs.a.call(void 0, [Qi],dn.prototype,"simple",1),_chunkBNN2XWNRjs.a.call(void 0, [Qi],dn.prototype,"multiAgent",1);var pn=class{constructor(e){this.config=e}async simple(e){return kn({aptosConfig:this.config,...e})}async multiAgent(e){return kn({aptosConfig:this.config,...e})}};_chunkBNN2XWNRjs.a.call(void 0, [Wi],pn.prototype,"simple",1),_chunkBNN2XWNRjs.a.call(void 0, [Wi],pn.prototype,"multiAgent",1);var Lr=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkBNN2XWNRjs.ca.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkBNN2XWNRjs.ea.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkBNN2XWNRjs.ca.call(void 0, this.sleepTime),_chunkBNN2XWNRjs.ea.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await cn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await cn({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 _chunkBNN2XWNRjs.ca.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkBNN2XWNRjs.ea.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkBNN2XWNRjs.ea.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkBNN2XWNRjs.ca.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var ln=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _250 => _250.pendingDequeue, 'access', _251 => _251.shift, 'call', _252 => _252(), 'optionalAccess', _253 => _253.resolve, 'call', _254 => _254(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 gn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},gn=class extends Error{};var ec="fulfilled",tc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(tc||{}),qr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new ln;this.transactionsQueue=new ln;this.outstandingTransactions=new ln;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Lr(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=St({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof gn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===ec?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof gn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(wt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===ec?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var $r=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new qr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var $n=class{constructor(e){this.config=e,this.build=new Hr(this.config),this.simulate=new dn(this.config),this.submit=new pn(this.config),this.batch=new $r(this.config)}async getTransactions(e){return Pi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return As({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Rn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return hs({aptosConfig:this.config,...e})}async waitForTransaction(e){return wt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return vr({aptosConfig:this.config})}getSigningMessage(e){return Ds(e)}async publishPackageTransaction(e){return Os({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Xs({aptosConfig:this.config,...e})}sign(e){return Nr({...e})}signAsFeePayer(e){return Or({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return St({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Ns({aptosConfig:this.config,...e})}};var Wn=class{constructor(e){this.config=e}async getTableItem(e){return xr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ms({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),fs({aptosConfig:this.config,...e})}};async function Wr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunkBNN2XWNRjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Do({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunkBNN2XWNRjs.j.fromHexInput(a.pepper).toUint8Array()}async function ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Wr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunkBNN2XWNRjs.j.fromHexInput(i).toUint8Array().length!==_e.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${_e.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunkBNN2XWNRjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunkBNN2XWNRjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await No({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,f=new ht({a:l.a,b:l.b,c:l.c});return new de({proof:new Jt(f,0),trainingWheelsSignature:Ne.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function nc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Wr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),d=ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let g=Z.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await Fn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Fe.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let f=k.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await Fn({aptosConfig:e,authenticationKey:f.authKey().derivedAddress()});return _e.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function rc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(Ko.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,P.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,_.MoveString(a.keys.map(c=>c.kid)),_.MoveString(a.keys.map(c=>c.alg)),_.MoveString(a.keys.map(c=>c.e)),_.MoveString(a.keys.map(c=>c.n))]},options:i})}var Qn=class{constructor(e){this.config=e}async getPepper(e){return Wr({aptosConfig:this.config,...e})}async getProof(e){return ji({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return nc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return rc({aptosConfig:this.config,...e})}};async function Sd(n){let{aptosConfig:e,options:t}=n,r={query:wr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _255 => _255.where]),offset:_optionalChain([t, 'optionalAccess', _256 => _256.offset]),limit:_optionalChain([t, 'optionalAccess', _257 => _257.limit]),order_by:_optionalChain([t, 'optionalAccess', _258 => _258.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function ic(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunkBNN2XWNRjs._.from(t).toStringLong()}};return(await Sd({aptosConfig:e,options:{...r,where:o}}))[0]}var jn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ic({aptosConfig:this.config,...e})}};var te=class{constructor(e){this.config=new Br(e),this.account=new Dn(this.config),this.abstraction=new Ht(this.config),this.ans=new Ln(this.config),this.coin=new Nn(this.config),this.digitalAsset=new On(this.config),this.event=new Gn(this.config),this.faucet=new Bn(this.config),this.fungibleAsset=new Mn(this.config),this.general=new Vn(this.config),this.staking=new qn(this.config),this.transaction=new $n(this.config),this.table=new Wn(this.config),this.keyless=new Qn(this.config),this.object=new jn(this.config)}};function ue(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}ue(te,Dn,"account");ue(te,Ht,"abstraction");ue(te,Ln,"ans");ue(te,Nn,"coin");ue(te,On,"digitalAsset");ue(te,Gn,"event");ue(te,Bn,"faucet");ue(te,Mn,"fungibleAsset");ue(te,Vn,"general");ue(te,qn,"staking");ue(te,$n,"transaction");ue(te,Wn,"table");ue(te,Qn,"keyless");ue(te,jn,"object");exports.APTOS_BIP44_REGEX = Ac; exports.APTOS_COIN = Ct; exports.APTOS_FA = vo; exports.APTOS_HARDENED_REGEX = fc; exports.AbstractKeylessAccount = fe; exports.AbstractMultiKey = Re; exports.AbstractPublicKey = er; exports.AbstractSignature = fn; exports.AbstractedAccount = br; exports.Account = st; exports.AccountAddress = _chunkBNN2XWNRjs._; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = Ut; exports.AccountAuthenticatorEd25519 = Ue; exports.AccountAuthenticatorMultiEd25519 = Ze; exports.AccountAuthenticatorMultiKey = He; exports.AccountAuthenticatorNoAccountAuthenticator = Zt; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = _chunkBNN2XWNRjs.w; exports.AccountPublicKey = oe; exports.AccountSequenceNumber = Lr; exports.AccountUtils = Ho; exports.AddressInvalidReason = _chunkBNN2XWNRjs.Z; exports.AnyPublicKey = U; exports.AnyPublicKeyVariant = _chunkBNN2XWNRjs.y; exports.AnySignature = V; exports.AnySignatureVariant = _chunkBNN2XWNRjs.A; exports.Aptos = te; exports.AptosApiError = Te; exports.AptosApiType = Qt; exports.AptosConfig = Br; exports.AuthenticationKey = L; exports.Bool = N; exports.CKDPriv = ho; exports.ChainId = en; exports.DEFAULT_MAX_GAS_AMOUNT = xo; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Io; exports.DEFAULT_TXN_TIMEOUT_SEC = ir; exports.DerivableAbstractedAccount = qo; exports.DeriveScheme = _chunkBNN2XWNRjs.Y; exports.Deserializer = K; exports.EPK_HORIZON_SECS = Xc; exports.Ed25519Account = re; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = E; exports.Ed25519Signature = R; exports.EntryFunction = Dt; exports.EntryFunctionBytes = Zn; exports.EphemeralCertificate = jt; exports.EphemeralCertificateVariant = _chunkBNN2XWNRjs.D; exports.EphemeralKeyPair = Mt; exports.EphemeralPublicKey = ft; exports.EphemeralPublicKeyVariant = _chunkBNN2XWNRjs.B; exports.EphemeralSignature = Ne; exports.EphemeralSignatureVariant = _chunkBNN2XWNRjs.C; exports.FIREBASE_AUTH_ISS_PATTERN = Ko; exports.FederatedKeylessAccount = Fe; exports.FederatedKeylessPublicKey = Z; exports.FeePayerRawTransaction = Ot; exports.FixedBytes = Ee; exports.Groth16ProofAndStatement = li; exports.Groth16VerificationKey = yi; exports.Groth16Zkp = ht; exports.HARDENED_OFFSET = mo; exports.Hex = _chunkBNN2XWNRjs.j; exports.HexInvalidReason = _chunkBNN2XWNRjs.i; exports.Identifier = F; exports.KeyType = hc; exports.KeylessAccount = _e; exports.KeylessConfiguration = gi; exports.KeylessError = P; exports.KeylessErrorCategory = Hc; exports.KeylessErrorResolutionTip = Lc; exports.KeylessErrorType = or; exports.KeylessPublicKey = k; exports.KeylessSignature = we; exports.MAX_AUD_VAL_BYTES = di; exports.MAX_COMMITED_EPK_BYTES = ru; exports.MAX_EXTRA_FIELD_BYTES = tu; exports.MAX_ISS_VAL_BYTES = eu; exports.MAX_JWT_HEADER_B64_BYTES = nu; exports.MAX_UID_KEY_BYTES = Yc; exports.MAX_UID_VAL_BYTES = Zc; exports.MimeType = _chunkBNN2XWNRjs.q; exports.ModuleId = _n; exports.MoveAbility = _chunkBNN2XWNRjs.U; exports.MoveFunctionVisibility = _chunkBNN2XWNRjs.T; exports.MoveJWK = mi; exports.MoveOption = Y; exports.MoveString = I; exports.MoveVector = _; exports.MultiAgentRawTransaction = Nt; exports.MultiAgentTransaction = mr; exports.MultiEd25519Account = on; exports.MultiEd25519PublicKey = Ve; exports.MultiEd25519Signature = Ye; exports.MultiKey = se; exports.MultiKeyAccount = at; exports.MultiKeySignature = Me; exports.MultiSig = vn; exports.MultiSigTransactionPayload = Cn; exports.Network = ii; exports.NetworkToChainId = oi; exports.NetworkToFaucetAPI = Eo; exports.NetworkToIndexerAPI = _o; exports.NetworkToNetworkName = Nl; exports.NetworkToNodeAPI = Po; exports.NetworkToPepperAPI = ni; exports.NetworkToProverAPI = ri; exports.ParsingError = _chunkBNN2XWNRjs.h; exports.PrivateKey = yt; exports.PrivateKeyVariants = _chunkBNN2XWNRjs.x; exports.ProcessorType = We; exports.PublicKey = xt; exports.RAW_TRANSACTION_SALT = Co; exports.RAW_TRANSACTION_WITH_DATA_SALT = si; exports.RawTransaction = Se; exports.RawTransactionWithData = lr; exports.RoleType = _chunkBNN2XWNRjs.V; exports.RotationProofChallenge = gr; exports.Script = In; exports.ScriptTransactionArgumentVariants = _chunkBNN2XWNRjs.s; exports.Secp256k1PrivateKey = Xe; exports.Secp256k1PublicKey = Je; exports.Secp256k1Signature = Rt; exports.Serializable = _chunkBNN2XWNRjs.l; exports.Serialized = mn; exports.Serializer = _chunkBNN2XWNRjs.m; exports.Signature = B; exports.SignedTransaction = ot; exports.SigningScheme = _chunkBNN2XWNRjs.W; exports.SigningSchemeInput = _chunkBNN2XWNRjs.X; exports.SimpleTransaction = yr; exports.SingleKeyAccount = ce; exports.StructTag = Le; exports.TransactionAndProof = Ar; exports.TransactionAuthenticator = it; exports.TransactionAuthenticatorEd25519 = zt; exports.TransactionAuthenticatorFeePayer = Bt; exports.TransactionAuthenticatorMultiAgent = Gt; exports.TransactionAuthenticatorMultiEd25519 = tn; exports.TransactionAuthenticatorSingleSender = Tt; exports.TransactionAuthenticatorVariant = _chunkBNN2XWNRjs.v; exports.TransactionPayload = Ft; exports.TransactionPayloadEntryFunction = En; exports.TransactionPayloadMultiSig = xn; exports.TransactionPayloadScript = Pn; exports.TransactionPayloadVariants = _chunkBNN2XWNRjs.t; exports.TransactionResponseType = _chunkBNN2XWNRjs.F; exports.TransactionVariants = _chunkBNN2XWNRjs.u; exports.TransactionWorker = qr; exports.TransactionWorkerEventsEnum = tc; exports.TypeTag = z; exports.TypeTagAddress = O; exports.TypeTagBool = H; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = Iu; exports.TypeTagReference = pr; exports.TypeTagSigner = kt; exports.TypeTagStruct = h; exports.TypeTagU128 = nt; exports.TypeTagU16 = et; exports.TypeTagU256 = rt; exports.TypeTagU32 = tt; exports.TypeTagU64 = J; exports.TypeTagU8 = ye; exports.TypeTagVariants = _chunkBNN2XWNRjs.r; exports.TypeTagVector = v; exports.U128 = ve; exports.U16 = xe; exports.U256 = he; exports.U32 = Ie; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = de; exports.ZkProof = Jt; exports.ZkpVariant = _chunkBNN2XWNRjs.E; exports.anyPublicKeyVariantToString = _chunkBNN2XWNRjs.z; exports.aptosCoinStructTag = rf; exports.aptosRequest = sr; exports.base64UrlDecode = _chunkBNN2XWNRjs.ga; exports.base64UrlToBytes = _chunkBNN2XWNRjs.ha; exports.bigIntToBytesLE = ti; exports.buildTransaction = Ni; exports.bytesToBigIntLE = It; exports.checkOrConvertArgument = Vt; exports.convertAmountFromHumanReadableToOnChain = _chunkBNN2XWNRjs.ia; exports.convertAmountFromOnChainToHumanReadable = _chunkBNN2XWNRjs.ja; exports.convertArgument = Di; exports.convertNumber = Kr; exports.createObjectAddress = _chunkBNN2XWNRjs.$; exports.createResourceAddress = _chunkBNN2XWNRjs.aa; exports.createTokenAddress = _chunkBNN2XWNRjs.ba; exports.deriveKey = Yr; exports.deriveTransactionType = fr; exports.deserializeFromScriptArgument = lu; exports.ensureBoolean = _chunkBNN2XWNRjs.n; exports.fetchEntryFunctionAbi = Cs; exports.fetchFunctionAbi = Fi; exports.fetchJWK = Ai; exports.fetchModuleAbi = Ru; exports.fetchMoveFunctionAbi = JT; exports.fetchViewFunctionAbi = Ks; exports.findFirstNonSignerArg = vs; exports.floorToWholeHour = _chunkBNN2XWNRjs.fa; exports.generateRawTransaction = Ou; exports.generateSignedTransaction = Oi; exports.generateSignedTransactionForSimulation = Us; exports.generateSigningMessage = bt; exports.generateSigningMessageForSerializable = fA; exports.generateSigningMessageForTransaction = ke; exports.generateTransactionPayload = Dr; exports.generateTransactionPayloadWithABI = Fu; exports.generateUserTransactionHash = ww; exports.generateViewFunctionPayload = Rs; exports.generateViewFunctionPayloadWithABI = Du; exports.get = ar; exports.getAptosFullNode = M; exports.getAptosPepperService = ug; exports.getAuthenticatorForSimulation = an; exports.getErrorMessage = _chunkBNN2XWNRjs.da; exports.getFunctionParts = _chunkBNN2XWNRjs.ma; exports.getIssAudAndUidVal = je; exports.getKeylessConfig = Xt; exports.getKeylessJWKs = au; exports.getPageWithObfuscatedCursor = ur; exports.hashStrToField = Oe; exports.hashValues = ks; exports.hexToAsciiString = _chunkBNN2XWNRjs.k; exports.isBcsAddress = Ur; exports.isBcsBool = Ei; exports.isBcsFixedBytes = Cu; exports.isBcsString = xi; exports.isBcsU128 = Ri; exports.isBcsU16 = vi; exports.isBcsU256 = Ui; exports.isBcsU32 = Ci; exports.isBcsU64 = Ki; exports.isBcsU8 = Ii; exports.isBlockEpilogueTransactionResponse = _chunkBNN2XWNRjs.M; exports.isBlockMetadataTransactionResponse = _chunkBNN2XWNRjs.J; exports.isBool = Ps; exports.isCanonicalEd25519Signature = Tc; exports.isEd25519Signature = _chunkBNN2XWNRjs.N; exports.isEmptyOption = Es; exports.isEncodedEntryFunctionArgument = xs; exports.isEncodedStruct = _chunkBNN2XWNRjs.la; exports.isFeePayerSignature = _chunkBNN2XWNRjs.Q; exports.isGenesisTransactionResponse = _chunkBNN2XWNRjs.I; exports.isKeylessSigner = hr; exports.isLargeNumber = Rr; exports.isMultiAgentSignature = _chunkBNN2XWNRjs.P; exports.isMultiEd25519Signature = _chunkBNN2XWNRjs.R; exports.isNumber = vu; exports.isPendingTransactionResponse = _chunkBNN2XWNRjs.G; exports.isScriptDataInput = Is; exports.isSecp256k1Signature = _chunkBNN2XWNRjs.O; exports.isSingleKeySigner = hi; exports.isSingleSenderSignature = _chunkBNN2XWNRjs.S; exports.isStateCheckpointTransactionResponse = _chunkBNN2XWNRjs.K; exports.isString = ct; exports.isUserTransactionResponse = _chunkBNN2XWNRjs.H; exports.isValidBIP44Path = fo; exports.isValidFunctionInfo = _chunkBNN2XWNRjs.na; exports.isValidHardenedPath = Ao; exports.isValidatorTransactionResponse = _chunkBNN2XWNRjs.L; exports.mnemonicToSeed = tr; exports.normalizeBundle = Ro; exports.nowInSeconds = _chunkBNN2XWNRjs.ea; exports.objectStructTag = me; exports.optionStructTag = of; exports.outOfRangeErrorMessage = _chunkBNN2XWNRjs.o; exports.padAndPackBytesWithLen = hn; exports.paginateWithCursor = cr; exports.paginateWithObfuscatedCursor = ci; exports.pairedFaMetadataAddress = _chunkBNN2XWNRjs.pa; exports.parseEncodedStruct = _chunkBNN2XWNRjs.ka; exports.parseJwtHeader = uu; exports.parseTypeTag = De; exports.poseidonHash = vt; exports.post = bn; exports.postAptosFaucet = Fo; exports.postAptosFullNode = At; exports.postAptosIndexer = ko; exports.postAptosPepperService = Do; exports.postAptosProvingService = No; exports.promiseFulfilledStatus = ec; exports.request = Wc; exports.sleep = _chunkBNN2XWNRjs.ca; exports.splitPath = bo; exports.standardizeTypeTags = kr; exports.stringStructTag = x; exports.throwTypeMismatch = D; exports.truncateAddress = _chunkBNN2XWNRjs.oa; exports.validateNumberInRange = _chunkBNN2XWNRjs.p; exports.verifyKeylessSignature = fi; exports.verifyKeylessSignatureWithJwkAndConfig = dr;
480
501
  //# sourceMappingURL=index.js.map