@aptos-labs/ts-sdk 0.0.7 → 0.0.8

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 (423) hide show
  1. package/README.md +17 -1
  2. package/dist/browser/index.d.ts +798 -446
  3. package/dist/browser/index.global.js +30 -30
  4. package/dist/browser/index.global.js.map +1 -1
  5. package/dist/common/index.d.ts +798 -446
  6. package/dist/common/index.js +29 -29
  7. package/dist/common/index.js.map +1 -1
  8. package/dist/esm/api/account.d.mts +72 -47
  9. package/dist/esm/api/account.mjs +1 -1
  10. package/dist/esm/api/ans.d.mts +19 -17
  11. package/dist/esm/api/ans.mjs +1 -1
  12. package/dist/esm/api/aptos.d.mts +1 -0
  13. package/dist/esm/api/aptos.mjs +1 -1
  14. package/dist/esm/api/aptosConfig.d.mts +2 -2
  15. package/dist/esm/api/aptosConfig.mjs +1 -1
  16. package/dist/esm/api/coin.d.mts +4 -3
  17. package/dist/esm/api/coin.mjs +1 -1
  18. package/dist/esm/api/digitalAsset.d.mts +21 -18
  19. package/dist/esm/api/digitalAsset.mjs +1 -1
  20. package/dist/esm/api/event.d.mts +12 -14
  21. package/dist/esm/api/event.mjs +1 -1
  22. package/dist/esm/api/faucet.d.mts +4 -4
  23. package/dist/esm/api/faucet.mjs +1 -1
  24. package/dist/esm/api/fungibleAsset.d.mts +71 -30
  25. package/dist/esm/api/fungibleAsset.mjs +1 -1
  26. package/dist/esm/api/general.d.mts +12 -5
  27. package/dist/esm/api/general.mjs +1 -1
  28. package/dist/esm/api/index.d.mts +1 -0
  29. package/dist/esm/api/index.mjs +1 -1
  30. package/dist/esm/api/staking.d.mts +13 -9
  31. package/dist/esm/api/staking.mjs +1 -1
  32. package/dist/esm/api/transaction.d.mts +36 -2
  33. package/dist/esm/api/transaction.mjs +1 -1
  34. package/dist/esm/api/transactionSubmission/build.d.mts +1 -0
  35. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  36. package/dist/esm/api/transactionSubmission/sign.d.mts +1 -0
  37. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  38. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -0
  39. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  40. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -0
  41. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission.d.mts +23 -1
  43. package/dist/esm/api/transactionSubmission.mjs +1 -1
  44. package/dist/esm/api/utils.d.mts +21 -0
  45. package/dist/esm/api/utils.mjs +2 -0
  46. package/dist/esm/bcs/deserializer.d.mts +4 -4
  47. package/dist/esm/bcs/deserializer.mjs +1 -1
  48. package/dist/esm/bcs/index.mjs +1 -1
  49. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  50. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  51. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  52. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  53. package/dist/esm/bcs/serializer.d.mts +4 -4
  54. package/dist/esm/bcs/serializer.mjs +1 -1
  55. package/dist/esm/{chunk-UAAI3NCA.mjs → chunk-2SAKPC5Q.mjs} +2 -2
  56. package/dist/esm/{chunk-3732I6BR.mjs → chunk-2YQXX64E.mjs} +2 -2
  57. package/dist/esm/chunk-3F5WV6US.mjs +2 -0
  58. package/dist/esm/chunk-3F5WV6US.mjs.map +1 -0
  59. package/dist/esm/{chunk-ARVSIDVB.mjs → chunk-3RMXGSHK.mjs} +2 -2
  60. package/dist/esm/chunk-3RMXGSHK.mjs.map +1 -0
  61. package/dist/esm/{chunk-4ADA5BE7.mjs → chunk-53DS6NBQ.mjs} +2 -2
  62. package/dist/esm/chunk-5CUNY7X2.mjs +2 -0
  63. package/dist/esm/chunk-5CUNY7X2.mjs.map +1 -0
  64. package/dist/esm/{chunk-QWVR4RCV.mjs → chunk-5OPOJ43H.mjs} +2 -2
  65. package/dist/esm/{chunk-72F5YXGC.mjs → chunk-5UY5OKXR.mjs} +2 -2
  66. package/dist/esm/chunk-5UY5OKXR.mjs.map +1 -0
  67. package/dist/esm/chunk-5ZVCSKFX.mjs +2 -0
  68. package/dist/esm/chunk-5ZVCSKFX.mjs.map +1 -0
  69. package/dist/esm/{chunk-HVADSXTB.mjs → chunk-73VWOS4Z.mjs} +2 -2
  70. package/dist/esm/chunk-ALFESCPU.mjs +2 -0
  71. package/dist/esm/chunk-ALFESCPU.mjs.map +1 -0
  72. package/dist/esm/chunk-APSQ4M23.mjs +2 -0
  73. package/dist/esm/chunk-APSQ4M23.mjs.map +1 -0
  74. package/dist/esm/{chunk-U25N2VWA.mjs → chunk-AZUWHKN5.mjs} +2 -2
  75. package/dist/esm/{chunk-UDBH4CER.mjs → chunk-BQSE5HHW.mjs} +7 -7
  76. package/dist/esm/chunk-BQSE5HHW.mjs.map +1 -0
  77. package/dist/esm/chunk-CCXMVVXD.mjs +2 -0
  78. package/dist/esm/chunk-CCXMVVXD.mjs.map +1 -0
  79. package/dist/esm/{chunk-JZNLZMUC.mjs → chunk-CJPCOS4R.mjs} +2 -2
  80. package/dist/esm/{chunk-S36IYY6K.mjs → chunk-CL5B2QNS.mjs} +2 -2
  81. package/dist/esm/chunk-CLJLQXFQ.mjs +2 -0
  82. package/dist/esm/chunk-CLJLQXFQ.mjs.map +1 -0
  83. package/dist/esm/{chunk-EWTHPMEE.mjs → chunk-CU2DINU4.mjs} +2 -2
  84. package/dist/esm/{chunk-5LO7FR2P.mjs → chunk-EFRFDFS4.mjs} +2 -2
  85. package/dist/esm/chunk-EOC4UI5B.mjs +2 -0
  86. package/dist/esm/{chunk-KC64ESLO.mjs.map → chunk-EOC4UI5B.mjs.map} +1 -1
  87. package/dist/esm/{chunk-HA6JD5R6.mjs → chunk-F6K26WV5.mjs} +2 -2
  88. package/dist/esm/{chunk-HA6JD5R6.mjs.map → chunk-F6K26WV5.mjs.map} +1 -1
  89. package/dist/esm/chunk-F7EWDYTE.mjs +2 -0
  90. package/dist/esm/chunk-F7EWDYTE.mjs.map +1 -0
  91. package/dist/esm/{chunk-44MGBJ73.mjs → chunk-FZ56IS3E.mjs} +2 -2
  92. package/dist/esm/chunk-G36AY4R7.mjs +2 -0
  93. package/dist/esm/chunk-G36AY4R7.mjs.map +1 -0
  94. package/dist/esm/chunk-GEZSEAL5.mjs +2 -0
  95. package/dist/esm/chunk-GEZSEAL5.mjs.map +1 -0
  96. package/dist/esm/chunk-GIZLK7M7.mjs +2 -0
  97. package/dist/esm/chunk-GIZLK7M7.mjs.map +1 -0
  98. package/dist/esm/chunk-GMG4VR3K.mjs +2 -0
  99. package/dist/esm/chunk-GMG4VR3K.mjs.map +1 -0
  100. package/dist/esm/{chunk-U6SZNNVL.mjs → chunk-GXPGRCSW.mjs} +2 -2
  101. package/dist/esm/{chunk-U6SZNNVL.mjs.map → chunk-GXPGRCSW.mjs.map} +1 -1
  102. package/dist/esm/{chunk-TPWSHFFI.mjs → chunk-HC5VMNXA.mjs} +2 -2
  103. package/dist/esm/chunk-HTI5LEST.mjs +2 -0
  104. package/dist/esm/chunk-HTI5LEST.mjs.map +1 -0
  105. package/dist/esm/chunk-IELTCGLP.mjs +2 -0
  106. package/dist/esm/chunk-IELTCGLP.mjs.map +1 -0
  107. package/dist/esm/chunk-IHYTP2EW.mjs +1 -0
  108. package/dist/esm/chunk-IHYTP2EW.mjs.map +1 -0
  109. package/dist/esm/chunk-JI2BBZ2W.mjs +2 -0
  110. package/dist/esm/{chunk-ND3ZQKTT.mjs.map → chunk-JI2BBZ2W.mjs.map} +1 -1
  111. package/dist/esm/chunk-KKER5KL4.mjs +2 -0
  112. package/dist/esm/chunk-KKER5KL4.mjs.map +1 -0
  113. package/dist/esm/chunk-KNMWDGP4.mjs +2 -0
  114. package/dist/esm/chunk-KNMWDGP4.mjs.map +1 -0
  115. package/dist/esm/{chunk-YYRDFZE6.mjs → chunk-KZSJ5MFF.mjs} +2 -2
  116. package/dist/esm/{chunk-YYRDFZE6.mjs.map → chunk-KZSJ5MFF.mjs.map} +1 -1
  117. package/dist/esm/chunk-MWAMLQ25.mjs +2 -0
  118. package/dist/esm/chunk-MWAMLQ25.mjs.map +1 -0
  119. package/dist/esm/chunk-NL72WE3E.mjs +2 -0
  120. package/dist/esm/{chunk-TIH6ARYP.mjs.map → chunk-NL72WE3E.mjs.map} +1 -1
  121. package/dist/esm/chunk-NZSGGL25.mjs +2 -0
  122. package/dist/esm/chunk-NZSGGL25.mjs.map +1 -0
  123. package/dist/esm/chunk-OBOOY2QD.mjs +2 -0
  124. package/dist/esm/chunk-OBOOY2QD.mjs.map +1 -0
  125. package/dist/esm/chunk-OT2UDMUU.mjs +2 -0
  126. package/dist/esm/chunk-OT2UDMUU.mjs.map +1 -0
  127. package/dist/esm/chunk-OZZDXS26.mjs +2 -0
  128. package/dist/esm/chunk-OZZDXS26.mjs.map +1 -0
  129. package/dist/esm/{chunk-DRPMIJH7.mjs → chunk-P5747ZYC.mjs} +2 -2
  130. package/dist/esm/{chunk-BPYLPPEQ.mjs → chunk-PL2VA73L.mjs} +2 -2
  131. package/dist/esm/chunk-PXTMLJKO.mjs +2 -0
  132. package/dist/esm/{chunk-WL4OXZLN.mjs → chunk-QCBIJCU4.mjs} +2 -2
  133. package/dist/esm/chunk-QEXAMHPU.mjs +2 -0
  134. package/dist/esm/chunk-QEXAMHPU.mjs.map +1 -0
  135. package/dist/esm/{chunk-KQXRH5FK.mjs → chunk-QNTV5NMH.mjs} +2 -2
  136. package/dist/esm/{chunk-HO7K2UAK.mjs → chunk-RCM3K5JL.mjs} +2 -2
  137. package/dist/esm/{chunk-3VZ3OZKC.mjs → chunk-RLG3WOTH.mjs} +2 -2
  138. package/dist/esm/chunk-SDPICQ5B.mjs +2 -0
  139. package/dist/esm/{chunk-FYIFBLHU.mjs.map → chunk-SDPICQ5B.mjs.map} +1 -1
  140. package/dist/esm/chunk-SGTFMSOG.mjs +2 -0
  141. package/dist/esm/chunk-SGTFMSOG.mjs.map +1 -0
  142. package/dist/esm/chunk-SO6EE5DX.mjs +2 -0
  143. package/dist/esm/chunk-SO6EE5DX.mjs.map +1 -0
  144. package/dist/esm/chunk-SRGPSANH.mjs +2 -0
  145. package/dist/esm/chunk-SRGPSANH.mjs.map +1 -0
  146. package/dist/esm/{chunk-GAI75GOG.mjs → chunk-SSJQOXEP.mjs} +2 -2
  147. package/dist/esm/chunk-TZ623H2V.mjs +2 -0
  148. package/dist/esm/chunk-TZ623H2V.mjs.map +1 -0
  149. package/dist/esm/chunk-U6Z4FNB7.mjs +2 -0
  150. package/dist/esm/chunk-U6Z4FNB7.mjs.map +1 -0
  151. package/dist/esm/{chunk-GTC7WHMV.mjs → chunk-UDMADMVO.mjs} +1 -1
  152. package/dist/esm/{chunk-GTC7WHMV.mjs.map → chunk-UDMADMVO.mjs.map} +1 -1
  153. package/dist/esm/chunk-UIVJXLRM.mjs +1 -0
  154. package/dist/esm/chunk-UIVJXLRM.mjs.map +1 -0
  155. package/dist/esm/chunk-UKSA4H2O.mjs +2 -0
  156. package/dist/esm/chunk-UKSA4H2O.mjs.map +1 -0
  157. package/dist/esm/chunk-UW6HQ643.mjs +2 -0
  158. package/dist/esm/chunk-UW6HQ643.mjs.map +1 -0
  159. package/dist/esm/{chunk-ZUHN56GM.mjs → chunk-UWXDXOFK.mjs} +2 -2
  160. package/dist/esm/chunk-UWXDXOFK.mjs.map +1 -0
  161. package/dist/esm/chunk-VQ7LYNMD.mjs +2 -0
  162. package/dist/esm/chunk-VQ7LYNMD.mjs.map +1 -0
  163. package/dist/esm/{chunk-IBH7IOIM.mjs → chunk-WTGGCH34.mjs} +2 -2
  164. package/dist/esm/{chunk-X32O46IB.mjs → chunk-XITLXPBK.mjs} +2 -2
  165. package/dist/esm/chunk-XMUUI6HG.mjs +2 -0
  166. package/dist/esm/{chunk-R3KWVOFG.mjs.map → chunk-XMUUI6HG.mjs.map} +1 -1
  167. package/dist/esm/chunk-XX2Z26FH.mjs +2 -0
  168. package/dist/esm/chunk-XX2Z26FH.mjs.map +1 -0
  169. package/dist/esm/chunk-Y6PVFMBS.mjs +2 -0
  170. package/dist/esm/chunk-Y6PVFMBS.mjs.map +1 -0
  171. package/dist/esm/{chunk-VWVEDCBM.mjs → chunk-YN6UIVFB.mjs} +2 -2
  172. package/dist/esm/{chunk-4KTQIWUP.mjs → chunk-ZFK7QD3B.mjs} +2 -2
  173. package/dist/esm/chunk-ZJUDDSWN.mjs +2 -0
  174. package/dist/esm/chunk-ZJUDDSWN.mjs.map +1 -0
  175. package/dist/esm/client/core.mjs +1 -1
  176. package/dist/esm/client/get.d.mts +1 -1
  177. package/dist/esm/client/get.mjs +1 -1
  178. package/dist/esm/client/index.mjs +1 -1
  179. package/dist/esm/client/post.mjs +1 -1
  180. package/dist/esm/core/account.mjs +1 -1
  181. package/dist/esm/core/accountAddress.d.mts +9 -9
  182. package/dist/esm/core/accountAddress.mjs +1 -1
  183. package/dist/esm/core/authenticationKey.mjs +1 -1
  184. package/dist/esm/core/crypto/anyPublicKey.d.mts +5 -0
  185. package/dist/esm/core/crypto/anyPublicKey.mjs +1 -1
  186. package/dist/esm/core/crypto/anySignature.mjs +1 -1
  187. package/dist/esm/core/crypto/asymmetricCrypto.mjs +1 -1
  188. package/dist/esm/core/crypto/ed25519.d.mts +3 -0
  189. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  190. package/dist/esm/core/crypto/index.d.mts +2 -2
  191. package/dist/esm/core/crypto/index.mjs +1 -1
  192. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  193. package/dist/esm/core/crypto/multiKey.d.mts +2 -0
  194. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  195. package/dist/esm/core/crypto/secp256k1.d.mts +3 -0
  196. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  197. package/dist/esm/core/hex.mjs +1 -1
  198. package/dist/esm/core/index.d.mts +2 -2
  199. package/dist/esm/core/index.mjs +1 -1
  200. package/dist/esm/index.d.mts +11 -8
  201. package/dist/esm/index.mjs +1 -1
  202. package/dist/esm/internal/account.d.mts +20 -33
  203. package/dist/esm/internal/account.mjs +1 -1
  204. package/dist/esm/internal/ans.d.mts +7 -10
  205. package/dist/esm/internal/ans.mjs +1 -1
  206. package/dist/esm/internal/coin.d.mts +4 -3
  207. package/dist/esm/internal/coin.mjs +1 -1
  208. package/dist/esm/internal/digitalAsset.d.mts +9 -18
  209. package/dist/esm/internal/digitalAsset.mjs +1 -1
  210. package/dist/esm/internal/event.d.mts +5 -12
  211. package/dist/esm/internal/event.mjs +1 -1
  212. package/dist/esm/internal/faucet.d.mts +5 -5
  213. package/dist/esm/internal/faucet.mjs +1 -1
  214. package/dist/esm/internal/fungibleAsset.d.mts +40 -22
  215. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  216. package/dist/esm/internal/general.d.mts +9 -5
  217. package/dist/esm/internal/general.mjs +1 -1
  218. package/dist/esm/internal/staking.d.mts +5 -7
  219. package/dist/esm/internal/staking.mjs +1 -1
  220. package/dist/esm/internal/transaction.d.mts +12 -4
  221. package/dist/esm/internal/transaction.mjs +1 -1
  222. package/dist/esm/internal/transactionSubmission.d.mts +24 -5
  223. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  224. package/dist/esm/transactions/authenticator/account.d.mts +5 -0
  225. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  226. package/dist/esm/transactions/authenticator/index.d.mts +1 -0
  227. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  228. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -0
  229. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  230. package/dist/esm/transactions/index.d.mts +4 -3
  231. package/dist/esm/transactions/index.mjs +1 -1
  232. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  233. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  234. package/dist/esm/transactions/instances/index.d.mts +1 -0
  235. package/dist/esm/transactions/instances/index.mjs +1 -1
  236. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  237. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  238. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  239. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -0
  240. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  241. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  242. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +89 -0
  243. package/dist/esm/transactions/management/accountSequenceNumber.mjs +2 -0
  244. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -0
  245. package/dist/esm/transactions/management/asyncQueue.d.mts +58 -0
  246. package/dist/esm/transactions/management/asyncQueue.mjs +2 -0
  247. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -0
  248. package/dist/esm/transactions/management/index.d.mts +36 -0
  249. package/dist/esm/transactions/management/index.mjs +2 -0
  250. package/dist/esm/transactions/management/index.mjs.map +1 -0
  251. package/dist/esm/transactions/management/transactionWorker.d.mts +135 -0
  252. package/dist/esm/transactions/management/transactionWorker.mjs +2 -0
  253. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -0
  254. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -1
  255. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  256. package/dist/esm/transactions/transactionBuilder/index.d.mts +4 -3
  257. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  258. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +3 -1
  259. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  260. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -2
  261. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  262. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  263. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  264. package/dist/esm/transactions/types.d.mts +3 -2
  265. package/dist/esm/types/generated/operations.d.mts +3 -3
  266. package/dist/esm/types/generated/queries.d.mts +3 -3
  267. package/dist/esm/types/generated/queries.mjs +1 -1
  268. package/dist/esm/types/index.d.mts +27 -9
  269. package/dist/esm/types/index.mjs +1 -1
  270. package/dist/esm/utils/const.d.mts +18 -1
  271. package/dist/esm/utils/const.mjs +1 -1
  272. package/dist/esm/utils/index.d.mts +1 -1
  273. package/dist/esm/utils/index.mjs +1 -1
  274. package/dist/esm/version.d.mts +1 -1
  275. package/dist/esm/version.mjs +1 -1
  276. package/package.json +1 -1
  277. package/src/api/account.ts +150 -53
  278. package/src/api/ans.ts +19 -22
  279. package/src/api/aptosConfig.ts +2 -2
  280. package/src/api/coin.ts +2 -6
  281. package/src/api/digitalAsset.ts +72 -22
  282. package/src/api/event.ts +28 -17
  283. package/src/api/faucet.ts +12 -9
  284. package/src/api/fungibleAsset.ts +76 -35
  285. package/src/api/general.ts +19 -3
  286. package/src/api/staking.ts +30 -11
  287. package/src/api/transaction.ts +16 -1
  288. package/src/api/transactionSubmission.ts +43 -1
  289. package/src/api/utils.ts +37 -0
  290. package/src/bcs/deserializer.ts +4 -4
  291. package/src/bcs/serializer.ts +4 -4
  292. package/src/client/core.ts +6 -4
  293. package/src/client/get.ts +7 -6
  294. package/src/core/accountAddress.ts +20 -22
  295. package/src/core/crypto/anyPublicKey.ts +12 -0
  296. package/src/core/crypto/ed25519.ts +13 -0
  297. package/src/core/crypto/index.ts +2 -0
  298. package/src/core/crypto/secp256k1.ts +12 -0
  299. package/src/core/hex.ts +5 -7
  300. package/src/index.ts +1 -0
  301. package/src/internal/account.ts +56 -50
  302. package/src/internal/ans.ts +52 -39
  303. package/src/internal/coin.ts +4 -6
  304. package/src/internal/digitalAsset.ts +12 -22
  305. package/src/internal/event.ts +7 -14
  306. package/src/internal/faucet.ts +10 -6
  307. package/src/internal/fungibleAsset.ts +36 -18
  308. package/src/internal/general.ts +30 -3
  309. package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +5 -5
  310. package/src/internal/queries/getProcessorStatus.graphql +2 -2
  311. package/src/internal/staking.ts +12 -14
  312. package/src/internal/transaction.ts +23 -26
  313. package/src/internal/transactionSubmission.ts +35 -5
  314. package/src/transactions/authenticator/account.ts +16 -0
  315. package/src/transactions/instances/moduleId.ts +1 -1
  316. package/src/transactions/management/accountSequenceNumber.ts +186 -0
  317. package/src/transactions/management/asyncQueue.ts +107 -0
  318. package/src/transactions/management/index.ts +2 -0
  319. package/src/transactions/management/transactionWorker.ts +275 -0
  320. package/src/transactions/transactionBuilder/helpers.ts +28 -1
  321. package/src/transactions/transactionBuilder/remoteAbi.ts +35 -28
  322. package/src/transactions/transactionBuilder/transactionBuilder.ts +28 -26
  323. package/src/transactions/typeTag/parser.ts +1 -1
  324. package/src/transactions/types.ts +2 -2
  325. package/src/types/generated/operations.ts +4 -2
  326. package/src/types/generated/queries.ts +4 -4
  327. package/src/types/index.ts +67 -11
  328. package/src/utils/const.ts +18 -0
  329. package/src/version.ts +1 -1
  330. package/dist/esm/chunk-2OZRBXLM.mjs +0 -2
  331. package/dist/esm/chunk-2OZRBXLM.mjs.map +0 -1
  332. package/dist/esm/chunk-33T7WTB6.mjs +0 -2
  333. package/dist/esm/chunk-33T7WTB6.mjs.map +0 -1
  334. package/dist/esm/chunk-62SCW5NH.mjs +0 -2
  335. package/dist/esm/chunk-62SCW5NH.mjs.map +0 -1
  336. package/dist/esm/chunk-67OGU66P.mjs +0 -2
  337. package/dist/esm/chunk-67OGU66P.mjs.map +0 -1
  338. package/dist/esm/chunk-72F5YXGC.mjs.map +0 -1
  339. package/dist/esm/chunk-ARVSIDVB.mjs.map +0 -1
  340. package/dist/esm/chunk-BFQRMCY2.mjs +0 -2
  341. package/dist/esm/chunk-BFQRMCY2.mjs.map +0 -1
  342. package/dist/esm/chunk-BM4HBROC.mjs +0 -2
  343. package/dist/esm/chunk-BM4HBROC.mjs.map +0 -1
  344. package/dist/esm/chunk-BV4OOU5Y.mjs +0 -2
  345. package/dist/esm/chunk-BV4OOU5Y.mjs.map +0 -1
  346. package/dist/esm/chunk-EFIYW4WK.mjs +0 -2
  347. package/dist/esm/chunk-FYIFBLHU.mjs +0 -2
  348. package/dist/esm/chunk-GU4OUKAF.mjs +0 -2
  349. package/dist/esm/chunk-GU4OUKAF.mjs.map +0 -1
  350. package/dist/esm/chunk-J5BH7V37.mjs +0 -2
  351. package/dist/esm/chunk-J5BH7V37.mjs.map +0 -1
  352. package/dist/esm/chunk-KC64ESLO.mjs +0 -2
  353. package/dist/esm/chunk-L7AA75WZ.mjs +0 -2
  354. package/dist/esm/chunk-L7AA75WZ.mjs.map +0 -1
  355. package/dist/esm/chunk-LACQ537H.mjs +0 -2
  356. package/dist/esm/chunk-LACQ537H.mjs.map +0 -1
  357. package/dist/esm/chunk-LDAD54H5.mjs +0 -2
  358. package/dist/esm/chunk-LDAD54H5.mjs.map +0 -1
  359. package/dist/esm/chunk-LXW3A3MJ.mjs +0 -2
  360. package/dist/esm/chunk-LXW3A3MJ.mjs.map +0 -1
  361. package/dist/esm/chunk-M2V2POWK.mjs +0 -2
  362. package/dist/esm/chunk-M2V2POWK.mjs.map +0 -1
  363. package/dist/esm/chunk-ND3ZQKTT.mjs +0 -2
  364. package/dist/esm/chunk-NZIJV4O2.mjs +0 -2
  365. package/dist/esm/chunk-NZIJV4O2.mjs.map +0 -1
  366. package/dist/esm/chunk-O2B54NZT.mjs +0 -2
  367. package/dist/esm/chunk-O2B54NZT.mjs.map +0 -1
  368. package/dist/esm/chunk-OCW2L33Q.mjs +0 -2
  369. package/dist/esm/chunk-OCW2L33Q.mjs.map +0 -1
  370. package/dist/esm/chunk-OCYS4V2V.mjs +0 -2
  371. package/dist/esm/chunk-OCYS4V2V.mjs.map +0 -1
  372. package/dist/esm/chunk-OSTH5JRX.mjs +0 -2
  373. package/dist/esm/chunk-OSTH5JRX.mjs.map +0 -1
  374. package/dist/esm/chunk-OVHY6ZUJ.mjs +0 -2
  375. package/dist/esm/chunk-OVHY6ZUJ.mjs.map +0 -1
  376. package/dist/esm/chunk-PZCMSHY6.mjs +0 -2
  377. package/dist/esm/chunk-PZCMSHY6.mjs.map +0 -1
  378. package/dist/esm/chunk-R3KWVOFG.mjs +0 -2
  379. package/dist/esm/chunk-RHS5ROLP.mjs +0 -2
  380. package/dist/esm/chunk-RHS5ROLP.mjs.map +0 -1
  381. package/dist/esm/chunk-RKKU2SY5.mjs +0 -2
  382. package/dist/esm/chunk-RKKU2SY5.mjs.map +0 -1
  383. package/dist/esm/chunk-RYETO74W.mjs +0 -2
  384. package/dist/esm/chunk-RYETO74W.mjs.map +0 -1
  385. package/dist/esm/chunk-TCTZCPQ6.mjs +0 -1
  386. package/dist/esm/chunk-TGKB6ALT.mjs +0 -2
  387. package/dist/esm/chunk-TGKB6ALT.mjs.map +0 -1
  388. package/dist/esm/chunk-TIH6ARYP.mjs +0 -2
  389. package/dist/esm/chunk-UDBH4CER.mjs.map +0 -1
  390. package/dist/esm/chunk-WEJAI26R.mjs +0 -2
  391. package/dist/esm/chunk-WEJAI26R.mjs.map +0 -1
  392. package/dist/esm/chunk-Y2HRRUZ6.mjs +0 -2
  393. package/dist/esm/chunk-Y2HRRUZ6.mjs.map +0 -1
  394. package/dist/esm/chunk-Y7VR7X5W.mjs +0 -2
  395. package/dist/esm/chunk-Y7VR7X5W.mjs.map +0 -1
  396. package/dist/esm/chunk-ZLW65YCO.mjs +0 -2
  397. package/dist/esm/chunk-ZLW65YCO.mjs.map +0 -1
  398. package/dist/esm/chunk-ZUHN56GM.mjs.map +0 -1
  399. /package/dist/esm/{chunk-TCTZCPQ6.mjs.map → api/utils.mjs.map} +0 -0
  400. /package/dist/esm/{chunk-UAAI3NCA.mjs.map → chunk-2SAKPC5Q.mjs.map} +0 -0
  401. /package/dist/esm/{chunk-3732I6BR.mjs.map → chunk-2YQXX64E.mjs.map} +0 -0
  402. /package/dist/esm/{chunk-4ADA5BE7.mjs.map → chunk-53DS6NBQ.mjs.map} +0 -0
  403. /package/dist/esm/{chunk-QWVR4RCV.mjs.map → chunk-5OPOJ43H.mjs.map} +0 -0
  404. /package/dist/esm/{chunk-HVADSXTB.mjs.map → chunk-73VWOS4Z.mjs.map} +0 -0
  405. /package/dist/esm/{chunk-U25N2VWA.mjs.map → chunk-AZUWHKN5.mjs.map} +0 -0
  406. /package/dist/esm/{chunk-JZNLZMUC.mjs.map → chunk-CJPCOS4R.mjs.map} +0 -0
  407. /package/dist/esm/{chunk-S36IYY6K.mjs.map → chunk-CL5B2QNS.mjs.map} +0 -0
  408. /package/dist/esm/{chunk-EWTHPMEE.mjs.map → chunk-CU2DINU4.mjs.map} +0 -0
  409. /package/dist/esm/{chunk-5LO7FR2P.mjs.map → chunk-EFRFDFS4.mjs.map} +0 -0
  410. /package/dist/esm/{chunk-44MGBJ73.mjs.map → chunk-FZ56IS3E.mjs.map} +0 -0
  411. /package/dist/esm/{chunk-TPWSHFFI.mjs.map → chunk-HC5VMNXA.mjs.map} +0 -0
  412. /package/dist/esm/{chunk-DRPMIJH7.mjs.map → chunk-P5747ZYC.mjs.map} +0 -0
  413. /package/dist/esm/{chunk-BPYLPPEQ.mjs.map → chunk-PL2VA73L.mjs.map} +0 -0
  414. /package/dist/esm/{chunk-EFIYW4WK.mjs.map → chunk-PXTMLJKO.mjs.map} +0 -0
  415. /package/dist/esm/{chunk-WL4OXZLN.mjs.map → chunk-QCBIJCU4.mjs.map} +0 -0
  416. /package/dist/esm/{chunk-KQXRH5FK.mjs.map → chunk-QNTV5NMH.mjs.map} +0 -0
  417. /package/dist/esm/{chunk-HO7K2UAK.mjs.map → chunk-RCM3K5JL.mjs.map} +0 -0
  418. /package/dist/esm/{chunk-3VZ3OZKC.mjs.map → chunk-RLG3WOTH.mjs.map} +0 -0
  419. /package/dist/esm/{chunk-GAI75GOG.mjs.map → chunk-SSJQOXEP.mjs.map} +0 -0
  420. /package/dist/esm/{chunk-IBH7IOIM.mjs.map → chunk-WTGGCH34.mjs.map} +0 -0
  421. /package/dist/esm/{chunk-X32O46IB.mjs.map → chunk-XITLXPBK.mjs.map} +0 -0
  422. /package/dist/esm/{chunk-VWVEDCBM.mjs.map → chunk-YN6UIVFB.mjs.map} +0 -0
  423. /package/dist/esm/{chunk-4KTQIWUP.mjs.map → chunk-ZFK7QD3B.mjs.map} +0 -0
@@ -8,6 +8,7 @@ import {
8
8
  getChainTopUserTransactions,
9
9
  getIndexerLastSuccessVersion,
10
10
  getLedgerInfo,
11
+ getProcessorStatus,
11
12
  getTableItem,
12
13
  queryIndexer,
13
14
  view,
@@ -16,13 +17,15 @@ import {
16
17
  AnyNumber,
17
18
  Block,
18
19
  GetChainTopUserTransactionsResponse,
20
+ GetProcessorStatusResponse,
19
21
  GraphqlQuery,
20
22
  LedgerInfo,
21
- LedgerVersion,
23
+ LedgerVersionArg,
22
24
  MoveValue,
23
25
  TableItemRequest,
24
26
  InputViewRequestData,
25
27
  } from "../types";
28
+ import { ProcessorType } from "../utils/const";
26
29
 
27
30
  /**
28
31
  * A class to query all `General` Aptos related queries
@@ -114,7 +117,7 @@ export class General {
114
117
  *
115
118
  * @returns Table item value rendered in JSON
116
119
  */
117
- async getTableItem<T>(args: { handle: string; data: TableItemRequest; options?: LedgerVersion }): Promise<T> {
120
+ async getTableItem<T>(args: { handle: string; data: TableItemRequest; options?: LedgerVersionArg }): Promise<T> {
118
121
  return getTableItem<T>({ aptosConfig: this.config, ...args });
119
122
  }
120
123
 
@@ -133,7 +136,10 @@ export class General {
133
136
  *
134
137
  * @returns an array of Move values
135
138
  */
136
- async view<T extends Array<MoveValue>>(args: { payload: InputViewRequestData; options?: LedgerVersion }): Promise<T> {
139
+ async view<T extends Array<MoveValue>>(args: {
140
+ payload: InputViewRequestData;
141
+ options?: LedgerVersionArg;
142
+ }): Promise<T> {
137
143
  return view<T>({ aptosConfig: this.config, ...args });
138
144
  }
139
145
 
@@ -185,4 +191,14 @@ export class General {
185
191
  async getIndexerLastSuccessVersion(): Promise<number> {
186
192
  return getIndexerLastSuccessVersion({ aptosConfig: this.config });
187
193
  }
194
+
195
+ /**
196
+ * Query the processor status for a specific processor type.
197
+ *
198
+ * @param processorType The processor type to query
199
+ * @returns
200
+ */
201
+ async getProcessorStatus(processorType: ProcessorType): Promise<GetProcessorStatusResponse[0]> {
202
+ return getProcessorStatus({ aptosConfig: this.config, processorType });
203
+ }
188
204
  }
@@ -1,45 +1,57 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { AptosConfig } from "./aptosConfig";
5
4
  import {
6
5
  getDelegatedStakingActivities,
7
6
  getNumberOfDelegators,
8
7
  getNumberOfDelegatorsForAllPools,
9
8
  } from "../internal/staking";
10
- import { GetDelegatedStakingActivitiesResponse, GetNumberOfDelegatorsResponse, OrderBy } from "../types";
9
+ import { AnyNumber, GetDelegatedStakingActivitiesResponse, GetNumberOfDelegatorsResponse, OrderByArg } from "../types";
11
10
  import { AccountAddressInput } from "../core";
11
+ import { ProcessorType } from "../utils/const";
12
+ import { AptosConfig } from "./aptosConfig";
13
+ import { waitForIndexerOnVersion } from "./utils";
12
14
 
13
15
  /**
14
16
  * A class to query all `Staking` related queries on Aptos.
15
17
  */
16
18
  export class Staking {
17
- readonly config: AptosConfig;
18
-
19
- constructor(config: AptosConfig) {
20
- this.config = config;
21
- }
19
+ constructor(readonly config: AptosConfig) {}
22
20
 
23
21
  /**
24
22
  * Queries current number of delegators in a pool. Throws an error if the pool is not found.
25
23
  *
26
24
  * @param args.poolAddress Pool address
25
+ * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
27
26
  * @returns The number of delegators for the given pool
28
27
  */
29
- async getNumberOfDelegators(args: { poolAddress: AccountAddressInput }): Promise<number> {
28
+ async getNumberOfDelegators(args: {
29
+ poolAddress: AccountAddressInput;
30
+ minimumLedgerVersion?: AnyNumber;
31
+ }): Promise<number> {
32
+ await waitForIndexerOnVersion({
33
+ config: this.config,
34
+ minimumLedgerVersion: args?.minimumLedgerVersion,
35
+ processorTypes: [ProcessorType.STAKE_PROCESSOR],
36
+ });
30
37
  return getNumberOfDelegators({ aptosConfig: this.config, ...args });
31
38
  }
32
39
 
33
40
  /**
34
41
  * Queries current number of delegators in a pool. Throws an error if the pool is not found.
35
42
  *
43
+ * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
36
44
  * @returns GetNumberOfDelegatorsForAllPoolsResponse response type
37
45
  */
38
46
  async getNumberOfDelegatorsForAllPools(args?: {
39
- options?: {
40
- orderBy?: OrderBy<GetNumberOfDelegatorsResponse[0]>;
41
- };
47
+ minimumLedgerVersion?: AnyNumber;
48
+ options?: OrderByArg<GetNumberOfDelegatorsResponse[0]>;
42
49
  }): Promise<GetNumberOfDelegatorsResponse> {
50
+ await waitForIndexerOnVersion({
51
+ config: this.config,
52
+ minimumLedgerVersion: args?.minimumLedgerVersion,
53
+ processorTypes: [ProcessorType.STAKE_PROCESSOR],
54
+ });
43
55
  return getNumberOfDelegatorsForAllPools({ aptosConfig: this.config, ...args });
44
56
  }
45
57
 
@@ -48,12 +60,19 @@ export class Staking {
48
60
  *
49
61
  * @param args.delegatorAddress Delegator address
50
62
  * @param args.poolAddress Pool address
63
+ * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
51
64
  * @returns GetDelegatedStakingActivitiesResponse response type
52
65
  */
53
66
  async getDelegatedStakingActivities(args: {
54
67
  delegatorAddress: AccountAddressInput;
55
68
  poolAddress: AccountAddressInput;
69
+ minimumLedgerVersion?: AnyNumber;
56
70
  }): Promise<GetDelegatedStakingActivitiesResponse> {
71
+ await waitForIndexerOnVersion({
72
+ config: this.config,
73
+ minimumLedgerVersion: args?.minimumLedgerVersion,
74
+ processorTypes: [ProcessorType.STAKE_PROCESSOR],
75
+ });
57
76
  return getDelegatedStakingActivities({ aptosConfig: this.config, ...args });
58
77
  }
59
78
  }
@@ -12,12 +12,15 @@ import {
12
12
  } from "../internal/transaction";
13
13
  import {
14
14
  AnyNumber,
15
+ CommittedTransactionResponse,
15
16
  GasEstimation,
16
17
  HexInput,
17
18
  PaginationArgs,
18
19
  TransactionResponse,
19
20
  WaitForTransactionOptions,
20
21
  } from "../types";
22
+ import { getSigningMessage } from "../internal/transactionSubmission";
23
+ import { AnyRawTransaction } from "../transactions";
21
24
 
22
25
  export class Transaction {
23
26
  readonly config: AptosConfig;
@@ -112,7 +115,7 @@ export class Transaction {
112
115
  async waitForTransaction(args: {
113
116
  transactionHash: HexInput;
114
117
  options?: WaitForTransactionOptions;
115
- }): Promise<TransactionResponse> {
118
+ }): Promise<CommittedTransactionResponse> {
116
119
  return waitForTransaction({
117
120
  aptosConfig: this.config,
118
121
  ...args,
@@ -139,4 +142,16 @@ export class Transaction {
139
142
  aptosConfig: this.config,
140
143
  });
141
144
  }
145
+
146
+ /**
147
+ * Returns a signing message for a transaction.
148
+ *
149
+ * This allows a user to sign a transaction using their own preferred signing method, and
150
+ * then submit it to the network.
151
+ * @param args.transaction A raw transaction for signing elsewhere
152
+ */
153
+ // eslint-disable-next-line class-methods-use-this
154
+ getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {
155
+ return getSigningMessage(args);
156
+ }
142
157
  }
@@ -3,9 +3,15 @@
3
3
 
4
4
  import { AptosConfig } from "./aptosConfig";
5
5
  import { Account, AccountAddressInput, PrivateKey } from "../core";
6
- import { AnyRawTransaction, SingleSignerTransaction, InputGenerateTransactionOptions } from "../transactions/types";
6
+ import {
7
+ AnyRawTransaction,
8
+ SingleSignerTransaction,
9
+ InputGenerateTransactionOptions,
10
+ InputGenerateTransactionPayloadData,
11
+ } from "../transactions/types";
7
12
  import { PendingTransactionResponse, HexInput, TransactionResponse } from "../types";
8
13
  import { publicPackageTransaction, rotateAuthKey, signAndSubmitTransaction } from "../internal/transactionSubmission";
14
+ import { TransactionWorker } from "../transactions/management";
9
15
 
10
16
  export class TransactionSubmission {
11
17
  readonly config: AptosConfig;
@@ -14,6 +20,42 @@ export class TransactionSubmission {
14
20
  this.config = config;
15
21
  }
16
22
 
23
+ /**
24
+ * Batch transactions for a single account.
25
+ *
26
+ * This function uses a transaction worker that receives payloads to be processed
27
+ * and submitted to chain.
28
+ * Note that this process is best for submitting multiple transactions that
29
+ * dont rely on each other, i.e batch funds, batch token mints, etc.
30
+ *
31
+ * If any worker failure, the functions throws an error.
32
+ *
33
+ * @param args.sender The sender account to sign and submit the transaction
34
+ * @param args.data An array of transaction payloads
35
+ * @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)
36
+ *
37
+ * @return void. Throws if any error
38
+ */
39
+ async batchTransactionsForSingleAccount(args: {
40
+ sender: Account;
41
+ data: InputGenerateTransactionPayloadData[];
42
+ options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">;
43
+ }): Promise<void> {
44
+ try {
45
+ const { sender, data, options } = args;
46
+ const transactionWorker = new TransactionWorker(this.config, sender);
47
+
48
+ transactionWorker.start();
49
+
50
+ for (const d of data) {
51
+ /* eslint-disable no-await-in-loop */
52
+ await transactionWorker.push(d, options);
53
+ }
54
+ } catch (error: any) {
55
+ throw new Error(`failed to submit transactions with error: ${error}`);
56
+ }
57
+ }
58
+
17
59
  /**
18
60
  * Sign and submit a single signer transaction to chain
19
61
  *
@@ -0,0 +1,37 @@
1
+ import { waitForIndexer } from "../internal/transaction";
2
+ import { ProcessorType } from "../utils";
3
+ import { AptosConfig } from "./aptosConfig";
4
+ import { AnyNumber } from "../types";
5
+
6
+ /**
7
+ * Utility function to handle optional waiting on indexer for APIs
8
+ *
9
+ * This is purposely placed here to not expose this internal function.
10
+ * @param args
11
+ */
12
+ export async function waitForIndexerOnVersion(args: {
13
+ config: AptosConfig;
14
+ minimumLedgerVersion?: AnyNumber;
15
+ processorTypes: Array<ProcessorType>;
16
+ }) {
17
+ if (args.minimumLedgerVersion !== undefined) {
18
+ // eslint-disable-next-line no-restricted-syntax
19
+
20
+ // Collect all of the promises to wait at the same time
21
+ // TODO(greg): This needs to be refactored to be handled at the query time. It involves rewriting
22
+ // a bunch of the logic for wait for indexer
23
+ const promises: Array<Promise<void>> = [];
24
+ // eslint-disable-next-line no-restricted-syntax
25
+ for (const processorType of args.processorTypes) {
26
+ promises.push(
27
+ waitForIndexer({
28
+ aptosConfig: args.config,
29
+ minimumLedgerVersion: args.minimumLedgerVersion,
30
+ processorType,
31
+ }),
32
+ );
33
+ }
34
+
35
+ await Promise.all(promises);
36
+ }
37
+ }
@@ -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.fromRelaxed("0x1"),
226
- * AccountAddress.fromRelaxed("0x2"),
227
- * AccountAddress.fromRelaxed("0xa"),
228
- * AccountAddress.fromRelaxed("0xb"),
225
+ * AccountAddress.from("0x1"),
226
+ * AccountAddress.from("0x2"),
227
+ * AccountAddress.from("0xa"),
228
+ * AccountAddress.from("0xb"),
229
229
  * );
230
230
  * const serializer = new Serializer();
231
231
  * serializer.serializeVector(addresses);
@@ -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.fromRelaxed("0x1"),
302
- * AccountAddress.fromRelaxed("0x2"),
303
- * AccountAddress.fromRelaxed("0xa"),
304
- * AccountAddress.fromRelaxed("0xb"),
301
+ * AccountAddress.from("0x1"),
302
+ * AccountAddress.from("0x2"),
303
+ * AccountAddress.from("0xa"),
304
+ * AccountAddress.from("0xb"),
305
305
  * );
306
306
  * const serializer = new Serializer();
307
307
  * serializer.serializeVector(addresses);
@@ -38,6 +38,9 @@ export async function request<Req, Res>(options: ClientRequest<Req>, client: Cli
38
38
  if (overrides?.AUTH_TOKEN && url.includes("faucet")) {
39
39
  headers.Authorization = `Bearer ${overrides?.AUTH_TOKEN}`;
40
40
  }
41
+ if (overrides?.API_KEY && !url.includes("faucet")) {
42
+ headers.Authorization = `Bearer ${overrides?.API_KEY}`;
43
+ }
41
44
 
42
45
  /*
43
46
  * make a call using the @aptos-labs/aptos-client package
@@ -99,15 +102,14 @@ export async function aptosRequest<Req extends {}, Res extends {}>(
99
102
 
100
103
  let errorMessage: string;
101
104
 
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
+ if (result && result.data && "message" in result.data && "error_code" in result.data) {
106
+ errorMessage = JSON.stringify(result.data);
105
107
  } else if (result.status in errors) {
106
108
  // If it's not an API type, it must come form infra, these are prehandled
107
109
  errorMessage = errors[result.status];
108
110
  } else {
109
111
  // Everything else is unhandled
110
- errorMessage = `Unhandled Error ${response.status} : ${response.statusText}`;
112
+ errorMessage = `Unhandled Error ${result.status} : ${result.statusText}`;
111
113
  }
112
114
 
113
115
  throw new AptosApiError(options, result, errorMessage);
package/src/client/get.ts CHANGED
@@ -78,17 +78,18 @@ export async function getAptosFullNode<Req extends {}, Res extends {}>(
78
78
  }
79
79
 
80
80
  /// This function is a helper for paginating using a function wrapping an API
81
- export async function paginateWithCursor<Req extends Record<string, any>, Res extends any[]>(
81
+ export async function paginateWithCursor<Req extends Record<string, any>, Res extends Array<{}>>(
82
82
  options: GetAptosRequestOptions,
83
83
  ): Promise<Res> {
84
- const out = [];
84
+ const out: any[] = [];
85
85
  let cursor: string | undefined;
86
- const requestParams = options.params as Req & { start?: string; limit?: number };
86
+ const requestParams = options.params as { start?: string; limit?: number };
87
87
  // eslint-disable-next-line no-constant-condition
88
88
  while (true) {
89
89
  requestParams.start = cursor;
90
90
  // eslint-disable-next-line no-await-in-loop
91
- const response = await getAptosFullNode<Req, Res>({
91
+ const response = await get<Req, Res>({
92
+ type: AptosApiType.FULLNODE,
92
93
  aptosConfig: options.aptosConfig,
93
94
  originMethod: options.originMethod,
94
95
  path: options.path,
@@ -103,11 +104,11 @@ export async function paginateWithCursor<Req extends Record<string, any>, Res ex
103
104
  cursor = response.headers["x-aptos-cursor"];
104
105
  // Now that we have the cursor (if any), we remove the headers before
105
106
  // adding these to the output of this function.
106
- delete (response as any).headers;
107
+ delete response.headers;
107
108
  out.push(...response.data);
108
109
  if (cursor === null || cursor === undefined) {
109
110
  break;
110
111
  }
111
112
  }
112
- return out as any;
113
+ return out as Res;
113
114
  }
@@ -218,7 +218,7 @@ export class AccountAddress extends Serializable implements TransactionArgument
218
218
 
219
219
  /**
220
220
  * NOTE: This function has strict parsing behavior. For relaxed behavior, please use
221
- * the `fromStringRelaxed` function.
221
+ * the `fromString` function.
222
222
  *
223
223
  * Creates an instance of AccountAddress from a hex string.
224
224
  *
@@ -243,20 +243,20 @@ export class AccountAddress extends Serializable implements TransactionArgument
243
243
  *
244
244
  * @returns An instance of AccountAddress.
245
245
  */
246
- static fromString(input: string): AccountAddress {
246
+ static fromStringStrict(input: string): AccountAddress {
247
247
  // Assert the string starts with 0x.
248
248
  if (!input.startsWith("0x")) {
249
249
  throw new ParsingError("Hex string must start with a leading 0x.", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);
250
250
  }
251
251
 
252
- const address = AccountAddress.fromStringRelaxed(input);
252
+ const address = AccountAddress.fromString(input);
253
253
 
254
254
  // Check if the address is in LONG form. If it is not, this is only allowed for
255
255
  // special addresses, in which case we check it is in proper SHORT form.
256
256
  if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {
257
257
  if (!address.isSpecial()) {
258
258
  throw new ParsingError(
259
- `The given hex string ${address} is not a special address, it must be represented as 0x + 64 chars.`,
259
+ `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,
260
260
  AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,
261
261
  );
262
262
  } else if (input.length !== 3) {
@@ -274,8 +274,8 @@ export class AccountAddress extends Serializable implements TransactionArgument
274
274
 
275
275
  /**
276
276
  * NOTE: This function has relaxed parsing behavior. For strict behavior, please use
277
- * the `fromString` function. Where possible use `fromString` rather than this
278
- * function, `fromStringRelaxed` is only provided for backwards compatibility.
277
+ * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this
278
+ * function, `fromString` is only provided for backwards compatibility.
279
279
  *
280
280
  * Creates an instance of AccountAddress from a hex string.
281
281
  *
@@ -297,7 +297,7 @@ export class AccountAddress extends Serializable implements TransactionArgument
297
297
  *
298
298
  * @returns An instance of AccountAddress.
299
299
  */
300
- static fromStringRelaxed(input: string): AccountAddress {
300
+ static fromString(input: string): AccountAddress {
301
301
  let parsedInput = input;
302
302
  // Remove leading 0x for parsing.
303
303
  if (input.startsWith("0x")) {
@@ -326,11 +326,10 @@ export class AccountAddress extends Serializable implements TransactionArgument
326
326
  // the hex string to bytes. Every two characters in a hex string constitutes a
327
327
  // single byte. So a 64 length hex string becomes a 32 byte array.
328
328
  addressBytes = hexToBytes(parsedInput.padStart(64, "0"));
329
- } catch (e) {
330
- const error = e as Error;
329
+ } catch (error: any) {
331
330
  // At this point the only way this can fail is if the hex string contains
332
331
  // invalid characters.
333
- throw new ParsingError(`Hex characters are invalid: ${error.message}`, AddressInvalidReason.INVALID_HEX_CHARS);
332
+ throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);
334
333
  }
335
334
 
336
335
  return new AccountAddress(addressBytes);
@@ -342,14 +341,14 @@ export class AccountAddress extends Serializable implements TransactionArgument
342
341
  * This handles, Uint8array, string, and AccountAddress itself
343
342
  * @param input
344
343
  */
345
- static fromRelaxed(input: AccountAddressInput): AccountAddress {
344
+ static from(input: AccountAddressInput): AccountAddress {
346
345
  if (input instanceof AccountAddress) {
347
346
  return input;
348
347
  }
349
348
  if (input instanceof Uint8Array) {
350
349
  return new AccountAddress(input);
351
350
  }
352
- return AccountAddress.fromStringRelaxed(input);
351
+ return AccountAddress.fromString(input);
353
352
  }
354
353
 
355
354
  /**
@@ -358,14 +357,14 @@ export class AccountAddress extends Serializable implements TransactionArgument
358
357
  * This handles, Uint8array, string, and AccountAddress itself
359
358
  * @param input
360
359
  */
361
- static from(input: AccountAddressInput): AccountAddress {
360
+ static fromStrict(input: AccountAddressInput): AccountAddress {
362
361
  if (input instanceof AccountAddress) {
363
362
  return input;
364
363
  }
365
364
  if (input instanceof Uint8Array) {
366
365
  return new AccountAddress(input);
367
366
  }
368
- return AccountAddress.fromString(input);
367
+ return AccountAddress.fromStringStrict(input);
369
368
  }
370
369
 
371
370
  // ===
@@ -376,25 +375,24 @@ export class AccountAddress extends Serializable implements TransactionArgument
376
375
  * Check if the string is a valid AccountAddress.
377
376
  *
378
377
  * @param args.input A hex string representing an account address.
379
- * @param args.relaxed If true, use relaxed parsing behavior. If false, use strict parsing behavior.
378
+ * @param args.strict If true, use strict parsing behavior. If false, use relaxed parsing behavior.
380
379
  *
381
380
  * @returns valid = true if the string is valid, valid = false if not. If the string
382
381
  * is not valid, invalidReason will be set explaining why it is invalid.
383
382
  */
384
- static isValid(args: { input: AccountAddressInput; relaxed?: boolean }): ParsingResult<AddressInvalidReason> {
383
+ static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {
385
384
  try {
386
- if (args.relaxed) {
387
- AccountAddress.fromRelaxed(args.input);
385
+ if (args.strict) {
386
+ AccountAddress.fromStrict(args.input);
388
387
  } else {
389
388
  AccountAddress.from(args.input);
390
389
  }
391
390
  return { valid: true };
392
- } catch (e) {
393
- const error = e as ParsingError<AddressInvalidReason>;
391
+ } catch (error: any) {
394
392
  return {
395
393
  valid: false,
396
- invalidReason: error.invalidReason,
397
- invalidReasonMessage: error.message,
394
+ invalidReason: error?.invalidReason,
395
+ invalidReasonMessage: error?.message,
398
396
  };
399
397
  }
400
398
  }
@@ -77,4 +77,16 @@ export class AnyPublicKey extends PublicKey {
77
77
  throw new Error(`Unknown variant index for AnyPublicKey: ${index}`);
78
78
  }
79
79
  }
80
+
81
+ static isPublicKey(publicKey: PublicKey): publicKey is AnyPublicKey {
82
+ return publicKey instanceof AnyPublicKey;
83
+ }
84
+
85
+ isEd25519(): this is Ed25519PublicKey {
86
+ return this.publicKey instanceof Ed25519PublicKey;
87
+ }
88
+
89
+ isSecp256k1PublicKey(): this is Secp256k1PublicKey {
90
+ return this.publicKey instanceof Secp256k1PublicKey;
91
+ }
80
92
  }
@@ -88,6 +88,11 @@ export class Ed25519PublicKey extends PublicKey {
88
88
  const bytes = deserializer.deserializeBytes();
89
89
  return new Ed25519PublicKey(bytes);
90
90
  }
91
+
92
+ // TODO(greg): Currently, we can't put this on the abstract type, because of a circular dependency
93
+ static isPublicKey(publicKey: PublicKey): publicKey is Ed25519PublicKey {
94
+ return publicKey instanceof Ed25519PublicKey;
95
+ }
91
96
  }
92
97
 
93
98
  /**
@@ -226,6 +231,10 @@ export class Ed25519PrivateKey extends PrivateKey {
226
231
  });
227
232
  return new Ed25519PrivateKey(privateKey);
228
233
  }
234
+
235
+ static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {
236
+ return privateKey instanceof Ed25519PrivateKey;
237
+ }
229
238
  }
230
239
 
231
240
  /**
@@ -284,4 +293,8 @@ export class Ed25519Signature extends Signature {
284
293
  const bytes = deserializer.deserializeBytes();
285
294
  return new Ed25519Signature(bytes);
286
295
  }
296
+
297
+ static isSignature(signature: Signature): signature is Ed25519Signature {
298
+ return signature instanceof Ed25519Signature;
299
+ }
287
300
  }
@@ -7,3 +7,5 @@ export * from "./multiEd25519";
7
7
  export * from "./secp256k1";
8
8
  export * from "./multiKey";
9
9
  export * from "./hdKey";
10
+ export * from "./anyPublicKey";
11
+ export * from "./anySignature";
@@ -83,6 +83,10 @@ export class Secp256k1PublicKey extends PublicKey {
83
83
  const bytes = deserializer.deserializeBytes();
84
84
  return new Secp256k1PublicKey(bytes);
85
85
  }
86
+
87
+ static isPublicKey(publicKey: PublicKey): publicKey is Secp256k1PublicKey {
88
+ return publicKey instanceof Secp256k1PublicKey;
89
+ }
86
90
  }
87
91
 
88
92
  /**
@@ -209,6 +213,10 @@ export class Secp256k1PrivateKey extends PrivateKey {
209
213
 
210
214
  return new Secp256k1PrivateKey(privateKey);
211
215
  }
216
+
217
+ static isPrivateKey(privateKey: PrivateKey): privateKey is Secp256k1PrivateKey {
218
+ return privateKey instanceof Secp256k1PrivateKey;
219
+ }
212
220
  }
213
221
 
214
222
  /**
@@ -272,4 +280,8 @@ export class Secp256k1Signature extends Signature {
272
280
  const bytes = deserializer.deserializeBytes();
273
281
  return new Secp256k1Signature(bytes);
274
282
  }
283
+
284
+ static isSignature(signature: Signature): signature is Secp256k1Signature {
285
+ return signature instanceof Secp256k1Signature;
286
+ }
275
287
  }
package/src/core/hex.ts CHANGED
@@ -115,10 +115,9 @@ export class Hex {
115
115
 
116
116
  try {
117
117
  return new Hex(hexToBytes(input));
118
- } catch (e) {
119
- const error = e as Error;
118
+ } catch (error: any) {
120
119
  throw new ParsingError(
121
- `Hex string contains invalid hex characters: ${error.message}`,
120
+ `Hex string contains invalid hex characters: ${error?.message}`,
122
121
  HexInvalidReason.INVALID_HEX_CHARS,
123
122
  );
124
123
  }
@@ -153,12 +152,11 @@ export class Hex {
153
152
  try {
154
153
  Hex.fromString(str);
155
154
  return { valid: true };
156
- } catch (e) {
157
- const error = e as ParsingError<HexInvalidReason>;
155
+ } catch (error: any) {
158
156
  return {
159
157
  valid: false,
160
- invalidReason: error.invalidReason,
161
- invalidReasonMessage: error.message,
158
+ invalidReason: error?.invalidReason,
159
+ invalidReasonMessage: error?.message,
162
160
  };
163
161
  }
164
162
  }
package/src/index.ts CHANGED
@@ -6,5 +6,6 @@ export * from "./bcs";
6
6
  export * from "./client";
7
7
  export * from "./core";
8
8
  export * from "./transactions";
9
+ export * from "./transactions/management";
9
10
  export * from "./types";
10
11
  export * from "./utils";