@aptos-labs/ts-sdk 1.35.0-zeta.1 → 1.35.0-zeta.2

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 (277) hide show
  1. package/dist/common/index.d.ts +31 -17
  2. package/dist/common/index.js +1044 -1026
  3. package/dist/common/index.js.map +1 -1
  4. package/dist/esm/account/AbstractKeylessAccount.mjs +19 -19
  5. package/dist/esm/account/AbstractedAccount.mjs +21 -21
  6. package/dist/esm/account/Account.mjs +20 -20
  7. package/dist/esm/account/AccountUtils.mjs +25 -25
  8. package/dist/esm/account/Ed25519Account.mjs +18 -18
  9. package/dist/esm/account/EphemeralKeyPair.mjs +12 -12
  10. package/dist/esm/account/FederatedKeylessAccount.mjs +20 -20
  11. package/dist/esm/account/KeylessAccount.mjs +20 -20
  12. package/dist/esm/account/MultiEd25519Account.mjs +18 -18
  13. package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
  14. package/dist/esm/account/MultiKeyAccount.mjs +22 -22
  15. package/dist/esm/account/SingleKeyAccount.mjs +18 -18
  16. package/dist/esm/account/index.mjs +28 -28
  17. package/dist/esm/account/utils.mjs +11 -11
  18. package/dist/esm/api/account/abstraction.mjs +39 -39
  19. package/dist/esm/api/account.mjs +43 -41
  20. package/dist/esm/api/ans.mjs +39 -39
  21. package/dist/esm/api/aptos.d.mts +0 -1
  22. package/dist/esm/api/aptos.mjs +73 -70
  23. package/dist/esm/api/coin.mjs +38 -37
  24. package/dist/esm/api/digitalAsset.mjs +39 -39
  25. package/dist/esm/api/event.mjs +16 -16
  26. package/dist/esm/api/experimental.mjs +26 -40
  27. package/dist/esm/api/faucet.mjs +15 -15
  28. package/dist/esm/api/fungibleAsset.mjs +39 -39
  29. package/dist/esm/api/general.d.mts +2 -2
  30. package/dist/esm/api/general.mjs +26 -40
  31. package/dist/esm/api/index.d.mts +0 -1
  32. package/dist/esm/api/index.mjs +73 -70
  33. package/dist/esm/api/keyless.mjs +40 -38
  34. package/dist/esm/api/object.mjs +16 -16
  35. package/dist/esm/api/staking.mjs +16 -16
  36. package/dist/esm/api/table.mjs +7 -7
  37. package/dist/esm/api/transaction.d.mts +30 -18
  38. package/dist/esm/api/transaction.mjs +45 -43
  39. package/dist/esm/api/transactionSubmission/build.mjs +37 -37
  40. package/dist/esm/api/transactionSubmission/management.mjs +41 -39
  41. package/dist/esm/api/transactionSubmission/sign.mjs +36 -36
  42. package/dist/esm/api/transactionSubmission/simulate.mjs +37 -37
  43. package/dist/esm/api/transactionSubmission/submit.mjs +37 -37
  44. package/dist/esm/api/utils.mjs +5 -5
  45. package/dist/esm/bcs/index.mjs +1 -1
  46. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  47. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  48. package/dist/esm/{chunk-JJ6MU2DV.mjs → chunk-2FTF6J7F.mjs} +3 -3
  49. package/dist/esm/{chunk-54XJAHWK.mjs → chunk-2HL7JEFC.mjs} +9 -9
  50. package/dist/esm/{chunk-TZZZNGQI.mjs → chunk-2WBJAKBO.mjs} +2 -2
  51. package/dist/esm/{chunk-3E2SXJXZ.mjs → chunk-3DAVHDK4.mjs} +2 -2
  52. package/dist/esm/{chunk-F65QGYVD.mjs → chunk-3TUV6YMI.mjs} +3 -3
  53. package/dist/esm/{chunk-KZFQOE4N.mjs → chunk-5ORUQZAR.mjs} +3 -3
  54. package/dist/esm/{chunk-RTNVJKNX.mjs → chunk-62LC4PPC.mjs} +3 -3
  55. package/dist/esm/{chunk-OOQS6BEP.mjs → chunk-6OFCIXWS.mjs} +2 -2
  56. package/dist/esm/chunk-6OFCIXWS.mjs.map +1 -0
  57. package/dist/esm/{chunk-YD3KHXBD.mjs → chunk-6SNGKTWE.mjs} +2 -2
  58. package/dist/esm/{chunk-2SIDNRJH.mjs → chunk-7F32C225.mjs} +4 -4
  59. package/dist/esm/{chunk-TFDBSPIQ.mjs → chunk-7WW735TU.mjs} +3 -3
  60. package/dist/esm/{chunk-SFF4FJUD.mjs → chunk-A33OBGVN.mjs} +3 -3
  61. package/dist/esm/{chunk-J32AERDF.mjs → chunk-A7LYGPFL.mjs} +3 -3
  62. package/dist/esm/{chunk-BADWWRLN.mjs → chunk-AGKEC2IM.mjs} +5 -5
  63. package/dist/esm/{chunk-GUEJH55K.mjs → chunk-BU43ZFDJ.mjs} +2 -2
  64. package/dist/esm/{chunk-PP2U5UMC.mjs → chunk-C7EEG6SW.mjs} +4 -4
  65. package/dist/esm/{chunk-HTC3Q5JN.mjs → chunk-D4MW64RH.mjs} +4 -4
  66. package/dist/esm/{chunk-YMHFUSKX.mjs → chunk-D6RXVCE3.mjs} +3 -3
  67. package/dist/esm/{chunk-7J37IHNP.mjs → chunk-DGDZNHUJ.mjs} +5 -3
  68. package/dist/esm/{chunk-7J37IHNP.mjs.map → chunk-DGDZNHUJ.mjs.map} +1 -1
  69. package/dist/esm/{chunk-NFBLI3BS.mjs → chunk-DMFRIING.mjs} +2 -2
  70. package/dist/esm/{chunk-CPZPXG7O.mjs → chunk-ECTX2FGD.mjs} +4 -4
  71. package/dist/esm/{chunk-CDJNQ7CS.mjs → chunk-FDMI4BUL.mjs} +29 -22
  72. package/dist/esm/chunk-FDMI4BUL.mjs.map +1 -0
  73. package/dist/esm/chunk-FRLS4GRM.mjs +62 -0
  74. package/dist/esm/chunk-FRLS4GRM.mjs.map +1 -0
  75. package/dist/esm/chunk-G3MHXDYA.mjs +1 -0
  76. package/dist/esm/chunk-G3MHXDYA.mjs.map +1 -0
  77. package/dist/esm/{chunk-OVZOE4GS.mjs → chunk-G6R77JKO.mjs} +16 -16
  78. package/dist/esm/{chunk-XHQMSKZP.mjs → chunk-G7BB6K4B.mjs} +5 -5
  79. package/dist/esm/{chunk-XB4SVKZP.mjs → chunk-GCQK2S5Q.mjs} +2 -2
  80. package/dist/esm/{chunk-2WTIMHGC.mjs → chunk-HBXBODME.mjs} +3 -3
  81. package/dist/esm/{chunk-D3IWXA33.mjs → chunk-HKQY5GXT.mjs} +7 -191
  82. package/dist/esm/chunk-HKQY5GXT.mjs.map +1 -0
  83. package/dist/esm/{chunk-WSI6NVQD.mjs → chunk-HL337SEM.mjs} +3 -3
  84. package/dist/esm/{chunk-V66UC6YI.mjs → chunk-HQDHSKVS.mjs} +2 -2
  85. package/dist/esm/{chunk-ZATMRCFV.mjs → chunk-I5G7XFGT.mjs} +3 -3
  86. package/dist/esm/{chunk-MC4OOX6X.mjs → chunk-IJ7XCPP3.mjs} +36 -31
  87. package/dist/esm/chunk-IJ7XCPP3.mjs.map +1 -0
  88. package/dist/esm/{chunk-SW4ASQPY.mjs → chunk-ILTEOGFF.mjs} +6 -6
  89. package/dist/esm/{chunk-KK7SBRDQ.mjs → chunk-IP7GATDH.mjs} +6 -6
  90. package/dist/esm/{chunk-KK7SBRDQ.mjs.map → chunk-IP7GATDH.mjs.map} +1 -1
  91. package/dist/esm/{chunk-RGHKUKOX.mjs → chunk-IPUAVRGL.mjs} +5 -5
  92. package/dist/esm/{chunk-MLGROHE6.mjs → chunk-IQVHXOD3.mjs} +10 -10
  93. package/dist/esm/{chunk-IEM26R5Q.mjs → chunk-JAZJE3OR.mjs} +2 -2
  94. package/dist/esm/{chunk-VJ2Z7GO3.mjs → chunk-JEVGHYEP.mjs} +2 -2
  95. package/dist/esm/{chunk-WPJUSJJQ.mjs → chunk-JFMFZ2IL.mjs} +3 -3
  96. package/dist/esm/{chunk-IORAMQ2Y.mjs → chunk-K5OCDM3W.mjs} +8 -8
  97. package/dist/esm/{chunk-IORAMQ2Y.mjs.map → chunk-K5OCDM3W.mjs.map} +1 -1
  98. package/dist/esm/{chunk-ESGBNVCA.mjs → chunk-ORCQEMJL.mjs} +2 -2
  99. package/dist/esm/{chunk-PYLTV3KI.mjs → chunk-QYNYDQE3.mjs} +4 -4
  100. package/dist/esm/{chunk-F2EFNUWD.mjs → chunk-R45SPK6Q.mjs} +4 -4
  101. package/dist/esm/{chunk-UKYATVYK.mjs → chunk-RCXGTN36.mjs} +2 -2
  102. package/dist/esm/{chunk-6DJZITWL.mjs → chunk-SPI2HO3E.mjs} +2 -2
  103. package/dist/esm/{chunk-YGFWUFZY.mjs → chunk-SPVJXZL5.mjs} +186 -62
  104. package/dist/esm/chunk-SPVJXZL5.mjs.map +1 -0
  105. package/dist/esm/{chunk-BVBIBMAE.mjs → chunk-SRXIHVZE.mjs} +2 -2
  106. package/dist/esm/{chunk-ZAPXD4FC.mjs → chunk-T4BFWV46.mjs} +2 -2
  107. package/dist/esm/{chunk-ZZWD23YW.mjs → chunk-T573PCIR.mjs} +3 -3
  108. package/dist/esm/{chunk-AEMQUDMU.mjs → chunk-TDLL7QX5.mjs} +11 -11
  109. package/dist/esm/{chunk-HRUI6AWF.mjs → chunk-TFW6N66T.mjs} +4 -4
  110. package/dist/esm/{chunk-LK4HGGAJ.mjs → chunk-TJDF4CXI.mjs} +2 -2
  111. package/dist/esm/{chunk-U7K7AJMC.mjs → chunk-TL4Z4KHK.mjs} +2 -2
  112. package/dist/esm/{chunk-IARAGRKO.mjs → chunk-UGFIWCJQ.mjs} +4 -4
  113. package/dist/esm/{chunk-Y25NJOOO.mjs → chunk-UK7SPHIE.mjs} +4 -4
  114. package/dist/esm/{chunk-MX2R6BBJ.mjs → chunk-UOHCJOXI.mjs} +2 -2
  115. package/dist/esm/{chunk-S5JIXUS6.mjs → chunk-WHSS6I7T.mjs} +4 -4
  116. package/dist/esm/{chunk-2ZX5PHCY.mjs → chunk-WLTQHGIJ.mjs} +5 -5
  117. package/dist/esm/{chunk-MD4TZ4HA.mjs → chunk-WUM247HF.mjs} +3 -3
  118. package/dist/esm/{chunk-IY2ASLSP.mjs → chunk-WXQUBQK4.mjs} +2 -2
  119. package/dist/esm/{chunk-3T7G4OUL.mjs → chunk-X4N5BN3S.mjs} +2 -2
  120. package/dist/esm/{chunk-TQLOZKH4.mjs → chunk-XIBOO3WF.mjs} +3 -3
  121. package/dist/esm/{chunk-2JLHWA2G.mjs → chunk-Y3M32DIB.mjs} +2 -2
  122. package/dist/esm/{chunk-IKEPH7D2.mjs → chunk-YK66QBML.mjs} +4 -4
  123. package/dist/esm/{chunk-PITSYZA7.mjs → chunk-YT7V6AVJ.mjs} +2 -2
  124. package/dist/esm/chunk-ZRBUAZZD.mjs +36 -0
  125. package/dist/esm/chunk-ZRBUAZZD.mjs.map +1 -0
  126. package/dist/esm/cli/index.mjs +1 -1
  127. package/dist/esm/cli/localNode.mjs +1 -1
  128. package/dist/esm/client/core.mjs +1 -1
  129. package/dist/esm/client/get.mjs +1 -1
  130. package/dist/esm/client/index.mjs +10 -10
  131. package/dist/esm/client/post.mjs +1 -1
  132. package/dist/esm/core/account/index.mjs +1 -1
  133. package/dist/esm/core/account/utils/address.mjs +1 -1
  134. package/dist/esm/core/account/utils/index.mjs +1 -1
  135. package/dist/esm/core/accountAddress.mjs +1 -1
  136. package/dist/esm/core/authenticationKey.mjs +1 -1
  137. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  138. package/dist/esm/core/crypto/ed25519.mjs +3 -3
  139. package/dist/esm/core/crypto/ephemeral.mjs +4 -4
  140. package/dist/esm/core/crypto/federatedKeyless.mjs +7 -7
  141. package/dist/esm/core/crypto/index.mjs +13 -13
  142. package/dist/esm/core/crypto/keyless.mjs +6 -6
  143. package/dist/esm/core/crypto/multiEd25519.mjs +11 -11
  144. package/dist/esm/core/crypto/multiKey.mjs +10 -10
  145. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  146. package/dist/esm/core/crypto/proof.mjs +1 -1
  147. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  148. package/dist/esm/core/crypto/secp256k1.mjs +3 -3
  149. package/dist/esm/core/crypto/signature.mjs +1 -1
  150. package/dist/esm/core/crypto/singleKey.mjs +9 -9
  151. package/dist/esm/core/index.mjs +13 -13
  152. package/dist/esm/errors/index.mjs +1 -1
  153. package/dist/esm/index.mjs +102 -99
  154. package/dist/esm/internal/abstraction.mjs +37 -37
  155. package/dist/esm/internal/account.d.mts +45 -5
  156. package/dist/esm/internal/account.mjs +48 -34
  157. package/dist/esm/internal/ans.mjs +38 -38
  158. package/dist/esm/internal/coin.mjs +37 -36
  159. package/dist/esm/internal/digitalAsset.mjs +37 -37
  160. package/dist/esm/internal/event.mjs +13 -13
  161. package/dist/esm/internal/experimental.mjs +25 -39
  162. package/dist/esm/internal/faucet.mjs +14 -14
  163. package/dist/esm/internal/fungibleAsset.mjs +37 -37
  164. package/dist/esm/internal/general.mjs +3 -3
  165. package/dist/esm/internal/keyless.mjs +39 -37
  166. package/dist/esm/internal/object.mjs +13 -13
  167. package/dist/esm/internal/staking.mjs +13 -13
  168. package/dist/esm/internal/table.mjs +4 -4
  169. package/dist/esm/internal/transaction.mjs +4 -4
  170. package/dist/esm/internal/transactionSubmission.d.mts +6 -36
  171. package/dist/esm/internal/transactionSubmission.mjs +36 -42
  172. package/dist/esm/internal/utils/index.d.mts +15 -0
  173. package/dist/esm/internal/utils/index.mjs +39 -0
  174. package/dist/esm/internal/utils/index.mjs.map +1 -0
  175. package/dist/esm/internal/utils/utils.d.mts +65 -0
  176. package/dist/esm/internal/utils/utils.mjs +38 -0
  177. package/dist/esm/internal/utils/utils.mjs.map +1 -0
  178. package/dist/esm/internal/view.mjs +25 -39
  179. package/dist/esm/transactions/authenticator/account.mjs +12 -12
  180. package/dist/esm/transactions/authenticator/index.mjs +13 -13
  181. package/dist/esm/transactions/authenticator/transaction.mjs +13 -13
  182. package/dist/esm/transactions/index.mjs +43 -57
  183. package/dist/esm/transactions/instances/index.mjs +21 -21
  184. package/dist/esm/transactions/instances/moduleId.mjs +11 -11
  185. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +12 -12
  186. package/dist/esm/transactions/instances/rawTransaction.mjs +12 -12
  187. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  188. package/dist/esm/transactions/instances/signedTransaction.mjs +15 -15
  189. package/dist/esm/transactions/instances/simpleTransaction.mjs +12 -12
  190. package/dist/esm/transactions/instances/transactionPayload.mjs +11 -11
  191. package/dist/esm/transactions/management/accountSequenceNumber.mjs +45 -33
  192. package/dist/esm/transactions/management/index.mjs +40 -38
  193. package/dist/esm/transactions/management/transactionWorker.mjs +40 -38
  194. package/dist/esm/transactions/scriptComposer/index.mjs +24 -38
  195. package/dist/esm/transactions/transactionBuilder/helpers.mjs +11 -11
  196. package/dist/esm/transactions/transactionBuilder/index.mjs +23 -37
  197. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +14 -45
  198. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +17 -17
  199. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +23 -38
  200. package/dist/esm/transactions/typeTag/index.mjs +11 -11
  201. package/dist/esm/transactions/typeTag/parser.mjs +11 -11
  202. package/dist/esm/types/index.mjs +1 -1
  203. package/dist/esm/utils/helpers.mjs +1 -1
  204. package/dist/esm/utils/index.mjs +1 -1
  205. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  206. package/package.json +25 -24
  207. package/src/account/MultiKeyAccount.ts +3 -2
  208. package/src/api/general.ts +2 -2
  209. package/src/api/transaction.ts +30 -29
  210. package/src/internal/account.ts +202 -61
  211. package/src/internal/transactionSubmission.ts +4 -202
  212. package/src/internal/utils/index.ts +4 -0
  213. package/src/internal/utils/utils.ts +116 -0
  214. package/src/transactions/scriptComposer/index.ts +3 -1
  215. package/src/transactions/transactionBuilder/remoteAbi.ts +1 -1
  216. package/src/transactions/transactionBuilder/transactionBuilder.ts +7 -2
  217. package/dist/esm/chunk-CDJNQ7CS.mjs.map +0 -1
  218. package/dist/esm/chunk-D3IWXA33.mjs.map +0 -1
  219. package/dist/esm/chunk-MC4OOX6X.mjs.map +0 -1
  220. package/dist/esm/chunk-OOQS6BEP.mjs.map +0 -1
  221. package/dist/esm/chunk-YGFWUFZY.mjs.map +0 -1
  222. /package/dist/esm/{chunk-JJ6MU2DV.mjs.map → chunk-2FTF6J7F.mjs.map} +0 -0
  223. /package/dist/esm/{chunk-54XJAHWK.mjs.map → chunk-2HL7JEFC.mjs.map} +0 -0
  224. /package/dist/esm/{chunk-TZZZNGQI.mjs.map → chunk-2WBJAKBO.mjs.map} +0 -0
  225. /package/dist/esm/{chunk-3E2SXJXZ.mjs.map → chunk-3DAVHDK4.mjs.map} +0 -0
  226. /package/dist/esm/{chunk-F65QGYVD.mjs.map → chunk-3TUV6YMI.mjs.map} +0 -0
  227. /package/dist/esm/{chunk-KZFQOE4N.mjs.map → chunk-5ORUQZAR.mjs.map} +0 -0
  228. /package/dist/esm/{chunk-RTNVJKNX.mjs.map → chunk-62LC4PPC.mjs.map} +0 -0
  229. /package/dist/esm/{chunk-YD3KHXBD.mjs.map → chunk-6SNGKTWE.mjs.map} +0 -0
  230. /package/dist/esm/{chunk-2SIDNRJH.mjs.map → chunk-7F32C225.mjs.map} +0 -0
  231. /package/dist/esm/{chunk-TFDBSPIQ.mjs.map → chunk-7WW735TU.mjs.map} +0 -0
  232. /package/dist/esm/{chunk-SFF4FJUD.mjs.map → chunk-A33OBGVN.mjs.map} +0 -0
  233. /package/dist/esm/{chunk-J32AERDF.mjs.map → chunk-A7LYGPFL.mjs.map} +0 -0
  234. /package/dist/esm/{chunk-BADWWRLN.mjs.map → chunk-AGKEC2IM.mjs.map} +0 -0
  235. /package/dist/esm/{chunk-GUEJH55K.mjs.map → chunk-BU43ZFDJ.mjs.map} +0 -0
  236. /package/dist/esm/{chunk-PP2U5UMC.mjs.map → chunk-C7EEG6SW.mjs.map} +0 -0
  237. /package/dist/esm/{chunk-HTC3Q5JN.mjs.map → chunk-D4MW64RH.mjs.map} +0 -0
  238. /package/dist/esm/{chunk-YMHFUSKX.mjs.map → chunk-D6RXVCE3.mjs.map} +0 -0
  239. /package/dist/esm/{chunk-NFBLI3BS.mjs.map → chunk-DMFRIING.mjs.map} +0 -0
  240. /package/dist/esm/{chunk-CPZPXG7O.mjs.map → chunk-ECTX2FGD.mjs.map} +0 -0
  241. /package/dist/esm/{chunk-OVZOE4GS.mjs.map → chunk-G6R77JKO.mjs.map} +0 -0
  242. /package/dist/esm/{chunk-XHQMSKZP.mjs.map → chunk-G7BB6K4B.mjs.map} +0 -0
  243. /package/dist/esm/{chunk-XB4SVKZP.mjs.map → chunk-GCQK2S5Q.mjs.map} +0 -0
  244. /package/dist/esm/{chunk-2WTIMHGC.mjs.map → chunk-HBXBODME.mjs.map} +0 -0
  245. /package/dist/esm/{chunk-WSI6NVQD.mjs.map → chunk-HL337SEM.mjs.map} +0 -0
  246. /package/dist/esm/{chunk-V66UC6YI.mjs.map → chunk-HQDHSKVS.mjs.map} +0 -0
  247. /package/dist/esm/{chunk-ZATMRCFV.mjs.map → chunk-I5G7XFGT.mjs.map} +0 -0
  248. /package/dist/esm/{chunk-SW4ASQPY.mjs.map → chunk-ILTEOGFF.mjs.map} +0 -0
  249. /package/dist/esm/{chunk-RGHKUKOX.mjs.map → chunk-IPUAVRGL.mjs.map} +0 -0
  250. /package/dist/esm/{chunk-MLGROHE6.mjs.map → chunk-IQVHXOD3.mjs.map} +0 -0
  251. /package/dist/esm/{chunk-IEM26R5Q.mjs.map → chunk-JAZJE3OR.mjs.map} +0 -0
  252. /package/dist/esm/{chunk-VJ2Z7GO3.mjs.map → chunk-JEVGHYEP.mjs.map} +0 -0
  253. /package/dist/esm/{chunk-WPJUSJJQ.mjs.map → chunk-JFMFZ2IL.mjs.map} +0 -0
  254. /package/dist/esm/{chunk-ESGBNVCA.mjs.map → chunk-ORCQEMJL.mjs.map} +0 -0
  255. /package/dist/esm/{chunk-PYLTV3KI.mjs.map → chunk-QYNYDQE3.mjs.map} +0 -0
  256. /package/dist/esm/{chunk-F2EFNUWD.mjs.map → chunk-R45SPK6Q.mjs.map} +0 -0
  257. /package/dist/esm/{chunk-UKYATVYK.mjs.map → chunk-RCXGTN36.mjs.map} +0 -0
  258. /package/dist/esm/{chunk-6DJZITWL.mjs.map → chunk-SPI2HO3E.mjs.map} +0 -0
  259. /package/dist/esm/{chunk-BVBIBMAE.mjs.map → chunk-SRXIHVZE.mjs.map} +0 -0
  260. /package/dist/esm/{chunk-ZAPXD4FC.mjs.map → chunk-T4BFWV46.mjs.map} +0 -0
  261. /package/dist/esm/{chunk-ZZWD23YW.mjs.map → chunk-T573PCIR.mjs.map} +0 -0
  262. /package/dist/esm/{chunk-AEMQUDMU.mjs.map → chunk-TDLL7QX5.mjs.map} +0 -0
  263. /package/dist/esm/{chunk-HRUI6AWF.mjs.map → chunk-TFW6N66T.mjs.map} +0 -0
  264. /package/dist/esm/{chunk-LK4HGGAJ.mjs.map → chunk-TJDF4CXI.mjs.map} +0 -0
  265. /package/dist/esm/{chunk-U7K7AJMC.mjs.map → chunk-TL4Z4KHK.mjs.map} +0 -0
  266. /package/dist/esm/{chunk-IARAGRKO.mjs.map → chunk-UGFIWCJQ.mjs.map} +0 -0
  267. /package/dist/esm/{chunk-Y25NJOOO.mjs.map → chunk-UK7SPHIE.mjs.map} +0 -0
  268. /package/dist/esm/{chunk-MX2R6BBJ.mjs.map → chunk-UOHCJOXI.mjs.map} +0 -0
  269. /package/dist/esm/{chunk-S5JIXUS6.mjs.map → chunk-WHSS6I7T.mjs.map} +0 -0
  270. /package/dist/esm/{chunk-2ZX5PHCY.mjs.map → chunk-WLTQHGIJ.mjs.map} +0 -0
  271. /package/dist/esm/{chunk-MD4TZ4HA.mjs.map → chunk-WUM247HF.mjs.map} +0 -0
  272. /package/dist/esm/{chunk-IY2ASLSP.mjs.map → chunk-WXQUBQK4.mjs.map} +0 -0
  273. /package/dist/esm/{chunk-3T7G4OUL.mjs.map → chunk-X4N5BN3S.mjs.map} +0 -0
  274. /package/dist/esm/{chunk-TQLOZKH4.mjs.map → chunk-XIBOO3WF.mjs.map} +0 -0
  275. /package/dist/esm/{chunk-2JLHWA2G.mjs.map → chunk-Y3M32DIB.mjs.map} +0 -0
  276. /package/dist/esm/{chunk-IKEPH7D2.mjs.map → chunk-YK66QBML.mjs.map} +0 -0
  277. /package/dist/esm/{chunk-PITSYZA7.mjs.map → chunk-YT7V6AVJ.mjs.map} +0 -0
@@ -7417,9 +7417,9 @@ var MultiKeyAccount = class _MultiKeyAccount {
7417
7417
  * @category Account (On-Chain Model)
7418
7418
  */
7419
7419
  static fromPublicKeysAndSigners(args) {
7420
- const { publicKeys, signaturesRequired, signers } = args;
7420
+ const { address, publicKeys, signaturesRequired, signers } = args;
7421
7421
  const multiKey = new MultiKey({ publicKeys, signaturesRequired });
7422
- return new _MultiKeyAccount({ multiKey, signers });
7422
+ return new _MultiKeyAccount({ multiKey, signers, address });
7423
7423
  }
7424
7424
  /**
7425
7425
  * Determines if the provided account is a multi-key account.
@@ -8535,6 +8535,51 @@ async function getProcessorStatus(args) {
8535
8535
  return data.processor_status[0];
8536
8536
  }
8537
8537
 
8538
+ // src/internal/utils/utils.ts
8539
+ async function getModules(args) {
8540
+ const { aptosConfig, accountAddress, options } = args;
8541
+ return paginateWithObfuscatedCursor({
8542
+ aptosConfig,
8543
+ originMethod: "getModules",
8544
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/modules`,
8545
+ params: {
8546
+ ledger_version: _optionalChain([options, 'optionalAccess', _63 => _63.ledgerVersion]),
8547
+ offset: _optionalChain([options, 'optionalAccess', _64 => _64.offset]),
8548
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _65 => _65.limit]), () => ( 1e3))
8549
+ }
8550
+ });
8551
+ }
8552
+ async function getInfo(args) {
8553
+ const { aptosConfig, accountAddress } = args;
8554
+ const { data } = await getAptosFullNode({
8555
+ aptosConfig,
8556
+ originMethod: "getInfo",
8557
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}`
8558
+ });
8559
+ return data;
8560
+ }
8561
+ async function getModule(args) {
8562
+ if (_optionalChain([args, 'access', _66 => _66.options, 'optionalAccess', _67 => _67.ledgerVersion]) !== void 0) {
8563
+ return getModuleInner(args);
8564
+ }
8565
+ return memoizeAsync(
8566
+ async () => getModuleInner(args),
8567
+ `module-${args.accountAddress}-${args.moduleName}`,
8568
+ 1e3 * 60 * 5
8569
+ // 5 minutes
8570
+ )();
8571
+ }
8572
+ async function getModuleInner(args) {
8573
+ const { aptosConfig, accountAddress, moduleName, options } = args;
8574
+ const { data } = await getAptosFullNode({
8575
+ aptosConfig,
8576
+ originMethod: "getModule",
8577
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/module/${moduleName}`,
8578
+ params: { ledger_version: _optionalChain([options, 'optionalAccess', _68 => _68.ledgerVersion]) }
8579
+ });
8580
+ return data;
8581
+ }
8582
+
8538
8583
  // src/internal/table.ts
8539
8584
  async function getTableItem(args) {
8540
8585
  const { aptosConfig, handle, data, options } = args;
@@ -8542,7 +8587,7 @@ async function getTableItem(args) {
8542
8587
  aptosConfig,
8543
8588
  originMethod: "getTableItem",
8544
8589
  path: `tables/${handle}/item`,
8545
- params: { ledger_version: _optionalChain([options, 'optionalAccess', _63 => _63.ledgerVersion]) },
8590
+ params: { ledger_version: _optionalChain([options, 'optionalAccess', _69 => _69.ledgerVersion]) },
8546
8591
  body: data
8547
8592
  });
8548
8593
  return response.data;
@@ -8552,10 +8597,10 @@ async function getTableItemsData(args) {
8552
8597
  const graphqlQuery = {
8553
8598
  query: GetTableItemsData,
8554
8599
  variables: {
8555
- where_condition: _optionalChain([options, 'optionalAccess', _64 => _64.where]),
8556
- offset: _optionalChain([options, 'optionalAccess', _65 => _65.offset]),
8557
- limit: _optionalChain([options, 'optionalAccess', _66 => _66.limit]),
8558
- order_by: _optionalChain([options, 'optionalAccess', _67 => _67.orderBy])
8600
+ where_condition: _optionalChain([options, 'optionalAccess', _70 => _70.where]),
8601
+ offset: _optionalChain([options, 'optionalAccess', _71 => _71.offset]),
8602
+ limit: _optionalChain([options, 'optionalAccess', _72 => _72.limit]),
8603
+ order_by: _optionalChain([options, 'optionalAccess', _73 => _73.orderBy])
8559
8604
  }
8560
8605
  };
8561
8606
  const data = await queryIndexer({
@@ -8570,10 +8615,10 @@ async function getTableItemsMetadata(args) {
8570
8615
  const graphqlQuery = {
8571
8616
  query: GetTableItemsMetadata,
8572
8617
  variables: {
8573
- where_condition: _optionalChain([options, 'optionalAccess', _68 => _68.where]),
8574
- offset: _optionalChain([options, 'optionalAccess', _69 => _69.offset]),
8575
- limit: _optionalChain([options, 'optionalAccess', _70 => _70.limit]),
8576
- order_by: _optionalChain([options, 'optionalAccess', _71 => _71.orderBy])
8618
+ where_condition: _optionalChain([options, 'optionalAccess', _74 => _74.where]),
8619
+ offset: _optionalChain([options, 'optionalAccess', _75 => _75.offset]),
8620
+ limit: _optionalChain([options, 'optionalAccess', _76 => _76.limit]),
8621
+ order_by: _optionalChain([options, 'optionalAccess', _77 => _77.orderBy])
8577
8622
  }
8578
8623
  };
8579
8624
  const data = await queryIndexer({
@@ -8591,7 +8636,7 @@ async function getTransactions(args) {
8591
8636
  aptosConfig,
8592
8637
  originMethod: "getTransactions",
8593
8638
  path: "transactions",
8594
- params: { start: _optionalChain([options, 'optionalAccess', _72 => _72.offset]), limit: _optionalChain([options, 'optionalAccess', _73 => _73.limit]) }
8639
+ params: { start: _optionalChain([options, 'optionalAccess', _78 => _78.offset]), limit: _optionalChain([options, 'optionalAccess', _79 => _79.limit]) }
8595
8640
  });
8596
8641
  }
8597
8642
  async function getGasPriceEstimation(args) {
@@ -8634,7 +8679,7 @@ async function isTransactionPending(args) {
8634
8679
  const transaction = await getTransactionByHash({ aptosConfig, transactionHash });
8635
8680
  return transaction.type === "pending_transaction" /* Pending */;
8636
8681
  } catch (e) {
8637
- if (_optionalChain([e, 'optionalAccess', _74 => _74.status]) === 404) {
8682
+ if (_optionalChain([e, 'optionalAccess', _80 => _80.status]) === 404) {
8638
8683
  return true;
8639
8684
  }
8640
8685
  throw e;
@@ -8651,8 +8696,8 @@ async function longWaitForTransaction(args) {
8651
8696
  }
8652
8697
  async function waitForTransaction(args) {
8653
8698
  const { aptosConfig, transactionHash, options } = args;
8654
- const timeoutSecs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _75 => _75.timeoutSecs]), () => ( DEFAULT_TXN_TIMEOUT_SEC));
8655
- const checkSuccess = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _76 => _76.checkSuccess]), () => ( true));
8699
+ const timeoutSecs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _81 => _81.timeoutSecs]), () => ( DEFAULT_TXN_TIMEOUT_SEC));
8700
+ const checkSuccess = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.checkSuccess]), () => ( true));
8656
8701
  let isPending = true;
8657
8702
  let timeElapsed = 0;
8658
8703
  let lastTxn;
@@ -8777,7 +8822,7 @@ async function getBlockByVersion(args) {
8777
8822
  aptosConfig,
8778
8823
  originMethod: "getBlockByVersion",
8779
8824
  path: `blocks/by_version/${ledgerVersion}`,
8780
- params: { with_transactions: _optionalChain([options, 'optionalAccess', _77 => _77.withTransactions]) }
8825
+ params: { with_transactions: _optionalChain([options, 'optionalAccess', _83 => _83.withTransactions]) }
8781
8826
  });
8782
8827
  return fillBlockTransactions({ block, ...args });
8783
8828
  }
@@ -8787,18 +8832,18 @@ async function getBlockByHeight(args) {
8787
8832
  aptosConfig,
8788
8833
  originMethod: "getBlockByHeight",
8789
8834
  path: `blocks/by_height/${blockHeight}`,
8790
- params: { with_transactions: _optionalChain([options, 'optionalAccess', _78 => _78.withTransactions]) }
8835
+ params: { with_transactions: _optionalChain([options, 'optionalAccess', _84 => _84.withTransactions]) }
8791
8836
  });
8792
8837
  return fillBlockTransactions({ block, ...args });
8793
8838
  }
8794
8839
  async function fillBlockTransactions(args) {
8795
8840
  const { aptosConfig, block, options } = args;
8796
- if (_optionalChain([options, 'optionalAccess', _79 => _79.withTransactions])) {
8841
+ if (_optionalChain([options, 'optionalAccess', _85 => _85.withTransactions])) {
8797
8842
  block.transactions = _nullishCoalesce(block.transactions, () => ( []));
8798
8843
  const lastTxn = block.transactions[block.transactions.length - 1];
8799
8844
  const firstVersion = BigInt(block.first_version);
8800
8845
  const lastVersion = BigInt(block.last_version);
8801
- const curVersion = _optionalChain([lastTxn, 'optionalAccess', _80 => _80.version]);
8846
+ const curVersion = _optionalChain([lastTxn, 'optionalAccess', _86 => _86.version]);
8802
8847
  let latestVersion;
8803
8848
  if (curVersion === void 0) {
8804
8849
  latestVersion = firstVersion - 1n;
@@ -8829,794 +8874,47 @@ async function fillBlockTransactions(args) {
8829
8874
  return block;
8830
8875
  }
8831
8876
 
8832
- // src/internal/account.ts
8833
- async function getInfo(args) {
8834
- const { aptosConfig, accountAddress } = args;
8835
- const { data } = await getAptosFullNode({
8836
- aptosConfig,
8837
- originMethod: "getInfo",
8838
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}`
8839
- });
8840
- return data;
8841
- }
8842
- async function getModules(args) {
8843
- const { aptosConfig, accountAddress, options } = args;
8844
- return paginateWithObfuscatedCursor({
8845
- aptosConfig,
8846
- originMethod: "getModules",
8847
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/modules`,
8848
- params: {
8849
- ledger_version: _optionalChain([options, 'optionalAccess', _81 => _81.ledgerVersion]),
8850
- offset: _optionalChain([options, 'optionalAccess', _82 => _82.offset]),
8851
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _83 => _83.limit]), () => ( 1e3))
8852
- }
8853
- });
8854
- }
8855
- async function getModule(args) {
8856
- if (_optionalChain([args, 'access', _84 => _84.options, 'optionalAccess', _85 => _85.ledgerVersion]) !== void 0) {
8857
- return getModuleInner(args);
8858
- }
8859
- return memoizeAsync(
8860
- async () => getModuleInner(args),
8861
- `module-${args.accountAddress}-${args.moduleName}`,
8862
- 1e3 * 60 * 5
8863
- // 5 minutes
8864
- )();
8865
- }
8866
- async function getModuleInner(args) {
8867
- const { aptosConfig, accountAddress, moduleName, options } = args;
8868
- const { data } = await getAptosFullNode({
8869
- aptosConfig,
8870
- originMethod: "getModule",
8871
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/module/${moduleName}`,
8872
- params: { ledger_version: _optionalChain([options, 'optionalAccess', _86 => _86.ledgerVersion]) }
8873
- });
8874
- return data;
8875
- }
8876
- async function getTransactions2(args) {
8877
- const { aptosConfig, accountAddress, options } = args;
8878
- return paginateWithCursor({
8879
- aptosConfig,
8880
- originMethod: "getTransactions",
8881
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/transactions`,
8882
- params: { start: _optionalChain([options, 'optionalAccess', _87 => _87.offset]), limit: _optionalChain([options, 'optionalAccess', _88 => _88.limit]) }
8883
- });
8884
- }
8885
- async function getResources(args) {
8886
- const { aptosConfig, accountAddress, options } = args;
8887
- return paginateWithObfuscatedCursor({
8888
- aptosConfig,
8889
- originMethod: "getResources",
8890
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/resources`,
8891
- params: {
8892
- ledger_version: _optionalChain([options, 'optionalAccess', _89 => _89.ledgerVersion]),
8893
- offset: _optionalChain([options, 'optionalAccess', _90 => _90.offset]),
8894
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _91 => _91.limit]), () => ( 999))
8895
- }
8896
- });
8877
+ // src/transactions/transactionBuilder/transactionBuilder.ts
8878
+
8879
+
8880
+ // src/transactions/typeTag/parser.ts
8881
+ function isValidIdentifier(str) {
8882
+ return !!str.match(/^[_a-zA-Z0-9]+$/);
8897
8883
  }
8898
- async function getResource(args) {
8899
- const { aptosConfig, accountAddress, resourceType, options } = args;
8900
- const { data } = await getAptosFullNode({
8901
- aptosConfig,
8902
- originMethod: "getResource",
8903
- path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/resource/${resourceType}`,
8904
- params: { ledger_version: _optionalChain([options, 'optionalAccess', _92 => _92.ledgerVersion]) }
8905
- });
8906
- return data.data;
8884
+ function isValidWhitespaceCharacter(char) {
8885
+ return !!char.match(/\s/);
8907
8886
  }
8908
- async function lookupOriginalAccountAddress(args) {
8909
- const { aptosConfig, authenticationKey, options } = args;
8910
- const resource = await getResource({
8911
- aptosConfig,
8912
- accountAddress: "0x1",
8913
- resourceType: "0x1::account::OriginatingAddress",
8914
- options
8915
- });
8916
- const {
8917
- address_map: { handle }
8918
- } = resource;
8919
- const authKeyAddress = _chunkJMOQXLEDjs.AccountAddress.from(authenticationKey);
8920
- try {
8921
- const originalAddress = await getTableItem({
8922
- aptosConfig,
8923
- handle,
8924
- data: {
8925
- key: authKeyAddress.toString(),
8926
- key_type: "address",
8927
- value_type: "address"
8928
- },
8929
- options
8930
- });
8931
- return _chunkJMOQXLEDjs.AccountAddress.from(originalAddress);
8932
- } catch (err) {
8933
- if (err instanceof AptosApiError && err.data.error_code === "table_item_not_found") {
8934
- return authKeyAddress;
8935
- }
8936
- throw err;
8937
- }
8887
+ function isGeneric(str) {
8888
+ return !!str.match(/^T[0-9]+$/);
8938
8889
  }
8939
- async function getAccountTokensCount(args) {
8940
- const { aptosConfig, accountAddress } = args;
8941
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
8942
- const whereCondition = {
8943
- owner_address: { _eq: address },
8944
- amount: { _gt: 0 }
8945
- };
8946
- const graphqlQuery = {
8947
- query: GetAccountTokensCount,
8948
- variables: { where_condition: whereCondition }
8949
- };
8950
- const data = await queryIndexer({
8951
- aptosConfig,
8952
- query: graphqlQuery,
8953
- originMethod: "getAccountTokensCount"
8954
- });
8955
- return data.current_token_ownerships_v2_aggregate.aggregate ? data.current_token_ownerships_v2_aggregate.aggregate.count : 0;
8890
+ function isRef(str) {
8891
+ return !!str.match(/^&.+$/);
8956
8892
  }
8957
- async function getAccountOwnedTokens(args) {
8958
- const { aptosConfig, accountAddress, options } = args;
8959
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
8960
- const whereCondition = {
8961
- owner_address: { _eq: address },
8962
- amount: { _gt: 0 }
8963
- };
8964
- if (_optionalChain([options, 'optionalAccess', _93 => _93.tokenStandard])) {
8965
- whereCondition.token_standard = { _eq: _optionalChain([options, 'optionalAccess', _94 => _94.tokenStandard]) };
8893
+ function isPrimitive(str) {
8894
+ switch (str) {
8895
+ case "signer":
8896
+ case "address":
8897
+ case "bool":
8898
+ case "u8":
8899
+ case "u16":
8900
+ case "u32":
8901
+ case "u64":
8902
+ case "u128":
8903
+ case "u256":
8904
+ return true;
8905
+ default:
8906
+ return false;
8966
8907
  }
8967
- const graphqlQuery = {
8968
- query: GetAccountOwnedTokens,
8969
- variables: {
8970
- where_condition: whereCondition,
8971
- offset: _optionalChain([options, 'optionalAccess', _95 => _95.offset]),
8972
- limit: _optionalChain([options, 'optionalAccess', _96 => _96.limit]),
8973
- order_by: _optionalChain([options, 'optionalAccess', _97 => _97.orderBy])
8974
- }
8975
- };
8976
- const data = await queryIndexer({
8977
- aptosConfig,
8978
- query: graphqlQuery,
8979
- originMethod: "getAccountOwnedTokens"
8980
- });
8981
- return data.current_token_ownerships_v2;
8982
8908
  }
8983
- async function getAccountOwnedTokensFromCollectionAddress(args) {
8984
- const { aptosConfig, accountAddress, collectionAddress, options } = args;
8985
- const ownerAddress = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
8986
- const collAddress = _chunkJMOQXLEDjs.AccountAddress.from(collectionAddress).toStringLong();
8987
- const whereCondition = {
8988
- owner_address: { _eq: ownerAddress },
8989
- current_token_data: { collection_id: { _eq: collAddress } },
8990
- amount: { _gt: 0 }
8991
- };
8992
- if (_optionalChain([options, 'optionalAccess', _98 => _98.tokenStandard])) {
8993
- whereCondition.token_standard = { _eq: _optionalChain([options, 'optionalAccess', _99 => _99.tokenStandard]) };
8994
- }
8995
- const graphqlQuery = {
8996
- query: GetAccountOwnedTokensFromCollection,
8997
- variables: {
8998
- where_condition: whereCondition,
8999
- offset: _optionalChain([options, 'optionalAccess', _100 => _100.offset]),
9000
- limit: _optionalChain([options, 'optionalAccess', _101 => _101.limit]),
9001
- order_by: _optionalChain([options, 'optionalAccess', _102 => _102.orderBy])
8909
+ function consumeWhitespace(tagStr, pos) {
8910
+ let i = pos;
8911
+ for (; i < tagStr.length; i += 1) {
8912
+ const innerChar = tagStr[i];
8913
+ if (!isValidWhitespaceCharacter(innerChar)) {
8914
+ break;
9002
8915
  }
9003
- };
9004
- const data = await queryIndexer({
9005
- aptosConfig,
9006
- query: graphqlQuery,
9007
- originMethod: "getAccountOwnedTokensFromCollectionAddress"
9008
- });
9009
- return data.current_token_ownerships_v2;
9010
- }
9011
- async function getAccountCollectionsWithOwnedTokens(args) {
9012
- const { aptosConfig, accountAddress, options } = args;
9013
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
9014
- const whereCondition = {
9015
- owner_address: { _eq: address }
9016
- };
9017
- if (_optionalChain([options, 'optionalAccess', _103 => _103.tokenStandard])) {
9018
- whereCondition.current_collection = {
9019
- token_standard: { _eq: _optionalChain([options, 'optionalAccess', _104 => _104.tokenStandard]) }
9020
- };
9021
8916
  }
9022
- const graphqlQuery = {
9023
- query: GetAccountCollectionsWithOwnedTokens,
9024
- variables: {
9025
- where_condition: whereCondition,
9026
- offset: _optionalChain([options, 'optionalAccess', _105 => _105.offset]),
9027
- limit: _optionalChain([options, 'optionalAccess', _106 => _106.limit]),
9028
- order_by: _optionalChain([options, 'optionalAccess', _107 => _107.orderBy])
9029
- }
9030
- };
9031
- const data = await queryIndexer({
9032
- aptosConfig,
9033
- query: graphqlQuery,
9034
- originMethod: "getAccountCollectionsWithOwnedTokens"
9035
- });
9036
- return data.current_collection_ownership_v2_view;
9037
- }
9038
- async function getAccountTransactionsCount(args) {
9039
- const { aptosConfig, accountAddress } = args;
9040
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
9041
- const graphqlQuery = {
9042
- query: GetAccountTransactionsCount,
9043
- variables: { address }
9044
- };
9045
- const data = await queryIndexer({
9046
- aptosConfig,
9047
- query: graphqlQuery,
9048
- originMethod: "getAccountTransactionsCount"
9049
- });
9050
- return data.account_transactions_aggregate.aggregate ? data.account_transactions_aggregate.aggregate.count : 0;
9051
- }
9052
- async function getAccountCoinsData(args) {
9053
- const { aptosConfig, accountAddress, options } = args;
9054
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
9055
- const whereCondition = {
9056
- ..._optionalChain([options, 'optionalAccess', _108 => _108.where]),
9057
- owner_address: { _eq: address }
9058
- };
9059
- const graphqlQuery = {
9060
- query: GetAccountCoinsData,
9061
- variables: {
9062
- where_condition: whereCondition,
9063
- offset: _optionalChain([options, 'optionalAccess', _109 => _109.offset]),
9064
- limit: _optionalChain([options, 'optionalAccess', _110 => _110.limit]),
9065
- order_by: _optionalChain([options, 'optionalAccess', _111 => _111.orderBy])
9066
- }
9067
- };
9068
- const data = await queryIndexer({
9069
- aptosConfig,
9070
- query: graphqlQuery,
9071
- originMethod: "getAccountCoinsData"
9072
- });
9073
- return data.current_fungible_asset_balances;
9074
- }
9075
- async function getAccountCoinsCount(args) {
9076
- const { aptosConfig, accountAddress } = args;
9077
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
9078
- const graphqlQuery = {
9079
- query: GetAccountCoinsCount,
9080
- variables: { address }
9081
- };
9082
- const data = await queryIndexer({
9083
- aptosConfig,
9084
- query: graphqlQuery,
9085
- originMethod: "getAccountCoinsCount"
9086
- });
9087
- if (!data.current_fungible_asset_balances_aggregate.aggregate) {
9088
- throw Error("Failed to get the count of account coins");
9089
- }
9090
- return data.current_fungible_asset_balances_aggregate.aggregate.count;
9091
- }
9092
- async function getAccountOwnedObjects(args) {
9093
- const { aptosConfig, accountAddress, options } = args;
9094
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
9095
- const whereCondition = {
9096
- owner_address: { _eq: address }
9097
- };
9098
- const graphqlQuery = {
9099
- query: GetObjectData,
9100
- variables: {
9101
- where_condition: whereCondition,
9102
- offset: _optionalChain([options, 'optionalAccess', _112 => _112.offset]),
9103
- limit: _optionalChain([options, 'optionalAccess', _113 => _113.limit]),
9104
- order_by: _optionalChain([options, 'optionalAccess', _114 => _114.orderBy])
9105
- }
9106
- };
9107
- const data = await queryIndexer({
9108
- aptosConfig,
9109
- query: graphqlQuery,
9110
- originMethod: "getAccountOwnedObjects"
9111
- });
9112
- return data.current_objects;
9113
- }
9114
- async function deriveAccountFromPrivateKey(args) {
9115
- const { aptosConfig, privateKey } = args;
9116
- const publicKey = new AnyPublicKey(privateKey.publicKey());
9117
- if (privateKey instanceof Secp256k1PrivateKey) {
9118
- const authKey = AuthenticationKey.fromPublicKey({ publicKey });
9119
- const address = authKey.derivedAddress();
9120
- return Account.fromPrivateKey({ privateKey, address });
9121
- }
9122
- if (privateKey instanceof Ed25519PrivateKey) {
9123
- const singleSenderTransactionAuthenticatorAuthKey = AuthenticationKey.fromPublicKey({
9124
- publicKey
9125
- });
9126
- const isSingleSenderTransactionAuthenticator = await isAccountExist({
9127
- authKey: singleSenderTransactionAuthenticatorAuthKey,
9128
- aptosConfig
9129
- });
9130
- if (isSingleSenderTransactionAuthenticator) {
9131
- const address = singleSenderTransactionAuthenticatorAuthKey.derivedAddress();
9132
- return Account.fromPrivateKey({ privateKey, address, legacy: false });
9133
- }
9134
- const legacyAuthKey = AuthenticationKey.fromPublicKey({
9135
- publicKey: publicKey.publicKey
9136
- });
9137
- const isLegacyEd25519 = await isAccountExist({ authKey: legacyAuthKey, aptosConfig });
9138
- if (isLegacyEd25519) {
9139
- const address = legacyAuthKey.derivedAddress();
9140
- return Account.fromPrivateKey({ privateKey, address, legacy: true });
9141
- }
9142
- }
9143
- throw new Error(`Can't derive account from private key ${privateKey}`);
9144
- }
9145
- async function isAccountExist(args) {
9146
- const { aptosConfig, authKey } = args;
9147
- const accountAddress = await lookupOriginalAccountAddress({
9148
- aptosConfig,
9149
- authenticationKey: authKey.derivedAddress()
9150
- });
9151
- try {
9152
- await getInfo({
9153
- aptosConfig,
9154
- accountAddress
9155
- });
9156
- return true;
9157
- } catch (error) {
9158
- if (error.status === 404) {
9159
- return false;
9160
- }
9161
- throw new Error(`Error while looking for an account info ${accountAddress.toString()}`);
9162
- }
9163
- }
9164
- async function getMultiKeysForAuthenticationKeys(args) {
9165
- const { aptosConfig, authKeys } = args;
9166
- if (authKeys.length === 0) {
9167
- throw new Error("No authentication keys provided");
9168
- }
9169
- const whereCondition = {
9170
- auth_key: { _in: authKeys.map((authKey) => authKey.toString()) }
9171
- };
9172
- const graphqlQuery = {
9173
- query: GetMultiKeyForAuthKey,
9174
- variables: {
9175
- where_condition: whereCondition
9176
- }
9177
- };
9178
- const { auth_key_multikey_layout: data } = await queryIndexer({
9179
- aptosConfig,
9180
- query: graphqlQuery,
9181
- originMethod: "getMultiKeysForAuthenticationKeys"
9182
- });
9183
- const authKeyToMultiKey = new Map(data.map((entry) => [entry.auth_key, entry]));
9184
- const result = [];
9185
- for (let i = 0; i < authKeys.length; i += 1) {
9186
- const entry = authKeyToMultiKey.get(authKeys[i].toString());
9187
- if (!entry) {
9188
- throw new Error(`Failed to find multikey for authentication key ${authKeys[i]}`);
9189
- }
9190
- const publicKey = extractMultiKeyFromData(entry);
9191
- result.push({ authKey: authKeys[i], publicKey });
9192
- }
9193
- return result;
9194
- }
9195
- function extractMultiKeyFromData(data) {
9196
- const signaturesRequired = data.signatures_required;
9197
- const multikeyLayout = data.multikey_layout_with_prefixes;
9198
- const multikeyType = data.multikey_type;
9199
- if (multikeyType === "multi_ed25519") {
9200
- const ed25519PublicKeys = [];
9201
- for (const key of multikeyLayout) {
9202
- ed25519PublicKeys.push(new Ed25519PublicKey(key));
9203
- }
9204
- return new MultiEd25519PublicKey({
9205
- publicKeys: ed25519PublicKeys,
9206
- threshold: signaturesRequired
9207
- });
9208
- }
9209
- if (multikeyType === "multi_key") {
9210
- const publicKeys = [];
9211
- for (const key of multikeyLayout) {
9212
- const deserializer = Deserializer.fromHex(key);
9213
- const variantIndex = deserializer.deserializeUleb128AsU32();
9214
- let publicKey;
9215
- switch (variantIndex) {
9216
- case 0 /* Ed25519 */:
9217
- publicKey = new Ed25519PublicKey(deserializer.deserializeFixedBytes(32));
9218
- break;
9219
- case 1 /* Secp256k1 */:
9220
- publicKey = new Secp256k1PublicKey(deserializer.deserializeFixedBytes(65));
9221
- break;
9222
- case 3 /* Keyless */:
9223
- publicKey = KeylessPublicKey.deserialize(deserializer);
9224
- break;
9225
- case 4 /* FederatedKeyless */:
9226
- publicKey = FederatedKeylessPublicKey.deserialize(deserializer);
9227
- break;
9228
- default:
9229
- throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
9230
- }
9231
- publicKeys.push(new AnyPublicKey(publicKey));
9232
- }
9233
- return new MultiKey({
9234
- publicKeys,
9235
- signaturesRequired
9236
- });
9237
- }
9238
- throw new Error("Unknown multikey type");
9239
- }
9240
- async function getAuthKeysForPublicKey(args) {
9241
- const { aptosConfig, publicKey, options } = args;
9242
- const verified = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _115 => _115.verified]), () => ( true));
9243
- let baseKey = publicKey;
9244
- if (publicKey instanceof AnyPublicKey) {
9245
- baseKey = publicKey.publicKey;
9246
- }
9247
- const whereCondition = {
9248
- public_key: { _eq: baseKey.toString() },
9249
- verified: { _eq: verified }
9250
- };
9251
- const graphqlQuery = {
9252
- query: GetAuthKeysForPublicKey,
9253
- variables: {
9254
- where_condition: whereCondition
9255
- }
9256
- };
9257
- const { public_key_auth_keys: data } = await queryIndexer({
9258
- aptosConfig,
9259
- query: graphqlQuery,
9260
- originMethod: "getAuthKeysForPublicKey"
9261
- });
9262
- const sortedData = data.sort((a, b) => Number(b.last_transaction_version) - Number(a.last_transaction_version));
9263
- const authKeys = sortedData.map((entry) => new AuthenticationKey({ data: entry.auth_key }));
9264
- return authKeys;
9265
- }
9266
- async function getLastestTransactionVersionForAddress(args) {
9267
- const { aptosConfig, accountAddress } = args;
9268
- const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString();
9269
- const whereCondition = {
9270
- signer: { _eq: accountAddress.toString() }
9271
- };
9272
- const graphqlQuery = {
9273
- query: GetSignatures,
9274
- variables: {
9275
- where_condition: whereCondition,
9276
- limit: 1,
9277
- order_by: { transaction_version: "desc" }
9278
- }
9279
- };
9280
- const { signatures: data } = await queryIndexer({
9281
- aptosConfig,
9282
- query: graphqlQuery,
9283
- originMethod: "getSignatures"
9284
- });
9285
- if (data.length !== 1) {
9286
- throw new Error(`Expected 1 account address for address ${address}, got ${data.length}`);
9287
- }
9288
- return Number(data[0].transaction_version);
9289
- }
9290
- async function getAccountAddressesForAuthKeys(args) {
9291
- const { aptosConfig, options, authKeys } = args;
9292
- const verified = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _116 => _116.verified]), () => ( true));
9293
- if (authKeys.length === 0) {
9294
- throw new Error("No authentication keys provided");
9295
- }
9296
- const whereCondition = {
9297
- auth_key: { _in: authKeys.map((authKey) => authKey.toString()) },
9298
- verified: { _eq: verified }
9299
- };
9300
- const graphqlQuery = {
9301
- query: GetAccountAddressesForAuthKey,
9302
- variables: {
9303
- where_condition: whereCondition
9304
- }
9305
- };
9306
- const { auth_key_account_addresses: data } = await queryIndexer({
9307
- aptosConfig,
9308
- query: graphqlQuery,
9309
- originMethod: "getAccountAddressesForAuthKeys"
9310
- });
9311
- return data.map((entry) => ({
9312
- authKey: new AuthenticationKey({ data: entry.auth_key }),
9313
- accountAddress: new (0, _chunkJMOQXLEDjs.AccountAddress)(_chunkJMOQXLEDjs.Hex.hexInputToUint8Array(entry.address)),
9314
- verified: entry.verified,
9315
- lastTransactionVersion: Number(entry.last_transaction_version)
9316
- }));
9317
- }
9318
- async function getAccountsForPublicKey(args) {
9319
- const { aptosConfig, publicKey } = args;
9320
- let baseKey = publicKey;
9321
- if (publicKey instanceof AnyPublicKey) {
9322
- baseKey = publicKey.publicKey;
9323
- }
9324
- const singleKeyPublicKeys = [];
9325
- if (baseKey instanceof Ed25519PublicKey) {
9326
- singleKeyPublicKeys.push(baseKey);
9327
- }
9328
- const anyPublicKey = new AnyPublicKey(baseKey);
9329
- singleKeyPublicKeys.push(anyPublicKey);
9330
- const singleKeyAuthKeyPublicKeyPairs = singleKeyPublicKeys.map((pubKey) => {
9331
- const authKey = pubKey.authKey();
9332
- return { authKey, publicKey: pubKey };
9333
- });
9334
- const multiKeyAuthKeys = await getAuthKeysForPublicKey({ aptosConfig, publicKey });
9335
- const [multiKeyPairs, authKeyAccountAddressPairs] = await Promise.all([
9336
- getMultiKeysForAuthenticationKeys({ aptosConfig, authKeys: multiKeyAuthKeys }),
9337
- getAccountAddressesForAuthKeys({
9338
- aptosConfig,
9339
- authKeys: multiKeyAuthKeys.concat(singleKeyAuthKeyPublicKeyPairs.map((pair) => pair.publicKey.authKey()))
9340
- })
9341
- ]);
9342
- const authKeyPublicKeyPairs = singleKeyAuthKeyPublicKeyPairs.concat(multiKeyPairs);
9343
- const result = [];
9344
- const authKeyToPublicKey = new Map(authKeyPublicKeyPairs.map((pair) => [pair.authKey.toString(), pair.publicKey]));
9345
- for (const authKeyAccountAddressPair of authKeyAccountAddressPairs) {
9346
- if (!authKeyToPublicKey.has(authKeyAccountAddressPair.authKey.toString())) {
9347
- throw new Error(`No publicKey found for authentication key ${authKeyAccountAddressPair.authKey}.`);
9348
- }
9349
- result.push({
9350
- accountAddress: authKeyAccountAddressPair.accountAddress,
9351
- publicKey: authKeyToPublicKey.get(authKeyAccountAddressPair.authKey.toString()),
9352
- verified: authKeyAccountAddressPair.verified,
9353
- lastTransactionVersion: authKeyAccountAddressPair.lastTransactionVersion
9354
- });
9355
- }
9356
- return result;
9357
- }
9358
- async function getPublicKeyFromAccountAddress(args) {
9359
- const { aptosConfig, accountAddress } = args;
9360
- const accountData = await getInfo({ aptosConfig, accountAddress });
9361
- const lastTransactionVersion = await getLastestTransactionVersionForAddress({
9362
- aptosConfig,
9363
- accountAddress
9364
- });
9365
- console.log("lastTransactionVersion", lastTransactionVersion);
9366
- const transaction = await getTransactionByVersion({ aptosConfig, ledgerVersion: lastTransactionVersion });
9367
- if (!_chunkJMOQXLEDjs.isUserTransactionResponse.call(void 0, transaction)) {
9368
- throw new Error("Transaction is not a user transaction");
9369
- }
9370
- const { signature } = transaction;
9371
- if (!signature) {
9372
- throw new Error("Transaction has no signature");
9373
- }
9374
- let publicKey;
9375
- if (_chunkJMOQXLEDjs.isEd25519Signature.call(void 0, signature)) {
9376
- publicKey = new Ed25519PublicKey(signature.public_key);
9377
- } else if (_chunkJMOQXLEDjs.isMultiEd25519Signature.call(void 0, signature)) {
9378
- publicKey = new MultiEd25519PublicKey({
9379
- publicKeys: signature.public_keys.map((pk) => new Ed25519PublicKey(pk)),
9380
- threshold: signature.threshold
9381
- });
9382
- } else if (_chunkJMOQXLEDjs.isSingleSenderSingleKeySignature.call(void 0, signature)) {
9383
- publicKey = parsePublicKey(signature.public_key);
9384
- } else if (_chunkJMOQXLEDjs.isSingleSenderMultiKeySignature.call(void 0, signature)) {
9385
- const publicKeys = [];
9386
- for (const pk of signature.public_keys) {
9387
- publicKeys.push(parsePublicKey(pk));
9388
- }
9389
- publicKey = new MultiKey({
9390
- publicKeys,
9391
- signaturesRequired: signature.signatures_required
9392
- });
9393
- } else {
9394
- throw new Error("Unknown signature type");
9395
- }
9396
- if (publicKey.authKey().toString() !== accountData.authentication_key) {
9397
- throw new Error(
9398
- "Derived public key does not match authentication key. The most recent signature was likely a key rotation."
9399
- );
9400
- }
9401
- return publicKey;
9402
- }
9403
- function parsePublicKey(data) {
9404
- if (data.type === "keyless") {
9405
- const deserializer = Deserializer.fromHex(data.value);
9406
- return new AnyPublicKey(KeylessPublicKey.deserialize(deserializer));
9407
- }
9408
- if (data.type === "ed25519") {
9409
- return new AnyPublicKey(new Ed25519PublicKey(data.value));
9410
- }
9411
- if (data.type === "secp256k1_ecdsa") {
9412
- return new AnyPublicKey(new Secp256k1PublicKey(data.value));
9413
- }
9414
- throw new Error("Unknown public key type");
9415
- }
9416
-
9417
- // src/api/utils.ts
9418
- async function waitForIndexerOnVersion(args) {
9419
- if (args.minimumLedgerVersion !== void 0) {
9420
- await waitForIndexer({
9421
- aptosConfig: args.config,
9422
- minimumLedgerVersion: args.minimumLedgerVersion,
9423
- processorType: args.processorType
9424
- });
9425
- }
9426
- }
9427
-
9428
- // src/transactions/transactionBuilder/helpers.ts
9429
- function isBool(arg) {
9430
- return typeof arg === "boolean";
9431
- }
9432
- function isString(arg) {
9433
- return typeof arg === "string";
9434
- }
9435
- function isNumber(arg) {
9436
- return typeof arg === "number";
9437
- }
9438
- function convertNumber(arg) {
9439
- if (isNumber(arg)) {
9440
- return arg;
9441
- }
9442
- if (isString(arg) && arg !== "") {
9443
- return Number.parseInt(arg, 10);
9444
- }
9445
- return void 0;
9446
- }
9447
- function isLargeNumber(arg) {
9448
- return typeof arg === "number" || typeof arg === "bigint" || typeof arg === "string";
9449
- }
9450
- function isEmptyOption(arg) {
9451
- return arg === null || arg === void 0;
9452
- }
9453
- function isEncodedEntryFunctionArgument(arg) {
9454
- return (
9455
- /**
9456
- * Determines if the provided argument is an instance of the Bool class.
9457
- *
9458
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9459
- * @group Implementation
9460
- * @category Transactions
9461
- */
9462
- isBcsBool(arg) || /**
9463
- * Determines if the provided argument is an instance of U8.
9464
- * This function helps validate the type of the argument passed to ensure it is a U8 type.
9465
- *
9466
- * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9467
- * @group Implementation
9468
- * @category Transactions
9469
- */
9470
- isBcsU8(arg) || /**
9471
- * Determines if the provided argument is an instance of U16.
9472
- *
9473
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9474
- * @group Implementation
9475
- * @category Transactions
9476
- */
9477
- isBcsU16(arg) || /**
9478
- * Determines if the provided argument is an instance of U32.
9479
- *
9480
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9481
- * @returns A boolean indicating whether the argument is a U32 instance.
9482
- * @group Implementation
9483
- * @category Transactions
9484
- */
9485
- isBcsU32(arg) || /**
9486
- * Determine if the provided argument is an instance of U64.
9487
- * This function helps validate that the argument conforms to the expected U64 type.
9488
- *
9489
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9490
- * @group Implementation
9491
- * @category Transactions
9492
- */
9493
- isBcsU64(arg) || /**
9494
- * Determines if the provided argument is an instance of U128.
9495
- * This function helps validate the type of the argument passed to ensure it is a U128 type.
9496
- *
9497
- * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9498
- * @group Implementation
9499
- * @category Transactions
9500
- */
9501
- isBcsU128(arg) || /**
9502
- * Determines if the provided argument is an instance of U256.
9503
- *
9504
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9505
- * @returns A boolean indicating whether the argument is a U256 instance.
9506
- * @group Implementation
9507
- * @category Transactions
9508
- */
9509
- isBcsU256(arg) || /**
9510
- * Determines if the provided argument is an instance of AccountAddress.
9511
- * This function helps validate whether a given input corresponds to a valid BCS address type.
9512
- *
9513
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9514
- * @group Implementation
9515
- * @category Transactions
9516
- */
9517
- isBcsAddress(arg) || /**
9518
- * Determine if the provided argument is an instance of MoveString.
9519
- *
9520
- * @param arg - The argument to check, which can be of types EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9521
- * @group Implementation
9522
- * @category Transactions
9523
- */
9524
- isBcsString(arg) || /**
9525
- * Determine if the provided argument is an instance of FixedBytes.
9526
- * This function helps to validate the type of the argument being passed.
9527
- *
9528
- * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9529
- * @group Implementation
9530
- * @category Transactions
9531
- */
9532
- isBcsFixedBytes(arg) || arg instanceof MoveVector || arg instanceof MoveOption
9533
- );
9534
- }
9535
- function isBcsBool(arg) {
9536
- return arg instanceof Bool;
9537
- }
9538
- function isBcsAddress(arg) {
9539
- return arg instanceof _chunkJMOQXLEDjs.AccountAddress;
9540
- }
9541
- function isBcsString(arg) {
9542
- return arg instanceof MoveString;
9543
- }
9544
- function isBcsFixedBytes(arg) {
9545
- return arg instanceof FixedBytes;
9546
- }
9547
- function isBcsU8(arg) {
9548
- return arg instanceof U8;
9549
- }
9550
- function isBcsU16(arg) {
9551
- return arg instanceof U16;
9552
- }
9553
- function isBcsU32(arg) {
9554
- return arg instanceof U32;
9555
- }
9556
- function isBcsU64(arg) {
9557
- return arg instanceof U64;
9558
- }
9559
- function isBcsU128(arg) {
9560
- return arg instanceof U128;
9561
- }
9562
- function isBcsU256(arg) {
9563
- return arg instanceof U256;
9564
- }
9565
- function isScriptDataInput(arg) {
9566
- return "bytecode" in arg;
9567
- }
9568
- function throwTypeMismatch(expectedType, position) {
9569
- throw new Error(`Type mismatch for argument ${position}, expected '${expectedType}'`);
9570
- }
9571
- function findFirstNonSignerArg(functionAbi) {
9572
- const index = functionAbi.params.findIndex((param) => param !== "signer" && param !== "&signer");
9573
- if (index < 0) {
9574
- return functionAbi.params.length;
9575
- }
9576
- return index;
9577
- }
9578
-
9579
- // src/transactions/transactionBuilder/transactionBuilder.ts
9580
-
9581
-
9582
- // src/transactions/typeTag/parser.ts
9583
- function isValidIdentifier(str) {
9584
- return !!str.match(/^[_a-zA-Z0-9]+$/);
9585
- }
9586
- function isValidWhitespaceCharacter(char) {
9587
- return !!char.match(/\s/);
9588
- }
9589
- function isGeneric(str) {
9590
- return !!str.match(/^T[0-9]+$/);
9591
- }
9592
- function isRef(str) {
9593
- return !!str.match(/^&.+$/);
9594
- }
9595
- function isPrimitive(str) {
9596
- switch (str) {
9597
- case "signer":
9598
- case "address":
9599
- case "bool":
9600
- case "u8":
9601
- case "u16":
9602
- case "u32":
9603
- case "u64":
9604
- case "u128":
9605
- case "u256":
9606
- return true;
9607
- default:
9608
- return false;
9609
- }
9610
- }
9611
- function consumeWhitespace(tagStr, pos) {
9612
- let i = pos;
9613
- for (; i < tagStr.length; i += 1) {
9614
- const innerChar = tagStr[i];
9615
- if (!isValidWhitespaceCharacter(innerChar)) {
9616
- break;
9617
- }
9618
- }
9619
- return i;
8917
+ return i;
9620
8918
  }
9621
8919
  var TypeTagParserErrorType = /* @__PURE__ */ ((TypeTagParserErrorType2) => {
9622
8920
  TypeTagParserErrorType2["InvalidTypeTag"] = "unknown type";
@@ -9650,7 +8948,7 @@ var TypeTagParserError = class extends Error {
9650
8948
  }
9651
8949
  };
9652
8950
  function parseTypeTag(typeStr, options) {
9653
- const allowGenerics = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _117 => _117.allowGenerics]), () => ( false));
8951
+ const allowGenerics = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _87 => _87.allowGenerics]), () => ( false));
9654
8952
  const saved = [];
9655
8953
  let innerTypes = [];
9656
8954
  let curTypes = [];
@@ -9800,10 +9098,161 @@ function parseTypeTagInner(str, types, allowGenerics) {
9800
9098
  }
9801
9099
  }
9802
9100
 
9101
+ // src/transactions/transactionBuilder/helpers.ts
9102
+ function isBool(arg) {
9103
+ return typeof arg === "boolean";
9104
+ }
9105
+ function isString(arg) {
9106
+ return typeof arg === "string";
9107
+ }
9108
+ function isNumber(arg) {
9109
+ return typeof arg === "number";
9110
+ }
9111
+ function convertNumber(arg) {
9112
+ if (isNumber(arg)) {
9113
+ return arg;
9114
+ }
9115
+ if (isString(arg) && arg !== "") {
9116
+ return Number.parseInt(arg, 10);
9117
+ }
9118
+ return void 0;
9119
+ }
9120
+ function isLargeNumber(arg) {
9121
+ return typeof arg === "number" || typeof arg === "bigint" || typeof arg === "string";
9122
+ }
9123
+ function isEmptyOption(arg) {
9124
+ return arg === null || arg === void 0;
9125
+ }
9126
+ function isEncodedEntryFunctionArgument(arg) {
9127
+ return (
9128
+ /**
9129
+ * Determines if the provided argument is an instance of the Bool class.
9130
+ *
9131
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9132
+ * @group Implementation
9133
+ * @category Transactions
9134
+ */
9135
+ isBcsBool(arg) || /**
9136
+ * Determines if the provided argument is an instance of U8.
9137
+ * This function helps validate the type of the argument passed to ensure it is a U8 type.
9138
+ *
9139
+ * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9140
+ * @group Implementation
9141
+ * @category Transactions
9142
+ */
9143
+ isBcsU8(arg) || /**
9144
+ * Determines if the provided argument is an instance of U16.
9145
+ *
9146
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9147
+ * @group Implementation
9148
+ * @category Transactions
9149
+ */
9150
+ isBcsU16(arg) || /**
9151
+ * Determines if the provided argument is an instance of U32.
9152
+ *
9153
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9154
+ * @returns A boolean indicating whether the argument is a U32 instance.
9155
+ * @group Implementation
9156
+ * @category Transactions
9157
+ */
9158
+ isBcsU32(arg) || /**
9159
+ * Determine if the provided argument is an instance of U64.
9160
+ * This function helps validate that the argument conforms to the expected U64 type.
9161
+ *
9162
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9163
+ * @group Implementation
9164
+ * @category Transactions
9165
+ */
9166
+ isBcsU64(arg) || /**
9167
+ * Determines if the provided argument is an instance of U128.
9168
+ * This function helps validate the type of the argument passed to ensure it is a U128 type.
9169
+ *
9170
+ * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9171
+ * @group Implementation
9172
+ * @category Transactions
9173
+ */
9174
+ isBcsU128(arg) || /**
9175
+ * Determines if the provided argument is an instance of U256.
9176
+ *
9177
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9178
+ * @returns A boolean indicating whether the argument is a U256 instance.
9179
+ * @group Implementation
9180
+ * @category Transactions
9181
+ */
9182
+ isBcsU256(arg) || /**
9183
+ * Determines if the provided argument is an instance of AccountAddress.
9184
+ * This function helps validate whether a given input corresponds to a valid BCS address type.
9185
+ *
9186
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9187
+ * @group Implementation
9188
+ * @category Transactions
9189
+ */
9190
+ isBcsAddress(arg) || /**
9191
+ * Determine if the provided argument is an instance of MoveString.
9192
+ *
9193
+ * @param arg - The argument to check, which can be of types EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9194
+ * @group Implementation
9195
+ * @category Transactions
9196
+ */
9197
+ isBcsString(arg) || /**
9198
+ * Determine if the provided argument is an instance of FixedBytes.
9199
+ * This function helps to validate the type of the argument being passed.
9200
+ *
9201
+ * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.
9202
+ * @group Implementation
9203
+ * @category Transactions
9204
+ */
9205
+ isBcsFixedBytes(arg) || arg instanceof MoveVector || arg instanceof MoveOption
9206
+ );
9207
+ }
9208
+ function isBcsBool(arg) {
9209
+ return arg instanceof Bool;
9210
+ }
9211
+ function isBcsAddress(arg) {
9212
+ return arg instanceof _chunkJMOQXLEDjs.AccountAddress;
9213
+ }
9214
+ function isBcsString(arg) {
9215
+ return arg instanceof MoveString;
9216
+ }
9217
+ function isBcsFixedBytes(arg) {
9218
+ return arg instanceof FixedBytes;
9219
+ }
9220
+ function isBcsU8(arg) {
9221
+ return arg instanceof U8;
9222
+ }
9223
+ function isBcsU16(arg) {
9224
+ return arg instanceof U16;
9225
+ }
9226
+ function isBcsU32(arg) {
9227
+ return arg instanceof U32;
9228
+ }
9229
+ function isBcsU64(arg) {
9230
+ return arg instanceof U64;
9231
+ }
9232
+ function isBcsU128(arg) {
9233
+ return arg instanceof U128;
9234
+ }
9235
+ function isBcsU256(arg) {
9236
+ return arg instanceof U256;
9237
+ }
9238
+ function isScriptDataInput(arg) {
9239
+ return "bytecode" in arg;
9240
+ }
9241
+ function throwTypeMismatch(expectedType, position) {
9242
+ throw new Error(`Type mismatch for argument ${position}, expected '${expectedType}'`);
9243
+ }
9244
+ function findFirstNonSignerArg(functionAbi) {
9245
+ const index = functionAbi.params.findIndex((param) => param !== "signer" && param !== "&signer");
9246
+ if (index < 0) {
9247
+ return functionAbi.params.length;
9248
+ }
9249
+ return index;
9250
+ }
9251
+
9803
9252
  // src/transactions/transactionBuilder/remoteAbi.ts
9804
9253
  var TEXT_ENCODER = new TextEncoder();
9805
9254
  function standardizeTypeTags(typeArguments) {
9806
- return _nullishCoalesce(_optionalChain([typeArguments, 'optionalAccess', _118 => _118.map, 'call', _119 => _119((typeArg) => {
9255
+ return _nullishCoalesce(_optionalChain([typeArguments, 'optionalAccess', _88 => _88.map, 'call', _89 => _89((typeArg) => {
9807
9256
  if (isString(typeArg)) {
9808
9257
  return parseTypeTag(typeArg);
9809
9258
  }
@@ -10198,7 +9647,7 @@ function generateViewFunctionPayloadWithABI(args) {
10198
9647
  `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`
10199
9648
  );
10200
9649
  }
10201
- const functionArguments = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _120 => _120.functionArguments, 'optionalAccess', _121 => _121.map, 'call', _122 => _122((arg, i) => convertArgument(args.function, functionAbi, arg, i, typeArguments))]), () => ( []));
9650
+ const functionArguments = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _90 => _90.functionArguments, 'optionalAccess', _91 => _91.map, 'call', _92 => _92((arg, i) => convertArgument(args.function, functionAbi, arg, i, typeArguments))]), () => ( []));
10202
9651
  if (functionArguments.length !== functionAbi.parameters.length) {
10203
9652
  throw new Error(
10204
9653
  // eslint-disable-next-line max-len
@@ -10226,7 +9675,7 @@ async function generateRawTransaction(args) {
10226
9675
  return { chainId: info.chain_id };
10227
9676
  };
10228
9677
  const getGasUnitPrice = async () => {
10229
- if (_optionalChain([options, 'optionalAccess', _123 => _123.gasUnitPrice])) {
9678
+ if (_optionalChain([options, 'optionalAccess', _93 => _93.gasUnitPrice])) {
10230
9679
  return { gasEstimate: options.gasUnitPrice };
10231
9680
  }
10232
9681
  const estimation = await getGasPriceEstimation({ aptosConfig });
@@ -10234,7 +9683,7 @@ async function generateRawTransaction(args) {
10234
9683
  };
10235
9684
  const getSequenceNumberForAny = async () => {
10236
9685
  const getSequenceNumber = async () => {
10237
- if (_optionalChain([options, 'optionalAccess', _124 => _124.accountSequenceNumber]) !== void 0) {
9686
+ if (_optionalChain([options, 'optionalAccess', _94 => _94.accountSequenceNumber]) !== void 0) {
10238
9687
  return options.accountSequenceNumber;
10239
9688
  }
10240
9689
  return (await getInfo({ aptosConfig, accountAddress: sender })).sequence_number;
@@ -10255,9 +9704,9 @@ async function generateRawTransaction(args) {
10255
9704
  getSequenceNumberForAny()
10256
9705
  ]);
10257
9706
  const { maxGasAmount, gasUnitPrice, expireTimestamp } = {
10258
- maxGasAmount: _optionalChain([options, 'optionalAccess', _125 => _125.maxGasAmount]) ? BigInt(options.maxGasAmount) : BigInt(DEFAULT_MAX_GAS_AMOUNT),
10259
- gasUnitPrice: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _126 => _126.gasUnitPrice]), () => ( BigInt(gasEstimate))),
10260
- expireTimestamp: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _127 => _127.expireTimestamp]), () => ( BigInt(Math.floor(Date.now() / 1e3) + DEFAULT_TXN_EXP_SEC_FROM_NOW)))
9707
+ maxGasAmount: _optionalChain([options, 'optionalAccess', _95 => _95.maxGasAmount]) ? BigInt(options.maxGasAmount) : BigInt(DEFAULT_MAX_GAS_AMOUNT),
9708
+ gasUnitPrice: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _96 => _96.gasUnitPrice]), () => ( BigInt(gasEstimate))),
9709
+ expireTimestamp: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.expireTimestamp]), () => ( BigInt(Math.floor(Date.now() / 1e3) + DEFAULT_TXN_EXP_SEC_FROM_NOW)))
10261
9710
  };
10262
9711
  return new RawTransaction(
10263
9712
  _chunkJMOQXLEDjs.AccountAddress.from(sender),
@@ -10279,7 +9728,7 @@ async function buildTransaction(args) {
10279
9728
  feePayerAddress
10280
9729
  });
10281
9730
  if ("secondarySignerAddresses" in args) {
10282
- const signers = _nullishCoalesce(_optionalChain([args, 'access', _128 => _128.secondarySignerAddresses, 'optionalAccess', _129 => _129.map, 'call', _130 => _130((signer) => _chunkJMOQXLEDjs.AccountAddress.from(signer))]), () => ( []));
9731
+ const signers = _nullishCoalesce(_optionalChain([args, 'access', _98 => _98.secondarySignerAddresses, 'optionalAccess', _99 => _99.map, 'call', _100 => _100((signer) => _chunkJMOQXLEDjs.AccountAddress.from(signer))]), () => ( []));
10283
9732
  return new MultiAgentTransaction(
10284
9733
  rawTxn,
10285
9734
  signers,
@@ -10383,7 +9832,12 @@ function getAuthenticatorForSimulation(publicKey) {
10383
9832
  return new AccountAuthenticatorMultiKey(
10384
9833
  accountPublicKey,
10385
9834
  new MultiKeySignature({
10386
- signatures: accountPublicKey.publicKeys.map(() => new AnySignature(invalidSignature)),
9835
+ signatures: accountPublicKey.publicKeys.map((pubKey) => {
9836
+ if (KeylessPublicKey.isInstance(pubKey.publicKey) || FederatedKeylessPublicKey.isInstance(pubKey.publicKey)) {
9837
+ return new AnySignature(KeylessSignature.getSimulationSignature());
9838
+ }
9839
+ return new AnySignature(invalidSignature);
9840
+ }),
10387
9841
  bitmap: accountPublicKey.createBitmap({
10388
9842
  bits: Array(accountPublicKey.publicKeys.length).fill(0).map((_, i) => i)
10389
9843
  })
@@ -10495,91 +9949,36 @@ var AptosScriptComposer = class _AptosScriptComposer {
10495
9949
  // or the regular entry function arguments.
10496
9950
  //
10497
9951
  // The function would also return a list of `CallArgument` that can be passed on to future calls.
10498
- async addBatchedCalls(input) {
10499
- const { moduleAddress, moduleName, functionName } = _chunkJMOQXLEDjs.getFunctionParts.call(void 0, input.function);
10500
- const nodeUrl = this.config.getRequestUrl("Fullnode" /* FULLNODE */);
10501
- await this.builder.load_module(nodeUrl, `${moduleAddress}::${moduleName}`);
10502
- if (input.typeArguments !== void 0) {
10503
- await Promise.all(input.typeArguments.map((typeTag) => this.builder.load_type_tag(nodeUrl, typeTag.toString())));
10504
- }
10505
- const typeArguments = standardizeTypeTags(input.typeArguments);
10506
- const functionAbi = await fetchMoveFunctionAbi(moduleAddress, moduleName, functionName, this.config);
10507
- if (typeArguments.length !== functionAbi.typeParameters.length) {
10508
- throw new Error(
10509
- `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`
10510
- );
10511
- }
10512
- const functionArguments = input.functionArguments.map(
10513
- (arg, i) => convertCallArgument(arg, functionName, functionAbi, i, typeArguments)
10514
- );
10515
- return this.builder.add_batched_call(
10516
- `${moduleAddress}::${moduleName}`,
10517
- functionName,
10518
- typeArguments.map((arg) => arg.toString()),
10519
- functionArguments
10520
- );
10521
- }
10522
- build() {
10523
- return this.builder.generate_batched_calls(true);
10524
- }
10525
- };
10526
-
10527
- // src/internal/view.ts
10528
- async function view(args) {
10529
- const { aptosConfig, payload, options } = args;
10530
- const viewFunctionPayload = await generateViewFunctionPayload({
10531
- ...payload,
10532
- aptosConfig
10533
- });
10534
- const serializer = new (0, _chunkJMOQXLEDjs.Serializer)();
10535
- viewFunctionPayload.serialize(serializer);
10536
- const bytes = serializer.toUint8Array();
10537
- const { data } = await postAptosFullNode({
10538
- aptosConfig,
10539
- path: "view",
10540
- originMethod: "view",
10541
- contentType: "application/x.aptos.view_function+bcs" /* BCS_VIEW_FUNCTION */,
10542
- params: { ledger_version: _optionalChain([options, 'optionalAccess', _131 => _131.ledgerVersion]) },
10543
- body: bytes
10544
- });
10545
- return data;
10546
- }
10547
- async function viewJson(args) {
10548
- const { aptosConfig, payload, options } = args;
10549
- const { data } = await postAptosFullNode({
10550
- aptosConfig,
10551
- originMethod: "viewJson",
10552
- path: "view",
10553
- params: { ledger_version: _optionalChain([options, 'optionalAccess', _132 => _132.ledgerVersion]) },
10554
- body: {
10555
- function: payload.function,
10556
- type_arguments: _nullishCoalesce(payload.typeArguments, () => ( [])),
10557
- arguments: _nullishCoalesce(payload.functionArguments, () => ( []))
9952
+ async addBatchedCalls(input) {
9953
+ const { moduleAddress, moduleName, functionName } = _chunkJMOQXLEDjs.getFunctionParts.call(void 0, input.function);
9954
+ const nodeUrl = this.config.getRequestUrl("Fullnode" /* FULLNODE */);
9955
+ await this.builder.load_module(nodeUrl, `${moduleAddress}::${moduleName}`);
9956
+ if (input.typeArguments !== void 0) {
9957
+ for (const typeArgument of input.typeArguments) {
9958
+ await this.builder.load_type_tag(nodeUrl, typeArgument.toString());
9959
+ }
10558
9960
  }
10559
- });
10560
- return data;
10561
- }
10562
-
10563
- // src/internal/coin.ts
10564
- var coinTransferAbi = {
10565
- typeParameters: [{ constraints: [] }],
10566
- parameters: [new TypeTagAddress(), new TypeTagU64()]
9961
+ const typeArguments = standardizeTypeTags(input.typeArguments);
9962
+ const functionAbi = await fetchMoveFunctionAbi(moduleAddress, moduleName, functionName, this.config);
9963
+ if (typeArguments.length !== functionAbi.typeParameters.length) {
9964
+ throw new Error(
9965
+ `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`
9966
+ );
9967
+ }
9968
+ const functionArguments = input.functionArguments.map(
9969
+ (arg, i) => convertCallArgument(arg, functionName, functionAbi, i, typeArguments)
9970
+ );
9971
+ return this.builder.add_batched_call(
9972
+ `${moduleAddress}::${moduleName}`,
9973
+ functionName,
9974
+ typeArguments.map((arg) => arg.toString()),
9975
+ functionArguments
9976
+ );
9977
+ }
9978
+ build() {
9979
+ return this.builder.generate_batched_calls(true);
9980
+ }
10567
9981
  };
10568
- async function transferCoinTransaction(args) {
10569
- const { aptosConfig, sender, recipient, amount, coinType, options } = args;
10570
- const coinStructType = _nullishCoalesce(coinType, () => ( APTOS_COIN));
10571
- return generateTransaction({
10572
- aptosConfig,
10573
- sender,
10574
- data: {
10575
- function: "0x1::aptos_account::transfer_coins",
10576
- typeArguments: [coinStructType],
10577
- functionArguments: [recipient, amount],
10578
- abi: coinTransferAbi
10579
- },
10580
- options
10581
- });
10582
- }
10583
9982
 
10584
9983
  // src/internal/transactionSubmission.ts
10585
9984
  async function generateTransaction(args) {
@@ -10678,9 +10077,9 @@ async function simulateTransaction(args) {
10678
10077
  body: signedTransaction,
10679
10078
  path: "transactions/simulate",
10680
10079
  params: {
10681
- estimate_gas_unit_price: _nullishCoalesce(_optionalChain([args, 'access', _133 => _133.options, 'optionalAccess', _134 => _134.estimateGasUnitPrice]), () => ( false)),
10682
- estimate_max_gas_amount: _nullishCoalesce(_optionalChain([args, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateMaxGasAmount]), () => ( false)),
10683
- estimate_prioritized_gas_unit_price: _nullishCoalesce(_optionalChain([args, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimatePrioritizedGasUnitPrice]), () => ( false))
10080
+ estimate_gas_unit_price: _nullishCoalesce(_optionalChain([args, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.estimateGasUnitPrice]), () => ( false)),
10081
+ estimate_max_gas_amount: _nullishCoalesce(_optionalChain([args, 'access', _103 => _103.options, 'optionalAccess', _104 => _104.estimateMaxGasAmount]), () => ( false)),
10082
+ estimate_prioritized_gas_unit_price: _nullishCoalesce(_optionalChain([args, 'access', _105 => _105.options, 'optionalAccess', _106 => _106.estimatePrioritizedGasUnitPrice]), () => ( false))
10684
10083
  },
10685
10084
  originMethod: "simulateTransaction",
10686
10085
  contentType: "application/x.aptos.signed_transaction+bcs" /* BCS_SIGNED_TRANSACTION */
@@ -10723,41 +10122,340 @@ async function signAndSubmitTransaction(args) {
10723
10122
  const senderAuthenticator = signTransaction({ signer, transaction });
10724
10123
  return submitTransaction({
10725
10124
  aptosConfig,
10726
- transaction,
10727
- senderAuthenticator,
10728
- feePayerAuthenticator
10125
+ transaction,
10126
+ senderAuthenticator,
10127
+ feePayerAuthenticator
10128
+ });
10129
+ }
10130
+ async function signAndSubmitAsFeePayer(args) {
10131
+ const { aptosConfig, senderAuthenticator, feePayer, transaction } = args;
10132
+ if (isKeylessSigner(feePayer)) {
10133
+ await feePayer.checkKeylessAccountValidity(aptosConfig);
10134
+ }
10135
+ const feePayerAuthenticator = signAsFeePayer({ signer: feePayer, transaction });
10136
+ return submitTransaction({
10137
+ aptosConfig,
10138
+ transaction,
10139
+ senderAuthenticator,
10140
+ feePayerAuthenticator
10141
+ });
10142
+ }
10143
+ var packagePublishAbi = {
10144
+ typeParameters: [],
10145
+ parameters: [TypeTagVector.u8(), new TypeTagVector(TypeTagVector.u8())]
10146
+ };
10147
+ async function publicPackageTransaction(args) {
10148
+ const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;
10149
+ const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));
10150
+ return generateTransaction({
10151
+ aptosConfig,
10152
+ sender: _chunkJMOQXLEDjs.AccountAddress.from(account),
10153
+ data: {
10154
+ function: "0x1::code::publish_package_txn",
10155
+ functionArguments: [MoveVector.U8(metadataBytes), new MoveVector(totalByteCode)],
10156
+ abi: packagePublishAbi
10157
+ },
10158
+ options
10159
+ });
10160
+ }
10161
+
10162
+ // src/internal/account.ts
10163
+ async function getInfo2(args) {
10164
+ return getInfo(args);
10165
+ }
10166
+ async function getModules2(args) {
10167
+ return getModules(args);
10168
+ }
10169
+ async function getModule2(args) {
10170
+ return getModule(args);
10171
+ }
10172
+ async function getTransactions2(args) {
10173
+ const { aptosConfig, accountAddress, options } = args;
10174
+ return paginateWithCursor({
10175
+ aptosConfig,
10176
+ originMethod: "getTransactions",
10177
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/transactions`,
10178
+ params: { start: _optionalChain([options, 'optionalAccess', _107 => _107.offset]), limit: _optionalChain([options, 'optionalAccess', _108 => _108.limit]) }
10179
+ });
10180
+ }
10181
+ async function getResources(args) {
10182
+ const { aptosConfig, accountAddress, options } = args;
10183
+ return paginateWithObfuscatedCursor({
10184
+ aptosConfig,
10185
+ originMethod: "getResources",
10186
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/resources`,
10187
+ params: {
10188
+ ledger_version: _optionalChain([options, 'optionalAccess', _109 => _109.ledgerVersion]),
10189
+ offset: _optionalChain([options, 'optionalAccess', _110 => _110.offset]),
10190
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _111 => _111.limit]), () => ( 999))
10191
+ }
10192
+ });
10193
+ }
10194
+ async function getResource(args) {
10195
+ const { aptosConfig, accountAddress, resourceType, options } = args;
10196
+ const { data } = await getAptosFullNode({
10197
+ aptosConfig,
10198
+ originMethod: "getResource",
10199
+ path: `accounts/${_chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString()}/resource/${resourceType}`,
10200
+ params: { ledger_version: _optionalChain([options, 'optionalAccess', _112 => _112.ledgerVersion]) }
10201
+ });
10202
+ return data.data;
10203
+ }
10204
+ async function lookupOriginalAccountAddress(args) {
10205
+ const { aptosConfig, authenticationKey, options } = args;
10206
+ const resource = await getResource({
10207
+ aptosConfig,
10208
+ accountAddress: "0x1",
10209
+ resourceType: "0x1::account::OriginatingAddress",
10210
+ options
10211
+ });
10212
+ const {
10213
+ address_map: { handle }
10214
+ } = resource;
10215
+ const authKeyAddress = _chunkJMOQXLEDjs.AccountAddress.from(authenticationKey);
10216
+ try {
10217
+ const originalAddress = await getTableItem({
10218
+ aptosConfig,
10219
+ handle,
10220
+ data: {
10221
+ key: authKeyAddress.toString(),
10222
+ key_type: "address",
10223
+ value_type: "address"
10224
+ },
10225
+ options
10226
+ });
10227
+ return _chunkJMOQXLEDjs.AccountAddress.from(originalAddress);
10228
+ } catch (err) {
10229
+ if (err instanceof AptosApiError && err.data.error_code === "table_item_not_found") {
10230
+ return authKeyAddress;
10231
+ }
10232
+ throw err;
10233
+ }
10234
+ }
10235
+ async function getAccountTokensCount(args) {
10236
+ const { aptosConfig, accountAddress } = args;
10237
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10238
+ const whereCondition = {
10239
+ owner_address: { _eq: address },
10240
+ amount: { _gt: 0 }
10241
+ };
10242
+ const graphqlQuery = {
10243
+ query: GetAccountTokensCount,
10244
+ variables: { where_condition: whereCondition }
10245
+ };
10246
+ const data = await queryIndexer({
10247
+ aptosConfig,
10248
+ query: graphqlQuery,
10249
+ originMethod: "getAccountTokensCount"
10250
+ });
10251
+ return data.current_token_ownerships_v2_aggregate.aggregate ? data.current_token_ownerships_v2_aggregate.aggregate.count : 0;
10252
+ }
10253
+ async function getAccountOwnedTokens(args) {
10254
+ const { aptosConfig, accountAddress, options } = args;
10255
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10256
+ const whereCondition = {
10257
+ owner_address: { _eq: address },
10258
+ amount: { _gt: 0 }
10259
+ };
10260
+ if (_optionalChain([options, 'optionalAccess', _113 => _113.tokenStandard])) {
10261
+ whereCondition.token_standard = { _eq: _optionalChain([options, 'optionalAccess', _114 => _114.tokenStandard]) };
10262
+ }
10263
+ const graphqlQuery = {
10264
+ query: GetAccountOwnedTokens,
10265
+ variables: {
10266
+ where_condition: whereCondition,
10267
+ offset: _optionalChain([options, 'optionalAccess', _115 => _115.offset]),
10268
+ limit: _optionalChain([options, 'optionalAccess', _116 => _116.limit]),
10269
+ order_by: _optionalChain([options, 'optionalAccess', _117 => _117.orderBy])
10270
+ }
10271
+ };
10272
+ const data = await queryIndexer({
10273
+ aptosConfig,
10274
+ query: graphqlQuery,
10275
+ originMethod: "getAccountOwnedTokens"
10276
+ });
10277
+ return data.current_token_ownerships_v2;
10278
+ }
10279
+ async function getAccountOwnedTokensFromCollectionAddress(args) {
10280
+ const { aptosConfig, accountAddress, collectionAddress, options } = args;
10281
+ const ownerAddress = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10282
+ const collAddress = _chunkJMOQXLEDjs.AccountAddress.from(collectionAddress).toStringLong();
10283
+ const whereCondition = {
10284
+ owner_address: { _eq: ownerAddress },
10285
+ current_token_data: { collection_id: { _eq: collAddress } },
10286
+ amount: { _gt: 0 }
10287
+ };
10288
+ if (_optionalChain([options, 'optionalAccess', _118 => _118.tokenStandard])) {
10289
+ whereCondition.token_standard = { _eq: _optionalChain([options, 'optionalAccess', _119 => _119.tokenStandard]) };
10290
+ }
10291
+ const graphqlQuery = {
10292
+ query: GetAccountOwnedTokensFromCollection,
10293
+ variables: {
10294
+ where_condition: whereCondition,
10295
+ offset: _optionalChain([options, 'optionalAccess', _120 => _120.offset]),
10296
+ limit: _optionalChain([options, 'optionalAccess', _121 => _121.limit]),
10297
+ order_by: _optionalChain([options, 'optionalAccess', _122 => _122.orderBy])
10298
+ }
10299
+ };
10300
+ const data = await queryIndexer({
10301
+ aptosConfig,
10302
+ query: graphqlQuery,
10303
+ originMethod: "getAccountOwnedTokensFromCollectionAddress"
10304
+ });
10305
+ return data.current_token_ownerships_v2;
10306
+ }
10307
+ async function getAccountCollectionsWithOwnedTokens(args) {
10308
+ const { aptosConfig, accountAddress, options } = args;
10309
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10310
+ const whereCondition = {
10311
+ owner_address: { _eq: address }
10312
+ };
10313
+ if (_optionalChain([options, 'optionalAccess', _123 => _123.tokenStandard])) {
10314
+ whereCondition.current_collection = {
10315
+ token_standard: { _eq: _optionalChain([options, 'optionalAccess', _124 => _124.tokenStandard]) }
10316
+ };
10317
+ }
10318
+ const graphqlQuery = {
10319
+ query: GetAccountCollectionsWithOwnedTokens,
10320
+ variables: {
10321
+ where_condition: whereCondition,
10322
+ offset: _optionalChain([options, 'optionalAccess', _125 => _125.offset]),
10323
+ limit: _optionalChain([options, 'optionalAccess', _126 => _126.limit]),
10324
+ order_by: _optionalChain([options, 'optionalAccess', _127 => _127.orderBy])
10325
+ }
10326
+ };
10327
+ const data = await queryIndexer({
10328
+ aptosConfig,
10329
+ query: graphqlQuery,
10330
+ originMethod: "getAccountCollectionsWithOwnedTokens"
10331
+ });
10332
+ return data.current_collection_ownership_v2_view;
10333
+ }
10334
+ async function getAccountTransactionsCount(args) {
10335
+ const { aptosConfig, accountAddress } = args;
10336
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10337
+ const graphqlQuery = {
10338
+ query: GetAccountTransactionsCount,
10339
+ variables: { address }
10340
+ };
10341
+ const data = await queryIndexer({
10342
+ aptosConfig,
10343
+ query: graphqlQuery,
10344
+ originMethod: "getAccountTransactionsCount"
10345
+ });
10346
+ return data.account_transactions_aggregate.aggregate ? data.account_transactions_aggregate.aggregate.count : 0;
10347
+ }
10348
+ async function getAccountCoinsData(args) {
10349
+ const { aptosConfig, accountAddress, options } = args;
10350
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10351
+ const whereCondition = {
10352
+ ..._optionalChain([options, 'optionalAccess', _128 => _128.where]),
10353
+ owner_address: { _eq: address }
10354
+ };
10355
+ const graphqlQuery = {
10356
+ query: GetAccountCoinsData,
10357
+ variables: {
10358
+ where_condition: whereCondition,
10359
+ offset: _optionalChain([options, 'optionalAccess', _129 => _129.offset]),
10360
+ limit: _optionalChain([options, 'optionalAccess', _130 => _130.limit]),
10361
+ order_by: _optionalChain([options, 'optionalAccess', _131 => _131.orderBy])
10362
+ }
10363
+ };
10364
+ const data = await queryIndexer({
10365
+ aptosConfig,
10366
+ query: graphqlQuery,
10367
+ originMethod: "getAccountCoinsData"
10729
10368
  });
10369
+ return data.current_fungible_asset_balances;
10730
10370
  }
10731
- async function signAndSubmitAsFeePayer(args) {
10732
- const { aptosConfig, senderAuthenticator, feePayer, transaction } = args;
10733
- if (isKeylessSigner(feePayer)) {
10734
- await feePayer.checkKeylessAccountValidity(aptosConfig);
10371
+ async function getAccountCoinsCount(args) {
10372
+ const { aptosConfig, accountAddress } = args;
10373
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10374
+ const graphqlQuery = {
10375
+ query: GetAccountCoinsCount,
10376
+ variables: { address }
10377
+ };
10378
+ const data = await queryIndexer({
10379
+ aptosConfig,
10380
+ query: graphqlQuery,
10381
+ originMethod: "getAccountCoinsCount"
10382
+ });
10383
+ if (!data.current_fungible_asset_balances_aggregate.aggregate) {
10384
+ throw Error("Failed to get the count of account coins");
10735
10385
  }
10736
- const feePayerAuthenticator = signAsFeePayer({ signer: feePayer, transaction });
10737
- return submitTransaction({
10386
+ return data.current_fungible_asset_balances_aggregate.aggregate.count;
10387
+ }
10388
+ async function getAccountOwnedObjects(args) {
10389
+ const { aptosConfig, accountAddress, options } = args;
10390
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toStringLong();
10391
+ const whereCondition = {
10392
+ owner_address: { _eq: address }
10393
+ };
10394
+ const graphqlQuery = {
10395
+ query: GetObjectData,
10396
+ variables: {
10397
+ where_condition: whereCondition,
10398
+ offset: _optionalChain([options, 'optionalAccess', _132 => _132.offset]),
10399
+ limit: _optionalChain([options, 'optionalAccess', _133 => _133.limit]),
10400
+ order_by: _optionalChain([options, 'optionalAccess', _134 => _134.orderBy])
10401
+ }
10402
+ };
10403
+ const data = await queryIndexer({
10738
10404
  aptosConfig,
10739
- transaction,
10740
- senderAuthenticator,
10741
- feePayerAuthenticator
10405
+ query: graphqlQuery,
10406
+ originMethod: "getAccountOwnedObjects"
10742
10407
  });
10408
+ return data.current_objects;
10743
10409
  }
10744
- var packagePublishAbi = {
10745
- typeParameters: [],
10746
- parameters: [TypeTagVector.u8(), new TypeTagVector(TypeTagVector.u8())]
10747
- };
10748
- async function publicPackageTransaction(args) {
10749
- const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;
10750
- const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));
10751
- return generateTransaction({
10410
+ async function deriveAccountFromPrivateKey(args) {
10411
+ const { aptosConfig, privateKey } = args;
10412
+ const publicKey = new AnyPublicKey(privateKey.publicKey());
10413
+ if (privateKey instanceof Secp256k1PrivateKey) {
10414
+ const authKey = AuthenticationKey.fromPublicKey({ publicKey });
10415
+ const address = authKey.derivedAddress();
10416
+ return Account.fromPrivateKey({ privateKey, address });
10417
+ }
10418
+ if (privateKey instanceof Ed25519PrivateKey) {
10419
+ const singleSenderTransactionAuthenticatorAuthKey = AuthenticationKey.fromPublicKey({
10420
+ publicKey
10421
+ });
10422
+ const isSingleSenderTransactionAuthenticator = await isAccountExist({
10423
+ authKey: singleSenderTransactionAuthenticatorAuthKey,
10424
+ aptosConfig
10425
+ });
10426
+ if (isSingleSenderTransactionAuthenticator) {
10427
+ const address = singleSenderTransactionAuthenticatorAuthKey.derivedAddress();
10428
+ return Account.fromPrivateKey({ privateKey, address, legacy: false });
10429
+ }
10430
+ const legacyAuthKey = AuthenticationKey.fromPublicKey({
10431
+ publicKey: publicKey.publicKey
10432
+ });
10433
+ const isLegacyEd25519 = await isAccountExist({ authKey: legacyAuthKey, aptosConfig });
10434
+ if (isLegacyEd25519) {
10435
+ const address = legacyAuthKey.derivedAddress();
10436
+ return Account.fromPrivateKey({ privateKey, address, legacy: true });
10437
+ }
10438
+ }
10439
+ throw new Error(`Can't derive account from private key ${privateKey}`);
10440
+ }
10441
+ async function isAccountExist(args) {
10442
+ const { aptosConfig, authKey } = args;
10443
+ const accountAddress = await lookupOriginalAccountAddress({
10752
10444
  aptosConfig,
10753
- sender: _chunkJMOQXLEDjs.AccountAddress.from(account),
10754
- data: {
10755
- function: "0x1::code::publish_package_txn",
10756
- functionArguments: [MoveVector.U8(metadataBytes), new MoveVector(totalByteCode)],
10757
- abi: packagePublishAbi
10758
- },
10759
- options
10445
+ authenticationKey: authKey.derivedAddress()
10760
10446
  });
10447
+ try {
10448
+ await getInfo2({
10449
+ aptosConfig,
10450
+ accountAddress
10451
+ });
10452
+ return true;
10453
+ } catch (error) {
10454
+ if (error.status === 404) {
10455
+ return false;
10456
+ }
10457
+ throw new Error(`Error while looking for an account info ${accountAddress.toString()}`);
10458
+ }
10761
10459
  }
10762
10460
  var rotateAuthKeyAbi = {
10763
10461
  typeParameters: [],
@@ -10770,17 +10468,71 @@ var rotateAuthKeyAbi = {
10770
10468
  TypeTagVector.u8()
10771
10469
  ]
10772
10470
  };
10773
- var rotateAuthKeyUnverifiedAbi = {
10774
- typeParameters: [],
10775
- parameters: [TypeTagVector.u8()]
10776
- };
10777
10471
  async function rotateAuthKey(args) {
10778
- const { aptosConfig, fromAccount, toNewPrivateKey } = args;
10779
- const accountInfo = await getInfo({
10472
+ const { aptosConfig, fromAccount, dangerouslySkipVerification } = args;
10473
+ if ("toNewPrivateKey" in args) {
10474
+ return rotateAuthKeyWithChallenge({
10475
+ aptosConfig,
10476
+ fromAccount,
10477
+ toNewPrivateKey: args.toNewPrivateKey
10478
+ });
10479
+ }
10480
+ let authKey;
10481
+ if ("toAccount" in args) {
10482
+ if (args.toAccount instanceof Ed25519Account) {
10483
+ return rotateAuthKeyWithChallenge({ aptosConfig, fromAccount, toNewPrivateKey: args.toAccount.privateKey });
10484
+ }
10485
+ if (args.toAccount instanceof MultiEd25519Account) {
10486
+ return rotateAuthKeyWithChallenge({ aptosConfig, fromAccount, toAccount: args.toAccount });
10487
+ }
10488
+ authKey = args.toAccount.publicKey.authKey();
10489
+ } else if ("toAuthKey" in args) {
10490
+ authKey = args.toAuthKey;
10491
+ } else {
10492
+ throw new Error("Invalid arguments");
10493
+ }
10494
+ const pendingTxn = await rotateAuthKeyUnverified({
10495
+ aptosConfig,
10496
+ fromAccount,
10497
+ toAuthKey: authKey
10498
+ });
10499
+ if (dangerouslySkipVerification === true) {
10500
+ return pendingTxn;
10501
+ }
10502
+ const rotateAuthKeyTxnResponse = await waitForTransaction({
10503
+ aptosConfig,
10504
+ transactionHash: pendingTxn.hash
10505
+ });
10506
+ if (!rotateAuthKeyTxnResponse.success) {
10507
+ throw new Error(`Failed to rotate authentication key - ${rotateAuthKeyTxnResponse}`);
10508
+ }
10509
+ const verificationTxn = await generateTransaction({
10510
+ aptosConfig,
10511
+ sender: fromAccount.accountAddress,
10512
+ data: {
10513
+ function: "0x1::account::set_originating_address",
10514
+ functionArguments: []
10515
+ }
10516
+ });
10517
+ return signAndSubmitTransaction({
10518
+ aptosConfig,
10519
+ signer: args.toAccount,
10520
+ // Use the new account to sign
10521
+ transaction: verificationTxn
10522
+ });
10523
+ }
10524
+ async function rotateAuthKeyWithChallenge(args) {
10525
+ const { aptosConfig, fromAccount } = args;
10526
+ const accountInfo = await getInfo2({
10780
10527
  aptosConfig,
10781
10528
  accountAddress: fromAccount.accountAddress
10782
10529
  });
10783
- const newAccount = Account.fromPrivateKey({ privateKey: toNewPrivateKey, legacy: true });
10530
+ let newAccount;
10531
+ if ("toNewPrivateKey" in args) {
10532
+ newAccount = Account.fromPrivateKey({ privateKey: args.toNewPrivateKey, legacy: true });
10533
+ } else {
10534
+ newAccount = args.toAccount;
10535
+ }
10784
10536
  const challenge = new RotationProofChallenge({
10785
10537
  sequenceNumber: BigInt(accountInfo.sequence_number),
10786
10538
  originator: fromAccount.accountAddress,
@@ -10788,8 +10540,8 @@ async function rotateAuthKey(args) {
10788
10540
  newPublicKey: newAccount.publicKey
10789
10541
  });
10790
10542
  const challengeHex = challenge.bcsToBytes();
10791
- const proofSignedByCurrentPrivateKey = fromAccount.sign(challengeHex);
10792
- const proofSignedByNewPrivateKey = newAccount.sign(challengeHex);
10543
+ const proofSignedByCurrentKey = fromAccount.sign(challengeHex);
10544
+ const proofSignedByNewKey = newAccount.sign(challengeHex);
10793
10545
  const rawTxn = await generateTransaction({
10794
10546
  aptosConfig,
10795
10547
  sender: fromAccount.accountAddress,
@@ -10802,100 +10554,338 @@ async function rotateAuthKey(args) {
10802
10554
  new U8(newAccount.signingScheme),
10803
10555
  // to scheme
10804
10556
  MoveVector.U8(newAccount.publicKey.toUint8Array()),
10805
- MoveVector.U8(proofSignedByCurrentPrivateKey.toUint8Array()),
10806
- MoveVector.U8(proofSignedByNewPrivateKey.toUint8Array())
10557
+ MoveVector.U8(proofSignedByCurrentKey.toUint8Array()),
10558
+ MoveVector.U8(proofSignedByNewKey.toUint8Array())
10807
10559
  ],
10808
10560
  abi: rotateAuthKeyAbi
10809
10561
  }
10810
- });
10811
- return signAndSubmitTransaction({
10562
+ });
10563
+ return signAndSubmitTransaction({
10564
+ aptosConfig,
10565
+ signer: fromAccount,
10566
+ transaction: rawTxn
10567
+ });
10568
+ }
10569
+ var rotateAuthKeyUnverifiedAbi = {
10570
+ typeParameters: [],
10571
+ parameters: [TypeTagVector.u8()]
10572
+ };
10573
+ async function rotateAuthKeyUnverified(args) {
10574
+ const { aptosConfig, fromAccount, toAuthKey } = args;
10575
+ const authKey = toAuthKey;
10576
+ const rawTxn = await generateTransaction({
10577
+ aptosConfig,
10578
+ sender: fromAccount.accountAddress,
10579
+ data: {
10580
+ function: "0x1::account::rotate_authentication_key_call",
10581
+ functionArguments: [MoveVector.U8(authKey.toUint8Array())],
10582
+ abi: rotateAuthKeyUnverifiedAbi
10583
+ }
10584
+ });
10585
+ return signAndSubmitTransaction({
10586
+ aptosConfig,
10587
+ signer: fromAccount,
10588
+ transaction: rawTxn
10589
+ });
10590
+ }
10591
+ async function getMultiKeysForAuthenticationKeys(args) {
10592
+ const { aptosConfig, authKeys } = args;
10593
+ if (authKeys.length === 0) {
10594
+ throw new Error("No authentication keys provided");
10595
+ }
10596
+ const whereCondition = {
10597
+ auth_key: { _in: authKeys.map((authKey) => authKey.toString()) }
10598
+ };
10599
+ const graphqlQuery = {
10600
+ query: GetMultiKeyForAuthKey,
10601
+ variables: {
10602
+ where_condition: whereCondition
10603
+ }
10604
+ };
10605
+ const { auth_key_multikey_layout: data } = await queryIndexer({
10606
+ aptosConfig,
10607
+ query: graphqlQuery,
10608
+ originMethod: "getMultiKeysForAuthenticationKeys"
10609
+ });
10610
+ const authKeyToMultiKey = new Map(data.map((entry) => [entry.auth_key, entry]));
10611
+ const result = [];
10612
+ for (let i = 0; i < authKeys.length; i += 1) {
10613
+ const entry = authKeyToMultiKey.get(authKeys[i].toString());
10614
+ if (!entry) {
10615
+ throw new Error(`Failed to find multikey for authentication key ${authKeys[i]}`);
10616
+ }
10617
+ const publicKey = extractMultiKeyFromData(entry);
10618
+ result.push({ authKey: authKeys[i], publicKey });
10619
+ }
10620
+ return result;
10621
+ }
10622
+ function extractMultiKeyFromData(data) {
10623
+ const signaturesRequired = data.signatures_required;
10624
+ const multikeyLayout = data.multikey_layout_with_prefixes;
10625
+ const multikeyType = data.multikey_type;
10626
+ if (multikeyType === "multi_ed25519") {
10627
+ const ed25519PublicKeys = [];
10628
+ for (const key of multikeyLayout) {
10629
+ ed25519PublicKeys.push(new Ed25519PublicKey(key));
10630
+ }
10631
+ return new MultiEd25519PublicKey({
10632
+ publicKeys: ed25519PublicKeys,
10633
+ threshold: signaturesRequired
10634
+ });
10635
+ }
10636
+ if (multikeyType === "multi_key") {
10637
+ const publicKeys = [];
10638
+ for (const key of multikeyLayout) {
10639
+ const deserializer = Deserializer.fromHex(key);
10640
+ const variantIndex = deserializer.deserializeUleb128AsU32();
10641
+ let publicKey;
10642
+ switch (variantIndex) {
10643
+ case 0 /* Ed25519 */:
10644
+ publicKey = new Ed25519PublicKey(deserializer.deserializeFixedBytes(32));
10645
+ break;
10646
+ case 1 /* Secp256k1 */:
10647
+ publicKey = new Secp256k1PublicKey(deserializer.deserializeFixedBytes(65));
10648
+ break;
10649
+ case 3 /* Keyless */:
10650
+ publicKey = KeylessPublicKey.deserialize(deserializer);
10651
+ break;
10652
+ case 4 /* FederatedKeyless */:
10653
+ publicKey = FederatedKeylessPublicKey.deserialize(deserializer);
10654
+ break;
10655
+ default:
10656
+ throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
10657
+ }
10658
+ publicKeys.push(new AnyPublicKey(publicKey));
10659
+ }
10660
+ return new MultiKey({
10661
+ publicKeys,
10662
+ signaturesRequired
10663
+ });
10664
+ }
10665
+ throw new Error("Unknown multikey type");
10666
+ }
10667
+ async function getAuthKeysForPublicKey(args) {
10668
+ const { aptosConfig, publicKey, options } = args;
10669
+ const verified = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.verified]), () => ( true));
10670
+ let baseKey = publicKey;
10671
+ if (publicKey instanceof AnyPublicKey) {
10672
+ baseKey = publicKey.publicKey;
10673
+ }
10674
+ const whereCondition = {
10675
+ public_key: { _eq: baseKey.toString() },
10676
+ verified: { _eq: verified }
10677
+ };
10678
+ const graphqlQuery = {
10679
+ query: GetAuthKeysForPublicKey,
10680
+ variables: {
10681
+ where_condition: whereCondition
10682
+ }
10683
+ };
10684
+ const { public_key_auth_keys: data } = await queryIndexer({
10812
10685
  aptosConfig,
10813
- signer: fromAccount,
10814
- transaction: rawTxn
10686
+ query: graphqlQuery,
10687
+ originMethod: "getAuthKeysForPublicKey"
10815
10688
  });
10689
+ const sortedData = data.sort((a, b) => Number(b.last_transaction_version) - Number(a.last_transaction_version));
10690
+ const authKeys = sortedData.map((entry) => new AuthenticationKey({ data: entry.auth_key }));
10691
+ return authKeys;
10816
10692
  }
10817
- async function rotateAuthKeyToMultiEd25519(args) {
10818
- const { aptosConfig, fromAccount, multiEd25519Account } = args;
10819
- const accountInfo = await getInfo({
10820
- aptosConfig,
10821
- accountAddress: fromAccount.accountAddress
10822
- });
10823
- const newAccount = multiEd25519Account;
10824
- const challenge = new RotationProofChallenge({
10825
- sequenceNumber: BigInt(accountInfo.sequence_number),
10826
- originator: fromAccount.accountAddress,
10827
- currentAuthKey: _chunkJMOQXLEDjs.AccountAddress.from(accountInfo.authentication_key),
10828
- newPublicKey: newAccount.publicKey
10829
- });
10830
- const challengeHex = challenge.bcsToBytes();
10831
- const proofSignedByCurrentPrivateKey = fromAccount.sign(challengeHex);
10832
- const proofSignedByNewPrivateKey = newAccount.sign(challengeHex);
10833
- const rawTxn = await generateTransaction({
10834
- aptosConfig,
10835
- sender: fromAccount.accountAddress,
10836
- data: {
10837
- function: "0x1::account::rotate_authentication_key",
10838
- functionArguments: [
10839
- new U8(fromAccount.signingScheme),
10840
- // from scheme
10841
- MoveVector.U8(fromAccount.publicKey.toUint8Array()),
10842
- new U8(newAccount.signingScheme),
10843
- // to scheme
10844
- MoveVector.U8(newAccount.publicKey.toUint8Array()),
10845
- MoveVector.U8(proofSignedByCurrentPrivateKey.toUint8Array()),
10846
- MoveVector.U8(proofSignedByNewPrivateKey.toUint8Array())
10847
- ],
10848
- abi: rotateAuthKeyAbi
10693
+ async function getLastestTransactionVersionForAddress(args) {
10694
+ const { aptosConfig, accountAddress } = args;
10695
+ const address = _chunkJMOQXLEDjs.AccountAddress.from(accountAddress).toString();
10696
+ const whereCondition = {
10697
+ signer: { _eq: accountAddress.toString() }
10698
+ };
10699
+ const graphqlQuery = {
10700
+ query: GetSignatures,
10701
+ variables: {
10702
+ where_condition: whereCondition,
10703
+ limit: 1,
10704
+ order_by: { transaction_version: "desc" }
10849
10705
  }
10850
- });
10851
- return signAndSubmitTransaction({
10706
+ };
10707
+ const { signatures: data } = await queryIndexer({
10852
10708
  aptosConfig,
10853
- signer: fromAccount,
10854
- transaction: rawTxn
10709
+ query: graphqlQuery,
10710
+ originMethod: "getSignatures"
10855
10711
  });
10712
+ if (data.length !== 1) {
10713
+ throw new Error(`No signatures found for address ${address}`);
10714
+ }
10715
+ return Number(data[0].transaction_version);
10856
10716
  }
10857
- async function rotateAuthKeyWithVerificationTransaction(args) {
10858
- const { aptosConfig, fromAccount, toAccount } = args;
10859
- const rawTxn = await generateTransaction({
10860
- aptosConfig,
10861
- sender: fromAccount.accountAddress,
10862
- data: {
10863
- function: "0x1::account::rotate_authentication_key_call",
10864
- functionArguments: [MoveVector.U8(toAccount.publicKey.authKey().toUint8Array())],
10865
- abi: rotateAuthKeyUnverifiedAbi
10717
+ async function getAccountAddressesForAuthKeys(args) {
10718
+ const { aptosConfig, options, authKeys } = args;
10719
+ const verified = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _136 => _136.verified]), () => ( true));
10720
+ if (authKeys.length === 0) {
10721
+ throw new Error("No authentication keys provided");
10722
+ }
10723
+ const whereCondition = {
10724
+ auth_key: { _in: authKeys.map((authKey) => authKey.toString()) },
10725
+ verified: { _eq: verified }
10726
+ };
10727
+ const graphqlQuery = {
10728
+ query: GetAccountAddressesForAuthKey,
10729
+ variables: {
10730
+ where_condition: whereCondition
10866
10731
  }
10867
- });
10868
- const pendingTxn = await signAndSubmitTransaction({
10732
+ };
10733
+ const { auth_key_account_addresses: data } = await queryIndexer({
10869
10734
  aptosConfig,
10870
- signer: fromAccount,
10871
- transaction: rawTxn
10735
+ query: graphqlQuery,
10736
+ originMethod: "getAccountAddressesForAuthKeys"
10872
10737
  });
10873
- const txnResponse = await waitForTransaction({
10874
- aptosConfig,
10875
- transactionHash: pendingTxn.hash
10738
+ return data.map((entry) => ({
10739
+ authKey: new AuthenticationKey({ data: entry.auth_key }),
10740
+ accountAddress: new (0, _chunkJMOQXLEDjs.AccountAddress)(_chunkJMOQXLEDjs.Hex.hexInputToUint8Array(entry.address)),
10741
+ verified: entry.verified,
10742
+ lastTransactionVersion: Number(entry.last_transaction_version)
10743
+ }));
10744
+ }
10745
+ async function getAccountsForPublicKey(args) {
10746
+ const { aptosConfig, publicKey } = args;
10747
+ let baseKey = publicKey;
10748
+ if (publicKey instanceof AnyPublicKey) {
10749
+ baseKey = publicKey.publicKey;
10750
+ }
10751
+ const singleKeyPublicKeys = [];
10752
+ if (baseKey instanceof Ed25519PublicKey) {
10753
+ singleKeyPublicKeys.push(baseKey);
10754
+ }
10755
+ const anyPublicKey = new AnyPublicKey(baseKey);
10756
+ singleKeyPublicKeys.push(anyPublicKey);
10757
+ const singleKeyAuthKeyPublicKeyPairs = singleKeyPublicKeys.map((pubKey) => {
10758
+ const authKey = pubKey.authKey();
10759
+ return { authKey, publicKey: pubKey };
10876
10760
  });
10877
- if (!txnResponse.success) {
10878
- throw new Error(`Failed to rotate authentication key - ${txnResponse}`);
10761
+ const multiKeyAuthKeys = await getAuthKeysForPublicKey({ aptosConfig, publicKey });
10762
+ const [multiKeyPairs, authKeyAccountAddressPairs] = await Promise.all([
10763
+ getMultiKeysForAuthenticationKeys({ aptosConfig, authKeys: multiKeyAuthKeys }),
10764
+ getAccountAddressesForAuthKeys({
10765
+ aptosConfig,
10766
+ authKeys: multiKeyAuthKeys.concat(singleKeyAuthKeyPublicKeyPairs.map((pair) => pair.publicKey.authKey()))
10767
+ })
10768
+ ]);
10769
+ const authKeyPublicKeyPairs = singleKeyAuthKeyPublicKeyPairs.concat(multiKeyPairs);
10770
+ const result = [];
10771
+ const authKeyToPublicKey = new Map(authKeyPublicKeyPairs.map((pair) => [pair.authKey.toString(), pair.publicKey]));
10772
+ for (const authKeyAccountAddressPair of authKeyAccountAddressPairs) {
10773
+ if (!authKeyToPublicKey.has(authKeyAccountAddressPair.authKey.toString())) {
10774
+ throw new Error(`No publicKey found for authentication key ${authKeyAccountAddressPair.authKey}.`);
10775
+ }
10776
+ result.push({
10777
+ accountAddress: authKeyAccountAddressPair.accountAddress,
10778
+ publicKey: authKeyToPublicKey.get(authKeyAccountAddressPair.authKey.toString()),
10779
+ verified: authKeyAccountAddressPair.verified,
10780
+ lastTransactionVersion: authKeyAccountAddressPair.lastTransactionVersion
10781
+ });
10879
10782
  }
10880
- const coinTxn = await transferCoinTransaction({
10783
+ return result;
10784
+ }
10785
+ async function getPublicKeyFromAccountAddress(args) {
10786
+ const { aptosConfig, accountAddress } = args;
10787
+ const accountData = await getInfo2({ aptosConfig, accountAddress });
10788
+ const lastTransactionVersion = await getLastestTransactionVersionForAddress({
10881
10789
  aptosConfig,
10882
- sender: toAccount.accountAddress,
10883
- recipient: toAccount.accountAddress,
10884
- amount: 1
10790
+ accountAddress
10791
+ });
10792
+ console.log("lastTransactionVersion", lastTransactionVersion);
10793
+ const transaction = await getTransactionByVersion({ aptosConfig, ledgerVersion: lastTransactionVersion });
10794
+ if (!_chunkJMOQXLEDjs.isUserTransactionResponse.call(void 0, transaction)) {
10795
+ throw new Error("Transaction is not a user transaction");
10796
+ }
10797
+ const { signature } = transaction;
10798
+ if (!signature) {
10799
+ throw new Error("Transaction has no signature");
10800
+ }
10801
+ let publicKey;
10802
+ if (_chunkJMOQXLEDjs.isEd25519Signature.call(void 0, signature)) {
10803
+ publicKey = new Ed25519PublicKey(signature.public_key);
10804
+ } else if (_chunkJMOQXLEDjs.isMultiEd25519Signature.call(void 0, signature)) {
10805
+ publicKey = new MultiEd25519PublicKey({
10806
+ publicKeys: signature.public_keys.map((pk) => new Ed25519PublicKey(pk)),
10807
+ threshold: signature.threshold
10808
+ });
10809
+ } else if (_chunkJMOQXLEDjs.isSingleSenderSingleKeySignature.call(void 0, signature)) {
10810
+ publicKey = parsePublicKey(signature.public_key);
10811
+ } else if (_chunkJMOQXLEDjs.isSingleSenderMultiKeySignature.call(void 0, signature)) {
10812
+ const publicKeys = [];
10813
+ for (const pk of signature.public_keys) {
10814
+ publicKeys.push(parsePublicKey(pk));
10815
+ }
10816
+ publicKey = new MultiKey({
10817
+ publicKeys,
10818
+ signaturesRequired: signature.signatures_required
10819
+ });
10820
+ } else {
10821
+ throw new Error("Unknown signature type");
10822
+ }
10823
+ if (publicKey.authKey().toString() !== accountData.authentication_key) {
10824
+ throw new Error(
10825
+ "Derived public key does not match authentication key. The most recent signature was likely a key rotation."
10826
+ );
10827
+ }
10828
+ return publicKey;
10829
+ }
10830
+ function parsePublicKey(data) {
10831
+ if (data.type === "keyless") {
10832
+ const deserializer = Deserializer.fromHex(data.value);
10833
+ return new AnyPublicKey(KeylessPublicKey.deserialize(deserializer));
10834
+ }
10835
+ if (data.type === "ed25519") {
10836
+ return new AnyPublicKey(new Ed25519PublicKey(data.value));
10837
+ }
10838
+ if (data.type === "secp256k1_ecdsa") {
10839
+ return new AnyPublicKey(new Secp256k1PublicKey(data.value));
10840
+ }
10841
+ throw new Error("Unknown public key type");
10842
+ }
10843
+
10844
+ // src/api/utils.ts
10845
+ async function waitForIndexerOnVersion(args) {
10846
+ if (args.minimumLedgerVersion !== void 0) {
10847
+ await waitForIndexer({
10848
+ aptosConfig: args.config,
10849
+ minimumLedgerVersion: args.minimumLedgerVersion,
10850
+ processorType: args.processorType
10851
+ });
10852
+ }
10853
+ }
10854
+
10855
+ // src/internal/view.ts
10856
+ async function view(args) {
10857
+ const { aptosConfig, payload, options } = args;
10858
+ const viewFunctionPayload = await generateViewFunctionPayload({
10859
+ ...payload,
10860
+ aptosConfig
10885
10861
  });
10886
- const pendingCoinTxn = await signAndSubmitTransaction({
10862
+ const serializer = new (0, _chunkJMOQXLEDjs.Serializer)();
10863
+ viewFunctionPayload.serialize(serializer);
10864
+ const bytes = serializer.toUint8Array();
10865
+ const { data } = await postAptosFullNode({
10887
10866
  aptosConfig,
10888
- signer: fromAccount,
10889
- transaction: coinTxn
10867
+ path: "view",
10868
+ originMethod: "view",
10869
+ contentType: "application/x.aptos.view_function+bcs" /* BCS_VIEW_FUNCTION */,
10870
+ params: { ledger_version: _optionalChain([options, 'optionalAccess', _137 => _137.ledgerVersion]) },
10871
+ body: bytes
10890
10872
  });
10891
- const coinTxnResponse = await waitForTransaction({
10873
+ return data;
10874
+ }
10875
+ async function viewJson(args) {
10876
+ const { aptosConfig, payload, options } = args;
10877
+ const { data } = await postAptosFullNode({
10892
10878
  aptosConfig,
10893
- transactionHash: pendingCoinTxn.hash
10879
+ originMethod: "viewJson",
10880
+ path: "view",
10881
+ params: { ledger_version: _optionalChain([options, 'optionalAccess', _138 => _138.ledgerVersion]) },
10882
+ body: {
10883
+ function: payload.function,
10884
+ type_arguments: _nullishCoalesce(payload.typeArguments, () => ( [])),
10885
+ arguments: _nullishCoalesce(payload.functionArguments, () => ( []))
10886
+ }
10894
10887
  });
10895
- if (!coinTxnResponse.success) {
10896
- throw new Error(`Failed to verify authentication key - ${coinTxnResponse}`);
10897
- }
10898
- return coinTxnResponse;
10888
+ return data;
10899
10889
  }
10900
10890
 
10901
10891
  // src/internal/abstraction.ts
@@ -11148,7 +11138,7 @@ var AccountAbstraction = class {
11148
11138
  };
11149
11139
 
11150
11140
  // src/api/account.ts
11151
- var Account2 = class {
11141
+ var Account3 = class {
11152
11142
  /**
11153
11143
  * Creates an instance of the Aptos client with the provided configuration.
11154
11144
  *
@@ -11197,7 +11187,7 @@ var Account2 = class {
11197
11187
  * @group Account
11198
11188
  */
11199
11189
  async getAccountInfo(args) {
11200
- return getInfo({ aptosConfig: this.config, ...args });
11190
+ return getInfo2({ aptosConfig: this.config, ...args });
11201
11191
  }
11202
11192
  /**
11203
11193
  * Queries for all modules in an account given an account address.
@@ -11234,7 +11224,7 @@ var Account2 = class {
11234
11224
  * @group Account
11235
11225
  */
11236
11226
  async getAccountModules(args) {
11237
- return getModules({ aptosConfig: this.config, ...args });
11227
+ return getModules2({ aptosConfig: this.config, ...args });
11238
11228
  }
11239
11229
  /**
11240
11230
  * Queries for a specific account module given an account address and module name.
@@ -11266,7 +11256,7 @@ var Account2 = class {
11266
11256
  * @group Account
11267
11257
  */
11268
11258
  async getAccountModule(args) {
11269
- return getModule({ aptosConfig: this.config, ...args });
11259
+ return getModule2({ aptosConfig: this.config, ...args });
11270
11260
  }
11271
11261
  /**
11272
11262
  * Queries account transactions given an account address.
@@ -12082,6 +12072,27 @@ var AptosConfig = class {
12082
12072
  }
12083
12073
  };
12084
12074
 
12075
+ // src/internal/coin.ts
12076
+ var coinTransferAbi = {
12077
+ typeParameters: [{ constraints: [] }],
12078
+ parameters: [new TypeTagAddress(), new TypeTagU64()]
12079
+ };
12080
+ async function transferCoinTransaction(args) {
12081
+ const { aptosConfig, sender, recipient, amount, coinType, options } = args;
12082
+ const coinStructType = _nullishCoalesce(coinType, () => ( APTOS_COIN));
12083
+ return generateTransaction({
12084
+ aptosConfig,
12085
+ sender,
12086
+ data: {
12087
+ function: "0x1::aptos_account::transfer_coins",
12088
+ typeArguments: [coinStructType],
12089
+ functionArguments: [recipient, amount],
12090
+ abi: coinTransferAbi
12091
+ },
12092
+ options
12093
+ });
12094
+ }
12095
+
12085
12096
  // src/api/coin.ts
12086
12097
  var Coin = class {
12087
12098
  /**
@@ -14666,11 +14677,11 @@ var General = class {
14666
14677
  * async function runExample() {
14667
14678
  * // Querying the Aptos Indexer for ledger information
14668
14679
  * const topUserTransactions = await aptos.queryIndexer({
14669
- * query: `query MyQuery {
14680
+ * query: { query: `query MyQuery {
14670
14681
  * ledger_infos {
14671
14682
  * chain_id
14672
14683
  * }
14673
- * }`
14684
+ * }`}
14674
14685
  * });
14675
14686
  *
14676
14687
  * console.log(topUserTransactions);
@@ -16174,7 +16185,7 @@ var AccountSequenceNumber = class {
16174
16185
  * @category Transactions
16175
16186
  */
16176
16187
  async initialize() {
16177
- const { sequence_number: sequenceNumber } = await getInfo({
16188
+ const { sequence_number: sequenceNumber } = await getInfo2({
16178
16189
  aptosConfig: this.aptosConfig,
16179
16190
  accountAddress: this.account.accountAddress
16180
16191
  });
@@ -16189,7 +16200,7 @@ var AccountSequenceNumber = class {
16189
16200
  * @category Transactions
16190
16201
  */
16191
16202
  async update() {
16192
- const { sequence_number: sequenceNumber } = await getInfo({
16203
+ const { sequence_number: sequenceNumber } = await getInfo2({
16193
16204
  aptosConfig: this.aptosConfig,
16194
16205
  accountAddress: this.account.accountAddress
16195
16206
  });
@@ -17098,13 +17109,26 @@ var Transaction = class {
17098
17109
  return publicPackageTransaction({ aptosConfig: this.config, ...args });
17099
17110
  }
17100
17111
  /**
17101
- * Rotate an account's authentication key. After rotation, only the new private key can be used to sign transactions for the account.
17102
- * Note: Only legacy Ed25519 scheme is supported for now.
17103
- * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}
17112
+ * Rotates the authentication key for a given account. Once an account is rotated, only the new private key
17113
+ * or keyless signing scheme can be used to sign transactions for the account.
17114
+ *
17115
+ * @param args - The arguments for rotating the authentication key.
17116
+ * @param args.fromAccount - The account from which the authentication key will be rotated.
17117
+ * @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey or toAuthKey.
17118
+ * @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount or toAuthKey.
17119
+ * @param args.toAuthKey - (Optional) The new authentication key to rotate to. Can only be used with dangerouslySkipVerification=true.
17120
+ * @param args.dangerouslySkipVerification - (Optional) If true, skips verification steps after rotation. Required when using toAuthKey.
17104
17121
  *
17105
- * @param args The arguments for rotating the auth key.
17106
- * @param args.fromAccount The account to rotate the auth key for.
17107
- * @param args.toNewPrivateKey The new private key to rotate to.
17122
+ * @remarks
17123
+ * This function supports three modes of rotation:
17124
+ * 1. Using a target Account object (toAccount)
17125
+ * 2. Using a new private key (toNewPrivateKey)
17126
+ * 3. Using a raw authentication key (toAuthKey) - requires dangerouslySkipVerification=true
17127
+ *
17128
+ * When not using dangerouslySkipVerification, the function performs additional safety checks and account setup.
17129
+ *
17130
+ * If the new key is a multi key, skipping verification is dangerous because verification will publish the public key onchain and
17131
+ * prevent users from being locked out of the account from loss of knowledge of one of the public keys.
17108
17132
  *
17109
17133
  * @returns PendingTransactionResponse
17110
17134
  *
@@ -17133,12 +17157,6 @@ var Transaction = class {
17133
17157
  async rotateAuthKey(args) {
17134
17158
  return rotateAuthKey({ aptosConfig: this.config, ...args });
17135
17159
  }
17136
- async rotateAuthKeyToMultiEd25519(args) {
17137
- return rotateAuthKeyToMultiEd25519({ aptosConfig: this.config, ...args });
17138
- }
17139
- async rotateAuthKeyWithVerificationTransaction(args) {
17140
- return rotateAuthKeyWithVerificationTransaction({ aptosConfig: this.config, ...args });
17141
- }
17142
17160
  /**
17143
17161
  * Sign a transaction that can later be submitted to the chain.
17144
17162
  * This function is essential for ensuring the authenticity of the transaction by using the provided account's signing capabilities.
@@ -18015,7 +18033,7 @@ var Aptos = class {
18015
18033
  */
18016
18034
  constructor(settings) {
18017
18035
  this.config = new AptosConfig(settings);
18018
- this.account = new Account2(this.config);
18036
+ this.account = new Account3(this.config);
18019
18037
  this.abstraction = new AccountAbstraction(this.config);
18020
18038
  this.ans = new ANS(this.config);
18021
18039
  this.coin = new Coin(this.config);
@@ -18042,7 +18060,7 @@ function applyMixin(targetClass, baseClass, baseClassProp) {
18042
18060
  Object.defineProperty(targetClass.prototype, propertyName, propertyDescriptor);
18043
18061
  });
18044
18062
  }
18045
- applyMixin(Aptos, Account2, "account");
18063
+ applyMixin(Aptos, Account3, "account");
18046
18064
  applyMixin(Aptos, AccountAbstraction, "abstraction");
18047
18065
  applyMixin(Aptos, ANS, "ans");
18048
18066
  applyMixin(Aptos, Coin, "coin");