@aptos-labs/ts-sdk 6.0.0 → 6.2.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 (467) hide show
  1. package/README.md +9 -13
  2. package/dist/common/{account-Dpz_N9h-.d.ts → account-DGpxrkAn.d.ts} +187 -20
  3. package/dist/common/chunk-2VR6ONNW.js +4 -0
  4. package/dist/common/chunk-2VR6ONNW.js.map +1 -0
  5. package/dist/common/cli/index.d.ts +2 -2
  6. package/dist/common/cli/index.js +1 -1
  7. package/dist/common/cli/index.js.map +1 -1
  8. package/dist/common/index.d.ts +69 -6
  9. package/dist/common/index.js +34 -45
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/{Ed25519Account-BW_kXHC2.d.mts → Ed25519Account-BCt2cu_M.d.mts} +2 -2
  12. package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
  13. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  14. package/dist/esm/account/AbstractedAccount.d.mts +2 -2
  15. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/Account.d.mts +2 -2
  17. package/dist/esm/account/Account.mjs +1 -1
  18. package/dist/esm/account/AccountUtils.d.mts +3 -3
  19. package/dist/esm/account/AccountUtils.mjs +1 -1
  20. package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
  21. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  22. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  23. package/dist/esm/account/Ed25519Account.mjs +1 -1
  24. package/dist/esm/account/EphemeralKeyPair.d.mts +26 -2
  25. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  26. package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
  27. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  28. package/dist/esm/account/KeylessAccount.d.mts +3 -3
  29. package/dist/esm/account/KeylessAccount.mjs +1 -1
  30. package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
  31. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  32. package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
  33. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  34. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  35. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  36. package/dist/esm/account/index.d.mts +3 -3
  37. package/dist/esm/account/index.mjs +1 -1
  38. package/dist/esm/account/utils.d.mts +1 -1
  39. package/dist/esm/account/utils.mjs +1 -1
  40. package/dist/esm/{account-CcxnCdYZ.d.mts → account-Dg0ejXHy.d.mts} +172 -8
  41. package/dist/esm/api/account/abstraction.d.mts +1 -1
  42. package/dist/esm/api/account/abstraction.mjs +1 -1
  43. package/dist/esm/api/account.d.mts +2 -2
  44. package/dist/esm/api/account.mjs +1 -1
  45. package/dist/esm/api/ans.d.mts +1 -1
  46. package/dist/esm/api/ans.mjs +1 -1
  47. package/dist/esm/api/aptos.d.mts +3 -3
  48. package/dist/esm/api/aptos.mjs +1 -1
  49. package/dist/esm/api/aptosConfig.d.mts +1 -1
  50. package/dist/esm/api/aptosConfig.mjs +1 -1
  51. package/dist/esm/api/coin.d.mts +1 -1
  52. package/dist/esm/api/coin.mjs +1 -1
  53. package/dist/esm/api/digitalAsset.d.mts +2 -2
  54. package/dist/esm/api/digitalAsset.mjs +1 -1
  55. package/dist/esm/api/faucet.d.mts +1 -1
  56. package/dist/esm/api/faucet.mjs +1 -1
  57. package/dist/esm/api/fungibleAsset.d.mts +2 -2
  58. package/dist/esm/api/fungibleAsset.mjs +1 -1
  59. package/dist/esm/api/general.d.mts +1 -1
  60. package/dist/esm/api/general.mjs +1 -1
  61. package/dist/esm/api/index.d.mts +3 -3
  62. package/dist/esm/api/index.mjs +1 -1
  63. package/dist/esm/api/keyless.d.mts +3 -3
  64. package/dist/esm/api/keyless.mjs +1 -1
  65. package/dist/esm/api/object.d.mts +1 -1
  66. package/dist/esm/api/object.mjs +1 -1
  67. package/dist/esm/api/staking.d.mts +1 -1
  68. package/dist/esm/api/staking.mjs +1 -1
  69. package/dist/esm/api/table.d.mts +1 -1
  70. package/dist/esm/api/table.mjs +1 -1
  71. package/dist/esm/api/transaction.d.mts +2 -2
  72. package/dist/esm/api/transaction.mjs +1 -1
  73. package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
  74. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  75. package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
  76. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  77. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  78. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  79. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  80. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  81. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  82. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
  83. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  84. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  85. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  86. package/dist/esm/api/utils.d.mts +1 -1
  87. package/dist/esm/api/utils.mjs +1 -1
  88. package/dist/esm/bcs/consts.d.mts +1 -1
  89. package/dist/esm/bcs/deserializer.d.mts +1 -1
  90. package/dist/esm/bcs/deserializer.mjs +1 -1
  91. package/dist/esm/bcs/index.d.mts +1 -1
  92. package/dist/esm/bcs/index.mjs +1 -1
  93. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
  94. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  95. package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
  96. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  97. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
  98. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  99. package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
  100. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  101. package/dist/esm/bcs/serializer.d.mts +1 -1
  102. package/dist/esm/bcs/serializer.mjs +1 -1
  103. package/dist/esm/{chunk-5FNZUL2Y.mjs → chunk-2VBY2V4Z.mjs} +2 -2
  104. package/dist/esm/chunk-2VHA77EO.mjs +2 -0
  105. package/dist/esm/chunk-2VHA77EO.mjs.map +1 -0
  106. package/dist/esm/{chunk-35DKMW7Q.mjs → chunk-44MMFX5F.mjs} +1 -1
  107. package/dist/esm/chunk-44MMFX5F.mjs.map +1 -0
  108. package/dist/esm/chunk-5HHC2YG4.mjs +2 -0
  109. package/dist/esm/chunk-5LMLIRGK.mjs +2 -0
  110. package/dist/esm/chunk-5LMLIRGK.mjs.map +1 -0
  111. package/dist/esm/chunk-66F7RP7K.mjs +2 -0
  112. package/dist/esm/chunk-66F7RP7K.mjs.map +1 -0
  113. package/dist/esm/chunk-6CD6PDFJ.mjs +4 -0
  114. package/dist/esm/chunk-6CD6PDFJ.mjs.map +1 -0
  115. package/dist/esm/{chunk-FW6UHAQV.mjs → chunk-A7SQEK23.mjs} +2 -2
  116. package/dist/esm/chunk-A7SQEK23.mjs.map +1 -0
  117. package/dist/esm/{chunk-G3HAIETV.mjs → chunk-ASFFADWS.mjs} +2 -2
  118. package/dist/esm/chunk-ASFFADWS.mjs.map +1 -0
  119. package/dist/esm/chunk-AUGTNOKZ.mjs +2 -0
  120. package/dist/esm/{chunk-RQN6LA7E.mjs.map → chunk-AUGTNOKZ.mjs.map} +1 -1
  121. package/dist/esm/chunk-BT742BFQ.mjs +2 -0
  122. package/dist/esm/chunk-BT742BFQ.mjs.map +1 -0
  123. package/dist/esm/chunk-C2KVLMPH.mjs +2 -0
  124. package/dist/esm/chunk-C2KVLMPH.mjs.map +1 -0
  125. package/dist/esm/{chunk-DIFSO4N6.mjs → chunk-CD3EZCI5.mjs} +2 -2
  126. package/dist/esm/{chunk-43LWUUXS.mjs → chunk-E3DHFXN4.mjs} +2 -2
  127. package/dist/esm/{chunk-QDJDZ3ON.mjs → chunk-EIWPAECI.mjs} +2 -2
  128. package/dist/esm/{chunk-GOXRBEIJ.mjs → chunk-F45HI7LU.mjs} +1 -1
  129. package/dist/esm/chunk-F45HI7LU.mjs.map +1 -0
  130. package/dist/esm/chunk-F4LHBGG2.mjs +2 -0
  131. package/dist/esm/chunk-F4LHBGG2.mjs.map +1 -0
  132. package/dist/esm/{chunk-MEG27LEV.mjs → chunk-FDHHQUS3.mjs} +3 -3
  133. package/dist/esm/chunk-FDHHQUS3.mjs.map +1 -0
  134. package/dist/esm/{chunk-LS2HRAVW.mjs → chunk-G5OONGWS.mjs} +1 -12
  135. package/dist/esm/chunk-G5OONGWS.mjs.map +1 -0
  136. package/dist/esm/{chunk-F3NI6N7R.mjs → chunk-H2T2SU5O.mjs} +2 -2
  137. package/dist/esm/chunk-H2T2SU5O.mjs.map +1 -0
  138. package/dist/esm/chunk-ITZN23GU.mjs +2 -0
  139. package/dist/esm/{chunk-X674XJNJ.mjs → chunk-KOVWYU53.mjs} +2 -2
  140. package/dist/esm/{chunk-PXJEKGEG.mjs → chunk-LDK76MDN.mjs} +2 -2
  141. package/dist/esm/chunk-M65PXVDO.mjs +2 -0
  142. package/dist/esm/chunk-M65PXVDO.mjs.map +1 -0
  143. package/dist/esm/{chunk-WZ6FL7CH.mjs → chunk-NWP2VEMB.mjs} +2 -2
  144. package/dist/esm/chunk-ODNZJSOC.mjs +2 -0
  145. package/dist/esm/chunk-ODNZJSOC.mjs.map +1 -0
  146. package/dist/esm/{chunk-6IWGTO2J.mjs → chunk-POQ4FT4E.mjs} +2 -2
  147. package/dist/esm/{chunk-76SVQZDX.mjs → chunk-Q4KYBAYN.mjs} +2 -2
  148. package/dist/esm/chunk-Q5ESW36C.mjs +2 -0
  149. package/dist/esm/chunk-Q5ESW36C.mjs.map +1 -0
  150. package/dist/esm/{chunk-52PWWLJJ.mjs → chunk-QRW7MQDA.mjs} +2 -2
  151. package/dist/esm/chunk-QRW7MQDA.mjs.map +1 -0
  152. package/dist/esm/{chunk-3P474TWM.mjs → chunk-R7PCBRRT.mjs} +2 -2
  153. package/dist/esm/chunk-T32P4APJ.mjs +2 -0
  154. package/dist/esm/chunk-T32P4APJ.mjs.map +1 -0
  155. package/dist/esm/chunk-TAHLOBRG.mjs +2 -0
  156. package/dist/esm/chunk-TAHLOBRG.mjs.map +1 -0
  157. package/dist/esm/{chunk-RYOICF37.mjs → chunk-TSPG5VED.mjs} +2 -2
  158. package/dist/esm/{chunk-56IXVVXX.mjs → chunk-UPHD2B4I.mjs} +2 -2
  159. package/dist/esm/{chunk-QREVMGQZ.mjs → chunk-UVJW4DPP.mjs} +1 -1
  160. package/dist/esm/{chunk-QREVMGQZ.mjs.map → chunk-UVJW4DPP.mjs.map} +1 -1
  161. package/dist/esm/chunk-UYG4XVVO.mjs +2 -0
  162. package/dist/esm/chunk-UYG4XVVO.mjs.map +1 -0
  163. package/dist/esm/chunk-WFZFTRRS.mjs +2 -0
  164. package/dist/esm/chunk-WFZFTRRS.mjs.map +1 -0
  165. package/dist/esm/{chunk-CUXCVNES.mjs → chunk-X4IR6WX6.mjs} +2 -2
  166. package/dist/esm/chunk-YJVBGKWM.mjs +2 -0
  167. package/dist/esm/chunk-YJVBGKWM.mjs.map +1 -0
  168. package/dist/esm/{chunk-NTLOKAPD.mjs → chunk-YTFJ5W7U.mjs} +2 -2
  169. package/dist/esm/cli/index.d.mts +2 -2
  170. package/dist/esm/cli/index.mjs +1 -1
  171. package/dist/esm/cli/localNode.d.mts +1 -1
  172. package/dist/esm/cli/localNode.mjs +1 -1
  173. package/dist/esm/cli/move.d.mts +1 -1
  174. package/dist/esm/cli/move.mjs +1 -1
  175. package/dist/esm/client/core.d.mts +1 -1
  176. package/dist/esm/client/core.mjs +1 -1
  177. package/dist/esm/client/get.d.mts +1 -1
  178. package/dist/esm/client/get.mjs +1 -1
  179. package/dist/esm/client/index.d.mts +1 -1
  180. package/dist/esm/client/index.mjs +1 -1
  181. package/dist/esm/client/post.d.mts +1 -1
  182. package/dist/esm/client/post.mjs +1 -1
  183. package/dist/esm/core/account/index.d.mts +1 -1
  184. package/dist/esm/core/account/index.mjs +1 -1
  185. package/dist/esm/core/account/utils/address.d.mts +1 -1
  186. package/dist/esm/core/account/utils/address.mjs +1 -1
  187. package/dist/esm/core/account/utils/index.d.mts +1 -1
  188. package/dist/esm/core/account/utils/index.mjs +1 -1
  189. package/dist/esm/core/accountAddress.d.mts +1 -1
  190. package/dist/esm/core/accountAddress.mjs +1 -1
  191. package/dist/esm/core/authenticationKey.d.mts +1 -1
  192. package/dist/esm/core/authenticationKey.mjs +1 -1
  193. package/dist/esm/core/crypto/abstraction.d.mts +1 -1
  194. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  195. package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
  196. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  197. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  198. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  199. package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
  200. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  201. package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
  202. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  203. package/dist/esm/core/crypto/index.d.mts +2 -2
  204. package/dist/esm/core/crypto/index.mjs +1 -1
  205. package/dist/esm/core/crypto/keyless.d.mts +2 -2
  206. package/dist/esm/core/crypto/keyless.mjs +1 -1
  207. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  208. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  209. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  210. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  211. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  212. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  213. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  214. package/dist/esm/core/crypto/proof.d.mts +1 -1
  215. package/dist/esm/core/crypto/proof.mjs +1 -1
  216. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  217. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  218. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  219. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  220. package/dist/esm/core/crypto/secp256r1.d.mts +1 -1
  221. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  222. package/dist/esm/core/crypto/signature.d.mts +1 -1
  223. package/dist/esm/core/crypto/signature.mjs +1 -1
  224. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  225. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  226. package/dist/esm/core/crypto/types.d.mts +1 -1
  227. package/dist/esm/core/crypto/utils.d.mts +1 -1
  228. package/dist/esm/core/crypto/utils.mjs +1 -1
  229. package/dist/esm/core/hex.d.mts +1 -1
  230. package/dist/esm/core/index.d.mts +2 -2
  231. package/dist/esm/core/index.mjs +1 -1
  232. package/dist/esm/errors/index.d.mts +1 -1
  233. package/dist/esm/errors/index.mjs +1 -1
  234. package/dist/esm/{federatedKeyless-BzaYmP03.d.mts → federatedKeyless-BYLu31Sa.d.mts} +13 -2
  235. package/dist/esm/index.d.mts +5 -5
  236. package/dist/esm/index.mjs +1 -1
  237. package/dist/esm/internal/abstraction.d.mts +1 -1
  238. package/dist/esm/internal/abstraction.mjs +1 -1
  239. package/dist/esm/internal/account.d.mts +3 -3
  240. package/dist/esm/internal/account.mjs +1 -1
  241. package/dist/esm/internal/ans.d.mts +2 -2
  242. package/dist/esm/internal/ans.mjs +1 -1
  243. package/dist/esm/internal/coin.d.mts +1 -1
  244. package/dist/esm/internal/coin.mjs +1 -1
  245. package/dist/esm/internal/digitalAsset.d.mts +3 -3
  246. package/dist/esm/internal/digitalAsset.mjs +1 -1
  247. package/dist/esm/internal/faucet.d.mts +1 -1
  248. package/dist/esm/internal/faucet.mjs +1 -1
  249. package/dist/esm/internal/fungibleAsset.d.mts +4 -4
  250. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  251. package/dist/esm/internal/general.d.mts +4 -2
  252. package/dist/esm/internal/general.mjs +1 -1
  253. package/dist/esm/internal/keyless.d.mts +3 -3
  254. package/dist/esm/internal/keyless.mjs +1 -1
  255. package/dist/esm/internal/object.d.mts +1 -1
  256. package/dist/esm/internal/object.mjs +1 -1
  257. package/dist/esm/internal/staking.d.mts +2 -2
  258. package/dist/esm/internal/staking.mjs +1 -1
  259. package/dist/esm/internal/table.d.mts +1 -1
  260. package/dist/esm/internal/table.mjs +1 -1
  261. package/dist/esm/internal/transaction.d.mts +1 -1
  262. package/dist/esm/internal/transaction.mjs +1 -1
  263. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  264. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  265. package/dist/esm/internal/utils/index.d.mts +1 -1
  266. package/dist/esm/internal/utils/index.mjs +1 -1
  267. package/dist/esm/internal/utils/utils.d.mts +1 -1
  268. package/dist/esm/internal/utils/utils.mjs +1 -1
  269. package/dist/esm/internal/view.d.mts +1 -1
  270. package/dist/esm/internal/view.mjs +1 -1
  271. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  272. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  273. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  274. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  275. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  276. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  277. package/dist/esm/transactions/index.d.mts +1 -1
  278. package/dist/esm/transactions/index.mjs +1 -1
  279. package/dist/esm/transactions/instances/chainId.d.mts +1 -1
  280. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  281. package/dist/esm/transactions/instances/identifier.d.mts +1 -1
  282. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  283. package/dist/esm/transactions/instances/index.d.mts +1 -1
  284. package/dist/esm/transactions/instances/index.mjs +1 -1
  285. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  286. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  287. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
  288. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  289. package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
  290. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  291. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  292. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  293. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  294. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  295. package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
  296. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  297. package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
  298. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  299. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  300. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  301. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  302. package/dist/esm/transactions/management/index.d.mts +2 -2
  303. package/dist/esm/transactions/management/index.mjs +1 -1
  304. package/dist/esm/transactions/management/transactionWorker.d.mts +12 -4
  305. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  306. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  307. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  308. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  309. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  310. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +2 -1
  311. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  312. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
  313. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  314. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  315. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  316. package/dist/esm/transactions/typeTag/index.d.mts +1 -1
  317. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  318. package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
  319. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  320. package/dist/esm/transactions/types.d.mts +1 -1
  321. package/dist/esm/types/generated/operations.d.mts +0 -11
  322. package/dist/esm/types/generated/queries.d.mts +1 -1
  323. package/dist/esm/types/generated/queries.mjs +1 -1
  324. package/dist/esm/types/index.d.mts +1 -1
  325. package/dist/esm/types/index.mjs +1 -1
  326. package/dist/esm/types/indexer.d.mts +1 -1
  327. package/dist/esm/types/types.d.mts +1 -1
  328. package/dist/esm/types/types.mjs +1 -1
  329. package/dist/esm/utils/const.d.mts +16 -2
  330. package/dist/esm/utils/const.mjs +1 -1
  331. package/dist/esm/utils/helpers.d.mts +21 -2
  332. package/dist/esm/utils/helpers.mjs +1 -1
  333. package/dist/esm/utils/index.d.mts +3 -3
  334. package/dist/esm/utils/index.mjs +1 -1
  335. package/dist/esm/utils/memoize.d.mts +23 -1
  336. package/dist/esm/utils/memoize.mjs +1 -1
  337. package/dist/esm/utils/normalizeBundle.d.mts +1 -1
  338. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  339. package/dist/esm/version.d.mts +1 -1
  340. package/dist/esm/version.mjs +1 -1
  341. package/package.json +36 -50
  342. package/src/account/AbstractKeylessAccount.ts +2 -3
  343. package/src/account/DerivableAbstractedAccount.ts +1 -3
  344. package/src/account/EphemeralKeyPair.ts +53 -2
  345. package/src/account/MultiEd25519Account.ts +0 -2
  346. package/src/account/MultiKeyAccount.ts +0 -2
  347. package/src/account/SingleKeyAccount.ts +0 -1
  348. package/src/api/account.ts +1 -2
  349. package/src/api/ans.ts +0 -1
  350. package/src/api/aptos.ts +1 -1
  351. package/src/api/aptosConfig.ts +12 -1
  352. package/src/api/transaction.ts +4 -4
  353. package/src/api/transactionSubmission/build.ts +1 -5
  354. package/src/api/transactionSubmission/helpers.ts +0 -1
  355. package/src/api/transactionSubmission/sign.ts +2 -2
  356. package/src/bcs/deserializer.ts +64 -17
  357. package/src/bcs/serializable/movePrimitives.ts +15 -28
  358. package/src/bcs/serializable/moveStructs.ts +4 -6
  359. package/src/bcs/serializer.ts +147 -12
  360. package/src/cli/localNode.ts +4 -7
  361. package/src/cli/move.ts +7 -7
  362. package/src/client/get.ts +8 -10
  363. package/src/core/account/utils/address.ts +3 -3
  364. package/src/core/accountAddress.ts +2 -3
  365. package/src/core/crypto/abstraction.ts +0 -3
  366. package/src/core/crypto/ed25519.ts +66 -1
  367. package/src/core/crypto/federatedKeyless.ts +1 -1
  368. package/src/core/crypto/keyless.ts +65 -14
  369. package/src/core/crypto/multiEd25519.ts +1 -3
  370. package/src/core/crypto/multiKey.ts +4 -7
  371. package/src/core/crypto/poseidon.ts +0 -1
  372. package/src/core/crypto/privateKey.ts +2 -5
  373. package/src/core/crypto/secp256k1.ts +68 -3
  374. package/src/core/crypto/secp256r1.ts +1 -1
  375. package/src/core/crypto/singleKey.ts +4 -1
  376. package/src/core/crypto/utils.ts +6 -3
  377. package/src/errors/index.ts +4 -5
  378. package/src/internal/account.ts +21 -30
  379. package/src/internal/ans.ts +5 -6
  380. package/src/internal/general.ts +24 -6
  381. package/src/internal/keyless.ts +1 -1
  382. package/src/internal/queries/getAccountAddressesForAuthKey.graphql +4 -1
  383. package/src/internal/queries/getAuthKeysForPublicKey.graphql +4 -1
  384. package/src/internal/queries/getCollectionData.graphql +0 -11
  385. package/src/internal/queries/getTableItemsData.graphql +1 -1
  386. package/src/internal/queries/getTableItemsMetadata.graphql +2 -2
  387. package/src/internal/transaction.ts +5 -7
  388. package/src/internal/transactionSubmission.ts +23 -0
  389. package/src/transactions/authenticator/account.ts +0 -4
  390. package/src/transactions/authenticator/transaction.ts +0 -2
  391. package/src/transactions/instances/multiAgentTransaction.ts +0 -2
  392. package/src/transactions/instances/rawTransaction.ts +0 -2
  393. package/src/transactions/instances/signedTransaction.ts +0 -2
  394. package/src/transactions/instances/simpleTransaction.ts +0 -2
  395. package/src/transactions/instances/transactionPayload.ts +5 -7
  396. package/src/transactions/management/accountSequenceNumber.ts +0 -4
  397. package/src/transactions/management/transactionWorker.ts +40 -10
  398. package/src/transactions/transactionBuilder/remoteAbi.ts +22 -8
  399. package/src/transactions/transactionBuilder/transactionBuilder.ts +14 -12
  400. package/src/transactions/typeTag/index.ts +0 -3
  401. package/src/transactions/typeTag/parser.ts +3 -5
  402. package/src/types/generated/operations.ts +0 -11
  403. package/src/types/generated/queries.ts +0 -11
  404. package/src/types/types.ts +26 -0
  405. package/src/utils/const.ts +17 -1
  406. package/src/utils/helpers.ts +47 -8
  407. package/src/utils/memoize.ts +177 -11
  408. package/src/version.ts +1 -1
  409. package/dist/common/chunk-4RHBBU7C.js +0 -4
  410. package/dist/common/chunk-4RHBBU7C.js.map +0 -1
  411. package/dist/esm/chunk-2DPQMXUG.mjs +0 -4
  412. package/dist/esm/chunk-2DPQMXUG.mjs.map +0 -1
  413. package/dist/esm/chunk-2LCPW76G.mjs +0 -2
  414. package/dist/esm/chunk-2LCPW76G.mjs.map +0 -1
  415. package/dist/esm/chunk-2PASUPUO.mjs +0 -2
  416. package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
  417. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  418. package/dist/esm/chunk-52PWWLJJ.mjs.map +0 -1
  419. package/dist/esm/chunk-54C2P534.mjs +0 -2
  420. package/dist/esm/chunk-54C2P534.mjs.map +0 -1
  421. package/dist/esm/chunk-BGZDJ5SM.mjs +0 -2
  422. package/dist/esm/chunk-BGZDJ5SM.mjs.map +0 -1
  423. package/dist/esm/chunk-C5UZZHA4.mjs +0 -2
  424. package/dist/esm/chunk-C5UZZHA4.mjs.map +0 -1
  425. package/dist/esm/chunk-F3NI6N7R.mjs.map +0 -1
  426. package/dist/esm/chunk-FW6UHAQV.mjs.map +0 -1
  427. package/dist/esm/chunk-G3HAIETV.mjs.map +0 -1
  428. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  429. package/dist/esm/chunk-I42Z32Q2.mjs +0 -2
  430. package/dist/esm/chunk-I42Z32Q2.mjs.map +0 -1
  431. package/dist/esm/chunk-JN65XG2P.mjs +0 -2
  432. package/dist/esm/chunk-JN65XG2P.mjs.map +0 -1
  433. package/dist/esm/chunk-KUF4DKN5.mjs +0 -2
  434. package/dist/esm/chunk-LD3I4CYO.mjs +0 -2
  435. package/dist/esm/chunk-LS2HRAVW.mjs.map +0 -1
  436. package/dist/esm/chunk-MEG27LEV.mjs.map +0 -1
  437. package/dist/esm/chunk-NCKJ7X57.mjs +0 -2
  438. package/dist/esm/chunk-NCKJ7X57.mjs.map +0 -1
  439. package/dist/esm/chunk-NK3Y3PV3.mjs +0 -2
  440. package/dist/esm/chunk-NK3Y3PV3.mjs.map +0 -1
  441. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  442. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  443. package/dist/esm/chunk-PYVKCTUN.mjs +0 -2
  444. package/dist/esm/chunk-PYVKCTUN.mjs.map +0 -1
  445. package/dist/esm/chunk-QEHKRR3I.mjs +0 -2
  446. package/dist/esm/chunk-QEHKRR3I.mjs.map +0 -1
  447. package/dist/esm/chunk-RQN6LA7E.mjs +0 -2
  448. package/dist/esm/chunk-Y426VCPM.mjs +0 -2
  449. package/dist/esm/chunk-Y426VCPM.mjs.map +0 -1
  450. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  451. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  452. /package/dist/esm/{chunk-5FNZUL2Y.mjs.map → chunk-2VBY2V4Z.mjs.map} +0 -0
  453. /package/dist/esm/{chunk-KUF4DKN5.mjs.map → chunk-5HHC2YG4.mjs.map} +0 -0
  454. /package/dist/esm/{chunk-DIFSO4N6.mjs.map → chunk-CD3EZCI5.mjs.map} +0 -0
  455. /package/dist/esm/{chunk-43LWUUXS.mjs.map → chunk-E3DHFXN4.mjs.map} +0 -0
  456. /package/dist/esm/{chunk-QDJDZ3ON.mjs.map → chunk-EIWPAECI.mjs.map} +0 -0
  457. /package/dist/esm/{chunk-LD3I4CYO.mjs.map → chunk-ITZN23GU.mjs.map} +0 -0
  458. /package/dist/esm/{chunk-X674XJNJ.mjs.map → chunk-KOVWYU53.mjs.map} +0 -0
  459. /package/dist/esm/{chunk-PXJEKGEG.mjs.map → chunk-LDK76MDN.mjs.map} +0 -0
  460. /package/dist/esm/{chunk-WZ6FL7CH.mjs.map → chunk-NWP2VEMB.mjs.map} +0 -0
  461. /package/dist/esm/{chunk-6IWGTO2J.mjs.map → chunk-POQ4FT4E.mjs.map} +0 -0
  462. /package/dist/esm/{chunk-76SVQZDX.mjs.map → chunk-Q4KYBAYN.mjs.map} +0 -0
  463. /package/dist/esm/{chunk-3P474TWM.mjs.map → chunk-R7PCBRRT.mjs.map} +0 -0
  464. /package/dist/esm/{chunk-RYOICF37.mjs.map → chunk-TSPG5VED.mjs.map} +0 -0
  465. /package/dist/esm/{chunk-56IXVVXX.mjs.map → chunk-UPHD2B4I.mjs.map} +0 -0
  466. /package/dist/esm/{chunk-CUXCVNES.mjs.map → chunk-X4IR6WX6.mjs.map} +0 -0
  467. /package/dist/esm/{chunk-NTLOKAPD.mjs.map → chunk-YTFJ5W7U.mjs.map} +0 -0
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunk4RHBBU7Cjs = require('./chunk-4RHBBU7C.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=_chunk4RHBBU7Cjs.v.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}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}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)}deserializeI8(){return new DataView(this.read(1)).getInt8(0)}deserializeI16(){return new DataView(this.read(2)).getInt16(0,!0)}deserializeI32(){return new DataView(this.read(4)).getInt32(0,!0)}deserializeI64(){let e=this.deserializeU32(),t=this.deserializeU32(),r=BigInt(BigInt(t)<<BigInt(32)|BigInt(e)),i=BigInt(1)<<BigInt(63);return r>=i?r-(BigInt(1)<<BigInt(64)):r}deserializeI128(){let e=this.deserializeU64(),t=this.deserializeU64(),r=BigInt(t<<BigInt(64)|e),i=BigInt(1)<<BigInt(127);return r>=i?r-(BigInt(1)<<BigInt(128)):r}deserializeI256(){let e=this.deserializeU128(),t=this.deserializeU128(),r=BigInt(t<<BigInt(128)|e),i=BigInt(1)<<BigInt(255);return r>=i?r-(BigInt(1)<<BigInt(256)):r}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunk4RHBBU7Cjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),(r&128)===0)break;t+=7}if(e>_chunk4RHBBU7Cjs.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 Re=class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),this.value=_chunk4RHBBU7Cjs.v.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 Sr=class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),this.value=new Re(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Re.deserialize(e,t);return new n(r.value)}};var N=class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.z.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 Se(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},ee= exports.U8 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,0,_chunk4RHBBU7Cjs.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())}},Ue= exports.U16 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,0,_chunk4RHBBU7Cjs.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())}},ze= exports.U32 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,0,_chunk4RHBBU7Cjs.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())}},$= exports.U64 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,BigInt(0),_chunk4RHBBU7Cjs.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())}},ke= exports.U128 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,BigInt(0),_chunk4RHBBU7Cjs.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())}},Se= exports.U256 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,BigInt(0),_chunk4RHBBU7Cjs.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())}},De= exports.I8 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.h,_chunk4RHBBU7Cjs.i),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(10),e.serialize(this)}static deserialize(e){return new n(e.deserializeI8())}},Fe= exports.I16 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.j,_chunk4RHBBU7Cjs.k),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(11),e.serialize(this)}static deserialize(e){return new n(e.deserializeI16())}},Ne= exports.I32 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.l,_chunk4RHBBU7Cjs.m),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(12),e.serialize(this)}static deserialize(e){return new n(e.deserializeI32())}},Oe= exports.I64 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.n,_chunk4RHBBU7Cjs.o),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(13),e.serialize(this)}static deserialize(e){return new n(e.deserializeI64())}},Be= exports.I128 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.p,_chunk4RHBBU7Cjs.q),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(14),e.serialize(this)}static deserialize(e){return new n(e.deserializeI128())}},Ge= exports.I256 =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),_chunk4RHBBU7Cjs.B.call(void 0, e,_chunk4RHBBU7Cjs.r,_chunk4RHBBU7Cjs.s),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(15),e.serialize(this)}static deserialize(e){return new n(e.deserializeI256())}};var S=class n extends _chunk4RHBBU7Cjs.x{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 ee)){new Gn(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=_chunk4RHBBU7Cjs.v.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 ee(r)))}static U16(e){return new n(e.map(t=>new Ue(t)))}static U32(e){return new n(e.map(t=>new ze(t)))}static U64(e){return new n(e.map(t=>new $(t)))}static U128(e){return new n(e.map(t=>new ke(t)))}static U256(e){return new n(e.map(t=>new Se(t)))}static Bool(e){return new n(e.map(t=>new N(t)))}static I8(e){return new n(e.map(t=>new De(t)))}static I16(e){return new n(e.map(t=>new Fe(t)))}static I32(e){return new n(e.map(t=>new Ne(t)))}static I64(e){return new n(e.map(t=>new Oe(t)))}static I128(e){return new n(e.map(t=>new Be(t)))}static I256(e){return new n(e.map(t=>new Ge(t)))}static MoveString(e){return new n(e.map(t=>new v(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)}},Gn= exports.Serialized =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),this.value=_chunk4RHBBU7Cjs.v.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 S(r)}},v= exports.MoveString =class n extends _chunk4RHBBU7Cjs.x{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())}},B= exports.MoveOption =class n extends _chunk4RHBBU7Cjs.x{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 ee(e):void 0)}static U16(e){return new n(e!=null?new Ue(e):void 0)}static U32(e){return new n(e!=null?new ze(e):void 0)}static U64(e){return new n(e!=null?new $(e):void 0)}static U128(e){return new n(e!=null?new ke(e):void 0)}static U256(e){return new n(e!=null?new Se(e):void 0)}static Bool(e){return new n(e!=null?new N(e):void 0)}static I8(e){return new n(e!=null?new De(e):void 0)}static I16(e){return new n(e!=null?new Fe(e):void 0)}static I32(e){return new n(e!=null?new Ne(e):void 0)}static I64(e){return new n(e!=null?new Oe(e):void 0)}static I128(e){return new n(e!=null?new Be(e):void 0)}static I256(e){return new n(e!=null?new Ge(e):void 0)}static MoveString(e){return new n(e!=null?new v(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 _chunk4RHBBU7Cjs.x{constructor(e){super();let{data:t}=e,r=_chunk4RHBBU7Cjs.v.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=_chunk4RHBBU7Cjs.v.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, _chunk4RHBBU7Cjs.pa)(this.data.toUint8Array())}};Ut.LENGTH=32;var H=Ut;var at=class extends _chunk4RHBBU7Cjs.x{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk4RHBBU7Cjs.v.fromHexInput(e).toString()}},ae= exports.AccountPublicKey =class extends at{};var O=class extends _chunk4RHBBU7Cjs.x{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk4RHBBU7Cjs.v.fromHexInput(e).toString()}};var Mn=class n extends O{constructor(e){super(),this.value=_chunk4RHBBU7Cjs.v.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},Ir= exports.AbstractPublicKey =class extends ae{constructor(e){super(),this.accountAddress=e}authKey(){return new H({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 ds = _interopRequireWildcard(_bip39);var hu=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,bu= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Tu= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Tu||{}),ps= exports.HARDENED_OFFSET =2147483648;function ls(n){return bu.test(n)}function gs(n){return hu.test(n)}var _i=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},ys= 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 _i(e,s)},wu=n=>n.replace(/'/g,""),ms= exports.splitPath =n=>n.split("/").slice(1).map(wu),Pr= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return ds.mnemonicToSeedSync(e)};var Vn=class Vn{static formatPrivateKey(e,t){let r=Vn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk4RHBBU7Cjs.v.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=Vn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk4RHBBU7Cjs.v.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=_chunk4RHBBU7Cjs.v.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=_chunk4RHBBU7Cjs.v.fromHexInput(e);return i}};Vn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var Ie=Vn;var _jwtdecode = require('jwt-decode');var zt=class n extends at{constructor(e){super();let t=e.constructor.name;switch(t){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Je= exports.EphemeralSignature =class n extends O{constructor(e){super();let t=e.constructor.name;switch(t){case U.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunk4RHBBU7Cjs.v.fromHexInput(e),r=new K(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof U)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(U.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var xi=[_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],As=31,Ou=16,fs=(Ou-1)*As;function Xe(n,e){let r=new TextEncoder().encode(n);return Bu(r,e)}function Bu(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 Gu(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Hu(n,e);return Mu(t)}function Hn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Gu(n,e).concat([BigInt(n.length)])}function Mu(n){if(n.length>fs)throw new Error(`Can't pack more than ${fs}. Was given ${n.length} bytes`);return Vu(n,As).map(e=>Mt(e))}function Vu(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function Mt(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 Ci(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 Hu(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>xi.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${xi.length}`);return xi[n.length-1](n)}var Er=class extends _chunk4RHBBU7Cjs.x{};var hs="6.0.0";var bs={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",shelbynet:"https://api.shelbynet.shelby.xyz/v1/graphql",netna:"https://api.netna.staging.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Ts= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",shelbynet:"https://api.shelbynet.shelby.xyz/v1",netna:"https://api.netna.staging.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},ws= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",shelbynet:"https://faucet.shelbynet.shelby.xyz",netna:"https://faucet-dev-netna-us-central1-410192433417.us-central1.run.app",local:"http://127.0.0.1:8081"},vi= 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",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/pepper/v0",netna:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Ki= 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",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/prover/v0",netna:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Ri= exports.Network =(a=>(a.MAINNET="mainnet",a.TESTNET="testnet",a.DEVNET="devnet",a.SHELBYNET="shelbynet",a.NETNA="netna",a.LOCAL="local",a.CUSTOM="custom",a))(Ri||{}),Ui= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},_g= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",shelbynet:"shelbynet",netna:"netna",local:"local",custom:"custom"};var un=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(un||{}),Ss= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Is= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,_r= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Ht= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Ps= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Es= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",zi= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",_s= exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT ="APTOS::AASigningData",kt= 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))(kt||{}),xs= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Cs(n,e){let t=e.bcsToBytes(),r=new K(t);return n.deserialize(r)}var qu=(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))(qu||{}),Lu= 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))(Lu||{}),xr= exports.KeylessErrorType =(A=>(A[A.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",A[A.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",A[A.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",A[A.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",A[A.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",A[A.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",A[A.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",A[A.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",A[A.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",A[A.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",A[A.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",A[A.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",A[A.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",A[A.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",A[A.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",A[A.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",A[A.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",A[A.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",A[A.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",A[A.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",A[A.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",A[A.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",A[A.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",A[A.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",A[A.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",A[A.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",A[A.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",A[A.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",A[A.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",A[A.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",A[A.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",A[A.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",A[A.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",A[A.UNKNOWN=33]="UNKNOWN",A))(xr||{}),vs={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"]},E= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=vs[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 _chunk2VR6ONNWjs = require('./chunk-2VR6ONNW.js');var Iu=new TextDecoder,ws=10*1024*1024,K= exports.Deserializer =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=_chunk2VR6ONNWjs.v.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=new Uint8Array(this.buffer,this.offset,e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}deserializeStr(){let e=this.deserializeBytes();return Iu.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();if(e>ws)throw new Error(`Deserialization error: byte array length ${e} exceeds maximum allowed ${ws}`);return this.read(e).slice()}deserializeFixedBytes(e){return this.read(e).slice()}deserializeBool(){let e=this.read(1)[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return this.read(1)[0]}deserializeU16(){let e=this.read(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!0)}deserializeU32(){let e=this.read(4);return new DataView(e.buffer,e.byteOffset,e.byteLength).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)}deserializeI8(){let e=this.read(1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}deserializeI16(){let e=this.read(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt16(0,!0)}deserializeI32(){let e=this.read(4);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt32(0,!0)}deserializeI64(){let e=this.deserializeU32(),t=this.deserializeU32(),r=BigInt(BigInt(t)<<BigInt(32)|BigInt(e)),i=BigInt(1)<<BigInt(63);return r>=i?r-(BigInt(1)<<BigInt(64)):r}deserializeI128(){let e=this.deserializeU64(),t=this.deserializeU64(),r=BigInt(t<<BigInt(64)|e),i=BigInt(1)<<BigInt(127);return r>=i?r-(BigInt(1)<<BigInt(128)):r}deserializeI256(){let e=this.deserializeU128(),t=this.deserializeU128(),r=BigInt(t<<BigInt(128)|e),i=BigInt(1)<<BigInt(255);return r>=i?r-(BigInt(1)<<BigInt(256)):r}deserializeUleb128AsU32(){let e=BigInt(0),t=0,r=5,i=0;for(;i<r;){let o=this.deserializeU8();if(i+=1,e|=BigInt(o&127)<<BigInt(t),e>_chunk2VR6ONNWjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");if((o&128)===0)break;t+=7}if(i===r&&e>_chunk2VR6ONNWjs.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 ze=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.value=_chunk2VR6ONNWjs.v.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 Pr=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.value=new ze(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=ze.deserialize(e,t);return new n(r.value)}};var F=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.M.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new Ee(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},ee= exports.U8 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,0,_chunk2VR6ONNWjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},ke= exports.U16 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,0,_chunk2VR6ONNWjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},De= exports.U32 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,0,_chunk2VR6ONNWjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},$= exports.U64 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,BigInt(0),_chunk2VR6ONNWjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},Ne= exports.U128 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,BigInt(0),_chunk2VR6ONNWjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},Ee= exports.U256 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,BigInt(0),_chunk2VR6ONNWjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}},Fe= exports.I8 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.h,_chunk2VR6ONNWjs.i),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(10),e.serialize(this)}static deserialize(e){return new n(e.deserializeI8())}},Oe= exports.I16 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.j,_chunk2VR6ONNWjs.k),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(11),e.serialize(this)}static deserialize(e){return new n(e.deserializeI16())}},Ge= exports.I32 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.l,_chunk2VR6ONNWjs.m),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(12),e.serialize(this)}static deserialize(e){return new n(e.deserializeI32())}},Be= exports.I64 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.n,_chunk2VR6ONNWjs.o),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(13),e.serialize(this)}static deserialize(e){return new n(e.deserializeI64())}},Me= exports.I128 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.p,_chunk2VR6ONNWjs.q),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(14),e.serialize(this)}static deserialize(e){return new n(e.deserializeI128())}},Ve= exports.I256 =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),_chunk2VR6ONNWjs.O.call(void 0, e,_chunk2VR6ONNWjs.r,_chunk2VR6ONNWjs.s),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(15),e.serialize(this)}static deserialize(e){return new n(e.deserializeI256())}};var S=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.values=e}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof ee)){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=_chunk2VR6ONNWjs.v.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 ee(r)))}static U16(e){return new n(e.map(t=>new ke(t)))}static U32(e){return new n(e.map(t=>new De(t)))}static U64(e){return new n(e.map(t=>new $(t)))}static U128(e){return new n(e.map(t=>new Ne(t)))}static U256(e){return new n(e.map(t=>new Ee(t)))}static Bool(e){return new n(e.map(t=>new F(t)))}static I8(e){return new n(e.map(t=>new Fe(t)))}static I16(e){return new n(e.map(t=>new Oe(t)))}static I32(e){return new n(e.map(t=>new Ge(t)))}static I64(e){return new n(e.map(t=>new Be(t)))}static I128(e){return new n(e.map(t=>new Me(t)))}static I256(e){return new n(e.map(t=>new Ve(t)))}static MoveString(e){return new n(e.map(t=>new C(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 _chunk2VR6ONNWjs.K{constructor(e){super(),this.value=_chunk2VR6ONNWjs.v.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 S(r)}},C= exports.MoveString =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},G= exports.MoveOption =class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){e.serializeAsBytes(this)}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 ee(e):void 0)}static U16(e){return new n(e!=null?new ke(e):void 0)}static U32(e){return new n(e!=null?new De(e):void 0)}static U64(e){return new n(e!=null?new $(e):void 0)}static U128(e){return new n(e!=null?new Ne(e):void 0)}static U256(e){return new n(e!=null?new Ee(e):void 0)}static Bool(e){return new n(e!=null?new F(e):void 0)}static I8(e){return new n(e!=null?new Fe(e):void 0)}static I16(e){return new n(e!=null?new Oe(e):void 0)}static I32(e){return new n(e!=null?new Ge(e):void 0)}static I64(e){return new n(e!=null?new Be(e):void 0)}static I128(e){return new n(e!=null?new Me(e):void 0)}static I256(e){return new n(e!=null?new Ve(e):void 0)}static MoveString(e){return new n(e!=null?new C(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 kt=class kt extends _chunk2VR6ONNWjs.K{constructor(e){super();let{data:t}=e,r=_chunk2VR6ONNWjs.v.fromHexInput(t);if(r.toUint8Array().length!==kt.LENGTH)throw new Error(`Authentication Key length should be ${kt.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(kt.LENGTH);return new kt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunk2VR6ONNWjs.v.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new kt({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, _chunk2VR6ONNWjs.Ca)(this.data.toUint8Array())}};kt.LENGTH=32;var H=kt;var ut=class extends _chunk2VR6ONNWjs.K{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk2VR6ONNWjs.v.fromHexInput(e).toString()}},ce= exports.AccountPublicKey =class extends ut{};var O=class extends _chunk2VR6ONNWjs.K{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk2VR6ONNWjs.v.fromHexInput(e).toString()}};var qn=class n extends O{constructor(e){super(),this.value=_chunk2VR6ONNWjs.v.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},_r= exports.AbstractPublicKey =class extends ce{constructor(e){super(),this.accountAddress=e}authKey(){return new H({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 Ss = _interopRequireWildcard(_bip39);var xu=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,vu= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Cu= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Cu||{}),Is= exports.HARDENED_OFFSET =2147483648;function Es(n){return vu.test(n)}function Ps(n){return xu.test(n)}var Ki=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},_s= 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 Ki(e,s)},Ku=n=>n.replace(/'/g,""),xs= exports.splitPath =n=>n.split("/").slice(1).map(Ku),xr= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return Ss.mnemonicToSeedSync(e)};var Ln=class Ln{static formatPrivateKey(e,t){let r=Ln.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk2VR6ONNWjs.v.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=Ln.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk2VR6ONNWjs.v.fromHexInput(e),r!==!1&&_chunk2VR6ONNWjs.Ia.call(void 0, "[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=_chunk2VR6ONNWjs.v.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=_chunk2VR6ONNWjs.v.fromHexInput(e);return i}};Ln.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var Pe=Ln;var _jwtdecode = require('jwt-decode');var Dt=class n extends ut{constructor(e){super();let t=e.constructor.name;if(t===P.name)this.publicKey=e,this.variant=0;else 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 P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return new n(P.deserialize(e));throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}static isPublicKey(e){return e instanceof n}},Ye= exports.EphemeralSignature =class n extends O{constructor(e){super();let t=e.constructor.name;if(t===U.name)this.signature=e;else throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}static fromHex(e){let t=_chunk2VR6ONNWjs.v.fromHexInput(e),r=new K(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof U)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return new n(U.deserialize(e));throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}};var _poseidonlite = require('poseidon-lite');var Ri=[_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],Cs=31,Wu=16,vs=(Wu-1)*Cs;function Ze(n,e){let r=new TextEncoder().encode(n);return Qu(r,e)}function Qu(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=$n(n,e);return Lt(t)}function ju(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Yu(n,e);return Ju(t)}function $n(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return ju(n,e).concat([BigInt(n.length)])}function Ju(n){if(n.length>vs)throw new Error(`Can't pack more than ${vs}. Was given ${n.length} bytes`);return Xu(n,Cs).map(e=>qt(e))}function Xu(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function qt(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 Ui(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 Yu(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 Lt(n){if(n.length>Ri.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${Ri.length}`);return Ri[n.length-1](n)}var vr=class extends _chunk2VR6ONNWjs.K{};var Ks="6.2.0";var Rs={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",shelbynet:"https://api.shelbynet.shelby.xyz/v1/graphql",netna:"https://api.netna.staging.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Us= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",shelbynet:"https://api.shelbynet.shelby.xyz/v1",netna:"https://api.netna.staging.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},zs= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",shelbynet:"https://faucet.shelbynet.shelby.xyz",netna:"https://faucet-dev-netna-us-central1-410192433417.us-central1.run.app",local:"http://127.0.0.1:8081"},zi= 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",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/pepper/v0",netna:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ki= 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",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/prover/v0",netna:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Di= exports.Network =(a=>(a.MAINNET="mainnet",a.TESTNET="testnet",a.DEVNET="devnet",a.SHELBYNET="shelbynet",a.NETNA="netna",a.LOCAL="local",a.CUSTOM="custom",a))(Di||{}),Ni= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Mg= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",shelbynet:"shelbynet",netna:"netna",local:"local",custom:"custom"};function ks(n,e){let t=e.bcsToBytes(),r=new K(t);return n.deserialize(r)}var Zu=(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))(Zu||{}),ed= 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))(ed||{}),Cr= exports.KeylessErrorType =(A=>(A[A.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",A[A.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",A[A.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",A[A.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",A[A.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",A[A.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",A[A.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",A[A.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",A[A.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",A[A.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",A[A.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",A[A.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",A[A.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",A[A.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",A[A.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",A[A.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",A[A.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",A[A.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",A[A.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",A[A.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",A[A.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",A[A.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",A[A.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",A[A.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",A[A.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",A[A.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",A[A.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",A[A.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",A[A.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",A[A.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",A[A.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",A[A.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",A[A.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",A[A.UNKNOWN=33]="UNKNOWN",A))(Cr||{}),Ds={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"]},I= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Ds[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 Pe?o+=`
3
+ Details: ${i}`),r instanceof _e?o+=`
4
4
  AptosApiError: ${r.message}`:r!==void 0&&(o+=`
5
- Error: ${_chunk4RHBBU7Cjs.va.call(void 0, r)}`),o+=`
6
- KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=vs[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Pe= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super($u({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 $u({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _2 => _2.headers, 'optionalAccess', _3 => _3.traceparent, 'optionalAccess', _4 => _4.split, 'call', _5 => _5("-"), 'access', _6 => _6[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', _7 => _7.data, 'optionalAccess', _8 => _8.errors, 'optionalAccess', _9 => _9[0], 'optionalAccess', _10 => _10.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.message])!=null&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${Wu(t.data)}`}var ki=400;function Wu(n){let e=JSON.stringify(n);return e.length<=ki?e:`truncated(original_size:${e.length}): ${e.slice(0,ki/2)}...${e.slice(-ki/2)}`}async function Qu(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _15 => _15.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${hs}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _16 => _16.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _17 => _17.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _18 => _18.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _19 => _19.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a,http2:_optionalChain([a, 'optionalAccess', _20 => _20.http2])})}async function Cr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Qu({...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 Pe({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a})}async function vr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return Cr({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function q(n){let{aptosConfig:e}=n;return vr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.fullnodeConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}async function Zg(n){return vr({...n,type:"Pepper"})}async function Kr(n){let e=new Array(0),t,r=n.params;do{let i=await vr({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 Di(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await Rr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _25 => _25.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 Rr(n){let e,t={};typeof _optionalChain([n, 'access', _26 => _26.params, 'optionalAccess', _27 => _27.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.limit])=="number"&&(t.limit=n.params.limit);let r=await vr({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 qn(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 Cr({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function Dt(n){let{aptosConfig:e}=n;return qn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _30 => _30.clientConfig, 'optionalAccess', _31 => _31.HEADERS]),..._optionalChain([e, 'access', _32 => _32.fullnodeConfig, 'optionalAccess', _33 => _33.HEADERS])}}})}async function Ks(n){let{aptosConfig:e}=n;return qn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _34 => _34.clientConfig, 'optionalAccess', _35 => _35.HEADERS]),..._optionalChain([e, 'access', _36 => _36.indexerConfig, 'optionalAccess', _37 => _37.HEADERS])}}})}async function Rs(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _38 => _38.clientConfig, 'optionalAccess', _39 => delete _39.API_KEY]),qn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([t, 'access', _42 => _42.faucetConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function Us(n){return qn({...n,type:"Pepper"})}async function zs(n){return qn({...n,type:"Prover"})}var Fi=new Map;function Ye(n,e,t){return async(...r)=>{if(Fi.has(e)){let{value:o,timestamp:s}=Fi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return Fi.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 Yu=1e7,Ni= exports.MAX_AUD_VAL_BYTES =120,Zu= exports.MAX_UID_KEY_BYTES =30,ed= exports.MAX_UID_VAL_BYTES =330,td= exports.MAX_ISS_VAL_BYTES =120,nd= exports.MAX_EXTRA_FIELD_BYTES =350,rd= exports.MAX_JWT_HEADER_B64_BYTES =300,id= exports.MAX_COMMITED_EPK_BYTES =93,Ze=class Ze extends ae{constructor(e,t){super();let r=_chunk4RHBBU7Cjs.v.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 _chunk4RHBBU7Cjs.y;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Ur({...e,publicKey:this}),!0}catch(t){if(t instanceof E)return!1;throw t}}async verifySignatureAsync(e){return Hi({...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 ks(e),new Ze(e.iss,ks(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 R=Ze;async function Hi(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await ln({aptosConfig:e}),options:a}=n;try{if(!(i instanceof ce))throw E.fromErrorType({type:26,details:"Not a keyless signature"});return Ur({message:r,publicKey:t,signature:i,jwk:o||await qi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _44 => _44.throwErrorWithReason]))throw c;return!1}}function Ur(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof ce))throw E.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof me))throw E.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof Ft))throw E.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<_chunk4RHBBU7Cjs.wa.call(void 0, ))throw E.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw E.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw E.fromErrorType({type:29});let f=od({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:f,groth16Proof:l}))throw E.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw E.fromErrorType({type:30});let p=new Bi(l,f);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw E.fromErrorType({type:31})}}function od(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof R?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof me))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(Mt(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Xe(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Xe(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Xe(" ",i.maxExtraFieldBytes))),a.push(Xe(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Xe(s.overrideAudVal,Ni)),a.push(1n)):(a.push(Xe("",Ni)),a.push(0n)),Vt(a)}async function qi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof R?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof L?t.jwkAddress:void 0;try{s=await cd({aptosConfig:e,jwkAddr:a})}catch(l){throw E.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 E.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw E.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function ks(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Mt(_chunk4RHBBU7Cjs.v.fromHexInput(i).toUint8Array()),Xe(r,Ni),Xe(t,ed),Xe(e,Zu)];return Ci(Vt(o),R.ID_COMMITMENT_LENGTH)}var ce=class n extends O{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 dd(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=dn.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=zt.deserialize(e),s=Je.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new dn(new me({proof:new pn(new Ft({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new zt(new P(new Uint8Array(32))),ephemeralSignature:new Je(new U(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},dn= exports.EphemeralCertificate =class n extends O{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(me.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Ln=class Ln extends _chunk4RHBBU7Cjs.x{constructor(e){if(super(),this.data=_chunk4RHBBU7Cjs.v.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 Ln(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(Oi(e)),o=r.sqrt(r.add(r.pow(i,3n),Ln.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Ln.B=_bn254.bn254.fields.Fp.create(3n);var ct=Ln;function Oi(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 $n=class $n extends _chunk4RHBBU7Cjs.x{constructor(e){if(super(),this.data=_chunk4RHBBU7Cjs.v.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new $n(t)}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([Oi(t),Oi(r)]),a=o.sqrt(o.add(o.pow(s,3n),$n.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})}};$n.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var qt=$n,Ft= exports.Groth16Zkp =class n extends Er{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new ct(t),this.b=new qt(r),this.c=new ct(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=ct.deserialize(e).bcsToBytes(),r=qt.deserialize(e).bcsToBytes(),i=ct.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()}}},Bi= exports.Groth16ProofAndStatement =class n extends _chunk4RHBBU7Cjs.x{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?Ci(r,32):_chunk4RHBBU7Cjs.v.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(Ft.deserialize(t),t.deserializeFixedBytes(32))}hash(){return et(this.bcsToBytes(),this.domainSeparator)}},pn= exports.ZkProof =class n extends _chunk4RHBBU7Cjs.x{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(Ft.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},me= exports.ZeroKnowledgeSig =class n extends O{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=pn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Je);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=Yu,maxExtraFieldBytes:o=nd,maxJwtHeaderB64Bytes:s=rd,maxIssValBytes:a=td,maxCommitedEpkBytes:c=id}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new zt(new P(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new Mi({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})}},Mi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new ct(t),this.betaG2=new qt(r),this.deltaG2=new qt(i),this.gammaAbcG1=[new ct(o[0]),new ct(o[1])],this.gammaG2=new qt(s)}hash(){let e=new _chunk4RHBBU7Cjs.y;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(ot=>ot.toProjectivePoint()),{Fp12:p}=_bn254.bn254.fields,y=f[0].add(f[1].multiply(t)),b=_bn254.bn254.pairing(y,d),D=_bn254.bn254.pairing(i,o),Y=_bn254.bn254.pairing(a,c),re=_bn254.bn254.pairing(s,l),Kt=p.mul(Y,p.mul(b,re));return p.eql(D,Kt)}catch(i){throw E.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 ln(n){let{aptosConfig:e}=n;try{return await Ye(async()=>{let[t,r]=await Promise.all([sd(n),ad(n)]);return Gi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof E?t:E.fromErrorType({type:25,error:t})}}function ut(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw E.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunk4RHBBU7Cjs.va.call(void 0, o)}`})}if(typeof r.iss!="string")throw E.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw E.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 sd(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await q({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk4RHBBU7Cjs.pa.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw E.fromErrorType({type:22,error:i})}}async function ad(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await q({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk4RHBBU7Cjs.pa.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _46 => _46.ledgerVersion])}});return i.data}catch(i){throw E.fromErrorType({type:23,error:i})}}async function cd(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _47 => _47.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _48 => _48.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(_chunk4RHBBU7Cjs.v.fromHexInput(d).toUint8Array()),f=Vi.deserialize(l);a.push(f)}o.set(_chunk4RHBBU7Cjs.w.call(void 0, s.issuer),a)}return o}var Vi=class n extends _chunk4RHBBU7Cjs.x{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(_chunk4RHBBU7Cjs.v.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw E.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk4RHBBU7Cjs.za.call(void 0, this.n),r=ud(e.reverse()).map(i=>Mt(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 ud(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 dd(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 L=class n extends ae{constructor(e,t){super(),this.jwkAddress=_chunk4RHBBU7Cjs.pa.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk4RHBBU7Cjs.y;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Ur({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk4RHBBU7Cjs.pa.deserialize(e),r=R.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Hi({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,R.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,R.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk4RHBBU7Cjs.pa&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof R}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ve=class Ve extends at{constructor(t){super();this.keyType="secp256k1";let r=_chunk4RHBBU7Cjs.v.fromHexInput(t),{length:i}=r.toUint8Array();if(i===Ve.LENGTH)this.key=r;else if(i===Ve.COMPRESSED_LENGTH){let o=_secp256k1.secp256k1.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk4RHBBU7Cjs.v.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ve.LENGTH} or ${Ve.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=yn(r),s=_chunk4RHBBU7Cjs.v.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new pt(r)}static deserialize(t){let r=t.deserializeBytes();return new Ve(r)}static isPublicKey(t){return t instanceof Ve}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _49 => _49.key, 'optionalAccess', _50 => _50.data, 'optionalAccess', _51 => _51.length])===Ve.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};Ve.LENGTH=65,Ve.COMPRESSED_LENGTH=33;var He=Ve,tt=class tt extends _chunk4RHBBU7Cjs.x{constructor(e,t){super();let r=Ie.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==tt.LENGTH)throw new Error(`PrivateKey length should be ${tt.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new tt(e,!1)}static fromDerivationPath(e,t){if(!ls(e))throw new Error(`Invalid derivation path ${e}`);return tt.fromDerivationPathInner(e,Pr(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new tt(r,!1)}sign(e){let t=yn(e),r=_chunk4RHBBU7Cjs.v.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new pt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new He(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return Ie.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new tt(t,!1)}static isPrivateKey(e){return e instanceof tt}};tt.LENGTH=32;var dt=tt,gn=class gn extends O{constructor(e){super();let t=_chunk4RHBBU7Cjs.v.fromHexInput(e);if(t.toUint8Array().length!==gn.LENGTH)throw new Error(`Signature length should be ${gn.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 gn(t)}};gn.LENGTH=64;var pt=gn;var _nistjs = require('@noble/curves/nist.js');var Ee=class Ee extends at{constructor(t){super();this.keyType="secp256r1";let r=_chunk4RHBBU7Cjs.v.fromHexInput(t),i=r.toUint8Array().length;if(i!==Ee.LENGTH&&i!==Ee.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${Ee.LENGTH} or ${Ee.COMPRESSED_LENGTH}, received ${i}`);if(i===Ee.COMPRESSED_LENGTH){let o=_nistjs.p256.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk4RHBBU7Cjs.v.fromHexInput(o.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let t=new _chunk4RHBBU7Cjs.y;return this.serialize(t),t.toUint8Array()}verifySignature(t){let{message:r,signature:i}=t,o=_chunk4RHBBU7Cjs.v.fromHexInput(r).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=i.toUint8Array();return _nistjs.p256.verify(a,s,this.toUint8Array())}async verifySignatureAsync(t){return this.verifySignature({message:t.message,signature:t.signature})}serialize(t){t.serializeBytes(this.key.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new Ee(r)}static load(t){let r=t.deserializeBytes();return new Ee(r)}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _52 => _52.key, 'optionalAccess', _53 => _53.data, 'optionalAccess', _54 => _54.length])===Ee.LENGTH&&"keyType"in t&&t.keyType==="secp256r1"}authKey(){let t=new _chunk4RHBBU7Cjs.y;return t.serializeU32AsUleb128(2),t.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:t.toUint8Array()})}};Ee.LENGTH=65,Ee.COMPRESSED_LENGTH=33;var An=Ee,Lt=class Lt extends Ie{constructor(e,t){super();let r=Ie.parseHexInput(e,"secp256r1",t),i=r.toUint8Array().length;if(i!==Lt.LENGTH)throw new Error(`PrivateKey length should be ${Lt.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return Ie.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(e){let t=_chunk4RHBBU7Cjs.v.fromHexInput(e),r=_sha3.sha3_256.call(void 0, t.toUint8Array()),i=_nistjs.p256.sign(r,this.key.toUint8Array());return new Li(i.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Lt(t)}static generate(){let e=_nistjs.p256.utils.randomPrivateKey();return new Lt(e)}publicKey(){let e=_nistjs.p256.getPublicKey(this.key.toUint8Array(),!1);return new An(e)}};Lt.LENGTH=32;var Ns=Lt,Qn= exports.WebAuthnSignature =class n extends O{constructor(e,t,r){super(),this.signature=_chunk4RHBBU7Cjs.v.fromHexInput(e),this.authenticatorData=_chunk4RHBBU7Cjs.v.fromHexInput(t),this.clientDataJSON=_chunk4RHBBU7Cjs.v.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.signature.toUint8Array()),e.serializeBytes(this.authenticatorData.toUint8Array()),e.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let e=new _chunk4RHBBU7Cjs.y;return this.serialize(e),e.toUint8Array()}bcsToHex(){return _chunk4RHBBU7Cjs.v.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return _chunk4RHBBU7Cjs.v.fromHexInput(this.bcsToBytes()).toString()}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Invalid id for WebAuthnSignature: ${t}`);let r=e.deserializeBytes(),i=e.deserializeBytes(),o=e.deserializeBytes();return new n(r,i,o)}},mn=class mn extends O{constructor(e){super();let t=_chunk4RHBBU7Cjs.v.fromHexInput(e),r=t.toUint8Array().length;if(r!==mn.LENGTH)throw new Error(`Signature length should be ${mn.LENGTH}, received ${r}`);let i=_nistjs.p256.Signature.fromCompact(t.toUint8Array()).normalizeS().toCompactRawBytes();this.data=_chunk4RHBBU7Cjs.v.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new mn(t)}};mn.LENGTH=64;var Li=mn;var x=class n extends ae{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof He)this.variant=1;else if(e instanceof An)this.variant=2;else if(e instanceof R)this.variant=3;else if(e instanceof L)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof R)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 G)){if(_optionalChain([e, 'access', _55 => _55.options, 'optionalAccess', _56 => _56.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 H.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=P.deserialize(e);break;case 1:r=He.deserialize(e);break;case 2:r=An.deserialize(e);break;case 3:r=R.deserialize(e);break;case 4:r=L.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 P}isSecp256k1PublicKey(){return this.publicKey instanceof He}static isInstance(e){return"publicKey"in e&&"variant"in e}},G= exports.AnySignature =class n extends O{constructor(e){if(super(),this.signature=e,e instanceof U)this.variant=0;else if(e instanceof pt)this.variant=1;else if(e instanceof Qn)this.variant=2;else if(e instanceof ce)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=U.deserialize(e);break;case 1:r=pt.deserialize(e);break;case 2:r=Qn.deserialize(e);break;case 3:r=ce.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 ld(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var zr=3,qe= exports.AbstractMultiKey =class extends ae{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}`)}},W= exports.MultiKey =class n extends qe{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`);if(this.publicKeys=t.map(i=>i instanceof x?i:new x(i)),r>zr&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>zr)throw new Error(`Construction of MultiKey with more than ${zr} keyless public keys is not allowed when signaturesRequired
7
- is greater than ${zr}. This is because a maximum of 3 keyless signatures are supported for a
8
- K-of-N MultiKey transaction.`);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 _e))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', _57 => _57.options, 'optionalAccess', _58 => _58.throwErrorWithReason]))throw r;return!1}}authKey(){return H.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(x),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof x?e:new x(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},fe=class fe extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>fe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${fe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof G?o:new G(o)),!(r instanceof Uint8Array))this.bitmap=fe.createBitmap({bits:r});else{if(r.length!==fe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${fe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+ld(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>=fe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${fe.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(G),r=e.deserializeBytes();return new fe({signatures:t,bitmap:r})}};fe.BITMAP_LEN=4,fe.MAX_SIGNATURES_SUPPORTED=fe.BITMAP_LEN*8;var _e=fe;var Ae=class Ae extends qe{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>Ae.MAX_KEYS||t.length<Ae.MIN_KEYS)throw new Error(`Must have between ${Ae.MIN_KEYS} and ${Ae.MAX_KEYS} public keys, inclusive`);if(r<Ae.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${Ae.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 Le))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 H.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*P.LENGTH)}),e[this.publicKeys.length*P.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+=P.LENGTH){let s=o;i.push(new P(t.subarray(s,s+P.LENGTH)))}return new Ae({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+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new Ae({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};Ae.MAX_KEYS=32,Ae.MIN_KEYS=2,Ae.MIN_THRESHOLD=1;var ie=Ae,he=class he extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>he.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${he.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=he.createBitmap({bits:r});else{if(r.length!==he.BITMAP_LEN)throw new Error(`"bitmap" length should be ${he.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*U.LENGTH+he.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*U.LENGTH)}),e.set(this.bitmap,this.signatures.length*U.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+=U.LENGTH){let s=o;i.push(new U(t.subarray(s,s+U.LENGTH)))}return new he({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>=he.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${he.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}};he.MAX_SIGNATURES_SUPPORTED=32,he.BITMAP_LEN=4;var Le=he;var yn=n=>typeof n=="string"?_chunk4RHBBU7Cjs.v.isValid(n).valid?n:new TextEncoder().encode(n):n,$i=n=>{if(n instanceof P||n instanceof x||n instanceof ie||n instanceof W)return n;if(n instanceof R||n instanceof L)return new x(n);throw new Error(`Unknown account public key: ${n}`)},Bs=n=>{let e=$i(n);if(e instanceof P)return 0;if(e instanceof x)return 2;if(e instanceof ie)return 1;if(e instanceof W)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var Wi=[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 gd(n){let e=n.toUint8Array().slice(32);for(let t=Wi.length-1;t>=0;t-=1){if(e[t]<Wi[t])return!0;if(e[t]>Wi[t])return!1}return!1}var Nt=class Nt extends ae{constructor(e){super();let t=_chunk4RHBBU7Cjs.v.fromHexInput(e);if(t.toUint8Array().length!==Nt.LENGTH)throw new Error(`PublicKey length should be ${Nt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!gd(r))return!1;let i=yn(t),o=_chunk4RHBBU7Cjs.v.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 H.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 Nt(t)}static isPublicKey(e){return e instanceof Nt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _59 => _59.key, 'optionalAccess', _60 => _60.data, 'optionalAccess', _61 => _61.length])===Nt.LENGTH}};Nt.LENGTH=32;var P=Nt,xe=class xe extends _chunk4RHBBU7Cjs.x{constructor(e,t){super();let r=Ie.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==xe.LENGTH)throw new Error(`PrivateKey length should be ${xe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new xe(e,!1)}static fromDerivationPath(e,t){if(!gs(e))throw new Error(`Invalid derivation path ${e}`);return xe.fromDerivationPathInner(e,Pr(t))}static fromDerivationPathInner(e,t,r=ps){let{key:i,chainCode:o}=_i(xe.SLIP_0010_SEED,t),s=ms(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>ys(c,d+r),{key:i,chainCode:o});return new xe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let t=yn(e),r=_chunk4RHBBU7Cjs.v.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new U(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Ie.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new xe(t,!1)}static isPrivateKey(e){return e instanceof xe}};xe.LENGTH=32,xe.SLIP_0010_SEED="ed25519 seed";var J=xe,hn=class hn extends O{constructor(e){super();let t=_chunk4RHBBU7Cjs.v.fromHexInput(e);if(t.toUint8Array().length!==hn.LENGTH)throw new Error(`Signature length should be ${hn.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 hn(t)}};hn.LENGTH=64;var U=hn;var Dr="Multiple possible deserializations found";function qf(n){let e=[P,x,ie,W,R,L,He],t;for(let r of e)try{let i=K.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Dr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Dr))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function Lf(n){let e=[U,G,Le,_e,ce,pt],t;for(let r of e)try{let i=K.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Dr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Dr))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var te=class extends _chunk4RHBBU7Cjs.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return $e.load(e);case 1:return lt.load(e);case 2:return ue.load(e);case 3:return nt.load(e);case 4:return bn.load(e);case 5:return $t.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof $e}isMultiEd25519(){return this instanceof lt}isSingleKey(){return this instanceof ue}isMultiKey(){return this instanceof nt}},$e= exports.AccountAuthenticatorEd25519 =class n extends te{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),r=U.deserialize(e);return new n(t,r)}},lt= exports.AccountAuthenticatorMultiEd25519 =class n extends te{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=ie.deserialize(e),r=Le.deserialize(e);return new n(t,r)}},ue= exports.AccountAuthenticatorSingleKey =class n extends te{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=x.deserialize(e),r=G.deserialize(e);return new n(t,r)}},nt= exports.AccountAuthenticatorMultiKey =class n extends te{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=W.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},bn= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends te{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},$t= exports.AccountAuthenticatorAbstraction =class n extends te{constructor(e,t,r,i){if(super(),!_chunk4RHBBU7Cjs.Fa.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=_chunk4RHBBU7Cjs.v.fromHexInput(_chunk4RHBBU7Cjs.v.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk4RHBBU7Cjs.Ea.call(void 0, this.functionInfo);_chunk4RHBBU7Cjs.pa.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.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk4RHBBU7Cjs.pa.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},Fr= exports.AccountAbstractionMessage =class n extends _chunk4RHBBU7Cjs.x{constructor(e,t){super(),this.originalSigningMessage=_chunk4RHBBU7Cjs.v.fromHexInput(_chunk4RHBBU7Cjs.v.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=_chunk4RHBBU7Cjs.Ea.call(void 0, this.functionInfo);_chunk4RHBBU7Cjs.pa.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=_chunk4RHBBU7Cjs.pa.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};var Tn=class n extends _chunk4RHBBU7Cjs.x{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 _chunk4RHBBU7Cjs.x{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var jn=class n extends _chunk4RHBBU7Cjs.x{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(_chunk4RHBBU7Cjs.pa.fromString(t[0]),new F(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk4RHBBU7Cjs.pa.deserialize(e),r=F.deserialize(e);return new n(t,r)}};var z=class n extends _chunk4RHBBU7Cjs.x{deserialize(e){let t=_chunk4RHBBU7Cjs.pa.deserialize(e),r=F.deserialize(e),i=F.deserialize(e),o=e.deserializeVector(n);return new rt(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Q.load(e);case 1:return de.load(e);case 2:return ne.load(e);case 3:return bt.load(e);case 4:return M.load(e);case 5:return Wt.load(e);case 6:return k.load(e);case 7:return h.load(e);case 8:return yt.load(e);case 9:return ft.load(e);case 10:return wt.load(e);case 11:return gt.load(e);case 12:return mt.load(e);case 13:return At.load(e);case 14:return ht.load(e);case 15:return Tt.load(e);case 16:return St.load(e);case 255:return V.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof Q}isAddress(){return this instanceof M}isGeneric(){return this instanceof V}isSigner(){return this instanceof Wt}isVector(){return this instanceof k}isStruct(){return this instanceof h}isU8(){return this instanceof de}isU16(){return this instanceof yt}isU32(){return this instanceof ft}isU64(){return this instanceof ne}isU128(){return this instanceof bt}isU256(){return this instanceof wt}isI8(){return this instanceof gt}isI16(){return this instanceof mt}isI32(){return this instanceof At}isI64(){return this instanceof ht}isI128(){return this instanceof Tt}isI256(){return this instanceof St}isPrimitive(){return this instanceof Wt||this instanceof M||this instanceof Q||this instanceof de||this instanceof yt||this instanceof ft||this instanceof ne||this instanceof bt||this instanceof wt||this instanceof gt||this instanceof mt||this instanceof At||this instanceof ht||this instanceof Tt||this instanceof St}},Q= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},de= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},gt= exports.TypeTagI8 =class n extends z{toString(){return"i8"}serialize(e){e.serializeU32AsUleb128(11)}static load(e){return new n}},yt= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},mt= exports.TypeTagI16 =class n extends z{toString(){return"i16"}serialize(e){e.serializeU32AsUleb128(12)}static load(e){return new n}},ft= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},At= exports.TypeTagI32 =class n extends z{toString(){return"i32"}serialize(e){e.serializeU32AsUleb128(13)}static load(e){return new n}},ne= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},ht= exports.TypeTagI64 =class n extends z{toString(){return"i64"}serialize(e){e.serializeU32AsUleb128(14)}static load(e){return new n}},bt= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Tt= exports.TypeTagI128 =class n extends z{toString(){return"i128"}serialize(e){e.serializeU32AsUleb128(15)}static load(e){return new n}},wt= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},St= exports.TypeTagI256 =class n extends z{toString(){return"i256"}serialize(e){e.serializeU32AsUleb128(16)}static load(e){return new n}},M= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Wt= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Nr= 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)}},V= 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)}},k= exports.TypeTagVector =class n extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new de)}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=rt.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(_chunk4RHBBU7Cjs.pa.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk4RHBBU7Cjs.pa.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk4RHBBU7Cjs.pa.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk4RHBBU7Cjs.pa.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk4RHBBU7Cjs.pa.ONE,"rate_limiter","RateLimiter")}},rt= exports.StructTag =class n extends _chunk4RHBBU7Cjs.x{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=_chunk4RHBBU7Cjs.pa.deserialize(e),r=F.deserialize(e),i=F.deserialize(e),o=e.deserializeVector(z);return new n(t,r,i,o)}};function qA(){return new rt(_chunk4RHBBU7Cjs.pa.ONE,new F("aptos_coin"),new F("AptosCoin"),[])}function C(){return new rt(_chunk4RHBBU7Cjs.pa.ONE,new F("string"),new F("String"),[])}function LA(n){return new rt(_chunk4RHBBU7Cjs.pa.ONE,new F("option"),new F("Option"),[n])}function be(n){return new rt(_chunk4RHBBU7Cjs.pa.ONE,new F("object"),new F("Object"),[n])}function yd(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return ee.deserialize(n);case 1:return $.deserialize(n);case 2:return ke.deserialize(n);case 3:return _chunk4RHBBU7Cjs.pa.deserialize(n);case 4:return S.deserialize(n,ee);case 5:return N.deserialize(n);case 6:return Ue.deserialize(n);case 7:return ze.deserialize(n);case 8:return Se.deserialize(n);case 9:return Gn.deserialize(n);case 10:return De.deserialize(n);case 11:return Fe.deserialize(n);case 12:return Ne.deserialize(n);case 13:return Oe.deserialize(n);case 14:return Be.deserialize(n);case 15:return Ge.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Ot=class extends _chunk4RHBBU7Cjs.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return wn.load(e);case 2:return Sn.load(e);case 3:return In.load(e);case 4:return Or.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},wn= exports.TransactionPayloadScript =class n extends Ot{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Pn.deserialize(e);return new n(t)}},Sn= exports.TransactionPayloadEntryFunction =class n extends Ot{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=It.deserialize(e);return new n(t)}},In= exports.TransactionPayloadMultiSig =class n extends Ot{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Jn.deserialize(e);return new n(t)}},It= 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(jn.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=jn.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=Sr.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},Pn= 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=yd(e);o.push(a)}return new n(t,r,o)}},Jn= 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=_chunk4RHBBU7Cjs.pa.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Xn.deserialize(e)),new n(t,i)}},Xn= exports.MultiSigTransactionPayload =class n extends _chunk4RHBBU7Cjs.x{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(It.deserialize(e))}},Or= exports.TransactionInnerPayload =class extends Ot{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Qt.load(e);default:throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}}},Qt= exports.TransactionInnerPayloadV1 =class n extends Or{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=En.deserialize(e),r=Br.deserialize(e);return new n(t,r)}},En= exports.TransactionExecutable =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Yn.load(e);case 1:return _n.load(e);case 2:return Zn.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},Yn= exports.TransactionExecutableScript =class n extends En{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Pn.deserialize(e);return new n(t)}},_n= exports.TransactionExecutableEntryFunction =class n extends En{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=It.deserialize(e);return new n(t)}},Zn= exports.TransactionExecutableEmpty =class n extends En{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Br= exports.TransactionExtraConfig =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return jt.load(e);default:throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}}},jt= exports.TransactionExtraConfigV1 =class n extends Br{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new $(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(_chunk4RHBBU7Cjs.pa),r=e.deserializeOption($);return new n(t,_optionalChain([r, 'optionalAccess', _62 => _62.value]))}};var Ce=class n extends _chunk4RHBBU7Cjs.x{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=_chunk4RHBBU7Cjs.pa.deserialize(e),r=e.deserializeU64(),i=Ot.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)}},Gr= exports.RawTransactionWithData =class extends _chunk4RHBBU7Cjs.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Jt.load(e);case 1:return Xt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Jt= exports.MultiAgentRawTransaction =class n extends Gr{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=Ce.deserialize(e),r=e.deserializeVector(_chunk4RHBBU7Cjs.pa);return new n(t,r)}},Xt= exports.FeePayerRawTransaction =class n extends Gr{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=Ce.deserialize(e),r=e.deserializeVector(_chunk4RHBBU7Cjs.pa),i=_chunk4RHBBU7Cjs.pa.deserialize(e);return new n(t,r,i)}};var Mr=class extends _chunk4RHBBU7Cjs.x{constructor(t){super();this.accountAddress=_chunk4RHBBU7Cjs.pa.ONE;this.moduleName=new v("account");this.structName=new v("RotationProofChallenge");this.sequenceNumber=new $(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 Pt=class extends _chunk4RHBBU7Cjs.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Yt.load(e);case 1:return xn.load(e);case 2:return Zt.load(e);case 3:return en.load(e);case 4:return Bt.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Yt}isMultiEd25519(){return this instanceof xn}isMultiAgent(){return this instanceof Zt}isFeePayer(){return this instanceof en}isSingleSender(){return this instanceof Bt}},Yt= exports.TransactionAuthenticatorEd25519 =class n extends Pt{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),r=U.deserialize(e);return new n(t,r)}},xn= exports.TransactionAuthenticatorMultiEd25519 =class n extends Pt{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=ie.deserialize(e),r=Le.deserialize(e);return new n(t,r)}},Zt= exports.TransactionAuthenticatorMultiAgent =class n extends Pt{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=te.deserialize(e),r=e.deserializeVector(_chunk4RHBBU7Cjs.pa),i=e.deserializeVector(te);return new n(t,r,i)}},en= exports.TransactionAuthenticatorFeePayer =class n extends Pt{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=te.deserialize(e),r=e.deserializeVector(_chunk4RHBBU7Cjs.pa),i=e.deserializeVector(te),o=_chunk4RHBBU7Cjs.pa.deserialize(e),s=te.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},Bt= exports.TransactionAuthenticatorSingleSender =class n extends Pt{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=te.deserialize(e);return new n(t)}};var Et=class n extends _chunk4RHBBU7Cjs.x{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=Ce.deserialize(e),r=Pt.deserialize(e);return new n(t,r)}};var Vr=class n extends _chunk4RHBBU7Cjs.x{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=Ce.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk4RHBBU7Cjs.pa.deserialize(e)),new n(t,i)}};var Hr=class n extends _chunk4RHBBU7Cjs.x{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=Ce.deserialize(e),r=e.deserializeVector(_chunk4RHBBU7Cjs.pa),i=e.deserializeBool(),o;return i&&(o=_chunk4RHBBU7Cjs.pa.deserialize(e)),new n(t,r,o)}};function qr(n){return n.feePayerAddress?new Xt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Jt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function et(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 ib(n){return et(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function We(n){let e=qr(n);return n.feePayerAddress?et(e.bcsToBytes(),zi):n.secondarySignerAddresses?et(e.bcsToBytes(),zi):et(e.bcsToBytes(),Es)}var oe=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk4RHBBU7Cjs.pa.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=J.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=J.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 $e(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new $e(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(We(e))}};function Qi(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var pe=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new x(t.publicKey()),this.accountAddress=r?_chunk4RHBBU7Cjs.pa.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=J.generate();break;case 2:r=dt.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=J.fromDerivationPath(r,i);break;case 2:o=dt.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 ue(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ue(this.publicKey,this.signTransaction(e))}sign(e){return new G(this.privateKey.sign(e))}signTransaction(e){return this.sign(We(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var _t=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?oe.generate():pe.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof J&&i?new oe({privateKey:t,address:r}):new pe({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?oe.fromDerivationPath({mnemonic:r,path:i}):pe.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 Ad=1209600,Cn=class Cn extends _chunk4RHBBU7Cjs.x{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new zt(t.publicKey()),this.expiryDateSecs=r||_chunk4RHBBU7Cjs.xa.call(void 0, _chunk4RHBBU7Cjs.wa.call(void 0, )+Ad),this.blinder=i!==void 0?_chunk4RHBBU7Cjs.v.fromHexInput(i).toUint8Array():hd();let o=Hn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Mt(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=J.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Cn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Cn.deserialize(new K(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _63 => _63.scheme])){case 0:default:t=J.generate()}return new Cn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _64 => _64.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Je(this.privateKey.sign(e))}};Cn.BLINDER_LENGTH=31;var tn=Cn;function hd(){return _utils3.randomBytes.call(void 0, tn.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function $r(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var vn=class vn extends _chunk4RHBBU7Cjs.x{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:y}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk4RHBBU7Cjs.pa.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 me)this.proof=l;else{if(f===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async D=>{await f(D),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk4RHBBU7Cjs.v.fromHexInput(d).toUint8Array();if(b.length!==vn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${vn.PEPPER_LENGTH}`);if(this.pepper=b,y!==void 0){if(_chunk4RHBBU7Cjs.v.hexInputToUint8Array(y).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk4RHBBU7Cjs.v.hexInputToUint8Array(y)}}getAnyPublicKey(){return new x(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=_chunk4RHBBU7Cjs.pa.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=tn.deserialize(t),c=me.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 G(this.sign(t)),i=new x(this.publicKey);return new ue(i,r)}signTransactionWithAuthenticator(t){let r=new G(this.signTransaction(t)),i=new x(this.publicKey);return new ue(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw E.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw E.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw E.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await ln({aptosConfig:t});if(_chunk4RHBBU7Cjs.v.hexInputToString(i.hash())!==_chunk4RHBBU7Cjs.v.hexInputToString(this.verificationKeyHash))throw E.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 vn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw E.fromErrorType({type:0});if(this.proof===void 0)throw E.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 ce({jwtHeader:_chunk4RHBBU7Cjs.ya.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new dn(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw E.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=qr(t),o=new Lr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw E.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=qr(t);return new Lr(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 qi(t)}};vn.PEPPER_LENGTH=31;var Te=vn,Lr= exports.TransactionAndProof =class extends _chunk4RHBBU7Cjs.x{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 et(this.bcsToBytes(),this.domainSeparator)}};var ve=class n extends Te{constructor(e){let t=R.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}=Te.partialDeserialize(e),{iss:d,aud:l,uidVal:f}=ut({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(_chunk4RHBBU7Cjs.v.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:y}=ut({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:f,uidKey:a,uidVal:y,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:_nullishCoalesce(l, () => ((d?d.hash():void 0)))})}};var Qe=class n extends Te{constructor(e){let t=L.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}=Te.partialDeserialize(e),d=_chunk4RHBBU7Cjs.pa.deserialize(e),{iss:l,aud:f,uidVal:p}=ut({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:y,uidVal:b}=ut({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:b,aud:y,pepper:s,jwkAddress:_chunk4RHBBU7Cjs.pa.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:_nullishCoalesce(f, () => ((l?l.hash():void 0)))})}};var xt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof oe?pe.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?_chunk4RHBBU7Cjs.pa.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 W({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new nt(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new nt(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof Te).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof Te).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 _e({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new _e({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var er=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk4RHBBU7Cjs.pa.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 lt(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new lt(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Le({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(We(e))}};function Gs(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk4RHBBU7Cjs.ja).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk4RHBBU7Cjs.pa.deserialize(n),signingScheme:e}}function Ms(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 Vs(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=tn.deserialize(n),o=me.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Hs;(f=>{function n(p){let y=new _chunk4RHBBU7Cjs.y;switch(y.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(y),p.signingScheme){case 0:return p.privateKey.serialize(y),y.toUint8Array();case 2:{if(!Qi(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(y.serializeU32AsUleb128(b.variant),b.variant){case 3:return Ms(p,y),y.toUint8Array();case 4:{let D=p;return Ms(D,y),D.publicKey.jwkAddress.serialize(y),y.serializeBool(D.audless),y.toUint8Array()}case 1:case 0:return p.privateKey.serialize(y),y.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(y),y.serializeU32AsUleb128(b.signers.length),b.signers.forEach(D=>{y.serializeFixedBytes(n(D))}),y.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}f.toBytes=n;function e(p){return _chunk4RHBBU7Cjs.v.hexInputToStringWithoutPrefix(n(p))}f.toHexStringWithoutPrefix=e;function t(p){return _chunk4RHBBU7Cjs.v.hexInputToString(n(p))}f.toHexString=t;function r(p){let{address:y,signingScheme:b}=Gs(p);switch(b){case 0:{let D=J.deserialize(p);return new oe({privateKey:D,address:y})}case 2:{let D=p.deserializeUleb128AsU32();switch(D){case 0:{let Y=J.deserialize(p);return new pe({privateKey:Y,address:y})}case 1:{let Y=dt.deserialize(p);return new pe({privateKey:Y,address:y})}case 3:{let Y=Vs(p),re=ut(Y);return new ve({...Y,...re})}case 4:{let Y=Vs(p),re=_chunk4RHBBU7Cjs.pa.deserialize(p),Kt=p.deserializeBool(),ot=ut(Y);return new Qe({...Y,...ot,jwkAddress:re,audless:Kt})}default:throw new Error(`Unsupported public key variant ${D}`)}}case 3:{let D=W.deserialize(p),Y=p.deserializeUleb128AsU32(),re=new Array;for(let Kt=0;Kt<Y;Kt+=1){let ot=r(p);if(!Qi(ot)&&!(ot instanceof oe))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");re.push(ot)}return new xt({multiKey:D,signers:re,address:y})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}f.deserialize=r;function i(p){let y=d(p);if(!(y instanceof ve))throw new Error("Deserialization of KeylessAccount failed");return y}f.keylessAccountFromHex=i;function o(p){let y=d(p);if(!(y instanceof Qe))throw new Error("Deserialization of FederatedKeylessAccount failed");return y}f.federatedKeylessAccountFromHex=o;function s(p){let y=d(p);if(!(y instanceof xt))throw new Error("Deserialization of MultiKeyAccount failed");return y}f.multiKeyAccountFromHex=s;function a(p){let y=d(p);if(!(y instanceof pe))throw new Error("Deserialization of SingleKeyAccount failed");return y}f.singleKeyAccountFromHex=a;function c(p){let y=d(p);if(!(y instanceof oe))throw new Error("Deserialization of Ed25519Account failed");return y}f.ed25519AccountFromHex=c;function d(p){return r(K.fromHex(p))}f.fromHex=d;function l(p){return d(p)}f.fromBytes=l})(Hs||(Hs= exports.AccountUtils ={}));var Wr=class n extends _t{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk4RHBBU7Cjs.Fa.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new Ir(this.accountAddress),this.sign=o=>new Mn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk4RHBBU7Cjs.y;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new Fr(t,r);return et(i.bcsToBytes(),_s)}signWithAuthenticator(t){return new $t(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(We(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(We(t))}setSigner(t){this.sign=r=>new Mn(t(r))}};var tr=class tr extends Wr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk4RHBBU7Cjs.pa)(tr.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk4RHBBU7Cjs.Fa.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 _chunk4RHBBU7Cjs.y;_chunk4RHBBU7Cjs.pa.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk4RHBBU7Cjs.y;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([tr.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new $t(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};tr.ADDRESS_DOMAIN_SEPERATOR=5;var Ls=tr;var wd=`
5
+ Error: ${_chunk2VR6ONNWjs.Ka.call(void 0, r)}`),o+=`
6
+ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Ds[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},_e= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(td({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 td({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _2 => _2.headers, 'optionalAccess', _3 => _3.traceparent, 'optionalAccess', _4 => _4.split, 'call', _5 => _5("-"), 'access', _6 => _6[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', _7 => _7.data, 'optionalAccess', _8 => _8.errors, 'optionalAccess', _9 => _9[0], 'optionalAccess', _10 => _10.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.message])!=null&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${nd(t.data)}`}var Fi=400;function nd(n){let e=JSON.stringify(n);return e.length<=Fi?e:`truncated(original_size:${e.length}): ${e.slice(0,Fi/2)}...${e.slice(-Fi/2)}`}async function rd(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _15 => _15.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Ks}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _16 => _16.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _17 => _17.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _18 => _18.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _19 => _19.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a,http2:_optionalChain([a, 'optionalAccess', _20 => _20.http2])})}async function Kr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await rd({...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 _e({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new _e({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new _e({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new _e({apiType:t,aptosRequest:n,aptosResponse:a})}async function Rr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return Kr({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function q(n){let{aptosConfig:e}=n;return Rr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.fullnodeConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}async function gy(n){return Rr({...n,type:"Pepper"})}async function Ur(n){let e=[],t,r=n.params;do{let i=await Rr({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=e.concat(i.data),r.start=t}while(t!=null);return e}async function Oi(n){let e=[],t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await zr({...n});if(t=s,e=e.concat(o.data),_optionalChain([n, 'optionalAccess', _25 => _25.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 zr(n){let e={};typeof _optionalChain([n, 'access', _26 => _26.params, 'optionalAccess', _27 => _27.cursor])=="string"&&(e.start=n.params.cursor),typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.limit])=="number"&&(e.limit=n.params.limit);let t=await Rr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:e,overrides:n.overrides}),r=_nullishCoalesce(t.headers["x-aptos-cursor"], () => (void 0));return{response:t,cursor:r}}async function Wn(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 Kr({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function dt(n){let{aptosConfig:e}=n;return Wn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _30 => _30.clientConfig, 'optionalAccess', _31 => _31.HEADERS]),..._optionalChain([e, 'access', _32 => _32.fullnodeConfig, 'optionalAccess', _33 => _33.HEADERS])}}})}async function Ns(n){let{aptosConfig:e}=n;return Wn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _34 => _34.clientConfig, 'optionalAccess', _35 => _35.HEADERS]),..._optionalChain([e, 'access', _36 => _36.indexerConfig, 'optionalAccess', _37 => _37.HEADERS])}}})}async function Fs(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _38 => _38.clientConfig, 'optionalAccess', _39 => delete _39.API_KEY]),Wn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([t, 'access', _42 => _42.faucetConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function Os(n){return Wn({...n,type:"Pepper"})}async function Gs(n){return Wn({...n,type:"Prover"})}var id=new Set;function od(n){if(!n||typeof n!="string")throw new Error("Cache key must be a non-empty string");if(n.length<10)throw new Error(`Cache key "${n}" is too short. Keys should be at least 10 characters and include a namespace prefix.`);let e=n.match(/^([a-z]+-[a-z]+-)/i);e&&id.add(e[1])}var et=new Map,Nt=null;function sd(){Nt===null&&(Nt=setInterval(()=>{let n=Date.now(),e=[];et.forEach((t,r)=>{t.ttlMs!==void 0&&n-t.timestamp>t.ttlMs&&e.push(r)}),e.forEach(t=>et.delete(t)),et.size===0&&Nt!==null&&(clearInterval(Nt),Nt=null)},6e4),typeof Nt=="object"&&"unref"in Nt&&Nt.unref())}function ad(){if(et.size>=1e3){let n=Math.ceil(100),e=Array.from(et.entries()).sort((t,r)=>t[1].lastAccess-r[1].lastAccess);for(let t=0;t<n&&t<e.length;t+=1)et.delete(e[t][0])}}function re(n,e,t){return od(e),async(...r)=>{let i=Date.now();if(et.has(e)){let s=et.get(e);if(t===void 0||i-s.timestamp<=t)return s.lastAccess=i,s.value;et.delete(e)}let o=await n(...r);return ad(),et.set(e,{value:o,timestamp:i,lastAccess:i,ttlMs:t}),sd(),o}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var pd=1e7,Gi= exports.MAX_AUD_VAL_BYTES =120,ld= exports.MAX_UID_KEY_BYTES =30,gd= exports.MAX_UID_VAL_BYTES =330,yd= exports.MAX_ISS_VAL_BYTES =120,md= exports.MAX_EXTRA_FIELD_BYTES =350,fd= exports.MAX_JWT_HEADER_B64_BYTES =300,Ad= exports.MAX_COMMITED_EPK_BYTES =93,tt=class tt extends ce{constructor(e,t){super();let r=_chunk2VR6ONNWjs.v.fromHexInput(t).toUint8Array();if(r.length!==tt.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${tt.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk2VR6ONNWjs.L;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return kr({...e,publicKey:this}),!0}catch(t){if(t instanceof I)return!1;throw t}}async verifySignatureAsync(e){return Li({...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 tt(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new tt(t,r)}static isPublicKey(e){return e instanceof tt}static create(e){return Bs(e),new tt(e.iss,Bs(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 tt.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}};tt.ID_COMMITMENT_LENGTH=32;var R=tt;async function Li(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await yn({aptosConfig:e}),options:a}=n;try{if(!(i instanceof ue))throw I.fromErrorType({type:26,details:"Not a keyless signature"});return kr({message:r,publicKey:t,signature:i,jwk:o||await $i({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _44 => _44.throwErrorWithReason]))throw c;return!1}}function kr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof ue))throw I.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof fe))throw I.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof Ft))throw I.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<_chunk2VR6ONNWjs.La.call(void 0, ))throw I.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw I.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw I.fromErrorType({type:29});let f=hd({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:f,groth16Proof:l}))throw I.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw I.fromErrorType({type:30});let p=new Mi(l,f);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw I.fromErrorType({type:31})}}function hd(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof R?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof fe))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...$n(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(qt(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Ze(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Ze(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Ze(" ",i.maxExtraFieldBytes))),a.push(Ze(`${_jsbase64.encode.call(void 0, t.jwtHeader,!0)}.`,i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Ze(s.overrideAudVal,Gi)),a.push(1n)):(a.push(Ze("",Gi)),a.push(0n)),Lt(a)}async function $i(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof R?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof L?t.jwkAddress:void 0;try{s=await wd({aptosConfig:e,jwkAddr:a})}catch(l){throw I.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 I.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw I.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Bs(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[qt(_chunk2VR6ONNWjs.v.fromHexInput(i).toUint8Array()),Ze(r,Gi),Ze(t,gd),Ze(e,ld)];return Ui(Lt(o),R.ID_COMMITMENT_LENGTH)}var ue=class n extends O{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 Id(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=ln.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=Dt.deserialize(e),s=Ye.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new ln(new fe({proof:new gn(new Ft({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Dt(new P(new Uint8Array(32))),ephemeralSignature:new Ye(new U(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},ln= exports.EphemeralCertificate =class n extends O{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();if(t===0)return new n(fe.deserialize(e),t);throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}},Qn=class Qn extends _chunk2VR6ONNWjs.K{constructor(e){if(super(),this.data=_chunk2VR6ONNWjs.v.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 Qn(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(Bi(e)),o=r.sqrt(r.add(r.pow(i,3n),Qn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Qn.B=_bn254.bn254.fields.Fp.create(3n);var pt=Qn;function Bi(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]&=63,_utils.bytesToNumberBE.call(void 0, e)}var jn=class jn extends _chunk2VR6ONNWjs.K{constructor(e){if(super(),this.data=_chunk2VR6ONNWjs.v.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 jn(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([Bi(t),Bi(r)]),a=o.sqrt(o.add(o.pow(s,3n),jn.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})}};jn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var $t=jn,Ft= exports.Groth16Zkp =class n extends vr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new pt(t),this.b=new $t(r),this.c=new pt(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=pt.deserialize(e).bcsToBytes(),r=$t.deserialize(e).bcsToBytes(),i=pt.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()}}},Mi= exports.Groth16ProofAndStatement =class n extends _chunk2VR6ONNWjs.K{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?Ui(r,32):_chunk2VR6ONNWjs.v.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(Ft.deserialize(t),t.deserializeFixedBytes(32))}hash(){return nt(this.bcsToBytes(),this.domainSeparator)}},gn= exports.ZkProof =class n extends _chunk2VR6ONNWjs.K{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();if(t===0)return new n(Ft.deserialize(e),t);throw new Error(`Unknown variant index for ZkProof: ${t}`)}},fe= exports.ZeroKnowledgeSig =class n extends O{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=gn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ye);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Vi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=pd,maxExtraFieldBytes:o=md,maxJwtHeaderB64Bytes:s=fd,maxIssValBytes:a=yd,maxCommitedEpkBytes:c=Ad}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new Dt(new P(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new Hi({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})}},Hi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new pt(t),this.betaG2=new $t(r),this.deltaG2=new $t(i),this.gammaAbcG1=[new pt(o[0]),new pt(o[1])],this.gammaG2=new $t(s)}hash(){let e=new _chunk2VR6ONNWjs.L;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(at=>at.toProjectivePoint()),{Fp12:p}=_bn254.bn254.fields,y=f[0].add(f[1].multiply(t)),b=_bn254.bn254.pairing(y,d),D=_bn254.bn254.pairing(i,o),Y=_bn254.bn254.pairing(a,c),ae=_bn254.bn254.pairing(s,l),Ie=p.mul(Y,p.mul(b,ae));return p.eql(D,Ie)}catch(i){throw I.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 yn(n){let{aptosConfig:e}=n;try{return await re(async()=>{let[t,r]=await Promise.all([bd(n),Td(n)]);return Vi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof I?t:I.fromErrorType({type:25,error:t})}}function lt(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch (e2){throw I.fromErrorType({type:12,details:"Invalid JWT format"})}if(typeof r.iss!="string")throw I.fromErrorType({type:12,details:"Invalid JWT: missing required claim"});if(typeof r.aud!="string")throw I.fromErrorType({type:12,details:"Invalid JWT: missing or malformed required claim"});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function bd(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await q({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk2VR6ONNWjs.Ca.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw I.fromErrorType({type:22,error:i})}}async function Td(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await q({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk2VR6ONNWjs.Ca.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _46 => _46.ledgerVersion])}});return i.data}catch(i){throw I.fromErrorType({type:23,error:i})}}async function wd(n){let{aptosConfig:e,jwkAddr:t,options:r,useCache:i=!0}=n,o=t?_chunk2VR6ONNWjs.Ca.from(t).toString():"0x1",s=`keyless-jwks-${e.network}-${o}`;return i&&!_optionalChain([r, 'optionalAccess', _47 => _47.ledgerVersion])?re(async()=>Ms({aptosConfig:e,jwkAddr:t,options:r}),s,1e3*60*5)():Ms({aptosConfig:e,jwkAddr:t,options:r})}async function Ms(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _48 => _48.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _49 => _49.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(_chunk2VR6ONNWjs.v.fromHexInput(d).toUint8Array()),f=qi.deserialize(l);a.push(f)}o.set(_chunk2VR6ONNWjs.w.call(void 0, s.issuer),a)}return o}var qi=class n extends _chunk2VR6ONNWjs.K{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(_chunk2VR6ONNWjs.v.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw I.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk2VR6ONNWjs.Oa.call(void 0, this.n),r=Sd(e.reverse()).map(i=>qt(i));return r.push(256n),Lt(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 Sd(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 Id(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw I.fromErrorType({type:12,details:"Invalid JWT header: missing required field"});return e}catch(e){throw e instanceof I?e:I.fromErrorType({type:12,details:"Invalid JWT header format"})}}var L=class n extends ce{constructor(e,t){super(),this.jwkAddress=_chunk2VR6ONNWjs.Ca.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk2VR6ONNWjs.L;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return kr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk2VR6ONNWjs.Ca.deserialize(e),r=R.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Li({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,R.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,R.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk2VR6ONNWjs.Ca&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof R}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var qe=class qe extends ut{constructor(t){super();this.keyType="secp256k1";let r=_chunk2VR6ONNWjs.v.fromHexInput(t),{length:i}=r.toUint8Array();if(i===qe.LENGTH)this.key=r;else if(i===qe.COMPRESSED_LENGTH){let o=_secp256k1.secp256k1.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk2VR6ONNWjs.v.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${qe.LENGTH} or ${qe.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=fn(r),s=_chunk2VR6ONNWjs.v.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new yt(r)}static deserialize(t){let r=t.deserializeBytes();return new qe(r)}static isPublicKey(t){return t instanceof qe}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _50 => _50.key, 'optionalAccess', _51 => _51.data, 'optionalAccess', _52 => _52.length])===qe.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};qe.LENGTH=65,qe.COMPRESSED_LENGTH=33;var Le=qe,rt=class rt extends _chunk2VR6ONNWjs.K{constructor(t,r){super();this.cleared=!1;let i=Pe.parseHexInput(t,"secp256k1",r);if(i.toUint8Array().length!==rt.LENGTH)throw new Error(`PrivateKey length should be ${rt.LENGTH}`);this.key=i}static generate(){let t=_secp256k1.secp256k1.utils.randomPrivateKey();return new rt(t,!1)}static fromDerivationPath(t,r){if(!Es(t))throw new Error(`Invalid derivation path ${t}`);return rt.fromDerivationPathInner(t,xr(r))}static fromDerivationPathInner(t,r){let{privateKey:i}=_bip32.HDKey.fromMasterSeed(r).derive(t);if(i===null)throw new Error("Invalid key");return new rt(i,!1)}ensureNotCleared(){if(this.cleared)throw new Error("Private key has been cleared from memory and can no longer be used")}clear(){if(!this.cleared){let t=this.key.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0),this.cleared=!0}}isCleared(){return this.cleared}sign(t){this.ensureNotCleared();let r=fn(t),i=_chunk2VR6ONNWjs.v.fromHexInput(r),o=_sha3.sha3_256.call(void 0, i.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new yt(s.toCompactRawBytes())}publicKey(){this.ensureNotCleared();let t=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Le(t)}toUint8Array(){return this.ensureNotCleared(),this.key.toUint8Array()}toString(){return this.ensureNotCleared(),this.toAIP80String()}toHexString(){return this.ensureNotCleared(),this.key.toString()}toAIP80String(){return this.ensureNotCleared(),Pe.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new rt(r,!1)}static isPrivateKey(t){return t instanceof rt}};rt.LENGTH=32;var gt=rt,mn=class mn extends O{constructor(e){super();let t=_chunk2VR6ONNWjs.v.fromHexInput(e);if(t.toUint8Array().length!==mn.LENGTH)throw new Error(`Signature length should be ${mn.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 mn(t)}};mn.LENGTH=64;var yt=mn;var _nist = require('@noble/curves/nist');var xe=class xe extends ut{constructor(t){super();this.keyType="secp256r1";let r=_chunk2VR6ONNWjs.v.fromHexInput(t),i=r.toUint8Array().length;if(i!==xe.LENGTH&&i!==xe.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${xe.LENGTH} or ${xe.COMPRESSED_LENGTH}, received ${i}`);if(i===xe.COMPRESSED_LENGTH){let o=_nist.p256.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk2VR6ONNWjs.v.fromHexInput(o.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let t=new _chunk2VR6ONNWjs.L;return this.serialize(t),t.toUint8Array()}verifySignature(t){let{message:r,signature:i}=t,o=_chunk2VR6ONNWjs.v.fromHexInput(r).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=i.toUint8Array();return _nist.p256.verify(a,s,this.toUint8Array())}async verifySignatureAsync(t){return this.verifySignature({message:t.message,signature:t.signature})}serialize(t){t.serializeBytes(this.key.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new xe(r)}static load(t){let r=t.deserializeBytes();return new xe(r)}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _53 => _53.key, 'optionalAccess', _54 => _54.data, 'optionalAccess', _55 => _55.length])===xe.LENGTH&&"keyType"in t&&t.keyType==="secp256r1"}authKey(){let t=new _chunk2VR6ONNWjs.L;return t.serializeU32AsUleb128(2),t.serializeFixedBytes(this.bcsToBytes()),H.fromSchemeAndBytes({scheme:2,input:t.toUint8Array()})}};xe.LENGTH=65,xe.COMPRESSED_LENGTH=33;var bn=xe,Wt=class Wt extends Pe{constructor(e,t){super();let r=Pe.parseHexInput(e,"secp256r1",t),i=r.toUint8Array().length;if(i!==Wt.LENGTH)throw new Error(`PrivateKey length should be ${Wt.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return Pe.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(e){let t=_chunk2VR6ONNWjs.v.fromHexInput(e),r=_sha3.sha3_256.call(void 0, t.toUint8Array()),i=_nist.p256.sign(r,this.key.toUint8Array());return new Wi(i.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Wt(t)}static generate(){let e=_nist.p256.utils.randomPrivateKey();return new Wt(e)}publicKey(){let e=_nist.p256.getPublicKey(this.key.toUint8Array(),!1);return new bn(e)}};Wt.LENGTH=32;var qs=Wt,Xn= exports.WebAuthnSignature =class n extends O{constructor(e,t,r){super(),this.signature=_chunk2VR6ONNWjs.v.fromHexInput(e),this.authenticatorData=_chunk2VR6ONNWjs.v.fromHexInput(t),this.clientDataJSON=_chunk2VR6ONNWjs.v.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.signature.toUint8Array()),e.serializeBytes(this.authenticatorData.toUint8Array()),e.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let e=new _chunk2VR6ONNWjs.L;return this.serialize(e),e.toUint8Array()}bcsToHex(){return _chunk2VR6ONNWjs.v.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return _chunk2VR6ONNWjs.v.fromHexInput(this.bcsToBytes()).toString()}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Invalid id for WebAuthnSignature: ${t}`);let r=e.deserializeBytes(),i=e.deserializeBytes(),o=e.deserializeBytes();return new n(r,i,o)}},An=class An extends O{constructor(e){super();let t=_chunk2VR6ONNWjs.v.fromHexInput(e),r=t.toUint8Array().length;if(r!==An.LENGTH)throw new Error(`Signature length should be ${An.LENGTH}, received ${r}`);let i=_nist.p256.Signature.fromCompact(t.toUint8Array()).normalizeS().toCompactRawBytes();this.data=_chunk2VR6ONNWjs.v.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new An(t)}};An.LENGTH=64;var Wi=An;var x=class n extends ce{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof Le)this.variant=1;else if(e instanceof bn)this.variant=2;else if(e instanceof R)this.variant=3;else if(e instanceof L)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof R)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 B)){if(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.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 H.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=P.deserialize(e);break;case 1:r=Le.deserialize(e);break;case 2:r=bn.deserialize(e);break;case 3:r=R.deserialize(e);break;case 4:r=L.deserialize(e);break;case 5:throw new Error("SlhDsaSha2_128s public key deserialization is not yet implemented");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 P}isSecp256k1PublicKey(){return this.publicKey instanceof Le}static isInstance(e){return"publicKey"in e&&"variant"in e}},B= exports.AnySignature =class n extends O{constructor(e){if(super(),this.signature=e,e instanceof U)this.variant=0;else if(e instanceof yt)this.variant=1;else if(e instanceof Xn)this.variant=2;else if(e instanceof ue)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=U.deserialize(e);break;case 1:r=yt.deserialize(e);break;case 2:r=Xn.deserialize(e);break;case 3:r=ue.deserialize(e);break;case 4:throw new Error("SlhDsaSha2_128s signature deserialization is not yet implemented");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 Pd(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Dr=3,$e= exports.AbstractMultiKey =class extends ce{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}`)}},W= exports.MultiKey =class n extends $e{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`);if(this.publicKeys=t.map(i=>i instanceof x?i:new x(i)),r>Dr&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>Dr)throw new Error(`Construction of MultiKey with more than ${Dr} keyless public keys is not allowed when signaturesRequired
7
+ is greater than ${Dr}. This is because a maximum of 3 keyless signatures are supported for a
8
+ K-of-N MultiKey transaction.`);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 ve))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', _58 => _58.options, 'optionalAccess', _59 => _59.throwErrorWithReason]))throw r;return!1}}authKey(){return H.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(x),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof x?e:new x(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},Ae=class Ae extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>Ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${Ae.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof B?o:new B(o)),!(r instanceof Uint8Array))this.bitmap=Ae.createBitmap({bits:r});else{if(r.length!==Ae.BITMAP_LEN)throw new Error(`"bitmap" length should be ${Ae.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Pd(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>=Ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${Ae.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");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(B),r=e.deserializeBytes();return new Ae({signatures:t,bitmap:r})}};Ae.BITMAP_LEN=4,Ae.MAX_SIGNATURES_SUPPORTED=Ae.BITMAP_LEN*8;var ve=Ae;var he=class he extends $e{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>he.MAX_KEYS||t.length<he.MIN_KEYS)throw new Error(`Must have between ${he.MIN_KEYS} and ${he.MAX_KEYS} public keys, inclusive`);if(r<he.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${he.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 We))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 H.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*P.LENGTH)}),e[this.publicKeys.length*P.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+=P.LENGTH){let s=o;i.push(new P(t.subarray(s,s+P.LENGTH)))}return new he({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+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new he({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};he.MAX_KEYS=32,he.MIN_KEYS=2,he.MIN_THRESHOLD=1;var ie=he,be=class be extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>be.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${be.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=be.createBitmap({bits:r});else{if(r.length!==be.BITMAP_LEN)throw new Error(`"bitmap" length should be ${be.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*U.LENGTH+be.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*U.LENGTH)}),e.set(this.bitmap,this.signatures.length*U.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+=U.LENGTH){let s=o;i.push(new U(t.subarray(s,s+U.LENGTH)))}return new be({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>=be.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${be.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}};be.MAX_SIGNATURES_SUPPORTED=32,be.BITMAP_LEN=4;var We=be;var fn=n=>typeof n=="string"?_chunk2VR6ONNWjs.v.isValid(n).valid?n:new TextEncoder().encode(n):n,Qi=n=>{if(n instanceof P||n instanceof x||n instanceof ie||n instanceof W)return n;if(n instanceof R||n instanceof L)return new x(n);throw new Error(`Unknown account public key: ${n}`)},$s=n=>{let e=Qi(n);if(e instanceof P)return 0;if(e instanceof x)return 2;if(e instanceof ie)return 1;if(e instanceof W)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var ji=[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 _d(n){let e=n.toUint8Array().slice(32);for(let t=ji.length-1;t>=0;t-=1){if(e[t]<ji[t])return!0;if(e[t]>ji[t])return!1}return!1}var Ot=class Ot extends ce{constructor(e){super();let t=_chunk2VR6ONNWjs.v.fromHexInput(e);if(t.toUint8Array().length!==Ot.LENGTH)throw new Error(`PublicKey length should be ${Ot.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!_d(r))return!1;let i=fn(t),o=_chunk2VR6ONNWjs.v.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 H.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 Ot(t)}static isPublicKey(e){return e instanceof Ot}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _60 => _60.key, 'optionalAccess', _61 => _61.data, 'optionalAccess', _62 => _62.length])===Ot.LENGTH}};Ot.LENGTH=32;var P=Ot,Ce=class Ce extends _chunk2VR6ONNWjs.K{constructor(t,r){super();this.cleared=!1;let i=Pe.parseHexInput(t,"ed25519",r);if(i.toUint8Array().length!==Ce.LENGTH)throw new Error(`PrivateKey length should be ${Ce.LENGTH}`);this.signingKey=i}static generate(){let t=_ed25519.ed25519.utils.randomPrivateKey();return new Ce(t,!1)}static fromDerivationPath(t,r){if(!Ps(t))throw new Error(`Invalid derivation path ${t}`);return Ce.fromDerivationPathInner(t,xr(r))}static fromDerivationPathInner(t,r,i=Is){let{key:o,chainCode:s}=Ki(Ce.SLIP_0010_SEED,r),a=xs(t).map(d=>parseInt(d,10)),{key:c}=a.reduce((d,l)=>_s(d,l+i),{key:o,chainCode:s});return new Ce(c,!1)}ensureNotCleared(){if(this.cleared)throw new Error("Private key has been cleared from memory and can no longer be used")}clear(){if(!this.cleared){let t=this.signingKey.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0),this.cleared=!0}}isCleared(){return this.cleared}publicKey(){this.ensureNotCleared();let t=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(t)}sign(t){this.ensureNotCleared();let r=fn(t),i=_chunk2VR6ONNWjs.v.fromHexInput(r).toUint8Array(),o=_ed25519.ed25519.sign(i,this.signingKey.toUint8Array());return new U(o)}toUint8Array(){return this.ensureNotCleared(),this.signingKey.toUint8Array()}toString(){return this.ensureNotCleared(),this.toAIP80String()}toHexString(){return this.ensureNotCleared(),this.signingKey.toString()}toAIP80String(){return this.ensureNotCleared(),Pe.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new Ce(r,!1)}static isPrivateKey(t){return t instanceof Ce}};Ce.LENGTH=32,Ce.SLIP_0010_SEED="ed25519 seed";var J=Ce,Tn=class Tn extends O{constructor(e){super();let t=_chunk2VR6ONNWjs.v.fromHexInput(e);if(t.toUint8Array().length!==Tn.LENGTH)throw new Error(`Signature length should be ${Tn.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 Tn(t)}};Tn.LENGTH=64;var U=Tn;var Fr="Multiple possible deserializations found";function rA(n){let e=[P,x,ie,W,R,L,Le],t;for(let r of e)try{let i=K.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Fr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Fr))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function iA(n){let e=[U,B,We,ve,ue,yt],t;for(let r of e)try{let i=K.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Fr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Fr))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var te=class extends _chunk2VR6ONNWjs.K{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Qe.load(e);case 1:return mt.load(e);case 2:return de.load(e);case 3:return it.load(e);case 4:return wn.load(e);case 5:return Qt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Qe}isMultiEd25519(){return this instanceof mt}isSingleKey(){return this instanceof de}isMultiKey(){return this instanceof it}},Qe= exports.AccountAuthenticatorEd25519 =class n extends te{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),r=U.deserialize(e);return new n(t,r)}},mt= exports.AccountAuthenticatorMultiEd25519 =class n extends te{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=ie.deserialize(e),r=We.deserialize(e);return new n(t,r)}},de= exports.AccountAuthenticatorSingleKey =class n extends te{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=x.deserialize(e),r=B.deserialize(e);return new n(t,r)}},it= exports.AccountAuthenticatorMultiKey =class n extends te{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=W.deserialize(e),r=ve.deserialize(e);return new n(t,r)}},wn= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends te{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Qt= exports.AccountAuthenticatorAbstraction =class n extends te{constructor(e,t,r,i){if(super(),!_chunk2VR6ONNWjs.Ua.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=_chunk2VR6ONNWjs.v.fromHexInput(_chunk2VR6ONNWjs.v.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk2VR6ONNWjs.Ta.call(void 0, this.functionInfo);_chunk2VR6ONNWjs.Ca.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.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk2VR6ONNWjs.Ca.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},Or= exports.AccountAbstractionMessage =class n extends _chunk2VR6ONNWjs.K{constructor(e,t){super(),this.originalSigningMessage=_chunk2VR6ONNWjs.v.fromHexInput(_chunk2VR6ONNWjs.v.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=_chunk2VR6ONNWjs.Ta.call(void 0, this.functionInfo);_chunk2VR6ONNWjs.Ca.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=_chunk2VR6ONNWjs.Ca.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};var Sn=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var N=class n extends _chunk2VR6ONNWjs.K{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var Yn=class n extends _chunk2VR6ONNWjs.K{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(_chunk2VR6ONNWjs.Ca.fromString(t[0]),new N(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk2VR6ONNWjs.Ca.deserialize(e),r=N.deserialize(e);return new n(t,r)}};var z=class n extends _chunk2VR6ONNWjs.K{deserialize(e){let t=_chunk2VR6ONNWjs.Ca.deserialize(e),r=N.deserialize(e),i=N.deserialize(e),o=e.deserializeVector(n);return new ot(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Q.load(e);case 1:return pe.load(e);case 2:return ne.load(e);case 3:return St.load(e);case 4:return M.load(e);case 5:return jt.load(e);case 6:return k.load(e);case 7:return h.load(e);case 8:return At.load(e);case 9:return bt.load(e);case 10:return Et.load(e);case 11:return ft.load(e);case 12:return ht.load(e);case 13:return Tt.load(e);case 14:return wt.load(e);case 15:return It.load(e);case 16:return Pt.load(e);case 255:return V.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof Q}isAddress(){return this instanceof M}isGeneric(){return this instanceof V}isSigner(){return this instanceof jt}isVector(){return this instanceof k}isStruct(){return this instanceof h}isU8(){return this instanceof pe}isU16(){return this instanceof At}isU32(){return this instanceof bt}isU64(){return this instanceof ne}isU128(){return this instanceof St}isU256(){return this instanceof Et}isI8(){return this instanceof ft}isI16(){return this instanceof ht}isI32(){return this instanceof Tt}isI64(){return this instanceof wt}isI128(){return this instanceof It}isI256(){return this instanceof Pt}isPrimitive(){return this instanceof jt||this instanceof M||this instanceof Q||this instanceof pe||this instanceof At||this instanceof bt||this instanceof ne||this instanceof St||this instanceof Et||this instanceof ft||this instanceof ht||this instanceof Tt||this instanceof wt||this instanceof It||this instanceof Pt}},Q= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},pe= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},ft= exports.TypeTagI8 =class n extends z{toString(){return"i8"}serialize(e){e.serializeU32AsUleb128(11)}static load(e){return new n}},At= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},ht= exports.TypeTagI16 =class n extends z{toString(){return"i16"}serialize(e){e.serializeU32AsUleb128(12)}static load(e){return new n}},bt= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},Tt= exports.TypeTagI32 =class n extends z{toString(){return"i32"}serialize(e){e.serializeU32AsUleb128(13)}static load(e){return new n}},ne= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},wt= exports.TypeTagI64 =class n extends z{toString(){return"i64"}serialize(e){e.serializeU32AsUleb128(14)}static load(e){return new n}},St= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},It= exports.TypeTagI128 =class n extends z{toString(){return"i128"}serialize(e){e.serializeU32AsUleb128(15)}static load(e){return new n}},Et= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},Pt= exports.TypeTagI256 =class n extends z{toString(){return"i256"}serialize(e){e.serializeU32AsUleb128(16)}static load(e){return new n}},M= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},jt= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Gr= 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)}},V= 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)}},k= exports.TypeTagVector =class n extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new pe)}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=ot.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(_chunk2VR6ONNWjs.Ca.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk2VR6ONNWjs.Ca.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk2VR6ONNWjs.Ca.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk2VR6ONNWjs.Ca.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk2VR6ONNWjs.Ca.ONE,"rate_limiter","RateLimiter")}},ot= exports.StructTag =class n extends _chunk2VR6ONNWjs.K{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=_chunk2VR6ONNWjs.Ca.deserialize(e),r=N.deserialize(e),i=N.deserialize(e),o=e.deserializeVector(z);return new n(t,r,i,o)}};function rh(){return new ot(_chunk2VR6ONNWjs.Ca.ONE,new N("aptos_coin"),new N("AptosCoin"),[])}function v(){return new ot(_chunk2VR6ONNWjs.Ca.ONE,new N("string"),new N("String"),[])}function ih(n){return new ot(_chunk2VR6ONNWjs.Ca.ONE,new N("option"),new N("Option"),[n])}function Te(n){return new ot(_chunk2VR6ONNWjs.Ca.ONE,new N("object"),new N("Object"),[n])}function xd(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return ee.deserialize(n);case 1:return $.deserialize(n);case 2:return Ne.deserialize(n);case 3:return _chunk2VR6ONNWjs.Ca.deserialize(n);case 4:return S.deserialize(n,ee);case 5:return F.deserialize(n);case 6:return ke.deserialize(n);case 7:return De.deserialize(n);case 8:return Ee.deserialize(n);case 9:return Hn.deserialize(n);case 10:return Fe.deserialize(n);case 11:return Oe.deserialize(n);case 12:return Ge.deserialize(n);case 13:return Be.deserialize(n);case 14:return Me.deserialize(n);case 15:return Ve.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Gt=class extends _chunk2VR6ONNWjs.K{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return In.load(e);case 2:return En.load(e);case 3:return Pn.load(e);case 4:return Br.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},In= exports.TransactionPayloadScript =class n extends Gt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=_n.deserialize(e);return new n(t)}},En= exports.TransactionPayloadEntryFunction =class n extends Gt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=_t.deserialize(e);return new n(t)}},Pn= exports.TransactionPayloadMultiSig =class n extends Gt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Zn.deserialize(e);return new n(t)}},_t= 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(Yn.fromStr(e),new N(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=Yn.deserialize(e),r=N.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=Pr.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},_n= 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=xd(e);o.push(a)}return new n(t,r,o)}},Zn= 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=_chunk2VR6ONNWjs.Ca.deserialize(e),r=e.deserializeBool(),i;return r&&(i=er.deserialize(e)),new n(t,i)}},er= exports.MultiSigTransactionPayload =class n extends _chunk2VR6ONNWjs.K{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(_t.deserialize(e))}},Br= exports.TransactionInnerPayload =class extends Gt{static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return Jt.load(e);throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}},Jt= exports.TransactionInnerPayloadV1 =class n extends Br{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=xn.deserialize(e),r=Mr.deserialize(e);return new n(t,r)}},xn= exports.TransactionExecutable =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return tr.load(e);case 1:return vn.load(e);case 2:return nr.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},tr= exports.TransactionExecutableScript =class n extends xn{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=_n.deserialize(e);return new n(t)}},vn= exports.TransactionExecutableEntryFunction =class n extends xn{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=_t.deserialize(e);return new n(t)}},nr= exports.TransactionExecutableEmpty =class n extends xn{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Mr= exports.TransactionExtraConfig =class{static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return Xt.load(e);throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}},Xt= exports.TransactionExtraConfigV1 =class n extends Mr{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new $(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(_chunk2VR6ONNWjs.Ca),r=e.deserializeOption($);return new n(t,_optionalChain([r, 'optionalAccess', _63 => _63.value]))}};var Ke=class n extends _chunk2VR6ONNWjs.K{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=_chunk2VR6ONNWjs.Ca.deserialize(e),r=e.deserializeU64(),i=Gt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Sn.deserialize(e);return new n(t,r,i,o,s,a,c)}},Vr= exports.RawTransactionWithData =class extends _chunk2VR6ONNWjs.K{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Yt.load(e);case 1:return Zt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Yt= exports.MultiAgentRawTransaction =class n extends Vr{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=Ke.deserialize(e),r=e.deserializeVector(_chunk2VR6ONNWjs.Ca);return new n(t,r)}},Zt= exports.FeePayerRawTransaction =class n extends Vr{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=Ke.deserialize(e),r=e.deserializeVector(_chunk2VR6ONNWjs.Ca),i=_chunk2VR6ONNWjs.Ca.deserialize(e);return new n(t,r,i)}};var Hr=class extends _chunk2VR6ONNWjs.K{constructor(t){super();this.accountAddress=_chunk2VR6ONNWjs.Ca.ONE;this.moduleName=new C("account");this.structName=new C("RotationProofChallenge");this.sequenceNumber=new $(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 xt=class extends _chunk2VR6ONNWjs.K{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return en.load(e);case 1:return Cn.load(e);case 2:return tn.load(e);case 3:return nn.load(e);case 4:return Bt.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof en}isMultiEd25519(){return this instanceof Cn}isMultiAgent(){return this instanceof tn}isFeePayer(){return this instanceof nn}isSingleSender(){return this instanceof Bt}},en= exports.TransactionAuthenticatorEd25519 =class n extends xt{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),r=U.deserialize(e);return new n(t,r)}},Cn= exports.TransactionAuthenticatorMultiEd25519 =class n extends xt{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=ie.deserialize(e),r=We.deserialize(e);return new n(t,r)}},tn= exports.TransactionAuthenticatorMultiAgent =class n extends xt{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=te.deserialize(e),r=e.deserializeVector(_chunk2VR6ONNWjs.Ca),i=e.deserializeVector(te);return new n(t,r,i)}},nn= exports.TransactionAuthenticatorFeePayer =class n extends xt{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=te.deserialize(e),r=e.deserializeVector(_chunk2VR6ONNWjs.Ca),i=e.deserializeVector(te),o=_chunk2VR6ONNWjs.Ca.deserialize(e),s=te.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},Bt= exports.TransactionAuthenticatorSingleSender =class n extends xt{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=te.deserialize(e);return new n(t)}};var vt=class n extends _chunk2VR6ONNWjs.K{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=Ke.deserialize(e),r=xt.deserialize(e);return new n(t,r)}};var qr=class n extends _chunk2VR6ONNWjs.K{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=Ke.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk2VR6ONNWjs.Ca.deserialize(e)),new n(t,i)}};var Lr=class n extends _chunk2VR6ONNWjs.K{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=Ke.deserialize(e),r=e.deserializeVector(_chunk2VR6ONNWjs.Ca),i=e.deserializeBool(),o;return i&&(o=_chunk2VR6ONNWjs.Ca.deserialize(e)),new n(t,r,o)}};function $r(n){return n.feePayerAddress?new Zt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Yt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function nt(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 fb(n){return nt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function je(n){let e=$r(n);return n.feePayerAddress?nt(e.bcsToBytes(),_chunk2VR6ONNWjs.F):n.secondarySignerAddresses?nt(e.bcsToBytes(),_chunk2VR6ONNWjs.F):nt(e.bcsToBytes(),_chunk2VR6ONNWjs.E)}var oe=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk2VR6ONNWjs.Ca.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=J.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=J.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 Qe(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Qe(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(je(e))}};function Ji(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var le=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new x(t.publicKey()),this.accountAddress=r?_chunk2VR6ONNWjs.Ca.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=J.generate();break;case 2:r=gt.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=J.fromDerivationPath(r,i);break;case 2:o=gt.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 de(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new de(this.publicKey,this.signTransaction(e))}sign(e){return new B(this.privateKey.sign(e))}signTransaction(e){return this.sign(je(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var Ct=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?oe.generate():le.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof J&&i?new oe({privateKey:t,address:r}):new le({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?oe.fromDerivationPath({mnemonic:r,path:i}):le.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 Kd=1209600,Kn=class Kn extends _chunk2VR6ONNWjs.K{constructor(t){super();this.cleared=!1;let{privateKey:r,expiryDateSecs:i,blinder:o}=t;this.privateKey=r,this.publicKey=new Dt(r.publicKey()),this.expiryDateSecs=i||_chunk2VR6ONNWjs.Ma.call(void 0, _chunk2VR6ONNWjs.La.call(void 0, )+Kd),this.blinder=o!==void 0?_chunk2VR6ONNWjs.v.fromHexInput(o).toUint8Array():Rd();let s=$n(this.publicKey.bcsToBytes(),93);s.push(BigInt(this.expiryDateSecs)),s.push(qt(this.blinder));let a=Lt(s);this.nonce=a.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}clear(){if(!this.cleared){if("clear"in this.privateKey&&typeof this.privateKey.clear=="function")this.privateKey.clear();else{let t=this.privateKey.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0)}crypto.getRandomValues(this.blinder),this.blinder.fill(255),crypto.getRandomValues(this.blinder),this.blinder.fill(0),this.cleared=!0}}isCleared(){return this.cleared}serialize(t){t.serializeU32AsUleb128(this.publicKey.variant),t.serializeBytes(this.privateKey.toUint8Array()),t.serializeU64(this.expiryDateSecs),t.serializeFixedBytes(this.blinder)}static deserialize(t){let r=t.deserializeUleb128AsU32(),i;if(r===0)i=J.deserialize(t);else throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`);let o=t.deserializeU64(),s=t.deserializeFixedBytes(31);return new Kn({privateKey:i,expiryDateSecs:Number(o),blinder:s})}static fromBytes(t){return Kn.deserialize(new K(t))}static generate(t){let r;switch(_optionalChain([t, 'optionalAccess', _64 => _64.scheme])){default:r=J.generate()}return new Kn({privateKey:r,expiryDateSecs:_optionalChain([t, 'optionalAccess', _65 => _65.expiryDateSecs])})}sign(t){if(this.cleared)throw new Error("EphemeralKeyPair has been cleared from memory and can no longer be used");if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ye(this.privateKey.sign(t))}};Kn.BLINDER_LENGTH=31;var rn=Kn;function Rd(){return _utils3.randomBytes.call(void 0, rn.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function Qr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Rn=class Rn extends _chunk2VR6ONNWjs.K{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:y}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk2VR6ONNWjs.Ca.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 fe)this.proof=l;else{if(f===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async D=>{await f(D),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk2VR6ONNWjs.v.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,y!==void 0){if(_chunk2VR6ONNWjs.v.hexInputToUint8Array(y).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk2VR6ONNWjs.v.hexInputToUint8Array(y)}}getAnyPublicKey(){return new x(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=_chunk2VR6ONNWjs.Ca.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=rn.deserialize(t),c=fe.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 B(this.sign(t)),i=new x(this.publicKey);return new de(i,r)}signTransactionWithAuthenticator(t){let r=new B(this.signTransaction(t)),i=new x(this.publicKey);return new de(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw I.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw I.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw I.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 yn({aptosConfig:t});if(_chunk2VR6ONNWjs.v.hexInputToString(i.hash())!==_chunk2VR6ONNWjs.v.hexInputToString(this.verificationKeyHash))throw I.fromErrorType({type:4})}else _chunk2VR6ONNWjs.Ia.call(void 0, "[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 I.fromErrorType({type:0});if(this.proof===void 0)throw I.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 ue({jwtHeader:_chunk2VR6ONNWjs.Na.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new ln(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw I.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=$r(t),o=new Wr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw I.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=$r(t);return new Wr(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 $i(t)}};Rn.PEPPER_LENGTH=31;var we=Rn,Wr= exports.TransactionAndProof =class extends _chunk2VR6ONNWjs.K{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 nt(this.bcsToBytes(),this.domainSeparator)}};var Re=class n extends we{constructor(e){let t=R.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}=we.partialDeserialize(e),{iss:d,aud:l,uidVal:f}=lt({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(_chunk2VR6ONNWjs.v.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:y}=lt({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:f,uidKey:a,uidVal:y,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:_nullishCoalesce(l, () => ((d?d.hash():void 0)))})}};var Je=class n extends we{constructor(e){let t=L.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}=we.partialDeserialize(e),d=_chunk2VR6ONNWjs.Ca.deserialize(e),{iss:l,aud:f,uidVal:p}=lt({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:y,uidVal:b}=lt({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:b,aud:y,pepper:s,jwkAddress:_chunk2VR6ONNWjs.Ca.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:_nullishCoalesce(f, () => ((l?l.hash():void 0)))})}};var Kt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof oe?le.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?_chunk2VR6ONNWjs.Ca.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 W({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new it(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new it(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof we).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof we).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 ve({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new ve({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var rr=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk2VR6ONNWjs.Ca.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 mt(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new mt(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new We({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(je(e))}};function Ws(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk2VR6ONNWjs.wa).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk2VR6ONNWjs.Ca.deserialize(n),signingScheme:e}}function Qs(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 js(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=rn.deserialize(n),o=fe.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Js;(f=>{function n(p){let y=new _chunk2VR6ONNWjs.L;switch(y.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(y),p.signingScheme){case 0:return p.privateKey.serialize(y),y.toUint8Array();case 2:{if(!Ji(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(y.serializeU32AsUleb128(b.variant),b.variant){case 3:return Qs(p,y),y.toUint8Array();case 4:{let D=p;return Qs(D,y),D.publicKey.jwkAddress.serialize(y),y.serializeBool(D.audless),y.toUint8Array()}case 1:case 0:return p.privateKey.serialize(y),y.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(y),y.serializeU32AsUleb128(b.signers.length),b.signers.forEach(D=>{y.serializeFixedBytes(n(D))}),y.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}f.toBytes=n;function e(p){return _chunk2VR6ONNWjs.v.hexInputToStringWithoutPrefix(n(p))}f.toHexStringWithoutPrefix=e;function t(p){return _chunk2VR6ONNWjs.v.hexInputToString(n(p))}f.toHexString=t;function r(p){let{address:y,signingScheme:b}=Ws(p);switch(b){case 0:{let D=J.deserialize(p);return new oe({privateKey:D,address:y})}case 2:{let D=p.deserializeUleb128AsU32();switch(D){case 0:{let Y=J.deserialize(p);return new le({privateKey:Y,address:y})}case 1:{let Y=gt.deserialize(p);return new le({privateKey:Y,address:y})}case 3:{let Y=js(p),ae=lt(Y);return new Re({...Y,...ae})}case 4:{let Y=js(p),ae=_chunk2VR6ONNWjs.Ca.deserialize(p),Ie=p.deserializeBool(),at=lt(Y);return new Je({...Y,...at,jwkAddress:ae,audless:Ie})}default:throw new Error(`Unsupported public key variant ${D}`)}}case 3:{let D=W.deserialize(p),Y=p.deserializeUleb128AsU32(),ae=new Array;for(let Ie=0;Ie<Y;Ie+=1){let at=r(p);if(!Ji(at)&&!(at instanceof oe))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");ae.push(at)}return new Kt({multiKey:D,signers:ae,address:y})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}f.deserialize=r;function i(p){let y=d(p);if(!(y instanceof Re))throw new Error("Deserialization of KeylessAccount failed");return y}f.keylessAccountFromHex=i;function o(p){let y=d(p);if(!(y instanceof Je))throw new Error("Deserialization of FederatedKeylessAccount failed");return y}f.federatedKeylessAccountFromHex=o;function s(p){let y=d(p);if(!(y instanceof Kt))throw new Error("Deserialization of MultiKeyAccount failed");return y}f.multiKeyAccountFromHex=s;function a(p){let y=d(p);if(!(y instanceof le))throw new Error("Deserialization of SingleKeyAccount failed");return y}f.singleKeyAccountFromHex=a;function c(p){let y=d(p);if(!(y instanceof oe))throw new Error("Deserialization of Ed25519Account failed");return y}f.ed25519AccountFromHex=c;function d(p){return r(K.fromHex(p))}f.fromHex=d;function l(p){return d(p)}f.fromBytes=l})(Js||(Js= exports.AccountUtils ={}));var jr=class n extends Ct{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk2VR6ONNWjs.Ua.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new _r(this.accountAddress),this.sign=o=>new qn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk2VR6ONNWjs.L;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new Or(t,r);return nt(i.bcsToBytes(),_chunk2VR6ONNWjs.G)}signWithAuthenticator(t){return new Qt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(je(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(je(t))}setSigner(t){this.sign=r=>new qn(t(r))}};var ir=class ir extends jr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk2VR6ONNWjs.Ca)(ir.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk2VR6ONNWjs.Ua.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 _chunk2VR6ONNWjs.L;_chunk2VR6ONNWjs.Ca.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk2VR6ONNWjs.L;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([ir.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new Qt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};ir.ADDRESS_DOMAIN_SEPERATOR=5;var Ys=ir;var kd=`
9
9
  fragment TokenActivitiesFields on token_activities_v2 {
10
10
  after_value
11
11
  before_value
@@ -23,7 +23,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
23
23
  transaction_version
24
24
  type
25
25
  }
26
- `,Sd=`
26
+ `,Dd=`
27
27
  fragment AnsTokenFragment on current_aptos_names {
28
28
  domain
29
29
  expiration_timestamp
@@ -35,7 +35,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
35
35
  subdomain_expiration_policy
36
36
  domain_expiration_timestamp
37
37
  }
38
- `,Qr=`
38
+ `,Jr=`
39
39
  fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
40
40
  token_standard
41
41
  token_properties_mutated_v1
@@ -82,7 +82,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
82
82
  }
83
83
  }
84
84
  }
85
- `,$s=`
85
+ `,Zs=`
86
86
  query getAccountAddressesForAuthKey($where_condition: auth_key_account_addresses_bool_exp, $order_by: [auth_key_account_addresses_order_by!]) {
87
87
  auth_key_account_addresses(where: $where_condition, order_by: $order_by) {
88
88
  auth_key
@@ -91,7 +91,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
91
91
  is_auth_key_used
92
92
  }
93
93
  }
94
- `,Ws=`
94
+ `,ea=`
95
95
  query getAccountCoinsCount($address: String) {
96
96
  current_fungible_asset_balances_aggregate(
97
97
  where: {owner_address: {_eq: $address}}
@@ -101,7 +101,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
101
101
  }
102
102
  }
103
103
  }
104
- `,Qs=`
104
+ `,ta=`
105
105
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
106
106
  current_fungible_asset_balances(
107
107
  where: $where_condition
@@ -134,7 +134,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
134
134
  }
135
135
  }
136
136
  }
137
- `,js=`
137
+ `,na=`
138
138
  query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
139
139
  current_collection_ownership_v2_view(
140
140
  where: $where_condition
@@ -168,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
168
168
  single_token_uri
169
169
  }
170
170
  }
171
- `,Js=`
171
+ `,ra=`
172
172
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
173
173
  current_token_ownerships_v2(
174
174
  where: $where_condition
@@ -179,7 +179,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
179
179
  ...CurrentTokenOwnershipFields
180
180
  }
181
181
  }
182
- ${Qr}`,Xw=`
182
+ ${Jr}`,aS=`
183
183
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
184
184
  current_token_ownerships_v2(
185
185
  where: $where_condition
@@ -190,7 +190,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
190
190
  ...CurrentTokenOwnershipFields
191
191
  }
192
192
  }
193
- ${Qr}`,Xs=`
193
+ ${Jr}`,ia=`
194
194
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
195
195
  current_token_ownerships_v2(
196
196
  where: $where_condition
@@ -201,7 +201,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
201
201
  ...CurrentTokenOwnershipFields
202
202
  }
203
203
  }
204
- ${Qr}`,Ys=`
204
+ ${Jr}`,oa=`
205
205
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
206
206
  current_token_ownerships_v2_aggregate(
207
207
  where: $where_condition
@@ -213,7 +213,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
213
213
  }
214
214
  }
215
215
  }
216
- `,Zs=`
216
+ `,sa=`
217
217
  query getAccountTransactionsCount($address: String) {
218
218
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
219
219
  aggregate {
@@ -221,7 +221,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
221
221
  }
222
222
  }
223
223
  }
224
- `,ea=`
224
+ `,aa=`
225
225
  query getAuthKeysForPublicKey($where_condition: public_key_auth_keys_bool_exp, $order_by: [public_key_auth_keys_order_by!]) {
226
226
  public_key_auth_keys(where: $where_condition, order_by: $order_by) {
227
227
  public_key
@@ -233,13 +233,13 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
233
233
  signature_type
234
234
  }
235
235
  }
236
- `,ta=`
236
+ `,ca=`
237
237
  query getChainTopUserTransactions($limit: Int) {
238
238
  user_transactions(limit: $limit, order_by: {version: desc}) {
239
239
  version
240
240
  }
241
241
  }
242
- `,na=`
242
+ `,ua=`
243
243
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
244
244
  current_collections_v2(where: $where_condition) {
245
245
  uri
@@ -256,20 +256,9 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
256
256
  description
257
257
  last_transaction_timestamp
258
258
  last_transaction_version
259
- cdn_asset_uris {
260
- cdn_image_uri
261
- asset_uri
262
- animation_optimizer_retry_count
263
- cdn_animation_uri
264
- cdn_json_uri
265
- image_optimizer_retry_count
266
- json_parser_retry_count
267
- raw_animation_uri
268
- raw_image_uri
269
- }
270
259
  }
271
260
  }
272
- `,ra=`
261
+ `,da=`
273
262
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
274
263
  current_fungible_asset_balances(
275
264
  where: $where_condition
@@ -287,7 +276,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
287
276
  token_standard
288
277
  }
289
278
  }
290
- `,ia=`
279
+ `,pa=`
291
280
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
292
281
  delegated_staking_activities(
293
282
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -300,7 +289,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
300
289
  transaction_version
301
290
  }
302
291
  }
303
- `;var oa=`
292
+ `;var la=`
304
293
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
305
294
  fungible_asset_activities(
306
295
  where: $where_condition
@@ -325,7 +314,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
325
314
  type
326
315
  }
327
316
  }
328
- `,sa=`
317
+ `,ga=`
329
318
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
330
319
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
331
320
  icon_uri
@@ -344,7 +333,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
344
333
  maximum_v2
345
334
  }
346
335
  }
347
- `,Kn=`
336
+ `,Un=`
348
337
  query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
349
338
  current_aptos_names(
350
339
  limit: $limit
@@ -360,14 +349,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
360
349
  }
361
350
  }
362
351
  }
363
- ${Sd}`,Ji=`
352
+ ${Dd}`,Yi=`
364
353
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
365
354
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
366
355
  num_active_delegator
367
356
  pool_address
368
357
  }
369
358
  }
370
- `,jr=`
359
+ `,Xr=`
371
360
  query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
372
361
  current_objects(
373
362
  where: $where_condition
@@ -384,7 +373,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
384
373
  is_deleted
385
374
  }
386
375
  }
387
- `,Xi=`
376
+ `,Zi=`
388
377
  query getProcessorStatus($where_condition: processor_status_bool_exp) {
389
378
  processor_status(where: $where_condition) {
390
379
  last_success_version
@@ -392,7 +381,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
392
381
  last_updated
393
382
  }
394
383
  }
395
- `,aa=`
384
+ `,ya=`
396
385
  query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
397
386
  table_items(
398
387
  where: $where_condition
@@ -408,7 +397,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
408
397
  write_set_change_index
409
398
  }
410
399
  }
411
- `,ca=`
400
+ `,ma=`
412
401
  query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
413
402
  table_metadatas(
414
403
  where: $where_condition
@@ -421,7 +410,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
421
410
  value_type
422
411
  }
423
412
  }
424
- `,ua=`
413
+ `,fa=`
425
414
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
426
415
  token_activities_v2(
427
416
  where: $where_condition
@@ -432,7 +421,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
432
421
  ...TokenActivitiesFields
433
422
  }
434
423
  }
435
- ${wd}`,Yi=`
424
+ ${kd}`,eo=`
436
425
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
437
426
  current_token_ownerships_v2(
438
427
  where: $where_condition
@@ -443,7 +432,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
443
432
  ...CurrentTokenOwnershipFields
444
433
  }
445
434
  }
446
- ${Qr}`,da=`
435
+ ${Jr}`,Aa=`
447
436
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
448
437
  current_token_datas_v2(
449
438
  where: $where_condition
@@ -483,5 +472,5 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
483
472
  }
484
473
  }
485
474
  }
486
- `;async function Jr(n){let{aptosConfig:e}=n,{data:t}=await q({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function pa(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:ta,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Ks({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Id(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Xi},originMethod:"getProcessorStatuses"})).processor_status}async function Xr(n){let e=await Id({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Yr(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Xi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Zr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await q({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}`});return r}async function ga(n){return _optionalChain([n, 'access', _65 => _65.options, 'optionalAccess', _66 => _66.ledgerVersion])!==void 0?la(n):Ye(async()=>la(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function la(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await q({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _67 => _67.ledgerVersion])}});return o}async function ei(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await Dt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _68 => _68.ledgerVersion])},body:r})).data}async function ya(n){let{aptosConfig:e,options:t}=n,r={query:aa,variables:{where_condition:_optionalChain([t, 'optionalAccess', _69 => _69.where]),offset:_optionalChain([t, 'optionalAccess', _70 => _70.offset]),limit:_optionalChain([t, 'optionalAccess', _71 => _71.limit]),order_by:_optionalChain([t, 'optionalAccess', _72 => _72.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function ma(n){let{aptosConfig:e,options:t}=n,r={query:ca,variables:{where_condition:_optionalChain([t, 'optionalAccess', _73 => _73.where]),offset:_optionalChain([t, 'optionalAccess', _74 => _74.offset]),limit:_optionalChain([t, 'optionalAccess', _75 => _75.limit]),order_by:_optionalChain([t, 'optionalAccess', _76 => _76.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function eo(n){let{aptosConfig:e,options:t}=n;return Kr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _77 => _77.offset]),limit:_optionalChain([t, 'optionalAccess', _78 => _78.limit])}})}async function ni(n){let{aptosConfig:e}=n;return Ye(async()=>{let{data:t}=await q({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function fa(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await q({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function nr(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await q({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function Aa(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await nr({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _79 => _79.status])===404)return!0;throw r}}async function Pd(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await q({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Rn(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _80 => _80.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.checkSuccess]), () => (!0)),s=!0,a=0,c,d,l=200,f=1.5;function p(y){if(!(y instanceof Pe)||(d=y,y.status!==404&&y.status>=400&&y.status<500))throw y}try{c=await nr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(y){p(y)}if(s){let y=Date.now();try{c=await Pd({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-y)/1e3}for(;s&&!(a>=i);){try{if(c=await nr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(y){p(y)}await _chunk4RHBBU7Cjs.ua.call(void 0, l),a+=l/1e3,l*=f}if(c===void 0)throw d||new ti(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new ti(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Zi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function ri(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 Yr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk4RHBBU7Cjs.ua.call(void 0, 200)}}var ti=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Zi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function ha(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _82 => _82.withTransactions])}});return Ta({block:i,...n})}async function ba(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])}});return Ta({block:i,...n})}async function Ta(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _84 => _84.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', _85 => _85.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(eo({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 wa(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Sa(n){return!!n.match(/\s/)}function Ed(n){return!!n.match(/^T[0-9]+$/)}function _d(n){return!!n.match(/^&.+$/)}function xd(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":case"i8":case"i16":case"i32":case"i64":case"i128":case"i256":return!0;default:return!1}}function Cd(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Sa(r))break}return t}var vd=(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))(vd||{}),X= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function je(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _86 => _86.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=rr(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new X(n,"unexpected '>'");if(c!==o.length)throw new X(n,"type argument count doesn't match expected amount");let{savedStr:f,savedTypes:p,savedExpectedTypes:y}=l;i=o,o=p,a=f,c=y}else if(d===","){if(r.length===0)throw new X(n,"unexpected ','");if(a.length===0)throw new X(n,"no type argument before ','");let l=rr(a,i,t);i=[],o.push(l),a="",c+=1}else if(Sa(d)){let l=!1;if(a.length!==0){let p=rr(a,i,t);i=[],o.push(p),a="",l=!0}s=Cd(n,s);let f=n[s];if(s<n.length&&l&&f!==","&&f!==">")throw new X(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new X(n,"no matching '>' for '<'");switch(o.length){case 0:return rr(a,i,t);case 1:if(a==="")return o[0];throw new X(n,"unexpected ','");default:throw new X(n,"unexpected whitespace character")}}function rr(n,e,t){let r=n.trim(),i=r.toLowerCase();if(xd(i)&&e.length>0)throw new X(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Wt;case"bool":return new Q;case"address":return new M;case"u8":return new de;case"u16":return new yt;case"u32":return new ft;case"u64":return new ne;case"u128":return new bt;case"u256":return new wt;case"i8":return new gt;case"i16":return new mt;case"i32":return new At;case"i64":return new ht;case"i128":return new Tt;case"i256":return new St;case"vector":if(e.length!==1)throw new X(n,"vector type expected to have exactly one type argument");return new k(e[0]);default:if(_d(r)){let a=r.substring(1);return new Nr(rr(a,e,t))}if(Ed(r)){if(t)return new V(Number(r.split("T")[1]));throw new X(n,"unexpected generic type")}if(!r.match(/:/))throw new X(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new X(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk4RHBBU7Cjs.pa.fromString(o[0])}catch (e4){throw new X(n,"struct address must be valid")}if(!wa(o[1]))throw new X(n,"module name must only contain alphanumeric or '_' characters");if(!wa(o[2]))throw new X(n,"struct name must only contain alphanumeric or '_' characters");return new h(new rt(s,new F(o[1]),new F(o[2]),e))}}function Ia(n){return typeof n=="boolean"}function Ct(n){return typeof n=="string"}function Kd(n){return typeof n=="number"}function nn(n){if(Kd(n))return n;if(Ct(n)&&n!=="")return Number.parseInt(n,10)}function rn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Pa(n){return n==null}function Ea(n){return to(n)||ro(n)||io(n)||oo(n)||so(n)||ao(n)||co(n)||ii(n)||no(n)||Rd(n)||uo(n)||po(n)||lo(n)||go(n)||yo(n)||mo(n)||n instanceof S||n instanceof B}function to(n){return n instanceof N}function ii(n){return n instanceof _chunk4RHBBU7Cjs.pa}function no(n){return n instanceof v}function Rd(n){return n instanceof Re}function ro(n){return n instanceof ee}function io(n){return n instanceof Ue}function oo(n){return n instanceof ze}function so(n){return n instanceof $}function ao(n){return n instanceof ke}function co(n){return n instanceof Se}function uo(n){return n instanceof De}function po(n){return n instanceof Fe}function lo(n){return n instanceof Ne}function go(n){return n instanceof Oe}function yo(n){return n instanceof Be}function mo(n){return n instanceof Ge}function _a(n){return"bytecode"in n}function _(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function xa(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ud=new TextEncoder;function oi(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _87 => _87.map, 'call', _88 => _88(e=>Ct(e)?je(e):e)]), () => ([]))}async function zd(n,e,t){return(await si({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Ao(n,e,t,r){let i=await zd(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 GS(n,e,t,r){let i=await Ao(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(je(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Ca(n,e,t,r){let i=await Ao(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=xa(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(je(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function va(n,e,t,r){let i=await Ao(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(je(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(je(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function ho(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=je(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 on(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function on(n,e,t,r,i,o){return Ea(n)?(fo(e,n,t),n):kd(n,e,t,r,i,o)}function kd(n,e,t,r,i,o){if(e.isBool()){if(Ia(n))return new N(n);if(Ct(n)){if(n==="true")return new N(!0);if(n==="false")return new N(!1)}_("boolean",t)}if(e.isAddress()){if(Ct(n))return _chunk4RHBBU7Cjs.pa.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk4RHBBU7Cjs.pa)(n.data);_("string | AccountAddress",t)}if(e.isU8()){let s=nn(n);if(s!==void 0)return new ee(s);_("number | string",t)}if(e.isU16()){let s=nn(n);if(s!==void 0)return new Ue(s);_("number | string",t)}if(e.isU32()){let s=nn(n);if(s!==void 0)return new ze(s);_("number | string",t)}if(e.isU64()){if(rn(n))return new $(BigInt(n));_("bigint | number | string",t)}if(e.isU128()){if(rn(n))return new ke(BigInt(n));_("bigint | number | string",t)}if(e.isU256()){if(rn(n))return new Se(BigInt(n));_("bigint | number | string",t)}if(e.isI8()){let s=nn(n);if(s!==void 0)return new De(s);_("number | string",t)}if(e.isI16()){let s=nn(n);if(s!==void 0)return new Fe(s);_("number | string",t)}if(e.isI32()){let s=nn(n);if(s!==void 0)return new Ne(s);_("number | string",t)}if(e.isI64()){if(rn(n))return new Oe(BigInt(n));_("bigint | number | string",t)}if(e.isI128()){if(rn(n))return new Be(BigInt(n));_("bigint | number | string",t)}if(e.isI256()){if(rn(n))return new Ge(BigInt(n));_("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 on(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(Ct(n))return S.U8(Ud.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(Ct(n)&&n.startsWith("["))return on(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>on(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 v(n);_("string",t)}if(e.isObject()){if(Ct(n))return _chunk4RHBBU7Cjs.pa.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk4RHBBU7Cjs.pa)(n.data);_("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Re(n);_("Uint8Array",t)}if(e.isOption()){if(Pa(n)){let a=e.value.typeArgs[0];return a instanceof Q?new B(null):a instanceof M?new B(null):a instanceof de?new B(null):a instanceof yt?new B(null):a instanceof ft?new B(null):a instanceof ne?new B(null):a instanceof bt?new B(null):a instanceof wt?new B(null):a instanceof gt?new B(null):a instanceof mt?new B(null):a instanceof At?new B(null):a instanceof ht?new B(null):a instanceof Tt?new B(null):a instanceof St?new B(null):new B(null)}return new B(on(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _89 => _89.structs, 'access', _90 => _90.find, 'call', _91 => _91(a=>a.name===e.value.name.identifier), 'optionalAccess', _92 => _92.fields, 'access', _93 => _93.length])===0&&n instanceof Uint8Array)return new Re(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _94 => _94.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Re(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 fo(n,e,t){if(n.isBool()){if(to(e))return;_("Bool",t)}if(n.isAddress()){if(ii(e))return;_("AccountAddress",t)}if(n.isU8()){if(ro(e))return;_("U8",t)}if(n.isU16()){if(io(e))return;_("U16",t)}if(n.isU32()){if(oo(e))return;_("U32",t)}if(n.isU64()){if(so(e))return;_("U64",t)}if(n.isU128()){if(ao(e))return;_("U128",t)}if(n.isU256()){if(co(e))return;_("U256",t)}if(n.isI8()){if(uo(e))return;_("I8",t)}if(n.isI16()){if(po(e))return;_("I16",t)}if(n.isI32()){if(lo(e))return;_("I32",t)}if(n.isI64()){if(go(e))return;_("I64",t)}if(n.isI128()){if(yo(e))return;_("I128",t)}if(n.isI256()){if(mo(e))return;_("I256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&fo(n.value,e.values[0],t);return}_("MoveVector",t)}if(n instanceof h){if(n.isString()){if(no(e))return;_("MoveString",t)}if(n.isObject()){if(ii(e))return;_("AccountAddress",t)}if(n.isOption()){if(e instanceof B){e.value!==void 0&&fo(n.value.typeArgs[0],e.value,t);return}_("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ai(n){if(_a(n))return Od(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk4RHBBU7Cjs.Ea.call(void 0, n.function),i=await za({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ca});return Fd({...n,abi:i})}function Fd(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk4RHBBU7Cjs.Ea.call(void 0, n.function),o=oi(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_optionalChain([n, 'access', _95 => _95.functionArguments, 'optionalAccess', _96 => _96.map, 'call', _97 => _97((c,d)=>ho(n.function,e,c,d,o))]);if((_nullishCoalesce(_optionalChain([s, 'optionalAccess', _98 => _98.length]), () => (0)))!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${_nullishCoalesce(_optionalChain([s, 'optionalAccess', _99 => _99.length]), () => (0))}`);let a=It.build(`${t}::${r}`,i,o,_nullishCoalesce(s, () => ([])));if("multisigAddress"in n){let c=_chunk4RHBBU7Cjs.pa.from(n.multisigAddress);return new In(new Jn(c,new Xn(a)))}return new Sn(a)}async function Ka(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk4RHBBU7Cjs.Ea.call(void 0, n.function),i=await za({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:va});return Nd({abi:i,...n})}function Nd(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk4RHBBU7Cjs.Ea.call(void 0, n.function),o=oi(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', _100 => _100.functionArguments, 'optionalAccess', _101 => _101.map, 'call', _102 => _102((a,c)=>ho(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 It.build(`${t}::${r}`,i,o,s)}function Od(n){return new wn(new Pn(_chunk4RHBBU7Cjs.v.fromHexInput(n.bytecode).toUint8Array(),oi(n.typeArguments),n.functionArguments))}async function Bd(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(_optionalChain([i, 'optionalAccess', _103 => _103.replayProtectionNonce])!==void 0&&_optionalChain([i, 'optionalAccess', _104 => _104.accountSequenceNumber])!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>Ui[e.network]?{chainId:Ui[e.network]}:{chainId:(await Jr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _105 => _105.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await ni({aptosConfig:e})).gas_estimate},c=async()=>{let re=async()=>_optionalChain([i, 'optionalAccess', _106 => _106.accountSequenceNumber])!==void 0?i.accountSequenceNumber:_optionalChain([i, 'optionalAccess', _107 => _107.replayProtectionNonce])!==void 0?0xdeadbeefn:(await Zr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk4RHBBU7Cjs.pa.from(o).equals(_chunk4RHBBU7Cjs.pa.ZERO))try{return await re()}catch (e5){return 0}else return re()},[{chainId:d},{gasEstimate:l},f]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:y,expireTimestamp:b,replayProtectionNonce:D}={maxGasAmount:_optionalChain([i, 'optionalAccess', _108 => _108.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _109 => _109.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _110 => _110.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()))),replayProtectionNonce:_optionalChain([i, 'optionalAccess', _111 => _111.replayProtectionNonce])?BigInt(i.replayProtectionNonce):void 0},Y=r;return D!==void 0&&(Y=Gd(r,D)),new Ce(_chunk4RHBBU7Cjs.pa.from(t),BigInt(f),Y,BigInt(p),BigInt(y),BigInt(b),new Tn(d))}function Gd(n,e){if(n instanceof wn)return new Qt(new Yn(n.script),new jt(void 0,e));if(n instanceof Sn)return new Qt(new _n(n.entryFunction),new jt(void 0,e));if(n instanceof In){let t=n.multiSig.transaction_payload,r;if(t===void 0||_optionalChain([t, 'optionalAccess', _112 => _112.transaction_payload])===void 0)r=new Zn;else if(t.transaction_payload instanceof It)r=new _n(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new Qt(r,new jt(n.multiSig.multisig_address,e))}else throw new Error(`Unsupported payload type: ${n}`)}async function bo(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Bd({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _113 => _113.secondarySignerAddresses, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(c=>_chunk4RHBBU7Cjs.pa.from(c))]), () => ([]));return new Hr(s,a,n.feePayerAddress?_chunk4RHBBU7Cjs.pa.from(n.feePayerAddress):void 0)}return new Vr(s,n.feePayerAddress?_chunk4RHBBU7Cjs.pa.from(n.feePayerAddress):void 0)}function Ra(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Un(e);if(t.feePayerAddress){let a=new Xt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(f=>Un(f)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Un(void 0)));let d=Un(i),l=new en(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new Et(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Jt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>Un(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Un(void 0));let d=new Zt(o,t.secondarySignerAddresses,c);return new Et(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof $e)s=new Yt(o.public_key,o.signature);else if(o instanceof ue||o instanceof nt)s=new Bt(o);else if(o instanceof bn)s=new Bt(o);else throw new Error("Invalid public key");return new Et(t.rawTransaction,s).bcsToBytes()}function Un(n){if(!n)return new bn;let t=R.isInstance(n)||L.isInstance(n)||He.isInstance(n)?new x(n):n,r=new U(new Uint8Array(64));if(P.isInstance(t))return new $e(t,r);if(x.isInstance(t))return R.isInstance(t.publicKey)?new ue(t,new G(ce.getSimulationSignature())):new ue(t,new G(r));if(W.isInstance(t))return new nt(t,new _e({signatures:t.publicKeys.map(i=>R.isInstance(i.publicKey)||L.isInstance(i.publicKey)?new G(ce.getSimulationSignature()):new G(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function To(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Cs(te,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 en(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 Zt(i,e.secondarySignerAddresses,r)}else i instanceof $e?o=new Yt(i.public_key,i.signature):i instanceof lt?o=new xn(i.public_key,i.signature):o=new Bt(i);return new Et(e.rawTransaction,o).bcsToBytes()}function Ua(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Md=Ua(["APTOS::Transaction"]);function gI(n){let e=To(n);return new (0, _chunk4RHBBU7Cjs.v)(Ua([Md,new Uint8Array([0]),e])).toString()}async function za({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ye(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function T(n){let e=await Vd(n);return Hd(n,e)}async function Vd(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await ai(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ai(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ai(r)),i}async function Hd(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(qd(n)&&(o=_chunk4RHBBU7Cjs.pa.ZERO.toString()),Ld(n)){let{secondarySignerAddresses:s}=n;return bo({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return bo({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function qd(n){return n.withFeePayer===!0}function Ld(n){return"secondarySignerAddresses"in n}function ka(n){let{transaction:e}=n;return We(e)}function ci(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function ui(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,ci({signer:e,transaction:t})}async function wo(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Ra({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Dt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _116 => _116.options, 'optionalAccess', _117 => _117.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _118 => _118.options, 'optionalAccess', _119 => _119.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _120 => _120.options, 'optionalAccess', _121 => _121.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function ir(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=To({...n});try{let{data:o}=await Dt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=Et.deserialize(new K(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof R||s.authenticator.sender.public_key.publicKey instanceof L)&&await Te.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function di(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;$r(t)&&await t.checkKeylessAccountValidity(e),$r(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&ui({signer:r,transaction:i}),a=ci({signer:t,transaction:i});return ir({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function Da(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;$r(r)&&await r.checkKeylessAccountValidity(e);let s=ui({signer:r,transaction:i});return ir({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var $d={typeParameters:[],parameters:[k.u8(),new k(k.u8())]};async function Fa(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:_chunk4RHBBU7Cjs.pa.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:$d},options:o})}async function zn(n){return Zr(n)}async function Na(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Di({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _122 => _122.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _123 => _123.limit]), () => (1e3))}})}async function Oa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Rr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _124 => _124.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _125 => _125.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _126 => _126.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function si(n){return ga(n)}async function Io(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Kr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([r, 'optionalAccess', _128 => _128.limit])}})}async function Po(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Di({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _129 => _129.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _130 => _130.limit]), () => (999))}})}async function Ba(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Rr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _131 => _131.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _132 => _132.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _133 => _133.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Eo(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await q({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk4RHBBU7Cjs.pa.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _134 => _134.ledgerVersion])}});return o.data}async function or(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Eo({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk4RHBBU7Cjs.pa.from(t);try{let a=await ei({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk4RHBBU7Cjs.pa.from(a)}catch(a){if(a instanceof Pe&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ga(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Ys,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 Ma(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard])});let s={query:Js,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:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Va(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),s=_chunk4RHBBU7Cjs.pa.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _140 => _140.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _141 => _141.tokenStandard])});let c={query:Xs,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _142 => _142.offset]),limit:_optionalChain([i, 'optionalAccess', _143 => _143.limit]),order_by:_optionalChain([i, 'optionalAccess', _144 => _144.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Ha(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _145 => _145.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _146 => _146.tokenStandard])}});let s={query:js,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _147 => _147.offset]),limit:_optionalChain([r, 'optionalAccess', _148 => _148.limit]),order_by:_optionalChain([r, 'optionalAccess', _149 => _149.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function qa(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Zs,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function La(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _150 => _150.where]),owner_address:{_eq:i}},s={query:Qs,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _151 => _151.offset]),limit:_optionalChain([r, 'optionalAccess', _152 => _152.limit]),order_by:_optionalChain([r, 'optionalAccess', _153 => _153.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function $a(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ws,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 Wa(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await q({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?_chunk4RHBBU7Cjs.pa.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function _o(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}},s={query:jr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _154 => _154.offset]),limit:_optionalChain([r, 'optionalAccess', _155 => _155.limit]),order_by:_optionalChain([r, 'optionalAccess', _156 => _156.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Qa(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _157 => _157.throwIfNoAccountFound]), () => (!1)),o=await pi({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return _t.fromPrivateKey({privateKey:t})}return o[0]}async function Wd(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([Po({aptosConfig:e,accountAddress:t}),_o({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!_optionalChain([r, 'optionalAccess', _158 => _158.withAuthKey]))return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var Qd={typeParameters:[],parameters:[new de,k.u8(),new de,k.u8(),k.u8(),k.u8()]};async function ja(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return So({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof oe?So({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):So({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function So(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await zn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=_t.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new Mr({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk4RHBBU7Cjs.pa.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new ee(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new ee(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(d.toUint8Array())],abi:Qd},options:r})}var jd={typeParameters:[],parameters:[new de,k.u8()]};async function Ja(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new ee(Bs(r)),S.U8($i(r).toUint8Array())],abi:jd},options:i})}async function li(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _159 => _159.noMultiKey]), () => (!1));if(i&&t instanceof qe)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof x&&t.publicKey instanceof P?o.push(t.publicKey):t instanceof P&&o.push(new x(t));let[s,a]=await Promise.all([Promise.all(o.map(async f=>{let p=await ep({aptosConfig:e,publicKey:f});if(p)return{...p,publicKey:f}})),!(t instanceof qe)&&!i?Xd({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 Yd({aptosConfig:e,authKeys:o.map(f=>f.authKey()),options:r});for(let f of l){if(c.find(y=>y.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 xo(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof J||t instanceof dt)return pi({aptosConfig:e,privateKey:t,options:r});if(t instanceof oe||t instanceof pe)return pi({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof ve||t instanceof Qe)return Jd({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof xt&&t.signers.length===1)return xo({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof er&&t.signers.length===1)return pi({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function Jd(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await li({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 qe){if(c.getSignaturesRequired()>1)continue;if(c instanceof ie)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof W&&s.push(new xt({multiKey:c,signers:[t],address:a}))}else t instanceof Qe?s.push(Qe.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(ve.create({...o,address:a}));return s}async function pi(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_t.fromPrivateKey({privateKey:t,legacy:!1}),o=await li({aptosConfig:e,publicKey:new x(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof qe){if(c.getSignaturesRequired()>1)continue;c instanceof ie?s.push(new er({publicKey:c,signers:[t],address:a})):c instanceof W&&s.push(new xt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof P;s.push(_t.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function Xd(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof qe)throw new Error("Public key is a multi-key.");let i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _160 => _160.includeUnverified]), () => (!1)),o=t instanceof x?t:new x(t),s=o.publicKey,a=_chunk4RHBBU7Cjs.O.call(void 0, o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},account_public_key:{_is_null:!1},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:ea,variables:{where_condition:c}},{public_key_auth_keys:l}=await w({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return l.filter(p=>p.account_public_key!==null).map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return ie.deserializeWithoutLength(K.fromHex(p.account_public_key));case"multi_key_signature":return W.deserialize(K.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function Yd(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _161 => _161.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:$s,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 H({data:c.auth_key}),accountAddress:new (0, _chunk4RHBBU7Cjs.pa)(_chunk4RHBBU7Cjs.v.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function Zd(n){let{aptosConfig:e,accountAddress:t}=n,r=await Io({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function ep(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([Zd({aptosConfig:e,accountAddress:r}),Wd({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function I(n){n.minimumLedgerVersion!==void 0&&await ri({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function le(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Ka({...t,aptosConfig:e}),o=new _chunk4RHBBU7Cjs.y;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Dt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _162 => _162.ledgerVersion])},body:s});return a}async function Xa(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await Dt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _163 => _163.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function Ya(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk4RHBBU7Cjs.Ea.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 M,new h(C()),new h(C())]}},options:i})}async function Za(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk4RHBBU7Cjs.Ea.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 M,new h(C()),new h(C())]}},options:i})}async function ec(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 sn=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk4RHBBU7Cjs.Ea.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _164 => _164.some, 'call', _165 => _165(s=>_chunk4RHBBU7Cjs.pa.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 Ya({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Za({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ec({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await le({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk4RHBBU7Cjs.pa.from(t)],abi:{typeParameters:[],parameters:[new M],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk4RHBBU7Cjs.pa.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var sr=class{constructor(e){this.config=e;this.abstraction=new sn(e)}async getAccountInfo(e){return zn({aptosConfig:this.config,...e})}async getAccountModules(e){return Na({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Oa({aptosConfig:this.config,...e})}async getAccountModule(e){return si({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Io({aptosConfig:this.config,...e})}async getAccountResources(e){return Po({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Ba({aptosConfig:this.config,...e})}async getAccountResource(e){return Eo({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return or({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ga({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ma({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Va({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ha({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),qa({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),La({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$a({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Ht,faMetadataAddress:Ps,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await Ye(async()=>{try{let c=(await le({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&_chunk4RHBBU7Cjs.Da.call(void 0, c.vec[0]))return _chunk4RHBBU7Cjs.Ca.call(void 0, c.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=_chunk4RHBBU7Cjs.pa.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ht?s=_chunk4RHBBU7Cjs.pa.A.toStringLong():s=_chunk4RHBBU7Cjs.qa.call(void 0, _chunk4RHBBU7Cjs.pa.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=_chunk4RHBBU7Cjs.pa.from(i);s=c.toStringLong(),c===_chunk4RHBBU7Cjs.pa.A&&(o=Ht)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await le({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await le({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return Wa({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),_o({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Qa({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),xo({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),li({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var gi=class{constructor(e){if(_optionalChain([e, 'optionalAccess', _166 => _166.fullnode])||_optionalChain([e, 'optionalAccess', _167 => _167.indexer])||_optionalChain([e, 'optionalAccess', _168 => _168.faucet])||_optionalChain([e, 'optionalAccess', _169 => _169.pepper])||_optionalChain([e, 'optionalAccess', _170 => _170.prover])){if(_optionalChain([e, 'optionalAccess', _171 => _171.network])==="custom")console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!_optionalChain([e, 'optionalAccess', _172 => _172.network]))throw new Error("Custom endpoints require a network to be specified")}this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _173 => _173.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _174 => _174.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _175 => _175.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _176 => _176.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _177 => _177.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _178 => _178.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _179 => _179.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _180 => _180.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _181 => _181.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _182 => _182.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _183 => _183.faucetConfig]), () => ({})),this.transactionGenerationConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _184 => _184.transactionGenerationConfig]), () => ({})),this.pluginConfig=_optionalChain([e, 'optionalAccess', _185 => _185.pluginSettings])?{...e.pluginSettings,IGNORE_TRANSACTION_SUBMITTER:!1}:void 0}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 Ts[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 ws[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 bs[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 vi[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 Ki[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return vi[this.network]===e}isProverServiceRequest(e){return Ki[this.network]===e}getDefaultMaxGasAmount(){return _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.transactionGenerationConfig, 'optionalAccess', _187 => _187.defaultMaxGasAmount]), () => (2e5))}getDefaultTxnExpirySecFromNow(){return _nullishCoalesce(_optionalChain([this, 'access', _188 => _188.transactionGenerationConfig, 'optionalAccess', _189 => _189.defaultTxnExpirySecFromNow]), () => (20))}setIgnoreTransactionSubmitter(e){this.pluginConfig&&(this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER=e)}getTransactionSubmitter(){if(this.pluginConfig!==void 0&&this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER!==!0)return this.pluginConfig.TRANSACTION_SUBMITTER}};var np={typeParameters:[{constraints:[]}],parameters:[new M,new ne]};async function tc(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, () => (Ht))],functionArguments:[r,i],abi:np},options:s})}var ar=class{constructor(e){this.config=e}async transferCoinTransaction(e){return tc({aptosConfig:this.config,...e})}};var Gt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Ke="0x4::token::Token";async function nc(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:da,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function rc(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Yi,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ic(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()},amount:{_gt:0}},o={query:Yi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _190 => _190.offset]),limit:_optionalChain([r, 'optionalAccess', _191 => _191.limit]),order_by:_optionalChain([r, 'optionalAccess', _192 => _192.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function oc(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}},o={query:ua,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _193 => _193.offset]),limit:_optionalChain([r, 'optionalAccess', _194 => _194.limit]),order_by:_optionalChain([r, 'optionalAccess', _195 => _195.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var rp={typeParameters:[],parameters:[new h(C()),new ne,new h(C()),new h(C()),new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new ne,new ne]};async function sc(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 v(n.description),new $(_nullishCoalesce(n.maxSupply, () => (_chunk4RHBBU7Cjs.e))),new v(n.name),new v(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 $(_nullishCoalesce(n.royaltyNumerator, () => (0))),new $(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:rp},options:t})}async function kn(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _196 => _196.where]);_optionalChain([t, 'optionalAccess', _197 => _197.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _198 => _198.tokenStandard]), () => ("v2"))});let i={query:na,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _199 => _199.offset]),limit:_optionalChain([t, 'optionalAccess', _200 => _200.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function ac(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk4RHBBU7Cjs.pa.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _201 => _201.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _202 => _202.tokenStandard]), () => ("v2"))}),kn({aptosConfig:e,options:{...i,where:s}})}async function cc(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _203 => _203.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _204 => _204.tokenStandard]), () => ("v2"))}),kn({aptosConfig:e,options:{...r,where:o}})}async function uc(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _205 => _205.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _206 => _206.tokenStandard]), () => ("v2"))}),kn({aptosConfig:e,options:{...r,where:o}})}async function dc(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk4RHBBU7Cjs.pa.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _207 => _207.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _208 => _208.tokenStandard]), () => ("v2"))}),(await kn({aptosConfig:i,options:{where:s}})).collection_id}var ip={typeParameters:[],parameters:[new h(C()),new h(C()),new h(C()),new h(C()),new k(new h(C())),new k(new h(C())),new k(k.u8())]};async function pc(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', _209 => _209.map, 'call', _210 => _210(p=>Gt[p])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new v(i),new v(o),new v(s),new v(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(f, () => ([]))),Ec(_nullishCoalesce(l, () => ([])),_nullishCoalesce(f, () => ([])))],abi:ip},options:t})}var op={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new M]};async function lc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(r),_chunk4RHBBU7Cjs.pa.from(i)],abi:op},options:s})}var sp={typeParameters:[],parameters:[new h(C()),new h(C()),new h(C()),new h(C()),new k(new h(C())),new k(new h(C())),new k(k.u8()),new M]};async function gc(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', _211 => _211.length])!==_optionalChain([l, 'optionalAccess', _212 => _212.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _213 => _213.length])!==_optionalChain([l, 'optionalAccess', _214 => _214.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _215 => _215.map, 'call', _216 => _216(y=>Gt[y])]);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(p, () => ([]))),Ec(_nullishCoalesce(l, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:sp},options:f})}var ap={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0)))]};async function yc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(r)],abi:ap},options:o})}var cp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0)))]};async function mc(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, () => (Ke))],functionArguments:[r],abi:cp},options:o})}var up={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0)))]};async function fc(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, () => (Ke))],functionArguments:[r],abi:up},options:o})}var dp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C())]};async function Ac(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(i),new v(r)],abi:dp},options:s})}var pp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C())]};async function hc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(i),new v(r)],abi:pp},options:s})}var lp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C())]};async function bc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(i),new v(r)],abi:lp},options:s})}var gp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C()),new h(C()),k.u8()]};async function Tc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(s),new v(r),new v(Gt[i]),S.U8(Co(o,Gt[i]))],abi:gp},options:c})}var yp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C())]};async function wc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(i),new v(r)],abi:yp},options:s})}var mp={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new V(0))),new h(C()),new h(C()),k.u8()]};async function Sc(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, () => (Ke))],functionArguments:[_chunk4RHBBU7Cjs.pa.from(s),new v(r),new v(Gt[i]),Co(o,Gt[i])],abi:mp},options:c})}var fp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(be(new V(0))),new h(C()),new V(1)]};async function Ic(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, () => (Ke)),Gt[i]],functionArguments:[_chunk4RHBBU7Cjs.pa.from(s),new v(r),o],abi:fp},options:c})}var Ap={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(be(new V(0))),new h(C()),new V(1)]};async function Pc(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, () => (Ke)),Gt[i]],functionArguments:[_chunk4RHBBU7Cjs.pa.from(s),new v(r),o],abi:Ap},options:c})}function Ec(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Co(n[i],r))}),t}function Co(n,e){let t=je(e);return on(n,t,0,[]).bcsToBytes()}var cr=class{constructor(e){this.config=e}async getCollectionData(e){await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunk4RHBBU7Cjs.pa.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _217 => _217.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _218 => _218.tokenStandard]), () => ("v2"))}),kn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ac({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),cc({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),uc({aptosConfig:this.config,...e})}async getCollectionId(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),dc({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),nc({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rc({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ic({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oc({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sc({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return pc({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return lc({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return gc({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return yc({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return mc({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return fc({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Ac({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return hc({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return bc({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Tc({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wc({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Sc({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ic({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Pc({aptosConfig:this.config,...e})}};async function _c(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _219 => _219.timeoutSecs])||20,{data:s}=await Rs({aptosConfig:e,path:"fund",body:{address:_chunk4RHBBU7Cjs.pa.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Rn({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _220 => _220.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var ur=class{constructor(e){this.config=e}async fundAccount(e){let t=await _c({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _221 => _221.options, 'optionalAccess', _222 => _222.waitForIndexer])===void 0||_optionalChain([e, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.waitForIndexer]))&&await ri({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function yi(n){let{aptosConfig:e,options:t}=n,r={query:sa,variables:{where_condition:_optionalChain([t, 'optionalAccess', _225 => _225.where]),limit:_optionalChain([t, 'optionalAccess', _226 => _226.limit]),offset:_optionalChain([t, 'optionalAccess', _227 => _227.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function xc(n){let{aptosConfig:e,options:t}=n,r={query:oa,variables:{where_condition:_optionalChain([t, 'optionalAccess', _228 => _228.where]),limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),offset:_optionalChain([t, 'optionalAccess', _230 => _230.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Cc(n){let{aptosConfig:e,options:t}=n,r={query:ra,variables:{where_condition:_optionalChain([t, 'optionalAccess', _231 => _231.where]),limit:_optionalChain([t, 'optionalAccess', _232 => _232.limit]),offset:_optionalChain([t, 'optionalAccess', _233 => _233.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var vc={typeParameters:[{constraints:[]}],parameters:[je("0x1::object::Object"),new M,new ne]};async function Kc(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:vc},options:s})}async function Rc(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:vc},options:s})}var dr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _234 => _234.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),yi({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _235 => _235.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await yi({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _236 => _236.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await yi({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk4RHBBU7Cjs.pa.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _237 => _237.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),xc({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _238 => _238.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Cc({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Kc({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Rc({aptosConfig:this.config,...e})}};var pr=class{constructor(e){this.config=e}async getLedgerInfo(){return Jr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return ha({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ba({aptosConfig:this.config,...e})}async view(e){return le({aptosConfig:this.config,...e})}async viewJson(e){return Xa({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return pa({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Xr({aptosConfig:this.config})}async getProcessorStatus(e){return Yr({aptosConfig:this.config,processorType:e})}};var vo,hp=6,Uc=["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 zc(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function vt(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(!zc(e))throw new Error(`${e} is not valid. ${Uc}`);if(t&&!zc(t))throw new Error(`${t} is not valid. ${Uc}`);return{domainName:t||e,subdomainName:t?e:void 0}}function bp({aptosConfig:n,name:e,gracePeriod:t}){if(!e)return"expired";let r=t*1e3,i=Date.now(),o=new Date(e.domain_expiration_timestamp).getTime(),s=new Date(e.expiration_timestamp).getTime(),a=o<i,c=s<i,d=c&&i-s<r,l=a&&i-o<r;return e.subdomain&&a&&!l?"expired":e.subdomain&&e.subdomain_expiration_policy===1?l?"in_grace_period":"active":d?"in_grace_period":c?"expired":"active"}var Tp="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",wp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Tp,custom:null,devnet:null,shelbynet:null,netna:null};function it(n){let e=wp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var mi=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function kc(n){let{aptosConfig:e,name:t}=n,r=it(e),{domainName:i,subdomainName:o}=vt(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=mi(s[0]);return a?_chunk4RHBBU7Cjs.pa.from(a):void 0}async function Dc(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=it(e),{domainName:l,subdomainName:f}=vt(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 re=_nullishCoalesce(t.years, () => (1));if(re!==1)throw new Error("For now, names can only be registered for 1 year at a time");let ot=re*31536e3,ko={function:`${d}::router::register_domain`,functionArguments:[l,ot,o,s]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(i).toString(),data:ko,options:a}),data:ko}}if(!f)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await Ko({aptosConfig:e,name:l});if(!y)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:y;if(b>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");let D={function:`${d}::router::register_subdomain`,functionArguments:[l,f,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(i).toString(),data:D,options:a}),data:D}}async function Ko(n){let{aptosConfig:e,name:t}=n,r=it(e),{domainName:i,subdomainName:o}=vt(t);try{let s=await le({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Fc(n){let{aptosConfig:e,address:t}=n,r=it(e),i=await le({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk4RHBBU7Cjs.pa.from(t).toString()]}}),o=mi(i[1]),s=mi(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Nc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=it(e);if(!r){let l={function:`${o}::router::clear_primary_name`,functionArguments:[]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(t).toString(),data:l,options:i}),data:l}}let{domainName:s,subdomainName:a}=vt(r),c={function:`${o}::router::set_primary_name`,functionArguments:[s,a]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(t).toString(),data:c,options:i}),data:c}}async function Oc(n){let{aptosConfig:e,name:t}=n,r=it(e),{domainName:i,subdomainName:o}=vt(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=mi(s[0]);return a?_chunk4RHBBU7Cjs.pa.from(a):void 0}async function Bc(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=it(e),{domainName:a,subdomainName:c}=vt(r),d={function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(t).toString(),data:d,options:o}),data:d}}async function Gc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=it(e),{domainName:s,subdomainName:a}=vt(r),c={function:`${o}::router::clear_target_addr`,functionArguments:[s,_nullishCoalesce(a, () => (null))]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(t).toString(),data:c,options:i}),data:c}}async function Mc(n){let{aptosConfig:e,name:t}=n,r=await Dn({aptosConfig:e}),{domainName:i,subdomainName:o=""}=vt(t),c=(await w({aptosConfig:e,query:{query:Kn,variables:{where_condition:{domain:{_eq:i},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return c?lr({aptosConfig:e,name:c,gracePeriod:r}):void 0}async function Vc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Dn({aptosConfig:e}),o=await $c({aptosConfig:e}),s=await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:Kn,variables:{limit:_optionalChain([t, 'optionalAccess', _239 => _239.limit]),offset:_optionalChain([t, 'optionalAccess', _240 => _240.offset]),order_by:_optionalChain([t, 'optionalAccess', _241 => _241.orderBy]),where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},..._nullishCoalesce(_optionalChain([n, 'access', _242 => _242.options, 'optionalAccess', _243 => _243.where]), () => ({}))}}}}),a=s.current_aptos_names.map(d=>lr({aptosConfig:e,name:d,gracePeriod:i})),c=_nullishCoalesce(_optionalChain([s, 'access', _244 => _244.current_aptos_names_aggregate, 'access', _245 => _245.aggregate, 'optionalAccess', _246 => _246.count]), () => (0));return{names:a,total:c}}async function Hc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Dn({aptosConfig:e}),o=await $c({aptosConfig:e}),s=await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Kn,variables:{limit:_optionalChain([t, 'optionalAccess', _247 => _247.limit]),offset:_optionalChain([t, 'optionalAccess', _248 => _248.offset]),order_by:_optionalChain([t, 'optionalAccess', _249 => _249.orderBy]),where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""},..._nullishCoalesce(_optionalChain([n, 'access', _250 => _250.options, 'optionalAccess', _251 => _251.where]), () => ({}))}}}}),a=s.current_aptos_names.map(d=>lr({aptosConfig:e,name:d,gracePeriod:i})),c=_nullishCoalesce(_optionalChain([s, 'access', _252 => _252.current_aptos_names_aggregate, 'access', _253 => _253.aggregate, 'optionalAccess', _254 => _254.count]), () => (0));return{names:a,total:c}}async function qc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Dn({aptosConfig:e}),o=await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Kn,variables:{limit:_optionalChain([t, 'optionalAccess', _255 => _255.limit]),offset:_optionalChain([t, 'optionalAccess', _256 => _256.offset]),order_by:_optionalChain([t, 'optionalAccess', _257 => _257.orderBy]),where_condition:{owner_address:{_eq:r.toString()},subdomain:{_neq:""},..._nullishCoalesce(_optionalChain([n, 'access', _258 => _258.options, 'optionalAccess', _259 => _259.where]), () => ({}))}}}}),s=o.current_aptos_names.map(c=>lr({aptosConfig:e,name:c,gracePeriod:i})),a=_nullishCoalesce(_optionalChain([o, 'access', _260 => _260.current_aptos_names_aggregate, 'access', _261 => _261.aggregate, 'optionalAccess', _262 => _262.count]), () => (0));return{names:s,total:a}}async function Lc(n){let{aptosConfig:e,options:t,domain:r}=n,i=await Dn({aptosConfig:e}),o=await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Kn,variables:{limit:_optionalChain([t, 'optionalAccess', _263 => _263.limit]),offset:_optionalChain([t, 'optionalAccess', _264 => _264.offset]),order_by:_optionalChain([t, 'optionalAccess', _265 => _265.orderBy]),where_condition:{domain:{_eq:r},subdomain:{_neq:""},..._nullishCoalesce(_optionalChain([n, 'access', _266 => _266.options, 'optionalAccess', _267 => _267.where]), () => ({}))}}}}),s=o.current_aptos_names.map(c=>lr({aptosConfig:e,name:c,gracePeriod:i})),a=_nullishCoalesce(_optionalChain([o, 'access', _268 => _268.current_aptos_names_aggregate, 'access', _269 => _269.aggregate, 'optionalAccess', _270 => _270.count]), () => (0));return{names:s,total:a}}async function $c(n){let{aptosConfig:e}=n,r=await Dn({aptosConfig:e})/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-r)).toISOString()}async function Dn(n){if(vo)return vo;let{aptosConfig:e}=n,t=it(e),[r]=await le({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}});return vo=r,r}async function Wc(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=it(e),a=i*31536e3,{domainName:c,subdomainName:d}=vt(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");let l={function:`${s}::router::renew_domain`,functionArguments:[c,a]};return{transaction:await T({aptosConfig:e,sender:_chunk4RHBBU7Cjs.pa.from(t).toString(),data:l,options:o}),data:l}}function lr({name:n,aptosConfig:e,gracePeriod:t}){let r=n.expiration_timestamp+"Z",i=n.domain_expiration_timestamp+"Z",o=!!n.subdomain,s=n.subdomain_expiration_policy,a=o&&s===1?i:r,c=bp({aptosConfig:e,name:n,gracePeriod:t}),d=!1;if(c==="in_grace_period")d=!0;else if(c==="active"){let l=new Date;l.setMonth(l.getMonth()+hp),d=new Date(a)<l}return{domain:n.domain,subdomain:n.subdomain||void 0,expiration_timestamp:r,expiration_status:c,domain_expiration_timestamp:i,expiration:new Date(a),token_standard:n.token_standard,is_primary:n.is_primary,subdomain_expiration_policy:_nullishCoalesce(n.subdomain_expiration_policy, () => (1)),owner_address:_nullishCoalesce(n.owner_address, () => ("")),registered_address:n.registered_address,isInRenewablePeriod:d}}var gr=class{constructor(e){this.config=e}async getOwnerAddress(e){return kc({aptosConfig:this.config,...e})}async getExpiration(e){return Ko({aptosConfig:this.config,...e})}async getTargetAddress(e){return Oc({aptosConfig:this.config,...e})}async setTargetAddress(e){return Bc({aptosConfig:this.config,...e})}async clearTargetAddress(e){return Gc({aptosConfig:this.config,...e})}async getPrimaryName(e){return Fc({aptosConfig:this.config,...e})}async setPrimaryName(e){return Nc({aptosConfig:this.config,...e})}async registerName(e){return Dc({aptosConfig:this.config,...e})}async renewDomain(e){return Wc({aptosConfig:this.config,...e})}async getName(e){return Mc({aptosConfig:this.config,...e})}async getAccountNames(e){return Vc({aptosConfig:this.config,...e})}async getAccountDomains(e){return Hc({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return qc({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Lc({aptosConfig:this.config,...e})}};async function Qc(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ji,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 jc(n){let{aptosConfig:e,options:t}=n,r={query:Ji,variables:{order_by:_optionalChain([t, 'optionalAccess', _271 => _271.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Jc(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ia,variables:{delegatorAddress:_chunk4RHBBU7Cjs.pa.from(t).toStringLong(),poolAddress:_chunk4RHBBU7Cjs.pa.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var yr=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _272 => _272.minimumLedgerVersion]),processorType:"stake_processor"}),Qc({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _273 => _273.minimumLedgerVersion]),processorType:"stake_processor"}),jc({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await I({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _274 => _274.minimumLedgerVersion]),processorType:"stake_processor"}),Jc({aptosConfig:this.config,...e})}};var fi=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 Ro(n,e){if(!(n.getTransactionSubmitter()!==void 0||e.transactionSubmitter!==void 0)&&e.transaction.feePayerAddress&&!e.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator")}function Uo(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var Fn=class{constructor(e){this.config=e}async simple(e){return wo({aptosConfig:this.config,...e})}async multiAgent(e){return wo({aptosConfig:this.config,...e})}};_chunk4RHBBU7Cjs.a.call(void 0, [Uo],Fn.prototype,"simple",1),_chunk4RHBBU7Cjs.a.call(void 0, [Uo],Fn.prototype,"multiAgent",1);var Ai=class{constructor(e){this.config=e}async simple(e){return Ro(this.config,e),ir({aptosConfig:this.config,...e})}async multiAgent(e){return Ro(this.config,e),ir({aptosConfig:this.config,...e})}};var hi=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 _chunk4RHBBU7Cjs.ua.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=_chunk4RHBBU7Cjs.wa.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk4RHBBU7Cjs.ua.call(void 0, this.sleepTime),_chunk4RHBBU7Cjs.wa.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 zn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await zn({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 _chunk4RHBBU7Cjs.ua.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk4RHBBU7Cjs.wa.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk4RHBBU7Cjs.wa.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 _chunk4RHBBU7Cjs.ua.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var Nn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _275 => _275.pendingDequeue, 'access', _276 => _276.shift, 'call', _277 => _277(), 'optionalAccess', _278 => _278.resolve, 'call', _279 => _279(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 On("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},On=class extends Error{};var Xc="fulfilled",Yc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Yc||{}),bi= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Nn;this.transactionsQueue=new Nn;this.outstandingTransactions=new Nn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new hi(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=di({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof On)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===Xc?(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 On)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Rn({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===Xc?(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,replayProtectionNonce:void 0}})}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 Ti=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new bi(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 mr=class{constructor(e){this.config=e,this.build=new fi(this.config),this.simulate=new Fn(this.config),this.submit=new Ai(this.config),this.batch=new Ti(this.config)}async getTransactions(e){return eo({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return fa({aptosConfig:this.config,...e})}async getTransactionByHash(e){return nr({aptosConfig:this.config,...e})}async isPendingTransaction(e){return Aa({aptosConfig:this.config,...e})}async waitForTransaction(e){return Rn({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return ni({aptosConfig:this.config})}getSigningMessage(e){return ka(e)}async publishPackageTransaction(e){return Fa({aptosConfig:this.config,...e})}async rotateAuthKey(e){return ja({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return Ja({aptosConfig:this.config,...e})}sign(e){return ci({...e})}signAsFeePayer(e){return ui({...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 di({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Da({aptosConfig:this.config,...e})}};var fr=class{constructor(e){this.config=e}async getTableItem(e){return ei({aptosConfig:this.config,...e})}async getTableItemsData(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ya({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ma({aptosConfig:this.config,...e})}};async function wi(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:_chunk4RHBBU7Cjs.v.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Us({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk4RHBBU7Cjs.v.fromHexInput(a.pepper).toUint8Array()}async function zo(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await wi(n),uidKey:o="sub",maxExpHorizonSecs:s=(await ln({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk4RHBBU7Cjs.v.fromHexInput(i).toUint8Array().length!==ve.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${ve.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:_chunk4RHBBU7Cjs.v.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk4RHBBU7Cjs.v.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await zs({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,f=new Ft({a:l.a,b:l.b,c:l.c});return new me({proof:new pn(f,0),trainingWheelsSignature:Je.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Zc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await wi(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await ln({aptosConfig:e}),d=zo({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let y=L.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await or({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return Qe.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let f=R.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await or({aptosConfig:e,authenticationKey:f.authKey().derivedAddress()});return ve.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function eu(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(xs.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}`,E.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,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 Ar=class{constructor(e){this.config=e}async getPepper(e){return wi({aptosConfig:this.config,...e})}async getProof(e){return zo({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Zc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return eu({aptosConfig:this.config,...e})}};async function Ep(n){let{aptosConfig:e,options:t}=n,r={query:jr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _280 => _280.where]),offset:_optionalChain([t, 'optionalAccess', _281 => _281.offset]),limit:_optionalChain([t, 'optionalAccess', _282 => _282.limit]),order_by:_optionalChain([t, 'optionalAccess', _283 => _283.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function tu(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk4RHBBU7Cjs.pa.from(t).toStringLong()}};return(await Ep({aptosConfig:e,options:{...r,where:o}}))[0]}var hr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await I({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),tu({aptosConfig:this.config,...e})}};var se=class{constructor(e){this.config=_nullishCoalesce(e, () => (new gi)),this.account=new sr(this.config),this.abstraction=new sn(this.config),this.ans=new gr(this.config),this.coin=new ar(this.config),this.digitalAsset=new cr(this.config),this.faucet=new ur(this.config),this.fungibleAsset=new dr(this.config),this.general=new pr(this.config),this.staking=new yr(this.config),this.transaction=new mr(this.config),this.table=new fr(this.config),this.keyless=new Ar(this.config),this.object=new hr(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function we(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value:function(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}we(se,sr,"account");we(se,sn,"abstraction");we(se,gr,"ans");we(se,ar,"coin");we(se,cr,"digitalAsset");we(se,ur,"faucet");we(se,dr,"fungibleAsset");we(se,pr,"general");we(se,yr,"staking");we(se,mr,"transaction");we(se,fr,"table");we(se,Ar,"keyless");we(se,hr,"object");exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT = _s; exports.APTOS_BIP44_REGEX = bu; exports.APTOS_COIN = Ht; exports.APTOS_FA = Ps; exports.APTOS_HARDENED_REGEX = hu; exports.AbstractKeylessAccount = Te; exports.AbstractMultiKey = qe; exports.AbstractPublicKey = Ir; exports.AbstractSignature = Mn; exports.AbstractedAccount = Wr; exports.Account = _t; exports.AccountAbstractionMessage = Fr; exports.AccountAddress = _chunk4RHBBU7Cjs.pa; exports.AccountAuthenticator = te; exports.AccountAuthenticatorAbstraction = $t; exports.AccountAuthenticatorEd25519 = $e; exports.AccountAuthenticatorMultiEd25519 = lt; exports.AccountAuthenticatorMultiKey = nt; exports.AccountAuthenticatorNoAccountAuthenticator = bn; exports.AccountAuthenticatorSingleKey = ue; exports.AccountAuthenticatorVariant = _chunk4RHBBU7Cjs.L; exports.AccountPublicKey = ae; exports.AccountSequenceNumber = hi; exports.AccountUtils = Hs; exports.AddressInvalidReason = _chunk4RHBBU7Cjs.oa; exports.AnyPublicKey = x; exports.AnyPublicKeyVariant = _chunk4RHBBU7Cjs.N; exports.AnySignature = G; exports.AnySignatureVariant = _chunk4RHBBU7Cjs.P; exports.Aptos = se; exports.AptosApiError = Pe; exports.AptosApiType = un; exports.AptosConfig = gi; exports.AuthenticationKey = H; exports.Bool = N; exports.CKDPriv = ys; exports.ChainId = Tn; exports.DEFAULT_MAX_GAS_AMOUNT = Ss; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Is; exports.DEFAULT_TXN_TIMEOUT_SEC = _r; exports.DerivableAbstractedAccount = Ls; exports.DeriveScheme = _chunk4RHBBU7Cjs.la; exports.Deserializer = K; exports.EPK_HORIZON_SECS = Yu; exports.Ed25519Account = oe; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = P; exports.Ed25519Signature = U; exports.EntryFunction = It; exports.EntryFunctionBytes = Sr; exports.EphemeralCertificate = dn; exports.EphemeralCertificateVariant = _chunk4RHBBU7Cjs.S; exports.EphemeralKeyPair = tn; exports.EphemeralPublicKey = zt; exports.EphemeralPublicKeyVariant = _chunk4RHBBU7Cjs.Q; exports.EphemeralSignature = Je; exports.EphemeralSignatureVariant = _chunk4RHBBU7Cjs.R; exports.ExpirationStatus = _chunk4RHBBU7Cjs.na; exports.FIREBASE_AUTH_ISS_PATTERN = xs; exports.FederatedKeylessAccount = Qe; exports.FederatedKeylessPublicKey = L; exports.FeePayerRawTransaction = Xt; exports.FixedBytes = Re; exports.Groth16ProofAndStatement = Bi; exports.Groth16VerificationKey = Mi; exports.Groth16Zkp = Ft; exports.HARDENED_OFFSET = ps; exports.Hex = _chunk4RHBBU7Cjs.v; exports.HexInvalidReason = _chunk4RHBBU7Cjs.u; exports.I128 = Be; exports.I16 = Fe; exports.I256 = Ge; exports.I32 = Ne; exports.I64 = Oe; exports.I8 = De; exports.Identifier = F; exports.KeyType = Tu; exports.KeylessAccount = ve; exports.KeylessConfiguration = Gi; exports.KeylessError = E; exports.KeylessErrorCategory = qu; exports.KeylessErrorResolutionTip = Lu; exports.KeylessErrorType = xr; exports.KeylessPublicKey = R; exports.KeylessSignature = ce; exports.MAX_AUD_VAL_BYTES = Ni; exports.MAX_COMMITED_EPK_BYTES = id; exports.MAX_EXTRA_FIELD_BYTES = nd; exports.MAX_ISS_VAL_BYTES = td; exports.MAX_JWT_HEADER_B64_BYTES = rd; exports.MAX_UID_KEY_BYTES = Zu; exports.MAX_UID_VAL_BYTES = ed; exports.MimeType = _chunk4RHBBU7Cjs.C; exports.ModuleId = jn; exports.MoveAbility = _chunk4RHBBU7Cjs.ha; exports.MoveFunctionVisibility = _chunk4RHBBU7Cjs.ga; exports.MoveJWK = Vi; exports.MoveOption = B; exports.MoveString = v; exports.MoveVector = S; exports.MultiAgentRawTransaction = Jt; exports.MultiAgentTransaction = Hr; exports.MultiEd25519Account = er; exports.MultiEd25519PublicKey = ie; exports.MultiEd25519Signature = Le; exports.MultiKey = W; exports.MultiKeyAccount = xt; exports.MultiKeySignature = _e; exports.MultiSig = Jn; exports.MultiSigTransactionPayload = Xn; exports.Network = Ri; exports.NetworkToChainId = Ui; exports.NetworkToFaucetAPI = ws; exports.NetworkToIndexerAPI = bs; exports.NetworkToNetworkName = _g; exports.NetworkToNodeAPI = Ts; exports.NetworkToPepperAPI = vi; exports.NetworkToProverAPI = Ki; exports.ParsingError = _chunk4RHBBU7Cjs.t; exports.PrivateKey = Ie; exports.PrivateKeyVariants = _chunk4RHBBU7Cjs.M; exports.ProcessorType = kt; exports.PublicKey = at; exports.RAW_TRANSACTION_SALT = Es; exports.RAW_TRANSACTION_WITH_DATA_SALT = zi; exports.RawTransaction = Ce; exports.RawTransactionWithData = Gr; exports.RoleType = _chunk4RHBBU7Cjs.ia; exports.RotationProofChallenge = Mr; exports.Script = Pn; exports.ScriptTransactionArgumentVariants = _chunk4RHBBU7Cjs.E; exports.Secp256k1PrivateKey = dt; exports.Secp256k1PublicKey = He; exports.Secp256k1Signature = pt; exports.Secp256r1PrivateKey = Ns; exports.Secp256r1PublicKey = An; exports.Secp256r1Signature = Li; exports.Serializable = _chunk4RHBBU7Cjs.x; exports.Serialized = Gn; exports.Serializer = _chunk4RHBBU7Cjs.y; exports.Signature = O; exports.SignedTransaction = Et; exports.SigningScheme = _chunk4RHBBU7Cjs.ja; exports.SigningSchemeInput = _chunk4RHBBU7Cjs.ka; exports.SimpleTransaction = Vr; exports.SingleKeyAccount = pe; exports.StructTag = rt; exports.SubdomainExpirationPolicy = _chunk4RHBBU7Cjs.ma; exports.TransactionAndProof = Lr; exports.TransactionAuthenticator = Pt; exports.TransactionAuthenticatorEd25519 = Yt; exports.TransactionAuthenticatorFeePayer = en; exports.TransactionAuthenticatorMultiAgent = Zt; exports.TransactionAuthenticatorMultiEd25519 = xn; exports.TransactionAuthenticatorSingleSender = Bt; exports.TransactionAuthenticatorVariant = _chunk4RHBBU7Cjs.K; exports.TransactionExecutable = En; exports.TransactionExecutableEmpty = Zn; exports.TransactionExecutableEntryFunction = _n; exports.TransactionExecutableScript = Yn; exports.TransactionExecutableVariants = _chunk4RHBBU7Cjs.H; exports.TransactionExtraConfig = Br; exports.TransactionExtraConfigV1 = jt; exports.TransactionExtraConfigVariants = _chunk4RHBBU7Cjs.I; exports.TransactionInnerPayload = Or; exports.TransactionInnerPayloadV1 = Qt; exports.TransactionInnerPayloadVariants = _chunk4RHBBU7Cjs.G; exports.TransactionPayload = Ot; exports.TransactionPayloadEntryFunction = Sn; exports.TransactionPayloadMultiSig = In; exports.TransactionPayloadScript = wn; exports.TransactionPayloadVariants = _chunk4RHBBU7Cjs.F; exports.TransactionResponseType = _chunk4RHBBU7Cjs.U; exports.TransactionVariants = _chunk4RHBBU7Cjs.J; exports.TransactionWorker = bi; exports.TransactionWorkerEventsEnum = Yc; exports.TypeTag = z; exports.TypeTagAddress = M; exports.TypeTagBool = Q; exports.TypeTagGeneric = V; exports.TypeTagI128 = Tt; exports.TypeTagI16 = mt; exports.TypeTagI256 = St; exports.TypeTagI32 = At; exports.TypeTagI64 = ht; exports.TypeTagI8 = gt; exports.TypeTagParserError = X; exports.TypeTagParserErrorType = vd; exports.TypeTagReference = Nr; exports.TypeTagSigner = Wt; exports.TypeTagStruct = h; exports.TypeTagU128 = bt; exports.TypeTagU16 = yt; exports.TypeTagU256 = wt; exports.TypeTagU32 = ft; exports.TypeTagU64 = ne; exports.TypeTagU8 = de; exports.TypeTagVariants = _chunk4RHBBU7Cjs.D; exports.TypeTagVector = k; exports.U128 = ke; exports.U16 = Ue; exports.U256 = Se; exports.U32 = ze; exports.U64 = $; exports.U8 = ee; exports.WebAuthnSignature = Qn; exports.ZeroKnowledgeSig = me; exports.ZkProof = pn; exports.ZkpVariant = _chunk4RHBBU7Cjs.T; exports.anyPublicKeyVariantToString = _chunk4RHBBU7Cjs.O; exports.aptosCoinStructTag = qA; exports.aptosRequest = Cr; exports.base64UrlDecode = _chunk4RHBBU7Cjs.ya; exports.base64UrlToBytes = _chunk4RHBBU7Cjs.za; exports.bigIntToBytesLE = Ci; exports.buildTransaction = bo; exports.bytesToBigIntLE = Mt; exports.checkOrConvertArgument = on; exports.convertAmountFromHumanReadableToOnChain = _chunk4RHBBU7Cjs.Aa; exports.convertAmountFromOnChainToHumanReadable = _chunk4RHBBU7Cjs.Ba; exports.convertArgument = ho; exports.convertNumber = nn; exports.convertPayloadToInnerPayload = Gd; exports.createObjectAddress = _chunk4RHBBU7Cjs.qa; exports.createResourceAddress = _chunk4RHBBU7Cjs.ra; exports.createTokenAddress = _chunk4RHBBU7Cjs.ta; exports.createUserDerivedObjectAddress = _chunk4RHBBU7Cjs.sa; exports.deriveKey = _i; exports.deriveTransactionType = qr; exports.deserializeFromScriptArgument = yd; exports.deserializePublicKey = qf; exports.deserializeSignature = Lf; exports.ensureBoolean = _chunk4RHBBU7Cjs.z; exports.fetchEntryFunctionAbi = Ca; exports.fetchFunctionAbi = Ao; exports.fetchJWK = qi; exports.fetchModuleAbi = zd; exports.fetchMoveFunctionAbi = GS; exports.fetchViewFunctionAbi = va; exports.findFirstNonSignerArg = xa; exports.floorToWholeHour = _chunk4RHBBU7Cjs.xa; exports.generateRawTransaction = Bd; exports.generateSignedTransaction = To; exports.generateSignedTransactionForSimulation = Ra; exports.generateSigningMessage = et; exports.generateSigningMessageForSerializable = ib; exports.generateSigningMessageForTransaction = We; exports.generateTransactionPayload = ai; exports.generateTransactionPayloadWithABI = Fd; exports.generateUserTransactionHash = gI; exports.generateViewFunctionPayload = Ka; exports.generateViewFunctionPayloadWithABI = Nd; exports.get = vr; exports.getAptosFullNode = q; exports.getAptosPepperService = Zg; exports.getAuthenticatorForSimulation = Un; exports.getErrorMessage = _chunk4RHBBU7Cjs.va; exports.getFunctionParts = _chunk4RHBBU7Cjs.Ea; exports.getIssAudAndUidVal = ut; exports.getKeylessConfig = ln; exports.getKeylessJWKs = cd; exports.getPageWithObfuscatedCursor = Rr; exports.hashStrToField = Xe; exports.hashValues = Ua; exports.hexToAsciiString = _chunk4RHBBU7Cjs.w; exports.isBcsAddress = ii; exports.isBcsBool = to; exports.isBcsFixedBytes = Rd; exports.isBcsI128 = yo; exports.isBcsI16 = po; exports.isBcsI256 = mo; exports.isBcsI32 = lo; exports.isBcsI64 = go; exports.isBcsI8 = uo; exports.isBcsString = no; exports.isBcsU128 = ao; exports.isBcsU16 = io; exports.isBcsU256 = co; exports.isBcsU32 = oo; exports.isBcsU64 = so; exports.isBcsU8 = ro; exports.isBlockEpilogueTransactionResponse = _chunk4RHBBU7Cjs.$; exports.isBlockMetadataTransactionResponse = _chunk4RHBBU7Cjs.Y; exports.isBool = Ia; exports.isCanonicalEd25519Signature = gd; exports.isEd25519Signature = _chunk4RHBBU7Cjs.aa; exports.isEmptyOption = Pa; exports.isEncodedEntryFunctionArgument = Ea; exports.isEncodedStruct = _chunk4RHBBU7Cjs.Da; exports.isFeePayerSignature = _chunk4RHBBU7Cjs.da; exports.isGenesisTransactionResponse = _chunk4RHBBU7Cjs.X; exports.isKeylessSigner = $r; exports.isLargeNumber = rn; exports.isMultiAgentSignature = _chunk4RHBBU7Cjs.ca; exports.isMultiEd25519Signature = _chunk4RHBBU7Cjs.ea; exports.isNumber = Kd; exports.isPendingTransactionResponse = _chunk4RHBBU7Cjs.V; exports.isScriptDataInput = _a; exports.isSecp256k1Signature = _chunk4RHBBU7Cjs.ba; exports.isSingleKeySigner = Qi; exports.isSingleSenderSignature = _chunk4RHBBU7Cjs.fa; exports.isStateCheckpointTransactionResponse = _chunk4RHBBU7Cjs.Z; exports.isString = Ct; exports.isUserTransactionResponse = _chunk4RHBBU7Cjs.W; exports.isValidBIP44Path = ls; exports.isValidFunctionInfo = _chunk4RHBBU7Cjs.Fa; exports.isValidHardenedPath = gs; exports.isValidatorTransactionResponse = _chunk4RHBBU7Cjs._; exports.mnemonicToSeed = Pr; exports.normalizeBundle = Cs; exports.nowInSeconds = _chunk4RHBBU7Cjs.wa; exports.objectStructTag = be; exports.optionStructTag = LA; exports.outOfRangeErrorMessage = _chunk4RHBBU7Cjs.A; exports.padAndPackBytesWithLen = Hn; exports.paginateWithCursor = Kr; exports.paginateWithObfuscatedCursor = Di; exports.pairedFaMetadataAddress = _chunk4RHBBU7Cjs.Ha; exports.parseEncodedStruct = _chunk4RHBBU7Cjs.Ca; exports.parseJwtHeader = dd; exports.parseTypeTag = je; exports.poseidonHash = Vt; exports.post = qn; exports.postAptosFaucet = Rs; exports.postAptosFullNode = Dt; exports.postAptosIndexer = Ks; exports.postAptosPepperService = Us; exports.postAptosProvingService = zs; exports.promiseFulfilledStatus = Xc; exports.request = Qu; exports.sleep = _chunk4RHBBU7Cjs.ua; exports.splitPath = ms; exports.standardizeTypeTags = oi; exports.stringStructTag = C; exports.throwTypeMismatch = _; exports.truncateAddress = _chunk4RHBBU7Cjs.Ga; exports.validateNumberInRange = _chunk4RHBBU7Cjs.B; exports.verifyKeylessSignature = Hi; exports.verifyKeylessSignatureWithJwkAndConfig = Ur;
475
+ `;var Nd=10*1e3;async function Yr(n){let{aptosConfig:e}=n,t=`ledger-info-${e.network}`;return re(async()=>{let{data:r}=await q({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return r},t,Nd)()}async function ha(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:ca,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Ns({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Fd(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Zi},originMethod:"getProcessorStatuses"})).processor_status}async function Zr(n){let e=await Fd({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function ei(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Zi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function ti(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await q({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}`});return r}async function Ta(n){return _optionalChain([n, 'access', _66 => _66.options, 'optionalAccess', _67 => _67.ledgerVersion])!==void 0?ba(n):re(async()=>ba(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ba(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await q({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _68 => _68.ledgerVersion])}});return o}async function ni(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await dt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _69 => _69.ledgerVersion])},body:r})).data}async function wa(n){let{aptosConfig:e,options:t}=n,r={query:ya,variables:{where_condition:_optionalChain([t, 'optionalAccess', _70 => _70.where]),offset:_optionalChain([t, 'optionalAccess', _71 => _71.offset]),limit:_optionalChain([t, 'optionalAccess', _72 => _72.limit]),order_by:_optionalChain([t, 'optionalAccess', _73 => _73.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function Sa(n){let{aptosConfig:e,options:t}=n,r={query:ma,variables:{where_condition:_optionalChain([t, 'optionalAccess', _74 => _74.where]),offset:_optionalChain([t, 'optionalAccess', _75 => _75.offset]),limit:_optionalChain([t, 'optionalAccess', _76 => _76.limit]),order_by:_optionalChain([t, 'optionalAccess', _77 => _77.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function no(n){let{aptosConfig:e,options:t}=n;return Ur({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([t, 'optionalAccess', _79 => _79.limit])}})}async function ii(n){let{aptosConfig:e}=n;return re(async()=>{let{data:t}=await q({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function Ia(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await q({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function or(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await q({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function Ea(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await or({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _80 => _80.status])===404)return!0;throw r}}async function Od(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await q({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function zn(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _82 => _82.checkSuccess]), () => (!0)),s=!0,a=0,c,d,l=200,f=1.5;function p(y){if(!(y instanceof _e)||(d=y,y.status!==404&&y.status>=400&&y.status<500))throw y}try{c=await or({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(y){p(y)}if(s){let y=Date.now();try{c=await Od({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-y)/1e3}for(;s&&!(a>=i);){try{if(c=await or({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(y){p(y)}await _chunk2VR6ONNWjs.Ja.call(void 0, l),a+=l/1e3,l*=f}if(c===void 0)throw d||new ri(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new ri(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new to(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function oi(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=Date.now(),s=BigInt(-1);for(;s<r;){if(Date.now()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await Zr({aptosConfig:e}):s=(await ei({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk2VR6ONNWjs.Ja.call(void 0, 200)}}var ri=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},to=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function Pa(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])}});return xa({block:i,...n})}async function _a(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _84 => _84.withTransactions])}});return xa({block:i,...n})}async function xa(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _85 => _85.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', _86 => _86.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(no({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 va(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Ca(n){return!!n.match(/\s/)}function Gd(n){return!!n.match(/^T[0-9]+$/)}function Bd(n){return!!n.match(/^&.+$/)}function Md(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":case"i8":case"i16":case"i32":case"i64":case"i128":case"i256":return!0;default:return!1}}function Vd(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Ca(r))break}return t}var Hd=(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))(Hd||{}),X= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Xe(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _87 => _87.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=sr(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new X(n,"unexpected '>'");if(c!==o.length)throw new X(n,"type argument count doesn't match expected amount");let{savedStr:f,savedTypes:p,savedExpectedTypes:y}=l;i=o,o=p,a=f,c=y}else if(d===","){if(r.length===0)throw new X(n,"unexpected ','");if(a.length===0)throw new X(n,"no type argument before ','");let l=sr(a,i,t);i=[],o.push(l),a="",c+=1}else if(Ca(d)){let l=!1;if(a.length!==0){let p=sr(a,i,t);i=[],o.push(p),a="",l=!0}s=Vd(n,s);let f=n[s];if(s<n.length&&l&&f!==","&&f!==">")throw new X(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new X(n,"no matching '>' for '<'");switch(o.length){case 0:return sr(a,i,t);case 1:if(a==="")return o[0];throw new X(n,"unexpected ','");default:throw new X(n,"unexpected whitespace character")}}function sr(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Md(i)&&e.length>0)throw new X(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new jt;case"bool":return new Q;case"address":return new M;case"u8":return new pe;case"u16":return new At;case"u32":return new bt;case"u64":return new ne;case"u128":return new St;case"u256":return new Et;case"i8":return new ft;case"i16":return new ht;case"i32":return new Tt;case"i64":return new wt;case"i128":return new It;case"i256":return new Pt;case"vector":if(e.length!==1)throw new X(n,"vector type expected to have exactly one type argument");return new k(e[0]);default:{if(Bd(r)){let a=r.substring(1);return new Gr(sr(a,e,t))}if(Gd(r)){if(t)return new V(Number(r.split("T")[1]));throw new X(n,"unexpected generic type")}if(!r.match(/:/))throw new X(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new X(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk2VR6ONNWjs.Ca.fromString(o[0])}catch (e4){throw new X(n,"struct address must be valid")}if(!va(o[1]))throw new X(n,"module name must only contain alphanumeric or '_' characters");if(!va(o[2]))throw new X(n,"struct name must only contain alphanumeric or '_' characters");return new h(new ot(s,new N(o[1]),new N(o[2]),e))}}}function Ka(n){return typeof n=="boolean"}function Rt(n){return typeof n=="string"}function qd(n){return typeof n=="number"}function on(n){if(qd(n))return n;if(Rt(n)&&n!=="")return Number.parseInt(n,10)}function sn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ra(n){return n==null}function Ua(n){return ro(n)||oo(n)||so(n)||ao(n)||co(n)||uo(n)||po(n)||si(n)||io(n)||Ld(n)||lo(n)||go(n)||yo(n)||mo(n)||fo(n)||Ao(n)||n instanceof S||n instanceof G}function ro(n){return n instanceof F}function si(n){return n instanceof _chunk2VR6ONNWjs.Ca}function io(n){return n instanceof C}function Ld(n){return n instanceof ze}function oo(n){return n instanceof ee}function so(n){return n instanceof ke}function ao(n){return n instanceof De}function co(n){return n instanceof $}function uo(n){return n instanceof Ne}function po(n){return n instanceof Ee}function lo(n){return n instanceof Fe}function go(n){return n instanceof Oe}function yo(n){return n instanceof Ge}function mo(n){return n instanceof Be}function fo(n){return n instanceof Me}function Ao(n){return n instanceof Ve}function za(n){return"bytecode"in n}function _(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function ka(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function ai(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _88 => _88.map, 'call', _89 => _89(e=>Rt(e)?Xe(e):e)]), () => ([]))}var $d=300*1e3;async function Wd(n,e,t){let r=`module-abi-${t.network}-${n}-${e}`;return re(async()=>(await ci({aptosConfig:t,accountAddress:n,moduleName:e})).abi,r,$d)()}async function bo(n,e,t,r){let i=await Wd(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 eI(n,e,t,r){let i=await bo(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(Xe(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Da(n,e,t,r){let i=await bo(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=ka(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Xe(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Na(n,e,t,r){let i=await bo(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(Xe(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Xe(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function To(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=Xe(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 an(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function an(n,e,t,r,i,o){return Ua(n)?(ho(e,n,t),n):Qd(n,e,t,r,i,o)}function Qd(n,e,t,r,i,o){if(e.isBool()){if(Ka(n))return new F(n);if(Rt(n)){if(n==="true")return new F(!0);if(n==="false")return new F(!1)}_("boolean",t)}if(e.isAddress()){if(Rt(n))return _chunk2VR6ONNWjs.Ca.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk2VR6ONNWjs.Ca)(n.data);_("string | AccountAddress",t)}if(e.isU8()){let s=on(n);if(s!==void 0)return new ee(s);_("number | string",t)}if(e.isU16()){let s=on(n);if(s!==void 0)return new ke(s);_("number | string",t)}if(e.isU32()){let s=on(n);if(s!==void 0)return new De(s);_("number | string",t)}if(e.isU64()){if(sn(n))return new $(BigInt(n));_("bigint | number | string",t)}if(e.isU128()){if(sn(n))return new Ne(BigInt(n));_("bigint | number | string",t)}if(e.isU256()){if(sn(n))return new Ee(BigInt(n));_("bigint | number | string",t)}if(e.isI8()){let s=on(n);if(s!==void 0)return new Fe(s);_("number | string",t)}if(e.isI16()){let s=on(n);if(s!==void 0)return new Oe(s);_("number | string",t)}if(e.isI32()){let s=on(n);if(s!==void 0)return new Ge(s);_("number | string",t)}if(e.isI64()){if(sn(n))return new Be(BigInt(n));_("bigint | number | string",t)}if(e.isI128()){if(sn(n))return new Me(BigInt(n));_("bigint | number | string",t)}if(e.isI256()){if(sn(n))return new Ve(BigInt(n));_("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 an(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(Rt(n))return S.U8(_chunk2VR6ONNWjs.J.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(Rt(n)&&n.startsWith("["))return an(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>an(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(Rt(n))return new C(n);_("string",t)}if(e.isObject()){if(Rt(n))return _chunk2VR6ONNWjs.Ca.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk2VR6ONNWjs.Ca)(n.data);_("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new ze(n);_("Uint8Array",t)}if(e.isOption()){if(Ra(n)){let a=e.value.typeArgs[0];return a instanceof Q?new G(null):a instanceof M?new G(null):a instanceof pe?new G(null):a instanceof At?new G(null):a instanceof bt?new G(null):a instanceof ne?new G(null):a instanceof St?new G(null):a instanceof Et?new G(null):a instanceof ft?new G(null):a instanceof ht?new G(null):a instanceof Tt?new G(null):a instanceof wt?new G(null):a instanceof It?new G(null):a instanceof Pt?new G(null):new G(null)}return new G(an(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _90 => _90.structs, 'access', _91 => _91.find, 'call', _92 => _92(a=>a.name===e.value.name.identifier), 'optionalAccess', _93 => _93.fields, 'access', _94 => _94.length])===0&&n instanceof Uint8Array)return new ze(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _95 => _95.allowUnknownStructs]))return _chunk2VR6ONNWjs.Ia.call(void 0, `[Aptos SDK] Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new ze(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 ho(n,e,t){if(n.isBool()){if(ro(e))return;_("Bool",t)}if(n.isAddress()){if(si(e))return;_("AccountAddress",t)}if(n.isU8()){if(oo(e))return;_("U8",t)}if(n.isU16()){if(so(e))return;_("U16",t)}if(n.isU32()){if(ao(e))return;_("U32",t)}if(n.isU64()){if(co(e))return;_("U64",t)}if(n.isU128()){if(uo(e))return;_("U128",t)}if(n.isU256()){if(po(e))return;_("U256",t)}if(n.isI8()){if(lo(e))return;_("I8",t)}if(n.isI16()){if(go(e))return;_("I16",t)}if(n.isI32()){if(yo(e))return;_("I32",t)}if(n.isI64()){if(mo(e))return;_("I64",t)}if(n.isI128()){if(fo(e))return;_("I128",t)}if(n.isI256()){if(Ao(e))return;_("I256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&ho(n.value,e.values[0],t);return}_("MoveVector",t)}if(n instanceof h){if(n.isString()){if(io(e))return;_("MoveString",t)}if(n.isObject()){if(si(e))return;_("AccountAddress",t)}if(n.isOption()){if(e instanceof G){e.value!==void 0&&ho(n.value.typeArgs[0],e.value,t);return}_("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ui(n){if(za(n))return Yd(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk2VR6ONNWjs.Ta.call(void 0, n.function),i=await Ba({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Da});return Jd({...n,abi:i})}function Jd(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk2VR6ONNWjs.Ta.call(void 0, n.function),o=ai(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_optionalChain([n, 'access', _96 => _96.functionArguments, 'optionalAccess', _97 => _97.map, 'call', _98 => _98((c,d)=>To(n.function,e,c,d,o))]);if((_nullishCoalesce(_optionalChain([s, 'optionalAccess', _99 => _99.length]), () => (0)))!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${_nullishCoalesce(_optionalChain([s, 'optionalAccess', _100 => _100.length]), () => (0))}`);let a=_t.build(`${t}::${r}`,i,o,_nullishCoalesce(s, () => ([])));if("multisigAddress"in n){let c=_chunk2VR6ONNWjs.Ca.from(n.multisigAddress);return new Pn(new Zn(c,new er(a)))}return new En(a)}async function Fa(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk2VR6ONNWjs.Ta.call(void 0, n.function),i=await Ba({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Na});return Xd({abi:i,...n})}function Xd(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk2VR6ONNWjs.Ta.call(void 0, n.function),o=ai(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', _101 => _101.functionArguments, 'optionalAccess', _102 => _102.map, 'call', _103 => _103((a,c)=>To(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 _t.build(`${t}::${r}`,i,o,s)}function Yd(n){return new In(new _n(_chunk2VR6ONNWjs.v.fromHexInput(n.bytecode).toUint8Array(),ai(n.typeArguments),n.functionArguments))}async function Zd(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(_optionalChain([i, 'optionalAccess', _104 => _104.replayProtectionNonce])!==void 0&&_optionalChain([i, 'optionalAccess', _105 => _105.accountSequenceNumber])!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>Ni[e.network]?{chainId:Ni[e.network]}:{chainId:(await Yr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _106 => _106.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await ii({aptosConfig:e})).gas_estimate},c=async()=>{let Ie=async()=>_optionalChain([i, 'optionalAccess', _107 => _107.accountSequenceNumber])!==void 0?i.accountSequenceNumber:_optionalChain([i, 'optionalAccess', _108 => _108.replayProtectionNonce])!==void 0?0xdeadbeefn:(await ti({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk2VR6ONNWjs.Ca.from(o).equals(_chunk2VR6ONNWjs.Ca.ZERO))try{return await Ie()}catch (e5){return 0}else return Ie()},[{chainId:d},{gasEstimate:l},f]=await Promise.all([s(),a(),c()]),p=_optionalChain([i, 'optionalAccess', _109 => _109.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),{maxGasAmount:y,gasUnitPrice:b,expireTimestamp:D,replayProtectionNonce:Y}={maxGasAmount:p<BigInt(2e3)?BigInt(2e3):p,gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _110 => _110.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _111 => _111.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()))),replayProtectionNonce:_optionalChain([i, 'optionalAccess', _112 => _112.replayProtectionNonce])?BigInt(i.replayProtectionNonce):void 0},ae=r;return Y!==void 0&&(ae=ep(r,Y)),new Ke(_chunk2VR6ONNWjs.Ca.from(t),BigInt(f),ae,BigInt(y),BigInt(b),BigInt(D),new Sn(d))}function ep(n,e){if(n instanceof In)return new Jt(new tr(n.script),new Xt(void 0,e));if(n instanceof En)return new Jt(new vn(n.entryFunction),new Xt(void 0,e));if(n instanceof Pn){let t=n.multiSig.transaction_payload,r;if(t===void 0||_optionalChain([t, 'optionalAccess', _113 => _113.transaction_payload])===void 0)r=new nr;else if(t.transaction_payload instanceof _t)r=new vn(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new Jt(r,new Xt(n.multiSig.multisig_address,e))}throw new Error(`Unsupported payload type: ${n}`)}async function wo(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Zd({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _114 => _114.secondarySignerAddresses, 'optionalAccess', _115 => _115.map, 'call', _116 => _116(c=>_chunk2VR6ONNWjs.Ca.from(c))]), () => ([]));return new Lr(s,a,n.feePayerAddress?_chunk2VR6ONNWjs.Ca.from(n.feePayerAddress):void 0)}return new qr(s,n.feePayerAddress?_chunk2VR6ONNWjs.Ca.from(n.feePayerAddress):void 0)}function Oa(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=kn(e);if(t.feePayerAddress){let a=new Zt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(f=>kn(f)):c=Array.from({length:t.secondarySignerAddresses.length},()=>kn(void 0)));let d=kn(i),l=new nn(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new vt(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Yt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>kn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>kn(void 0));let d=new tn(o,t.secondarySignerAddresses,c);return new vt(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Qe)s=new en(o.public_key,o.signature);else if(o instanceof de||o instanceof it)s=new Bt(o);else if(o instanceof wn)s=new Bt(o);else throw new Error("Invalid public key");return new vt(t.rawTransaction,s).bcsToBytes()}function kn(n){if(!n)return new wn;let t=R.isInstance(n)||L.isInstance(n)||Le.isInstance(n)?new x(n):n,r=new U(new Uint8Array(64));if(P.isInstance(t))return new Qe(t,r);if(x.isInstance(t))return R.isInstance(t.publicKey)?new de(t,new B(ue.getSimulationSignature())):new de(t,new B(r));if(W.isInstance(t))return new it(t,new ve({signatures:t.publicKeys.map(i=>R.isInstance(i.publicKey)||L.isInstance(i.publicKey)?new B(ue.getSimulationSignature()):new B(r)),bitmap:t.createBitmap({bits:new Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function So(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=ks(te,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 nn(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 tn(i,e.secondarySignerAddresses,r)}else i instanceof Qe?o=new en(i.public_key,i.signature):i instanceof mt?o=new Cn(i.public_key,i.signature):o=new Bt(i);return new vt(e.rawTransaction,o).bcsToBytes()}function Ga(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var tp=Ga(["APTOS::Transaction"]);function vI(n){let e=So(n);return new (0, _chunk2VR6ONNWjs.v)(Ga([tp,new Uint8Array([0]),e])).toString()}async function Ba({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:re(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function T(n){let e=await np(n);return rp(n,e)}async function np(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await ui(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ui(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ui(r)),i}async function rp(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ip(n)&&(o=_chunk2VR6ONNWjs.Ca.ZERO.toString()),op(n)){let{secondarySignerAddresses:s}=n;return wo({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return wo({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ip(n){return n.withFeePayer===!0}function op(n){return"secondarySignerAddresses"in n}function Ma(n){let{transaction:e}=n;return je(e)}function di(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function pi(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,di({signer:e,transaction:t})}async function Io(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Oa({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await dt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _117 => _117.options, 'optionalAccess', _118 => _118.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _119 => _119.options, 'optionalAccess', _120 => _120.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _121 => _121.options, 'optionalAccess', _122 => _122.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});if(_optionalChain([n, 'access', _123 => _123.options, 'optionalAccess', _124 => _124.estimateMaxGasAmount])&&c.length>0&&c[0].vm_status==="MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS"){let{data:d}=await dt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _125 => _125.options, 'optionalAccess', _126 => _126.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:!1,estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _127 => _127.options, 'optionalAccess', _128 => _128.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return d}return c}async function ar(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=So({...n});try{let{data:o}=await dt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=vt.deserialize(new K(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof R||s.authenticator.sender.public_key.publicKey instanceof L)&&await we.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function li(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;Qr(t)&&await t.checkKeylessAccountValidity(e),Qr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&pi({signer:r,transaction:i}),a=di({signer:t,transaction:i});return ar({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function Va(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;Qr(r)&&await r.checkKeylessAccountValidity(e);let s=pi({signer:r,transaction:i});return ar({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var sp={typeParameters:[],parameters:[k.u8(),new k(k.u8())]};async function Ha(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:_chunk2VR6ONNWjs.Ca.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:sp},options:o})}async function Dn(n){return ti(n)}async function qa(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Oi({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _129 => _129.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _130 => _130.limit]), () => (1e3))}})}async function La(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await zr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _131 => _131.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _132 => _132.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _133 => _133.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function ci(n){return Ta(n)}async function Po(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Ur({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _134 => _134.offset]),limit:_optionalChain([r, 'optionalAccess', _135 => _135.limit])}})}async function _o(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Oi({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _136 => _136.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _137 => _137.limit]), () => (999))}})}async function $a(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await zr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _138 => _138.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _139 => _139.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _140 => _140.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function xo(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await q({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk2VR6ONNWjs.Ca.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _141 => _141.ledgerVersion])}});return o.data}async function cr(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await xo({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk2VR6ONNWjs.Ca.from(t);try{let a=await ni({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk2VR6ONNWjs.Ca.from(a)}catch(a){if(a instanceof _e&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Wa(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:oa,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 Qa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _142 => _142.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _143 => _143.tokenStandard])});let s={query:ra,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:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ja(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),s=_chunk2VR6ONNWjs.Ca.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _147 => _147.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _148 => _148.tokenStandard])});let c={query:ia,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _149 => _149.offset]),limit:_optionalChain([i, 'optionalAccess', _150 => _150.limit]),order_by:_optionalChain([i, 'optionalAccess', _151 => _151.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Ja(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _152 => _152.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _153 => _153.tokenStandard])}});let s={query:na,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _154 => _154.offset]),limit:_optionalChain([r, 'optionalAccess', _155 => _155.limit]),order_by:_optionalChain([r, 'optionalAccess', _156 => _156.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function Xa(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:sa,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Ya(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _157 => _157.where]),owner_address:{_eq:i}},s={query:ta,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _158 => _158.offset]),limit:_optionalChain([r, 'optionalAccess', _159 => _159.limit]),order_by:_optionalChain([r, 'optionalAccess', _160 => _160.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Za(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:ea,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw new Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function ec(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await q({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?_chunk2VR6ONNWjs.Ca.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function vo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}},s={query:Xr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _161 => _161.offset]),limit:_optionalChain([r, 'optionalAccess', _162 => _162.limit]),order_by:_optionalChain([r, 'optionalAccess', _163 => _163.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function tc(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _164 => _164.throwIfNoAccountFound]), () => (!1)),o=await gi({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return Ct.fromPrivateKey({privateKey:t})}return o[0]}async function ap(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([_o({aptosConfig:e,accountAddress:t}),vo({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!_optionalChain([r, 'optionalAccess', _165 => _165.withAuthKey]))return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var cp={typeParameters:[],parameters:[new pe,k.u8(),new pe,k.u8(),k.u8(),k.u8()]};async function nc(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return Eo({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof oe?Eo({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):Eo({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function Eo(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await Dn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=Ct.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new Hr({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk2VR6ONNWjs.Ca.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new ee(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new ee(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(d.toUint8Array())],abi:cp},options:r})}var up={typeParameters:[],parameters:[new pe,k.u8()]};async function rc(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new ee($s(r)),S.U8(Qi(r).toUint8Array())],abi:up},options:i})}async function yi(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _166 => _166.noMultiKey]), () => (!1));if(i&&t instanceof $e)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof x&&t.publicKey instanceof P?o.push(t.publicKey):t instanceof P&&o.push(new x(t));let[s,a]=await Promise.all([Promise.all(o.map(async f=>{let p=await yp({aptosConfig:e,publicKey:f});if(p)return{...p,publicKey:f}})),!(t instanceof $e)&&!i?pp({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 lp({aptosConfig:e,authKeys:o.map(f=>f.authKey()),options:r});for(let f of l){if(c.find(y=>y.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 Co(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof J||t instanceof gt)return gi({aptosConfig:e,privateKey:t,options:r});if(t instanceof oe||t instanceof le)return gi({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof Re||t instanceof Je)return dp({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof Kt&&t.signers.length===1)return Co({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof rr&&t.signers.length===1)return gi({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function dp(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await yi({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 $e){if(c.getSignaturesRequired()>1)continue;if(c instanceof ie)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof W&&s.push(new Kt({multiKey:c,signers:[t],address:a}))}else t instanceof Je?s.push(Je.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(Re.create({...o,address:a}));return s}async function gi(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=Ct.fromPrivateKey({privateKey:t,legacy:!1}),o=await yi({aptosConfig:e,publicKey:new x(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof $e){if(c.getSignaturesRequired()>1)continue;c instanceof ie?s.push(new rr({publicKey:c,signers:[t],address:a})):c instanceof W&&s.push(new Kt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof P;s.push(Ct.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function pp(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof $e)throw new Error("Public key is a multi-key.");let i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _167 => _167.includeUnverified]), () => (!1)),o=t instanceof x?t:new x(t),s=o.publicKey,a=_chunk2VR6ONNWjs.$.call(void 0, o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},account_public_key:{_is_null:!1},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:aa,variables:{where_condition:c}},{public_key_auth_keys:l}=await w({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return l.filter(p=>p.account_public_key!==null).map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return ie.deserializeWithoutLength(K.fromHex(p.account_public_key));case"multi_key_signature":return W.deserialize(K.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function lp(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _168 => _168.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:Zs,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 H({data:c.auth_key}),accountAddress:new (0, _chunk2VR6ONNWjs.Ca)(_chunk2VR6ONNWjs.v.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function gp(n){let{aptosConfig:e,accountAddress:t}=n,r=await Po({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function yp(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([gp({aptosConfig:e,accountAddress:r}),ap({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function E(n){n.minimumLedgerVersion!==void 0&&await oi({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ge(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Fa({...t,aptosConfig:e}),o=new _chunk2VR6ONNWjs.L;i.serialize(o);let s=o.toUint8Array(),{data:a}=await dt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _169 => _169.ledgerVersion])},body:s});return a}async function ic(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await dt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _170 => _170.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function oc(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk2VR6ONNWjs.Ta.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 M,new h(v()),new h(v())]}},options:i})}async function sc(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk2VR6ONNWjs.Ta.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 M,new h(v()),new h(v())]}},options:i})}async function ac(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 cn=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk2VR6ONNWjs.Ta.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _171 => _171.some, 'call', _172 => _172(s=>_chunk2VR6ONNWjs.Ca.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 oc({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return sc({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ac({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ge({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk2VR6ONNWjs.Ca.from(t)],abi:{typeParameters:[],parameters:[new M],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk2VR6ONNWjs.Ca.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var ur=class{constructor(e){this.config=e;this.abstraction=new cn(e)}async getAccountInfo(e){return Dn({aptosConfig:this.config,...e})}async getAccountModules(e){return qa({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return La({aptosConfig:this.config,...e})}async getAccountModule(e){return ci({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Po({aptosConfig:this.config,...e})}async getAccountResources(e){return _o({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return $a({aptosConfig:this.config,...e})}async getAccountResource(e){return xo({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return cr({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Wa({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Qa({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ja({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ja({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Xa({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ya({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Za({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:_chunk2VR6ONNWjs.C,faMetadataAddress:_chunk2VR6ONNWjs.D,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await re(async()=>{try{let c=(await ge({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&_chunk2VR6ONNWjs.Sa.call(void 0, c.vec[0]))return _chunk2VR6ONNWjs.Ra.call(void 0, c.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=_chunk2VR6ONNWjs.Ca.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===_chunk2VR6ONNWjs.C?s=_chunk2VR6ONNWjs.Ca.A.toStringLong():s=_chunk2VR6ONNWjs.Da.call(void 0, _chunk2VR6ONNWjs.Ca.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=_chunk2VR6ONNWjs.Ca.from(i);s=c.toStringLong(),c===_chunk2VR6ONNWjs.Ca.A&&(o=_chunk2VR6ONNWjs.C)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await ge({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await ge({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return ec({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),vo({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),tc({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Co({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),yi({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var mi=class{constructor(e){if(_optionalChain([e, 'optionalAccess', _173 => _173.fullnode])||_optionalChain([e, 'optionalAccess', _174 => _174.indexer])||_optionalChain([e, 'optionalAccess', _175 => _175.faucet])||_optionalChain([e, 'optionalAccess', _176 => _176.pepper])||_optionalChain([e, 'optionalAccess', _177 => _177.prover])){if(_optionalChain([e, 'optionalAccess', _178 => _178.network])==="custom")console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!_optionalChain([e, 'optionalAccess', _179 => _179.network]))throw new Error("Custom endpoints require a network to be specified")}_chunk2VR6ONNWjs.Ha.call(void 0, )&&_optionalChain([e, 'optionalAccess', _180 => _180.clientConfig, 'optionalAccess', _181 => _181.http2])!==!1&&console.warn("[Aptos SDK] Bun does not fully support HTTP/2, which is enabled by default in this SDK. It is recommended to disable HTTP/2 by setting `clientConfig: { http2: false }` in your AptosConfig. For example: new AptosConfig({ network: Network.TESTNET, clientConfig: { http2: false } })"),this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _182 => _182.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _183 => _183.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _184 => _184.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _185 => _185.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _186 => _186.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _187 => _187.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _188 => _188.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _189 => _189.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _190 => _190.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _191 => _191.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _192 => _192.faucetConfig]), () => ({})),this.transactionGenerationConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _193 => _193.transactionGenerationConfig]), () => ({})),this.pluginConfig=_optionalChain([e, 'optionalAccess', _194 => _194.pluginSettings])?{...e.pluginSettings,IGNORE_TRANSACTION_SUBMITTER:!1}:void 0}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 Us[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 zs[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 Rs[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 zi[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 ki[this.network];default:throw new Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return zi[this.network]===e}isProverServiceRequest(e){return ki[this.network]===e}getDefaultMaxGasAmount(){return _nullishCoalesce(_optionalChain([this, 'access', _195 => _195.transactionGenerationConfig, 'optionalAccess', _196 => _196.defaultMaxGasAmount]), () => (2e6))}getDefaultTxnExpirySecFromNow(){return _nullishCoalesce(_optionalChain([this, 'access', _197 => _197.transactionGenerationConfig, 'optionalAccess', _198 => _198.defaultTxnExpirySecFromNow]), () => (20))}setIgnoreTransactionSubmitter(e){this.pluginConfig&&(this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER=e)}getTransactionSubmitter(){if(this.pluginConfig!==void 0&&this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER!==!0)return this.pluginConfig.TRANSACTION_SUBMITTER}};var fp={typeParameters:[{constraints:[]}],parameters:[new M,new ne]};async function cc(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, () => (_chunk2VR6ONNWjs.C))],functionArguments:[r,i],abi:fp},options:s})}var dr=class{constructor(e){this.config=e}async transferCoinTransaction(e){return cc({aptosConfig:this.config,...e})}};var Mt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Ue="0x4::token::Token";async function uc(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:Aa,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function dc(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:eo,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function pc(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()},amount:{_gt:0}},o={query:eo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _199 => _199.offset]),limit:_optionalChain([r, 'optionalAccess', _200 => _200.limit]),order_by:_optionalChain([r, 'optionalAccess', _201 => _201.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function lc(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}},o={query:fa,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _202 => _202.offset]),limit:_optionalChain([r, 'optionalAccess', _203 => _203.limit]),order_by:_optionalChain([r, 'optionalAccess', _204 => _204.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ap={typeParameters:[],parameters:[new h(v()),new ne,new h(v()),new h(v()),new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new ne,new ne]};async function gc(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 C(n.description),new $(_nullishCoalesce(n.maxSupply, () => (_chunk2VR6ONNWjs.e))),new C(n.name),new C(n.uri),new F(_nullishCoalesce(n.mutableDescription, () => (!0))),new F(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new F(_nullishCoalesce(n.mutableURI, () => (!0))),new F(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new F(_nullishCoalesce(n.mutableTokenName, () => (!0))),new F(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new F(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new F(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new F(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new $(_nullishCoalesce(n.royaltyNumerator, () => (0))),new $(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Ap},options:t})}async function Nn(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _205 => _205.where]);_optionalChain([t, 'optionalAccess', _206 => _206.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _207 => _207.tokenStandard]), () => ("v2"))});let i={query:ua,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _208 => _208.offset]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function yc(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk2VR6ONNWjs.Ca.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _210 => _210.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _211 => _211.tokenStandard]), () => ("v2"))}),Nn({aptosConfig:e,options:{...i,where:s}})}async function mc(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _212 => _212.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _213 => _213.tokenStandard]), () => ("v2"))}),Nn({aptosConfig:e,options:{...r,where:o}})}async function fc(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _214 => _214.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _215 => _215.tokenStandard]), () => ("v2"))}),Nn({aptosConfig:e,options:{...r,where:o}})}async function Ac(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk2VR6ONNWjs.Ca.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _216 => _216.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _217 => _217.tokenStandard]), () => ("v2"))}),(await Nn({aptosConfig:i,options:{where:s}})).collection_id}var hp={typeParameters:[],parameters:[new h(v()),new h(v()),new h(v()),new h(v()),new k(new h(v())),new k(new h(v())),new k(k.u8())]};async function hc(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', _218 => _218.map, 'call', _219 => _219(p=>Mt[p])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new C(i),new C(o),new C(s),new C(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(f, () => ([]))),Uc(_nullishCoalesce(l, () => ([])),_nullishCoalesce(f, () => ([])))],abi:hp},options:t})}var bp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new M]};async function bc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(r),_chunk2VR6ONNWjs.Ca.from(i)],abi:bp},options:s})}var Tp={typeParameters:[],parameters:[new h(v()),new h(v()),new h(v()),new h(v()),new k(new h(v())),new k(new h(v())),new k(k.u8()),new M]};async function Tc(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', _220 => _220.length])!==_optionalChain([l, 'optionalAccess', _221 => _221.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _222 => _222.length])!==_optionalChain([l, 'optionalAccess', _223 => _223.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _224 => _224.map, 'call', _225 => _225(y=>Mt[y])]);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(p, () => ([]))),Uc(_nullishCoalesce(l, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:Tp},options:f})}var wp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0)))]};async function wc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(r)],abi:wp},options:o})}var Sp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0)))]};async function Sc(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, () => (Ue))],functionArguments:[r],abi:Sp},options:o})}var Ip={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0)))]};async function Ic(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, () => (Ue))],functionArguments:[r],abi:Ip},options:o})}var Ep={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v())]};async function Ec(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(i),new C(r)],abi:Ep},options:s})}var Pp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v())]};async function Pc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(i),new C(r)],abi:Pp},options:s})}var _p={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v())]};async function _c(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(i),new C(r)],abi:_p},options:s})}var xp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v()),new h(v()),k.u8()]};async function xc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(s),new C(r),new C(Mt[i]),S.U8(Ko(o,Mt[i]))],abi:xp},options:c})}var vp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v())]};async function vc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(i),new C(r)],abi:vp},options:s})}var Cp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new V(0))),new h(v()),new h(v()),k.u8()]};async function Cc(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, () => (Ue))],functionArguments:[_chunk2VR6ONNWjs.Ca.from(s),new C(r),new C(Mt[i]),Ko(o,Mt[i])],abi:Cp},options:c})}var Kp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(Te(new V(0))),new h(v()),new V(1)]};async function Kc(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, () => (Ue)),Mt[i]],functionArguments:[_chunk2VR6ONNWjs.Ca.from(s),new C(r),o],abi:Kp},options:c})}var Rp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(Te(new V(0))),new h(v()),new V(1)]};async function Rc(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, () => (Ue)),Mt[i]],functionArguments:[_chunk2VR6ONNWjs.Ca.from(s),new C(r),o],abi:Rp},options:c})}function Uc(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Ko(n[i],r))}),t}function Ko(n,e){let t=Xe(e);return an(n,t,0,[]).bcsToBytes()}var pr=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=_chunk2VR6ONNWjs.Ca.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _226 => _226.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _227 => _227.tokenStandard]), () => ("v2"))}),Nn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),yc({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),mc({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),fc({aptosConfig:this.config,...e})}async getCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ac({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),uc({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),dc({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pc({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),lc({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return gc({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return hc({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return bc({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Tc({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return wc({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Sc({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Ic({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Ec({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Pc({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return _c({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return xc({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return vc({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Cc({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Kc({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Rc({aptosConfig:this.config,...e})}};async function zc(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _228 => _228.timeoutSecs])||20,{data:s}=await Fs({aptosConfig:e,path:"fund",body:{address:_chunk2VR6ONNWjs.Ca.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await zn({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _229 => _229.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var lr=class{constructor(e){this.config=e}async fundAccount(e){let t=await zc({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _230 => _230.options, 'optionalAccess', _231 => _231.waitForIndexer])===void 0||_optionalChain([e, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.waitForIndexer]))&&await oi({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function fi(n){let{aptosConfig:e,options:t}=n,r={query:ga,variables:{where_condition:_optionalChain([t, 'optionalAccess', _234 => _234.where]),limit:_optionalChain([t, 'optionalAccess', _235 => _235.limit]),offset:_optionalChain([t, 'optionalAccess', _236 => _236.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function kc(n){let{aptosConfig:e,options:t}=n,r={query:la,variables:{where_condition:_optionalChain([t, 'optionalAccess', _237 => _237.where]),limit:_optionalChain([t, 'optionalAccess', _238 => _238.limit]),offset:_optionalChain([t, 'optionalAccess', _239 => _239.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Dc(n){let{aptosConfig:e,options:t}=n,r={query:da,variables:{where_condition:_optionalChain([t, 'optionalAccess', _240 => _240.where]),limit:_optionalChain([t, 'optionalAccess', _241 => _241.limit]),offset:_optionalChain([t, 'optionalAccess', _242 => _242.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Nc={typeParameters:[{constraints:[]}],parameters:[Xe("0x1::object::Object"),new M,new ne]};async function Fc(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:Nc},options:s})}async function Oc(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:Nc},options:s})}var gr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _243 => _243.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),fi({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _244 => _244.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await fi({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _245 => _245.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await fi({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk2VR6ONNWjs.Ca.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _246 => _246.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),kc({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _247 => _247.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Dc({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Fc({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Oc({aptosConfig:this.config,...e})}};var yr=class{constructor(e){this.config=e}async getLedgerInfo(){return Yr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Pa({aptosConfig:this.config,...e})}async getBlockByHeight(e){return _a({aptosConfig:this.config,...e})}async view(e){return ge({aptosConfig:this.config,...e})}async viewJson(e){return ic({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ha({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Zr({aptosConfig:this.config})}async getProcessorStatus(e){return ei({aptosConfig:this.config,processorType:e})}};var Ro,Up=6,Gc=["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 Bc(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Ut(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(!Bc(e))throw new Error(`${e} is not valid. ${Gc}`);if(t&&!Bc(t))throw new Error(`${t} is not valid. ${Gc}`);return{domainName:t||e,subdomainName:t?e:void 0}}function zp({name:n,gracePeriod:e}){if(!n)return"expired";let t=e*1e3,r=Date.now(),i=new Date(n.domain_expiration_timestamp).getTime(),o=new Date(n.expiration_timestamp).getTime(),s=i<r,a=o<r,c=a&&r-o<t,d=s&&r-i<t;return n.subdomain&&s&&!d?"expired":n.subdomain&&n.subdomain_expiration_policy===1?d?"in_grace_period":"active":c?"in_grace_period":a?"expired":"active"}var kp="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Dp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:kp,custom:null,devnet:null,shelbynet:null,netna:null};function st(n){let e=Dp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Ai=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Mc(n){let{aptosConfig:e,name:t}=n,r=st(e),{domainName:i,subdomainName:o}=Ut(t),s=await ge({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Ai(s[0]);return a?_chunk2VR6ONNWjs.Ca.from(a):void 0}async function Vc(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=st(e),{domainName:l,subdomainName:f}=Ut(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 ae=_nullishCoalesce(t.years, () => (1));if(ae!==1)throw new Error("For now, names can only be registered for 1 year at a time");let at=ae*31536e3,No={function:`${d}::router::register_domain`,functionArguments:[l,at,o,s]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(i).toString(),data:No,options:a}),data:No}}if(!f)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await Uo({aptosConfig:e,name:l});if(!y)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:y;if(b>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");let D={function:`${d}::router::register_subdomain`,functionArguments:[l,f,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(i).toString(),data:D,options:a}),data:D}}async function Uo(n){let{aptosConfig:e,name:t}=n,r=st(e),{domainName:i,subdomainName:o}=Ut(t);try{let s=await ge({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Hc(n){let{aptosConfig:e,address:t}=n,r=st(e),i=await ge({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk2VR6ONNWjs.Ca.from(t).toString()]}}),o=Ai(i[1]),s=Ai(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function qc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=st(e);if(!r){let l={function:`${o}::router::clear_primary_name`,functionArguments:[]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(t).toString(),data:l,options:i}),data:l}}let{domainName:s,subdomainName:a}=Ut(r),c={function:`${o}::router::set_primary_name`,functionArguments:[s,a]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(t).toString(),data:c,options:i}),data:c}}async function Lc(n){let{aptosConfig:e,name:t}=n,r=st(e),{domainName:i,subdomainName:o}=Ut(t),s=await ge({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Ai(s[0]);return a?_chunk2VR6ONNWjs.Ca.from(a):void 0}async function $c(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=st(e),{domainName:a,subdomainName:c}=Ut(r),d={function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(t).toString(),data:d,options:o}),data:d}}async function Wc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=st(e),{domainName:s,subdomainName:a}=Ut(r),c={function:`${o}::router::clear_target_addr`,functionArguments:[s,_nullishCoalesce(a, () => (null))]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(t).toString(),data:c,options:i}),data:c}}async function Qc(n){let{aptosConfig:e,name:t}=n,r=await Fn({aptosConfig:e}),{domainName:i,subdomainName:o=""}=Ut(t),c=(await w({aptosConfig:e,query:{query:Un,variables:{where_condition:{domain:{_eq:i},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return c?mr({aptosConfig:e,name:c,gracePeriod:r}):void 0}async function jc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Fn({aptosConfig:e}),o=await Zc({aptosConfig:e}),s=await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:Un,variables:{limit:_optionalChain([t, 'optionalAccess', _248 => _248.limit]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),order_by:_optionalChain([t, 'optionalAccess', _250 => _250.orderBy]),where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},..._nullishCoalesce(_optionalChain([n, 'access', _251 => _251.options, 'optionalAccess', _252 => _252.where]), () => ({}))}}}}),a=s.current_aptos_names.map(d=>mr({aptosConfig:e,name:d,gracePeriod:i})),c=_nullishCoalesce(_optionalChain([s, 'access', _253 => _253.current_aptos_names_aggregate, 'access', _254 => _254.aggregate, 'optionalAccess', _255 => _255.count]), () => (0));return{names:a,total:c}}async function Jc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Fn({aptosConfig:e}),o=await Zc({aptosConfig:e}),s=await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Un,variables:{limit:_optionalChain([t, 'optionalAccess', _256 => _256.limit]),offset:_optionalChain([t, 'optionalAccess', _257 => _257.offset]),order_by:_optionalChain([t, 'optionalAccess', _258 => _258.orderBy]),where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""},..._nullishCoalesce(_optionalChain([n, 'access', _259 => _259.options, 'optionalAccess', _260 => _260.where]), () => ({}))}}}}),a=s.current_aptos_names.map(d=>mr({aptosConfig:e,name:d,gracePeriod:i})),c=_nullishCoalesce(_optionalChain([s, 'access', _261 => _261.current_aptos_names_aggregate, 'access', _262 => _262.aggregate, 'optionalAccess', _263 => _263.count]), () => (0));return{names:a,total:c}}async function Xc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Fn({aptosConfig:e}),o=await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Un,variables:{limit:_optionalChain([t, 'optionalAccess', _264 => _264.limit]),offset:_optionalChain([t, 'optionalAccess', _265 => _265.offset]),order_by:_optionalChain([t, 'optionalAccess', _266 => _266.orderBy]),where_condition:{owner_address:{_eq:r.toString()},subdomain:{_neq:""},..._nullishCoalesce(_optionalChain([n, 'access', _267 => _267.options, 'optionalAccess', _268 => _268.where]), () => ({}))}}}}),s=o.current_aptos_names.map(c=>mr({aptosConfig:e,name:c,gracePeriod:i})),a=_nullishCoalesce(_optionalChain([o, 'access', _269 => _269.current_aptos_names_aggregate, 'access', _270 => _270.aggregate, 'optionalAccess', _271 => _271.count]), () => (0));return{names:s,total:a}}async function Yc(n){let{aptosConfig:e,options:t,domain:r}=n,i=await Fn({aptosConfig:e}),o=await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Un,variables:{limit:_optionalChain([t, 'optionalAccess', _272 => _272.limit]),offset:_optionalChain([t, 'optionalAccess', _273 => _273.offset]),order_by:_optionalChain([t, 'optionalAccess', _274 => _274.orderBy]),where_condition:{domain:{_eq:r},subdomain:{_neq:""},..._nullishCoalesce(_optionalChain([n, 'access', _275 => _275.options, 'optionalAccess', _276 => _276.where]), () => ({}))}}}}),s=o.current_aptos_names.map(c=>mr({aptosConfig:e,name:c,gracePeriod:i})),a=_nullishCoalesce(_optionalChain([o, 'access', _277 => _277.current_aptos_names_aggregate, 'access', _278 => _278.aggregate, 'optionalAccess', _279 => _279.count]), () => (0));return{names:s,total:a}}async function Zc(n){let{aptosConfig:e}=n,r=await Fn({aptosConfig:e})/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-r)).toISOString()}async function Fn(n){if(Ro)return Ro;let{aptosConfig:e}=n,t=st(e),[r]=await ge({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}});return Ro=r,r}async function eu(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=st(e),a=i*31536e3,{domainName:c,subdomainName:d}=Ut(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");let l={function:`${s}::router::renew_domain`,functionArguments:[c,a]};return{transaction:await T({aptosConfig:e,sender:_chunk2VR6ONNWjs.Ca.from(t).toString(),data:l,options:o}),data:l}}function mr({name:n,aptosConfig:e,gracePeriod:t}){let r=`${n.expiration_timestamp}Z`,i=`${n.domain_expiration_timestamp}Z`,o=!!n.subdomain,s=n.subdomain_expiration_policy,a=o&&s===1?i:r,c=zp({aptosConfig:e,name:n,gracePeriod:t}),d=!1;if(c==="in_grace_period")d=!0;else if(c==="active"){let l=new Date;l.setMonth(l.getMonth()+Up),d=new Date(a)<l}return{domain:n.domain,subdomain:n.subdomain||void 0,expiration_timestamp:r,expiration_status:c,domain_expiration_timestamp:i,expiration:new Date(a),token_standard:n.token_standard,is_primary:n.is_primary,subdomain_expiration_policy:_nullishCoalesce(n.subdomain_expiration_policy, () => (1)),owner_address:_nullishCoalesce(n.owner_address, () => ("")),registered_address:n.registered_address,isInRenewablePeriod:d}}var fr=class{constructor(e){this.config=e}async getOwnerAddress(e){return Mc({aptosConfig:this.config,...e})}async getExpiration(e){return Uo({aptosConfig:this.config,...e})}async getTargetAddress(e){return Lc({aptosConfig:this.config,...e})}async setTargetAddress(e){return $c({aptosConfig:this.config,...e})}async clearTargetAddress(e){return Wc({aptosConfig:this.config,...e})}async getPrimaryName(e){return Hc({aptosConfig:this.config,...e})}async setPrimaryName(e){return qc({aptosConfig:this.config,...e})}async registerName(e){return Vc({aptosConfig:this.config,...e})}async renewDomain(e){return eu({aptosConfig:this.config,...e})}async getName(e){return Qc({aptosConfig:this.config,...e})}async getAccountNames(e){return jc({aptosConfig:this.config,...e})}async getAccountDomains(e){return Jc({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Xc({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Yc({aptosConfig:this.config,...e})}};async function tu(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Yi,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 nu(n){let{aptosConfig:e,options:t}=n,r={query:Yi,variables:{order_by:_optionalChain([t, 'optionalAccess', _280 => _280.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function ru(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:pa,variables:{delegatorAddress:_chunk2VR6ONNWjs.Ca.from(t).toStringLong(),poolAddress:_chunk2VR6ONNWjs.Ca.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var Ar=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _281 => _281.minimumLedgerVersion]),processorType:"stake_processor"}),tu({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _282 => _282.minimumLedgerVersion]),processorType:"stake_processor"}),nu({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _283 => _283.minimumLedgerVersion]),processorType:"stake_processor"}),ru({aptosConfig:this.config,...e})}};var hi=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 zo(n,e){if(!(n.getTransactionSubmitter()!==void 0||e.transactionSubmitter!==void 0)&&e.transaction.feePayerAddress&&!e.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator")}function ko(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var On=class{constructor(e){this.config=e}async simple(e){return Io({aptosConfig:this.config,...e})}async multiAgent(e){return Io({aptosConfig:this.config,...e})}};_chunk2VR6ONNWjs.a.call(void 0, [ko],On.prototype,"simple",1),_chunk2VR6ONNWjs.a.call(void 0, [ko],On.prototype,"multiAgent",1);var bi=class{constructor(e){this.config=e}async simple(e){return zo(this.config,e),ar({aptosConfig:this.config,...e})}async multiAgent(e){return zo(this.config,e),ar({aptosConfig:this.config,...e})}};var Ti=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 _chunk2VR6ONNWjs.Ja.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=_chunk2VR6ONNWjs.La.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk2VR6ONNWjs.Ja.call(void 0, this.sleepTime),_chunk2VR6ONNWjs.La.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 Dn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Dn({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 _chunk2VR6ONNWjs.Ja.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk2VR6ONNWjs.La.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk2VR6ONNWjs.La.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 _chunk2VR6ONNWjs.Ja.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 Gn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _284 => _284.pendingDequeue, 'access', _285 => _285.shift, 'call', _286 => _286(), 'optionalAccess', _287 => _287.resolve, 'call', _288 => _288(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 Bn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Bn=class extends Error{};var iu=1e4,ou= exports.promiseFulfilledStatus ="fulfilled",su= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(su||{}),wi= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Gn;this.transactionsQueue=new Gn;this.outstandingTransactions=new Gn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Ti(t,r,i,o,s)}addToTransactionHistory(t,r){if(t.push(r),t.length>iu){let i=Math.ceil(iu*.1);t.splice(0,i)}}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=li({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Bn)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===ou?(this.addToTransactionHistory(this.sentTransactions,[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.addToTransactionHistory(this.sentTransactions,[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 Bn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(zn({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===ou?(this.addToTransactionHistory(this.executedTransactions,[a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.addToTransactionHistory(this.executedTransactions,[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,replayProtectionNonce:void 0}})}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 Si=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new wi(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 hr=class{constructor(e){this.config=e,this.build=new hi(this.config),this.simulate=new On(this.config),this.submit=new bi(this.config),this.batch=new Si(this.config)}async getTransactions(e){return no({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Ia({aptosConfig:this.config,...e})}async getTransactionByHash(e){return or({aptosConfig:this.config,...e})}async isPendingTransaction(e){return Ea({aptosConfig:this.config,...e})}async waitForTransaction(e){return zn({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return ii({aptosConfig:this.config})}getSigningMessage(e){return Ma(e)}async publishPackageTransaction(e){return Ha({aptosConfig:this.config,...e})}async rotateAuthKey(e){return nc({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return rc({aptosConfig:this.config,...e})}sign(e){return di({...e})}signAsFeePayer(e){return pi({...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 li({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Va({aptosConfig:this.config,...e})}};var br=class{constructor(e){this.config=e}async getTableItem(e){return ni({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),wa({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Sa({aptosConfig:this.config,...e})}};async function Ii(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:_chunk2VR6ONNWjs.v.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Os({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk2VR6ONNWjs.v.fromHexInput(a.pepper).toUint8Array()}async function Do(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Ii(n),uidKey:o="sub",maxExpHorizonSecs:s=(await yn({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk2VR6ONNWjs.v.fromHexInput(i).toUint8Array().length!==Re.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Re.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 new Error(`The EphemeralKeyPair is too long lived. Its lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunk2VR6ONNWjs.v.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk2VR6ONNWjs.v.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await Gs({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,f=new Ft({a:l.a,b:l.b,c:l.c});return new fe({proof:new gn(f,0),trainingWheelsSignature:Ye.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function au(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Ii(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await yn({aptosConfig:e}),d=Do({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let y=L.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await cr({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return Je.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let f=R.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await cr({aptosConfig:e,authenticationKey:f.authKey().derivedAddress()});return Re.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function cu(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(_chunk2VR6ONNWjs.I.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}`,I.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,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 Tr=class{constructor(e){this.config=e}async getPepper(e){return Ii({aptosConfig:this.config,...e})}async getProof(e){return Do({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return au({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return cu({aptosConfig:this.config,...e})}};async function Gp(n){let{aptosConfig:e,options:t}=n,r={query:Xr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _289 => _289.where]),offset:_optionalChain([t, 'optionalAccess', _290 => _290.offset]),limit:_optionalChain([t, 'optionalAccess', _291 => _291.limit]),order_by:_optionalChain([t, 'optionalAccess', _292 => _292.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function uu(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk2VR6ONNWjs.Ca.from(t).toStringLong()}};return(await Gp({aptosConfig:e,options:{...r,where:o}}))[0]}var wr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),uu({aptosConfig:this.config,...e})}};var se=class{constructor(e){this.config=_nullishCoalesce(e, () => (new mi)),this.account=new ur(this.config),this.abstraction=new cn(this.config),this.ans=new fr(this.config),this.coin=new dr(this.config),this.digitalAsset=new pr(this.config),this.faucet=new lr(this.config),this.fungibleAsset=new gr(this.config),this.general=new yr(this.config),this.staking=new Ar(this.config),this.transaction=new hr(this.config),this.table=new br(this.config),this.keyless=new Tr(this.config),this.object=new wr(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function Se(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}Se(se,ur,"account");Se(se,cn,"abstraction");Se(se,fr,"ans");Se(se,dr,"coin");Se(se,pr,"digitalAsset");Se(se,lr,"faucet");Se(se,gr,"fungibleAsset");Se(se,yr,"general");Se(se,Ar,"staking");Se(se,hr,"transaction");Se(se,br,"table");Se(se,Tr,"keyless");Se(se,wr,"object");exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT = _chunk2VR6ONNWjs.G; exports.APTOS_BIP44_REGEX = vu; exports.APTOS_COIN = _chunk2VR6ONNWjs.C; exports.APTOS_FA = _chunk2VR6ONNWjs.D; exports.APTOS_HARDENED_REGEX = xu; exports.AbstractKeylessAccount = we; exports.AbstractMultiKey = $e; exports.AbstractPublicKey = _r; exports.AbstractSignature = qn; exports.AbstractedAccount = jr; exports.Account = Ct; exports.AccountAbstractionMessage = Or; exports.AccountAddress = _chunk2VR6ONNWjs.Ca; exports.AccountAuthenticator = te; exports.AccountAuthenticatorAbstraction = Qt; exports.AccountAuthenticatorEd25519 = Qe; exports.AccountAuthenticatorMultiEd25519 = mt; exports.AccountAuthenticatorMultiKey = it; exports.AccountAuthenticatorNoAccountAuthenticator = wn; exports.AccountAuthenticatorSingleKey = de; exports.AccountAuthenticatorVariant = _chunk2VR6ONNWjs.Y; exports.AccountPublicKey = ce; exports.AccountSequenceNumber = Ti; exports.AccountUtils = Js; exports.AddressInvalidReason = _chunk2VR6ONNWjs.Ba; exports.AnyPublicKey = x; exports.AnyPublicKeyVariant = _chunk2VR6ONNWjs._; exports.AnySignature = B; exports.AnySignatureVariant = _chunk2VR6ONNWjs.aa; exports.Aptos = se; exports.AptosApiError = _e; exports.AptosApiType = _chunk2VR6ONNWjs.x; exports.AptosConfig = mi; exports.AuthenticationKey = H; exports.Bool = F; exports.CKDPriv = _s; exports.ChainId = Sn; exports.DEFAULT_MAX_GAS_AMOUNT = _chunk2VR6ONNWjs.y; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = _chunk2VR6ONNWjs.A; exports.DEFAULT_TXN_TIMEOUT_SEC = _chunk2VR6ONNWjs.B; exports.DerivableAbstractedAccount = Ys; exports.DeriveScheme = _chunk2VR6ONNWjs.ya; exports.Deserializer = K; exports.EPK_HORIZON_SECS = pd; exports.Ed25519Account = oe; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = P; exports.Ed25519Signature = U; exports.EntryFunction = _t; exports.EntryFunctionBytes = Pr; exports.EphemeralCertificate = ln; exports.EphemeralCertificateVariant = _chunk2VR6ONNWjs.da; exports.EphemeralKeyPair = rn; exports.EphemeralPublicKey = Dt; exports.EphemeralPublicKeyVariant = _chunk2VR6ONNWjs.ba; exports.EphemeralSignature = Ye; exports.EphemeralSignatureVariant = _chunk2VR6ONNWjs.ca; exports.ExpirationStatus = _chunk2VR6ONNWjs.Aa; exports.FIREBASE_AUTH_ISS_PATTERN = _chunk2VR6ONNWjs.I; exports.FederatedKeylessAccount = Je; exports.FederatedKeylessPublicKey = L; exports.FeePayerRawTransaction = Zt; exports.FixedBytes = ze; exports.Groth16ProofAndStatement = Mi; exports.Groth16VerificationKey = Hi; exports.Groth16Zkp = Ft; exports.HARDENED_OFFSET = Is; exports.Hex = _chunk2VR6ONNWjs.v; exports.HexInvalidReason = _chunk2VR6ONNWjs.u; exports.I128 = Me; exports.I16 = Oe; exports.I256 = Ve; exports.I32 = Ge; exports.I64 = Be; exports.I8 = Fe; exports.Identifier = N; exports.KeyType = Cu; exports.KeylessAccount = Re; exports.KeylessConfiguration = Vi; exports.KeylessError = I; exports.KeylessErrorCategory = Zu; exports.KeylessErrorResolutionTip = ed; exports.KeylessErrorType = Cr; exports.KeylessPublicKey = R; exports.KeylessSignature = ue; exports.MAX_AUD_VAL_BYTES = Gi; exports.MAX_COMMITED_EPK_BYTES = Ad; exports.MAX_EXTRA_FIELD_BYTES = md; exports.MAX_ISS_VAL_BYTES = yd; exports.MAX_JWT_HEADER_B64_BYTES = fd; exports.MAX_UID_KEY_BYTES = ld; exports.MAX_UID_VAL_BYTES = gd; exports.MIN_MAX_GAS_AMOUNT = _chunk2VR6ONNWjs.z; exports.MimeType = _chunk2VR6ONNWjs.P; exports.ModuleId = Yn; exports.MoveAbility = _chunk2VR6ONNWjs.ua; exports.MoveFunctionVisibility = _chunk2VR6ONNWjs.ta; exports.MoveJWK = qi; exports.MoveOption = G; exports.MoveString = C; exports.MoveVector = S; exports.MultiAgentRawTransaction = Yt; exports.MultiAgentTransaction = Lr; exports.MultiEd25519Account = rr; exports.MultiEd25519PublicKey = ie; exports.MultiEd25519Signature = We; exports.MultiKey = W; exports.MultiKeyAccount = Kt; exports.MultiKeySignature = ve; exports.MultiSig = Zn; exports.MultiSigTransactionPayload = er; exports.Network = Di; exports.NetworkToChainId = Ni; exports.NetworkToFaucetAPI = zs; exports.NetworkToIndexerAPI = Rs; exports.NetworkToNetworkName = Mg; exports.NetworkToNodeAPI = Us; exports.NetworkToPepperAPI = zi; exports.NetworkToProverAPI = ki; exports.ParsingError = _chunk2VR6ONNWjs.t; exports.PrivateKey = Pe; exports.PrivateKeyVariants = _chunk2VR6ONNWjs.Z; exports.ProcessorType = _chunk2VR6ONNWjs.H; exports.PublicKey = ut; exports.RAW_TRANSACTION_SALT = _chunk2VR6ONNWjs.E; exports.RAW_TRANSACTION_WITH_DATA_SALT = _chunk2VR6ONNWjs.F; exports.RawTransaction = Ke; exports.RawTransactionWithData = Vr; exports.RoleType = _chunk2VR6ONNWjs.va; exports.RotationProofChallenge = Hr; exports.Script = _n; exports.ScriptTransactionArgumentVariants = _chunk2VR6ONNWjs.R; exports.Secp256k1PrivateKey = gt; exports.Secp256k1PublicKey = Le; exports.Secp256k1Signature = yt; exports.Secp256r1PrivateKey = qs; exports.Secp256r1PublicKey = bn; exports.Secp256r1Signature = Wi; exports.Serializable = _chunk2VR6ONNWjs.K; exports.Serialized = Hn; exports.Serializer = _chunk2VR6ONNWjs.L; exports.Signature = O; exports.SignedTransaction = vt; exports.SigningScheme = _chunk2VR6ONNWjs.wa; exports.SigningSchemeInput = _chunk2VR6ONNWjs.xa; exports.SimpleTransaction = qr; exports.SingleKeyAccount = le; exports.StructTag = ot; exports.SubdomainExpirationPolicy = _chunk2VR6ONNWjs.za; exports.TEXT_ENCODER = _chunk2VR6ONNWjs.J; exports.TransactionAndProof = Wr; exports.TransactionAuthenticator = xt; exports.TransactionAuthenticatorEd25519 = en; exports.TransactionAuthenticatorFeePayer = nn; exports.TransactionAuthenticatorMultiAgent = tn; exports.TransactionAuthenticatorMultiEd25519 = Cn; exports.TransactionAuthenticatorSingleSender = Bt; exports.TransactionAuthenticatorVariant = _chunk2VR6ONNWjs.X; exports.TransactionExecutable = xn; exports.TransactionExecutableEmpty = nr; exports.TransactionExecutableEntryFunction = vn; exports.TransactionExecutableScript = tr; exports.TransactionExecutableVariants = _chunk2VR6ONNWjs.U; exports.TransactionExtraConfig = Mr; exports.TransactionExtraConfigV1 = Xt; exports.TransactionExtraConfigVariants = _chunk2VR6ONNWjs.V; exports.TransactionInnerPayload = Br; exports.TransactionInnerPayloadV1 = Jt; exports.TransactionInnerPayloadVariants = _chunk2VR6ONNWjs.T; exports.TransactionPayload = Gt; exports.TransactionPayloadEntryFunction = En; exports.TransactionPayloadMultiSig = Pn; exports.TransactionPayloadScript = In; exports.TransactionPayloadVariants = _chunk2VR6ONNWjs.S; exports.TransactionResponseType = _chunk2VR6ONNWjs.fa; exports.TransactionVariants = _chunk2VR6ONNWjs.W; exports.TransactionWorker = wi; exports.TransactionWorkerEventsEnum = su; exports.TypeTag = z; exports.TypeTagAddress = M; exports.TypeTagBool = Q; exports.TypeTagGeneric = V; exports.TypeTagI128 = It; exports.TypeTagI16 = ht; exports.TypeTagI256 = Pt; exports.TypeTagI32 = Tt; exports.TypeTagI64 = wt; exports.TypeTagI8 = ft; exports.TypeTagParserError = X; exports.TypeTagParserErrorType = Hd; exports.TypeTagReference = Gr; exports.TypeTagSigner = jt; exports.TypeTagStruct = h; exports.TypeTagU128 = St; exports.TypeTagU16 = At; exports.TypeTagU256 = Et; exports.TypeTagU32 = bt; exports.TypeTagU64 = ne; exports.TypeTagU8 = pe; exports.TypeTagVariants = _chunk2VR6ONNWjs.Q; exports.TypeTagVector = k; exports.U128 = Ne; exports.U16 = ke; exports.U256 = Ee; exports.U32 = De; exports.U64 = $; exports.U8 = ee; exports.WebAuthnSignature = Xn; exports.ZeroKnowledgeSig = fe; exports.ZkProof = gn; exports.ZkpVariant = _chunk2VR6ONNWjs.ea; exports.anyPublicKeyVariantToString = _chunk2VR6ONNWjs.$; exports.aptosCoinStructTag = rh; exports.aptosRequest = Kr; exports.base64UrlDecode = _chunk2VR6ONNWjs.Na; exports.base64UrlToBytes = _chunk2VR6ONNWjs.Oa; exports.bigIntToBytesLE = Ui; exports.buildTransaction = wo; exports.bytesToBigIntLE = qt; exports.checkOrConvertArgument = an; exports.convertAmountFromHumanReadableToOnChain = _chunk2VR6ONNWjs.Pa; exports.convertAmountFromOnChainToHumanReadable = _chunk2VR6ONNWjs.Qa; exports.convertArgument = To; exports.convertNumber = on; exports.convertPayloadToInnerPayload = ep; exports.createObjectAddress = _chunk2VR6ONNWjs.Da; exports.createResourceAddress = _chunk2VR6ONNWjs.Ea; exports.createTokenAddress = _chunk2VR6ONNWjs.Ga; exports.createUserDerivedObjectAddress = _chunk2VR6ONNWjs.Fa; exports.deriveKey = Ki; exports.deriveTransactionType = $r; exports.deserializeFromScriptArgument = xd; exports.deserializePublicKey = rA; exports.deserializeSignature = iA; exports.ensureBoolean = _chunk2VR6ONNWjs.M; exports.fetchEntryFunctionAbi = Da; exports.fetchFunctionAbi = bo; exports.fetchJWK = $i; exports.fetchModuleAbi = Wd; exports.fetchMoveFunctionAbi = eI; exports.fetchViewFunctionAbi = Na; exports.findFirstNonSignerArg = ka; exports.floorToWholeHour = _chunk2VR6ONNWjs.Ma; exports.generateRawTransaction = Zd; exports.generateSignedTransaction = So; exports.generateSignedTransactionForSimulation = Oa; exports.generateSigningMessage = nt; exports.generateSigningMessageForSerializable = fb; exports.generateSigningMessageForTransaction = je; exports.generateTransactionPayload = ui; exports.generateTransactionPayloadWithABI = Jd; exports.generateUserTransactionHash = vI; exports.generateViewFunctionPayload = Fa; exports.generateViewFunctionPayloadWithABI = Xd; exports.get = Rr; exports.getAptosFullNode = q; exports.getAptosPepperService = gy; exports.getAuthenticatorForSimulation = kn; exports.getErrorMessage = _chunk2VR6ONNWjs.Ka; exports.getFunctionParts = _chunk2VR6ONNWjs.Ta; exports.getIssAudAndUidVal = lt; exports.getKeylessConfig = yn; exports.getKeylessJWKs = wd; exports.getPageWithObfuscatedCursor = zr; exports.hashStrToField = Ze; exports.hashValues = Ga; exports.hexToAsciiString = _chunk2VR6ONNWjs.w; exports.isBcsAddress = si; exports.isBcsBool = ro; exports.isBcsFixedBytes = Ld; exports.isBcsI128 = fo; exports.isBcsI16 = go; exports.isBcsI256 = Ao; exports.isBcsI32 = yo; exports.isBcsI64 = mo; exports.isBcsI8 = lo; exports.isBcsString = io; exports.isBcsU128 = uo; exports.isBcsU16 = so; exports.isBcsU256 = po; exports.isBcsU32 = ao; exports.isBcsU64 = co; exports.isBcsU8 = oo; exports.isBlockEpilogueTransactionResponse = _chunk2VR6ONNWjs.ma; exports.isBlockMetadataTransactionResponse = _chunk2VR6ONNWjs.ja; exports.isBool = Ka; exports.isBun = _chunk2VR6ONNWjs.Ha; exports.isCanonicalEd25519Signature = _d; exports.isEd25519Signature = _chunk2VR6ONNWjs.na; exports.isEmptyOption = Ra; exports.isEncodedEntryFunctionArgument = Ua; exports.isEncodedStruct = _chunk2VR6ONNWjs.Sa; exports.isFeePayerSignature = _chunk2VR6ONNWjs.qa; exports.isGenesisTransactionResponse = _chunk2VR6ONNWjs.ia; exports.isKeylessSigner = Qr; exports.isLargeNumber = sn; exports.isMultiAgentSignature = _chunk2VR6ONNWjs.pa; exports.isMultiEd25519Signature = _chunk2VR6ONNWjs.ra; exports.isNumber = qd; exports.isPendingTransactionResponse = _chunk2VR6ONNWjs.ga; exports.isScriptDataInput = za; exports.isSecp256k1Signature = _chunk2VR6ONNWjs.oa; exports.isSingleKeySigner = Ji; exports.isSingleSenderSignature = _chunk2VR6ONNWjs.sa; exports.isStateCheckpointTransactionResponse = _chunk2VR6ONNWjs.ka; exports.isString = Rt; exports.isUserTransactionResponse = _chunk2VR6ONNWjs.ha; exports.isValidBIP44Path = Es; exports.isValidFunctionInfo = _chunk2VR6ONNWjs.Ua; exports.isValidHardenedPath = Ps; exports.isValidatorTransactionResponse = _chunk2VR6ONNWjs.la; exports.mnemonicToSeed = xr; exports.normalizeBundle = ks; exports.nowInSeconds = _chunk2VR6ONNWjs.La; exports.objectStructTag = Te; exports.optionStructTag = ih; exports.outOfRangeErrorMessage = _chunk2VR6ONNWjs.N; exports.padAndPackBytesWithLen = $n; exports.paginateWithCursor = Ur; exports.paginateWithObfuscatedCursor = Oi; exports.pairedFaMetadataAddress = _chunk2VR6ONNWjs.Wa; exports.parseEncodedStruct = _chunk2VR6ONNWjs.Ra; exports.parseJwtHeader = Id; exports.parseTypeTag = Xe; exports.poseidonHash = Lt; exports.post = Wn; exports.postAptosFaucet = Fs; exports.postAptosFullNode = dt; exports.postAptosIndexer = Ns; exports.postAptosPepperService = Os; exports.postAptosProvingService = Gs; exports.promiseFulfilledStatus = ou; exports.request = rd; exports.sleep = _chunk2VR6ONNWjs.Ja; exports.splitPath = xs; exports.standardizeTypeTags = ai; exports.stringStructTag = v; exports.throwTypeMismatch = _; exports.truncateAddress = _chunk2VR6ONNWjs.Va; exports.validateNumberInRange = _chunk2VR6ONNWjs.O; exports.verifyKeylessSignature = Li; exports.verifyKeylessSignatureWithJwkAndConfig = kr; exports.warnIfDevelopment = _chunk2VR6ONNWjs.Ia;
487
476
  //# sourceMappingURL=index.js.map