@aptos-labs/ts-sdk 0.0.3 → 0.0.5

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 (476) hide show
  1. package/README.md +1 -0
  2. package/dist/{cjs → browser}/index.d.ts +431 -237
  3. package/dist/browser/index.global.js +44 -42
  4. package/dist/browser/index.global.js.map +1 -1
  5. package/dist/common/index.d.ts +5831 -0
  6. package/dist/common/index.js +406 -0
  7. package/dist/common/index.js.map +1 -0
  8. package/dist/esm/api/account.d.ts +292 -0
  9. package/dist/esm/api/account.mjs +2 -0
  10. package/dist/esm/api/account.mjs.map +1 -0
  11. package/dist/esm/api/ans.d.ts +79 -0
  12. package/dist/esm/api/ans.mjs +2 -0
  13. package/dist/esm/api/ans.mjs.map +1 -0
  14. package/dist/esm/api/aptos.d.ts +72 -0
  15. package/dist/esm/api/aptos.mjs +2 -0
  16. package/dist/esm/api/aptos.mjs.map +1 -0
  17. package/dist/esm/api/aptosConfig.d.ts +51 -0
  18. package/dist/esm/api/aptosConfig.mjs +2 -0
  19. package/dist/esm/api/aptosConfig.mjs.map +1 -0
  20. package/dist/esm/api/coin.d.ts +59 -0
  21. package/dist/esm/api/coin.mjs +2 -0
  22. package/dist/esm/api/coin.mjs.map +1 -0
  23. package/dist/esm/api/digitalAsset.d.ts +174 -0
  24. package/dist/esm/api/digitalAsset.mjs +2 -0
  25. package/dist/esm/api/digitalAsset.mjs.map +1 -0
  26. package/dist/esm/api/event.d.ts +74 -0
  27. package/dist/esm/api/event.mjs +2 -0
  28. package/dist/esm/api/event.mjs.map +1 -0
  29. package/dist/esm/api/faucet.d.ts +37 -0
  30. package/dist/esm/api/faucet.mjs +2 -0
  31. package/dist/esm/api/faucet.mjs.map +1 -0
  32. package/dist/esm/api/fungibleAsset.d.ts +72 -0
  33. package/dist/esm/api/fungibleAsset.mjs +2 -0
  34. package/dist/esm/api/fungibleAsset.mjs.map +1 -0
  35. package/dist/esm/api/general.d.ts +150 -0
  36. package/dist/esm/api/general.mjs +2 -0
  37. package/dist/esm/api/general.mjs.map +1 -0
  38. package/dist/esm/api/index.d.ts +46 -0
  39. package/dist/esm/api/index.mjs +2 -0
  40. package/dist/esm/api/index.mjs.map +1 -0
  41. package/dist/esm/api/staking.d.ts +53 -0
  42. package/dist/esm/api/staking.mjs +2 -0
  43. package/dist/esm/api/staking.mjs.map +1 -0
  44. package/dist/esm/api/transaction.d.ts +101 -0
  45. package/dist/esm/api/transaction.mjs +2 -0
  46. package/dist/esm/api/transaction.mjs.map +1 -0
  47. package/dist/esm/api/transactionSubmission.d.ts +142 -0
  48. package/dist/esm/api/transactionSubmission.mjs +2 -0
  49. package/dist/esm/api/transactionSubmission.mjs.map +1 -0
  50. package/dist/esm/bcs/consts.d.ts +14 -0
  51. package/dist/esm/bcs/consts.mjs +2 -0
  52. package/dist/esm/bcs/consts.mjs.map +1 -0
  53. package/dist/esm/bcs/deserializer.d.ts +150 -0
  54. package/dist/esm/bcs/deserializer.mjs +2 -0
  55. package/dist/esm/bcs/deserializer.mjs.map +1 -0
  56. package/dist/esm/bcs/index.d.ts +14 -0
  57. package/dist/esm/bcs/index.mjs +2 -0
  58. package/dist/esm/bcs/index.mjs.map +1 -0
  59. package/dist/esm/bcs/serializable/entryFunctionBytes.d.ts +40 -0
  60. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +2 -0
  61. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -0
  62. package/dist/esm/bcs/serializable/fixedBytes.d.ts +52 -0
  63. package/dist/esm/bcs/serializable/fixedBytes.mjs +2 -0
  64. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -0
  65. package/dist/esm/bcs/serializable/movePrimitives.d.ts +69 -0
  66. package/dist/esm/bcs/serializable/movePrimitives.mjs +2 -0
  67. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -0
  68. package/dist/esm/bcs/serializable/moveStructs.d.ts +284 -0
  69. package/dist/esm/bcs/serializable/moveStructs.mjs +2 -0
  70. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -0
  71. package/dist/esm/bcs/serializer.d.ts +192 -0
  72. package/dist/esm/bcs/serializer.mjs +2 -0
  73. package/dist/esm/bcs/serializer.mjs.map +1 -0
  74. package/dist/esm/chunk-2444YR3Y.mjs +2 -0
  75. package/dist/esm/chunk-2444YR3Y.mjs.map +1 -0
  76. package/dist/esm/chunk-27P7PELS.mjs +2 -0
  77. package/dist/esm/chunk-27P7PELS.mjs.map +1 -0
  78. package/dist/esm/chunk-2B5QXKPU.mjs +2 -0
  79. package/dist/esm/chunk-2B5QXKPU.mjs.map +1 -0
  80. package/dist/esm/chunk-2MQZUGO6.mjs +2 -0
  81. package/dist/esm/chunk-2MQZUGO6.mjs.map +1 -0
  82. package/dist/esm/chunk-3JPVQHOR.mjs +2 -0
  83. package/dist/esm/chunk-3JPVQHOR.mjs.map +1 -0
  84. package/dist/esm/chunk-3OJN4I42.mjs +2 -0
  85. package/dist/esm/chunk-3OJN4I42.mjs.map +1 -0
  86. package/dist/esm/chunk-3YOV42H5.mjs +2 -0
  87. package/dist/esm/chunk-3YOV42H5.mjs.map +1 -0
  88. package/dist/esm/chunk-4WPQQPUF.mjs +1 -0
  89. package/dist/esm/chunk-4WPQQPUF.mjs.map +1 -0
  90. package/dist/esm/chunk-6FBKUTGF.mjs +2 -0
  91. package/dist/esm/chunk-6FBKUTGF.mjs.map +1 -0
  92. package/dist/esm/chunk-7AIV5FEN.mjs +2 -0
  93. package/dist/esm/chunk-7AIV5FEN.mjs.map +1 -0
  94. package/dist/esm/chunk-7AQXAH6Q.mjs +2 -0
  95. package/dist/esm/chunk-7AQXAH6Q.mjs.map +1 -0
  96. package/dist/esm/chunk-7TL2MY2B.mjs +2 -0
  97. package/dist/esm/chunk-7TL2MY2B.mjs.map +1 -0
  98. package/dist/esm/chunk-ADR4XQPR.mjs +2 -0
  99. package/dist/esm/chunk-ADR4XQPR.mjs.map +1 -0
  100. package/dist/esm/chunk-AH44UPM4.mjs +2 -0
  101. package/dist/esm/chunk-AH44UPM4.mjs.map +1 -0
  102. package/dist/esm/chunk-AY2HWVDO.mjs +2 -0
  103. package/dist/esm/chunk-AY2HWVDO.mjs.map +1 -0
  104. package/dist/esm/chunk-BC2NOUYT.mjs +2 -0
  105. package/dist/esm/chunk-BC2NOUYT.mjs.map +1 -0
  106. package/dist/esm/chunk-BIUGRAMO.mjs +2 -0
  107. package/dist/esm/chunk-BIUGRAMO.mjs.map +1 -0
  108. package/dist/esm/chunk-BREUBEPM.mjs +2 -0
  109. package/dist/esm/chunk-BREUBEPM.mjs.map +1 -0
  110. package/dist/esm/chunk-BSCOVLWS.mjs +1 -0
  111. package/dist/esm/chunk-BSCOVLWS.mjs.map +1 -0
  112. package/dist/esm/chunk-BTK34A5U.mjs +406 -0
  113. package/dist/esm/chunk-BTK34A5U.mjs.map +1 -0
  114. package/dist/esm/chunk-CZZJAR3B.mjs +2 -0
  115. package/dist/esm/chunk-CZZJAR3B.mjs.map +1 -0
  116. package/dist/esm/chunk-DNDWTM7A.mjs +2 -0
  117. package/dist/esm/chunk-DNDWTM7A.mjs.map +1 -0
  118. package/dist/esm/chunk-DNYVUM3K.mjs +2 -0
  119. package/dist/esm/chunk-DNYVUM3K.mjs.map +1 -0
  120. package/dist/esm/chunk-DXUIJ6KA.mjs +2 -0
  121. package/dist/esm/chunk-DXUIJ6KA.mjs.map +1 -0
  122. package/dist/esm/chunk-E72CFUU4.mjs +2 -0
  123. package/dist/esm/chunk-E72CFUU4.mjs.map +1 -0
  124. package/dist/esm/chunk-E7FWVXGX.mjs +1 -0
  125. package/dist/esm/chunk-E7FWVXGX.mjs.map +1 -0
  126. package/dist/esm/chunk-EKAOAGNQ.mjs +2 -0
  127. package/dist/esm/chunk-EKAOAGNQ.mjs.map +1 -0
  128. package/dist/esm/chunk-FBPNHF54.mjs +2 -0
  129. package/dist/esm/chunk-FBPNHF54.mjs.map +1 -0
  130. package/dist/esm/chunk-FHJ7F7Z6.mjs +2 -0
  131. package/dist/esm/chunk-FHJ7F7Z6.mjs.map +1 -0
  132. package/dist/esm/chunk-FNB6CFQR.mjs +2 -0
  133. package/dist/esm/chunk-FNB6CFQR.mjs.map +1 -0
  134. package/dist/esm/chunk-FYIFBLHU.mjs +2 -0
  135. package/dist/esm/chunk-FYIFBLHU.mjs.map +1 -0
  136. package/dist/esm/chunk-FZY4PMEE.mjs +1 -0
  137. package/dist/esm/chunk-FZY4PMEE.mjs.map +1 -0
  138. package/dist/esm/chunk-GUT3G5CG.mjs +2 -0
  139. package/dist/esm/chunk-GUT3G5CG.mjs.map +1 -0
  140. package/dist/esm/chunk-HH5RSP2H.mjs +2 -0
  141. package/dist/esm/chunk-HH5RSP2H.mjs.map +1 -0
  142. package/dist/esm/chunk-HTZTTZQJ.mjs +1 -0
  143. package/dist/esm/chunk-HTZTTZQJ.mjs.map +1 -0
  144. package/dist/esm/chunk-I5OYNCZS.mjs +1 -0
  145. package/dist/esm/chunk-I5OYNCZS.mjs.map +1 -0
  146. package/dist/esm/chunk-IPJKGHQY.mjs +2 -0
  147. package/dist/esm/chunk-IPJKGHQY.mjs.map +1 -0
  148. package/dist/esm/chunk-IXMH6AXJ.mjs +2 -0
  149. package/dist/esm/chunk-IXMH6AXJ.mjs.map +1 -0
  150. package/dist/esm/chunk-IZHPCZE3.mjs +2 -0
  151. package/dist/esm/chunk-IZHPCZE3.mjs.map +1 -0
  152. package/dist/esm/chunk-J3QOSJFP.mjs +2 -0
  153. package/dist/esm/chunk-J3QOSJFP.mjs.map +1 -0
  154. package/dist/esm/chunk-J5OKXARS.mjs +2 -0
  155. package/dist/esm/chunk-J5OKXARS.mjs.map +1 -0
  156. package/dist/esm/chunk-JTGGMXB7.mjs +2 -0
  157. package/dist/esm/chunk-JTGGMXB7.mjs.map +1 -0
  158. package/dist/esm/chunk-KC64ESLO.mjs +2 -0
  159. package/dist/esm/chunk-KC64ESLO.mjs.map +1 -0
  160. package/dist/esm/chunk-KFP7MDSD.mjs +2 -0
  161. package/dist/esm/chunk-KFP7MDSD.mjs.map +1 -0
  162. package/dist/esm/chunk-KJDY66XF.mjs +2 -0
  163. package/dist/esm/chunk-KJDY66XF.mjs.map +1 -0
  164. package/dist/esm/chunk-KNLMUSIO.mjs +2 -0
  165. package/dist/esm/chunk-KNLMUSIO.mjs.map +1 -0
  166. package/dist/esm/chunk-KPESAXVI.mjs +2 -0
  167. package/dist/esm/chunk-KPESAXVI.mjs.map +1 -0
  168. package/dist/esm/chunk-KWJ6XKNF.mjs +2 -0
  169. package/dist/esm/chunk-KWJ6XKNF.mjs.map +1 -0
  170. package/dist/esm/chunk-KYWYIK5P.mjs +2 -0
  171. package/dist/esm/chunk-KYWYIK5P.mjs.map +1 -0
  172. package/dist/esm/chunk-LAXIJRYU.mjs +2 -0
  173. package/dist/esm/chunk-LAXIJRYU.mjs.map +1 -0
  174. package/dist/esm/chunk-LR65XHSF.mjs +2 -0
  175. package/dist/esm/chunk-LR65XHSF.mjs.map +1 -0
  176. package/dist/esm/chunk-LU6VS7PJ.mjs +2 -0
  177. package/dist/esm/chunk-LU6VS7PJ.mjs.map +1 -0
  178. package/dist/esm/chunk-LV33NV4J.mjs +2 -0
  179. package/dist/esm/chunk-LV33NV4J.mjs.map +1 -0
  180. package/dist/esm/chunk-MIBLZSNS.mjs +2 -0
  181. package/dist/esm/chunk-MIBLZSNS.mjs.map +1 -0
  182. package/dist/esm/chunk-N2FKVZ4D.mjs +1 -0
  183. package/dist/esm/chunk-N2FKVZ4D.mjs.map +1 -0
  184. package/dist/esm/chunk-N6XWY4UT.mjs +2 -0
  185. package/dist/esm/chunk-N6XWY4UT.mjs.map +1 -0
  186. package/dist/esm/chunk-NKTKHC3Z.mjs +2 -0
  187. package/dist/esm/chunk-NKTKHC3Z.mjs.map +1 -0
  188. package/dist/esm/chunk-O243HOP3.mjs +2 -0
  189. package/dist/esm/chunk-O243HOP3.mjs.map +1 -0
  190. package/dist/esm/chunk-PDLUCVJB.mjs +2 -0
  191. package/dist/esm/chunk-PDLUCVJB.mjs.map +1 -0
  192. package/dist/esm/chunk-PJDVHU7X.mjs +2 -0
  193. package/dist/esm/chunk-PJDVHU7X.mjs.map +1 -0
  194. package/dist/esm/chunk-R7G3CLRI.mjs +1 -0
  195. package/dist/esm/chunk-R7G3CLRI.mjs.map +1 -0
  196. package/dist/esm/chunk-RMMOF53Q.mjs +1 -0
  197. package/dist/esm/chunk-RMMOF53Q.mjs.map +1 -0
  198. package/dist/esm/chunk-SJLO3JIH.mjs +2 -0
  199. package/dist/esm/chunk-SJLO3JIH.mjs.map +1 -0
  200. package/dist/esm/chunk-TCTZCPQ6.mjs +1 -0
  201. package/dist/esm/chunk-TCTZCPQ6.mjs.map +1 -0
  202. package/dist/esm/chunk-TXUMB5ZO.mjs +2 -0
  203. package/dist/esm/chunk-TXUMB5ZO.mjs.map +1 -0
  204. package/dist/esm/chunk-TYHBYRUA.mjs +2 -0
  205. package/dist/esm/chunk-TYHBYRUA.mjs.map +1 -0
  206. package/dist/esm/chunk-UQIOMAXE.mjs +2 -0
  207. package/dist/esm/chunk-UQIOMAXE.mjs.map +1 -0
  208. package/dist/esm/chunk-UVGCVCNG.mjs +2 -0
  209. package/dist/esm/chunk-UVGCVCNG.mjs.map +1 -0
  210. package/dist/esm/chunk-UYVPNUH3.mjs +1 -0
  211. package/dist/esm/chunk-UYVPNUH3.mjs.map +1 -0
  212. package/dist/esm/chunk-V3MBJJTL.mjs +1 -0
  213. package/dist/esm/chunk-V3MBJJTL.mjs.map +1 -0
  214. package/dist/esm/chunk-V6AAQLLJ.mjs +2 -0
  215. package/dist/esm/chunk-V6AAQLLJ.mjs.map +1 -0
  216. package/dist/esm/chunk-VAGYTPSI.mjs +2 -0
  217. package/dist/esm/chunk-VAGYTPSI.mjs.map +1 -0
  218. package/dist/esm/chunk-WGXAIQ7K.mjs +2 -0
  219. package/dist/esm/chunk-WGXAIQ7K.mjs.map +1 -0
  220. package/dist/esm/chunk-WNEZCERQ.mjs +2 -0
  221. package/dist/esm/chunk-WNEZCERQ.mjs.map +1 -0
  222. package/dist/esm/chunk-WVMDCC4V.mjs +2 -0
  223. package/dist/esm/chunk-WVMDCC4V.mjs.map +1 -0
  224. package/dist/esm/chunk-XFS5O5GJ.mjs +2 -0
  225. package/dist/esm/chunk-XFS5O5GJ.mjs.map +1 -0
  226. package/dist/esm/chunk-XFSL7O6Q.mjs +2 -0
  227. package/dist/esm/chunk-XFSL7O6Q.mjs.map +1 -0
  228. package/dist/esm/chunk-XNFEUXDS.mjs +2 -0
  229. package/dist/esm/chunk-XNFEUXDS.mjs.map +1 -0
  230. package/dist/esm/chunk-YS2OX7AB.mjs +2 -0
  231. package/dist/esm/chunk-YS2OX7AB.mjs.map +1 -0
  232. package/dist/esm/chunk-Z56AKXJ7.mjs +2 -0
  233. package/dist/esm/chunk-Z56AKXJ7.mjs.map +1 -0
  234. package/dist/esm/chunk-ZT2A5ABR.mjs +2 -0
  235. package/dist/esm/chunk-ZT2A5ABR.mjs.map +1 -0
  236. package/dist/esm/chunk-ZXJ5ZBTL.mjs +2 -0
  237. package/dist/esm/chunk-ZXJ5ZBTL.mjs.map +1 -0
  238. package/dist/esm/client/core.d.ts +24 -0
  239. package/dist/esm/client/core.mjs +2 -0
  240. package/dist/esm/client/core.mjs.map +1 -0
  241. package/dist/esm/client/get.d.ts +55 -0
  242. package/dist/esm/client/get.mjs +2 -0
  243. package/dist/esm/client/get.mjs.map +1 -0
  244. package/dist/esm/client/index.d.ts +11 -0
  245. package/dist/esm/client/index.mjs +2 -0
  246. package/dist/esm/client/index.mjs.map +1 -0
  247. package/dist/esm/client/post.d.ts +60 -0
  248. package/dist/esm/client/post.mjs +2 -0
  249. package/dist/esm/client/post.mjs.map +1 -0
  250. package/dist/esm/client/types.d.ts +46 -0
  251. package/dist/esm/client/types.mjs +2 -0
  252. package/dist/esm/client/types.mjs.map +1 -0
  253. package/dist/esm/core/account.d.ts +184 -0
  254. package/dist/esm/core/account.mjs +2 -0
  255. package/dist/esm/core/account.mjs.map +1 -0
  256. package/dist/esm/core/accountAddress.d.ts +244 -0
  257. package/dist/esm/core/accountAddress.mjs +2 -0
  258. package/dist/esm/core/accountAddress.mjs.map +1 -0
  259. package/dist/esm/core/authenticationKey.d.ts +74 -0
  260. package/dist/esm/core/authenticationKey.mjs +2 -0
  261. package/dist/esm/core/authenticationKey.mjs.map +1 -0
  262. package/dist/esm/core/common.d.ts +32 -0
  263. package/dist/esm/core/common.mjs +2 -0
  264. package/dist/esm/core/common.mjs.map +1 -0
  265. package/dist/esm/core/crypto/anyPublicKey.d.ts +54 -0
  266. package/dist/esm/core/crypto/anyPublicKey.mjs +2 -0
  267. package/dist/esm/core/crypto/anyPublicKey.mjs.map +1 -0
  268. package/dist/esm/core/crypto/anySignature.d.ts +31 -0
  269. package/dist/esm/core/crypto/anySignature.mjs +2 -0
  270. package/dist/esm/core/crypto/anySignature.mjs.map +1 -0
  271. package/dist/esm/core/crypto/asymmetricCrypto.d.ts +74 -0
  272. package/dist/esm/core/crypto/asymmetricCrypto.mjs +2 -0
  273. package/dist/esm/core/crypto/asymmetricCrypto.mjs.map +1 -0
  274. package/dist/esm/core/crypto/ed25519.d.ts +173 -0
  275. package/dist/esm/core/crypto/ed25519.mjs +2 -0
  276. package/dist/esm/core/crypto/ed25519.mjs.map +1 -0
  277. package/dist/esm/core/crypto/hdKey.d.ts +65 -0
  278. package/dist/esm/core/crypto/hdKey.mjs +2 -0
  279. package/dist/esm/core/crypto/hdKey.mjs.map +1 -0
  280. package/dist/esm/core/crypto/index.d.ts +17 -0
  281. package/dist/esm/core/crypto/index.mjs +2 -0
  282. package/dist/esm/core/crypto/index.mjs.map +1 -0
  283. package/dist/esm/core/crypto/multiEd25519.d.ts +126 -0
  284. package/dist/esm/core/crypto/multiEd25519.mjs +2 -0
  285. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -0
  286. package/dist/esm/core/crypto/multiKey.d.ts +52 -0
  287. package/dist/esm/core/crypto/multiKey.mjs +2 -0
  288. package/dist/esm/core/crypto/multiKey.mjs.map +1 -0
  289. package/dist/esm/core/crypto/secp256k1.d.ts +161 -0
  290. package/dist/esm/core/crypto/secp256k1.mjs +2 -0
  291. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -0
  292. package/dist/esm/core/hex.d.ts +105 -0
  293. package/dist/esm/core/hex.mjs +2 -0
  294. package/dist/esm/core/hex.mjs.map +1 -0
  295. package/dist/esm/core/index.d.ts +21 -0
  296. package/dist/esm/core/index.mjs +2 -0
  297. package/dist/esm/core/index.mjs.map +1 -0
  298. package/dist/esm/index.d.ts +60 -5637
  299. package/dist/esm/index.mjs +1 -5444
  300. package/dist/esm/index.mjs.map +1 -1
  301. package/dist/esm/internal/account.d.ts +143 -0
  302. package/dist/esm/internal/account.mjs +2 -0
  303. package/dist/esm/internal/account.mjs.map +1 -0
  304. package/dist/esm/internal/ans.d.ts +83 -0
  305. package/dist/esm/internal/ans.mjs +2 -0
  306. package/dist/esm/internal/ans.mjs.map +1 -0
  307. package/dist/esm/internal/coin.d.ts +43 -0
  308. package/dist/esm/internal/coin.mjs +2 -0
  309. package/dist/esm/internal/coin.mjs.map +1 -0
  310. package/dist/esm/internal/digitalAsset.d.ts +118 -0
  311. package/dist/esm/internal/digitalAsset.mjs +2 -0
  312. package/dist/esm/internal/digitalAsset.mjs.map +1 -0
  313. package/dist/esm/internal/event.d.ts +45 -0
  314. package/dist/esm/internal/event.mjs +2 -0
  315. package/dist/esm/internal/event.mjs.map +1 -0
  316. package/dist/esm/internal/faucet.d.ts +29 -0
  317. package/dist/esm/internal/faucet.mjs +2 -0
  318. package/dist/esm/internal/faucet.mjs.map +1 -0
  319. package/dist/esm/internal/fungibleAsset.d.ts +38 -0
  320. package/dist/esm/internal/fungibleAsset.mjs +2 -0
  321. package/dist/esm/internal/fungibleAsset.mjs.map +1 -0
  322. package/dist/esm/internal/general.d.ts +60 -0
  323. package/dist/esm/internal/general.mjs +2 -0
  324. package/dist/esm/internal/general.mjs.map +1 -0
  325. package/dist/esm/internal/staking.d.ts +38 -0
  326. package/dist/esm/internal/staking.mjs +2 -0
  327. package/dist/esm/internal/staking.mjs.map +1 -0
  328. package/dist/esm/internal/transaction.d.ts +57 -0
  329. package/dist/esm/internal/transaction.mjs +2 -0
  330. package/dist/esm/internal/transaction.mjs.map +1 -0
  331. package/dist/esm/internal/transactionSubmission.d.ts +148 -0
  332. package/dist/esm/internal/transactionSubmission.mjs +2 -0
  333. package/dist/esm/internal/transactionSubmission.mjs.map +1 -0
  334. package/dist/esm/transactions/authenticator/account.d.ts +79 -0
  335. package/dist/esm/transactions/authenticator/account.mjs +2 -0
  336. package/dist/esm/transactions/authenticator/account.mjs.map +1 -0
  337. package/dist/esm/transactions/authenticator/index.d.ts +19 -0
  338. package/dist/esm/transactions/authenticator/index.mjs +2 -0
  339. package/dist/esm/transactions/authenticator/index.mjs.map +1 -0
  340. package/dist/esm/transactions/authenticator/transaction.d.ts +105 -0
  341. package/dist/esm/transactions/authenticator/transaction.mjs +2 -0
  342. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -0
  343. package/dist/esm/transactions/index.d.ts +39 -0
  344. package/dist/esm/transactions/index.mjs +2 -0
  345. package/dist/esm/transactions/index.mjs.map +1 -0
  346. package/dist/esm/transactions/instances/chainId.d.ts +21 -0
  347. package/dist/esm/transactions/instances/chainId.mjs +2 -0
  348. package/dist/esm/transactions/instances/chainId.mjs.map +1 -0
  349. package/dist/esm/transactions/instances/identifier.d.ts +23 -0
  350. package/dist/esm/transactions/instances/identifier.mjs +2 -0
  351. package/dist/esm/transactions/instances/identifier.mjs.map +1 -0
  352. package/dist/esm/transactions/instances/index.d.ts +29 -0
  353. package/dist/esm/transactions/instances/index.mjs +2 -0
  354. package/dist/esm/transactions/instances/index.mjs.map +1 -0
  355. package/dist/esm/transactions/instances/moduleId.d.ts +37 -0
  356. package/dist/esm/transactions/instances/moduleId.mjs +2 -0
  357. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -0
  358. package/dist/esm/transactions/instances/rawTransaction.d.ts +98 -0
  359. package/dist/esm/transactions/instances/rawTransaction.mjs +2 -0
  360. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -0
  361. package/dist/esm/transactions/instances/rotationProofChallenge.d.ts +37 -0
  362. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +2 -0
  363. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -0
  364. package/dist/esm/transactions/instances/signedTransaction.d.ts +46 -0
  365. package/dist/esm/transactions/instances/signedTransaction.mjs +2 -0
  366. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -0
  367. package/dist/esm/transactions/instances/transactionArgument.d.ts +40 -0
  368. package/dist/esm/transactions/instances/transactionArgument.mjs +2 -0
  369. package/dist/esm/transactions/instances/transactionArgument.mjs.map +1 -0
  370. package/dist/esm/transactions/instances/transactionPayload.d.ts +211 -0
  371. package/dist/esm/transactions/instances/transactionPayload.mjs +2 -0
  372. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -0
  373. package/dist/esm/transactions/transactionBuilder/helpers.d.ts +63 -0
  374. package/dist/esm/transactions/transactionBuilder/helpers.mjs +2 -0
  375. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -0
  376. package/dist/esm/transactions/transactionBuilder/index.d.ts +35 -0
  377. package/dist/esm/transactions/transactionBuilder/index.mjs +2 -0
  378. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -0
  379. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.ts +54 -0
  380. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +2 -0
  381. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -0
  382. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.ts +128 -0
  383. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +2 -0
  384. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -0
  385. package/dist/esm/transactions/typeTag/index.d.ts +127 -0
  386. package/dist/esm/transactions/typeTag/index.mjs +2 -0
  387. package/dist/esm/transactions/typeTag/index.mjs.map +1 -0
  388. package/dist/esm/transactions/typeTag/parser.d.ts +47 -0
  389. package/dist/esm/transactions/typeTag/parser.mjs +2 -0
  390. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -0
  391. package/dist/esm/transactions/types.d.ts +253 -0
  392. package/dist/esm/transactions/types.mjs +2 -0
  393. package/dist/esm/transactions/types.mjs.map +1 -0
  394. package/dist/esm/types/generated/operations.d.ts +604 -0
  395. package/dist/esm/types/generated/operations.mjs +1 -0
  396. package/dist/esm/types/generated/operations.mjs.map +1 -0
  397. package/dist/esm/types/generated/queries.d.ts +55 -0
  398. package/dist/esm/types/generated/queries.mjs +2 -0
  399. package/dist/esm/types/generated/queries.mjs.map +1 -0
  400. package/dist/esm/types/generated/types.d.ts +9458 -0
  401. package/dist/esm/types/generated/types.mjs +2 -0
  402. package/dist/esm/types/generated/types.mjs.map +1 -0
  403. package/dist/{types → esm/types}/index.d.ts +19 -451
  404. package/dist/esm/types/index.mjs +2 -0
  405. package/dist/esm/types/index.mjs.map +1 -0
  406. package/dist/esm/types/indexer.d.ts +62 -0
  407. package/dist/esm/types/indexer.mjs +2 -0
  408. package/dist/esm/types/indexer.mjs.map +1 -0
  409. package/dist/esm/utils/apiEndpoints.d.ts +14 -0
  410. package/dist/esm/utils/apiEndpoints.mjs +2 -0
  411. package/dist/esm/utils/apiEndpoints.mjs.map +1 -0
  412. package/dist/esm/utils/const.d.ts +42 -0
  413. package/dist/esm/utils/const.mjs +2 -0
  414. package/dist/esm/utils/const.mjs.map +1 -0
  415. package/dist/esm/utils/helpers.d.ts +7 -0
  416. package/dist/esm/utils/helpers.mjs +2 -0
  417. package/dist/esm/utils/helpers.mjs.map +1 -0
  418. package/dist/esm/utils/memoize.d.ts +20 -0
  419. package/dist/esm/utils/memoize.mjs +2 -0
  420. package/dist/esm/utils/memoize.mjs.map +1 -0
  421. package/dist/esm/version.d.ts +8 -0
  422. package/dist/esm/version.mjs +2 -0
  423. package/dist/esm/version.mjs.map +1 -0
  424. package/package.json +17 -13
  425. package/src/api/account.ts +17 -18
  426. package/src/api/ans.ts +58 -0
  427. package/src/api/aptos.ts +7 -1
  428. package/src/api/coin.ts +3 -3
  429. package/src/api/digitalAsset.ts +9 -8
  430. package/src/api/event.ts +4 -3
  431. package/src/api/faucet.ts +3 -2
  432. package/src/api/general.ts +2 -2
  433. package/src/api/staking.ts +5 -4
  434. package/src/api/transactionSubmission.ts +41 -20
  435. package/src/bcs/deserializer.ts +4 -4
  436. package/src/bcs/serializable/moveStructs.ts +13 -13
  437. package/src/bcs/serializer.ts +4 -4
  438. package/src/client/core.ts +18 -8
  439. package/src/core/account.ts +90 -33
  440. package/src/core/accountAddress.ts +34 -30
  441. package/src/core/authenticationKey.ts +11 -9
  442. package/src/core/crypto/ed25519.ts +48 -1
  443. package/src/core/crypto/hdKey.ts +105 -0
  444. package/src/core/crypto/index.ts +1 -0
  445. package/src/core/crypto/secp256k1.ts +36 -0
  446. package/src/index.ts +0 -1
  447. package/src/internal/account.ts +80 -58
  448. package/src/internal/ans.ts +175 -0
  449. package/src/internal/coin.ts +5 -5
  450. package/src/internal/digitalAsset.ts +16 -17
  451. package/src/internal/event.ts +8 -8
  452. package/src/internal/faucet.ts +4 -4
  453. package/src/internal/general.ts +3 -3
  454. package/src/internal/queries/getEvents.graphql +1 -0
  455. package/src/internal/staking.ts +8 -8
  456. package/src/internal/transactionSubmission.ts +78 -19
  457. package/src/transactions/instances/index.ts +1 -0
  458. package/src/transactions/instances/moduleId.ts +1 -1
  459. package/src/transactions/instances/rotationProofChallenge.ts +58 -0
  460. package/src/transactions/transactionBuilder/helpers.ts +5 -1
  461. package/src/transactions/transactionBuilder/remoteAbi.ts +4 -4
  462. package/src/transactions/transactionBuilder/transactionBuilder.ts +31 -49
  463. package/src/transactions/typeTag/index.ts +10 -10
  464. package/src/transactions/typeTag/parser.ts +1 -1
  465. package/src/transactions/types.ts +31 -20
  466. package/src/types/generated/operations.ts +19 -18
  467. package/src/types/generated/queries.ts +20 -19
  468. package/src/types/generated/types.ts +6 -0
  469. package/src/types/index.ts +15 -18
  470. package/src/utils/apiEndpoints.ts +8 -0
  471. package/src/version.ts +1 -1
  472. package/dist/cjs/index.js +0 -5631
  473. package/dist/cjs/index.js.map +0 -1
  474. package/dist/types/index.js +0 -176
  475. package/dist/types/index.js.map +0 -1
  476. package/src/utils/hdKey.ts +0 -113
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { AptosConfig } from "./aptosConfig";
5
- import { Account } from "../core";
5
+ import { Account, AccountAddressInput, PrivateKey } from "../core";
6
6
  import { AccountAuthenticator } from "../transactions/authenticator/account";
7
7
  import {
8
8
  AnyRawTransaction,
@@ -15,11 +15,13 @@ import {
15
15
  InputSingleSignerTransaction,
16
16
  InputSimulateTransactionData,
17
17
  InputGenerateTransactionOptions,
18
+ InputSubmitTransactionData,
18
19
  } from "../transactions/types";
19
- import { UserTransactionResponse, PendingTransactionResponse, HexInput } from "../types";
20
+ import { UserTransactionResponse, PendingTransactionResponse, HexInput, TransactionResponse } from "../types";
20
21
  import {
21
22
  generateTransaction,
22
23
  publicPackageTransaction,
24
+ rotateAuthKey,
23
25
  signAndSubmitTransaction,
24
26
  signTransaction,
25
27
  simulateTransaction,
@@ -47,7 +49,7 @@ export class TransactionSubmission {
47
49
  /**
48
50
  * Generates any transaction by passing in the required arguments
49
51
  *
50
- * @param args.sender The transaction sender's account address as a HexInput
52
+ * @param args.sender The transaction sender's account address as a AccountAddressInput
51
53
  * @param args.data EntryFunctionData | ScriptData | MultiSigData
52
54
  * @param args.feePayerAddress optional. For a fee payer (aka sponsored) transaction
53
55
  * @param args.secondarySignerAddresses optional. For a multi-agent or fee payer (aka sponsored) transactions
@@ -75,10 +77,10 @@ export class TransactionSubmission {
75
77
  * }
76
78
  * ```
77
79
  *
78
- * @return A raw transaction type (note that it holds the raw transaction as a bcs serialized data)
80
+ * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses
79
81
  * ```
80
82
  * {
81
- * rawTransaction: Uint8Array,
83
+ * rawTransaction: RawTransaction,
82
84
  * secondarySignerAddresses? : Array<AccountAddress>,
83
85
  * feePayerAddress?: AccountAddress
84
86
  * }
@@ -92,10 +94,11 @@ export class TransactionSubmission {
92
94
  * Sign a transaction that can later be submitted to chain
93
95
  *
94
96
  * @param args.signer The signer account to sign the transaction
95
- * @param args.transaction A raw transaction type (note that it holds the raw transaction as a bcs serialized data)
97
+ * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
98
+ * @param args.asFeePayer optional. If the signer is also the fee payer
96
99
  * ```
97
100
  * {
98
- * rawTransaction: Uint8Array,
101
+ * rawTransaction: RawTransaction,
99
102
  * secondarySignerAddresses? : Array<AccountAddress>,
100
103
  * feePayerAddress?: AccountAddress
101
104
  * }
@@ -104,8 +107,19 @@ export class TransactionSubmission {
104
107
  * @return The signer AccountAuthenticator
105
108
  */
106
109
  /* eslint-disable class-methods-use-this */
107
- signTransaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
108
- return signTransaction({ ...args });
110
+ signTransaction(args: {
111
+ signer: Account;
112
+ transaction: AnyRawTransaction;
113
+ asFeePayer?: boolean;
114
+ }): AccountAuthenticator {
115
+ const { signer, transaction, asFeePayer } = args;
116
+ if (asFeePayer) {
117
+ transaction.feePayerAddress = signer.accountAddress;
118
+ }
119
+ return signTransaction({
120
+ signer,
121
+ transaction,
122
+ });
109
123
  }
110
124
 
111
125
  /**
@@ -130,14 +144,7 @@ export class TransactionSubmission {
130
144
  *
131
145
  * @return PendingTransactionResponse
132
146
  */
133
- async submitTransaction(args: {
134
- transaction: AnyRawTransaction;
135
- senderAuthenticator: AccountAuthenticator;
136
- secondarySignerAuthenticators?: {
137
- feePayerAuthenticator?: AccountAuthenticator;
138
- additionalSignersAuthenticators?: Array<AccountAuthenticator>;
139
- };
140
- }): Promise<PendingTransactionResponse> {
147
+ async submitTransaction(args: InputSubmitTransactionData): Promise<PendingTransactionResponse> {
141
148
  return submitTransaction({ aptosConfig: this.config, ...args });
142
149
  }
143
150
 
@@ -145,10 +152,10 @@ export class TransactionSubmission {
145
152
  * Sign and submit a single signer transaction to chain
146
153
  *
147
154
  * @param args.signer The signer account to sign the transaction
148
- * @param args.transaction A raw transaction type (note that it holds the raw transaction as a bcs serialized data)
155
+ * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
149
156
  * ```
150
157
  * {
151
- * rawTransaction: Uint8Array,
158
+ * rawTransaction: RawTransaction,
152
159
  * secondarySignerAddresses? : Array<AccountAddress>,
153
160
  * feePayerAddress?: AccountAddress
154
161
  * }
@@ -182,11 +189,25 @@ export class TransactionSubmission {
182
189
  * @returns A SingleSignerTransaction that can be simulated or submitted to chain
183
190
  */
184
191
  async publishPackageTransaction(args: {
185
- account: HexInput;
192
+ account: AccountAddressInput;
186
193
  metadataBytes: HexInput;
187
194
  moduleBytecode: Array<HexInput>;
188
195
  options?: InputGenerateTransactionOptions;
189
196
  }): Promise<InputSingleSignerTransaction> {
190
197
  return publicPackageTransaction({ aptosConfig: this.config, ...args });
191
198
  }
199
+
200
+ /**
201
+ * Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for
202
+ * the account.
203
+ * Note: Only legacy Ed25519 scheme is supported for now.
204
+ * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}
205
+ * @param args.fromAccount The account to rotate the auth key for
206
+ * @param args.toNewPrivateKey The new private key to rotate to
207
+ *
208
+ * @returns PendingTransactionResponse
209
+ */
210
+ async rotateAuthKey(args: { fromAccount: Account; toNewPrivateKey: PrivateKey }): Promise<TransactionResponse> {
211
+ return rotateAuthKey({ aptosConfig: this.config, ...args });
212
+ }
192
213
  }
@@ -222,10 +222,10 @@ export class Deserializer {
222
222
  * @example
223
223
  * // serialize a vector of addresses
224
224
  * const addresses = new Array<AccountAddress>(
225
- * AccountAddress.fromHexInputRelaxed("0x1"),
226
- * AccountAddress.fromHexInputRelaxed("0x2"),
227
- * AccountAddress.fromHexInputRelaxed("0xa"),
228
- * AccountAddress.fromHexInputRelaxed("0xb"),
225
+ * AccountAddress.fromRelaxed("0x1"),
226
+ * AccountAddress.fromRelaxed("0x2"),
227
+ * AccountAddress.fromRelaxed("0xa"),
228
+ * AccountAddress.fromRelaxed("0xb"),
229
229
  * );
230
230
  * const serializer = new Serializer();
231
231
  * serializer.serializeVector(addresses);
@@ -42,11 +42,6 @@ import { EntryFunctionArgument, TransactionArgument } from "../../transactions/i
42
42
  * const vecOfStrings = new MoveVector([new MoveString("hello"), new MoveString("world")]);
43
43
  * const vecOfStrings2 = MoveVector.MoveString(["hello", "world"]);
44
44
  *
45
- * // where MySerializableStruct is a class you've made that implements Serializable
46
- * const vecOfSerializableValues = new MoveVector<MySerializableStruct>([
47
- * new MySerializableStruct("hello", "world"),
48
- * new MySerializableStruct("foo", "bar"),
49
- * ]);
50
45
  * @params
51
46
  * values: an Array<T> of values where T is a class that implements Serializable
52
47
  * @returns a `MoveVector<T>` with the values `values`
@@ -73,9 +68,11 @@ export class MoveVector<T extends Serializable & EntryFunctionArgument>
73
68
  */
74
69
  serializeForScriptFunction(serializer: Serializer): void {
75
70
  // runtime check to ensure that you can't serialize anything other than vector<u8>
76
- // TODO: consider adding support for MoveString later?
77
71
  const isU8 = this.values[0] instanceof U8;
78
- if (!isU8) {
72
+ // if the inner array is length 0, we can't check the type because it has no instance, so we assume it's a u8
73
+ // it may not be, but we don't care because regardless of a vector's type,
74
+ // a zero-length vector is serialized to a single byte value: 0
75
+ if (!isU8 && this.values[0] !== undefined) {
79
76
  throw new Error("Script function arguments only accept u8 vectors");
80
77
  }
81
78
  serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8Vector);
@@ -172,7 +169,7 @@ export class MoveVector<T extends Serializable & EntryFunctionArgument>
172
169
  *
173
170
  * @example
174
171
  * const v = MoveVector.Bool([true, false, true, false]);
175
- * @params values: an array of `numbers` to convert to Bools
172
+ * @params values: an array of `bools` to convert to Bools
176
173
  * @returns a `MoveVector<Bool>`
177
174
  */
178
175
  static Bool(values: Array<boolean>): MoveVector<Bool> {
@@ -184,7 +181,7 @@ export class MoveVector<T extends Serializable & EntryFunctionArgument>
184
181
  *
185
182
  * @example
186
183
  * const v = MoveVector.MoveString(["hello", "world"]);
187
- * @params values: an array of `numbers` to convert to MoveStrings
184
+ * @params values: an array of `strings` to convert to MoveStrings
188
185
  * @returns a `MoveVector<MoveString>`
189
186
  */
190
187
  static MoveString(values: Array<string>): MoveVector<MoveString> {
@@ -202,8 +199,9 @@ export class MoveVector<T extends Serializable & EntryFunctionArgument>
202
199
  *
203
200
  * NOTE: This will not work with types that aren't of the Serializable class.
204
201
  *
205
- * If you want to use types that merely implement Deserializable,
206
- * please use the deserializeVector function in the Deserializer class.
202
+ * If you're looking for a more flexible deserialization function, you can use the deserializeVector function
203
+ * in the Deserializer class.
204
+ *
207
205
  * @example
208
206
  * const vec = MoveVector.deserialize(deserializer, U64);
209
207
  * @params deserializer: the Deserializer instance to use, with bytes loaded into it already.
@@ -242,8 +240,10 @@ export class MoveString extends Serializable implements TransactionArgument {
242
240
  }
243
241
 
244
242
  serializeForScriptFunction(serializer: Serializer): void {
245
- // serialize the string, load it into a vector<u8> and serialize it as a script vector<u8> argument
246
- const vectorU8 = MoveVector.U8(this.bcsToBytes());
243
+ // Serialize the string as a fixed byte string, i.e., without the length prefix
244
+ const fixedStringBytes = this.bcsToBytes().slice(1);
245
+ // Put those bytes into a vector<u8> and serialize it as a script function argument
246
+ const vectorU8 = MoveVector.U8(fixedStringBytes);
247
247
  vectorU8.serializeForScriptFunction(serializer);
248
248
  }
249
249
 
@@ -298,10 +298,10 @@ export class Serializer {
298
298
  * @param values The array of BCS Serializable values
299
299
  * @example
300
300
  * const addresses = new Array<AccountAddress>(
301
- * AccountAddress.fromHexInputRelaxed("0x1"),
302
- * AccountAddress.fromHexInputRelaxed("0x2"),
303
- * AccountAddress.fromHexInputRelaxed("0xa"),
304
- * AccountAddress.fromHexInputRelaxed("0xb"),
301
+ * AccountAddress.fromRelaxed("0x1"),
302
+ * AccountAddress.fromRelaxed("0x2"),
303
+ * AccountAddress.fromRelaxed("0xa"),
304
+ * AccountAddress.fromRelaxed("0xb"),
305
305
  * );
306
306
  * const serializer = new Serializer();
307
307
  * serializer.serializeVector(addresses);
@@ -32,8 +32,11 @@ export async function request<Req, Res>(options: ClientRequest<Req>, client: Cli
32
32
  "content-type": contentType ?? MimeType.JSON,
33
33
  };
34
34
 
35
- if (overrides?.TOKEN) {
36
- headers.Authorization = `Bearer ${overrides?.TOKEN}`;
35
+ // TODO - auth token is being used only for faucet, it breaks full node requests.
36
+ // Find a more sophisticated way than that but without the need to add the
37
+ // auth_token on every `aptos.fundAccount()` call
38
+ if (overrides?.AUTH_TOKEN && url.includes("faucet")) {
39
+ headers.Authorization = `Bearer ${overrides?.AUTH_TOKEN}`;
37
40
  }
38
41
 
39
42
  /*
@@ -94,11 +97,18 @@ export async function aptosRequest<Req, Res>(
94
97
  return result;
95
98
  }
96
99
 
97
- const errorMessage = errors[result.status];
100
+ let errorMessage: string;
98
101
 
99
- throw new AptosApiError(
100
- options,
101
- result,
102
- errorMessage ?? `Unhandled Error ${response.status} : ${response.statusText}`,
103
- );
102
+ // If it is the shape of an AptosApiError, convert it properly
103
+ if ("message" in response.data && "error_code" in response.data) {
104
+ errorMessage = JSON.stringify(response.data);
105
+ } else if (result.status in errors) {
106
+ // If it's not an API type, it must come form infra, these are prehandled
107
+ errorMessage = errors[result.status];
108
+ } else {
109
+ // Everything else is unhandled
110
+ errorMessage = `Unhandled Error ${response.status} : ${response.statusText}`;
111
+ }
112
+
113
+ throw new AptosApiError(options, result, errorMessage);
104
114
  }
@@ -9,7 +9,6 @@ import { MultiEd25519PublicKey } from "./crypto/multiEd25519";
9
9
  import { Secp256k1PrivateKey, Secp256k1PublicKey } from "./crypto/secp256k1";
10
10
  import { Hex } from "./hex";
11
11
  import { GenerateAccount, HexInput, SigningScheme, SigningSchemeInput } from "../types";
12
- import { derivePrivateKeyFromMnemonic, KeyType } from "../utils/hdKey";
13
12
  import { AnyPublicKey } from "./crypto/anyPublicKey";
14
13
 
15
14
  /**
@@ -26,11 +25,14 @@ import { AnyPublicKey } from "./crypto/anyPublicKey";
26
25
  * `SingleSender` supports `ED25519` and `Secp256k1`, and `MultiSender` supports
27
26
  * `MultiED25519`.
28
27
  *
29
- * In TypeScript SDK, we support all of these options
30
- * @generate default to generate Unified keys, with an optional `legacy` boolean argument
31
- * that lets you generate new keys conforming to the Legacy authentication.
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
+ *
32
33
  * @fromPrivateKey derives an account by a provided private key and address, with an optional
33
- * `legacy` boolean argument that lets you generate new keys conforming to the Legacy authentication.
34
+ * `legacy` boolean argument that lets you generate new keys conforming to the Unified authentication.
35
+ *
34
36
  * @fromDerivationPath derives an account with bip44 path and mnemonics,
35
37
  *
36
38
  */
@@ -70,13 +72,14 @@ export class Account {
70
72
  */
71
73
  private constructor(args: { privateKey: PrivateKey; address: AccountAddress; legacy?: boolean }) {
72
74
  const { privateKey, address, legacy } = args;
75
+ const useLegacy = legacy ?? true;
73
76
 
74
77
  // Derive the public key from the private key
75
78
  this.publicKey = privateKey.publicKey();
76
79
 
77
80
  // Derive the signing scheme from the public key
78
81
  if (this.publicKey instanceof Ed25519PublicKey) {
79
- if (legacy) {
82
+ if (useLegacy) {
80
83
  this.signingScheme = SigningScheme.Ed25519;
81
84
  } else {
82
85
  this.publicKey = new AnyPublicKey(this.publicKey);
@@ -97,7 +100,8 @@ export class Account {
97
100
 
98
101
  /**
99
102
  * Derives an account with random private key and address.
100
- * Default generation is using the Unified flow with ED25519 key
103
+ *
104
+ * Default generation is using the Legacy ED25519 key
101
105
  *
102
106
  * @param args optional. Unify GenerateAccount type for Legacy and Unified keys
103
107
  *
@@ -123,37 +127,75 @@ export class Account {
123
127
  * @returns Account with the given signing scheme
124
128
  */
125
129
  static generate(args?: GenerateAccount): Account {
130
+ const useLegacy = args?.legacy ?? true;
131
+
126
132
  let privateKey: PrivateKey;
133
+ let publicKey: PublicKey;
127
134
 
128
135
  switch (args?.scheme) {
129
136
  case SigningSchemeInput.Secp256k1Ecdsa:
130
137
  privateKey = Secp256k1PrivateKey.generate();
138
+ publicKey = new AnyPublicKey(privateKey.publicKey());
131
139
  break;
132
140
  default:
133
141
  privateKey = Ed25519PrivateKey.generate();
142
+ if (useLegacy === false) {
143
+ publicKey = new AnyPublicKey(privateKey.publicKey());
144
+ } else {
145
+ publicKey = privateKey.publicKey();
146
+ }
134
147
  }
148
+ const authKey = AuthenticationKey.fromPublicKey({ publicKey });
149
+
150
+ const address = authKey.derivedAddress();
151
+ return new Account({ privateKey, address, legacy: args?.legacy });
152
+ }
135
153
 
136
- let publicKey = privateKey.publicKey();
137
- if (!args?.legacy) {
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
138
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}`);
139
184
  }
140
185
 
141
- const address = new AccountAddress({
142
- data: Account.authKey({
143
- publicKey,
144
- }).toUint8Array(),
145
- });
146
- return new Account({ privateKey, address, legacy: args?.legacy });
186
+ const authKey = AuthenticationKey.fromPublicKey({ publicKey });
187
+ const address = authKey.derivedAddress();
188
+ return new Account({ privateKey, address, legacy: useLegacy });
147
189
  }
148
190
 
149
191
  /**
150
192
  * Instantiates an account given a private key and a specified account address.
151
193
  * This is primarily used to instantiate an `Account` that has had its authentication key rotated.
152
194
  *
153
- * @param privateKey PrivateKey - private key of the account
154
- * @param address The account address
155
- * @param args.legacy optional. If set to true, the keypair authentication keys will be derived with a Legacy scheme.
156
- * Defaults to deriving an authentication key with a Unified scheme
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
157
199
  *
158
200
  * @returns Account
159
201
  */
@@ -169,19 +211,35 @@ export class Account {
169
211
  /**
170
212
  * Derives an account with bip44 path and mnemonics,
171
213
  *
172
- * @param args.path the BIP44 derive path (e.g. m/44'/637'/0'/0'/0')
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
173
217
  * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
174
218
  * @param args.mnemonic the mnemonic seed phrase of the account
175
- * @returns AptosAccount
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
176
223
  */
177
- static fromDerivationPath(args: { path: string; mnemonic: string }): Account {
178
- const { path, mnemonic } = args;
179
- const { key } = derivePrivateKeyFromMnemonic(KeyType.ED25519, path, mnemonic);
180
- const privateKey = new Ed25519PrivateKey(key);
181
- const publicKey = privateKey.publicKey();
182
- const authKey = Account.authKey({ publicKey });
183
- const address = new AccountAddress({ data: authKey.toUint8Array() });
184
- return new Account({ privateKey, address, legacy: true });
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 });
185
243
  }
186
244
 
187
245
  /**
@@ -190,12 +248,11 @@ export class Account {
190
248
  * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}
191
249
  *
192
250
  * @param args.publicKey PublicKey - public key of the account
193
- * @returns Authentication key for the associated account
251
+ * @returns The authentication key for the associated account
194
252
  */
195
- static authKey(args: { publicKey: PublicKey }): Hex {
253
+ static authKey(args: { publicKey: PublicKey }): AuthenticationKey {
196
254
  const { publicKey } = args;
197
- const authKey = AuthenticationKey.fromPublicKey({ publicKey });
198
- return authKey.data;
255
+ return AuthenticationKey.fromPublicKey({ publicKey });
199
256
  }
200
257
 
201
258
  /**
@@ -21,6 +21,8 @@ export enum AddressInvalidReason {
21
21
  INVALID_PADDING_ZEROES = "INVALID_PADDING_ZEROES",
22
22
  }
23
23
 
24
+ export type AccountAddressInput = HexInput | AccountAddress;
25
+
24
26
  /**
25
27
  * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction
26
28
  * hashes, use the Hex class.
@@ -53,30 +55,30 @@ export class AccountAddress extends Serializable implements TransactionArgument
53
55
  */
54
56
  static readonly LONG_STRING_LENGTH: number = 64;
55
57
 
56
- static ZERO: AccountAddress = AccountAddress.fromString("0x0");
58
+ static ZERO: AccountAddress = AccountAddress.from("0x0");
57
59
 
58
- static ONE: AccountAddress = AccountAddress.fromString("0x1");
60
+ static ONE: AccountAddress = AccountAddress.from("0x1");
59
61
 
60
- static TWO: AccountAddress = AccountAddress.fromString("0x2");
62
+ static TWO: AccountAddress = AccountAddress.from("0x2");
61
63
 
62
- static THREE: AccountAddress = AccountAddress.fromString("0x3");
64
+ static THREE: AccountAddress = AccountAddress.from("0x3");
63
65
 
64
- static FOUR: AccountAddress = AccountAddress.fromString("0x4");
66
+ static FOUR: AccountAddress = AccountAddress.from("0x4");
65
67
 
66
68
  /**
67
69
  * Creates an instance of AccountAddress from a Uint8Array.
68
70
  *
69
71
  * @param args.data A Uint8Array representing an account address.
70
72
  */
71
- constructor(args: { data: Uint8Array }) {
73
+ constructor(input: Uint8Array) {
72
74
  super();
73
- if (args.data.length !== AccountAddress.LENGTH) {
75
+ if (input.length !== AccountAddress.LENGTH) {
74
76
  throw new ParsingError(
75
77
  "AccountAddress data should be exactly 32 bytes long",
76
78
  AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,
77
79
  );
78
80
  }
79
- this.data = args.data;
81
+ this.data = input;
80
82
  }
81
83
 
82
84
  /**
@@ -207,7 +209,7 @@ export class AccountAddress extends Serializable implements TransactionArgument
207
209
  */
208
210
  static deserialize(deserializer: Deserializer): AccountAddress {
209
211
  const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);
210
- return new AccountAddress({ data: bytes });
212
+ return new AccountAddress(bytes);
211
213
  }
212
214
 
213
215
  // ===
@@ -331,37 +333,39 @@ export class AccountAddress extends Serializable implements TransactionArgument
331
333
  throw new ParsingError(`Hex characters are invalid: ${error.message}`, AddressInvalidReason.INVALID_HEX_CHARS);
332
334
  }
333
335
 
334
- return new AccountAddress({ data: addressBytes });
336
+ return new AccountAddress(addressBytes);
335
337
  }
336
338
 
337
339
  /**
338
- * Convenience method for creating an AccountAddress from HexInput. For
339
- * more information on how this works, see the constructor and fromString.
340
- *
341
- * @param input A hex string or Uint8Array representing an account address.
340
+ * Convenience method for creating an AccountAddress from all known inputs.
342
341
  *
343
- * @returns An instance of AccountAddress.
342
+ * This handles, Uint8array, string, and AccountAddress itself
343
+ * @param input
344
344
  */
345
- static fromHexInput(input: HexInput): AccountAddress {
345
+ static fromRelaxed(input: AccountAddressInput): AccountAddress {
346
+ if (input instanceof AccountAddress) {
347
+ return input;
348
+ }
346
349
  if (input instanceof Uint8Array) {
347
- return new AccountAddress({ data: input });
350
+ return new AccountAddress(input);
348
351
  }
349
- return AccountAddress.fromString(input);
352
+ return AccountAddress.fromStringRelaxed(input);
350
353
  }
351
354
 
352
355
  /**
353
- * Convenience method for creating an AccountAddress from HexInput. For
354
- * more information on how this works, see the constructor and fromStringRelaxed.
356
+ * Convenience method for creating an AccountAddress from all known inputs.
355
357
  *
356
- * @param hexInput A hex string or Uint8Array representing an account address.
357
- *
358
- * @returns An instance of AccountAddress.
358
+ * This handles, Uint8array, string, and AccountAddress itself
359
+ * @param input
359
360
  */
360
- static fromHexInputRelaxed(hexInput: HexInput): AccountAddress {
361
- if (hexInput instanceof Uint8Array) {
362
- return new AccountAddress({ data: hexInput });
361
+ static from(input: AccountAddressInput): AccountAddress {
362
+ if (input instanceof AccountAddress) {
363
+ return input;
363
364
  }
364
- return AccountAddress.fromStringRelaxed(hexInput);
365
+ if (input instanceof Uint8Array) {
366
+ return new AccountAddress(input);
367
+ }
368
+ return AccountAddress.fromString(input);
365
369
  }
366
370
 
367
371
  // ===
@@ -377,12 +381,12 @@ export class AccountAddress extends Serializable implements TransactionArgument
377
381
  * @returns valid = true if the string is valid, valid = false if not. If the string
378
382
  * is not valid, invalidReason will be set explaining why it is invalid.
379
383
  */
380
- static isValid(args: { input: string; relaxed?: boolean }): ParsingResult<AddressInvalidReason> {
384
+ static isValid(args: { input: AccountAddressInput; relaxed?: boolean }): ParsingResult<AddressInvalidReason> {
381
385
  try {
382
386
  if (args.relaxed) {
383
- AccountAddress.fromStringRelaxed(args.input);
387
+ AccountAddress.fromRelaxed(args.input);
384
388
  } else {
385
- AccountAddress.fromString(args.input);
389
+ AccountAddress.from(args.input);
386
390
  }
387
391
  return { valid: true };
388
392
  } catch (e) {
@@ -18,13 +18,13 @@ import { Deserializer } from "../bcs/deserializer";
18
18
  * their private key(s) associated with the account without changing the address that hosts their account.
19
19
  * @see {@link https://aptos.dev/concepts/accounts | Account Basics}
20
20
  *
21
- * Note: AuthenticationKey only supports Ed25519 and MultiEd25519 public keys for now.
22
- *
23
21
  * Account addresses can be derived from AuthenticationKey
24
22
  */
25
23
  export class AuthenticationKey extends Serializable {
26
24
  /**
27
25
  * An authentication key is always a SHA3-256 hash of data, and is always 32 bytes.
26
+ *
27
+ * The data to hash depends on the underlying public key type and the derivation scheme.
28
28
  */
29
29
  static readonly LENGTH: number = 32;
30
30
 
@@ -66,10 +66,11 @@ export class AuthenticationKey extends Serializable {
66
66
  }
67
67
 
68
68
  /**
69
- * Creates an AuthenticationKey from seed bytes and a scheme
69
+ * Derives an AuthenticationKey from the public key seed bytes and an explicit derivation scheme.
70
+ *
71
+ * This facilitates targeting a specific scheme for deriving an authentication key from a public key.
70
72
  *
71
- * This allows for the creation of AuthenticationKeys that are not derived from Public Keys directly
72
- * @param args
73
+ * @param args - the public key and scheme to use for the derivation
73
74
  */
74
75
  public static fromPublicKeyAndScheme(args: { publicKey: PublicKey; scheme: AuthenticationKeyScheme }) {
75
76
  const { publicKey, scheme } = args;
@@ -102,7 +103,8 @@ export class AuthenticationKey extends Serializable {
102
103
  }
103
104
 
104
105
  /**
105
- * Converts a PublicKey(s) to AuthenticationKey
106
+ * Converts a PublicKey(s) to an AuthenticationKey, using the derivation scheme inferred from the
107
+ * instance of the PublicKey type passed in.
106
108
  *
107
109
  * @param args.publicKey
108
110
  * @returns AuthenticationKey
@@ -129,12 +131,12 @@ export class AuthenticationKey extends Serializable {
129
131
  }
130
132
 
131
133
  /**
132
- * Derives an account address from AuthenticationKey. Since current AccountAddress is 32 bytes,
133
- * AuthenticationKey bytes are directly translated to AccountAddress.
134
+ * Derives an account address from an AuthenticationKey. Since an AccountAddress is also 32 bytes,
135
+ * the AuthenticationKey bytes are directly translated to an AccountAddress.
134
136
  *
135
137
  * @returns AccountAddress
136
138
  */
137
139
  derivedAddress(): AccountAddress {
138
- return new AccountAddress({ data: this.data.toUint8Array() });
140
+ return new AccountAddress(this.data.toUint8Array());
139
141
  }
140
142
  }