@aptos-labs/ts-sdk 1.35.0-zeta.0 → 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 (285) hide show
  1. package/dist/common/{accountAddress-D3UA_cOZ.d.ts → accountAddress-Ce4Cv60D.d.ts} +36 -2
  2. package/dist/common/{chunk-CSUBLTFA.js → chunk-JMOQXLED.js} +10 -2
  3. package/dist/common/chunk-JMOQXLED.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +2 -2
  6. package/dist/common/index.d.ts +33 -19
  7. package/dist/common/index.js +1325 -1289
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/esm/account/AbstractKeylessAccount.mjs +14 -14
  10. package/dist/esm/account/AbstractedAccount.mjs +17 -17
  11. package/dist/esm/account/Account.mjs +16 -16
  12. package/dist/esm/account/AccountUtils.mjs +21 -21
  13. package/dist/esm/account/Ed25519Account.mjs +14 -14
  14. package/dist/esm/account/EphemeralKeyPair.mjs +5 -5
  15. package/dist/esm/account/FederatedKeylessAccount.mjs +15 -15
  16. package/dist/esm/account/KeylessAccount.mjs +15 -15
  17. package/dist/esm/account/MultiEd25519Account.mjs +14 -14
  18. package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
  19. package/dist/esm/account/MultiKeyAccount.mjs +17 -17
  20. package/dist/esm/account/SingleKeyAccount.mjs +14 -14
  21. package/dist/esm/account/index.mjs +24 -24
  22. package/dist/esm/account/utils.mjs +6 -6
  23. package/dist/esm/api/account/abstraction.mjs +36 -36
  24. package/dist/esm/api/account.mjs +40 -38
  25. package/dist/esm/api/ans.mjs +36 -36
  26. package/dist/esm/api/aptos.d.mts +0 -1
  27. package/dist/esm/api/aptos.mjs +71 -68
  28. package/dist/esm/api/coin.mjs +35 -34
  29. package/dist/esm/api/digitalAsset.mjs +36 -36
  30. package/dist/esm/api/event.mjs +10 -10
  31. package/dist/esm/api/experimental.mjs +23 -37
  32. package/dist/esm/api/faucet.mjs +9 -9
  33. package/dist/esm/api/fungibleAsset.mjs +36 -36
  34. package/dist/esm/api/general.d.mts +2 -2
  35. package/dist/esm/api/general.mjs +23 -37
  36. package/dist/esm/api/index.d.mts +0 -1
  37. package/dist/esm/api/index.mjs +71 -68
  38. package/dist/esm/api/keyless.mjs +37 -35
  39. package/dist/esm/api/object.mjs +10 -10
  40. package/dist/esm/api/staking.mjs +10 -10
  41. package/dist/esm/api/table.mjs +10 -10
  42. package/dist/esm/api/transaction.d.mts +30 -18
  43. package/dist/esm/api/transaction.mjs +43 -41
  44. package/dist/esm/api/transactionSubmission/build.mjs +34 -34
  45. package/dist/esm/api/transactionSubmission/management.mjs +38 -36
  46. package/dist/esm/api/transactionSubmission/sign.mjs +33 -33
  47. package/dist/esm/api/transactionSubmission/simulate.mjs +34 -34
  48. package/dist/esm/api/transactionSubmission/submit.mjs +34 -34
  49. package/dist/esm/api/utils.mjs +8 -8
  50. package/dist/esm/bcs/index.mjs +7 -7
  51. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  52. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  53. package/dist/esm/{chunk-XGUYC57L.mjs → chunk-2FTF6J7F.mjs} +3 -3
  54. package/dist/esm/{chunk-LHQJNJUB.mjs → chunk-2HL7JEFC.mjs} +9 -9
  55. package/dist/esm/{chunk-EFJAJFI3.mjs → chunk-2WBJAKBO.mjs} +2 -2
  56. package/dist/esm/{chunk-J7WQ42OC.mjs → chunk-3DAVHDK4.mjs} +2 -2
  57. package/dist/esm/{chunk-QN5BQMWP.mjs → chunk-56UCIGTO.mjs} +2 -2
  58. package/dist/esm/{chunk-I6QE3PKO.mjs → chunk-5ORUQZAR.mjs} +2 -2
  59. package/dist/esm/{chunk-P64LPFEC.mjs → chunk-62LC4PPC.mjs} +2 -2
  60. package/dist/esm/{chunk-ZWD4BJVD.mjs → chunk-6OFCIXWS.mjs} +3 -3
  61. package/dist/esm/chunk-6OFCIXWS.mjs.map +1 -0
  62. package/dist/esm/{chunk-LL4RQKIB.mjs → chunk-6T3V5LXK.mjs} +1 -2
  63. package/dist/esm/{chunk-LL4RQKIB.mjs.map → chunk-6T3V5LXK.mjs.map} +1 -1
  64. package/dist/esm/{chunk-UXAUOSSB.mjs → chunk-7F32C225.mjs} +6 -6
  65. package/dist/esm/{chunk-ESZLRZTK.mjs → chunk-7WW735TU.mjs} +3 -3
  66. package/dist/esm/{chunk-BQ5JTYXK.mjs → chunk-A33OBGVN.mjs} +3 -3
  67. package/dist/esm/{chunk-LFMXR5C2.mjs → chunk-A7LYGPFL.mjs} +3 -3
  68. package/dist/esm/{chunk-SDIZSFCQ.mjs → chunk-BU43ZFDJ.mjs} +2 -2
  69. package/dist/esm/{chunk-YIHVPGHN.mjs → chunk-C7EEG6SW.mjs} +4 -4
  70. package/dist/esm/{chunk-XGB3QLVI.mjs → chunk-D6RXVCE3.mjs} +3 -3
  71. package/dist/esm/{chunk-SGKF62FT.mjs → chunk-DGDZNHUJ.mjs} +5 -3
  72. package/dist/esm/{chunk-SGKF62FT.mjs.map → chunk-DGDZNHUJ.mjs.map} +1 -1
  73. package/dist/esm/{chunk-WEOK7WVL.mjs → chunk-EBFKT35C.mjs} +2 -2
  74. package/dist/esm/{chunk-JOVCSFQC.mjs → chunk-F4VI7BNX.mjs} +2 -2
  75. package/dist/esm/{chunk-VGI2LPO3.mjs → chunk-FDMI4BUL.mjs} +32 -25
  76. package/dist/esm/chunk-FDMI4BUL.mjs.map +1 -0
  77. package/dist/esm/chunk-FRLS4GRM.mjs +62 -0
  78. package/dist/esm/chunk-FRLS4GRM.mjs.map +1 -0
  79. package/dist/esm/chunk-G3MHXDYA.mjs +1 -0
  80. package/dist/esm/chunk-G3MHXDYA.mjs.map +1 -0
  81. package/dist/esm/{chunk-ZNGTK5IZ.mjs → chunk-G6R77JKO.mjs} +29 -29
  82. package/dist/esm/{chunk-6PMKDSGB.mjs → chunk-G7BB6K4B.mjs} +2 -2
  83. package/dist/esm/{chunk-ODG7T6OV.mjs → chunk-GCQK2S5Q.mjs} +2 -2
  84. package/dist/esm/{chunk-4BXAKN6A.mjs → chunk-HBXBODME.mjs} +3 -3
  85. package/dist/esm/{chunk-UKZP2GAB.mjs → chunk-HKQY5GXT.mjs} +7 -191
  86. package/dist/esm/chunk-HKQY5GXT.mjs.map +1 -0
  87. package/dist/esm/{chunk-NMYFY7WN.mjs → chunk-HL337SEM.mjs} +3 -3
  88. package/dist/esm/{chunk-K3CXNID3.mjs → chunk-HQDHSKVS.mjs} +2 -2
  89. package/dist/esm/{chunk-S56SMMAK.mjs → chunk-I5G7XFGT.mjs} +3 -3
  90. package/dist/esm/{chunk-HQ6A6TYS.mjs → chunk-IJ7XCPP3.mjs} +17 -12
  91. package/dist/esm/chunk-IJ7XCPP3.mjs.map +1 -0
  92. package/dist/esm/{chunk-46VPRC7E.mjs → chunk-ILTEOGFF.mjs} +2 -2
  93. package/dist/esm/{chunk-KLZCGNPI.mjs → chunk-IP7GATDH.mjs} +6 -6
  94. package/dist/esm/{chunk-KLZCGNPI.mjs.map → chunk-IP7GATDH.mjs.map} +1 -1
  95. package/dist/esm/{chunk-MHZVL3EA.mjs → chunk-IQVHXOD3.mjs} +8 -8
  96. package/dist/esm/{chunk-4WNIKKIV.mjs → chunk-JAZJE3OR.mjs} +3 -3
  97. package/dist/esm/{chunk-SN6KXHPA.mjs → chunk-JEVGHYEP.mjs} +2 -2
  98. package/dist/esm/{chunk-OQ6XT2GF.mjs → chunk-JFMFZ2IL.mjs} +3 -3
  99. package/dist/esm/{chunk-HQTQEHHZ.mjs → chunk-JQIRRM7G.mjs} +4 -4
  100. package/dist/esm/{chunk-MG6UFOJW.mjs → chunk-K5OCDM3W.mjs} +6 -6
  101. package/dist/esm/{chunk-MG6UFOJW.mjs.map → chunk-K5OCDM3W.mjs.map} +1 -1
  102. package/dist/esm/{chunk-MUSTBCQX.mjs → chunk-KW64NP2F.mjs} +2 -2
  103. package/dist/esm/{chunk-DUOU3SNQ.mjs → chunk-ORCQEMJL.mjs} +3 -3
  104. package/dist/esm/{chunk-LSIXUJ5T.mjs → chunk-QYNYDQE3.mjs} +4 -4
  105. package/dist/esm/{chunk-5E2IDRDF.mjs → chunk-R45SPK6Q.mjs} +2 -2
  106. package/dist/esm/{chunk-KAKSJSCR.mjs → chunk-RCXGTN36.mjs} +2 -2
  107. package/dist/esm/{chunk-3QMLVT4L.mjs → chunk-SPI2HO3E.mjs} +2 -2
  108. package/dist/esm/{chunk-KEZG4OGH.mjs → chunk-SPVJXZL5.mjs} +208 -68
  109. package/dist/esm/chunk-SPVJXZL5.mjs.map +1 -0
  110. package/dist/esm/{chunk-QW7RQDZ5.mjs → chunk-SQNS4SFV.mjs} +9 -1
  111. package/dist/esm/{chunk-QW7RQDZ5.mjs.map → chunk-SQNS4SFV.mjs.map} +1 -1
  112. package/dist/esm/{chunk-MIVDDJAH.mjs → chunk-SRXIHVZE.mjs} +2 -2
  113. package/dist/esm/{chunk-2ZOIVB2U.mjs → chunk-T4BFWV46.mjs} +2 -2
  114. package/dist/esm/{chunk-TQDWZXFD.mjs → chunk-TDLL7QX5.mjs} +7 -7
  115. package/dist/esm/{chunk-Y4FHNC5I.mjs → chunk-TJDF4CXI.mjs} +2 -2
  116. package/dist/esm/{chunk-HMHFKEHQ.mjs → chunk-TL4Z4KHK.mjs} +2 -2
  117. package/dist/esm/{chunk-Y7KAC4I4.mjs → chunk-UGFIWCJQ.mjs} +2 -2
  118. package/dist/esm/{chunk-EBEO4SA4.mjs → chunk-UGKZQUGE.mjs} +4 -4
  119. package/dist/esm/{chunk-KCV4HRSJ.mjs → chunk-UK7SPHIE.mjs} +4 -4
  120. package/dist/esm/{chunk-KEKNIJHE.mjs → chunk-WHSS6I7T.mjs} +3 -3
  121. package/dist/esm/{chunk-3SCNBHUA.mjs → chunk-WLTQHGIJ.mjs} +5 -5
  122. package/dist/esm/{chunk-I4OHHVRF.mjs → chunk-WUM247HF.mjs} +2 -2
  123. package/dist/esm/{chunk-A3TQLIEM.mjs → chunk-WXQUBQK4.mjs} +2 -2
  124. package/dist/esm/{chunk-WPV52HGD.mjs → chunk-X4N5BN3S.mjs} +3 -3
  125. package/dist/esm/{chunk-KPAICS4T.mjs → chunk-XX6C2QGI.mjs} +2 -2
  126. package/dist/esm/{chunk-XXLSA7W7.mjs → chunk-Y3M32DIB.mjs} +2 -2
  127. package/dist/esm/{chunk-HLTYSM7H.mjs → chunk-YK66QBML.mjs} +2 -2
  128. package/dist/esm/{chunk-EMKV5DFX.mjs → chunk-YT7V6AVJ.mjs} +3 -3
  129. package/dist/esm/chunk-ZRBUAZZD.mjs +36 -0
  130. package/dist/esm/chunk-ZRBUAZZD.mjs.map +1 -0
  131. package/dist/esm/cli/index.mjs +1 -1
  132. package/dist/esm/cli/localNode.mjs +1 -1
  133. package/dist/esm/client/core.mjs +4 -4
  134. package/dist/esm/client/get.mjs +4 -4
  135. package/dist/esm/client/index.mjs +5 -5
  136. package/dist/esm/client/post.mjs +5 -5
  137. package/dist/esm/core/account/index.mjs +1 -1
  138. package/dist/esm/core/account/utils/address.mjs +1 -1
  139. package/dist/esm/core/account/utils/index.mjs +1 -1
  140. package/dist/esm/core/accountAddress.mjs +1 -1
  141. package/dist/esm/core/authenticationKey.mjs +1 -1
  142. package/dist/esm/core/crypto/abstraction.mjs +3 -3
  143. package/dist/esm/core/crypto/ed25519.mjs +3 -3
  144. package/dist/esm/core/crypto/ephemeral.mjs +3 -3
  145. package/dist/esm/core/crypto/federatedKeyless.mjs +5 -5
  146. package/dist/esm/core/crypto/index.mjs +5 -5
  147. package/dist/esm/core/crypto/keyless.mjs +5 -5
  148. package/dist/esm/core/crypto/multiEd25519.mjs +5 -5
  149. package/dist/esm/core/crypto/multiKey.mjs +5 -5
  150. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  151. package/dist/esm/core/crypto/proof.mjs +3 -3
  152. package/dist/esm/core/crypto/publicKey.mjs +3 -3
  153. package/dist/esm/core/crypto/secp256k1.mjs +3 -3
  154. package/dist/esm/core/crypto/signature.mjs +3 -3
  155. package/dist/esm/core/crypto/singleKey.mjs +5 -5
  156. package/dist/esm/core/index.mjs +5 -5
  157. package/dist/esm/errors/index.mjs +2 -2
  158. package/dist/esm/index.d.mts +1 -1
  159. package/dist/esm/index.mjs +81 -74
  160. package/dist/esm/internal/abstraction.mjs +34 -34
  161. package/dist/esm/internal/account.d.mts +45 -5
  162. package/dist/esm/internal/account.mjs +44 -30
  163. package/dist/esm/internal/ans.mjs +35 -35
  164. package/dist/esm/internal/coin.mjs +34 -33
  165. package/dist/esm/internal/digitalAsset.mjs +34 -34
  166. package/dist/esm/internal/event.mjs +7 -7
  167. package/dist/esm/internal/experimental.mjs +22 -36
  168. package/dist/esm/internal/faucet.mjs +8 -8
  169. package/dist/esm/internal/fungibleAsset.mjs +34 -34
  170. package/dist/esm/internal/general.mjs +6 -6
  171. package/dist/esm/internal/keyless.mjs +36 -34
  172. package/dist/esm/internal/object.mjs +7 -7
  173. package/dist/esm/internal/staking.mjs +7 -7
  174. package/dist/esm/internal/table.mjs +7 -7
  175. package/dist/esm/internal/transaction.mjs +7 -7
  176. package/dist/esm/internal/transactionSubmission.d.mts +6 -36
  177. package/dist/esm/internal/transactionSubmission.mjs +33 -39
  178. package/dist/esm/internal/utils/index.d.mts +15 -0
  179. package/dist/esm/internal/utils/index.mjs +39 -0
  180. package/dist/esm/internal/utils/index.mjs.map +1 -0
  181. package/dist/esm/internal/utils/utils.d.mts +65 -0
  182. package/dist/esm/internal/utils/utils.mjs +38 -0
  183. package/dist/esm/internal/utils/utils.mjs.map +1 -0
  184. package/dist/esm/internal/view.mjs +22 -36
  185. package/dist/esm/transactions/authenticator/account.mjs +5 -5
  186. package/dist/esm/transactions/authenticator/index.mjs +5 -5
  187. package/dist/esm/transactions/authenticator/transaction.mjs +5 -5
  188. package/dist/esm/transactions/index.mjs +23 -37
  189. package/dist/esm/transactions/instances/index.mjs +14 -14
  190. package/dist/esm/transactions/instances/moduleId.mjs +5 -5
  191. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +9 -9
  192. package/dist/esm/transactions/instances/rawTransaction.mjs +8 -8
  193. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +3 -3
  194. package/dist/esm/transactions/instances/signedTransaction.mjs +9 -9
  195. package/dist/esm/transactions/instances/simpleTransaction.mjs +9 -9
  196. package/dist/esm/transactions/instances/transactionPayload.mjs +6 -6
  197. package/dist/esm/transactions/management/accountSequenceNumber.mjs +41 -29
  198. package/dist/esm/transactions/management/index.mjs +37 -35
  199. package/dist/esm/transactions/management/transactionWorker.mjs +37 -35
  200. package/dist/esm/transactions/scriptComposer/index.mjs +21 -35
  201. package/dist/esm/transactions/transactionBuilder/helpers.mjs +6 -6
  202. package/dist/esm/transactions/transactionBuilder/index.mjs +20 -34
  203. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +9 -40
  204. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +13 -13
  205. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +19 -34
  206. package/dist/esm/transactions/typeTag/index.mjs +5 -5
  207. package/dist/esm/transactions/typeTag/parser.mjs +5 -5
  208. package/dist/esm/types/index.d.mts +1 -1
  209. package/dist/esm/types/index.mjs +5 -1
  210. package/dist/esm/types/types.d.mts +36 -2
  211. package/dist/esm/types/types.mjs +5 -1
  212. package/dist/esm/utils/helpers.mjs +1 -1
  213. package/dist/esm/utils/index.mjs +4 -4
  214. package/dist/esm/utils/normalizeBundle.mjs +3 -3
  215. package/package.json +25 -24
  216. package/src/account/MultiKeyAccount.ts +3 -2
  217. package/src/api/general.ts +2 -2
  218. package/src/api/transaction.ts +30 -29
  219. package/src/client/post.ts +0 -1
  220. package/src/internal/account.ts +230 -71
  221. package/src/internal/transactionSubmission.ts +4 -202
  222. package/src/internal/utils/index.ts +4 -0
  223. package/src/internal/utils/utils.ts +116 -0
  224. package/src/transactions/scriptComposer/index.ts +3 -1
  225. package/src/transactions/transactionBuilder/remoteAbi.ts +1 -1
  226. package/src/transactions/transactionBuilder/transactionBuilder.ts +7 -2
  227. package/src/types/types.ts +38 -1
  228. package/dist/common/chunk-CSUBLTFA.js.map +0 -1
  229. package/dist/esm/chunk-HQ6A6TYS.mjs.map +0 -1
  230. package/dist/esm/chunk-KEZG4OGH.mjs.map +0 -1
  231. package/dist/esm/chunk-UKZP2GAB.mjs.map +0 -1
  232. package/dist/esm/chunk-VGI2LPO3.mjs.map +0 -1
  233. package/dist/esm/chunk-ZWD4BJVD.mjs.map +0 -1
  234. /package/dist/esm/{chunk-XGUYC57L.mjs.map → chunk-2FTF6J7F.mjs.map} +0 -0
  235. /package/dist/esm/{chunk-LHQJNJUB.mjs.map → chunk-2HL7JEFC.mjs.map} +0 -0
  236. /package/dist/esm/{chunk-EFJAJFI3.mjs.map → chunk-2WBJAKBO.mjs.map} +0 -0
  237. /package/dist/esm/{chunk-J7WQ42OC.mjs.map → chunk-3DAVHDK4.mjs.map} +0 -0
  238. /package/dist/esm/{chunk-QN5BQMWP.mjs.map → chunk-56UCIGTO.mjs.map} +0 -0
  239. /package/dist/esm/{chunk-I6QE3PKO.mjs.map → chunk-5ORUQZAR.mjs.map} +0 -0
  240. /package/dist/esm/{chunk-P64LPFEC.mjs.map → chunk-62LC4PPC.mjs.map} +0 -0
  241. /package/dist/esm/{chunk-UXAUOSSB.mjs.map → chunk-7F32C225.mjs.map} +0 -0
  242. /package/dist/esm/{chunk-ESZLRZTK.mjs.map → chunk-7WW735TU.mjs.map} +0 -0
  243. /package/dist/esm/{chunk-BQ5JTYXK.mjs.map → chunk-A33OBGVN.mjs.map} +0 -0
  244. /package/dist/esm/{chunk-LFMXR5C2.mjs.map → chunk-A7LYGPFL.mjs.map} +0 -0
  245. /package/dist/esm/{chunk-SDIZSFCQ.mjs.map → chunk-BU43ZFDJ.mjs.map} +0 -0
  246. /package/dist/esm/{chunk-YIHVPGHN.mjs.map → chunk-C7EEG6SW.mjs.map} +0 -0
  247. /package/dist/esm/{chunk-XGB3QLVI.mjs.map → chunk-D6RXVCE3.mjs.map} +0 -0
  248. /package/dist/esm/{chunk-WEOK7WVL.mjs.map → chunk-EBFKT35C.mjs.map} +0 -0
  249. /package/dist/esm/{chunk-JOVCSFQC.mjs.map → chunk-F4VI7BNX.mjs.map} +0 -0
  250. /package/dist/esm/{chunk-ZNGTK5IZ.mjs.map → chunk-G6R77JKO.mjs.map} +0 -0
  251. /package/dist/esm/{chunk-6PMKDSGB.mjs.map → chunk-G7BB6K4B.mjs.map} +0 -0
  252. /package/dist/esm/{chunk-ODG7T6OV.mjs.map → chunk-GCQK2S5Q.mjs.map} +0 -0
  253. /package/dist/esm/{chunk-4BXAKN6A.mjs.map → chunk-HBXBODME.mjs.map} +0 -0
  254. /package/dist/esm/{chunk-NMYFY7WN.mjs.map → chunk-HL337SEM.mjs.map} +0 -0
  255. /package/dist/esm/{chunk-K3CXNID3.mjs.map → chunk-HQDHSKVS.mjs.map} +0 -0
  256. /package/dist/esm/{chunk-S56SMMAK.mjs.map → chunk-I5G7XFGT.mjs.map} +0 -0
  257. /package/dist/esm/{chunk-46VPRC7E.mjs.map → chunk-ILTEOGFF.mjs.map} +0 -0
  258. /package/dist/esm/{chunk-MHZVL3EA.mjs.map → chunk-IQVHXOD3.mjs.map} +0 -0
  259. /package/dist/esm/{chunk-4WNIKKIV.mjs.map → chunk-JAZJE3OR.mjs.map} +0 -0
  260. /package/dist/esm/{chunk-SN6KXHPA.mjs.map → chunk-JEVGHYEP.mjs.map} +0 -0
  261. /package/dist/esm/{chunk-OQ6XT2GF.mjs.map → chunk-JFMFZ2IL.mjs.map} +0 -0
  262. /package/dist/esm/{chunk-HQTQEHHZ.mjs.map → chunk-JQIRRM7G.mjs.map} +0 -0
  263. /package/dist/esm/{chunk-MUSTBCQX.mjs.map → chunk-KW64NP2F.mjs.map} +0 -0
  264. /package/dist/esm/{chunk-DUOU3SNQ.mjs.map → chunk-ORCQEMJL.mjs.map} +0 -0
  265. /package/dist/esm/{chunk-LSIXUJ5T.mjs.map → chunk-QYNYDQE3.mjs.map} +0 -0
  266. /package/dist/esm/{chunk-5E2IDRDF.mjs.map → chunk-R45SPK6Q.mjs.map} +0 -0
  267. /package/dist/esm/{chunk-KAKSJSCR.mjs.map → chunk-RCXGTN36.mjs.map} +0 -0
  268. /package/dist/esm/{chunk-3QMLVT4L.mjs.map → chunk-SPI2HO3E.mjs.map} +0 -0
  269. /package/dist/esm/{chunk-MIVDDJAH.mjs.map → chunk-SRXIHVZE.mjs.map} +0 -0
  270. /package/dist/esm/{chunk-2ZOIVB2U.mjs.map → chunk-T4BFWV46.mjs.map} +0 -0
  271. /package/dist/esm/{chunk-TQDWZXFD.mjs.map → chunk-TDLL7QX5.mjs.map} +0 -0
  272. /package/dist/esm/{chunk-Y4FHNC5I.mjs.map → chunk-TJDF4CXI.mjs.map} +0 -0
  273. /package/dist/esm/{chunk-HMHFKEHQ.mjs.map → chunk-TL4Z4KHK.mjs.map} +0 -0
  274. /package/dist/esm/{chunk-Y7KAC4I4.mjs.map → chunk-UGFIWCJQ.mjs.map} +0 -0
  275. /package/dist/esm/{chunk-EBEO4SA4.mjs.map → chunk-UGKZQUGE.mjs.map} +0 -0
  276. /package/dist/esm/{chunk-KCV4HRSJ.mjs.map → chunk-UK7SPHIE.mjs.map} +0 -0
  277. /package/dist/esm/{chunk-KEKNIJHE.mjs.map → chunk-WHSS6I7T.mjs.map} +0 -0
  278. /package/dist/esm/{chunk-3SCNBHUA.mjs.map → chunk-WLTQHGIJ.mjs.map} +0 -0
  279. /package/dist/esm/{chunk-I4OHHVRF.mjs.map → chunk-WUM247HF.mjs.map} +0 -0
  280. /package/dist/esm/{chunk-A3TQLIEM.mjs.map → chunk-WXQUBQK4.mjs.map} +0 -0
  281. /package/dist/esm/{chunk-WPV52HGD.mjs.map → chunk-X4N5BN3S.mjs.map} +0 -0
  282. /package/dist/esm/{chunk-KPAICS4T.mjs.map → chunk-XX6C2QGI.mjs.map} +0 -0
  283. /package/dist/esm/{chunk-XXLSA7W7.mjs.map → chunk-Y3M32DIB.mjs.map} +0 -0
  284. /package/dist/esm/{chunk-HLTYSM7H.mjs.map → chunk-YK66QBML.mjs.map} +0 -0
  285. /package/dist/esm/{chunk-EMKV5DFX.mjs.map → chunk-YT7V6AVJ.mjs.map} +0 -0
package/package.json CHANGED
@@ -36,9 +36,9 @@
36
36
  "build:clean": "rm -rf dist",
37
37
  "build": "pnpm build:clean && tsup",
38
38
  "prepublishOnly": "pnpm run build",
39
- "_fmt": "prettier 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'",
39
+ "_fmt": "prettier 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' 'eslint.config.cjs'",
40
40
  "fmt": "pnpm _fmt --write",
41
- "lint": "eslint 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.ts'",
41
+ "lint": "eslint '**/*.{cts,mts,ts}'",
42
42
  "test": "pnpm jest",
43
43
  "unit-test": "pnpm jest tests/unit",
44
44
  "e2e-test": "pnpm jest tests/e2e",
@@ -64,38 +64,39 @@
64
64
  "poseidon-lite": "^0.2.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@babel/traverse": "^7.25.7",
68
- "@cucumber/cucumber": "^11.0.1",
69
- "@graphql-codegen/cli": "^5.0.2",
67
+ "@babel/traverse": "^7.26.8",
68
+ "@cucumber/cucumber": "^11.2.0",
69
+ "@eslint/eslintrc": "^3.2.0",
70
+ "@graphql-codegen/cli": "^5.0.4",
70
71
  "@graphql-codegen/import-types-preset": "^3.0.0",
71
- "@graphql-codegen/typescript": "^4.0.9",
72
+ "@graphql-codegen/typescript": "^4.1.3",
72
73
  "@graphql-codegen/typescript-graphql-request": "^6.2.0",
73
- "@graphql-codegen/typescript-operations": "^4.2.3",
74
+ "@graphql-codegen/typescript-operations": "^4.4.1",
74
75
  "@types/base-64": "^1.0.2",
75
- "@types/jest": "^29.5.13",
76
- "@types/jsonwebtoken": "^9.0.7",
77
- "@types/node": "^20.16.10",
78
- "@typescript-eslint/eslint-plugin": "^6.21.0",
79
- "@typescript-eslint/parser": "^6.21.0",
80
- "dotenv": "^16.4.5",
81
- "eslint": "^8.57.1",
76
+ "@types/jest": "^29.5.14",
77
+ "@types/jsonwebtoken": "^9.0.8",
78
+ "@types/node": "^20.17.17",
79
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
80
+ "@typescript-eslint/parser": "^7.18.0",
81
+ "dotenv": "^16.4.7",
82
+ "eslint": "^9.20.1",
82
83
  "eslint-config-airbnb-base": "^15.0.0",
83
- "eslint-config-airbnb-typescript": "^17.1.0",
84
- "eslint-config-prettier": "^9.1.0",
84
+ "eslint-config-prettier": "^10.0.1",
85
85
  "eslint-plugin-import": "^2.31.0",
86
- "graphql": "^16.9.0",
86
+ "graphql": "^16.10.0",
87
+ "globals": "^15.14.0",
87
88
  "graphql-request": "^6.1.0",
88
89
  "jest": "^29.7.0",
89
90
  "jsonwebtoken": "^9.0.2",
90
- "prettier": "^3.3.3",
91
+ "prettier": "^3.5.0",
91
92
  "tree-kill": "^1.2.2",
92
93
  "ts-jest": "^29.2.5",
93
- "ts-loader": "^9.5.1",
94
+ "ts-loader": "^9.5.2",
94
95
  "ts-node": "^10.9.2",
95
- "tsup": "^8.3.0",
96
- "typedoc": "^0.26.8",
97
- "typedoc-plugin-missing-exports": "^3.0.0",
98
- "typescript": "^5.6.2"
96
+ "tsup": "^8.3.6",
97
+ "typedoc": "^0.27.7",
98
+ "typedoc-plugin-missing-exports": "^3.1.0",
99
+ "typescript": "^5.7.3"
99
100
  },
100
- "version": "1.35.0-zeta.0"
101
+ "version": "1.35.0-zeta.2"
101
102
  }
@@ -148,13 +148,14 @@ export class MultiKeyAccount implements Account, KeylessSigner {
148
148
  * @category Account (On-Chain Model)
149
149
  */
150
150
  static fromPublicKeysAndSigners(args: {
151
+ address?: AccountAddressInput;
151
152
  publicKeys: PublicKey[];
152
153
  signaturesRequired: number;
153
154
  signers: SingleKeySignerOrLegacyEd25519Account[];
154
155
  }): MultiKeyAccount {
155
- const { publicKeys, signaturesRequired, signers } = args;
156
+ const { address, publicKeys, signaturesRequired, signers } = args;
156
157
  const multiKey = new MultiKey({ publicKeys, signaturesRequired });
157
- return new MultiKeyAccount({ multiKey, signers });
158
+ return new MultiKeyAccount({ multiKey, signers, address });
158
159
  }
159
160
 
160
161
  /**
@@ -279,11 +279,11 @@ export class General {
279
279
  * async function runExample() {
280
280
  * // Querying the Aptos Indexer for ledger information
281
281
  * const topUserTransactions = await aptos.queryIndexer({
282
- * query: `query MyQuery {
282
+ * query: { query: `query MyQuery {
283
283
  * ledger_infos {
284
284
  * chain_id
285
285
  * }
286
- * }`
286
+ * }`}
287
287
  * });
288
288
  *
289
289
  * console.log(topUserTransactions);
@@ -24,9 +24,6 @@ import {
24
24
  FeePayerOrFeePayerAuthenticatorOrNeither,
25
25
  getSigningMessage,
26
26
  publicPackageTransaction,
27
- rotateAuthKey,
28
- rotateAuthKeyToMultiEd25519,
29
- rotateAuthKeyWithVerificationTransaction,
30
27
  signAndSubmitAsFeePayer,
31
28
  signAndSubmitTransaction,
32
29
  signAsFeePayer,
@@ -38,14 +35,14 @@ import {
38
35
  InputGenerateTransactionOptions,
39
36
  InputGenerateTransactionPayloadData,
40
37
  } from "../transactions";
41
- import { AccountAddressInput, Ed25519PrivateKey } from "../core";
38
+ import { AccountAddressInput, AuthenticationKey, Ed25519PrivateKey } from "../core";
42
39
  import { Account } from "../account";
43
40
  import { Build } from "./transactionSubmission/build";
44
41
  import { Simulate } from "./transactionSubmission/simulate";
45
42
  import { Submit } from "./transactionSubmission/submit";
46
43
  import { TransactionManagement } from "./transactionSubmission/management";
47
44
  import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
48
- import { MultiEd25519Account } from "../account/MultiEd25519Account";
45
+ import { rotateAuthKey } from "../internal/account";
49
46
 
50
47
  /**
51
48
  * Represents a transaction in the Aptos blockchain,
@@ -477,13 +474,26 @@ export class Transaction {
477
474
  }
478
475
 
479
476
  /**
480
- * Rotate an account's authentication key. After rotation, only the new private key can be used to sign transactions for the account.
481
- * Note: Only legacy Ed25519 scheme is supported for now.
482
- * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}
477
+ * Rotates the authentication key for a given account. Once an account is rotated, only the new private key
478
+ * or keyless signing scheme can be used to sign transactions for the account.
483
479
  *
484
- * @param args The arguments for rotating the auth key.
485
- * @param args.fromAccount The account to rotate the auth key for.
486
- * @param args.toNewPrivateKey The new private key to rotate to.
480
+ * @param args - The arguments for rotating the authentication key.
481
+ * @param args.fromAccount - The account from which the authentication key will be rotated.
482
+ * @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey or toAuthKey.
483
+ * @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount or toAuthKey.
484
+ * @param args.toAuthKey - (Optional) The new authentication key to rotate to. Can only be used with dangerouslySkipVerification=true.
485
+ * @param args.dangerouslySkipVerification - (Optional) If true, skips verification steps after rotation. Required when using toAuthKey.
486
+ *
487
+ * @remarks
488
+ * This function supports three modes of rotation:
489
+ * 1. Using a target Account object (toAccount)
490
+ * 2. Using a new private key (toNewPrivateKey)
491
+ * 3. Using a raw authentication key (toAuthKey) - requires dangerouslySkipVerification=true
492
+ *
493
+ * When not using dangerouslySkipVerification, the function performs additional safety checks and account setup.
494
+ *
495
+ * If the new key is a multi key, skipping verification is dangerous because verification will publish the public key onchain and
496
+ * prevent users from being locked out of the account from loss of knowledge of one of the public keys.
487
497
  *
488
498
  * @returns PendingTransactionResponse
489
499
  *
@@ -509,27 +519,18 @@ export class Transaction {
509
519
  * ```
510
520
  * @group Transaction
511
521
  */
512
- async rotateAuthKey(args: {
513
- fromAccount: Account;
514
- toNewPrivateKey: Ed25519PrivateKey;
515
- }): Promise<PendingTransactionResponse> {
522
+ async rotateAuthKey(
523
+ args: {
524
+ fromAccount: Account;
525
+ } & (
526
+ | { toAccount: Account; dangerouslySkipVerification?: never }
527
+ | { toNewPrivateKey: Ed25519PrivateKey; dangerouslySkipVerification?: never }
528
+ | { toAuthKey: AuthenticationKey; dangerouslySkipVerification: true }
529
+ ),
530
+ ): Promise<PendingTransactionResponse> {
516
531
  return rotateAuthKey({ aptosConfig: this.config, ...args });
517
532
  }
518
533
 
519
- async rotateAuthKeyToMultiEd25519(args: {
520
- fromAccount: Account;
521
- multiEd25519Account: MultiEd25519Account;
522
- }): Promise<PendingTransactionResponse> {
523
- return rotateAuthKeyToMultiEd25519({ aptosConfig: this.config, ...args });
524
- }
525
-
526
- async rotateAuthKeyWithVerificationTransaction(args: {
527
- fromAccount: Account;
528
- toAccount: Account;
529
- }): Promise<CommittedTransactionResponse> {
530
- return rotateAuthKeyWithVerificationTransaction({ aptosConfig: this.config, ...args });
531
- }
532
-
533
534
  /**
534
535
  * Sign a transaction that can later be submitted to the chain.
535
536
  * This function is essential for ensuring the authenticity of the transaction by using the provided account's signing capabilities.
@@ -230,7 +230,6 @@ export async function postAptosIndexer<Req extends {}, Res extends {}>(
230
230
  options: PostAptosRequestOptions,
231
231
  ): Promise<AptosResponse<Req, Res>> {
232
232
  const { aptosConfig } = options;
233
- console.log("request", JSON.stringify(options.body, null, 2));
234
233
 
235
234
  return post<Req, Res>({
236
235
  ...options,
@@ -21,7 +21,8 @@ import {
21
21
  GetObjectDataQueryResponse,
22
22
  isEd25519Signature,
23
23
  isMultiEd25519Signature,
24
- isSingleSenderSignature,
24
+ isSingleSenderMultiKeySignature,
25
+ isSingleSenderSingleKeySignature,
25
26
  isUserTransactionResponse,
26
27
  LedgerVersionArg,
27
28
  MoveModuleBytecode,
@@ -29,12 +30,13 @@ import {
29
30
  MoveStructId,
30
31
  OrderByArg,
31
32
  PaginationArgs,
33
+ PendingTransactionResponse,
32
34
  TokenStandardArg,
33
35
  TransactionResponse,
34
36
  WhereArg,
35
37
  } from "../types";
36
38
  import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
37
- import { Account } from "../account";
39
+ import { Account, Ed25519Account, MultiEd25519Account } from "../account";
38
40
  import {
39
41
  AbstractMultiKey,
40
42
  AccountPublicKey,
@@ -49,6 +51,7 @@ import {
49
51
  Secp256k1PublicKey,
50
52
  } from "../core/crypto";
51
53
  import { queryIndexer } from "./general";
54
+ import { getModules as getModulesUtil, getModule as getModuleUtil, getInfo as getInfoUtil } from "./utils";
52
55
  import {
53
56
  GetAccountCoinsCountQuery,
54
57
  GetAccountCoinsDataQuery,
@@ -77,7 +80,6 @@ import {
77
80
  GetAccountAddressesForAuthKey,
78
81
  GetSignatures,
79
82
  } from "../types/generated/queries";
80
- import { memoizeAsync } from "../utils/memoize";
81
83
  import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey, createObjectAddress, Hex } from "../core";
82
84
  import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
83
85
  import { getTableItem } from "./table";
@@ -85,6 +87,10 @@ import { APTOS_COIN } from "../utils";
85
87
  import { AptosApiError } from "../errors";
86
88
  import { Deserializer } from "../bcs";
87
89
  import { getTransactionByVersion } from "./transaction";
90
+ import { signAndSubmitTransaction, generateTransaction } from "./transactionSubmission";
91
+ import { EntryFunctionABI, RotationProofChallenge, TypeTagU8, TypeTagVector } from "../transactions";
92
+ import { U8, MoveVector } from "../bcs";
93
+ import { waitForTransaction } from "./transaction";
88
94
  import { deriveKeylessAccount, DeriveKeylessAccountParams } from "./keyless";
89
95
 
90
96
  /**
@@ -99,13 +105,7 @@ export async function getInfo(args: {
99
105
  aptosConfig: AptosConfig;
100
106
  accountAddress: AccountAddressInput;
101
107
  }): Promise<AccountData> {
102
- const { aptosConfig, accountAddress } = args;
103
- const { data } = await getAptosFullNode<{}, AccountData>({
104
- aptosConfig,
105
- originMethod: "getInfo",
106
- path: `accounts/${AccountAddress.from(accountAddress).toString()}`,
107
- });
108
- return data;
108
+ return getInfoUtil(args);
109
109
  }
110
110
 
111
111
  /**
@@ -125,17 +125,7 @@ export async function getModules(args: {
125
125
  accountAddress: AccountAddressInput;
126
126
  options?: PaginationArgs & LedgerVersionArg;
127
127
  }): Promise<MoveModuleBytecode[]> {
128
- const { aptosConfig, accountAddress, options } = args;
129
- return paginateWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
130
- aptosConfig,
131
- originMethod: "getModules",
132
- path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
133
- params: {
134
- ledger_version: options?.ledgerVersion,
135
- offset: options?.offset,
136
- limit: options?.limit ?? 1000,
137
- },
138
- });
128
+ return getModulesUtil(args);
139
129
  }
140
130
 
141
131
  /**
@@ -157,45 +147,7 @@ export async function getModule(args: {
157
147
  moduleName: string;
158
148
  options?: LedgerVersionArg;
159
149
  }): Promise<MoveModuleBytecode> {
160
- // We don't memoize the account module by ledger version, as it's not a common use case, this would be handled
161
- // by the developer directly
162
- if (args.options?.ledgerVersion !== undefined) {
163
- return getModuleInner(args);
164
- }
165
-
166
- return memoizeAsync(
167
- async () => getModuleInner(args),
168
- `module-${args.accountAddress}-${args.moduleName}`,
169
- 1000 * 60 * 5, // 5 minutes
170
- )();
171
- }
172
-
173
- /**
174
- * Retrieves the bytecode of a specified module from a given account address.
175
- *
176
- * @param args - The parameters for retrieving the module bytecode.
177
- * @param args.aptosConfig - The configuration for connecting to the Aptos network.
178
- * @param args.accountAddress - The address of the account from which to retrieve the module.
179
- * @param args.moduleName - The name of the module to retrieve.
180
- * @param args.options - Optional parameters for specifying the ledger version.
181
- * @param args.options.ledgerVersion - The specific ledger version to query.
182
- * @group Implementation
183
- */
184
- async function getModuleInner(args: {
185
- aptosConfig: AptosConfig;
186
- accountAddress: AccountAddressInput;
187
- moduleName: string;
188
- options?: LedgerVersionArg;
189
- }): Promise<MoveModuleBytecode> {
190
- const { aptosConfig, accountAddress, moduleName, options } = args;
191
-
192
- const { data } = await getAptosFullNode<{}, MoveModuleBytecode>({
193
- aptosConfig,
194
- originMethod: "getModule",
195
- path: `accounts/${AccountAddress.from(accountAddress).toString()}/module/${moduleName}`,
196
- params: { ledger_version: options?.ledgerVersion },
197
- });
198
- return data;
150
+ return getModuleUtil(args);
199
151
  }
200
152
 
201
153
  /**
@@ -845,6 +797,197 @@ export async function isAccountExist(args: { aptosConfig: AptosConfig; authKey:
845
797
  }
846
798
  }
847
799
 
800
+ const rotateAuthKeyAbi: EntryFunctionABI = {
801
+ typeParameters: [],
802
+ parameters: [
803
+ new TypeTagU8(),
804
+ TypeTagVector.u8(),
805
+ new TypeTagU8(),
806
+ TypeTagVector.u8(),
807
+ TypeTagVector.u8(),
808
+ TypeTagVector.u8(),
809
+ ],
810
+ };
811
+
812
+ /**
813
+ * Rotates the authentication key for a given account.
814
+ *
815
+ * @param args - The arguments for rotating the authentication key.
816
+ * @param args.aptosConfig - The configuration settings for the Aptos network.
817
+ * @param args.fromAccount - The account from which the authentication key will be rotated.
818
+ * @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey or toAuthKey.
819
+ * @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount or toAuthKey.
820
+ * @param args.toAuthKey - (Optional) The new authentication key to rotate to. Can only be used with dangerouslySkipVerification=true.
821
+ * @param args.dangerouslySkipVerification - (Optional) If true, skips verification steps after rotation. Required when using toAuthKey.
822
+ *
823
+ * @remarks
824
+ * This function supports three modes of rotation:
825
+ * 1. Using a target Account object (toAccount)
826
+ * 2. Using a new private key (toNewPrivateKey)
827
+ * 3. Using a raw authentication key (toAuthKey) - requires dangerouslySkipVerification=true
828
+ *
829
+ * When not using dangerouslySkipVerification, the function performs additional safety checks and account setup.
830
+ *
831
+ * If the new key is a multi key, skipping verification is dangerous because verification will publish the public key onchain and
832
+ * prevent users from being locked out of the account from loss of knowledge of one of the public keys.
833
+ *
834
+ * @returns A promise that resolves to the pending transaction response.
835
+ * @throws Error if the rotation fails or verification fails.
836
+ *
837
+ * @group Implementation
838
+ */
839
+ export async function rotateAuthKey(
840
+ args: {
841
+ aptosConfig: AptosConfig;
842
+ fromAccount: Account;
843
+ } & (
844
+ | { toAccount: Account; dangerouslySkipVerification?: never }
845
+ | { toNewPrivateKey: Ed25519PrivateKey; dangerouslySkipVerification?: never }
846
+ | { toAuthKey: AuthenticationKey; dangerouslySkipVerification: true }
847
+ ),
848
+ ): Promise<PendingTransactionResponse> {
849
+ const { aptosConfig, fromAccount, dangerouslySkipVerification } = args;
850
+ if ("toNewPrivateKey" in args) {
851
+ return rotateAuthKeyWithChallenge({
852
+ aptosConfig,
853
+ fromAccount,
854
+ toNewPrivateKey: args.toNewPrivateKey,
855
+ });
856
+ }
857
+ let authKey: AuthenticationKey;
858
+ if ("toAccount" in args) {
859
+ if (args.toAccount instanceof Ed25519Account) {
860
+ return rotateAuthKeyWithChallenge({ aptosConfig, fromAccount, toNewPrivateKey: args.toAccount.privateKey });
861
+ }
862
+ if (args.toAccount instanceof MultiEd25519Account) {
863
+ return rotateAuthKeyWithChallenge({ aptosConfig, fromAccount, toAccount: args.toAccount });
864
+ }
865
+ authKey = args.toAccount.publicKey.authKey();
866
+ } else if ("toAuthKey" in args) {
867
+ authKey = args.toAuthKey;
868
+ } else {
869
+ throw new Error("Invalid arguments");
870
+ }
871
+
872
+ const pendingTxn = await rotateAuthKeyUnverified({
873
+ aptosConfig,
874
+ fromAccount,
875
+ toAuthKey: authKey,
876
+ });
877
+
878
+ if (dangerouslySkipVerification === true) {
879
+ return pendingTxn;
880
+ }
881
+
882
+ const rotateAuthKeyTxnResponse = await waitForTransaction({
883
+ aptosConfig,
884
+ transactionHash: pendingTxn.hash,
885
+ });
886
+ if (!rotateAuthKeyTxnResponse.success) {
887
+ throw new Error(`Failed to rotate authentication key - ${rotateAuthKeyTxnResponse}`);
888
+ }
889
+
890
+ // Verify the rotation by setting the originating address to the new account.
891
+ // This verifies the rotation even if the transaction payload fails to execute successfully.
892
+ const verificationTxn = await generateTransaction({
893
+ aptosConfig,
894
+ sender: fromAccount.accountAddress,
895
+ data: {
896
+ function: "0x1::account::set_originating_address",
897
+ functionArguments: [],
898
+ },
899
+ });
900
+
901
+ return signAndSubmitTransaction({
902
+ aptosConfig,
903
+ signer: args.toAccount, // Use the new account to sign
904
+ transaction: verificationTxn,
905
+ });
906
+ }
907
+
908
+ async function rotateAuthKeyWithChallenge(
909
+ args: {
910
+ aptosConfig: AptosConfig;
911
+ fromAccount: Account;
912
+ } & ({ toNewPrivateKey: Ed25519PrivateKey } | { toAccount: MultiEd25519Account }),
913
+ ): Promise<PendingTransactionResponse> {
914
+ const { aptosConfig, fromAccount } = args;
915
+ const accountInfo = await getInfo({
916
+ aptosConfig,
917
+ accountAddress: fromAccount.accountAddress,
918
+ });
919
+
920
+ let newAccount: Account;
921
+ if ("toNewPrivateKey" in args) {
922
+ newAccount = Account.fromPrivateKey({ privateKey: args.toNewPrivateKey, legacy: true });
923
+ } else {
924
+ newAccount = args.toAccount;
925
+ }
926
+
927
+ const challenge = new RotationProofChallenge({
928
+ sequenceNumber: BigInt(accountInfo.sequence_number),
929
+ originator: fromAccount.accountAddress,
930
+ currentAuthKey: AccountAddress.from(accountInfo.authentication_key),
931
+ newPublicKey: newAccount.publicKey,
932
+ });
933
+
934
+ // Sign the challenge
935
+ const challengeHex = challenge.bcsToBytes();
936
+ const proofSignedByCurrentKey = fromAccount.sign(challengeHex);
937
+ const proofSignedByNewKey = newAccount.sign(challengeHex);
938
+
939
+ // Generate transaction
940
+ const rawTxn = await generateTransaction({
941
+ aptosConfig,
942
+ sender: fromAccount.accountAddress,
943
+ data: {
944
+ function: "0x1::account::rotate_authentication_key",
945
+ functionArguments: [
946
+ new U8(fromAccount.signingScheme), // from scheme
947
+ MoveVector.U8(fromAccount.publicKey.toUint8Array()),
948
+ new U8(newAccount.signingScheme), // to scheme
949
+ MoveVector.U8(newAccount.publicKey.toUint8Array()),
950
+ MoveVector.U8(proofSignedByCurrentKey.toUint8Array()),
951
+ MoveVector.U8(proofSignedByNewKey.toUint8Array()),
952
+ ],
953
+ abi: rotateAuthKeyAbi,
954
+ },
955
+ });
956
+ return signAndSubmitTransaction({
957
+ aptosConfig,
958
+ signer: fromAccount,
959
+ transaction: rawTxn,
960
+ });
961
+ }
962
+
963
+ const rotateAuthKeyUnverifiedAbi: EntryFunctionABI = {
964
+ typeParameters: [],
965
+ parameters: [TypeTagVector.u8()],
966
+ };
967
+
968
+ async function rotateAuthKeyUnverified(args: {
969
+ aptosConfig: AptosConfig;
970
+ fromAccount: Account;
971
+ toAuthKey: AuthenticationKey;
972
+ }): Promise<PendingTransactionResponse> {
973
+ const { aptosConfig, fromAccount, toAuthKey } = args;
974
+ const authKey = toAuthKey;
975
+ const rawTxn = await generateTransaction({
976
+ aptosConfig,
977
+ sender: fromAccount.accountAddress,
978
+ data: {
979
+ function: "0x1::account::rotate_authentication_key_call",
980
+ functionArguments: [MoveVector.U8(authKey.toUint8Array())],
981
+ abi: rotateAuthKeyUnverifiedAbi,
982
+ },
983
+ });
984
+ return signAndSubmitTransaction({
985
+ aptosConfig,
986
+ signer: fromAccount,
987
+ transaction: rawTxn,
988
+ });
989
+ }
990
+
848
991
  async function getMultiKeysForAuthenticationKeys(args: {
849
992
  aptosConfig: AptosConfig;
850
993
  authKeys: AuthenticationKey[];
@@ -980,6 +1123,7 @@ async function getLastestTransactionVersionForAddress(args: {
980
1123
  variables: {
981
1124
  where_condition: whereCondition,
982
1125
  limit: 1,
1126
+ order_by: { transaction_version: "desc" },
983
1127
  },
984
1128
  };
985
1129
 
@@ -990,7 +1134,7 @@ async function getLastestTransactionVersionForAddress(args: {
990
1134
  });
991
1135
 
992
1136
  if (data.length !== 1) {
993
- throw new Error(`Expected 1 account address for address ${address}, got ${data.length}`);
1137
+ throw new Error(`No signatures found for address ${address}`);
994
1138
  }
995
1139
  return Number(data[0].transaction_version);
996
1140
  }
@@ -1102,6 +1246,7 @@ export async function getPublicKeyFromAccountAddress(args: {
1102
1246
  aptosConfig,
1103
1247
  accountAddress,
1104
1248
  });
1249
+ console.log("lastTransactionVersion", lastTransactionVersion);
1105
1250
 
1106
1251
  const transaction = await getTransactionByVersion({ aptosConfig, ledgerVersion: lastTransactionVersion });
1107
1252
  if (!isUserTransactionResponse(transaction)) {
@@ -1121,17 +1266,17 @@ export async function getPublicKeyFromAccountAddress(args: {
1121
1266
  publicKeys: signature.public_keys.map((pk) => new Ed25519PublicKey(pk)),
1122
1267
  threshold: signature.threshold,
1123
1268
  });
1124
- } else if (isSingleSenderSignature(signature)) {
1125
- if (signature.public_key.type === "keyless") {
1126
- const deserializer = Deserializer.fromHex(signature.public_key.value);
1127
- publicKey = new AnyPublicKey(KeylessPublicKey.deserialize(deserializer));
1128
- } else if (signature.public_key.type === "ed25519") {
1129
- publicKey = new AnyPublicKey(new Ed25519PublicKey(signature.public_key.value));
1130
- } else if (signature.public_key.type === "secp256k1_ecdsa") {
1131
- publicKey = new AnyPublicKey(new Secp256k1PublicKey(signature.public_key.value));
1132
- } else {
1133
- throw new Error("Unknown public key type");
1269
+ } else if (isSingleSenderSingleKeySignature(signature)) {
1270
+ publicKey = parsePublicKey(signature.public_key);
1271
+ } else if (isSingleSenderMultiKeySignature(signature)) {
1272
+ const publicKeys: Array<PublicKey> = [];
1273
+ for (const pk of signature.public_keys) {
1274
+ publicKeys.push(parsePublicKey(pk));
1134
1275
  }
1276
+ publicKey = new MultiKey({
1277
+ publicKeys,
1278
+ signaturesRequired: signature.signatures_required,
1279
+ });
1135
1280
  } else {
1136
1281
  throw new Error("Unknown signature type");
1137
1282
  }
@@ -1191,3 +1336,17 @@ export async function getMultiKeyFromAuthenticationKey(args: {
1191
1336
  // }
1192
1337
 
1193
1338
  type AccountDerivationParams = { privateKey: PrivateKey } | DeriveKeylessAccountParams;
1339
+
1340
+ function parsePublicKey(data: { value: string; type: string }): AnyPublicKey {
1341
+ if (data.type === "keyless") {
1342
+ const deserializer = Deserializer.fromHex(data.value);
1343
+ return new AnyPublicKey(KeylessPublicKey.deserialize(deserializer));
1344
+ }
1345
+ if (data.type === "ed25519") {
1346
+ return new AnyPublicKey(new Ed25519PublicKey(data.value));
1347
+ }
1348
+ if (data.type === "secp256k1_ecdsa") {
1349
+ return new AnyPublicKey(new Secp256k1PublicKey(data.value));
1350
+ }
1351
+ throw new Error("Unknown public key type");
1352
+ }