@aptos-labs/ts-sdk 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/dist/browser/index.d.ts +1226 -975
  2. package/dist/browser/index.global.js +32 -30
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/common/index.d.ts +1226 -975
  5. package/dist/common/index.js +27 -25
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/api/account.d.mts +12 -6
  8. package/dist/esm/api/account.mjs +1 -1
  9. package/dist/esm/api/ans.d.mts +11 -12
  10. package/dist/esm/api/ans.mjs +1 -1
  11. package/dist/esm/api/aptos.d.mts +13 -14
  12. package/dist/esm/api/aptos.mjs +1 -1
  13. package/dist/esm/api/aptosConfig.mjs +1 -1
  14. package/dist/esm/api/coin.d.mts +13 -13
  15. package/dist/esm/api/coin.mjs +1 -1
  16. package/dist/esm/api/digitalAsset.d.mts +20 -10
  17. package/dist/esm/api/digitalAsset.mjs +1 -1
  18. package/dist/esm/api/event.d.mts +14 -1
  19. package/dist/esm/api/event.mjs +1 -1
  20. package/dist/esm/api/faucet.mjs +1 -1
  21. package/dist/esm/api/fungibleAsset.d.mts +9 -10
  22. package/dist/esm/api/fungibleAsset.mjs +1 -1
  23. package/dist/esm/api/general.mjs +1 -1
  24. package/dist/esm/api/index.d.mts +13 -14
  25. package/dist/esm/api/index.mjs +1 -1
  26. package/dist/esm/api/staking.mjs +1 -1
  27. package/dist/esm/api/transaction.d.mts +5 -6
  28. package/dist/esm/api/transaction.mjs +1 -1
  29. package/dist/esm/api/transactionSubmission/build.d.mts +8 -8
  30. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  31. package/dist/esm/api/transactionSubmission/management.d.mts +11 -12
  32. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  33. package/dist/esm/api/transactionSubmission/sign.d.mts +11 -12
  34. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  35. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  36. package/dist/esm/api/transactionSubmission/simulate.d.mts +11 -11
  37. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  38. package/dist/esm/api/transactionSubmission/submit.d.mts +6 -6
  39. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  40. package/dist/esm/api/utils.mjs +1 -1
  41. package/dist/esm/bcs/index.mjs +1 -1
  42. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  43. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  44. package/dist/esm/chunk-2E2JOGE5.mjs +2 -0
  45. package/dist/esm/chunk-2E2JOGE5.mjs.map +1 -0
  46. package/dist/esm/chunk-3EUOBVCT.mjs +2 -0
  47. package/dist/esm/{chunk-A2QH4A6D.mjs.map → chunk-3EUOBVCT.mjs.map} +1 -1
  48. package/dist/esm/{chunk-RNO5ZG3C.mjs → chunk-52RTAMN7.mjs} +2 -2
  49. package/dist/esm/chunk-7BDYKJXX.mjs +2 -0
  50. package/dist/esm/chunk-7BDYKJXX.mjs.map +1 -0
  51. package/dist/esm/{chunk-WQI2RH2S.mjs → chunk-7U36LMP4.mjs} +2 -2
  52. package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-ARIC32W7.mjs} +2 -2
  53. package/dist/esm/{chunk-RIL4SHXC.mjs → chunk-B7M3OWHV.mjs} +2 -2
  54. package/dist/esm/{chunk-C7ZX475J.mjs → chunk-BBUAAJRA.mjs} +2 -2
  55. package/dist/esm/chunk-C3HM7HQP.mjs +2 -0
  56. package/dist/esm/chunk-C3HM7HQP.mjs.map +1 -0
  57. package/dist/esm/{chunk-DRF6AMEZ.mjs → chunk-CHA5DSSD.mjs} +2 -2
  58. package/dist/esm/chunk-CVEJHRAU.mjs +2 -0
  59. package/dist/esm/chunk-CVEJHRAU.mjs.map +1 -0
  60. package/dist/esm/chunk-DE5OOOVY.mjs +2 -0
  61. package/dist/esm/{chunk-3UYBNX3P.mjs.map → chunk-DE5OOOVY.mjs.map} +1 -1
  62. package/dist/esm/{chunk-IKCBGNRD.mjs → chunk-DGOT2VR5.mjs} +2 -2
  63. package/dist/esm/{chunk-GVHOHNHT.mjs → chunk-EF2F7NWO.mjs} +2 -2
  64. package/dist/esm/{chunk-J6RCCKOA.mjs → chunk-EQZ757ES.mjs} +2 -2
  65. package/dist/esm/{chunk-CX5ULWJQ.mjs → chunk-F67Y7YH6.mjs} +2 -2
  66. package/dist/esm/{chunk-JLL7BCD4.mjs → chunk-FVMVV4V3.mjs} +2 -2
  67. package/dist/esm/chunk-FWDKABRW.mjs +2 -0
  68. package/dist/esm/chunk-FWDKABRW.mjs.map +1 -0
  69. package/dist/esm/chunk-G62HQC77.mjs +2 -0
  70. package/dist/esm/chunk-G62HQC77.mjs.map +1 -0
  71. package/dist/esm/{chunk-ESX5X52V.mjs → chunk-GQOOXOTN.mjs} +2 -2
  72. package/dist/esm/chunk-GRJJBGHT.mjs +2 -0
  73. package/dist/esm/chunk-GRJJBGHT.mjs.map +1 -0
  74. package/dist/esm/chunk-HEPV52CH.mjs +2 -0
  75. package/dist/esm/chunk-HEPV52CH.mjs.map +1 -0
  76. package/dist/esm/{chunk-XQIWF5HY.mjs → chunk-I3TCHVQQ.mjs} +2 -2
  77. package/dist/esm/{chunk-3NOQE6U3.mjs → chunk-ILJWEPDW.mjs} +2 -2
  78. package/dist/esm/chunk-INORE66K.mjs +2 -0
  79. package/dist/esm/chunk-INORE66K.mjs.map +1 -0
  80. package/dist/esm/{chunk-5L6SRCJP.mjs → chunk-J6MWD4XN.mjs} +2 -2
  81. package/dist/esm/{chunk-YGMT4GQ5.mjs → chunk-JEHR6GKW.mjs} +2 -2
  82. package/dist/esm/chunk-JEHR6GKW.mjs.map +1 -0
  83. package/dist/esm/chunk-KUX6GQ2E.mjs +1 -0
  84. package/dist/esm/{chunk-6UNBJAV6.mjs → chunk-KWJTVJ7C.mjs} +2 -2
  85. package/dist/esm/chunk-KWJTVJ7C.mjs.map +1 -0
  86. package/dist/esm/{chunk-WK36MJRI.mjs → chunk-LLL2LFYH.mjs} +2 -2
  87. package/dist/esm/chunk-LMXP3JUU.mjs +2 -0
  88. package/dist/esm/chunk-LMXP3JUU.mjs.map +1 -0
  89. package/dist/esm/{chunk-5WXR2O3T.mjs → chunk-N65SOKJQ.mjs} +2 -2
  90. package/dist/esm/{chunk-XOBXX273.mjs → chunk-NL3XVNS5.mjs} +2 -2
  91. package/dist/esm/{chunk-Q7JKS6WV.mjs → chunk-NURFZOR4.mjs} +2 -2
  92. package/dist/esm/{chunk-MKERJNYN.mjs → chunk-OG56TYZE.mjs} +2 -2
  93. package/dist/esm/chunk-Q6WOHF4A.mjs +2 -0
  94. package/dist/esm/chunk-Q6WOHF4A.mjs.map +1 -0
  95. package/dist/esm/chunk-QA4XWNIH.mjs +2 -0
  96. package/dist/esm/chunk-QA4XWNIH.mjs.map +1 -0
  97. package/dist/esm/chunk-QE4ASJ5K.mjs +1 -0
  98. package/dist/esm/chunk-QR72RXBS.mjs +2 -0
  99. package/dist/esm/chunk-QR72RXBS.mjs.map +1 -0
  100. package/dist/esm/{chunk-TVURQPLA.mjs → chunk-R4VJDSIP.mjs} +2 -2
  101. package/dist/esm/{chunk-O57QZZF2.mjs → chunk-S2F6CSH4.mjs} +2 -2
  102. package/dist/esm/chunk-S2F6CSH4.mjs.map +1 -0
  103. package/dist/esm/{chunk-BQSE5HHW.mjs → chunk-S4SEFF4K.mjs} +3 -1
  104. package/dist/esm/chunk-S4SEFF4K.mjs.map +1 -0
  105. package/dist/esm/{chunk-OVSV4Y32.mjs → chunk-SXIFL5DQ.mjs} +2 -2
  106. package/dist/esm/{chunk-OVSV4Y32.mjs.map → chunk-SXIFL5DQ.mjs.map} +1 -1
  107. package/dist/esm/{chunk-Z6XNTGNK.mjs → chunk-TN5BUH4F.mjs} +2 -2
  108. package/dist/esm/chunk-TNVR7SNR.mjs +2 -0
  109. package/dist/esm/chunk-TNVR7SNR.mjs.map +1 -0
  110. package/dist/esm/chunk-TX7UK75Q.mjs +2 -0
  111. package/dist/esm/chunk-TX7UK75Q.mjs.map +1 -0
  112. package/dist/esm/{chunk-YE3DZD6T.mjs → chunk-UIUSDBCL.mjs} +2 -2
  113. package/dist/esm/{chunk-7JTOGYO7.mjs → chunk-UMLDKLDL.mjs} +2 -2
  114. package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
  115. package/dist/esm/{chunk-6Y3VBRMN.mjs → chunk-VEVBHH3M.mjs} +2 -2
  116. package/dist/esm/{chunk-T5IFXLOP.mjs → chunk-VMXBMAYK.mjs} +2 -2
  117. package/dist/esm/chunk-WKUXBIYB.mjs +2 -0
  118. package/dist/esm/chunk-WKUXBIYB.mjs.map +1 -0
  119. package/dist/esm/chunk-WME5D6YR.mjs +2 -0
  120. package/dist/esm/chunk-WME5D6YR.mjs.map +1 -0
  121. package/dist/esm/chunk-WTHNSNAX.mjs +2 -0
  122. package/dist/esm/chunk-WTHNSNAX.mjs.map +1 -0
  123. package/dist/esm/{chunk-WC2WSKYZ.mjs → chunk-X5C3LYI7.mjs} +2 -2
  124. package/dist/esm/chunk-XKD7W5NO.mjs +2 -0
  125. package/dist/esm/{chunk-UJAX75ON.mjs.map → chunk-XKD7W5NO.mjs.map} +1 -1
  126. package/dist/esm/{chunk-OWZLBIDD.mjs → chunk-XTPFQ4MH.mjs} +2 -2
  127. package/dist/esm/{chunk-D2GNCG27.mjs → chunk-Y5AJLNUD.mjs} +2 -2
  128. package/dist/esm/chunk-YDAA4RG4.mjs +2 -0
  129. package/dist/esm/chunk-YDAA4RG4.mjs.map +1 -0
  130. package/dist/esm/{chunk-ZFPA45OK.mjs → chunk-YR2R3LW4.mjs} +2 -2
  131. package/dist/esm/chunk-YZZO6VDC.mjs +2 -0
  132. package/dist/esm/chunk-YZZO6VDC.mjs.map +1 -0
  133. package/dist/esm/client/core.mjs +1 -1
  134. package/dist/esm/client/get.mjs +1 -1
  135. package/dist/esm/client/index.mjs +1 -1
  136. package/dist/esm/client/post.mjs +1 -1
  137. package/dist/esm/core/account/Account.d.mts +20 -0
  138. package/dist/esm/core/account/Account.mjs +2 -0
  139. package/dist/esm/core/account/Ed25519Account.d.mts +20 -0
  140. package/dist/esm/core/account/Ed25519Account.mjs +2 -0
  141. package/dist/esm/core/account/SingleKeyAccount.d.mts +20 -0
  142. package/dist/esm/core/account/SingleKeyAccount.mjs +2 -0
  143. package/dist/esm/core/account/SingleKeyAccount.mjs.map +1 -0
  144. package/dist/esm/core/account/index.d.mts +305 -0
  145. package/dist/esm/core/account/index.mjs +2 -0
  146. package/dist/esm/core/account/index.mjs.map +1 -0
  147. package/dist/esm/core/accountAddress.mjs +1 -1
  148. package/dist/esm/core/authenticationKey.d.mts +7 -68
  149. package/dist/esm/core/authenticationKey.mjs +1 -1
  150. package/dist/esm/core/crypto/ed25519.d.mts +49 -61
  151. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  152. package/dist/esm/core/crypto/index.d.mts +9 -6
  153. package/dist/esm/core/crypto/index.mjs +1 -1
  154. package/dist/esm/core/crypto/multiEd25519.d.mts +17 -14
  155. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  156. package/dist/esm/core/crypto/multiKey.d.mts +70 -17
  157. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  158. package/dist/esm/core/crypto/privateKey.d.mts +35 -0
  159. package/dist/esm/core/crypto/privateKey.mjs +2 -0
  160. package/dist/esm/core/crypto/privateKey.mjs.map +1 -0
  161. package/dist/esm/core/crypto/publicKey.d.mts +13 -0
  162. package/dist/esm/core/crypto/publicKey.mjs +2 -0
  163. package/dist/esm/core/crypto/publicKey.mjs.map +1 -0
  164. package/dist/esm/core/crypto/secp256k1.d.mts +43 -67
  165. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  166. package/dist/esm/core/crypto/signature.d.mts +28 -0
  167. package/dist/esm/core/crypto/signature.mjs +2 -0
  168. package/dist/esm/core/crypto/signature.mjs.map +1 -0
  169. package/dist/esm/core/crypto/singleKey.d.mts +68 -0
  170. package/dist/esm/core/crypto/singleKey.mjs +2 -0
  171. package/dist/esm/core/crypto/singleKey.mjs.map +1 -0
  172. package/dist/esm/core/index.d.mts +9 -8
  173. package/dist/esm/core/index.mjs +1 -1
  174. package/dist/esm/index.d.mts +9 -9
  175. package/dist/esm/index.mjs +1 -1
  176. package/dist/esm/internal/account.d.mts +9 -3
  177. package/dist/esm/internal/account.mjs +1 -1
  178. package/dist/esm/internal/ans.d.mts +10 -11
  179. package/dist/esm/internal/ans.mjs +1 -1
  180. package/dist/esm/internal/coin.d.mts +9 -9
  181. package/dist/esm/internal/coin.mjs +1 -1
  182. package/dist/esm/internal/digitalAsset.d.mts +15 -12
  183. package/dist/esm/internal/digitalAsset.mjs +1 -1
  184. package/dist/esm/internal/event.d.mts +7 -2
  185. package/dist/esm/internal/event.mjs +1 -1
  186. package/dist/esm/internal/faucet.d.mts +1 -1
  187. package/dist/esm/internal/faucet.mjs +1 -1
  188. package/dist/esm/internal/fungibleAsset.d.mts +9 -10
  189. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  190. package/dist/esm/internal/general.mjs +1 -1
  191. package/dist/esm/internal/staking.d.mts +1 -1
  192. package/dist/esm/internal/staking.mjs +1 -1
  193. package/dist/esm/internal/transaction.mjs +1 -1
  194. package/dist/esm/internal/transactionSubmission.d.mts +10 -11
  195. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  196. package/dist/esm/publicKey-lq5djCIY.d.mts +113 -0
  197. package/dist/esm/transactions/authenticator/account.d.mts +6 -4
  198. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  199. package/dist/esm/transactions/authenticator/index.d.mts +6 -6
  200. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  201. package/dist/esm/transactions/authenticator/transaction.d.mts +5 -5
  202. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  203. package/dist/esm/transactions/index.d.mts +6 -7
  204. package/dist/esm/transactions/index.mjs +1 -1
  205. package/dist/esm/transactions/instances/index.d.mts +4 -4
  206. package/dist/esm/transactions/instances/index.mjs +1 -1
  207. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  208. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  209. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  210. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +2 -1
  211. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  212. package/dist/esm/transactions/instances/signedTransaction.d.mts +8 -8
  213. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  214. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  215. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  216. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +11 -5
  217. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  218. package/dist/esm/transactions/management/index.d.mts +11 -12
  219. package/dist/esm/transactions/management/index.mjs +1 -1
  220. package/dist/esm/transactions/management/transactionWorker.d.mts +11 -12
  221. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  222. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +10 -10
  223. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  224. package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -10
  225. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  226. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +8 -8
  227. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  228. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +9 -10
  229. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  230. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  231. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  232. package/dist/esm/transactions/types.d.mts +9 -9
  233. package/dist/esm/types/generated/operations.d.mts +6 -0
  234. package/dist/esm/types/generated/queries.d.mts +6 -6
  235. package/dist/esm/types/generated/queries.mjs +1 -1
  236. package/dist/esm/types/generated/types.d.mts +594 -56
  237. package/dist/esm/types/generated/types.mjs +1 -1
  238. package/dist/esm/types/generated/types.mjs.map +1 -1
  239. package/dist/esm/types/index.d.mts +35 -6
  240. package/dist/esm/types/index.mjs +1 -1
  241. package/dist/esm/utils/const.d.mts +1 -2
  242. package/dist/esm/utils/const.mjs +1 -1
  243. package/dist/esm/utils/index.d.mts +1 -1
  244. package/dist/esm/utils/index.mjs +1 -1
  245. package/dist/esm/version.d.mts +1 -1
  246. package/dist/esm/version.mjs +1 -1
  247. package/package.json +16 -16
  248. package/src/api/aptosConfig.ts +2 -2
  249. package/src/api/digitalAsset.ts +20 -0
  250. package/src/api/event.ts +27 -1
  251. package/src/core/account/Account.ts +245 -0
  252. package/src/core/account/Ed25519Account.ts +88 -0
  253. package/src/core/account/SingleKeyAccount.ts +120 -0
  254. package/src/core/account/index.ts +3 -0
  255. package/src/core/authenticationKey.ts +18 -52
  256. package/src/core/crypto/ed25519.ts +118 -104
  257. package/src/core/crypto/index.ts +6 -5
  258. package/src/core/crypto/multiEd25519.ts +98 -44
  259. package/src/core/crypto/multiKey.ts +192 -34
  260. package/src/core/crypto/privateKey.ts +25 -0
  261. package/src/core/crypto/publicKey.ts +52 -0
  262. package/src/core/crypto/secp256k1.ts +108 -111
  263. package/src/core/crypto/signature.ts +46 -0
  264. package/src/core/crypto/singleKey.ts +180 -0
  265. package/src/internal/account.ts +5 -3
  266. package/src/internal/digitalAsset.ts +26 -0
  267. package/src/internal/event.ts +33 -1
  268. package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +1 -0
  269. package/src/internal/queries/getTokenData.graphql +1 -0
  270. package/src/transactions/authenticator/account.ts +1 -2
  271. package/src/transactions/instances/rotationProofChallenge.ts +1 -1
  272. package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -21
  273. package/src/transactions/types.ts +1 -1
  274. package/src/types/generated/operations.ts +6 -0
  275. package/src/types/generated/queries.ts +2 -0
  276. package/src/types/generated/types.ts +662 -55
  277. package/src/types/index.ts +40 -4
  278. package/src/utils/const.ts +0 -4
  279. package/src/version.ts +1 -1
  280. package/dist/esm/chunk-2QV6HI3M.mjs +0 -2
  281. package/dist/esm/chunk-2QV6HI3M.mjs.map +0 -1
  282. package/dist/esm/chunk-3UYBNX3P.mjs +0 -2
  283. package/dist/esm/chunk-4SAUEZTN.mjs +0 -2
  284. package/dist/esm/chunk-4SAUEZTN.mjs.map +0 -1
  285. package/dist/esm/chunk-6UNBJAV6.mjs.map +0 -1
  286. package/dist/esm/chunk-7IGH7N52.mjs +0 -2
  287. package/dist/esm/chunk-7IGH7N52.mjs.map +0 -1
  288. package/dist/esm/chunk-A2QH4A6D.mjs +0 -2
  289. package/dist/esm/chunk-AA3GRJNL.mjs +0 -2
  290. package/dist/esm/chunk-AA3GRJNL.mjs.map +0 -1
  291. package/dist/esm/chunk-ALFESCPU.mjs +0 -2
  292. package/dist/esm/chunk-ALFESCPU.mjs.map +0 -1
  293. package/dist/esm/chunk-BQSE5HHW.mjs.map +0 -1
  294. package/dist/esm/chunk-CCUD52OF.mjs +0 -2
  295. package/dist/esm/chunk-CCUD52OF.mjs.map +0 -1
  296. package/dist/esm/chunk-ERWQOVBF.mjs +0 -2
  297. package/dist/esm/chunk-ERWQOVBF.mjs.map +0 -1
  298. package/dist/esm/chunk-FBFMQZTM.mjs +0 -2
  299. package/dist/esm/chunk-FBFMQZTM.mjs.map +0 -1
  300. package/dist/esm/chunk-FP5DPRYL.mjs +0 -2
  301. package/dist/esm/chunk-FP5DPRYL.mjs.map +0 -1
  302. package/dist/esm/chunk-HHJBCGAQ.mjs +0 -2
  303. package/dist/esm/chunk-HHJBCGAQ.mjs.map +0 -1
  304. package/dist/esm/chunk-I7WRJY7K.mjs +0 -2
  305. package/dist/esm/chunk-I7WRJY7K.mjs.map +0 -1
  306. package/dist/esm/chunk-INV6U3KS.mjs +0 -2
  307. package/dist/esm/chunk-INV6U3KS.mjs.map +0 -1
  308. package/dist/esm/chunk-O57QZZF2.mjs.map +0 -1
  309. package/dist/esm/chunk-SBMJNU2O.mjs +0 -2
  310. package/dist/esm/chunk-SBMJNU2O.mjs.map +0 -1
  311. package/dist/esm/chunk-SZYATFM7.mjs +0 -2
  312. package/dist/esm/chunk-SZYATFM7.mjs.map +0 -1
  313. package/dist/esm/chunk-UCHGKGCF.mjs +0 -2
  314. package/dist/esm/chunk-UCHGKGCF.mjs.map +0 -1
  315. package/dist/esm/chunk-UIVJXLRM.mjs +0 -1
  316. package/dist/esm/chunk-UJAX75ON.mjs +0 -2
  317. package/dist/esm/chunk-V6JFR2CB.mjs +0 -2
  318. package/dist/esm/chunk-V6JFR2CB.mjs.map +0 -1
  319. package/dist/esm/chunk-YGMT4GQ5.mjs.map +0 -1
  320. package/dist/esm/chunk-ZFIMVSCR.mjs +0 -2
  321. package/dist/esm/chunk-ZFIMVSCR.mjs.map +0 -1
  322. package/dist/esm/chunk-ZIZ7PVK2.mjs +0 -2
  323. package/dist/esm/chunk-ZIZ7PVK2.mjs.map +0 -1
  324. package/dist/esm/core/account.d.mts +0 -184
  325. package/dist/esm/core/account.mjs +0 -2
  326. package/dist/esm/core/crypto/anyPublicKey.d.mts +0 -59
  327. package/dist/esm/core/crypto/anyPublicKey.mjs +0 -2
  328. package/dist/esm/core/crypto/anySignature.d.mts +0 -31
  329. package/dist/esm/core/crypto/anySignature.mjs +0 -2
  330. package/dist/esm/core/crypto/asymmetricCrypto.d.mts +0 -74
  331. package/dist/esm/core/crypto/asymmetricCrypto.mjs +0 -2
  332. package/src/core/account.ts +0 -282
  333. package/src/core/crypto/anyPublicKey.ts +0 -92
  334. package/src/core/crypto/anySignature.ts +0 -56
  335. package/src/core/crypto/asymmetricCrypto.ts +0 -77
  336. /package/dist/esm/{chunk-RNO5ZG3C.mjs.map → chunk-52RTAMN7.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-WQI2RH2S.mjs.map → chunk-7U36LMP4.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-ARIC32W7.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-RIL4SHXC.mjs.map → chunk-B7M3OWHV.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-C7ZX475J.mjs.map → chunk-BBUAAJRA.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-DRF6AMEZ.mjs.map → chunk-CHA5DSSD.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-IKCBGNRD.mjs.map → chunk-DGOT2VR5.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-GVHOHNHT.mjs.map → chunk-EF2F7NWO.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-J6RCCKOA.mjs.map → chunk-EQZ757ES.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-CX5ULWJQ.mjs.map → chunk-F67Y7YH6.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-JLL7BCD4.mjs.map → chunk-FVMVV4V3.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-ESX5X52V.mjs.map → chunk-GQOOXOTN.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-XQIWF5HY.mjs.map → chunk-I3TCHVQQ.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-3NOQE6U3.mjs.map → chunk-ILJWEPDW.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-5L6SRCJP.mjs.map → chunk-J6MWD4XN.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-UIVJXLRM.mjs.map → chunk-KUX6GQ2E.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-WK36MJRI.mjs.map → chunk-LLL2LFYH.mjs.map} +0 -0
  353. /package/dist/esm/{chunk-5WXR2O3T.mjs.map → chunk-N65SOKJQ.mjs.map} +0 -0
  354. /package/dist/esm/{chunk-XOBXX273.mjs.map → chunk-NL3XVNS5.mjs.map} +0 -0
  355. /package/dist/esm/{chunk-Q7JKS6WV.mjs.map → chunk-NURFZOR4.mjs.map} +0 -0
  356. /package/dist/esm/{chunk-MKERJNYN.mjs.map → chunk-OG56TYZE.mjs.map} +0 -0
  357. /package/dist/esm/{core/account.mjs.map → chunk-QE4ASJ5K.mjs.map} +0 -0
  358. /package/dist/esm/{chunk-TVURQPLA.mjs.map → chunk-R4VJDSIP.mjs.map} +0 -0
  359. /package/dist/esm/{chunk-Z6XNTGNK.mjs.map → chunk-TN5BUH4F.mjs.map} +0 -0
  360. /package/dist/esm/{chunk-YE3DZD6T.mjs.map → chunk-UIUSDBCL.mjs.map} +0 -0
  361. /package/dist/esm/{chunk-7JTOGYO7.mjs.map → chunk-UMLDKLDL.mjs.map} +0 -0
  362. /package/dist/esm/{core/crypto/anyPublicKey.mjs.map → chunk-UVSRX4SV.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-6Y3VBRMN.mjs.map → chunk-VEVBHH3M.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-T5IFXLOP.mjs.map → chunk-VMXBMAYK.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-WC2WSKYZ.mjs.map → chunk-X5C3LYI7.mjs.map} +0 -0
  366. /package/dist/esm/{chunk-OWZLBIDD.mjs.map → chunk-XTPFQ4MH.mjs.map} +0 -0
  367. /package/dist/esm/{chunk-D2GNCG27.mjs.map → chunk-Y5AJLNUD.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-ZFPA45OK.mjs.map → chunk-YR2R3LW4.mjs.map} +0 -0
  369. /package/dist/esm/core/{crypto/anySignature.mjs.map → account/Account.mjs.map} +0 -0
  370. /package/dist/esm/core/{crypto/asymmetricCrypto.mjs.map → account/Ed25519Account.mjs.map} +0 -0
@@ -1,184 +0,0 @@
1
- import { AccountAddress } from './accountAddress.mjs';
2
- import { AuthenticationKey } from './authenticationKey.mjs';
3
- import { PublicKey, PrivateKey, Signature } from './crypto/asymmetricCrypto.mjs';
4
- import { SigningScheme, GenerateAccount, SigningSchemeInput, HexInput } from '../types/index.mjs';
5
- import '../bcs/serializer.mjs';
6
- import './hex.mjs';
7
- import './common.mjs';
8
- import '../utils/apiEndpoints.mjs';
9
- import '../types/indexer.mjs';
10
- import '../types/generated/operations.mjs';
11
- import '../types/generated/types.mjs';
12
- import '../bcs/deserializer.mjs';
13
- import '../transactions/instances/transactionArgument.mjs';
14
-
15
- /**
16
- * Class for creating and managing account on Aptos network
17
- *
18
- * Use this class to create accounts, sign transactions, and more.
19
- * Note: Creating an account instance does not create the account on-chain.
20
- *
21
- * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
22
- * `Legacy` and `Unified` authentications.
23
- *
24
- * @Legacy includes `ED25519` and `MultiED25519`
25
- * @Unified includes `SingleSender` and `MultiSender`, where currently
26
- * `SingleSender` supports `ED25519` and `Secp256k1`, and `MultiSender` supports
27
- * `MultiED25519`.
28
- *
29
- * In TypeScript SDK, we support all of these options:
30
- *
31
- * @generate default to generate Legacy Ed25519 keys, with an optional `legacy` boolean argument
32
- * that lets you generate new keys conforming to the Unified authentication.
33
- *
34
- * @fromPrivateKey derives an account by a provided private key and address, with an optional
35
- * `legacy` boolean argument that lets you generate new keys conforming to the Unified authentication.
36
- *
37
- * @fromDerivationPath derives an account with bip44 path and mnemonics,
38
- *
39
- */
40
- declare class Account {
41
- /**
42
- * Public key associated with the account
43
- */
44
- readonly publicKey: PublicKey;
45
- /**
46
- * Private key associated with the account
47
- */
48
- readonly privateKey: PrivateKey;
49
- /**
50
- * Account address associated with the account
51
- */
52
- readonly accountAddress: AccountAddress;
53
- /**
54
- * Signing scheme used to sign transactions
55
- */
56
- readonly signingScheme: SigningScheme;
57
- /**
58
- * constructor for Account
59
- *
60
- * Need to update this to use the new crypto library if new schemes are added.
61
- *
62
- * @param args.privateKey PrivateKey - private key of the account
63
- * @param args.address AccountAddress - address of the account
64
- * @param args.legacy optional. If set to false, the keypair authentication keys will be derived with a unified scheme.
65
- * Defaults to deriving an authentication key with the legacy scheme.
66
- *
67
- * This method is private because it should only be called by the factory static methods.
68
- * @returns Account
69
- */
70
- private constructor();
71
- /**
72
- * Derives an account with random private key and address.
73
- *
74
- * Default generation is using the Legacy ED25519 key
75
- *
76
- * @param args optional. Unify GenerateAccount type for Legacy and Unified keys
77
- *
78
- * Account input type to generate an account using Legacy
79
- * Ed25519 or MultiEd25519 keys or without a specified `scheme`.
80
- * ```
81
- * GenerateAccountWithLegacyKey = {
82
- * scheme?: SigningSchemeInput.Ed25519 | SigningSchemeInput.MultiEd25519;
83
- * legacy: true;
84
- * };
85
- * ```
86
- *
87
- * Account input type to generate an account using Unified
88
- * Secp256k1Ecdsa key
89
- * In this case `legacy` is always false
90
- * ```
91
- * GenerateAccountWithUnifiedKey = {
92
- * scheme: SigningSchemeInput.Secp256k1Ecdsa;
93
- * legacy?: false;
94
- * };
95
- * ```
96
- *
97
- * @returns Account with the given signing scheme
98
- */
99
- static generate(args?: GenerateAccount): Account;
100
- /**
101
- * Instantiates an account given a private key.
102
- *
103
- * This is used as a local calculation and therefore is used to instantiate an `Account`
104
- * that has not had its authentication key rotated.
105
- *
106
- * @param privateKey PrivateKey - private key of the account
107
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
108
- * to generating a Legacy Ed25519 keypair
109
- *
110
- * @returns Account
111
- */
112
- static fromPrivateKey(args: {
113
- privateKey: PrivateKey;
114
- legacy?: boolean;
115
- }): Account;
116
- /**
117
- * Instantiates an account given a private key and a specified account address.
118
- * This is primarily used to instantiate an `Account` that has had its authentication key rotated.
119
- *
120
- * @param args.privateKey PrivateKey - the underlying private key for the account
121
- * @param args.address AccountAddress - The account address the `Account` will sign for
122
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
123
- * to generating a Legacy Ed25519 keypair
124
- *
125
- * @returns Account
126
- */
127
- static fromPrivateKeyAndAddress(args: {
128
- privateKey: PrivateKey;
129
- address: AccountAddress;
130
- legacy?: boolean;
131
- }): Account;
132
- /**
133
- * Derives an account with bip44 path and mnemonics,
134
- *
135
- * @param args.scheme The signing scheme to derive with
136
- * @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
137
- * or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
138
- * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
139
- * @param args.mnemonic the mnemonic seed phrase of the account
140
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
141
- * to generating a Legacy Ed25519 keypair
142
- *
143
- * @returns Account
144
- */
145
- static fromDerivationPath(args: {
146
- scheme: SigningSchemeInput;
147
- path: string;
148
- mnemonic: string;
149
- legacy?: boolean;
150
- }): Account;
151
- /**
152
- * This key enables account owners to rotate their private key(s)
153
- * associated with the account without changing the address that hosts their account.
154
- * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}
155
- *
156
- * @param args.publicKey PublicKey - public key of the account
157
- * @returns The authentication key for the associated account
158
- */
159
- static authKey(args: {
160
- publicKey: PublicKey;
161
- }): AuthenticationKey;
162
- /**
163
- * Sign the given message with the private key.
164
- *
165
- * TODO: Add sign transaction or specific types
166
- *
167
- * @param data in HexInput format
168
- * @returns Signature
169
- */
170
- sign(data: HexInput): Signature;
171
- /**
172
- * Verify the given message and signature with the public key.
173
- *
174
- * @param args.message raw message data in HexInput format
175
- * @param args.signature signed message Signature
176
- * @returns
177
- */
178
- verifySignature(args: {
179
- message: HexInput;
180
- signature: Signature;
181
- }): boolean;
182
- }
183
-
184
- export { Account };
@@ -1,2 +0,0 @@
1
- import{a}from"../chunk-FP5DPRYL.mjs";import"../chunk-SBMJNU2O.mjs";import"../chunk-7IGH7N52.mjs";import"../chunk-UCHGKGCF.mjs";import"../chunk-FBFMQZTM.mjs";import"../chunk-ZFIMVSCR.mjs";import"../chunk-I7WRJY7K.mjs";import"../chunk-V6JFR2CB.mjs";import"../chunk-LR65XHSF.mjs";import"../chunk-F7CR75CJ.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-F7MOQC7Z.mjs";import"../chunk-PPTG6BDV.mjs";import"../chunk-B2ZKW23W.mjs";import"../chunk-VRSUCKJA.mjs";import"../chunk-ALFESCPU.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-6IFMQ5AS.mjs";import"../chunk-N4RBQZ2B.mjs";import"../chunk-NL72WE3E.mjs";import"../chunk-FBPNHF54.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-FVA2OPG4.mjs";export{a as Account};
2
- //# sourceMappingURL=account.mjs.map
@@ -1,59 +0,0 @@
1
- import { Deserializer } from '../../bcs/deserializer.mjs';
2
- import { Serializer } from '../../bcs/serializer.mjs';
3
- import { HexInput } from '../../types/index.mjs';
4
- import { AnySignature } from './anySignature.mjs';
5
- import { PublicKey } from './asymmetricCrypto.mjs';
6
- import { Ed25519PublicKey } from './ed25519.mjs';
7
- import { Secp256k1PublicKey } from './secp256k1.mjs';
8
- import '../../utils/apiEndpoints.mjs';
9
- import '../../types/indexer.mjs';
10
- import '../../types/generated/operations.mjs';
11
- import '../../types/generated/types.mjs';
12
- import '../hex.mjs';
13
- import '../common.mjs';
14
-
15
- /**
16
- * Represents any public key supported by Aptos.
17
- *
18
- * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
19
- * `Legacy` and `Unified` authentication keys.
20
- *
21
- * Any unified authentication key is represented in the SDK as `AnyPublicKey`.
22
- */
23
- declare class AnyPublicKey extends PublicKey {
24
- /**
25
- * Reference to the inner public key
26
- */
27
- readonly publicKey: PublicKey;
28
- constructor(publicKey: PublicKey);
29
- /**
30
- * Get the public key in bytes (Uint8Array).
31
- *
32
- * @returns Uint8Array representation of the public key
33
- */
34
- toUint8Array(): Uint8Array;
35
- /**
36
- * Get the public key as a hex string with the 0x prefix.
37
- *
38
- * @returns string representation of the public key
39
- */
40
- toString(): string;
41
- /**
42
- * Verifies a signed data with a public key
43
- *
44
- * @param args.message message
45
- * @param args.signature The signature
46
- * @returns true if the signature is valid
47
- */
48
- verifySignature(args: {
49
- message: HexInput;
50
- signature: AnySignature;
51
- }): boolean;
52
- serialize(serializer: Serializer): void;
53
- static deserialize(deserializer: Deserializer): AnyPublicKey;
54
- static isPublicKey(publicKey: PublicKey): publicKey is AnyPublicKey;
55
- isEd25519(): this is Ed25519PublicKey;
56
- isSecp256k1PublicKey(): this is Secp256k1PublicKey;
57
- }
58
-
59
- export { AnyPublicKey };
@@ -1,2 +0,0 @@
1
- import{a}from"../../chunk-FBFMQZTM.mjs";import"../../chunk-ZFIMVSCR.mjs";import"../../chunk-I7WRJY7K.mjs";import"../../chunk-V6JFR2CB.mjs";import"../../chunk-LR65XHSF.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-F7MOQC7Z.mjs";import"../../chunk-PPTG6BDV.mjs";import"../../chunk-B2ZKW23W.mjs";import"../../chunk-VRSUCKJA.mjs";import"../../chunk-ALFESCPU.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-6IFMQ5AS.mjs";import"../../chunk-N4RBQZ2B.mjs";import"../../chunk-NL72WE3E.mjs";import"../../chunk-FBPNHF54.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-FVA2OPG4.mjs";export{a as AnyPublicKey};
2
- //# sourceMappingURL=anyPublicKey.mjs.map
@@ -1,31 +0,0 @@
1
- import { Deserializer } from '../../bcs/deserializer.mjs';
2
- import { Serializer } from '../../bcs/serializer.mjs';
3
- import { Signature } from './asymmetricCrypto.mjs';
4
- import '../../types/index.mjs';
5
- import '../../utils/apiEndpoints.mjs';
6
- import '../../types/indexer.mjs';
7
- import '../../types/generated/operations.mjs';
8
- import '../../types/generated/types.mjs';
9
- import '../hex.mjs';
10
- import '../common.mjs';
11
-
12
- declare class AnySignature extends Signature {
13
- readonly signature: Signature;
14
- constructor(signature: Signature);
15
- /**
16
- * Get the public key in bytes (Uint8Array).
17
- *
18
- * @returns Uint8Array representation of the public key
19
- */
20
- toUint8Array(): Uint8Array;
21
- /**
22
- * Get the public key as a hex string with the 0x prefix.
23
- *
24
- * @returns string representation of the public key
25
- */
26
- toString(): string;
27
- serialize(serializer: Serializer): void;
28
- static deserialize(deserializer: Deserializer): AnySignature;
29
- }
30
-
31
- export { AnySignature };
@@ -1,2 +0,0 @@
1
- import{a}from"../../chunk-2QV6HI3M.mjs";import"../../chunk-ZFIMVSCR.mjs";import"../../chunk-I7WRJY7K.mjs";import"../../chunk-V6JFR2CB.mjs";import"../../chunk-LR65XHSF.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-F7MOQC7Z.mjs";import"../../chunk-PPTG6BDV.mjs";import"../../chunk-B2ZKW23W.mjs";import"../../chunk-VRSUCKJA.mjs";import"../../chunk-ALFESCPU.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-6IFMQ5AS.mjs";import"../../chunk-N4RBQZ2B.mjs";import"../../chunk-NL72WE3E.mjs";import"../../chunk-FBPNHF54.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-FVA2OPG4.mjs";export{a as AnySignature};
2
- //# sourceMappingURL=anySignature.mjs.map
@@ -1,74 +0,0 @@
1
- import { HexInput } from '../../types/index.mjs';
2
- import { Serializable, Serializer } from '../../bcs/serializer.mjs';
3
- import '../../utils/apiEndpoints.mjs';
4
- import '../../types/indexer.mjs';
5
- import '../../types/generated/operations.mjs';
6
- import '../../types/generated/types.mjs';
7
- import '../hex.mjs';
8
- import '../common.mjs';
9
-
10
- /**
11
- * An abstract representation of a public key. All Asymmetric key pairs will use this to
12
- * verify signatures and for authentication keys.
13
- */
14
- declare abstract class PublicKey extends Serializable {
15
- /**
16
- * Verifies that the private key associated with this public key signed the message with the given signature.
17
- * @param args.message The message that was signed
18
- * @param args.signature The signature to verify
19
- */
20
- abstract verifySignature(args: {
21
- message: HexInput;
22
- signature: Signature;
23
- }): boolean;
24
- /**
25
- * Get the raw public key bytes
26
- */
27
- abstract toUint8Array(): Uint8Array;
28
- /**
29
- * Get the public key as a hex string with a 0x prefix e.g. 0x123456...
30
- */
31
- abstract toString(): string;
32
- abstract serialize(serializer: Serializer): void;
33
- }
34
- /**
35
- * An abstract representation of a private key. This is used to sign transactions and
36
- * derive the public key associated.
37
- */
38
- declare abstract class PrivateKey extends Serializable {
39
- /**
40
- * Sign a message with the key
41
- * @param message The message to sign
42
- */
43
- abstract sign(message: HexInput): Signature;
44
- /**
45
- * Get the raw private key bytes
46
- */
47
- abstract toUint8Array(): Uint8Array;
48
- /**
49
- * Get the private key as a hex string with a 0x prefix e.g. 0x123456...
50
- */
51
- abstract toString(): string;
52
- abstract serialize(serializer: Serializer): void;
53
- /**
54
- * Derives the public key associated with the private key
55
- */
56
- abstract publicKey(): PublicKey;
57
- }
58
- /**
59
- * An abstract representation of a signature. This is the product of signing a
60
- * message and can be used with the PublicKey to verify the signature.
61
- */
62
- declare abstract class Signature extends Serializable {
63
- /**
64
- * Get the raw signature bytes
65
- */
66
- abstract toUint8Array(): Uint8Array;
67
- /**
68
- * Get the signature as a hex string with a 0x prefix e.g. 0x123456...
69
- */
70
- abstract toString(): string;
71
- abstract serialize(serializer: Serializer): void;
72
- }
73
-
74
- export { PrivateKey, PublicKey, Signature };
@@ -1,2 +0,0 @@
1
- import{a,b,c}from"../../chunk-V6JFR2CB.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-F7MOQC7Z.mjs";import"../../chunk-PPTG6BDV.mjs";import"../../chunk-B2ZKW23W.mjs";import"../../chunk-VRSUCKJA.mjs";import"../../chunk-ALFESCPU.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-6IFMQ5AS.mjs";import"../../chunk-N4RBQZ2B.mjs";import"../../chunk-NL72WE3E.mjs";import"../../chunk-FBPNHF54.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-FVA2OPG4.mjs";export{b as PrivateKey,a as PublicKey,c as Signature};
2
- //# sourceMappingURL=asymmetricCrypto.mjs.map
@@ -1,282 +0,0 @@
1
- // Copyright © Aptos Foundation
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { AccountAddress } from "./accountAddress";
5
- import { AuthenticationKey } from "./authenticationKey";
6
- import { PrivateKey, PublicKey, Signature } from "./crypto/asymmetricCrypto";
7
- import { Ed25519PrivateKey, Ed25519PublicKey } from "./crypto/ed25519";
8
- import { MultiEd25519PublicKey } from "./crypto/multiEd25519";
9
- import { Secp256k1PrivateKey, Secp256k1PublicKey } from "./crypto/secp256k1";
10
- import { Hex } from "./hex";
11
- import { GenerateAccount, HexInput, SigningScheme, SigningSchemeInput } from "../types";
12
- import { AnyPublicKey } from "./crypto/anyPublicKey";
13
-
14
- /**
15
- * Class for creating and managing account on Aptos network
16
- *
17
- * Use this class to create accounts, sign transactions, and more.
18
- * Note: Creating an account instance does not create the account on-chain.
19
- *
20
- * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
21
- * `Legacy` and `Unified` authentications.
22
- *
23
- * @Legacy includes `ED25519` and `MultiED25519`
24
- * @Unified includes `SingleSender` and `MultiSender`, where currently
25
- * `SingleSender` supports `ED25519` and `Secp256k1`, and `MultiSender` supports
26
- * `MultiED25519`.
27
- *
28
- * In TypeScript SDK, we support all of these options:
29
- *
30
- * @generate default to generate Legacy Ed25519 keys, with an optional `legacy` boolean argument
31
- * that lets you generate new keys conforming to the Unified authentication.
32
- *
33
- * @fromPrivateKey derives an account by a provided private key and address, with an optional
34
- * `legacy` boolean argument that lets you generate new keys conforming to the Unified authentication.
35
- *
36
- * @fromDerivationPath derives an account with bip44 path and mnemonics,
37
- *
38
- */
39
- export class Account {
40
- /**
41
- * Public key associated with the account
42
- */
43
- readonly publicKey: PublicKey;
44
-
45
- /**
46
- * Private key associated with the account
47
- */
48
- readonly privateKey: PrivateKey;
49
-
50
- /**
51
- * Account address associated with the account
52
- */
53
- readonly accountAddress: AccountAddress;
54
-
55
- /**
56
- * Signing scheme used to sign transactions
57
- */
58
- readonly signingScheme: SigningScheme;
59
-
60
- /**
61
- * constructor for Account
62
- *
63
- * Need to update this to use the new crypto library if new schemes are added.
64
- *
65
- * @param args.privateKey PrivateKey - private key of the account
66
- * @param args.address AccountAddress - address of the account
67
- * @param args.legacy optional. If set to false, the keypair authentication keys will be derived with a unified scheme.
68
- * Defaults to deriving an authentication key with the legacy scheme.
69
- *
70
- * This method is private because it should only be called by the factory static methods.
71
- * @returns Account
72
- */
73
- private constructor(args: { privateKey: PrivateKey; address: AccountAddress; legacy?: boolean }) {
74
- const { privateKey, address, legacy } = args;
75
- const useLegacy = legacy ?? true;
76
-
77
- // Derive the public key from the private key
78
- this.publicKey = privateKey.publicKey();
79
-
80
- // Derive the signing scheme from the public key
81
- if (this.publicKey instanceof Ed25519PublicKey) {
82
- if (useLegacy) {
83
- this.signingScheme = SigningScheme.Ed25519;
84
- } else {
85
- this.publicKey = new AnyPublicKey(this.publicKey);
86
- this.signingScheme = SigningScheme.SingleKey;
87
- }
88
- } else if (this.publicKey instanceof MultiEd25519PublicKey) {
89
- this.signingScheme = SigningScheme.MultiEd25519;
90
- } else if (this.publicKey instanceof Secp256k1PublicKey) {
91
- this.publicKey = new AnyPublicKey(this.publicKey);
92
- this.signingScheme = SigningScheme.SingleKey;
93
- } else {
94
- throw new Error("Can not create new Account, unsupported public key type");
95
- }
96
-
97
- this.privateKey = privateKey;
98
- this.accountAddress = address;
99
- }
100
-
101
- /**
102
- * Derives an account with random private key and address.
103
- *
104
- * Default generation is using the Legacy ED25519 key
105
- *
106
- * @param args optional. Unify GenerateAccount type for Legacy and Unified keys
107
- *
108
- * Account input type to generate an account using Legacy
109
- * Ed25519 or MultiEd25519 keys or without a specified `scheme`.
110
- * ```
111
- * GenerateAccountWithLegacyKey = {
112
- * scheme?: SigningSchemeInput.Ed25519 | SigningSchemeInput.MultiEd25519;
113
- * legacy: true;
114
- * };
115
- * ```
116
- *
117
- * Account input type to generate an account using Unified
118
- * Secp256k1Ecdsa key
119
- * In this case `legacy` is always false
120
- * ```
121
- * GenerateAccountWithUnifiedKey = {
122
- * scheme: SigningSchemeInput.Secp256k1Ecdsa;
123
- * legacy?: false;
124
- * };
125
- * ```
126
- *
127
- * @returns Account with the given signing scheme
128
- */
129
- static generate(args?: GenerateAccount): Account {
130
- const useLegacy = args?.legacy ?? true;
131
-
132
- let privateKey: PrivateKey;
133
- let publicKey: PublicKey;
134
-
135
- switch (args?.scheme) {
136
- case SigningSchemeInput.Secp256k1Ecdsa:
137
- privateKey = Secp256k1PrivateKey.generate();
138
- publicKey = new AnyPublicKey(privateKey.publicKey());
139
- break;
140
- default:
141
- privateKey = Ed25519PrivateKey.generate();
142
- if (useLegacy === false) {
143
- publicKey = new AnyPublicKey(privateKey.publicKey());
144
- } else {
145
- publicKey = privateKey.publicKey();
146
- }
147
- }
148
- const authKey = AuthenticationKey.fromPublicKey({ publicKey });
149
-
150
- const address = authKey.derivedAddress();
151
- return new Account({ privateKey, address, legacy: args?.legacy });
152
- }
153
-
154
- /**
155
- * Instantiates an account given a private key.
156
- *
157
- * This is used as a local calculation and therefore is used to instantiate an `Account`
158
- * that has not had its authentication key rotated.
159
- *
160
- * @param privateKey PrivateKey - private key of the account
161
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
162
- * to generating a Legacy Ed25519 keypair
163
- *
164
- * @returns Account
165
- */
166
- static fromPrivateKey(args: { privateKey: PrivateKey; legacy?: boolean }): Account {
167
- const { privateKey, legacy } = args;
168
- const useLegacy = legacy ?? true;
169
-
170
- let publicKey;
171
- if (privateKey instanceof Secp256k1PrivateKey) {
172
- // Secp256k1 single sender
173
- publicKey = new AnyPublicKey(privateKey.publicKey());
174
- } else if (privateKey instanceof Ed25519PrivateKey) {
175
- // legacy Ed25519
176
- if (useLegacy) {
177
- publicKey = privateKey.publicKey();
178
- } else {
179
- // Ed25519 single sender
180
- publicKey = new AnyPublicKey(privateKey.publicKey());
181
- }
182
- } else {
183
- throw new Error(`Unsupported private key ${privateKey}`);
184
- }
185
-
186
- const authKey = AuthenticationKey.fromPublicKey({ publicKey });
187
- const address = authKey.derivedAddress();
188
- return new Account({ privateKey, address, legacy: useLegacy });
189
- }
190
-
191
- /**
192
- * Instantiates an account given a private key and a specified account address.
193
- * This is primarily used to instantiate an `Account` that has had its authentication key rotated.
194
- *
195
- * @param args.privateKey PrivateKey - the underlying private key for the account
196
- * @param args.address AccountAddress - The account address the `Account` will sign for
197
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
198
- * to generating a Legacy Ed25519 keypair
199
- *
200
- * @returns Account
201
- */
202
- static fromPrivateKeyAndAddress(args: {
203
- privateKey: PrivateKey;
204
- address: AccountAddress;
205
- legacy?: boolean;
206
- }): Account {
207
- const { privateKey, address, legacy } = args;
208
- return new Account({ privateKey, address, legacy });
209
- }
210
-
211
- /**
212
- * Derives an account with bip44 path and mnemonics,
213
- *
214
- * @param args.scheme The signing scheme to derive with
215
- * @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
216
- * or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
217
- * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
218
- * @param args.mnemonic the mnemonic seed phrase of the account
219
- * @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
220
- * to generating a Legacy Ed25519 keypair
221
- *
222
- * @returns Account
223
- */
224
- static fromDerivationPath(args: {
225
- scheme: SigningSchemeInput;
226
- path: string;
227
- mnemonic: string;
228
- legacy?: boolean;
229
- }): Account {
230
- const { path, mnemonic, scheme, legacy } = args;
231
- let privateKey: PrivateKey;
232
- switch (scheme) {
233
- case SigningSchemeInput.Secp256k1Ecdsa:
234
- privateKey = Secp256k1PrivateKey.fromDerivationPath(path, mnemonic);
235
- break;
236
- case SigningSchemeInput.Ed25519:
237
- privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);
238
- break;
239
- default:
240
- throw new Error(`Unsupported scheme ${scheme}`);
241
- }
242
- return Account.fromPrivateKey({ privateKey, legacy });
243
- }
244
-
245
- /**
246
- * This key enables account owners to rotate their private key(s)
247
- * associated with the account without changing the address that hosts their account.
248
- * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}
249
- *
250
- * @param args.publicKey PublicKey - public key of the account
251
- * @returns The authentication key for the associated account
252
- */
253
- static authKey(args: { publicKey: PublicKey }): AuthenticationKey {
254
- const { publicKey } = args;
255
- return AuthenticationKey.fromPublicKey({ publicKey });
256
- }
257
-
258
- /**
259
- * Sign the given message with the private key.
260
- *
261
- * TODO: Add sign transaction or specific types
262
- *
263
- * @param data in HexInput format
264
- * @returns Signature
265
- */
266
- sign(data: HexInput): Signature {
267
- return this.privateKey.sign(data);
268
- }
269
-
270
- /**
271
- * Verify the given message and signature with the public key.
272
- *
273
- * @param args.message raw message data in HexInput format
274
- * @param args.signature signed message Signature
275
- * @returns
276
- */
277
- verifySignature(args: { message: HexInput; signature: Signature }): boolean {
278
- const { message, signature } = args;
279
- const rawMessage = Hex.fromHexInput(message).toUint8Array();
280
- return this.publicKey.verifySignature({ message: rawMessage, signature });
281
- }
282
- }