@aptos-labs/ts-sdk 6.1.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +9 -13
  2. package/dist/common/{account-CSOaJ0SC.d.ts → account-DGpxrkAn.d.ts} +6 -2
  3. package/dist/common/chunk-2VR6ONNW.js +4 -0
  4. package/dist/common/{chunk-3NBJLJ2Y.js.map → chunk-2VR6ONNW.js.map} +1 -1
  5. package/dist/common/cli/index.d.ts +2 -2
  6. package/dist/common/cli/index.js +1 -1
  7. package/dist/common/cli/index.js.map +1 -1
  8. package/dist/common/index.d.ts +22 -20
  9. package/dist/common/index.js +31 -31
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/Account.mjs +1 -1
  14. package/dist/esm/account/AccountUtils.mjs +1 -1
  15. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.mjs +1 -1
  17. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  18. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  19. package/dist/esm/account/KeylessAccount.mjs +1 -1
  20. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  21. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  22. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  23. package/dist/esm/account/index.mjs +1 -1
  24. package/dist/esm/account/utils.mjs +1 -1
  25. package/dist/esm/api/account/abstraction.mjs +1 -1
  26. package/dist/esm/api/account.mjs +1 -1
  27. package/dist/esm/api/ans.mjs +1 -1
  28. package/dist/esm/api/aptos.mjs +1 -1
  29. package/dist/esm/api/aptosConfig.mjs +1 -1
  30. package/dist/esm/api/coin.mjs +1 -1
  31. package/dist/esm/api/digitalAsset.mjs +1 -1
  32. package/dist/esm/api/faucet.mjs +1 -1
  33. package/dist/esm/api/fungibleAsset.mjs +1 -1
  34. package/dist/esm/api/general.mjs +1 -1
  35. package/dist/esm/api/index.mjs +1 -1
  36. package/dist/esm/api/keyless.mjs +1 -1
  37. package/dist/esm/api/object.mjs +1 -1
  38. package/dist/esm/api/staking.mjs +1 -1
  39. package/dist/esm/api/table.mjs +1 -1
  40. package/dist/esm/api/transaction.d.mts +19 -17
  41. package/dist/esm/api/transaction.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  43. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  44. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  45. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  46. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  47. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  48. package/dist/esm/api/utils.mjs +1 -1
  49. package/dist/esm/bcs/index.mjs +1 -1
  50. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  51. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  52. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  53. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  54. package/dist/esm/bcs/serializer.mjs +1 -1
  55. package/dist/esm/chunk-2CH5QB7U.mjs +4 -0
  56. package/dist/esm/chunk-2CH5QB7U.mjs.map +1 -0
  57. package/dist/esm/{chunk-UZMJ4DAO.mjs → chunk-2VBY2V4Z.mjs} +2 -2
  58. package/dist/esm/{chunk-VW3Y5EOJ.mjs → chunk-44MMFX5F.mjs} +1 -1
  59. package/dist/esm/chunk-44MMFX5F.mjs.map +1 -0
  60. package/dist/esm/chunk-5HHC2YG4.mjs +2 -0
  61. package/dist/esm/chunk-5LMLIRGK.mjs +2 -0
  62. package/dist/esm/chunk-5LMLIRGK.mjs.map +1 -0
  63. package/dist/esm/chunk-66F7RP7K.mjs +2 -0
  64. package/dist/esm/chunk-66F7RP7K.mjs.map +1 -0
  65. package/dist/esm/{chunk-YNNDFGVQ.mjs → chunk-A7SQEK23.mjs} +2 -2
  66. package/dist/esm/chunk-A7SQEK23.mjs.map +1 -0
  67. package/dist/esm/{chunk-KLDERTLN.mjs → chunk-ASFFADWS.mjs} +2 -2
  68. package/dist/esm/{chunk-32J7VMLV.mjs → chunk-BT742BFQ.mjs} +2 -2
  69. package/dist/esm/chunk-BT742BFQ.mjs.map +1 -0
  70. package/dist/esm/chunk-C2KVLMPH.mjs +2 -0
  71. package/dist/esm/chunk-C2KVLMPH.mjs.map +1 -0
  72. package/dist/esm/{chunk-VWXVSRRQ.mjs → chunk-CD3EZCI5.mjs} +2 -2
  73. package/dist/esm/{chunk-QV37KEZY.mjs → chunk-E3DHFXN4.mjs} +2 -2
  74. package/dist/esm/{chunk-DE4YVX3L.mjs → chunk-EIWPAECI.mjs} +2 -2
  75. package/dist/esm/{chunk-US6KOOYS.mjs → chunk-F4LHBGG2.mjs} +2 -2
  76. package/dist/esm/chunk-F4LHBGG2.mjs.map +1 -0
  77. package/dist/esm/{chunk-TIMTVXFU.mjs → chunk-F5KAWYF5.mjs} +2 -2
  78. package/dist/esm/chunk-F5KAWYF5.mjs.map +1 -0
  79. package/dist/esm/{chunk-VWLK43JM.mjs → chunk-FDHHQUS3.mjs} +2 -2
  80. package/dist/esm/{chunk-3FDSKP56.mjs → chunk-J73MMLF7.mjs} +2 -2
  81. package/dist/esm/{chunk-DRGODFFX.mjs → chunk-LTZRUAGD.mjs} +2 -2
  82. package/dist/esm/{chunk-RGXAFBFA.mjs → chunk-NTREJSOS.mjs} +2 -2
  83. package/dist/esm/{chunk-PDNDARQY.mjs → chunk-OAK2V35A.mjs} +2 -2
  84. package/dist/esm/{chunk-UNA3V4UB.mjs → chunk-POQ4FT4E.mjs} +2 -2
  85. package/dist/esm/{chunk-WRV7BWXE.mjs → chunk-QFUXOL34.mjs} +2 -2
  86. package/dist/esm/{chunk-YOT47DDX.mjs → chunk-QRW7MQDA.mjs} +2 -2
  87. package/dist/esm/chunk-QRW7MQDA.mjs.map +1 -0
  88. package/dist/esm/{chunk-RSUFVB4P.mjs → chunk-R7PCBRRT.mjs} +2 -2
  89. package/dist/esm/{chunk-BHVMFSAD.mjs → chunk-TAHLOBRG.mjs} +2 -2
  90. package/dist/esm/chunk-TAHLOBRG.mjs.map +1 -0
  91. package/dist/esm/{chunk-DECWO3X5.mjs → chunk-TEI33TO7.mjs} +2 -2
  92. package/dist/esm/{chunk-POKQD2RK.mjs → chunk-TSPG5VED.mjs} +2 -2
  93. package/dist/esm/{chunk-QYC3HOQX.mjs → chunk-UBPX6GOS.mjs} +2 -2
  94. package/dist/esm/{chunk-YMZF4KMT.mjs → chunk-UPHD2B4I.mjs} +2 -2
  95. package/dist/esm/{chunk-U5HTF4OK.mjs → chunk-UVJW4DPP.mjs} +1 -1
  96. package/dist/esm/{chunk-U5HTF4OK.mjs.map → chunk-UVJW4DPP.mjs.map} +1 -1
  97. package/dist/esm/{chunk-GP3CDQFI.mjs → chunk-UYG4XVVO.mjs} +2 -2
  98. package/dist/esm/chunk-UYG4XVVO.mjs.map +1 -0
  99. package/dist/esm/{chunk-3Q3J4DTI.mjs → chunk-WD3SPNH7.mjs} +2 -2
  100. package/dist/esm/{chunk-UXDYADZV.mjs → chunk-WFZFTRRS.mjs} +2 -2
  101. package/dist/esm/chunk-WVKZFOPV.mjs +2 -0
  102. package/dist/esm/{chunk-QRD5NGNC.mjs.map → chunk-WVKZFOPV.mjs.map} +1 -1
  103. package/dist/esm/{chunk-SZBXWUBS.mjs → chunk-YJVBGKWM.mjs} +2 -2
  104. package/dist/esm/cli/index.d.mts +1 -1
  105. package/dist/esm/cli/index.mjs +1 -1
  106. package/dist/esm/cli/localNode.d.mts +1 -1
  107. package/dist/esm/cli/localNode.mjs +1 -1
  108. package/dist/esm/cli/move.mjs +1 -1
  109. package/dist/esm/client/core.mjs +1 -1
  110. package/dist/esm/client/get.mjs +1 -1
  111. package/dist/esm/client/index.mjs +1 -1
  112. package/dist/esm/client/post.mjs +1 -1
  113. package/dist/esm/core/account/index.mjs +1 -1
  114. package/dist/esm/core/account/utils/address.mjs +1 -1
  115. package/dist/esm/core/account/utils/index.mjs +1 -1
  116. package/dist/esm/core/accountAddress.mjs +1 -1
  117. package/dist/esm/core/authenticationKey.mjs +1 -1
  118. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  119. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  120. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  121. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  122. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  123. package/dist/esm/core/crypto/index.mjs +1 -1
  124. package/dist/esm/core/crypto/keyless.mjs +1 -1
  125. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  126. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  127. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  128. package/dist/esm/core/crypto/proof.mjs +1 -1
  129. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  130. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  131. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  132. package/dist/esm/core/crypto/signature.mjs +1 -1
  133. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  134. package/dist/esm/core/crypto/utils.mjs +1 -1
  135. package/dist/esm/core/index.mjs +1 -1
  136. package/dist/esm/errors/index.mjs +1 -1
  137. package/dist/esm/index.d.mts +1 -1
  138. package/dist/esm/index.mjs +1 -1
  139. package/dist/esm/internal/abstraction.mjs +1 -1
  140. package/dist/esm/internal/account.mjs +1 -1
  141. package/dist/esm/internal/ans.mjs +1 -1
  142. package/dist/esm/internal/coin.mjs +1 -1
  143. package/dist/esm/internal/digitalAsset.mjs +1 -1
  144. package/dist/esm/internal/faucet.mjs +1 -1
  145. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  146. package/dist/esm/internal/general.mjs +1 -1
  147. package/dist/esm/internal/keyless.mjs +1 -1
  148. package/dist/esm/internal/object.mjs +1 -1
  149. package/dist/esm/internal/staking.mjs +1 -1
  150. package/dist/esm/internal/table.mjs +1 -1
  151. package/dist/esm/internal/transaction.mjs +1 -1
  152. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  153. package/dist/esm/internal/utils/index.mjs +1 -1
  154. package/dist/esm/internal/utils/utils.mjs +1 -1
  155. package/dist/esm/internal/view.mjs +1 -1
  156. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  157. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  158. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  159. package/dist/esm/transactions/index.mjs +1 -1
  160. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  161. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  162. package/dist/esm/transactions/instances/index.mjs +1 -1
  163. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  164. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  165. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  166. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  167. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  168. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  169. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  170. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  171. package/dist/esm/transactions/management/index.mjs +1 -1
  172. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  173. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  174. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  175. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  176. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  177. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  178. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  179. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  180. package/dist/esm/utils/const.d.mts +6 -2
  181. package/dist/esm/utils/const.mjs +1 -1
  182. package/dist/esm/utils/helpers.mjs +1 -1
  183. package/dist/esm/utils/index.d.mts +1 -1
  184. package/dist/esm/utils/index.mjs +1 -1
  185. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  186. package/dist/esm/version.d.mts +1 -1
  187. package/dist/esm/version.mjs +1 -1
  188. package/package.json +15 -22
  189. package/src/account/EphemeralKeyPair.ts +0 -1
  190. package/src/api/aptos.ts +1 -2
  191. package/src/api/aptosConfig.ts +1 -3
  192. package/src/api/transaction.ts +19 -17
  193. package/src/api/transactionSubmission/helpers.ts +0 -1
  194. package/src/bcs/serializable/movePrimitives.ts +0 -1
  195. package/src/bcs/serializer.ts +1 -5
  196. package/src/cli/localNode.ts +2 -4
  197. package/src/cli/move.ts +2 -2
  198. package/src/core/account/utils/address.ts +3 -3
  199. package/src/core/crypto/abstraction.ts +0 -3
  200. package/src/core/crypto/keyless.ts +0 -1
  201. package/src/core/crypto/privateKey.ts +0 -1
  202. package/src/core/crypto/singleKey.ts +0 -1
  203. package/src/internal/account.ts +1 -1
  204. package/src/internal/keyless.ts +1 -1
  205. package/src/internal/queries/getAccountAddressesForAuthKey.graphql +4 -1
  206. package/src/internal/queries/getAuthKeysForPublicKey.graphql +4 -1
  207. package/src/internal/queries/getTableItemsData.graphql +1 -1
  208. package/src/internal/queries/getTableItemsMetadata.graphql +2 -2
  209. package/src/internal/transaction.ts +2 -2
  210. package/src/transactions/authenticator/account.ts +0 -1
  211. package/src/transactions/instances/transactionPayload.ts +0 -3
  212. package/src/transactions/management/accountSequenceNumber.ts +0 -2
  213. package/src/transactions/transactionBuilder/remoteAbi.ts +11 -16
  214. package/src/transactions/transactionBuilder/transactionBuilder.ts +1 -3
  215. package/src/transactions/typeTag/index.ts +0 -3
  216. package/src/transactions/typeTag/parser.ts +2 -3
  217. package/src/utils/const.ts +6 -1
  218. package/src/utils/helpers.ts +3 -4
  219. package/src/version.ts +1 -1
  220. package/dist/common/chunk-3NBJLJ2Y.js +0 -4
  221. package/dist/esm/chunk-32J7VMLV.mjs.map +0 -1
  222. package/dist/esm/chunk-7FG7RJDS.mjs +0 -2
  223. package/dist/esm/chunk-7FG7RJDS.mjs.map +0 -1
  224. package/dist/esm/chunk-BHVMFSAD.mjs.map +0 -1
  225. package/dist/esm/chunk-CWI5B5KE.mjs +0 -2
  226. package/dist/esm/chunk-GP3CDQFI.mjs.map +0 -1
  227. package/dist/esm/chunk-GWM3VCT4.mjs +0 -4
  228. package/dist/esm/chunk-GWM3VCT4.mjs.map +0 -1
  229. package/dist/esm/chunk-HHAUJ5E4.mjs +0 -2
  230. package/dist/esm/chunk-HHAUJ5E4.mjs.map +0 -1
  231. package/dist/esm/chunk-QRD5NGNC.mjs +0 -2
  232. package/dist/esm/chunk-TIMTVXFU.mjs.map +0 -1
  233. package/dist/esm/chunk-US6KOOYS.mjs.map +0 -1
  234. package/dist/esm/chunk-V5K2RRFT.mjs +0 -2
  235. package/dist/esm/chunk-V5K2RRFT.mjs.map +0 -1
  236. package/dist/esm/chunk-VW3Y5EOJ.mjs.map +0 -1
  237. package/dist/esm/chunk-YNNDFGVQ.mjs.map +0 -1
  238. package/dist/esm/chunk-YOT47DDX.mjs.map +0 -1
  239. /package/dist/esm/{chunk-UZMJ4DAO.mjs.map → chunk-2VBY2V4Z.mjs.map} +0 -0
  240. /package/dist/esm/{chunk-CWI5B5KE.mjs.map → chunk-5HHC2YG4.mjs.map} +0 -0
  241. /package/dist/esm/{chunk-KLDERTLN.mjs.map → chunk-ASFFADWS.mjs.map} +0 -0
  242. /package/dist/esm/{chunk-VWXVSRRQ.mjs.map → chunk-CD3EZCI5.mjs.map} +0 -0
  243. /package/dist/esm/{chunk-QV37KEZY.mjs.map → chunk-E3DHFXN4.mjs.map} +0 -0
  244. /package/dist/esm/{chunk-DE4YVX3L.mjs.map → chunk-EIWPAECI.mjs.map} +0 -0
  245. /package/dist/esm/{chunk-VWLK43JM.mjs.map → chunk-FDHHQUS3.mjs.map} +0 -0
  246. /package/dist/esm/{chunk-3FDSKP56.mjs.map → chunk-J73MMLF7.mjs.map} +0 -0
  247. /package/dist/esm/{chunk-DRGODFFX.mjs.map → chunk-LTZRUAGD.mjs.map} +0 -0
  248. /package/dist/esm/{chunk-RGXAFBFA.mjs.map → chunk-NTREJSOS.mjs.map} +0 -0
  249. /package/dist/esm/{chunk-PDNDARQY.mjs.map → chunk-OAK2V35A.mjs.map} +0 -0
  250. /package/dist/esm/{chunk-UNA3V4UB.mjs.map → chunk-POQ4FT4E.mjs.map} +0 -0
  251. /package/dist/esm/{chunk-WRV7BWXE.mjs.map → chunk-QFUXOL34.mjs.map} +0 -0
  252. /package/dist/esm/{chunk-RSUFVB4P.mjs.map → chunk-R7PCBRRT.mjs.map} +0 -0
  253. /package/dist/esm/{chunk-DECWO3X5.mjs.map → chunk-TEI33TO7.mjs.map} +0 -0
  254. /package/dist/esm/{chunk-POKQD2RK.mjs.map → chunk-TSPG5VED.mjs.map} +0 -0
  255. /package/dist/esm/{chunk-QYC3HOQX.mjs.map → chunk-UBPX6GOS.mjs.map} +0 -0
  256. /package/dist/esm/{chunk-YMZF4KMT.mjs.map → chunk-UPHD2B4I.mjs.map} +0 -0
  257. /package/dist/esm/{chunk-3Q3J4DTI.mjs.map → chunk-WD3SPNH7.mjs.map} +0 -0
  258. /package/dist/esm/{chunk-UXDYADZV.mjs.map → chunk-WFZFTRRS.mjs.map} +0 -0
  259. /package/dist/esm/{chunk-SZBXWUBS.mjs.map → chunk-YJVBGKWM.mjs.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-V5K2RRFT.mjs";import{b as e}from"./chunk-STY74NUA.mjs";var r=class extends i{async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.bcsToBytes()}toString(){let t=this.toUint8Array();return e.fromHexInput(t).toString()}},n=class extends r{};export{r as a,n as b};
2
- //# sourceMappingURL=chunk-UZMJ4DAO.mjs.map
1
+ import{a as i}from"./chunk-66F7RP7K.mjs";import{b as e}from"./chunk-STY74NUA.mjs";var r=class extends i{async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.bcsToBytes()}toString(){let t=this.toUint8Array();return e.fromHexInput(t).toString()}},n=class extends r{};export{r as a,n as b};
2
+ //# sourceMappingURL=chunk-2VBY2V4Z.mjs.map
@@ -1,2 +1,2 @@
1
1
  import{spawn as p}from"child_process";import{platform as g}from"os";var u=class{async init(t){let{network:o,profile:e,extraArguments:r,showStdout:a}=t,s=["aptos","init",`--network=${o??"local"}`,`--profile=${e??"default"}`];return r&&s.push(...r),this.runCommand(s,a)}async compile(t){let{packageDirectoryPath:o,namedAddresses:e,extraArguments:r,showStdout:a}=t,s=["aptos","move","compile","--package-dir",o],n=this.parseNamedAddresses(e);return s.push(...this.prepareNamedAddresses(n)),r&&s.push(...r),this.runCommand(s,a)}async test(t){let{packageDirectoryPath:o,namedAddresses:e,extraArguments:r,showStdout:a}=t,s=["aptos","move","test","--package-dir",o],n=this.parseNamedAddresses(e);return s.push(...this.prepareNamedAddresses(n)),r&&s.push(...r),this.runCommand(s,a)}async publish(t){let{packageDirectoryPath:o,namedAddresses:e,profile:r,extraArguments:a,showStdout:s}=t,n=["aptos","move","publish","--package-dir",o,`--profile=${r??"default"}`],d=this.parseNamedAddresses(e);return n.push(...this.prepareNamedAddresses(d)),a&&n.push(...a),this.runCommand(n,s)}async createObjectAndPublishPackage(t){let{packageDirectoryPath:o,addressName:e,namedAddresses:r,profile:a,extraArguments:s,showStdout:n}=t,d=["aptos","move","create-object-and-publish-package","--package-dir",o,"--address-name",e,`--profile=${a??"default"}`],i=this.parseNamedAddresses(r);d.push(...this.prepareNamedAddresses(i)),s&&d.push(...s);let{output:c}=await this.runCommand(d,n);return{objectAddress:this.extractAddressFromOutput(c)}}async upgradeObjectPackage(t){let{packageDirectoryPath:o,objectAddress:e,namedAddresses:r,profile:a,extraArguments:s,showStdout:n}=t,d=["aptos","move","upgrade-object-package","--package-dir",o,"--object-address",e,`--profile=${a??"default"}`],i=this.parseNamedAddresses(r);return d.push(...this.prepareNamedAddresses(i)),s&&d.push(...s),this.runCommand(d,n)}async buildPublishPayload(t){let{outputFile:o,packageDirectoryPath:e,namedAddresses:r,extraArguments:a,showStdout:s}=t,n=["aptos","move","build-publish-payload","--json-output-file",o,"--package-dir",e],d=this.parseNamedAddresses(r);return n.push(...this.prepareNamedAddresses(d)),a&&n.push(...a),this.runCommand(n,s)}async runScript(t){let{compiledScriptPath:o,profile:e,extraArguments:r,showStdout:a}=t,s=["aptos","move","run-script","--compiled-script-path",o,`--profile=${e??"default"}`];return r&&s.push(...r),this.runCommand(s,a)}async gasProfile(t){let{network:o,transactionId:e,extraArguments:r,showStdout:a}=t,s=["aptos","move","replay","--profile-gas","--network",o,"--txn-id",e];return r&&s.push(...r),this.runCommand(s,a)}async runCommand(t,o=!0){return new Promise((e,r)=>{let a=g(),s,n="",d="";a==="win32"?s=p("npx",t,{shell:!0}):s=p("npx",t),s.stdout.on("data",i=>{d=i.toString(),n+=i.toString()}),o&&(s.stdout.pipe(process.stdout),s.stderr.pipe(process.stderr)),process.stdin.pipe(s.stdin),s.on("close",i=>{if(i===0)try{let c=JSON.parse(d);c.Error?r(new Error(`Error: ${c.Error}`)):c.Result&&e({result:c.Result,output:n})}catch{e({output:n})}else r(new Error(`Child process exited with code ${i}`))})})}prepareNamedAddresses(t){let o=t.size,e=[];if(o===0)return e;e.push("--named-addresses");let r=[];return t.forEach((a,s)=>{let n=`${s}=${a.toString()}`;r.push(n)}),e.push(r.join(",")),e}parseNamedAddresses(t){let o=new Map;return Object.keys(t).forEach(e=>{let r=t[e];o.set(e,r)}),o}extractAddressFromOutput(t){let o=t.match("Code was successfully deployed to object address (0x[0-9a-fA-F]+)");if(o)return o[1];throw new Error("Failed to extract object address from output")}};export{u as a};
2
- //# sourceMappingURL=chunk-VW3Y5EOJ.mjs.map
2
+ //# sourceMappingURL=chunk-44MMFX5F.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/move.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { platform } from \"node:os\";\n\nimport { AccountAddress } from \"../core\";\nimport { Network } from \"../utils\";\n\n/**\n * Class representing a Move package management utility for the Aptos blockchain.\n * This class provides methods to initialize directories, compile packages, run tests, publish modules, create objects, upgrade\n * packages, build transaction payloads, and run scripts.\n * @group Implementation\n * @category CLI\n */\nexport class Move {\n /**\n * Initialize the current directory for Aptos by configuring the necessary settings.\n * Configuration will be pushed into .aptos/config.yaml.\n *\n * @param args - The arguments for initialization.\n * @param args.network - Optional Network type argument to use for default settings; defaults to local.\n * @param args.profile - Optional Profile to use from the config file; defaults to 'default'. This will override associated\n * settings such as the REST URL, the Faucet URL, and the private key arguments.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n * @group Implementation\n * @category CLI\n */\n async init(args: {\n network?: Network;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { network, profile, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"init\", `--network=${network ?? \"local\"}`, `--profile=${profile ?? \"default\"}`];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Compile a Move package located at the specified directory path.\n * This function helps in preparing the Move package for deployment or further processing.\n *\n * @param args - The arguments for compiling the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n * @group Implementation\n * @category CLI\n */\n async compile(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"compile\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run Move unit tests for a specified package.\n *\n * @param args - The arguments for running the tests.\n * @param args.packageDirectoryPath - The path to a Move package (the folder containing a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The stdout output from running the tests.\n * @group Implementation\n * @category CLI\n */\n async test(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"test\", \"--package-dir\", packageDirectoryPath];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Publishes the modules to the publisher account on the Aptos blockchain.\n *\n * @param args - The arguments for publishing the modules.\n * @param args.packageDirectoryPath - The path to a move package (the folder with a Move.toml file).\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n * @group Implementation\n * @category CLI\n */\n async publish(args: {\n packageDirectoryPath: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"publish\",\n \"--package-dir\",\n packageDirectoryPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Create a new object and publish the Move package to it on the Aptos blockchain.\n *\n * @param args - The arguments for creating the object and publishing the package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.addressName - Address name for the Move package.\n * @param args.namedAddresses - Named addresses for the Move binary.\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns The object address.\n *\n * A complete example in CLI:\n * aptos move create-object-and-publish-package \\\n * --package-dir path_to_directory_that_has_move.toml \\\n * --address-name launchpad_addr \\\n * --named-addresses \"launchpad_addr=0x123,initial_creator_addr=0x456\" \\\n * --profile my_profile \\\n * --assume-yes\n * @group Implementation\n * @category CLI\n */\n async createObjectAndPublishPackage(args: {\n packageDirectoryPath: string;\n addressName: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ objectAddress: string }> {\n const { packageDirectoryPath, addressName, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"create-object-and-publish-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--address-name\",\n addressName,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n const { output } = await this.runCommand(cliArgs, showStdout);\n return { objectAddress: this.extractAddressFromOutput(output) };\n }\n\n /**\n * Upgrade a Move package previously published to an object on the Aptos blockchain.\n * The caller must be the object owner to execute this function.\n *\n * @param args - The arguments for upgrading the object package.\n * @param args.packageDirectoryPath - Path to a Move package (the folder with a Move.toml file).\n * @param args.objectAddress - Address of the object that the Move package published to. Ex. 0x1000\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n * @returns stdout\n * @group Implementation\n * @category CLI\n */\n async upgradeObjectPackage(args: {\n packageDirectoryPath: string;\n objectAddress: string;\n namedAddresses: Record<string, AccountAddress>;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { packageDirectoryPath, objectAddress, namedAddresses, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"upgrade-object-package\",\n \"--package-dir\",\n packageDirectoryPath,\n \"--object-address\",\n objectAddress,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Build a publication transaction payload and store it in a JSON output file.\n *\n * @param args - The arguments for building the publishing payload.\n * @param args.packageDirectoryPath - Path to a move package (the folder with a Move.toml file).\n * @param args.outputFile - Output file to write the publication transaction to.\n * @param args.namedAddresses - Named addresses for the move binary. Ex. { alice: 0x1234, bob: 0x5678 }\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"] *\n * @returns stdout\n * @group Implementation\n * @category CLI\n */\n async buildPublishPayload(args: {\n packageDirectoryPath: string;\n outputFile: string;\n namedAddresses: Record<string, AccountAddress>;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { outputFile, packageDirectoryPath, namedAddresses, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"build-publish-payload\",\n \"--json-output-file\",\n outputFile,\n \"--package-dir\",\n packageDirectoryPath,\n ];\n\n const addressesMap = this.parseNamedAddresses(namedAddresses);\n\n cliArgs.push(...this.prepareNamedAddresses(addressesMap));\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Runs a Move script using the provided compiled script path and optional parameters. Ensure that the script is compiled\n * before executing this function.\n *\n * @param args - The arguments for running the script.\n * @param args.compiledScriptPath - Path to a compiled Move script bytecode file.\n * Ex. \"build/my_package/bytecode_scripts/my_move_script.mv\"\n * @param args.profile - Optional profile to use from the config file.\n * @param args.extraArguments - Optional extra arguments to include in the form of an array of strings.\n * Ex. [\"--assume-yes\",\"--gas-unit-price=10\"]\n *\n * @returns The standard output from running the script.\n * @group Implementation\n * @category CLI\n */\n async runScript(args: {\n compiledScriptPath: string;\n profile?: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string }> {\n const { compiledScriptPath, profile, extraArguments, showStdout } = args;\n const cliArgs = [\n \"aptos\",\n \"move\",\n \"run-script\",\n \"--compiled-script-path\",\n compiledScriptPath,\n `--profile=${profile ?? \"default\"}`,\n ];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n async gasProfile(args: {\n network: string;\n transactionId: string;\n extraArguments?: Array<string>;\n showStdout?: boolean;\n }): Promise<{ output: string; result?: any }> {\n const { network, transactionId, extraArguments, showStdout } = args;\n const cliArgs = [\"aptos\", \"move\", \"replay\", \"--profile-gas\", \"--network\", network, \"--txn-id\", transactionId];\n\n if (extraArguments) {\n cliArgs.push(...extraArguments);\n }\n\n return this.runCommand(cliArgs, showStdout);\n }\n\n /**\n * Run a command with the specified arguments and return the output.\n *\n * @param args - An array of strings representing the command-line arguments to be passed to the command.\n * @param showStdout - Show the standard output generated by the command.\n * @returns The standard output generated by the command.\n * @group Implementation\n * @category CLI\n */\n\n private async runCommand(args: Array<string>, showStdout: boolean = true): Promise<{ result?: any; output: string }> {\n return new Promise((resolve, reject) => {\n const currentPlatform = platform();\n let childProcess;\n let stdout = \"\";\n // CLI final stdout is the Result/Error JSON string output\n // so we need to keep track of the last stdout\n let lastStdout = \"\";\n\n // Check if current OS is windows\n if (currentPlatform === \"win32\") {\n childProcess = spawn(\"npx\", args, { shell: true });\n } else {\n childProcess = spawn(\"npx\", args);\n }\n\n childProcess.stdout.on(\"data\", (data) => {\n lastStdout = data.toString();\n stdout += data.toString();\n });\n\n if (showStdout) {\n childProcess.stdout.pipe(process.stdout);\n childProcess.stderr.pipe(process.stderr);\n }\n process.stdin.pipe(childProcess.stdin);\n\n childProcess.on(\"close\", (code) => {\n if (code === 0) {\n try {\n // parse the last stdout as it might be the result\n const parsed = JSON.parse(lastStdout);\n if (parsed.Error) {\n reject(new Error(`Error: ${parsed.Error}`)); // Reject if the \"Error\" key exists\n } else if (parsed.Result) {\n resolve({ result: parsed.Result, output: stdout }); // Resolve if the \"Result\" key exists\n }\n } catch {\n // resolve the stdout as it might be just a stdout\n resolve({ output: stdout });\n }\n } else {\n reject(new Error(`Child process exited with code ${code}`)); // Reject with an error if the child process exits with an error code\n }\n });\n });\n }\n\n /**\n * Convert named addresses from a Map into an array separated by a comma.\n *\n * @param namedAddresses - A Map where the key is a string representing the name and the value is an AccountAddress.\n * Ex. {'alice' => '0x123', 'bob' => '0x456'}\n * @returns An array of named addresses formatted as strings separated by a comma. Ex. \"alice=0x123,bob=0x456\"\n * @group Implementation\n * @category CLI\n */\n\n private prepareNamedAddresses(namedAddresses: Map<string, AccountAddress>): Array<string> {\n const totalNames = namedAddresses.size;\n const newArgs: Array<string> = [];\n\n if (totalNames === 0) {\n return newArgs;\n }\n\n newArgs.push(\"--named-addresses\");\n\n const names: Array<string> = [];\n namedAddresses.forEach((value, key) => {\n const toAppend = `${key}=${value.toString()}`;\n names.push(toAppend);\n });\n newArgs.push(names.join(\",\"));\n return newArgs;\n }\n\n /**\n * Parse named addresses from a Record type into a Map.\n *\n * This function transforms a collection of named addresses into a more accessible format by mapping each name to its\n * corresponding address.\n *\n * @param namedAddresses - A record containing named addresses where the key is the name and the value is the AccountAddress.\n * @returns A Map where each key is a name and each value is the corresponding address.\n * @group Implementation\n * @category CLI\n */\n\n private parseNamedAddresses(namedAddresses: Record<string, AccountAddress>): Map<string, AccountAddress> {\n const addressesMap = new Map();\n\n Object.keys(namedAddresses).forEach((key) => {\n const address = namedAddresses[key];\n addressesMap.set(key, address);\n });\n\n return addressesMap;\n }\n\n /**\n * Extracts the object address from the provided output string.\n *\n * @param output - The output string containing the object address.\n * @returns The extracted object address.\n * @throws Error if the object address cannot be extracted from the output.\n * @group Implementation\n * @category CLI\n */\n\n private extractAddressFromOutput(output: string): string {\n const match = output.match(\"Code was successfully deployed to object address (0x[0-9a-fA-F]+)\");\n if (match) {\n return match[1];\n }\n throw new Error(\"Failed to extract object address from output\");\n }\n}\n"],"mappings":"AAAA,OAAS,SAAAA,MAAa,gBACtB,OAAS,YAAAC,MAAgB,KAYlB,IAAMC,EAAN,KAAW,CAehB,MAAM,KAAKC,EAKqB,CAC9B,GAAM,CAAE,QAAAC,EAAS,QAAAC,EAAS,eAAAC,EAAgB,WAAAC,CAAW,EAAIJ,EACnDK,EAAU,CAAC,QAAS,OAAQ,aAAaJ,GAAW,OAAO,GAAI,aAAaC,GAAW,SAAS,EAAE,EAExG,OAAIC,GACFE,EAAQ,KAAK,GAAGF,CAAc,EAGzB,KAAK,WAAWE,EAASD,CAAU,CAC5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AAI,EAAE,CAAC,CAE9D,CAAC,CACH,CAAC,CACH,CAYQ,sBAAsBf,EAA4D,CACxF,IAAMiB,EAAajB,EAAe,KAC5BkB,EAAyB,CAAC,EAEhC,GAAID,IAAe,EACjB,OAAOC,EAGTA,EAAQ,KAAK,mBAAmB,EAEhC,IAAMC,EAAuB,CAAC,EAC9B,OAAAnB,EAAe,QAAQ,CAACoB,EAAOC,IAAQ,CACrC,IAAMC,EAAW,GAAGD,CAAG,IAAID,EAAM,SAAS,CAAC,GAC3CD,EAAM,KAAKG,CAAQ,CACrB,CAAC,EACDJ,EAAQ,KAAKC,EAAM,KAAK,GAAG,CAAC,EACrBD,CACT,CAcQ,oBAAoBlB,EAA6E,CACvG,IAAMC,EAAe,IAAI,IAEzB,cAAO,KAAKD,CAAc,EAAE,QAASqB,GAAQ,CAC3C,IAAME,EAAUvB,EAAeqB,CAAG,EAClCpB,EAAa,IAAIoB,EAAKE,CAAO,CAC/B,CAAC,EAEMtB,CACT,CAYQ,yBAAyBE,EAAwB,CACvD,IAAMqB,EAAQrB,EAAO,MAAM,mEAAmE,EAC9F,GAAIqB,EACF,OAAOA,EAAM,CAAC,EAEhB,MAAM,IAAI,MAAM,8CAA8C,CAChE,CACF","names":["spawn","platform","Move","args","network","profile","extraArguments","showStdout","cliArgs","packageDirectoryPath","namedAddresses","addressesMap","addressName","output","objectAddress","outputFile","compiledScriptPath","transactionId","resolve","reject","currentPlatform","childProcess","stdout","lastStdout","data","code","parsed","totalNames","newArgs","names","value","key","toAppend","address","match"]}
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-66F7RP7K.mjs";var e=class extends a{};export{e as a};
2
+ //# sourceMappingURL=chunk-5HHC2YG4.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a as i}from"./chunk-C2KVLMPH.mjs";import{b as r}from"./chunk-FDHHQUS3.mjs";import{Base64 as u,decode as d}from"js-base64";function _(){try{return typeof globalThis<"u"&&"Bun"in globalThis}catch{return!1}}function x(e){typeof process<"u"&&process.env&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test"||process.env.APTOS_SDK_WARNINGS==="true")&&console.warn(e)}async function A(e){return new Promise(n=>{setTimeout(n,e)})}function v(e){return e instanceof Error?e.message:String(e)}var h=()=>Math.floor(Date.now()/1e3);function S(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function b(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return d(t)}function y(e){let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return u.toUint8Array(n)}var T=(e,n)=>e*10**n,M=(e,n)=>e/10**n,a=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},N=e=>{let{account_address:n,module_name:t,struct_name:o}=e,s=a(t),c=a(o);return`${n}::${s}::${c}`},I=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null&&"account_address"in e&&"module_name"in e&&"struct_name"in e&&typeof e.account_address=="string"&&typeof e.module_name=="string"&&typeof e.struct_name=="string";function w(e){let n=e.split("::");if(n.length!==3)throw new Error(`Invalid function ${e}`);let t=n[0],o=n[1],s=n[2];return{moduleAddress:t,moduleName:o,functionName:s}}function E(e){let n=e.split("::");return n.length===3&&r.isValid({input:n[0]}).valid}function D(e,n=6,t=5){return`${e.slice(0,n)}...${e.slice(-t)}`}var m="0x1::aptos_coin::AptosCoin";function l(e){let n=/0x[0-9a-fA-F]+/g;return e.replace(n,t=>r.from(t,{maxMissingChars:63}).toStringShort())}function $(e){let n=l(e);return n===m?r.A:i(r.A,n)}export{_ as a,x as b,A as c,v as d,h as e,S as f,b as g,y as h,T as i,M as j,N as k,I as l,w as m,E as n,D as o,$ as p};
2
+ //# sourceMappingURL=chunk-5LMLIRGK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/helpers.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Base64, decode } from \"js-base64\";\nimport { MoveFunctionId, MoveStructId } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { createObjectAddress } from \"../core/account/utils/address\";\n\n/**\n * Checks if the current runtime environment is Bun.\n * This is useful for detecting Bun-specific compatibility issues.\n *\n * @returns true if running in Bun, false otherwise.\n * @group Implementation\n * @category Utils\n */\nexport function isBun(): boolean {\n try {\n // Bun exposes a global `Bun` object.\n return typeof globalThis !== \"undefined\" && \"Bun\" in globalThis;\n } catch {\n return false;\n }\n}\n\n/**\n * Logs a warning message to the console only in development environments.\n * This function helps reduce information leakage in production while maintaining\n * helpful warnings during development.\n *\n * @param message - The warning message to log.\n * @group Implementation\n * @category Utils\n */\nexport function warnIfDevelopment(message: string): void {\n // Check common environment variables to determine if we're in development\n // This works in Node.js, bundlers like webpack/vite, and most build systems\n const isDevelopment =\n typeof process !== \"undefined\" &&\n process.env &&\n (process.env.NODE_ENV === \"development\" ||\n process.env.NODE_ENV === \"test\" ||\n process.env.APTOS_SDK_WARNINGS === \"true\");\n\n if (isDevelopment) {\n console.warn(message);\n }\n}\n\n/**\n * Sleep for the specified amount of time in milliseconds.\n * This function can be used to introduce delays in asynchronous operations.\n *\n * @param timeMs - The time in milliseconds to sleep.\n * @group Implementation\n * @category Utils\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\n/**\n * Get the error message from an unknown error.\n *\n * @param error The error to get the message from\n * @returns The error message\n * @group Implementation\n * @category Utils\n */\nexport function getErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * @group Implementation\n * @category Utils\n */\nexport const nowInSeconds = () => Math.floor(Date.now() / 1000);\n\n/**\n * Floors the given timestamp to the nearest whole hour.\n * This function is useful for normalizing timestamps to hourly intervals.\n *\n * @param timestampInSeconds - The timestamp in seconds to be floored.\n * @group Implementation\n * @category Utils\n */\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\n/**\n * Decodes a base64 URL-encoded string into its original form.\n * This function is useful for converting base64 URL-encoded data back to a readable format.\n *\n * @param base64Url - The base64 URL-encoded string to decode.\n * @returns The decoded string.\n * @group Implementation\n * @category Utils\n */\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n\nexport function base64UrlToBytes(base64Url: string): Uint8Array {\n // Convert Base64Url to Base64\n let base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Add padding if needed\n while (base64.length % 4 !== 0) {\n base64 += \"=\";\n }\n // Use js-base64 to convert base64 to Uint8Array\n return Base64.toUint8Array(base64);\n}\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * a human-readable amount format to the smallest unit format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromHumanReadableToOnChain = (value: number, decimal: number) => value * 10 ** decimal;\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * the smallest unit format to a human-readable amount format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromOnChainToHumanReadable = (value: number, decimal: number) => value / 10 ** decimal;\n\n/**\n * Convert a hex string to an ascii string with the `0x` prefix.\n *\n * `0x6170746f735f636f696e` --> `aptos_coin`\n *\n * @param hex The hex string to convert (e.g. `0x6170746f735f636f696e`)\n * @returns The ascii string\n * @group Implementation\n * @category Utils\n */\nconst hexToAscii = (hex: string) => {\n let str = \"\";\n for (let n = 2; n < hex.length; n += 2) {\n str += String.fromCharCode(parseInt(hex.substring(n, n + 2), 16));\n }\n return str;\n};\n\n/**\n * Convert an encoded struct to a MoveStructId.\n *\n * @example\n * const structObj = {\n * account_address: \"0x1\",\n * module_name: \"0x6170746f735f636f696e\",\n * struct_name: \"0x4170746f73436f696e\",\n * };\n * // structId is \"0x1::aptos_coin::AptosCoin\"\n * const structId = parseEncodedStruct(structObj);\n *\n * @param structObj The struct with account_address, module_name, and struct_name properties\n * @returns The MoveStructId\n * @group Implementation\n * @category Utils\n */\nexport const parseEncodedStruct = (structObj: {\n account_address: string;\n module_name: string;\n struct_name: string;\n}): MoveStructId => {\n const { account_address, module_name, struct_name } = structObj;\n const moduleName = hexToAscii(module_name);\n const structName = hexToAscii(struct_name);\n return `${account_address}::${moduleName}::${structName}`;\n};\n\n/**\n * Determines whether the given object is an encoded struct type with the following properties:\n * - account_address: string\n * - module_name: string\n * - struct_name: string\n *\n * @param structObj The object to check\n * @returns Whether the object is an encoded struct type\n * @group Implementation\n * @category Utils\n */\nexport const isEncodedStruct = (\n structObj: any,\n): structObj is {\n account_address: string;\n module_name: string;\n struct_name: string;\n} =>\n typeof structObj === \"object\" &&\n !Array.isArray(structObj) &&\n structObj !== null &&\n \"account_address\" in structObj &&\n \"module_name\" in structObj &&\n \"struct_name\" in structObj &&\n typeof structObj.account_address === \"string\" &&\n typeof structObj.module_name === \"string\" &&\n typeof structObj.struct_name === \"string\";\n\n/**\n * Splits a function identifier into its constituent parts: module address, module name, and function name.\n * This function helps in validating and extracting details from a function identifier string.\n *\n * @param functionArg - The function identifier string in the format \"moduleAddress::moduleName::functionName\".\n * @returns An object containing the module address, module name, and function name.\n * @throws Error if the function identifier does not contain exactly three parts.\n * @group Implementation\n * @category Transactions\n */\nexport function getFunctionParts(functionArg: MoveFunctionId) {\n const funcNameParts = functionArg.split(\"::\");\n if (funcNameParts.length !== 3) {\n throw new Error(`Invalid function ${functionArg}`);\n }\n const moduleAddress = funcNameParts[0];\n const moduleName = funcNameParts[1];\n const functionName = funcNameParts[2];\n return { moduleAddress, moduleName, functionName };\n}\n\n/**\n * Validates the provided function information.\n *\n * @param functionInfo - The function information to validate.\n * @returns Whether the function information is valid.\n * @group Implementation\n * @category Utils\n */\nexport function isValidFunctionInfo(functionInfo: string): boolean {\n const parts = functionInfo.split(\"::\");\n return parts.length === 3 && AccountAddress.isValid({ input: parts[0] }).valid;\n}\n\n/**\n * Truncates the provided wallet address at the middle with an ellipsis.\n *\n * @param address - The wallet address to truncate.\n * @param start - The number of characters to show at the beginning of the address.\n * @param end - The number of characters to show at the end of the address.\n * @returns The truncated address.\n * @group Implementation\n * @category Utils\n */\nexport function truncateAddress(address: string, start: number = 6, end: number = 5) {\n return `${address.slice(0, start)}...${address.slice(-end)}`;\n}\n\n/**\n * Constants for metadata address calculation\n */\nconst APTOS_COIN_TYPE_STR = \"0x1::aptos_coin::AptosCoin\";\n\n/**\n * Helper function to standardize Move type string by converting all addresses to short form,\n * including addresses within nested type parameters\n */\nfunction standardizeMoveTypeString(input: string): string {\n // Regular expression to match addresses in the type string, including those within type parameters\n // This regex matches \"0x\" followed by hex digits, handling both standalone addresses and those within <>\n const addressRegex = /0x[0-9a-fA-F]+/g;\n\n return input.replace(addressRegex, (match) =>\n // Use AccountAddress to handle the address\n AccountAddress.from(match, { maxMissingChars: 63 }).toStringShort(),\n );\n}\n\n/**\n * Calculates the paired FA metadata address for a given coin type.\n * This function is tolerant of various address formats in the coin type string,\n * including complex nested types.\n *\n * @example\n * // All these formats are valid and will produce the same result:\n * pairedFaMetadataAddress(\"0x1::aptos_coin::AptosCoin\") // simple form\n * pairedFaMetadataAddress(\"0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin\") // long form\n * pairedFaMetadataAddress(\"0x00001::aptos_coin::AptosCoin\") // with leading zeros\n * pairedFaMetadataAddress(\"0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>\") // nested type parameters\n *\n * @param coinType - The coin type string in any of these formats:\n * - Short form address: \"0x1::aptos_coin::AptosCoin\"\n * - Long form address: \"0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin\"\n * - With leading zeros: \"0x00001::aptos_coin::AptosCoin\"\n * - With nested types: \"0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>\"\n * @returns The calculated metadata address as an AccountAddress instance\n */\nexport function pairedFaMetadataAddress(coinType: `0x${string}::${string}::${string}`): AccountAddress {\n // Standardize the coin type string to handle any address format\n const standardizedMoveTypeName = standardizeMoveTypeString(coinType);\n\n return standardizedMoveTypeName === APTOS_COIN_TYPE_STR\n ? AccountAddress.A\n : createObjectAddress(AccountAddress.A, standardizedMoveTypeName);\n}\n"],"mappings":"kFAGA,OAAS,UAAAA,EAAQ,UAAAC,MAAc,YAaxB,SAASC,GAAiB,CAC/B,GAAI,CAEF,OAAO,OAAO,WAAe,KAAe,QAAS,UACvD,MAAQ,CACN,MAAO,EACT,CACF,CAWO,SAASC,EAAkBC,EAAuB,CAIrD,OAAO,QAAY,KACnB,QAAQ,MACP,QAAQ,IAAI,WAAa,eACxB,QAAQ,IAAI,WAAa,QACzB,QAAQ,IAAI,qBAAuB,SAGrC,QAAQ,KAAKA,CAAO,CAExB,CAUA,eAAsBC,EAAMC,EAA+B,CACzD,OAAO,IAAI,QAASC,GAAY,CAC9B,WAAWA,EAASD,CAAM,CAC5B,CAAC,CACH,CAUO,SAASE,EAAgBC,EAAwB,CACtD,OAAOA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAC9D,CAMO,IAAMC,EAAe,IAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAUvD,SAASC,EAAiBC,EAA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UACrC,OAAOA,EAAU,aAAgB,UACjC,OAAOA,EAAU,aAAgB,SAY5B,SAASO,EAAiBC,EAA6B,CAC5D,IAAMC,EAAgBD,EAAY,MAAM,IAAI,EAC5C,GAAIC,EAAc,SAAW,EAC3B,MAAM,IAAI,MAAM,oBAAoBD,CAAW,EAAE,EAEnD,IAAME,EAAgBD,EAAc,CAAC,EAC/BL,EAAaK,EAAc,CAAC,EAC5BE,EAAeF,EAAc,CAAC,EACpC,MAAO,CAAE,cAAAC,EAAe,WAAAN,EAAY,aAAAO,CAAa,CACnD,CAUO,SAASC,EAAoBC,EAA+B,CACjE,IAAMC,EAAQD,EAAa,MAAM,IAAI,EACrC,OAAOC,EAAM,SAAW,GAAKC,EAAe,QAAQ,CAAE,MAAOD,EAAM,CAAC,CAAE,CAAC,EAAE,KAC3E,CAYO,SAASE,EAAgBC,EAAiBC,EAAgB,EAAGC,EAAc,EAAG,CACnF,MAAO,GAAGF,EAAQ,MAAM,EAAGC,CAAK,CAAC,MAAMD,EAAQ,MAAM,CAACE,CAAG,CAAC,EAC5D,CAKA,IAAMC,EAAsB,6BAM5B,SAASC,EAA0BC,EAAuB,CAGxD,IAAMC,EAAe,kBAErB,OAAOD,EAAM,QAAQC,EAAeC,GAElCT,EAAe,KAAKS,EAAO,CAAE,gBAAiB,EAAG,CAAC,EAAE,cAAc,CACpE,CACF,CAqBO,SAASC,EAAwBC,EAA+D,CAErG,IAAMC,EAA2BN,EAA0BK,CAAQ,EAEnE,OAAOC,IAA6BP,EAChCL,EAAe,EACfa,EAAoBb,EAAe,EAAGY,CAAwB,CACpE","names":["Base64","decode","isBun","warnIfDevelopment","message","sleep","timeMs","resolve","getErrorMessage","error","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","decode","base64UrlToBytes","Base64","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName","isEncodedStruct","getFunctionParts","functionArg","funcNameParts","moduleAddress","functionName","isValidFunctionInfo","functionInfo","parts","AccountAddress","truncateAddress","address","start","end","APTOS_COIN_TYPE_STR","standardizeMoveTypeString","input","addressRegex","match","pairedFaMetadataAddress","coinType","standardizedMoveTypeName","createObjectAddress"]}
@@ -0,0 +1,2 @@
1
+ import{m as E}from"./chunk-TAHLOBRG.mjs";import{b as x}from"./chunk-STY74NUA.mjs";import{a as U,b as c,c as h,d as l,e as u,f as b,g as y,h as g,i as z,j as A,k as p,l as _,m as w,n as d,o as N,p as m,q as T,r as M}from"./chunk-X2TPNKLV.mjs";import{a as s}from"./chunk-KDMSOCZY.mjs";var R=class{bcsToBytes(){let e=new n;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return x.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},V=256,I=[],X=8;function W(){let r=I.pop();return r?(r.reset(),r):new n}function F(r){I.length<X&&I.push(r)}var n=class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.dataView=new DataView(this.buffer),this.offset=0}ensureBufferWillHandleSize(e){let i=this.offset+e;if(this.buffer.byteLength>=i)return;let t=Math.max(Math.floor(this.buffer.byteLength*1.5),i+V),a=new ArrayBuffer(t);new Uint8Array(a).set(new Uint8Array(this.buffer,0,this.offset)),this.buffer=a,this.dataView=new DataView(this.buffer)}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,i,t){this.ensureBufferWillHandleSize(i),e.apply(this.dataView,[this.offset,t,!0]),this.offset+=i}serializeStr(e){this.serializeBytes(E.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){D(e);let i=e?1:0;this.appendToBuffer(new Uint8Array([i]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let i=BigInt(e)&BigInt(h),t=BigInt(e)>>BigInt(32);this.serializeU32(Number(i)),this.serializeU32(Number(t))}serializeU128(e){let i=BigInt(e)&l,t=BigInt(e)>>BigInt(64);this.serializeU64(i),this.serializeU64(t)}serializeU256(e){let i=BigInt(e)&u,t=BigInt(e)>>BigInt(128);this.serializeU128(i),this.serializeU128(t)}serializeI8(e){this.serializeWithFunction(DataView.prototype.setInt8,1,e)}serializeI16(e){this.serializeWithFunction(DataView.prototype.setInt16,2,e)}serializeI32(e){this.serializeWithFunction(DataView.prototype.setInt32,4,e)}serializeI64(e){let i=BigInt(e),t=i<0?(BigInt(1)<<BigInt(64))+i:i,a=t&BigInt(h),f=t>>BigInt(32);this.serializeU32(Number(a)),this.serializeU32(Number(f))}serializeI128(e){let i=BigInt(e),t=i<0?(BigInt(1)<<BigInt(128))+i:i,a=t&l,f=t>>BigInt(64);this.serializeU64(a),this.serializeU64(f)}serializeI256(e){let i=BigInt(e),t=i<0?(BigInt(1)<<BigInt(256))+i:i,a=t&u,f=t>>BigInt(128);this.serializeU128(a),this.serializeU128(f)}serializeU32AsUleb128(e){let i=e,t=[];for(;i>>>7;)t.push(i&127|128),i>>>=7;t.push(i),this.appendToBuffer(new Uint8Array(t))}toUint8Array(){return new Uint8Array(this.buffer,0,this.offset).slice()}reset(){this.offset>0&&new Uint8Array(this.buffer,0,this.offset).fill(0),this.offset=0}getOffset(){return this.offset}toUint8ArrayView(){return new Uint8Array(this.buffer,0,this.offset)}serialize(e){e.serialize(this)}serializeAsBytes(e){let i=W();try{e.serialize(i);let t=i.toUint8ArrayView();this.serializeBytes(t)}finally{F(i)}}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(i=>{i.serialize(this)})}serializeOption(e,i){let t=e!==void 0;this.serializeBool(t),t&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?i!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};s([o(0,U)],n.prototype,"serializeU8",1),s([o(0,c)],n.prototype,"serializeU16",1),s([o(0,h)],n.prototype,"serializeU32",1),s([o(BigInt(0),l)],n.prototype,"serializeU64",1),s([o(BigInt(0),u)],n.prototype,"serializeU128",1),s([o(BigInt(0),b)],n.prototype,"serializeU256",1),s([o(y,g)],n.prototype,"serializeI8",1),s([o(z,A)],n.prototype,"serializeI16",1),s([o(p,_)],n.prototype,"serializeI32",1),s([o(w,d)],n.prototype,"serializeI64",1),s([o(N,m)],n.prototype,"serializeI128",1),s([o(T,M)],n.prototype,"serializeI256",1),s([o(0,h)],n.prototype,"serializeU32AsUleb128",1);function D(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var G=(r,e,i)=>`${r} is out of range: [${e}, ${i}]`;function S(r,e,i){let t=BigInt(r);if(t>BigInt(i)||t<BigInt(e))throw new Error(G(r,e,i))}function o(r,e){return(i,t,a)=>{let f=a.value;return a.value=function(B){return S(B,r,e),f.apply(this,[B])},a}}export{R as a,n as b,D as c,G as d,S as e};
2
+ //# sourceMappingURL=chunk-66F7RP7K.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bcs/serializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n MIN_I8_NUMBER,\n MAX_I8_NUMBER,\n MIN_I16_NUMBER,\n MAX_I16_NUMBER,\n MIN_I32_NUMBER,\n MAX_I32_NUMBER,\n MIN_I64_BIG_INT,\n MAX_I64_BIG_INT,\n MIN_I128_BIG_INT,\n MAX_I128_BIG_INT,\n MIN_I256_BIG_INT,\n MAX_I256_BIG_INT,\n} from \"./consts\";\nimport { Hex } from \"../core/hex\";\nimport { AnyNumber, Uint16, Uint32, Uint8 } from \"../types\";\nimport { TEXT_ENCODER } from \"../utils/const\";\n\n/**\n * This class serves as a base class for all serializable types. It facilitates\n * composable serialization of complex types and enables the serialization of\n * instances to their BCS (Binary Canonical Serialization) representation.\n * @group Implementation\n * @category BCS\n */\nexport abstract class Serializable {\n abstract serialize(serializer: Serializer): void;\n\n /**\n * Serializes a `Serializable` value to its BCS representation.\n * This function is the TypeScript SDK equivalent of `bcs::to_bytes` in Move.\n * @returns the BCS representation of the Serializable instance as a byte buffer.\n * @group Implementation\n * @category BCS\n */\n bcsToBytes(): Uint8Array {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Converts the BCS-serialized bytes of a value into a Hex instance.\n * This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.\n * @returns A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.\n * @group Implementation\n * @category BCS\n */\n bcsToHex(): Hex {\n const bcsBytes = this.bcsToBytes();\n return Hex.fromHexInput(bcsBytes);\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value without the 0x prefix.\n * @returns the hex format as a string without `0x` prefix.\n */\n toStringWithoutPrefix(): string {\n return this.bcsToHex().toStringWithoutPrefix();\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value with the 0x prefix.\n * @returns the hex formatas a string prefixed by `0x`.\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n}\n\n/**\n * Minimum buffer growth increment to avoid too many small reallocations.\n */\nconst MIN_BUFFER_GROWTH = 256;\n\n/**\n * Pool of reusable Serializer instances for temporary serialization operations.\n * This reduces allocations when using serializeAsBytes() repeatedly.\n */\nconst serializerPool: Serializer[] = [];\nconst MAX_POOL_SIZE = 8;\n\n/**\n * Acquires a Serializer from the pool or creates a new one.\n * @internal\n */\nfunction acquireSerializer(): Serializer {\n const serializer = serializerPool.pop();\n if (serializer) {\n serializer.reset();\n return serializer;\n }\n return new Serializer();\n}\n\n/**\n * Returns a Serializer to the pool for reuse.\n * @internal\n */\nfunction releaseSerializer(serializer: Serializer): void {\n if (serializerPool.length < MAX_POOL_SIZE) {\n serializerPool.push(serializer);\n }\n}\n\n/**\n * A class for serializing various data types into a binary format.\n * It provides methods to serialize strings, bytes, numbers, and other serializable objects\n * using the Binary Coded Serialization (BCS) layout. The serialized data can be retrieved as a\n * Uint8Array.\n * @group Implementation\n * @category BCS\n */\nexport class Serializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Reusable DataView instance to reduce allocations during serialization.\n * Recreated when buffer is resized.\n */\n private dataView: DataView;\n\n /**\n * Constructs a serializer with a buffer of size `length` bytes, 64 bytes by default.\n * The `length` must be greater than 0.\n *\n * @param length - The size of the buffer in bytes.\n * @group Implementation\n * @category BCS\n */\n constructor(length: number = 64) {\n if (length <= 0) {\n throw new Error(\"Length needs to be greater than 0\");\n }\n this.buffer = new ArrayBuffer(length);\n this.dataView = new DataView(this.buffer);\n this.offset = 0;\n }\n\n /**\n * Ensures that the internal buffer can accommodate the specified number of bytes.\n * This function dynamically resizes the buffer using a growth factor of 1.5x with\n * a minimum growth increment to balance memory usage and reallocation frequency.\n *\n * @param bytes - The number of bytes to ensure the buffer can handle.\n * @group Implementation\n * @category BCS\n */\n private ensureBufferWillHandleSize(bytes: number) {\n const requiredSize = this.offset + bytes;\n if (this.buffer.byteLength >= requiredSize) {\n return;\n }\n\n // Calculate new size: max of (1.5x current size) or (current + required + MIN_GROWTH)\n // Using 1.5x instead of 2x provides better memory efficiency\n const growthSize = Math.max(Math.floor(this.buffer.byteLength * 1.5), requiredSize + MIN_BUFFER_GROWTH);\n\n const newBuffer = new ArrayBuffer(growthSize);\n new Uint8Array(newBuffer).set(new Uint8Array(this.buffer, 0, this.offset));\n this.buffer = newBuffer;\n this.dataView = new DataView(this.buffer);\n }\n\n /**\n * Appends the specified values to the buffer, ensuring that the buffer can accommodate the new data.\n *\n * @param {Uint8Array} values - The values to be appended to the buffer.\n * @group Implementation\n * @category BCS\n */\n protected appendToBuffer(values: Uint8Array) {\n this.ensureBufferWillHandleSize(values.length);\n new Uint8Array(this.buffer, this.offset).set(values);\n this.offset += values.length;\n }\n\n /**\n * Serializes a value into the buffer using the provided function, ensuring the buffer can accommodate the size.\n * Uses the cached DataView instance for better performance.\n *\n * @param fn - The function to serialize the value, which takes a byte offset, the value to serialize, and an optional little-endian flag.\n * @param fn.byteOffset - The byte offset at which to write the value.\n * @param fn.value - The numeric value to serialize into the buffer.\n * @param fn.littleEndian - Optional flag indicating whether to use little-endian byte order (defaults to true).\n * @group Implementation\n * @category BCS\n */\n // TODO: JSDoc bytesLength and value\n private serializeWithFunction(\n fn: (byteOffset: number, value: number, littleEndian?: boolean) => void,\n bytesLength: number,\n value: number,\n ) {\n this.ensureBufferWillHandleSize(bytesLength);\n fn.apply(this.dataView, [this.offset, value, true]);\n this.offset += bytesLength;\n }\n\n /**\n * Serializes a string. UTF8 string is supported.\n * The number of bytes in the string content is serialized first, as a uleb128-encoded u32 integer.\n * Then the string content is serialized as UTF8 encoded bytes.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @param value - The string to serialize.\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeStr(\"1234abcd\");\n * assert(serializer.toUint8Array() === new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeStr(value: string) {\n this.serializeBytes(TEXT_ENCODER.encode(value));\n }\n\n /**\n * Serializes an array of bytes.\n *\n * This function encodes the length of the byte array as a u32 integer in uleb128 format, followed by the byte array itself.\n * BCS layout for \"bytes\": bytes_length | bytes\n * where bytes_length is a u32 integer encoded as a uleb128 integer, equal to the length of the bytes array.\n * @param value - The byte array to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBytes(value: Uint8Array) {\n this.serializeU32AsUleb128(value.length);\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes an array of bytes with a known length, allowing for efficient deserialization without needing to serialize the\n * length itself.\n * When deserializing, the number of bytes to deserialize needs to be passed in.\n\n * @param value - The Uint8Array to be serialized.\n * @group Implementation\n * @category BCS\n */\n serializeFixedBytes(value: Uint8Array) {\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes a boolean value into a byte representation.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n *\n * @param value - The boolean value to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBool(value: boolean) {\n /**\n * Ensures that the provided value is a boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n const byteValue = value ? 1 : 0;\n this.appendToBuffer(new Uint8Array([byteValue]));\n }\n\n /**\n * Serializes a Uint8 value and appends it to the buffer.\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @param value - The Uint8 value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U8_NUMBER)\n serializeU8(value: Uint8) {\n this.appendToBuffer(new Uint8Array([value]));\n }\n\n /**\n * Serializes a uint16 number.\n *\n * @group Implementation\n * @category BCS\n\n */\n\n /**\n * Serializes a 16-bit unsigned integer value into a binary format.\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n *\n * @param value - The 16-bit unsigned integer value to serialize.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU16(4660);\n * assert(serializer.toUint8Array() === new Uint8Array([0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U16_NUMBER)\n serializeU16(value: Uint16) {\n this.serializeWithFunction(DataView.prototype.setUint16, 2, value);\n }\n\n /**\n * Serializes a 32-bit unsigned integer value into a binary format.\n * This function is useful for encoding data that needs to be stored or transmitted in a compact form.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU32(305419896);\n * assert(serializer.toUint8Array() === new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * ```\n * @param value - The 32-bit unsigned integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32(value: Uint32) {\n this.serializeWithFunction(DataView.prototype.setUint32, 4, value);\n }\n\n /**\n * Serializes a 64-bit unsigned integer into a format suitable for storage or transmission.\n * This function breaks down the value into two 32-bit components and writes them in little-endian order.\n *\n * @param value - The 64-bit unsigned integer to serialize, represented as a number.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU64(1311768467750121216);\n * assert(serializer.toUint8Array() === new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U64_BIG_INT)\n serializeU64(value: AnyNumber) {\n const low = BigInt(value) & BigInt(MAX_U32_NUMBER);\n const high = BigInt(value) >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a U128 value into a format suitable for storage or transmission.\n *\n * @param value - The U128 value to serialize, represented as a number.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U128_BIG_INT)\n serializeU128(value: AnyNumber) {\n const low = BigInt(value) & MAX_U64_BIG_INT;\n const high = BigInt(value) >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a U256 value into a byte representation.\n * This function is essential for encoding large numbers in a compact format suitable for transmission or storage.\n *\n * @param value - The U256 value to serialize, represented as an AnyNumber.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U256_BIG_INT)\n serializeU256(value: AnyNumber) {\n const low = BigInt(value) & MAX_U128_BIG_INT;\n const high = BigInt(value) >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes an 8-bit signed integer value.\n * BCS layout for \"int8\": One byte. Binary format in little-endian representation.\n *\n * @param value - The 8-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I8_NUMBER, MAX_I8_NUMBER)\n serializeI8(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt8, 1, value);\n }\n\n /**\n * Serializes a 16-bit signed integer value into a binary format.\n * BCS layout for \"int16\": Two bytes. Binary format in little-endian representation.\n *\n * @param value - The 16-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I16_NUMBER, MAX_I16_NUMBER)\n serializeI16(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt16, 2, value);\n }\n\n /**\n * Serializes a 32-bit signed integer value into a binary format.\n *\n * @param value - The 32-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I32_NUMBER, MAX_I32_NUMBER)\n serializeI32(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt32, 4, value);\n }\n\n /**\n * Serializes a 64-bit signed integer into a format suitable for storage or transmission.\n * This function uses two's complement representation for negative values.\n *\n * @param value - The 64-bit signed integer to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I64_BIG_INT, MAX_I64_BIG_INT)\n serializeI64(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(64)) + val : val;\n const low = unsigned & BigInt(MAX_U32_NUMBER);\n const high = unsigned >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a 128-bit signed integer value.\n *\n * @param value - The 128-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I128_BIG_INT, MAX_I128_BIG_INT)\n serializeI128(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(128)) + val : val;\n const low = unsigned & MAX_U64_BIG_INT;\n const high = unsigned >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a 256-bit signed integer value.\n *\n * @param value - The 256-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I256_BIG_INT, MAX_I256_BIG_INT)\n serializeI256(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(256)) + val : val;\n const low = unsigned & MAX_U128_BIG_INT;\n const high = unsigned >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes a 32-bit unsigned integer as a variable-length ULEB128 encoded byte array.\n * BCS uses uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\n *\n * @param val - The 32-bit unsigned integer value to be serialized.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32AsUleb128(val: Uint32) {\n let value = val;\n const valueArray = [];\n while (value >>> 7 !== 0) {\n valueArray.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n valueArray.push(value);\n this.appendToBuffer(new Uint8Array(valueArray));\n }\n\n /**\n * Returns the buffered bytes as a Uint8Array.\n *\n * This function allows you to retrieve the byte representation of the buffer up to the current offset.\n * For better performance, returns a view when the buffer is exactly the right size, or copies\n * only the used portion otherwise.\n *\n * @returns Uint8Array - The byte array representation of the buffer.\n * @group Implementation\n * @category BCS\n */\n toUint8Array(): Uint8Array {\n // Return a copy of only the used portion of the buffer\n // Using subarray + slice pattern for efficiency\n return new Uint8Array(this.buffer, 0, this.offset).slice();\n }\n\n /**\n * Resets the serializer to its initial state, allowing the buffer to be reused.\n * This clears the buffer contents to prevent data leakage between uses.\n *\n * @group Implementation\n * @category BCS\n */\n reset(): void {\n // Clear buffer contents to prevent data leakage when reusing pooled serializers\n // Only clear the portion that was used (up to offset) for efficiency\n if (this.offset > 0) {\n new Uint8Array(this.buffer, 0, this.offset).fill(0);\n }\n this.offset = 0;\n }\n\n /**\n * Returns the current number of bytes written to the serializer.\n *\n * @returns The number of bytes written.\n * @group Implementation\n * @category BCS\n */\n getOffset(): number {\n return this.offset;\n }\n\n /**\n * Returns a view of the serialized bytes without copying.\n * WARNING: The returned view is only valid until the next write operation.\n * Use toUint8Array() if you need a persistent copy.\n *\n * @returns A Uint8Array view of the buffer (not a copy).\n * @group Implementation\n * @category BCS\n */\n toUint8ArrayView(): Uint8Array {\n return new Uint8Array(this.buffer, 0, this.offset);\n }\n\n /**\n * Serializes a `Serializable` value, facilitating composable serialization.\n *\n * @param value The Serializable value to serialize.\n *\n * @returns the serializer instance\n * @group Implementation\n * @category BCS\n */\n serialize<T extends Serializable>(value: T): void {\n // NOTE: The `serialize` method called by `value` is defined in `value`'s\n // Serializable interface, not the one defined in this class.\n value.serialize(this);\n }\n\n /**\n * Serializes a Serializable value as a byte array with a length prefix.\n * This is the optimized pattern for entry function argument serialization.\n *\n * Instead of:\n * ```typescript\n * const bcsBytes = value.bcsToBytes(); // Creates new Serializer, copies bytes\n * serializer.serializeBytes(bcsBytes);\n * ```\n *\n * Use:\n * ```typescript\n * serializer.serializeAsBytes(value); // Uses pooled Serializer, avoids extra copy\n * ```\n *\n * This method uses a pooled Serializer instance to reduce allocations and\n * directly appends the serialized bytes with a length prefix.\n *\n * @param value - The Serializable value to serialize as bytes.\n * @group Implementation\n * @category BCS\n */\n serializeAsBytes<T extends Serializable>(value: T): void {\n // Acquire a pooled serializer for temporary use\n const tempSerializer = acquireSerializer();\n\n try {\n // Serialize the value to the temporary serializer\n value.serialize(tempSerializer);\n\n // Get the serialized bytes (as a view to avoid copying)\n const bytes = tempSerializer.toUint8ArrayView();\n\n // Serialize with length prefix to this serializer\n this.serializeBytes(bytes);\n } finally {\n // Return the serializer to the pool for reuse\n releaseSerializer(tempSerializer);\n }\n }\n\n /**\n * Serializes an array of BCS Serializable values to a serializer instance.\n * The bytes are added to the serializer instance's byte buffer.\n *\n * @param values The array of BCS Serializable values\n * @example\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n * // serializedBytes is now the BCS-serialized bytes\n * // The equivalent value in Move would be:\n * // `bcs::to_bytes(&vector<address> [@0x1, @0x2, @0xa, @0xb])`;\n * @group Implementation\n * @category BCS\n */\n serializeVector<T extends Serializable>(values: Array<T>): void {\n this.serializeU32AsUleb128(values.length);\n values.forEach((item) => {\n item.serialize(this);\n });\n }\n\n /**\n * Serializes an optional value which can be a Serializable, string, or Uint8Array.\n * For strings and Uint8Arrays, it uses the appropriate serialization method.\n *\n * @param value The value to serialize (Serializable, string, Uint8Array, or undefined)\n * @param len Optional fixed length for Uint8Array serialization. If provided, uses serializeFixedBytes instead of serializeBytes\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeOption(\"hello\"); // Serializes optional string\n * serializer.serializeOption(new Uint8Array([1, 2, 3])); // Serializes optional bytes\n * serializer.serializeOption(new Uint8Array([1, 2, 3]), 3); // Serializes optional fixed-length bytes\n * serializer.serializeOption(new AccountAddress(...)); // Serializes optional Serializable\n * serializer.serializeOption(undefined); // Serializes none case\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeOption<T extends Serializable | string | Uint8Array>(value?: T, len?: number): void {\n const hasValue = value !== undefined;\n this.serializeBool(hasValue);\n if (hasValue) {\n if (typeof value === \"string\") {\n this.serializeStr(value);\n } else if (value instanceof Uint8Array) {\n if (len !== undefined) {\n this.serializeFixedBytes(value);\n } else {\n this.serializeBytes(value);\n }\n } else {\n value.serialize(this);\n }\n }\n }\n\n /**\n * @deprecated use `serializeOption` instead.\n * Serializes an optional string, supporting UTF8 encoding.\n * The function encodes the existence of the string first, followed by the length and content if it exists.\n *\n * BCS layout for optional \"string\": 1 | string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n * BCS layout for undefined: 0\n *\n * @param value - The optional string to serialize. If undefined, it will serialize as 0.\n * @group Implementation\n * @category BCS\n */\n serializeOptionStr(value?: string): void {\n if (value === undefined) {\n this.serializeU32AsUleb128(0);\n } else {\n this.serializeU32AsUleb128(1);\n this.serializeStr(value);\n }\n }\n}\n\n/**\n * @group Implementation\n * @category BCS\n */\nexport function ensureBoolean(value: unknown): asserts value is boolean {\n if (typeof value !== \"boolean\") {\n throw new Error(`${value} is not a boolean value`);\n }\n}\n/**\n * @group Implementation\n * @category BCS\n */\nexport const outOfRangeErrorMessage = (value: AnyNumber, min: AnyNumber, max: AnyNumber) =>\n `${value} is out of range: [${min}, ${max}]`;\n\n/**\n * Validates that a given number is within a specified range.\n * This function throws an error if the value is outside the defined minimum and maximum bounds.\n *\n * @param value - The number to validate.\n * @param minValue - The minimum allowable value (inclusive).\n * @param maxValue - The maximum allowable value (inclusive).\n * @group Implementation\n * @category BCS\n */\nexport function validateNumberInRange<T extends AnyNumber>(value: T, minValue: T, maxValue: T) {\n const valueBigInt = BigInt(value);\n if (valueBigInt > BigInt(maxValue) || valueBigInt < BigInt(minValue)) {\n throw new Error(outOfRangeErrorMessage(value, minValue, maxValue));\n }\n}\n\n/**\n * A decorator that validates that the input argument for a function is within a specified range.\n * This ensures that the function is only called with valid input values, preventing potential errors.\n *\n * @param minValue - The input argument must be greater than or equal to this value.\n * @param maxValue - The input argument must be less than or equal to this value.\n * @group Implementation\n * @category BCS\n */\nfunction checkNumberRange<T extends AnyNumber>(minValue: T, maxValue: T) {\n return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => {\n const childFunction = descriptor.value;\n\n descriptor.value = function deco(value: AnyNumber) {\n validateNumberInRange(value, minValue, maxValue);\n return childFunction.apply(this, [value]);\n };\n\n return descriptor;\n };\n}\n"],"mappings":"2RAkCO,IAAeA,EAAf,KAA4B,CAUjC,YAAyB,CACvB,IAAMC,EAAa,IAAIC,EACvB,YAAK,UAAUD,CAAU,EAClBA,EAAW,aAAa,CACjC,CASA,UAAgB,CACd,IAAME,EAAW,KAAK,WAAW,EACjC,OAAOC,EAAI,aAAaD,CAAQ,CAClC,CAMA,uBAAgC,CAC9B,OAAO,KAAK,SAAS,EAAE,sBAAsB,CAC/C,CAMA,UAAmB,CACjB,MAAO,KAAK,KAAK,sBAAsB,CAAC,EAC1C,CACF,EAKME,EAAoB,IAMpBC,EAA+B,CAAC,EAChCC,EAAgB,EAMtB,SAASC,GAAgC,CACvC,IAAMP,EAAaK,EAAe,IAAI,EACtC,OAAIL,GACFA,EAAW,MAAM,EACVA,GAEF,IAAIC,CACb,CAMA,SAASO,EAAkBR,EAA8B,CACnDK,EAAe,OAASC,GAC1BD,EAAe,KAAKL,CAAU,CAElC,CAUO,IAAMC,EAAN,KAAiB,CAmBtB,YAAYQ,EAAiB,GAAI,CAC/B,GAAIA,GAAU,EACZ,MAAM,IAAI,MAAM,mCAAmC,EAErD,KAAK,OAAS,IAAI,YAAYA,CAAM,EACpC,KAAK,SAAW,IAAI,SAAS,KAAK,MAAM,EACxC,KAAK,OAAS,CAChB,CAWQ,2BAA2BC,EAAe,CAChD,IAAMC,EAAe,KAAK,OAASD,EACnC,GAAI,KAAK,OAAO,YAAcC,EAC5B,OAKF,IAAMC,EAAa,KAAK,IAAI,KAAK,MAAM,KAAK,OAAO,WAAa,GAAG,EAAGD,EAAeP,CAAiB,EAEhGS,EAAY,IAAI,YAAYD,CAAU,EAC5C,IAAI,WAAWC,CA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AAa,CAC7F,IAAMC,EAAc,OAAOvC,CAAK,EAChC,GAAIuC,EAAc,OAAOD,CAAQ,GAAKC,EAAc,OAAOF,CAAQ,EACjE,MAAM,IAAI,MAAMJ,EAAuBjC,EAAOqC,EAAUC,CAAQ,CAAC,CAErE,CAWA,SAASrB,EAAsCoB,EAAaC,EAAa,CACvE,MAAO,CAACE,EAAiBC,EAAqBC,IAAmC,CAC/E,IAAMC,EAAgBD,EAAW,MAEjC,OAAAA,EAAW,MAAQ,SAAc1C,EAAkB,CACjD,OAAAoC,EAAsBpC,EAAOqC,EAAUC,CAAQ,EACxCK,EAAc,MAAM,KAAM,CAAC3C,CAAK,CAAC,CAC1C,EAEO0C,CACT,CACF","names":["Serializable","serializer","Serializer","bcsBytes","Hex","MIN_BUFFER_GROWTH","serializerPool","MAX_POOL_SIZE","acquireSerializer","releaseSerializer","length","bytes","requiredSize","growthSize","newBuffer","values","fn","bytesLength","value","TEXT_ENCODER","ensureBoolean","byteValue","low","MAX_U32_NUMBER","high","MAX_U64_BIG_INT","MAX_U128_BIG_INT","val","unsigned","valueArray","tempSerializer","item","len","hasValue","__decorateClass","checkNumberRange","MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U256_BIG_INT","MIN_I8_NUMBER","MAX_I8_NUMBER","MIN_I16_NUMBER","MAX_I16_NUMBER","MIN_I32_NUMBER","MAX_I32_NUMBER","MIN_I64_BIG_INT","MAX_I64_BIG_INT","MIN_I128_BIG_INT","MAX_I128_BIG_INT","MIN_I256_BIG_INT","MAX_I256_BIG_INT","outOfRangeErrorMessage","min","max","validateNumberInRange","minValue","maxValue","valueBigInt","target","propertyKey","descriptor","childFunction"]}
@@ -1,2 +1,2 @@
1
- import{c as r}from"./chunk-7FG7RJDS.mjs";import{spawn as c}from"child_process";import l from"tree-kill";import{platform as h}from"os";var e=class{constructor(t){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.showStdout=!0;this.process=null;this.extraArgs=[];this.showStdout=t?.showStdout??!0,this.extraArgs=t?.extraArgs??[]}async stop(){await new Promise((t,o)=>{this.process?.pid&&l(this.process.pid,s=>{s?o(s):t(!0)})})}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let o=["aptos","node","run-localnet","--force-restart","--assume-yes","--with-indexer-api",...this.extraArgs],s=h(),i={env:{...process.env,ENABLE_KEYLESS_DEFAULT:"1"},...s==="win32"&&{shell:!0}};this.process=c("npx",o,i),this.process.stdout?.on("data",a=>{let n=a.toString();this.showStdout&&console.log(n)})}async waitUntilProcessIsUp(){let t=await this.checkIfProcessIsUp(),o=Date.now()/1e3,s=o;for(;!t&&o+this.MAXIMUM_WAIT_TIME_SEC>s;)await r(1e3),t=await this.checkIfProcessIsUp(),s=Date.now()/1e3;if(!t)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch{return!1}}};export{e as a};
2
- //# sourceMappingURL=chunk-YNNDFGVQ.mjs.map
1
+ import{c as r}from"./chunk-5LMLIRGK.mjs";import{spawn as c}from"child_process";import l from"tree-kill";import{platform as h}from"os";var e=class{constructor(t){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.showStdout=!0;this.process=null;this.extraArgs=[];this.showStdout=t?.showStdout??!0,this.extraArgs=t?.extraArgs??[]}async stop(){await new Promise((t,o)=>{this.process?.pid&&l(this.process.pid,s=>{s?o(s):t(!0)})})}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let o=["aptos","node","run-localnet","--force-restart","--assume-yes","--with-indexer-api",...this.extraArgs],s=h(),i={env:{...process.env,ENABLE_KEYLESS_DEFAULT:"1"},...s==="win32"&&{shell:!0}};this.process=c("npx",o,i),this.process.stdout?.on("data",a=>{let n=a.toString();this.showStdout&&console.log(n)})}async waitUntilProcessIsUp(){let t=await this.checkIfProcessIsUp(),o=Date.now()/1e3,s=o;for(;!t&&o+this.MAXIMUM_WAIT_TIME_SEC>s;)await r(1e3),t=await this.checkIfProcessIsUp(),s=Date.now()/1e3;if(!t)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch{return!1}}};export{e as a};
2
+ //# sourceMappingURL=chunk-A7SQEK23.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/localNode.ts"],"sourcesContent":["import { ChildProcessWithoutNullStreams, spawn } from \"node:child_process\";\nimport kill from \"tree-kill\";\nimport { platform } from \"node:os\";\n\nimport { sleep } from \"../utils/helpers\";\n\n/**\n * Represents a local node for running a localnet environment.\n * This class provides methods to start, stop, and check the status of the localnet process.\n * It manages the lifecycle of the node process and ensures that it is operational before executing tests.\n * @group Implementation\n * @category CLI\n */\nexport class LocalNode {\n readonly MAXIMUM_WAIT_TIME_SEC = 75;\n\n readonly READINESS_ENDPOINT = \"http://127.0.0.1:8070/\";\n\n showStdout: boolean = true;\n\n process: ChildProcessWithoutNullStreams | null = null;\n\n extraArgs: string[] = [];\n\n constructor(args?: { showStdout?: boolean; extraArgs?: string[] }) {\n this.showStdout = args?.showStdout ?? true;\n this.extraArgs = args?.extraArgs ?? [];\n }\n\n /**\n * Kills the current process and all its descendant processes.\n *\n * @returns {Promise<void>} A promise that resolves to true if the process was successfully killed.\n * @throws {Error} If there is an error while attempting to kill the process.\n * @group Implementation\n * @category CLI\n */\n async stop(): Promise<void> {\n await new Promise((resolve, reject) => {\n if (!this.process?.pid) return;\n\n /**\n * Terminates the process associated with the given process ID.\n *\n * @param pid - The process ID of the process to be terminated.\n * @param callback - A function that is called after the termination attempt is complete.\n * @param callback.err - An error object if the termination failed; otherwise, null.\n * @param callback.resolve - A boolean indicating whether the termination was successful.\n * @group Implementation\n * @category CLI\n */\n kill(this.process.pid, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve(true);\n }\n });\n });\n }\n\n /**\n * Runs a localnet and waits for the process to be up.\n * If the local node process is already running, it returns without starting the process.\n *\n * @returns {Promise<void>} A promise that resolves when the process is up.\n * @group Implementation\n * @category CLI\n */\n async run(): Promise<void> {\n const nodeIsUp = await this.checkIfProcessIsUp();\n if (nodeIsUp) {\n return;\n }\n this.start();\n await this.waitUntilProcessIsUp();\n }\n\n /**\n * Starts the localnet by running the Aptos node with the specified command-line arguments.\n *\n * @returns {void}\n *\n * @throws {Error} If there is an issue starting the localnet.\n * @group Implementation\n * @category CLI\n */\n start(): void {\n const cliCommand = \"npx\";\n const cliArgs = [\n \"aptos\",\n \"node\",\n \"run-localnet\",\n \"--force-restart\",\n \"--assume-yes\",\n \"--with-indexer-api\",\n ...this.extraArgs,\n ];\n\n const currentPlatform = platform();\n const spawnConfig = {\n env: { ...process.env, ENABLE_KEYLESS_DEFAULT: \"1\" },\n ...(currentPlatform === \"win32\" && { shell: true }),\n };\n\n this.process = spawn(cliCommand, cliArgs, spawnConfig);\n\n this.process.stdout?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output log\n if (this.showStdout) {\n console.log(str);\n }\n });\n }\n\n /**\n * Waits for the localnet process to be operational within a specified maximum wait time.\n * This function continuously checks if the process is up and will throw an error if it fails to start.\n *\n * @returns Promise<boolean> - Resolves to true if the process is up, otherwise throws an error.\n * @group Implementation\n * @category CLI\n */\n async waitUntilProcessIsUp(): Promise<boolean> {\n let operational = await this.checkIfProcessIsUp();\n const start = Date.now() / 1000;\n let last = start;\n\n while (!operational && start + this.MAXIMUM_WAIT_TIME_SEC > last) {\n await sleep(1000);\n\n operational = await this.checkIfProcessIsUp();\n last = Date.now() / 1000;\n }\n\n // If we are here it means something blocks the process to start.\n // Might worth checking if another process is running on port 8080\n if (!operational) {\n throw new Error(\"Process failed to start\");\n }\n\n return true;\n }\n\n /**\n * Checks if the localnet is up by querying the readiness endpoint.\n *\n * @returns Promise<boolean> - A promise that resolves to true if the localnet is up, otherwise false.\n * @group Implementation\n * @category CLI\n */\n async checkIfProcessIsUp(): Promise<boolean> {\n try {\n // Query readiness endpoint\n const data = await fetch(this.READINESS_ENDPOINT);\n if (data.status === 200) {\n return true;\n }\n return false;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"yCAAA,OAAyC,SAAAA,MAAa,gBACtD,OAAOC,MAAU,YACjB,OAAS,YAAAC,MAAgB,KAWlB,IAAMC,EAAN,KAAgB,CAWrB,YAAYC,EAAuD,CAVnE,KAAS,sBAAwB,GAEjC,KAAS,mBAAqB,yBAE9B,gBAAsB,GAEtB,aAAiD,KAEjD,eAAsB,CAAC,EAGrB,KAAK,WAAaA,GAAM,YAAc,GACtC,KAAK,UAAYA,GAAM,WAAa,CAAC,CACvC,CAUA,MAAM,MAAsB,CAC1B,MAAM,IAAI,QAAQ,CAACC,EAASC,IAAW,CAChC,KAAK,SAAS,KAYnBC,EAAK,KAAK,QAAQ,IAAMC,GAAQ,CAC1BA,EACFF,EAAOE,CAAG,EAEVH,EAAQ,EAAI,CAEhB,CAAC,CACH,CAAC,CACH,CAUA,MAAM,KAAqB,CACR,MAAM,KAAK,mBAAmB,IAI/C,KAAK,MAAM,EACX,MAAM,KAAK,qBAAqB,EAClC,CAWA,OAAc,CAEZ,IAAMI,EAAU,CACd,QACA,OACA,eACA,kBACA,eACA,qBACA,GAAG,KAAK,SACV,EAEMC,EAAkBC,EAAS,EAC3BC,EAAc,CAClB,IAAK,CAAE,GAAG,QAAQ,IAAK,uBAAwB,GAAI,EACnD,GAAIF,IAAoB,SAAW,CAAE,MAAO,EAAK,CACnD,EAEA,KAAK,QAAUG,EAAM,MAAYJ,EAASG,CAAW,EAErD,KAAK,QAAQ,QAAQ,GAAG,OAASE,GAAc,CAC7C,IAAMC,EAAMD,EAAK,SAAS,EAEtB,KAAK,YACP,QAAQ,IAAIC,CAAG,CAEnB,CAAC,CACH,CAUA,MAAM,sBAAyC,CAC7C,IAAIC,EAAc,MAAM,KAAK,mBAAmB,EAC1CC,EAAQ,KAAK,IAAI,EAAI,IACvBC,EAAOD,EAEX,KAAO,CAACD,GAAeC,EAAQ,KAAK,sBAAwBC,GAC1D,MAAMC,EAAM,GAAI,EAEhBH,EAAc,MAAM,KAAK,mBAAmB,EAC5CE,EAAO,KAAK,IAAI,EAAI,IAKtB,GAAI,CAACF,EACH,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAO,EACT,CASA,MAAM,oBAAuC,CAC3C,GAAI,CAGF,OADa,MAAM,MAAM,KAAK,kBAAkB,GACvC,SAAW,GAItB,MAAQ,CACN,MAAO,EACT,CACF,CACF","names":["spawn","kill","platform","LocalNode","args","resolve","reject","kill","err","cliArgs","currentPlatform","platform","spawnConfig","spawn","data","str","operational","start","last","sleep"]}
@@ -1,7 +1,7 @@
1
- import{d as a}from"./chunk-7FG7RJDS.mjs";var l=(t=>(t[t.API_ERROR=0]="API_ERROR",t[t.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",t[t.SESSION_EXPIRED=2]="SESSION_EXPIRED",t[t.INVALID_STATE=3]="INVALID_STATE",t[t.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",t[t.UNKNOWN=5]="UNKNOWN",t))(l||{}),O=(s=>(s.REAUTHENTICATE="Re-authentiate to continue using your keyless account",s.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",s.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",s.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",s.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",s.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",s.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s))(O||{}),u=(e=>(e[e.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",e[e.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",e[e.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",e[e.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",e[e.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",e[e.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",e[e.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",e[e.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",e[e.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",e[e.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",e[e.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",e[e.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",e[e.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",e[e.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",e[e.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",e[e.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",e[e.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",e[e.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",e[e.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",e[e.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",e[e.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",e[e.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",e[e.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",e[e.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",e[e.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",e[e.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",e[e.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",e[e.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",e[e.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",e[e.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",e[e.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",e[e.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",e[e.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",e[e.UNKNOWN=33]="UNKNOWN",e))(u||{}),A={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},N=class _ extends Error{constructor(o){let{innerError:r,category:E,resolutionTip:i,type:R,message:t=A[R][0],details:I}=o;super(t),this.name="KeylessError",this.innerError=r,this.category=E,this.resolutionTip=i,this.type=R,this.details=I,this.message=_.constructMessage(t,i,r,I)}static constructMessage(o,r,E,i){let R=`
1
+ import{d as a}from"./chunk-5LMLIRGK.mjs";var l=(t=>(t[t.API_ERROR=0]="API_ERROR",t[t.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",t[t.SESSION_EXPIRED=2]="SESSION_EXPIRED",t[t.INVALID_STATE=3]="INVALID_STATE",t[t.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",t[t.UNKNOWN=5]="UNKNOWN",t))(l||{}),O=(s=>(s.REAUTHENTICATE="Re-authentiate to continue using your keyless account",s.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",s.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",s.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",s.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",s.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",s.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s))(O||{}),u=(e=>(e[e.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",e[e.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",e[e.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",e[e.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",e[e.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",e[e.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",e[e.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",e[e.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",e[e.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",e[e.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",e[e.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",e[e.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",e[e.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",e[e.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",e[e.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",e[e.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",e[e.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",e[e.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",e[e.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",e[e.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",e[e.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",e[e.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",e[e.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",e[e.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",e[e.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",e[e.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",e[e.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",e[e.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",e[e.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",e[e.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",e[e.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",e[e.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",e[e.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",e[e.UNKNOWN=33]="UNKNOWN",e))(u||{}),A={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},N=class _ extends Error{constructor(o){let{innerError:r,category:E,resolutionTip:i,type:R,message:t=A[R][0],details:I}=o;super(t),this.name="KeylessError",this.innerError=r,this.category=E,this.resolutionTip=i,this.type=R,this.details=I,this.message=_.constructMessage(t,i,r,I)}static constructMessage(o,r,E,i){let R=`
2
2
  Message: ${o}`;return i&&(R+=`
3
3
  Details: ${i}`),E instanceof T?R+=`
4
4
  AptosApiError: ${E.message}`:E!==void 0&&(R+=`
5
5
  Error: ${a(E)}`),R+=`
6
6
  KeylessErrorResolutionTip: ${r}`,R}static fromErrorType(o){let{error:r,type:E,details:i}=o,[R,t,I]=A[E];return new _({message:R,details:i,innerError:r,category:t,resolutionTip:I,type:E})}},T=class extends Error{constructor({apiType:o,aptosRequest:r,aptosResponse:E}){super(S({apiType:o,aptosRequest:r,aptosResponse:E})),this.name="AptosApiError",this.url=E.url,this.status=E.status,this.statusText=E.statusText,this.data=E.data,this.request=r}};function S({apiType:_,aptosRequest:o,aptosResponse:r}){let E=r.headers?.traceparent?.split("-")[1],i=E?`(trace_id:${E}) `:"",R=`Request to [${_}]: ${o.method} ${r.url??o.url} ${i}failed with`;return _==="Indexer"&&r.data?.errors?.[0]?.message!=null?`${R}: ${r.data.errors[0].message}`:r.data?.message!=null&&r.data?.error_code!=null?`${R}: ${JSON.stringify(r.data)}`:`${R} status: ${r.statusText}(code:${r.status}) and response body: ${P(r.data)}`}var n=400;function P(_){let o=JSON.stringify(_);return o.length<=n?o:`truncated(original_size:${o.length}): ${o.slice(0,n/2)}...${o.slice(-n/2)}`}export{l as a,O as b,u as c,N as d,T as e};
7
- //# sourceMappingURL=chunk-KLDERTLN.mjs.map
7
+ //# sourceMappingURL=chunk-ASFFADWS.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as r,c as B,e as s}from"./chunk-V5K2RRFT.mjs";import{a,b as l,c as n,d as o,e as z,f as u,g as c,h as d,i as I,j as p,k as U,l as v,m as A,n as m,o as S,p as h,q as F,r as y}from"./chunk-X2TPNKLV.mjs";var b=class i extends r{constructor(e){super(),B(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new t(e.deserializeU256())}static deserialize(e){return new i(e.deserializeBool())}},N=class i extends r{constructor(e){super(),s(e,0,a),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new i(e.deserializeU8())}},_=class i extends r{constructor(e){super(),s(e,0,l),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new i(e.deserializeU16())}},g=class i extends r{constructor(e){super(),s(e,0,n),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new i(e.deserializeU32())}},M=class i extends r{constructor(e){super(),s(e,BigInt(0),o),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new i(e.deserializeU64())}},x=class i extends r{constructor(e){super(),s(e,BigInt(0),z),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new i(e.deserializeU128())}},t=class i extends r{constructor(e){super(),s(e,BigInt(0),u),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new i(e.deserializeU256())}},T=class i extends r{constructor(e){super(),s(e,c,d),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(10),e.serialize(this)}static deserialize(e){return new i(e.deserializeI8())}},E=class i extends r{constructor(e){super(),s(e,I,p),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(11),e.serialize(this)}static deserialize(e){return new i(e.deserializeI16())}},D=class i extends r{constructor(e){super(),s(e,U,v),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(12),e.serialize(this)}static deserialize(e){return new i(e.deserializeI32())}},w=class i extends r{constructor(e){super(),s(e,A,m),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(13),e.serialize(this)}static deserialize(e){return new i(e.deserializeI64())}},X=class i extends r{constructor(e){super(),s(e,S,h),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(14),e.serialize(this)}static deserialize(e){return new i(e.deserializeI128())}},R=class i extends r{constructor(e){super(),s(e,F,y),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(15),e.serialize(this)}static deserialize(e){return new i(e.deserializeI256())}};export{b as a,N as b,_ as c,g as d,M as e,x as f,t as g,T as h,E as i,D as j,w as k,X as l,R as m};
2
- //# sourceMappingURL=chunk-32J7VMLV.mjs.map
1
+ import{a as r,c as B,e as s}from"./chunk-66F7RP7K.mjs";import{a,b as l,c as n,d as o,e as z,f as u,g as c,h as d,i as I,j as p,k as U,l as v,m as A,n as m,o as S,p as h,q as F,r as y}from"./chunk-X2TPNKLV.mjs";var b=class i extends r{constructor(e){super(),B(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new t(e.deserializeU256())}static deserialize(e){return new i(e.deserializeBool())}},N=class i extends r{constructor(e){super(),s(e,0,a),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new i(e.deserializeU8())}},_=class i extends r{constructor(e){super(),s(e,0,l),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new i(e.deserializeU16())}},g=class i extends r{constructor(e){super(),s(e,0,n),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new i(e.deserializeU32())}},M=class i extends r{constructor(e){super(),s(e,BigInt(0),o),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new i(e.deserializeU64())}},x=class i extends r{constructor(e){super(),s(e,BigInt(0),z),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new i(e.deserializeU128())}},t=class i extends r{constructor(e){super(),s(e,BigInt(0),u),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new i(e.deserializeU256())}},T=class i extends r{constructor(e){super(),s(e,c,d),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(10),e.serialize(this)}static deserialize(e){return new i(e.deserializeI8())}},E=class i extends r{constructor(e){super(),s(e,I,p),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(11),e.serialize(this)}static deserialize(e){return new i(e.deserializeI16())}},D=class i extends r{constructor(e){super(),s(e,U,v),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(12),e.serialize(this)}static deserialize(e){return new i(e.deserializeI32())}},w=class i extends r{constructor(e){super(),s(e,A,m),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(13),e.serialize(this)}static deserialize(e){return new i(e.deserializeI64())}},X=class i extends r{constructor(e){super(),s(e,S,h),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(14),e.serialize(this)}static deserialize(e){return new i(e.deserializeI128())}},R=class i extends r{constructor(e){super(),s(e,F,y),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(15),e.serialize(this)}static deserialize(e){return new i(e.deserializeI256())}};export{b as a,N as b,_ as c,g as d,M as e,x as f,t as g,T as h,E as i,D as j,w as k,X as l,R as m};
2
+ //# sourceMappingURL=chunk-BT742BFQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bcs/serializable/movePrimitives.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n MIN_I8_NUMBER,\n MAX_I8_NUMBER,\n MIN_I16_NUMBER,\n MAX_I16_NUMBER,\n MIN_I32_NUMBER,\n MAX_I32_NUMBER,\n MIN_I64_BIG_INT,\n MAX_I64_BIG_INT,\n MIN_I128_BIG_INT,\n MAX_I128_BIG_INT,\n MIN_I256_BIG_INT,\n MAX_I256_BIG_INT,\n} from \"../consts\";\nimport { Deserializer } from \"../deserializer\";\nimport { Serializable, Serializer, ensureBoolean, validateNumberInRange } from \"../serializer\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { AnyNumber, Uint16, Uint32, Uint8, Int8, Int16, Int32, ScriptTransactionArgumentVariants } from \"../../types\";\n\n/**\n * Represents a boolean value that can be serialized and deserialized.\n * This class extends the Serializable class and provides methods to serialize\n * the boolean value for different contexts, such as entry functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Bool extends Serializable implements TransactionArgument {\n public readonly value: boolean;\n\n /**\n * Constructs a new instance with a specified value.\n * This ensures that the value is validated to be within the acceptable range.\n *\n * @param value - The number to be validated and assigned, which must be between 0 and MAX_U256_BIG_INT.\n * @group Implementation\n * @category BCS\n */\n constructor(value: boolean) {\n super();\n\n /**\n * Ensures that the provided value is of type boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n this.value = value;\n }\n\n /**\n * Serializes the value using the provided serializer.\n * This function is essential for converting the value into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBool(this.value);\n }\n\n /**\n * Serializes the current instance for use in an entry function by converting it to a byte sequence.\n * This allows the instance to be properly formatted for serialization in transactions.\n * Uses the optimized serializeAsBytes method to reduce allocations.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n /**\n * Serializes the current instance for use in a script function.\n * This allows for the conversion of the instance into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Bool);\n serializer.serialize(this);\n }\n\n /**\n * Deserializes a U256 value from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the U256 data.\n * @group Implementation\n * @category BCS\n */\n\n deserialize(deserializer: Deserializer) {\n return new U256(deserializer.deserializeU256());\n }\n\n static deserialize(deserializer: Deserializer): Bool {\n return new Bool(deserializer.deserializeBool());\n }\n}\n\n/**\n * Represents an unsigned 8-bit integer (U8) value.\n * This class extends the Serializable class and provides methods for serialization and deserialization of U8 values.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U8 extends Serializable implements TransactionArgument {\n public readonly value: Uint8;\n\n constructor(value: Uint8) {\n super();\n validateNumberInRange(value, 0, MAX_U8_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU8(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U8 {\n return new U8(deserializer.deserializeU8());\n }\n}\n\n/**\n * Represents a 16-bit unsigned integer (U16) value.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of the U16 value.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U16 extends Serializable implements TransactionArgument {\n public readonly value: Uint16;\n\n constructor(value: Uint16) {\n super();\n validateNumberInRange(value, 0, MAX_U16_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU16(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U16);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U16 {\n return new U16(deserializer.deserializeU16());\n }\n}\n\n/**\n * Represents a 32-bit unsigned integer (U32) that can be serialized and deserialized.\n * This class ensures that the value is within the valid range for a U32.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U32 extends Serializable implements TransactionArgument {\n public readonly value: Uint32;\n\n constructor(value: Uint32) {\n super();\n validateNumberInRange(value, 0, MAX_U32_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U32);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U32 {\n return new U32(deserializer.deserializeU32());\n }\n}\n\n/**\n * Represents a 64-bit unsigned integer (U64) and provides methods for serialization.\n *\n * This class ensures that the value is within the valid range for a U64 and provides\n * functionality to serialize the value for various use cases, including entry functions\n * and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U64 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U64_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU64(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U64);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U64 {\n return new U64(deserializer.deserializeU64());\n }\n}\n\n/**\n * Represents a 128-bit unsigned integer value.\n * This class provides methods for serialization and deserialization\n * of U128 values, ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U128 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U128_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU128(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U128);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U128 {\n return new U128(deserializer.deserializeU128());\n }\n}\n\n/**\n * Represents a 256-bit unsigned integer (U256) that extends the Serializable class.\n * This class provides methods for serialization and deserialization of U256 values,\n * ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U256 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U256_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU256(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U256);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U256 {\n return new U256(deserializer.deserializeU256());\n }\n}\n\n/**\n * Represents an 8-bit signed integer (I8) value.\n * This class extends the Serializable class and provides methods for serialization and deserialization of I8 values.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I8 extends Serializable implements TransactionArgument {\n public readonly value: Int8;\n\n constructor(value: Int8) {\n super();\n validateNumberInRange(value, MIN_I8_NUMBER, MAX_I8_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI8(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I8);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I8 {\n return new I8(deserializer.deserializeI8());\n }\n}\n\n/**\n * Represents a 16-bit signed integer (I16) value.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of the I16 value.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I16 extends Serializable implements TransactionArgument {\n public readonly value: Int16;\n\n constructor(value: Int16) {\n super();\n validateNumberInRange(value, MIN_I16_NUMBER, MAX_I16_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI16(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I16);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I16 {\n return new I16(deserializer.deserializeI16());\n }\n}\n\n/**\n * Represents a 32-bit signed integer (I32) that can be serialized and deserialized.\n * This class ensures that the value is within the valid range for an I32.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I32 extends Serializable implements TransactionArgument {\n public readonly value: Int32;\n\n constructor(value: Int32) {\n super();\n validateNumberInRange(value, MIN_I32_NUMBER, MAX_I32_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI32(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I32);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I32 {\n return new I32(deserializer.deserializeI32());\n }\n}\n\n/**\n * Represents a 64-bit signed integer (I64) and provides methods for serialization.\n *\n * This class ensures that the value is within the valid range for an I64 and provides\n * functionality to serialize the value for various use cases, including entry functions\n * and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I64 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I64_BIG_INT, MAX_I64_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI64(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I64);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I64 {\n return new I64(deserializer.deserializeI64());\n }\n}\n\n/**\n * Represents a 128-bit signed integer value.\n * This class provides methods for serialization and deserialization\n * of I128 values, ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I128 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I128_BIG_INT, MAX_I128_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI128(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I128);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I128 {\n return new I128(deserializer.deserializeI128());\n }\n}\n\n/**\n * Represents a 256-bit signed integer (I256) that extends the Serializable class.\n * This class provides methods for serialization and deserialization of I256 values,\n * ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I256 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I256_BIG_INT, MAX_I256_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI256(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I256);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I256 {\n return new I256(deserializer.deserializeI256());\n }\n}\n"],"mappings":"kNAoCO,IAAMA,EAAN,MAAMC,UAAaC,CAA4C,CAWpE,YAAYC,EAAgB,CAC1B,MAAM,EAWNC,EAAcD,CAAK,EACnB,KAAK,MAAQA,CACf,CAUA,UAAUE,EAA8B,CACtCA,EAAW,cAAc,KAAK,KAAK,CACrC,CAWA,0BAA0BA,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAUA,2BAA2BA,EAA8B,CACvDA,EAAW,uBAA4D,EACvEA,EAAW,UAAU,IAAI,CAC3B,CAUA,YAAYC,EAA4B,CACtC,OAAO,IAAIC,EAAKD,EAAa,gBAAgB,CAAC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AAW,iBAAiB,IAAI,CAClC,CAEA,2BAA2BA,EAA8B,CACvDA,EAAW,wBAA4D,EACvEA,EAAW,UAAU,IAAI,CAC3B,CAEA,OAAO,YAAYC,EAAkC,CACnD,OAAO,IAAIyC,EAAKzC,EAAa,gBAAgB,CAAC,CAChD,CACF","names":["Bool","_Bool","Serializable","value","ensureBoolean","serializer","deserializer","U256","U8","_U8","validateNumberInRange","MAX_U8_NUMBER","U16","_U16","MAX_U16_NUMBER","U32","_U32","MAX_U32_NUMBER","U64","_U64","MAX_U64_BIG_INT","U128","_U128","MAX_U128_BIG_INT","_U256","MAX_U256_BIG_INT","I8","_I8","MIN_I8_NUMBER","MAX_I8_NUMBER","I16","_I16","MIN_I16_NUMBER","MAX_I16_NUMBER","I32","_I32","MIN_I32_NUMBER","MAX_I32_NUMBER","I64","_I64","MIN_I64_BIG_INT","MAX_I64_BIG_INT","I128","_I128","MIN_I128_BIG_INT","MAX_I128_BIG_INT","I256","_I256","MIN_I256_BIG_INT","MAX_I256_BIG_INT"]}
@@ -0,0 +1,2 @@
1
+ import{b as o}from"./chunk-FDHHQUS3.mjs";import{m as n}from"./chunk-TAHLOBRG.mjs";import{sha3_256 as d}from"@noble/hashes/sha3";var A=(s,e)=>{let r=s.bcsToBytes(),t=typeof e=="string"?n.encode(e):e,c=new Uint8Array([...r,...t,254]);return new o(d(c))},m=(s,e)=>{let r=s.bcsToBytes(),t=typeof e=="string"?n.encode(e):e,c=new Uint8Array([...r,...t,255]);return new o(d(c))},p=(s,e)=>{let r=s.bcsToBytes(),t=e.bcsToBytes(),c=new Uint8Array([...r,...t,252]);return new o(d(c))},B=(s,e,r)=>{let t=`${e}::${r}`;return A(s,t)};export{A as a,m as b,p as c,B as d};
2
+ //# sourceMappingURL=chunk-C2KVLMPH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/account/utils/address.ts"],"sourcesContent":["import { sha3_256 } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"../../accountAddress\";\nimport { DeriveScheme } from \"../../../types\";\nimport { TEXT_ENCODER } from \"../../../utils/const\";\n\n/**\n * Creates an object address from creator address and seed\n *\n * @param creatorAddress The object creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The object account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n const seedBytes = typeof seed === \"string\" ? TEXT_ENCODER.encode(seed) : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveObjectAddressFromSeed]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a resource address from creator address and seed\n *\n * @param creatorAddress The creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The resource account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createResourceAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n\n const seedBytes = typeof seed === \"string\" ? TEXT_ENCODER.encode(seed) : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveResourceAccountAddress]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a user derived object address from source address and derive_from address\n *\n * @param sourceAddress The source account address\n * @param deriveFromAddress The address to derive from\n *\n * @returns The user derived object address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createUserDerivedObjectAddress = (\n sourceAddress: AccountAddress,\n deriveFromAddress: AccountAddress,\n): AccountAddress => {\n const sourceBytes = sourceAddress.bcsToBytes();\n const deriveFromBytes = deriveFromAddress.bcsToBytes();\n\n const bytes = new Uint8Array([...sourceBytes, ...deriveFromBytes, DeriveScheme.DeriveObjectAddressFromObject]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a token object address from creator address, collection name and token name\n *\n * @param creatorAddress The token creator account address\n * @param collectionName The collection name\n * @param tokenName The token name\n *\n * @returns The token account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createTokenAddress = (\n creatorAddress: AccountAddress,\n collectionName: string,\n tokenName: string,\n): AccountAddress => {\n const seed = `${collectionName}::${tokenName}`;\n return createObjectAddress(creatorAddress, seed);\n};\n"],"mappings":"kFAAA,OAAS,YAAAA,MAAgB,qBAelB,IAAMC,EAAsB,CAACC,EAAgCC,IAA8C,CAChH,IAAMC,EAAeF,EAAe,WAAW,EACzCG,EAAY,OAAOF,GAAS,SAAWG,EAAa,OAAOH,CAAI,EAAIA,EAEnEI,EAAQ,IAAI,WAAW,CAAC,GAAGH,EAAc,GAAGC,KAAmD,CAAC,EAEtG,OAAO,IAAIG,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAYaG,EAAwB,CAACR,EAAgCC,IAA8C,CAClH,IAAMC,EAAeF,EAAe,WAAW,EAEzCG,EAAY,OAAOF,GAAS,SAAWG,EAAa,OAAOH,CAAI,EAAIA,EAEnEI,EAAQ,IAAI,WAAW,CAAC,GAAGH,EAAc,GAAGC,KAAoD,CAAC,EAEvG,OAAO,IAAIG,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAYaI,EAAiC,CAC5CC,EACAC,IACmB,CACnB,IAAMC,EAAcF,EAAc,WAAW,EACvCG,EAAkBF,EAAkB,WAAW,EAE/CN,EAAQ,IAAI,WAAW,CAAC,GAAGO,EAAa,GAAGC,KAA2D,CAAC,EAE7G,OAAO,IAAIP,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAaaS,EAAqB,CAChCd,EACAe,EACAC,IACmB,CACnB,IAAMf,EAAO,GAAGc,CAAc,KAAKC,CAAS,GAC5C,OAAOjB,EAAoBC,EAAgBC,CAAI,CACjD","names":["sha3_256","createObjectAddress","creatorAddress","seed","creatorBytes","seedBytes","TEXT_ENCODER","bytes","AccountAddress","sha3_256","createResourceAddress","createUserDerivedObjectAddress","sourceAddress","deriveFromAddress","sourceBytes","deriveFromBytes","createTokenAddress","collectionName","tokenName"]}
@@ -1,2 +1,2 @@
1
- import{a as r}from"./chunk-V5K2RRFT.mjs";import{b as i}from"./chunk-STY74NUA.mjs";var t=class a extends r{constructor(e){super(),this.value=i.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,s){let o=e.deserializeFixedBytes(s);return new a(o)}};export{t as a};
2
- //# sourceMappingURL=chunk-VWXVSRRQ.mjs.map
1
+ import{a as r}from"./chunk-66F7RP7K.mjs";import{b as i}from"./chunk-STY74NUA.mjs";var t=class a extends r{constructor(e){super(),this.value=i.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,s){let o=e.deserializeFixedBytes(s);return new a(o)}};export{t as a};
2
+ //# sourceMappingURL=chunk-CD3EZCI5.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-VWXVSRRQ.mjs";import{a as r}from"./chunk-V5K2RRFT.mjs";var t=class l extends r{constructor(e){super(),this.value=new i(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,s){let a=i.deserialize(e,s);return new l(a.value)}};export{t as a};
2
- //# sourceMappingURL=chunk-QV37KEZY.mjs.map
1
+ import{a as i}from"./chunk-CD3EZCI5.mjs";import{a as r}from"./chunk-66F7RP7K.mjs";var t=class l extends r{constructor(e){super(),this.value=new i(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,s){let a=i.deserialize(e,s);return new l(a.value)}};export{t as a};
2
+ //# sourceMappingURL=chunk-E3DHFXN4.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as r}from"./chunk-V5K2RRFT.mjs";import{b as t}from"./chunk-STY74NUA.mjs";var o=class extends r{toUint8Array(){return this.bcsToBytes()}toString(){let i=this.toUint8Array();return t.fromHexInput(i).toString()}};export{o as a};
2
- //# sourceMappingURL=chunk-DE4YVX3L.mjs.map
1
+ import{a as r}from"./chunk-66F7RP7K.mjs";import{b as t}from"./chunk-STY74NUA.mjs";var o=class extends r{toUint8Array(){return this.bcsToBytes()}toString(){let i=this.toUint8Array();return t.fromHexInput(i).toString()}};export{o as a};
2
+ //# sourceMappingURL=chunk-EIWPAECI.mjs.map
@@ -1,2 +1,2 @@
1
- import{b as o}from"./chunk-7FG7RJDS.mjs";import{b as r}from"./chunk-STY74NUA.mjs";var a=class a{static formatPrivateKey(e,p){let i=a.AIP80_PREFIXES[p],t=e;return typeof t=="string"&&t.startsWith(i)&&(t=t.split("-")[2]),`${i}${r.fromHexInput(t).toString()}`}static parseHexInput(e,p,i){let t,n=a.AIP80_PREFIXES[p];if(typeof e=="string")if(!i&&!e.startsWith(n))t=r.fromHexInput(e),i!==!1&&o("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(n))t=r.fromHexString(e.split("-")[2]);else throw i?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else t=r.fromHexInput(e);return t}};a.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var s=a;export{s as a};
2
- //# sourceMappingURL=chunk-US6KOOYS.mjs.map
1
+ import{b as o}from"./chunk-5LMLIRGK.mjs";import{b as r}from"./chunk-STY74NUA.mjs";var a=class a{static formatPrivateKey(e,p){let i=a.AIP80_PREFIXES[p],t=e;return typeof t=="string"&&t.startsWith(i)&&(t=t.split("-")[2]),`${i}${r.fromHexInput(t).toString()}`}static parseHexInput(e,p,i){let t,n=a.AIP80_PREFIXES[p];if(typeof e=="string")if(!i&&!e.startsWith(n))t=r.fromHexInput(e),i!==!1&&o("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(n))t=r.fromHexString(e.split("-")[2]);else throw i?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else t=r.fromHexInput(e);return t}};a.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var s=a;export{s as a};
2
+ //# sourceMappingURL=chunk-F4LHBGG2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/crypto/privateKey.ts"],"sourcesContent":["import { HexInput, PrivateKeyVariants } from \"../../types\";\nimport { Hex } from \"../hex\";\nimport { PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { warnIfDevelopment } from \"../../utils/helpers\";\n\n/**\n * Represents a private key used for signing messages and deriving the associated public key.\n * @group Implementation\n * @category Serialization\n */\nexport interface PrivateKey {\n /**\n * Sign the given message with the private key to create a signature.\n * @param message - The message to be signed, provided in HexInput format.\n * @returns A Signature object representing the signed message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Signature;\n\n /**\n * Derive the public key associated with the private key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): PublicKey;\n\n /**\n * Get the private key in bytes (Uint8Array).\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array;\n}\n\nexport class PrivateKey {\n /**\n * The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation\n * to get an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n */\n public static readonly AIP80_PREFIXES = {\n [PrivateKeyVariants.Ed25519]: \"ed25519-priv-\",\n [PrivateKeyVariants.Secp256k1]: \"secp256k1-priv-\",\n [PrivateKeyVariants.Secp256r1]: \"secp256r1-priv-\",\n };\n\n /**\n * Format a HexInput to an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param privateKey - The HexString or Uint8Array format of the private key.\n * @param privateKeyType - The private key type\n */\n public static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string {\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n\n // Remove the prefix if it exists\n let formattedPrivateKey = privateKey;\n if (typeof formattedPrivateKey === \"string\" && formattedPrivateKey.startsWith(aip80Prefix)) {\n formattedPrivateKey = formattedPrivateKey.split(\"-\")[2];\n }\n\n return `${aip80Prefix}${Hex.fromHexInput(formattedPrivateKey).toString()}`;\n }\n\n /**\n * Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param value - A HexString, Uint8Array, or a AIP-80 compliant string.\n * @param privateKeyType - The private key type\n * @param strict - If true, the value MUST be compliant with AIP-80.\n */\n public static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex {\n let data: Hex;\n\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n if (typeof value === \"string\") {\n if (!strict && !value.startsWith(aip80Prefix)) {\n // HexString input\n data = Hex.fromHexInput(value);\n // If the strictness is false, the user has opted into non-AIP-80 compliant private keys.\n if (strict !== false) {\n warnIfDevelopment(\n \"[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.\",\n );\n }\n } else if (value.startsWith(aip80Prefix)) {\n // AIP-80 Compliant String input\n data = Hex.fromHexString(value.split(\"-\")[2]);\n } else {\n if (strict) {\n // The value does not start with the AIP-80 prefix, and strict is true.\n throw new Error(\"Invalid HexString input while parsing private key. Must AIP-80 compliant string.\");\n }\n\n // This condition should never be reached.\n throw new Error(\"Invalid HexString input while parsing private key.\");\n }\n } else {\n // The value is an Uint8Array\n data = Hex.fromHexInput(value);\n }\n\n return data;\n }\n}\n"],"mappings":"kFAoCO,IAAMA,EAAN,MAAMA,CAAW,CAqBtB,OAAc,iBAAiBC,EAAsBC,EAAkC,CACrF,IAAMC,EAAcH,EAAW,eAAeE,CAAI,EAG9CE,EAAsBH,EAC1B,OAAI,OAAOG,GAAwB,UAAYA,EAAoB,WAAWD,CAAW,IACvFC,EAAsBA,EAAoB,MAAM,GAAG,EAAE,CAAC,GAGjD,GAAGD,CAAW,GAAGE,EAAI,aAAaD,CAAmB,EAAE,SAAS,CAAC,EAC1E,CAWA,OAAc,cAAcE,EAAiBJ,EAA0BK,EAAuB,CAC5F,IAAIC,EAEEL,EAAcH,EAAW,eAAeE,CAAI,EAClD,GAAI,OAAOI,GAAU,SACnB,GAAI,CAACC,GAAU,CAACD,EAAM,WAAWH,CAAW,EAE1CK,EAAOH,EAAI,aAAaC,CAAK,EAEzBC,IAAW,IACbE,EACE,uRACF,UAEOH,EAAM,WAAWH,CAAW,EAErCK,EAAOH,EAAI,cAAcC,EAAM,MAAM,GAAG,EAAE,CAAC,CAAC,MAE5C,OAAIC,EAEI,IAAI,MAAM,kFAAkF,EAI9F,IAAI,MAAM,oDAAoD,OAItEC,EAAOH,EAAI,aAAaC,CAAK,EAG/B,OAAOE,CACT,CACF,EA3EaR,EAOY,eAAiB,CACrC,QAA6B,gBAC7B,UAA+B,kBAC/B,UAA+B,iBAClC,EAXK,IAAMU,EAANV","names":["_PrivateKey","privateKey","type","aip80Prefix","formattedPrivateKey","Hex","value","strict","data","warnIfDevelopment","PrivateKey"]}
@@ -1,2 +1,2 @@
1
- import{e as x,f as B}from"./chunk-3FDSKP56.mjs";import{a as k}from"./chunk-ODNZJSOC.mjs";import{b as f,d as A}from"./chunk-DECWO3X5.mjs";import{e as b}from"./chunk-KLDERTLN.mjs";import{e as C}from"./chunk-BHVMFSAD.mjs";import{c as d}from"./chunk-7FG7RJDS.mjs";async function H(o){let{aptosConfig:n,options:t}=o;return A({aptosConfig:n,originMethod:"getTransactions",path:"transactions",params:{start:t?.offset,limit:t?.limit}})}async function W(o){let{aptosConfig:n}=o;return k(async()=>{let{data:t}=await f({aptosConfig:n,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${n.network}`,1e3*60*5)()}async function O(o){let{aptosConfig:n,ledgerVersion:t}=o,{data:s}=await f({aptosConfig:n,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return s}async function y(o){let{aptosConfig:n,transactionHash:t}=o,{data:s}=await f({aptosConfig:n,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return s}async function q(o){let{aptosConfig:n,transactionHash:t}=o;try{return(await y({aptosConfig:n,transactionHash:t})).type==="pending_transaction"}catch(s){if(s?.status===404)return!0;throw s}}async function R(o){let{aptosConfig:n,transactionHash:t}=o,{data:s}=await f({aptosConfig:n,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return s}async function z(o){let{aptosConfig:n,transactionHash:t,options:s}=o,r=s?.timeoutSecs??20,u=s?.checkSuccess??!0,e=!0,p=0,i,g,l=200,h=1.5;function c(a){if(!(a instanceof b)||(g=a,a.status!==404&&a.status>=400&&a.status<500))throw a}try{i=await y({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction"}catch(a){c(a)}if(e){let a=Date.now();try{i=await R({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction"}catch(w){c(w)}p=(Date.now()-a)/1e3}for(;e&&!(p>=r);){try{if(i=await y({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction",!e)break}catch(a){c(a)}await d(l),p+=l/1e3,l*=h}if(i===void 0)throw g||new m(`Fetching transaction ${t} failed and timed out after ${r} seconds`,i);if(i.type==="pending_transaction")throw new m(`Transaction ${t} timed out in pending state after ${r} seconds`,i);if(!u)return i;if(!i.success)throw new T(`Transaction ${t} failed with an error: ${i.vm_status}`,i);return i}async function U(o){let{aptosConfig:n,processorType:t}=o,s=BigInt(o.minimumLedgerVersion),r=3e3,u=new Date().getTime(),e=BigInt(-1);for(;e<s;){if(new Date().getTime()-u>r)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?e=await x({aptosConfig:n}):e=(await B({aptosConfig:n,processorType:t})).last_success_version,e>=s)break;await d(200)}}var m=class extends Error{constructor(n,t){super(n),this.lastSubmittedTransaction=t}},T=class extends Error{constructor(n,t){super(n),this.transaction=t}};async function X(o){let{aptosConfig:n,ledgerVersion:t,options:s}=o,{data:r}=await f({aptosConfig:n,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:s?.withTransactions}});return P({block:r,...o})}async function j(o){let{aptosConfig:n,blockHeight:t,options:s}=o,{data:r}=await f({aptosConfig:n,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:s?.withTransactions}});return P({block:r,...o})}async function P(o){let{aptosConfig:n,block:t,options:s}=o;if(s?.withTransactions){t.transactions=t.transactions??[];let r=t.transactions[t.transactions.length-1],u=BigInt(t.first_version),e=BigInt(t.last_version),p=r?.version,i;if(p===void 0?i=u-1n:i=BigInt(p),i===e)return t;let g=[],l=100n;for(let c=i+1n;c<e;c+=BigInt(100))g.push(H({aptosConfig:n,options:{offset:c,limit:Math.min(Number(l),Number(e-c+1n))}}));let h=await Promise.all(g);for(let c of h)t.transactions.push(...c)}return t}export{H as a,W as b,O as c,y as d,q as e,R as f,z as g,U as h,m as i,T as j,X as k,j as l};
2
- //# sourceMappingURL=chunk-TIMTVXFU.mjs.map
1
+ import{e as x,f as B}from"./chunk-J73MMLF7.mjs";import{a as k}from"./chunk-ODNZJSOC.mjs";import{b as f,d as A}from"./chunk-TEI33TO7.mjs";import{e as b}from"./chunk-ASFFADWS.mjs";import{c as d}from"./chunk-5LMLIRGK.mjs";import{e as C}from"./chunk-TAHLOBRG.mjs";async function H(o){let{aptosConfig:n,options:t}=o;return A({aptosConfig:n,originMethod:"getTransactions",path:"transactions",params:{start:t?.offset,limit:t?.limit}})}async function W(o){let{aptosConfig:n}=o;return k(async()=>{let{data:t}=await f({aptosConfig:n,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${n.network}`,1e3*60*5)()}async function O(o){let{aptosConfig:n,ledgerVersion:t}=o,{data:s}=await f({aptosConfig:n,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return s}async function y(o){let{aptosConfig:n,transactionHash:t}=o,{data:s}=await f({aptosConfig:n,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return s}async function q(o){let{aptosConfig:n,transactionHash:t}=o;try{return(await y({aptosConfig:n,transactionHash:t})).type==="pending_transaction"}catch(s){if(s?.status===404)return!0;throw s}}async function R(o){let{aptosConfig:n,transactionHash:t}=o,{data:s}=await f({aptosConfig:n,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return s}async function z(o){let{aptosConfig:n,transactionHash:t,options:s}=o,r=s?.timeoutSecs??20,u=s?.checkSuccess??!0,e=!0,p=0,i,g,l=200,h=1.5;function c(a){if(!(a instanceof b)||(g=a,a.status!==404&&a.status>=400&&a.status<500))throw a}try{i=await y({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction"}catch(a){c(a)}if(e){let a=Date.now();try{i=await R({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction"}catch(w){c(w)}p=(Date.now()-a)/1e3}for(;e&&!(p>=r);){try{if(i=await y({aptosConfig:n,transactionHash:t}),e=i.type==="pending_transaction",!e)break}catch(a){c(a)}await d(l),p+=l/1e3,l*=h}if(i===void 0)throw g||new m(`Fetching transaction ${t} failed and timed out after ${r} seconds`,i);if(i.type==="pending_transaction")throw new m(`Transaction ${t} timed out in pending state after ${r} seconds`,i);if(!u)return i;if(!i.success)throw new T(`Transaction ${t} failed with an error: ${i.vm_status}`,i);return i}async function U(o){let{aptosConfig:n,processorType:t}=o,s=BigInt(o.minimumLedgerVersion),r=3e3,u=Date.now(),e=BigInt(-1);for(;e<s;){if(Date.now()-u>r)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?e=await x({aptosConfig:n}):e=(await B({aptosConfig:n,processorType:t})).last_success_version,e>=s)break;await d(200)}}var m=class extends Error{constructor(n,t){super(n),this.lastSubmittedTransaction=t}},T=class extends Error{constructor(n,t){super(n),this.transaction=t}};async function X(o){let{aptosConfig:n,ledgerVersion:t,options:s}=o,{data:r}=await f({aptosConfig:n,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:s?.withTransactions}});return P({block:r,...o})}async function j(o){let{aptosConfig:n,blockHeight:t,options:s}=o,{data:r}=await f({aptosConfig:n,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:s?.withTransactions}});return P({block:r,...o})}async function P(o){let{aptosConfig:n,block:t,options:s}=o;if(s?.withTransactions){t.transactions=t.transactions??[];let r=t.transactions[t.transactions.length-1],u=BigInt(t.first_version),e=BigInt(t.last_version),p=r?.version,i;if(p===void 0?i=u-1n:i=BigInt(p),i===e)return t;let g=[],l=100n;for(let c=i+1n;c<e;c+=BigInt(100))g.push(H({aptosConfig:n,options:{offset:c,limit:Math.min(Number(l),Number(e-c+1n))}}));let h=await Promise.all(g);for(let c of h)t.transactions.push(...c)}return t}export{H as a,W as b,O as c,y as d,q as e,R as f,z as g,U as h,m as i,T as j,X as k,j as l};
2
+ //# sourceMappingURL=chunk-F5KAWYF5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/internal/transaction.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/transaction}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * transaction namespace and without having a dependency cycle error.\n * @group Implementation\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, paginateWithCursor } from \"../client\";\nimport { AptosApiError } from \"../errors\";\nimport {\n TransactionResponseType,\n type AnyNumber,\n type GasEstimation,\n type HexInput,\n type PaginationArgs,\n type TransactionResponse,\n WaitForTransactionOptions,\n CommittedTransactionResponse,\n Block,\n} from \"../types\";\nimport { DEFAULT_TXN_TIMEOUT_SEC, ProcessorType } from \"../utils/const\";\nimport { sleep } from \"../utils/helpers\";\nimport { memoizeAsync } from \"../utils/memoize\";\nimport { getIndexerLastSuccessVersion, getProcessorStatus } from \"./general\";\n\n/**\n * Retrieve a list of transactions based on the specified options.\n *\n * @param {Object} args - The parameters for retrieving transactions.\n * @param {Object} args.aptosConfig - The configuration object for Aptos.\n * @param {Object} args.options - The options for pagination.\n * @param {number} args.options.offset - The number of transactions to skip before starting to collect the result set.\n * @param {number} args.options.limit - The maximum number of transactions to return.\n * @group Implementation\n */\nexport async function getTransactions(args: {\n aptosConfig: AptosConfig;\n options?: PaginationArgs;\n}): Promise<TransactionResponse[]> {\n const { aptosConfig, options } = args;\n return paginateWithCursor<{}, TransactionResponse[]>({\n aptosConfig,\n originMethod: \"getTransactions\",\n path: \"transactions\",\n params: { start: options?.offset, limit: options?.limit },\n });\n}\n\n/**\n * Retrieves the estimated gas price for transactions on the Aptos network.\n * This function helps users understand the current gas price, which is essential for transaction planning and cost estimation.\n *\n * @param args - The configuration parameters for the Aptos network.\n * @param args.aptosConfig - The configuration object containing network details.\n * @group Implementation\n */\nexport async function getGasPriceEstimation(args: { aptosConfig: AptosConfig }) {\n const { aptosConfig } = args;\n\n return memoizeAsync(\n async () => {\n const { data } = await getAptosFullNode<{}, GasEstimation>({\n aptosConfig,\n originMethod: \"getGasPriceEstimation\",\n path: \"estimate_gas_price\",\n });\n return data;\n },\n `gas-price-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Retrieves the transaction details associated with a specific ledger version.\n *\n * @param args - The arguments for the transaction retrieval.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.ledgerVersion - The ledger version for which to retrieve the transaction.\n * @returns The transaction details for the specified ledger version.\n * @group Implementation\n */\nexport async function getTransactionByVersion(args: {\n aptosConfig: AptosConfig;\n ledgerVersion: AnyNumber;\n}): Promise<TransactionResponse> {\n const { aptosConfig, ledgerVersion } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n originMethod: \"getTransactionByVersion\",\n path: `transactions/by_version/${ledgerVersion}`,\n });\n return data;\n}\n\n/**\n * Retrieves transaction details using the specified transaction hash.\n *\n * @param args - The arguments for retrieving the transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.transactionHash - The hash of the transaction to retrieve.\n * @returns A promise that resolves to the transaction details.\n * @group Implementation\n */\nexport async function getTransactionByHash(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<TransactionResponse> {\n const { aptosConfig, transactionHash } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n path: `transactions/by_hash/${transactionHash}`,\n originMethod: \"getTransactionByHash\",\n });\n return data;\n}\n\n/**\n * Checks if a transaction is currently pending based on its hash.\n * This function helps determine the status of a transaction in the Aptos network.\n *\n * @param args - The arguments for checking the transaction status.\n * @param args.aptosConfig - The configuration settings for connecting to the Aptos network.\n * @param args.transactionHash - The hash of the transaction to check.\n * @returns A boolean indicating whether the transaction is pending.\n * @throws An error if the transaction cannot be retrieved due to reasons other than a 404 status.\n * @group Implementation\n */\nexport async function isTransactionPending(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<boolean> {\n const { aptosConfig, transactionHash } = args;\n try {\n const transaction = await getTransactionByHash({ aptosConfig, transactionHash });\n return transaction.type === TransactionResponseType.Pending;\n } catch (e: any) {\n if (e?.status === 404) {\n return true;\n }\n throw e;\n }\n}\n\n/**\n * Waits for a transaction to be confirmed by its hash.\n * This function allows you to monitor the status of a transaction until it is finalized.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.transactionHash - The hash of the transaction to wait for.\n * @group Implementation\n */\nexport async function longWaitForTransaction(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<TransactionResponse> {\n const { aptosConfig, transactionHash } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n path: `transactions/wait_by_hash/${transactionHash}`,\n originMethod: \"longWaitForTransaction\",\n });\n return data;\n}\n\n/**\n * Waits for a transaction to be confirmed on the blockchain and handles potential errors during the process.\n * This function allows you to monitor the status of a transaction until it is either confirmed or fails.\n *\n * @param args - The arguments for waiting for a transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.transactionHash - The hash of the transaction to wait for.\n * @param args.options - Optional settings for waiting, including timeout and success check.\n * @param args.options.timeoutSecs - The maximum time to wait for the transaction in seconds. Defaults to a predefined value.\n * @param args.options.checkSuccess - A flag indicating whether to check the success status of the transaction. Defaults to true.\n * @returns A promise that resolves to the transaction response once the transaction is confirmed.\n * @throws WaitForTransactionError if the transaction times out or remains pending.\n * @throws FailedTransactionError if the transaction fails.\n * @group Implementation\n */\nexport async function waitForTransaction(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n options?: WaitForTransactionOptions;\n}): Promise<CommittedTransactionResponse> {\n const { aptosConfig, transactionHash, options } = args;\n const timeoutSecs = options?.timeoutSecs ?? DEFAULT_TXN_TIMEOUT_SEC;\n const checkSuccess = options?.checkSuccess ?? true;\n\n let isPending = true;\n let timeElapsed = 0;\n let lastTxn: TransactionResponse | undefined;\n let lastError: AptosApiError | undefined;\n let backoffIntervalMs = 200;\n const backoffMultiplier = 1.5;\n\n /**\n * Handles API errors by throwing the last error or a timeout error for a failed transaction.\n *\n * @param e - The error object that occurred during the API call.\n * @throws {Error} Throws the last error if it exists; otherwise, throws a WaitForTransactionError indicating a timeout.\n * @group Implementation\n */\n function handleAPIError(e: any) {\n // In short, this means we will retry if it was an AptosApiError and the code was 404 or 5xx.\n const isAptosApiError = e instanceof AptosApiError;\n if (!isAptosApiError) {\n throw e; // This would be unexpected\n }\n lastError = e;\n const isRequestError = e.status !== 404 && e.status >= 400 && e.status < 500;\n if (isRequestError) {\n throw e;\n }\n }\n\n // check to see if the txn is already on the blockchain\n try {\n lastTxn = await getTransactionByHash({ aptosConfig, transactionHash });\n isPending = lastTxn.type === TransactionResponseType.Pending;\n } catch (e) {\n handleAPIError(e);\n }\n\n // If the transaction is pending, we do a long wait once to avoid polling\n if (isPending) {\n const startTime = Date.now();\n try {\n lastTxn = await longWaitForTransaction({ aptosConfig, transactionHash });\n isPending = lastTxn.type === TransactionResponseType.Pending;\n } catch (e) {\n handleAPIError(e);\n }\n timeElapsed = (Date.now() - startTime) / 1000;\n }\n\n // Now we do polling to see if the transaction is still pending\n while (isPending) {\n if (timeElapsed >= timeoutSecs) {\n break;\n }\n try {\n lastTxn = await getTransactionByHash({ aptosConfig, transactionHash });\n\n isPending = lastTxn.type === TransactionResponseType.Pending;\n\n if (!isPending) {\n break;\n }\n } catch (e) {\n handleAPIError(e);\n }\n\n await sleep(backoffIntervalMs);\n timeElapsed += backoffIntervalMs / 1000; // Convert to seconds\n backoffIntervalMs *= backoffMultiplier;\n }\n\n // There is a chance that lastTxn is still undefined. Let's throw the last error otherwise a WaitForTransactionError\n if (lastTxn === undefined) {\n if (lastError) {\n throw lastError;\n } else {\n throw new WaitForTransactionError(\n `Fetching transaction ${transactionHash} failed and timed out after ${timeoutSecs} seconds`,\n lastTxn,\n );\n }\n }\n\n if (lastTxn.type === TransactionResponseType.Pending) {\n throw new WaitForTransactionError(\n `Transaction ${transactionHash} timed out in pending state after ${timeoutSecs} seconds`,\n lastTxn,\n );\n }\n if (!checkSuccess) {\n return lastTxn;\n }\n if (!lastTxn.success) {\n throw new FailedTransactionError(\n `Transaction ${transactionHash} failed with an error: ${lastTxn.vm_status}`,\n lastTxn,\n );\n }\n\n return lastTxn;\n}\n\n/**\n * Waits for the indexer to sync up to the specified ledger version. The timeout is 3 seconds.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.minimumLedgerVersion - The minimum ledger version that the indexer should sync to.\n * @param args.processorType - (Optional) The type of processor to check the last success version from.\n * @group Implementation\n */\nexport async function waitForIndexer(args: {\n aptosConfig: AptosConfig;\n minimumLedgerVersion: AnyNumber;\n processorType?: ProcessorType;\n}): Promise<void> {\n const { aptosConfig, processorType } = args;\n const minimumLedgerVersion = BigInt(args.minimumLedgerVersion);\n const timeoutMilliseconds = 3000; // 3 seconds\n const startTime = Date.now();\n let indexerVersion = BigInt(-1);\n\n while (indexerVersion < minimumLedgerVersion) {\n // check for timeout\n if (Date.now() - startTime > timeoutMilliseconds) {\n throw new Error(\"waitForLastSuccessIndexerVersionSync timeout\");\n }\n\n if (processorType === undefined) {\n // Get the last success version from all processor\n\n indexerVersion = await getIndexerLastSuccessVersion({ aptosConfig });\n } else {\n // Get the last success version from the specific processor\n\n const processor = await getProcessorStatus({ aptosConfig, processorType });\n indexerVersion = processor.last_success_version;\n }\n\n if (indexerVersion >= minimumLedgerVersion) {\n // break out immediately if we are synced\n break;\n }\n\n await sleep(200);\n }\n}\n\n/**\n * Represents an error that occurs when waiting for a transaction to complete.\n * This error is thrown by the `waitForTransaction` function when a transaction\n * times out or when the transaction response is undefined.\n *\n * @param message - A descriptive message for the error.\n * @param lastSubmittedTransaction - The last submitted transaction response, if available.\n * @group Implementation\n */\nexport class WaitForTransactionError extends Error {\n public readonly lastSubmittedTransaction: TransactionResponse | undefined;\n\n /**\n * Constructs an instance of the class with a specified message and transaction response.\n *\n * @param message - The message associated with the transaction.\n * @param lastSubmittedTransaction - The transaction response object containing details about the transaction.\n * @group Implementation\n */\n constructor(message: string, lastSubmittedTransaction: TransactionResponse | undefined) {\n super(message);\n this.lastSubmittedTransaction = lastSubmittedTransaction;\n }\n}\n\n/**\n * Represents an error that occurs when a transaction fails.\n * This error is thrown by the `waitForTransaction` function when the `checkSuccess` parameter is set to true.\n *\n * @param message - A description of the error.\n * @param transaction - The transaction response associated with the failure.\n * @group Implementation\n */\nexport class FailedTransactionError extends Error {\n public readonly transaction: TransactionResponse;\n\n constructor(message: string, transaction: TransactionResponse) {\n super(message);\n this.transaction = transaction;\n }\n}\n\n/**\n * Retrieves a block from the Aptos blockchain by its ledger version.\n * This function allows you to obtain detailed information about a specific block, including its transactions if requested.\n *\n * @param args - The arguments for retrieving the block.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos node.\n * @param args.ledgerVersion - The ledger version of the block to retrieve.\n * @param args.options - Optional parameters for the request.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block data.\n * @group Implementation\n */\nexport async function getBlockByVersion(args: {\n aptosConfig: AptosConfig;\n ledgerVersion: AnyNumber;\n options?: { withTransactions?: boolean };\n}): Promise<Block> {\n const { aptosConfig, ledgerVersion, options } = args;\n const { data: block } = await getAptosFullNode<{}, Block>({\n aptosConfig,\n originMethod: \"getBlockByVersion\",\n path: `blocks/by_version/${ledgerVersion}`,\n params: { with_transactions: options?.withTransactions },\n });\n\n return fillBlockTransactions({ block, ...args });\n}\n\n/**\n * Retrieves a block from the Aptos blockchain by its height.\n *\n * @param args - The parameters for retrieving the block.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network.\n * @param args.blockHeight - The height of the block to retrieve.\n * @param args.options - Optional parameters for the request.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block data.\n * @returns A promise that resolves to the block data, potentially including its transactions.\n * @group Implementation\n */\nexport async function getBlockByHeight(args: {\n aptosConfig: AptosConfig;\n blockHeight: AnyNumber;\n options?: { withTransactions?: boolean };\n}): Promise<Block> {\n const { aptosConfig, blockHeight, options } = args;\n const { data: block } = await getAptosFullNode<{}, Block>({\n aptosConfig,\n originMethod: \"getBlockByHeight\",\n path: `blocks/by_height/${blockHeight}`,\n params: { with_transactions: options?.withTransactions },\n });\n return fillBlockTransactions({ block, ...args });\n}\n\n/**\n * Fills in the block with transactions if not enough were returned. This function ensures that the block contains all relevant\n * transactions by fetching any missing ones based on the specified options.\n * @param args - The arguments for filling the block transactions.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.block - The block object that will be filled with transactions.\n * @param args.options - Optional settings for fetching transactions.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block.\n * @group Implementation\n */\nasync function fillBlockTransactions(args: {\n aptosConfig: AptosConfig;\n block: Block;\n options?: { withTransactions?: boolean };\n}) {\n const { aptosConfig, block, options } = args;\n if (options?.withTransactions) {\n // Transactions should be filled, but this ensures it\n block.transactions = block.transactions ?? [];\n\n const lastTxn = block.transactions[block.transactions.length - 1];\n const firstVersion = BigInt(block.first_version);\n const lastVersion = BigInt(block.last_version);\n\n // Convert the transaction to the type\n const curVersion: string | undefined = (lastTxn as any)?.version;\n let latestVersion;\n\n // This time, if we don't have any transactions, we will try once with the start of the block\n if (curVersion === undefined) {\n latestVersion = firstVersion - 1n;\n } else {\n latestVersion = BigInt(curVersion);\n }\n\n // If we have all the transactions in the block, we can skip out, otherwise we need to fill the transactions\n if (latestVersion === lastVersion) {\n return block;\n }\n\n // For now, we will grab all the transactions in groups of 100, but we can make this more efficient by trying larger\n // amounts\n const fetchFutures = [];\n const pageSize = 100n;\n for (let i = latestVersion + 1n; i < lastVersion; i += BigInt(100)) {\n fetchFutures.push(\n getTransactions({\n aptosConfig,\n options: {\n offset: i,\n limit: Math.min(Number(pageSize), Number(lastVersion - i + 1n)),\n },\n }),\n );\n }\n\n // Combine all the futures\n const responses = await Promise.all(fetchFutures);\n for (const txns of responses) {\n block.transactions.push(...txns);\n }\n }\n\n return block;\n}\n"],"mappings":"oQAwCA,eAAsBA,EAAgBC,EAGH,CACjC,GAAM,CAAE,YAAAC,EAAa,QAAAC,CAAQ,EAAIF,E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ursor","getGasPriceEstimation","memoizeAsync","data","getAptosFullNode","getTransactionByVersion","ledgerVersion","getTransactionByHash","transactionHash","isTransactionPending","e","longWaitForTransaction","waitForTransaction","timeoutSecs","checkSuccess","isPending","timeElapsed","lastTxn","lastError","backoffIntervalMs","backoffMultiplier","handleAPIError","AptosApiError","startTime","sleep","WaitForTransactionError","FailedTransactionError","waitForIndexer","processorType","minimumLedgerVersion","timeoutMilliseconds","indexerVersion","getIndexerLastSuccessVersion","getProcessorStatus","message","lastSubmittedTransaction","transaction","getBlockByVersion","block","fillBlockTransactions","getBlockByHeight","blockHeight","firstVersion","lastVersion","curVersion","latestVersion","fetchFutures","pageSize","i","responses","txns"]}
@@ -1,4 +1,4 @@
1
- import{a as l}from"./chunk-V5K2RRFT.mjs";import{a as i}from"./chunk-IF4UU2MT.mjs";import{bytesToHex as a,hexToBytes as g}from"@noble/hashes/utils";var u=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",s))(u||{}),e=class e extends l{constructor(t){if(super(),t.length!==e.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=a(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return a(this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let t=a(this.data).replace(/^0+/,"");return t===""?"0":t}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){t.serializeAsBytes(this)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let r=t.deserializeFixedBytes(e.LENGTH);return new e(r)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let r=e.fromString(t);if(t.length!==e.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(t,{maxMissingChars:r=4}={}){let n=t;if(t.startsWith("0x")&&(n=t.slice(2)),n.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(r>63||r<0)throw new i(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let o;try{o=g(n.padStart(64,"0"))}catch(h){throw new i(`Hex characters are invalid: ${h?.message}`,"invalid_hex_chars")}let d=new e(o);if(n.length<64-r&&!d.isSpecial())throw new i(`Hex string is too short, must be ${64-r} to 64 chars long, excluding the leading 0x. You may need to fix
1
+ import{a as l}from"./chunk-66F7RP7K.mjs";import{a as i}from"./chunk-IF4UU2MT.mjs";import{bytesToHex as a,hexToBytes as g}from"@noble/hashes/utils";var u=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",s))(u||{}),e=class e extends l{constructor(t){if(super(),t.length!==e.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=a(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return a(this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let t=a(this.data).replace(/^0+/,"");return t===""?"0":t}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){t.serializeAsBytes(this)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let r=t.deserializeFixedBytes(e.LENGTH);return new e(r)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let r=e.fromString(t);if(t.length!==e.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(t,{maxMissingChars:r=4}={}){let n=t;if(t.startsWith("0x")&&(n=t.slice(2)),n.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(r>63||r<0)throw new i(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let o;try{o=g(n.padStart(64,"0"))}catch(h){throw new i(`Hex characters are invalid: ${h?.message}`,"invalid_hex_chars")}let d=new e(o);if(n.length<64-r&&!d.isSpecial())throw new i(`Hex string is too short, must be ${64-r} to 64 chars long, excluding the leading 0x. You may need to fix
2
2
  the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
3
3
  Received ${t}`,"too_short");return d}static from(t,{maxMissingChars:r=4}={}){return typeof t=="string"?e.fromString(t,{maxMissingChars:r}):t instanceof Uint8Array?new e(t):t}static fromStrict(t){return typeof t=="string"?e.fromStringStrict(t):t instanceof Uint8Array?new e(t):t}static isValid(t){try{return t.strict?e.fromStrict(t.input):e.from(t.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,n)=>r===t.data[n])}};e.LENGTH=32,e.LONG_STRING_LENGTH=64,e.ZERO=e.from("0x0"),e.ONE=e.from("0x1"),e.TWO=e.from("0x2"),e.THREE=e.from("0x3"),e.FOUR=e.from("0x4"),e.A=e.from("0xA");var c=e;export{u as a,c as b};
4
- //# sourceMappingURL=chunk-VWLK43JM.mjs.map
4
+ //# sourceMappingURL=chunk-FDHHQUS3.mjs.map